cl
2024-01-23 6dadf36ef118fbb3b2cd5aca94cde88e29fb55dc
提交 | 用户 | 时间
71e81e 1 /**
2  * 详情对话框
3  */
4 var EquipmentMaintainPlanInfoDlg = {
5     data: {
6         id: "",
7         equipmentNo: "",
8         equipmentName: "",
9         planNo: "",
10         planName: "",
11         planType: "",
12         maintainType: "",
13         intervalTime: "",
14         intervalUnit: "",
15         state: "",
16         spareField1: "",
17         spareField2: "",
18         remarks: "",
19         createUser: "",
20         updateUser: "",
21         createTime: "",
22         updateTime: "",
23         startTime: "",
24         endTime: ""
25     }
26 };
27
28 layui.use(['table','form', 'admin', 'ax','laydate','upload','formSelects'], function () {
29     var $ = layui.jquery;
30     var $ax = layui.ax;
31     var form = layui.form;
32     var admin = layui.admin;
33     var table = layui.table;
34
35
36     var dataList = new Array();
37
38     /**
39      * 物料档案管理
40      */
41     var EqConfTable = {
42         tableId: "eqConfTable"
43     };
44     table.render({
45         elem: '#eqConfTable',page: true
46         , cols: [[ //标题栏
47             // {type: 'checkbox'},
48             {field: 'maintainContentCode',  title: '编号'},
49             {field: 'maintainContentName',  title: '名称'},
50             {field: 'maintainContentType',  title: '类型'},
51             {field: 'maintainContent',  title: '保养内容描述'},
52             {align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 120}
53         ]]
54         ,limit: 10
55         , data: dataList
56         , even: true
57     });
58
59     //获取详情信息,填充表单
60     var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainPlan/detail?id=" + Feng.getUrlParam("id"));
61     var result = ajax.start();
62     form.val('equipmentMaintainPlanForm', result.data);
63
64     var contentPlan = new $ax(Feng.ctxPath + "/equipmentMaintainContentPlan/detailByMaintainPlanNo?planNo=" + result.data.planNo);
65     var Planresult = contentPlan.start();
66
67     Planresult.forEach(function (val, index) {
68         var obj = {
69             'maintainContentCode': val.maintainContentCode,
70             'maintainContentName': val.maintainContentName,
71             'maintainContentType': val.maintainContentType,
72             'maintainContent': val.maintainContent,
73         };
74         dataList.push(obj);
75     });
76     table.reload(EqConfTable.tableId, {
77         data: dataList
78     });
79     table.reload(EqConfTable.tableId, {
80         data: Planresult
81     });
82     console.log("加载数据后的dataList状态"+dataList);
83
84     $('#btnAdds').click(function () {
85         console.log("点击保养计划配置")
86         EqConfTable.btnForProcess();
87     });
88
89     EqConfTable.btnForProcess = function () {
90         layer.open({
91             type: 2,
92             title: '保养内容',
93             area: ['800px', '650px'],
94             content: Feng.ctxPath + '/equipmentMaintainContentConf/addListConf',
95             end: function () {
96                 var info = $("#materialList").val();
97                 console.log(info)
98                 if (info != "") {
99                     var tempList = eval(info);
100                     tempList.forEach(function (val, index) {
101                         var obj = {
102                             'maintainContentCode': val.maintainContentCode,
103                             'maintainContentName': val.maintainContentName,
104                             'maintainContentType': val.maintainContentType,
105                             'maintainContent': val.maintainContent,
106                         };
107                         dataList.push(obj);
108                     });
109                     table.reload(EqConfTable.tableId, {
110                         data: dataList
111                     });
112                     $("#materialList").val("");
113                 }
114             }
115         });
116     };
117
118
119     // 工具条点击事件
120     table.on('tool(' + EqConfTable.tableId + ')', function (obj) {
121         var data = obj.data;
122         var layEvent = obj.event;
123
124         if (layEvent === 'delete') {
125             EqConfTable.onDeleteItem(data);
126         }
127     });
128
129     /**
130      * 点击删除
131      *
132      * @param data 点击按钮时候的行数据
133      */
134     EqConfTable.onDeleteItem = function (data) {
135         let operation = function () {
136             for (let i = 0; i < dataList.length; i++) {
137                 console.log(dataList[i].maintainContentCode)
138                 console.log(data.maintainContentCode)
139                 if (dataList[i].maintainContentCode === data.maintainContentCode) {
140                     dataList.splice(i, 1);
141                     Feng.success("删除成功!");
142                 }
143             }
144             table.reload(EqConfTable.tableId, {
145                 data: dataList
146             });
147         };
148         Feng.confirm("是否删除?", operation);
149     };
150
151     $('#cancel').click(function(){
152         window.location.href = Feng.ctxPath + '/equipmentMaintainPlan'
153     });
154
155     //表单提交事件
156     form.on('submit(btnSubmit)', function (data) {
157         var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainPlan/editItem", function (data) {
158             Feng.success("更新成功!");
159             window.location.href = Feng.ctxPath + '/equipmentMaintainPlan'
160         }, function (data) {
161             Feng.error("更新失败!" + data.responseJSON.message)
162         });
163         ajax.set(data.field);
164         ajax.set("dataList", JSON.stringify(dataList));
165         ajax.start();
166
167         return false;
168     });
169
170 });