123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <style>
- /* 自定义样式 */
- /*.layui-table-testcss .layui-table-header,*/
- /*.layui-form-testcss > div{margin-bottom: 6px;}*/
- </style>
- <div class="p-3 bg-white">
- <table class="layui-hide" id="record" lay-filter="record"></table>
- </div>
- <script type="text/html" id="toolbarrecord">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-sm" lay-event="add">+ 新建记录</button>
- </div>
- </script>
- <script>
- function record() {
- let tool = layui.tool, table = layui.table;
- //项目任务
- var allcount;
- parent.layui.recordTable = table.render({
- elem: '#record',
- title: '文档列表',
- toolbar: '#toolbarrecord',
- cellMinWidth: 80,
- parseData: function (res) { // 数据解析回调函数
- // 在这里可以获取数据总数
- allcount = res.data.length;
- return {
- code: res.code, // 数据状态码
- msg: res.msg, // 状态信息
- count: res.count, // 数据总数
- data: res.data // 当前页数据
- };
- },
- className: 'layui-table-testcss', // 用于给表格主容器追加 css 类名
- // lineStyle: 'height: 151px;', // 定义表格的多行样式
- url: "/admin/project.record/cplist",
- where: {'project_id': project_id},
- page: true, //开启分页
- limit: 20,
- cols: [[
- {field: 'id', title: '记录编号', width: 80, align: 'center',
- templet: function (d) {
- console.log(allcount,d.LAY_NUM)
- return allcount - (d.LAY_NUM - 1);
-
- }
- },
- {field: 'title', title: '记录内容',
- templet: function (d) {
- var html = '<a class="side-a" lay-event="detail">' + d.content + '</a>';
- return html;
- }
- },
- {field: 'create_time', title: '创建时间', align: 'center', width: 150},
- {field: 'admin_name', title: '创建人', align: 'center', width: 100},
- {field: 'right', fixed: 'right', title: '操作', width: 100, align: 'center',
- templet: function (d) {
- var html = '<div class="layui-btn-group">';
- var btn1 = '<span class="layui-btn layui-btn-xs" lay-event="edit">编辑</span>';
- var btn2 = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span>';
- return html + btn1 + btn2 + '</div>';
- }
- }
- ]]
- });
- //触发事件
- table.on('toolbar(record)', function (obj) {
- var checkStatus = table.checkStatus(obj.config.id);
- switch (obj.event) {
- case 'add':
- parent.layui.tool.side('/admin/project.record/add?project_id=' + project_id); // 项目id
- break;
- }
- });
- table.on('tool(record)', function (obj) {
- var data = obj.data; //获得当前行数据
- if (obj.event === 'detail') { //查看
- let url = '/admin/project.record/view?id=' + data.id;// 项目id
- parent.layui.tool.side(url);
- }
- if (obj.event === 'edit') {
- parent.layui.tool.side('/admin/project.record/edit?id=' + data.id); // 项目id
- return;
- }
- if (obj.event === 'del') {
- layer.confirm('确定要删除吗?', {
- icon: 3,
- title: '提示'
- }, function (index) {
- let callback = function (e) {
- layer.msg(e.msg);
- if (e.code == 0) {
- obj.del();
- }
- }
- tool.delete("/admin/project.record/del", {id: data.id}, callback);// 项目id
- layer.close(index);
- });
- }
- })
- }
- </script>
|