This commit is contained in:
chenyang
2022-07-10 14:31:13 +08:00
parent da6f349faa
commit 6c2ddd2955
3 changed files with 16 additions and 9 deletions
+3 -3
View File
@@ -37,7 +37,7 @@ class CooperationMindLog(AbstractModel):
"""
操作日志表
"""
coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False)
coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE)
log_uuid = models.CharField(verbose_name='操作UUID', max_length=64, null=False, blank=False)
log_content = models.CharField(verbose_name='操作内容', max_length=1024, null=False, blank=False)
operator_user_id = models.BigIntegerField(verbose_name='操作人', null=True)
@@ -59,7 +59,7 @@ class CooperationMindShare(AbstractModel):
"""
分享记录表
"""
coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False)
coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE)
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False)
share_uuid = models.CharField(verbose_name='分享uuid', max_length=128, null=False, blank=False)
share_uuid_hash = models.BigIntegerField(verbose_name='分享uuid_hash', null=False, blank=False)
@@ -80,7 +80,7 @@ class CooperationMindStar(AbstractModel):
收藏记录表
"""
user_id = models.BigIntegerField(verbose_name='收藏人', null=False)
coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False)
coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE)
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False)
class Meta:
+2 -2
View File
@@ -49,7 +49,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
elif 'share' == src_page:
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'))
self.queryset = CooperationMind.objects.annotate(share_new=Exists(share), ).filter(share_new=1)
self.queryset = CooperationMind.objects.annotate(share_new=Exists(share), ).filter(share_new=1).values('id', 'coop_mind_name', "client_uuid", "data_format")
else:
# 不返回数据
self.queryset = CooperationMind.objects.filter(creator_user_id=-100).values('id', 'coop_mind_name', "client_uuid", "data_format")
@@ -123,7 +123,7 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView):
def get(self, request, *args, **kwargs):
"""
通过链接即uuid获得分享的导图,默认有uuid就能进入界面查看
通过链接即uuid、hash获得分享的导图详情
"""
share_uuid_hash = request.GET.get('h')
share_uuid = request.GET.get('u')
+11 -4
View File
@@ -112,7 +112,8 @@
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
} else if (src_page === 'share') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>`
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="">查看分享链接</a>`
}
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
@@ -139,9 +140,17 @@
async: false
});
},
/**显示分享链接*/
show_share_url: function (u, h) {
const url = `s_2_d?u=${u}&h=${h}`
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
$('#share_mind_modal_a').click()
},
/**分页组件*/
init_pagination: function (count, page_size) {
/**计算页数*/
if (count <= 0) return
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
const container = $('#pagination_div')
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
@@ -197,9 +206,7 @@
data: {'id': mind_id},
dataType: "json",
success: function (resp) {
const url = `s_2_d?u=${resp.data.u}&h=${resp.data.h}`
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
$('#share_mind_modal_a').click()
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
},
async: false
});