list 页面查询

This commit is contained in:
aqu415
2022-02-13 12:47:30 +08:00
parent 4efc6c6028
commit accbabb746
8 changed files with 176 additions and 36 deletions
+95 -20
View File
@@ -49,7 +49,30 @@
},
// 获取数据
fetch_data: function () {
console.log(this.opts)
const get_param = {'page': this.current_page, 'page_size': this.limit}
if (this.get_coop_mind_name()) {
get_param.coop_mind_name = this.get_coop_mind_name()
}
$.get('list', get_param, function (resp) {
console.log(resp)
$('#layui-table tbody').empty()
const results = resp.results
results.forEach(item => {
const tr = `<tr>
<td>${item.coop_mind_name}</td>
<td>${item.creator}</td>
<td>${item.create_time}</td>
<td>${item.update_time}</td>
<td></td>
</tr>`
$('#layui-table tbody').append(tr)
})
})
// 分页组件
this.auto_page_bar()
},
get_coop_mind_name: function () {
return $('#mind_name').val()
},
// 显示分页组件
auto_page_bar: function () {
@@ -75,6 +98,17 @@
}
}
return target;
},
json2string: function (json) {
if (!!JSON) {
try {
return JSON.stringify(json);
} catch (e) {
logger.warn(e);
logger.warn('can not convert to string');
return null;
}
}
}
}
@@ -83,13 +117,59 @@
const view = new listView({'page_bar_elem': 'page_bar'})
view.init()
view.fetch_data()
view.auto_page_bar()
// 绑定事件
$('#c_').click(function () {
const mind_name = $('#mind_name').val()
if (mind_name) {
$.post('create', {'mind_name': mind_name}, function (resp) {
const snapshot_data = {
id: 'root',
topic: 'jsMind',
children: [
{
id: 'easy',
topic: 'Easy',
direction: 'left',
expanded: false,
children: [
{id: 'easy1', topic: 'Easy to show'},
{id: 'easy2', topic: 'Easy to edit'},
{id: 'easy3', topic: 'Easy to store'},
{id: 'easy4', topic: 'Easy to embed'}
]
},
{
id: 'open',
topic: 'Open Source',
direction: 'right',
expanded: true,
children: [
{id: 'open1', topic: 'on GitHub'},
{id: 'open2', topic: 'BSD License'}
]
},
{
id: 'powerful',
topic: 'Powerful',
direction: 'right',
children: [
{id: 'powerful1', topic: 'Base on Javascript'},
{id: 'powerful2', topic: 'Base on HTML5'},
{id: 'powerful3', topic: 'Depends on you'}
]
},
{
id: 'other',
topic: 'test node',
direction: 'left',
children: [
{id: 'other1', topic: "I'm from local variable"},
{id: 'other2', topic: 'I can do everything'}
]
}
]
}
$.post('create', {'mind_name': mind_name, 'snapshot_data': view.json2string(snapshot_data)}, function (resp) {
console.log(resp)
view.fetch_data()
})
@@ -103,35 +183,30 @@
<body>
<div style="margin-top: 5px;">
<div class="layui-input-inline">
<input name="mind_name" required lay-verify="required" placeholder="请输入思维导图名称" autocomplete="off" class="layui-input" id="mind_name">
<input name="mind_name" required lay-verify="required" autocomplete="off" class="layui-input" id="mind_name" value="pp">
</div>
<button type="button" class="layui-btn" id="c_">创建导图</button>
<button type="button" class="layui-btn">搜索</button>
</div>
<table class="layui-table">
<table class="layui-table" id="layui-table">
<colgroup>
<col width="150">
<col width="200">
<col width="500">
<col width="100">
<col width="300">
<col width="300">
<col>
</colgroup>
<thead>
<tr>
<th>昵称</th>
<th>加入时间</th>
<th>签名</th>
<th>名称</th>
<th>创建人</th>
<th>创建时间</th>
<th>更新时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>贤心</td>
<td>2016-11-29</td>
<td>人生就像是一场修行</td>
</tr>
<tr>
<td>许闲心</td>
<td>2016-11-28</td>
<td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
</tr>
</tbody>
</table>
<div id="page_bar"></div>