123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <div class="p-3 bg-white">
- <table class="layui-hide" id="appointment" lay-filter="appointment"></table>
- </div>
- <script type="text/html" id="toolbarappointment">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-sm" lay-event="add">+ 新增预约</button>
- </div>
- </script>
- <script>
- function appointment() {
- let tool = layui.tool, table = layui.table;
- //项目任务
- var allcount;
- parent.layui.appointmentTable = table.render({
- elem: '#appointment',
- title: '文档列表',
- toolbar: '#toolbarappointment',
- cellMinWidth: 80,
- parseData: function (res) { // 数据解析回调函数
- // 在这里可以获取数据总数
- allcount = res.data.length;
- return {
- code: res.code, // 数据状态码
- msg: res.msg, // 状态信息
- count: res.count, // 数据总数
- data: res.data // 当前页数据
- };
- },
- url: "/admin/project.appointment/datalist",
- where: {'project_id': project_id},
- page: false, //开启分页
- 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: 'appointment_time', title: '预约时间',align: 'center', width: 200},
- {field: 'dispatch_num', title: '派遣人数', align: 'center', width: 100},
- {field: 'address_or_remark', title: '地址/备注', align: 'center'},
- {field: 'sponsor_name', title: '发起人', align: 'center', width: 100},
- {field: 'approval_name', title: '审批人', align: 'center', width: 100},
- {field: 'audit_status', title: '状态', align: 'center', width: 100,templet:function(d){
- if(d.audit_status==0){
- return "待审核"
- }else if(d.audit_status==1){
- return "通过"
- }else if(d.audit_status==2){
- return "拒绝"
- }
- }},
- {field: 'audit_remark', title: '回执', align: 'center', width: 150},
- {field: 'right', fixed: 'right', title: '操作', width: 100, align: 'center',
- templet: function (d) {
- if(d.operate && d.audit_status==0){
- var html = '<div class="layui-btn-group">';
- var btn1 = '<span class="layui-btn layui-btn-xs" lay-event="agree">同意</span>';
- var btn2 = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="disagree">拒绝</span>';
- return html + btn1 + btn2 + '</div>';
- }else{
- return "";
- }
-
- }
- }
- ]]
- });
- //触发事件
- table.on('toolbar(appointment)', function (obj) {
- var checkStatus = table.checkStatus(obj.config.id);
- switch (obj.event) {
- case 'add':
- parent.layui.tool.side('/admin/project.appointment/add?project_id=' + project_id); // 项目id
- break;
- }
- });
- table.on('tool(appointment)', function (obj) {
- var data = obj.data; //获得当前行数据
- console.log(data);
- if (obj.event === 'agree') {
- layer.prompt({
- title: '请输入<span style="color: green">回执</span>',
- formType: 2,
- area: ['35vw', '15vw']
- }, function (text, index) {
- let callback = function (e) {
- parent.layui.appointmentTable.reload()
- layer.msg(e.msg);
- setTimeout(function () {
- layer.close(index);
- }, 2000)
- }
- if (text !== "") {
- tool.post("/admin/project.appointment/agree", {id: data.id,audit_remark:text,project_id:data.project_id}, callback);// 项目id
- } else {
- layer.msg("回执不能为空")
- }
- })
- return;
- }
- if (obj.event === 'disagree') {
- layer.prompt({
- title: '请输入<span style="color: red">回执</span>',
- formType: 2,
- area: ['35vw', '15vw']
- }, function (text, index) {
- let callback = function (e) {
- parent.layui.appointmentTable.reload()
- layer.msg(e.msg);
- setTimeout(function () {
- layer.close(index);
- }, 2000)
- }
- if (text !== "") {
- tool.post("/admin/project.appointment/disagree", {id: data.id,audit_remark:text,project_id:data.project_id}, callback);// 项目id
- } else {
- layer.msg("回执不能为空")
- }
- })
-
-
- return;
- }
- })
- }
- </script>
|