update
This commit is contained in:
+42
-35
@@ -66,6 +66,7 @@
|
||||
if (!page_size) {
|
||||
page_size = me.default_page_size
|
||||
}
|
||||
me.current_page_num = current_page
|
||||
$.ajax({
|
||||
type: `get`,
|
||||
url: `list?page=${current_page}&page_size=${page_size}`,
|
||||
@@ -85,32 +86,22 @@
|
||||
results.forEach(function (item) {
|
||||
const uuid = me.get_uu_id()
|
||||
const content = `
|
||||
<div class="card col-3" style="margin: 6px;" id='card_${uuid}'>
|
||||
<div class="card col-3" style="margin: 6px;margin-left: 20px;" id='card_${uuid}'>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${item.coop_mind_name}</h5>
|
||||
<img src="https://img0.baidu.com/it/u=218959243,558802769&fm=253&fmt=auto&app=138&f=JPEG" class="card-img-top" style="height: 100px;">
|
||||
<div class="card-title" style="margin-bottom: 0px;text-overflow:ellipsis;font-weight:bold;line-height: 1rem">${item.coop_mind_name}</div>
|
||||
<hr style="margin: 0">
|
||||
<div style="height: 80px;"></div>
|
||||
<div style="text-align:right;">
|
||||
<a href="#" class="btn btn-info" onclick="window.open('detail?id=${item.id}')">编辑</a>
|
||||
<a href="#" class="btn btn-info" onclick="del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
<a href="#" class="btn btn-info" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
</div>`
|
||||
row.append(content)
|
||||
idx++
|
||||
if (idx % 3 === 0) {
|
||||
// 3个一行
|
||||
$('main .container-fluid').append(row)
|
||||
// 重置row
|
||||
row = $(`<div class="row"></row>`)
|
||||
}
|
||||
})
|
||||
|
||||
// 如果不是3的整数倍,将剩余的添加
|
||||
if (idx % 3 !== 0) {
|
||||
$('main .container-fluid').append(row)
|
||||
}
|
||||
|
||||
$('main .container-fluid').append(row)
|
||||
me.init_pagination(resp.count, me.default_page_size)
|
||||
// success end
|
||||
},
|
||||
@@ -119,19 +110,22 @@
|
||||
},
|
||||
/**分页组件*/
|
||||
init_pagination: function (count, page_size) {
|
||||
const all_page = (count > page_size && count % page_size > 0) ? (count % page_size) + 1 : count % page_size
|
||||
/**计算页数*/
|
||||
console.log(Math.floor(count / page_size))
|
||||
|
||||
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>`)
|
||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||
|
||||
if (this.current_page_num > 1) {
|
||||
navigation_ul.append(`<li class="page-item disabled"><a class="page-link">上一页</a></li>`)
|
||||
navigation_ul.append(`<li class="page-item disabled"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
|
||||
}
|
||||
for (let i = 0; i < all_page; i++) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="#">${i + 1}</a></li>`)
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
|
||||
}
|
||||
if (this.current_page_num < all_page) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="#">下一页</a></li>`)
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
|
||||
}
|
||||
navigation.append(navigation_ul)
|
||||
container.empty()
|
||||
@@ -306,11 +300,13 @@
|
||||
if (resp.code === 0) {
|
||||
me.fetch_mind()
|
||||
$('#newMindModal').modal('hide')
|
||||
// 新页面打开
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('detail?id=' + id)
|
||||
}, 500)
|
||||
if ($('#exampleCheck1').prop("checked")) {
|
||||
/**新页面打开*/
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('detail?id=' + id)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
@@ -318,8 +314,24 @@
|
||||
async: false
|
||||
});
|
||||
})
|
||||
/** 新建后打开复选框勾选事件*/
|
||||
$('#exampleCheck1').change(function () {
|
||||
const checked = $(this).prop("checked")
|
||||
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
|
||||
})
|
||||
|
||||
/** modal 显示完毕后事件*/
|
||||
$('#newMindModal').on('shown.bs.modal', function () {
|
||||
const cookie_checked_ = $.cookie('open_aft_create')
|
||||
if (cookie_checked_) {
|
||||
$('#exampleCheck1').attr('checked', 'checked')
|
||||
} else {
|
||||
$('#exampleCheck1').removeAttr('checked');
|
||||
}
|
||||
})
|
||||
/************************************* jq_listener_init end *******************************************/
|
||||
}
|
||||
// prototype end
|
||||
/** prototype end **/
|
||||
}
|
||||
|
||||
|
||||
@@ -331,7 +343,7 @@
|
||||
|
||||
/**如果已经登录则查询列表*/
|
||||
view.fetch_mind()
|
||||
window.mindView = view
|
||||
window.mind = view
|
||||
// js end
|
||||
})
|
||||
</script>
|
||||
@@ -345,7 +357,7 @@
|
||||
<ul class="navbar-nav px-3">
|
||||
<li class="nav-item text-nowrap">
|
||||
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mindView.logout_()" style="display: none;">注销</a>
|
||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -390,14 +402,10 @@
|
||||
|
||||
<!-- 右侧内容 start-->
|
||||
<main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-md-4" id="main">
|
||||
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">全部文件</h1>
|
||||
</div>
|
||||
<div>
|
||||
<h5 class="h5">全部文件</h5>
|
||||
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#newMindModal">新建导图</button>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
<!--
|
||||
<div class="row">
|
||||
@@ -412,7 +420,6 @@
|
||||
-->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- navigation start-->
|
||||
<div id="pagination_div"></div>
|
||||
<!-- navigation end-->
|
||||
|
||||
+10
-10
@@ -26,8 +26,8 @@
|
||||
coop_api_url: null,
|
||||
// websocket 地址
|
||||
coop_ws_url: null,
|
||||
// 标记当前客户端(同一个IP可能打开多个浏览器,需要用client_id区分)
|
||||
client_id: null,
|
||||
// 标记当前客户端(同一个IP可能打开多个浏览器,需要用client_uuid区分)
|
||||
client_uuid: null,
|
||||
// 当前脑图ID
|
||||
coop_mind_id: null,
|
||||
// 上一次操作日志ID
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
_init_properties: function (_jm) {
|
||||
// 设置属性
|
||||
this.client_id = Jm.util.uuid.newid()
|
||||
this.client_uuid = Jm.util.uuid.newid()
|
||||
this.coop_api_url = _jm.options.coop_api_url
|
||||
this.coop_ws_url = _jm.options.coop_ws_url
|
||||
this.coop_mind_id = _jm.options.coop_mind_id
|
||||
@@ -127,7 +127,7 @@
|
||||
* 构建公共参数
|
||||
*/
|
||||
_build_evt_param: function () {
|
||||
return {'client_id': this.client_id, 'log_uuid': Jm.util.uuid.newid(), 'coop_mind_id': this.coop_mind_id}
|
||||
return {'client_uuid': this.client_uuid, 'log_uuid': Jm.util.uuid.newid(), 'coop_mind_id': this.coop_mind_id}
|
||||
},
|
||||
// 调用jsmind接口
|
||||
_handle_jsmind_with_ws_message: function (message) {
|
||||
@@ -137,16 +137,16 @@
|
||||
// 处理消息广告方法
|
||||
_handle_msg_inner(msg_json, is_batch) {
|
||||
|
||||
// 校验 client_id
|
||||
const client_id = msg_json.client_id
|
||||
if (!client_id) {
|
||||
// 校验 client_uuid
|
||||
const client_uuid = msg_json.client_uuid
|
||||
if (!client_uuid) {
|
||||
return
|
||||
}
|
||||
const log_content = JSON.parse(msg_json.log_content)
|
||||
const log_id = msg_json.id
|
||||
if (log_id > this.coop_mind_log_id) {
|
||||
// 第一次批量获得日志和被动接收日志,设置coop_mind_log_last_id和coop_mind_log_id 相同,不进行批量保存快照
|
||||
if (is_batch || client_id !== this.client_id) {
|
||||
if (is_batch || client_uuid !== this.client_uuid) {
|
||||
this.coop_mind_log_last_id = log_id
|
||||
} else {
|
||||
// 设置 coop_mind_log_last_id 便于批量保存快照
|
||||
@@ -156,7 +156,7 @@
|
||||
}
|
||||
|
||||
// 回放
|
||||
if (client_id === this.client_id) {
|
||||
if (client_uuid === this.client_uuid) {
|
||||
console.log('self msg')
|
||||
} else {
|
||||
const evt = log_content.evt
|
||||
@@ -229,7 +229,7 @@
|
||||
me.timer_push_task = setInterval(function () {
|
||||
const param = {
|
||||
'data': Jm.util.json.json2string(me._jm.get_data('node_tree').data),
|
||||
'client_id': me.client_id,
|
||||
'client_uuid': me.client_uuid,
|
||||
'coop_mind_id': me.coop_mind_id,
|
||||
'coop_mind_log_id': me.coop_mind_log_id,
|
||||
'type': 'snapshot',
|
||||
|
||||
@@ -91,6 +91,10 @@ const modal = `
|
||||
<div style="text-align:right;">
|
||||
<button type="button" class="btn btn-info" id="new_mind_btn">确认创建</button>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox" class="form-check-input" id="exampleCheck1">
|
||||
<label class="form-check-label" for="exampleCheck1">新建后打开</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!--end-->
|
||||
|
||||
Reference in New Issue
Block a user