update
This commit is contained in:
@@ -165,3 +165,17 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
|
|
||||||
# 重复分享
|
# 重复分享
|
||||||
return build_response(code=DUPLICATE, data={"u": share.share_uuid, "h": share.share_uuid_hash})
|
return build_response(code=DUPLICATE, data={"u": share.share_uuid, "h": share.share_uuid_hash})
|
||||||
|
|
||||||
|
def delete(self, request):
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
post_body = request.POST
|
||||||
|
id = post_body.get('id')
|
||||||
|
user = request.user
|
||||||
|
if id is None:
|
||||||
|
return build_response(code=CODE_FAILED, msg='参数错误')
|
||||||
|
if user.id is None:
|
||||||
|
return build_response(code=CODE_FAILED, msg='用户未登录')
|
||||||
|
res = CooperationMindShare.objects.filter(coop_mind_id=id, operator_user_id=user.id).delete()
|
||||||
|
return build_response(msg="操作成功", data=res[0])
|
||||||
|
|||||||
+55
-21
@@ -22,11 +22,12 @@
|
|||||||
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||||
this.current_page_num = 1
|
this.current_page_num = 1
|
||||||
this.default_page_size = 15
|
this.default_page_size = 15
|
||||||
|
this.title_map = new Map([["main", "全部文件"], ["share", "我的分享"]]);// k-v 的形式
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultView.prototype = {
|
DefaultView.prototype = {
|
||||||
/**界面初始化*/
|
/**界面初始化*/
|
||||||
view_init: function () {
|
init_view: function () {
|
||||||
const uid = $('#uid').html()
|
const uid = $('#uid').html()
|
||||||
// 未登录
|
// 未登录
|
||||||
if (!uid || isNaN(uid)) {
|
if (!uid || isNaN(uid)) {
|
||||||
@@ -40,6 +41,10 @@
|
|||||||
$('#login_register').hide()
|
$('#login_register').hide()
|
||||||
$('#logout_a').show()
|
$('#logout_a').show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断页面
|
||||||
|
const src_page = this.get_src_page()
|
||||||
|
$('#main h5').html(this.title_map.get(src_page))
|
||||||
},
|
},
|
||||||
get_uu_id: function () {
|
get_uu_id: function () {
|
||||||
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||||
@@ -78,7 +83,6 @@
|
|||||||
|
|
||||||
// 获得跳转源页面
|
// 获得跳转源页面
|
||||||
const src_page = me.get_src_page()
|
const src_page = me.get_src_page()
|
||||||
console.log(src_page)
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: `get`,
|
type: `get`,
|
||||||
@@ -96,26 +100,34 @@
|
|||||||
const results = resp.results
|
const results = resp.results
|
||||||
let idx = 0
|
let idx = 0
|
||||||
let row = $(`<div class="row"></row>`)
|
let row = $(`<div class="row"></row>`)
|
||||||
|
|
||||||
|
|
||||||
results.forEach(function (item) {
|
results.forEach(function (item) {
|
||||||
const uuid = me.get_uu_id()
|
const uuid = me.get_uu_id()
|
||||||
const content = `
|
|
||||||
<div class="card col-2" style="margin: 6px;margin-left: 20px;" id='card_${uuid}'>
|
// 添加按钮组
|
||||||
<div class="card-body">
|
let sub_btn;
|
||||||
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
|
if (src_page === 'main') {
|
||||||
<hr style="margin: 0">
|
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}')">编辑</a>
|
||||||
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}')">
|
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||||
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
|
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
|
||||||
<div class="btn-group btn-group-sm" role="group">
|
} else if (src_page === 'share') {
|
||||||
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
|
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>`
|
||||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
|
}
|
||||||
<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}')">编辑</a>
|
|
||||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
|
||||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>
|
<div class="card-body">
|
||||||
</div>
|
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
|
||||||
</div>
|
<hr style="margin: 0">
|
||||||
</div>
|
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}')">
|
||||||
</div>
|
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
|
||||||
</div>`
|
<div class="btn-group btn-group-sm" role="group">
|
||||||
|
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
row.append(content)
|
row.append(content)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -192,6 +204,28 @@
|
|||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/**取消分享*/
|
||||||
|
share_cancel: function (mind_id) {
|
||||||
|
const me = this
|
||||||
|
$.ajax({
|
||||||
|
type: "delete",
|
||||||
|
url: "share",
|
||||||
|
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||||
|
data: {'id': mind_id},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (resp) {
|
||||||
|
if (me.is_success_resp(resp)) {
|
||||||
|
location.reload()
|
||||||
|
} else {
|
||||||
|
common_alert(resp.msg)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
},
|
||||||
|
is_success_resp(resp) {
|
||||||
|
return resp.code === 0
|
||||||
|
},
|
||||||
/** 清除注册时输入内容 */
|
/** 清除注册时输入内容 */
|
||||||
clear_reg_info: function () {
|
clear_reg_info: function () {
|
||||||
$('#userName').val('');
|
$('#userName').val('');
|
||||||
@@ -384,7 +418,7 @@
|
|||||||
$(function () {
|
$(function () {
|
||||||
const view = new DefaultView()
|
const view = new DefaultView()
|
||||||
/**初始化*/
|
/**初始化*/
|
||||||
view.view_init()
|
view.init_view()
|
||||||
view.jq_listener_init()
|
view.jq_listener_init()
|
||||||
|
|
||||||
/**如果已经登录则查询列表*/
|
/**如果已经登录则查询列表*/
|
||||||
|
|||||||
Reference in New Issue
Block a user