This commit is contained in:
aqu415
2022-02-13 13:43:31 +08:00
parent 14da24d469
commit a7a6efc18b
+33 -21
View File
@@ -51,8 +51,8 @@
fetch_data: function () { fetch_data: function () {
const me = this const me = this
const get_param = {'page': this.current_page, 'page_size': this.limit} const get_param = {'page': this.current_page, 'page_size': this.limit}
if (this.get_coop_mind_name()) { if (this.get_search_coop_mind_name()) {
get_param.coop_mind_name = this.get_coop_mind_name() get_param.coop_mind_name = this.get_search_coop_mind_name()
} }
$.get('list', get_param, function (resp) { $.get('list', get_param, function (resp) {
// 清空数据 // 清空数据
@@ -78,7 +78,7 @@
me.auto_page_bar() me.auto_page_bar()
}) })
}, },
get_coop_mind_name: function () { get_search_coop_mind_name: function () {
return $('#mind_name').val() return $('#mind_name').val()
}, },
// 显示分页组件 // 显示分页组件
@@ -126,17 +126,35 @@
view.fetch_data() view.fetch_data()
// 绑定事件 // 搜索
$('#search').click(function () {
view.fetch_data()
})
// 清空
$('#clear').click(function () {
$('#mind_name').val('')
view.fetch_data()
})
// 创建
$('#crt_out').click(function () { $('#crt_out').click(function () {
const content_html = `<div style="margin-left: 30px;margin-top: 20px;">
<div class="layui-input-inline">
<div class="layui-input-inline"><input required autocomplete="off" class="layui-input" id="mind_name_crt" value="pp"></div>
</div>
<button type="button" class="layui-btn" id="crt_inner">创建</button>
</div>`
layer.open({ layer.open({
type: 1, type: 1,
content: $('#layer_open'), //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响 content: content_html, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
area: ['400px', '200px'] area: ['400px', '200px']
}); });
// 调用后台创建脑图
$('#crt_inner').click(crt_inner)
//
}) })
// 调用后台创建脑图 function crt_inner() {
$('#crt_inner').click(function () {
const mind_name = $('#mind_name_crt').val() const mind_name = $('#mind_name_crt').val()
if (mind_name) { if (mind_name) {
const snapshot_data = { const snapshot_data = {
@@ -158,8 +176,8 @@
{ {
id: 'open', id: 'open',
topic: 'Open Source', topic: 'Open Source',
direction: 'right', direction: 'left',
expanded: true, expanded: false,
children: [ children: [
{id: 'open1', topic: 'on GitHub'}, {id: 'open1', topic: 'on GitHub'},
{id: 'open2', topic: 'BSD License'} {id: 'open2', topic: 'BSD License'}
@@ -169,6 +187,7 @@
id: 'powerful', id: 'powerful',
topic: 'Powerful', topic: 'Powerful',
direction: 'right', direction: 'right',
expanded: false,
children: [ children: [
{id: 'powerful1', topic: 'Base on Javascript'}, {id: 'powerful1', topic: 'Base on Javascript'},
{id: 'powerful2', topic: 'Base on HTML5'}, {id: 'powerful2', topic: 'Base on HTML5'},
@@ -185,15 +204,16 @@
} }
] ]
} }
// // post start
$.post('create', {'mind_name': mind_name, 'snapshot_data': view.json2string(snapshot_data)}, function (resp) { $.post('create', {'mind_name': mind_name, 'snapshot_data': view.json2string(snapshot_data)}, function (resp) {
layer.closeAll() layer.closeAll()
view.fetch_data() view.fetch_data()
}) })
// post end
} else { } else {
layer.msg('请输入导图名称') layer.msg('请输入导图名称')
} }
}) }
// //
}) })
</script> </script>
@@ -203,7 +223,8 @@
<div class="layui-input-inline"> <div class="layui-input-inline">
<input autocomplete="off" class="layui-input" id="mind_name"> <input autocomplete="off" class="layui-input" id="mind_name">
</div> </div>
<button type="button" class="layui-btn">搜索</button> <button type="button" class="layui-btn" id="search">搜索</button>
<button type="button" class="layui-btn" id="clear">清空</button>
<button type="button" class="layui-btn" id="crt_out">创建导图</button> <button type="button" class="layui-btn" id="crt_out">创建导图</button>
</div> </div>
<table class="layui-table" id="layui-table"> <table class="layui-table" id="layui-table">
@@ -227,14 +248,5 @@
</tbody> </tbody>
</table> </table>
<div id="page_bar"></div> <div id="page_bar"></div>
<!-- 弹出层 start-->
<div style="display: none;margin-left: 30px;margin-top: 20px;" id="layer_open">
<div class="layui-input-inline">
<div class="layui-input-inline"><input required autocomplete="off" class="layui-input" id="mind_name_crt" value="pp"></div>
</div>
<button type="button" class="layui-btn" id="crt_inner">创建</button>
</div>
<!-- 弹出层 end-->
</body> </body>
</html> </html>