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     var laydate = layui.laydate;
35
36
37     var dataList = new Array();
38
39     laydate.render({
40         elem: '#startTime' //指定元素
41     });
42
43     laydate.render({
44         elem: '#endTime' //指定元素
45     });
46
47     $(document).ready(function () {
48         var ajax1 = new $ax(Feng.ctxPath + "/equipmentMaintainPlan/planNumberGenerate");
49         var result1 = ajax1.start();
50         console.log(result1.data);
51         $("#planNo").val(result1.data)
52
53         $(document).ready(function () {
54             $.ajax({
55                 type: "POST",
56                 contentType: "application/json;charset=UTF-8",
57                 url: Feng.ctxPath + '/equipmentMaintainPlan/getIntervalUnit',
58                 success: function (result) {
59                     console.log(result);
60                     $.each(result.data, function (index, value) {
61                         $('#intervalUnit').append(new Option(value.name));// 下拉菜单里添加元素
62                     });
63                     layui.form.render("select");//重新渲染 固定写法
64                 },
65             });
66         });
67     });
68
69
70     //表单提交事件
71     form.on('submit(btnSubmit)', function (data) {
72         if(dataList.length === 0){
73             Feng.error("请配置保养内容!");
74             return false;
75         }else {
76             var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainPlan/addItem", function (data) {
77                 Feng.success("添加成功!");
78                 window.location.href = Feng.ctxPath + '/equipmentMaintainPlan'
79             }, function (data) {
80                 Feng.error("添加失败!" + data.responseJSON.message)
81             });
82             ajax.set(data.field);
83             ajax.set("dataList", JSON.stringify(dataList));
84             ajax.start();
85             return false;
86         }
87     });
88
89     /**
90      * 物料档案管理
91      */
92     var EqConfTable = {
93         tableId: "eqConfTable"
94     };
95     table.render({
96         elem: '#eqConfTable',page: true
97         , cols: [[ //标题栏
98             // {type: 'checkbox'},
99             {field: 'maintainContentCode',  title: '编号'},
100             {field: 'maintainContentName',  title: '名称'},
101             {field: 'maintainContentType',  title: '类型'},
102             {field: 'maintainContent',  title: '保养内容描述'},
103             {align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 120}
104         ]]
105         ,limit: 10
106         , data: dataList
107         , even: true
108     });
109
110     table.reload(EqConfTable.tableId, {
111         data: dataList
112     });
113
114     $('#btnAdds').click(function () {
115         console.log("点击保养计划配置")
116         EqConfTable.btnForProcess();
117     });
118
119     EqConfTable.btnForProcess = function () {
120         layer.open({
121             type: 2,
122             title: '保养内容',
123             area: ['800px', '650px'],
124             content: Feng.ctxPath + '/equipmentMaintainContentConf/addListConf',
125             end: function () {
126                 var info = $("#materialList").val();
127                 console.log(info)
128                 if (info != "") {
129                     var tempList = eval(info);
130                     tempList.forEach(function (val, index) {
131                         var obj = {
132                             'maintainContentCode': val.maintainContentCode,
133                             'maintainContentName': val.maintainContentName,
134                             'maintainContentType': val.maintainContentType,
135                             'maintainContent': val.maintainContent,
136                         };
137                         dataList.push(obj);
138                     });
139                     table.reload(EqConfTable.tableId, {
140                         data: dataList
141                     });
142                     $("#materialList").val("");
143                 }
144             }
145         });
146     };
147
148     // 工具条点击事件
149     table.on('tool(' + EqConfTable.tableId + ')', function (obj) {
150         var data = obj.data;
151         var layEvent = obj.event;
152
153         if (layEvent === 'delete') {
154             EqConfTable.onDeleteItem(data);
155         }
156     });
157
158     /**
159      * 点击删除
160      *
161      * @param data 点击按钮时候的行数据
162      */
163     EqConfTable.onDeleteItem = function (data) {
164         var operation = function () {
165             for (var i = 0; i < dataList.length; i++) {
166                 console.log(dataList[i].maintainContentCode)
167                 console.log(data.maintainContentCode)
168                 if (dataList[i].maintainContentCode == data.maintainContentCode) {
169                     dataList.splice(i, 1);
170                     Feng.success("删除成功!");
171                 }
172             }
173             table.reload(EqConfTable.tableId, {
174                 data: dataList
175             });
176         };
177         Feng.confirm("是否删除?", operation);
178     };
179
180     $('#cancel').click(function(){
181         window.location.href = Feng.ctxPath + '/equipmentMaintainPlan'
182     });
183
184     $('#equipmentNo').click(function (){
185         layer.open({
186             type: 2,
187             area: ['1000px', '600px'],
188             title: '设备列表',
189             content: Feng.ctxPath + '/equipmentMaintainPlan/eqList',
190             end: function () {
191                 let msg = JSON.parse(window.localStorage.getItem('message'));
192                 console.log("选择工单_id", msg.id)
193                 $('#equipmentNo').val(msg.equipmentNo);
194                 $('#equipmentName').val(msg.equipmentName);
195                 console.log(msg);
196             }
197         });
198     });
199
200 });