懒羊羊
2023-11-14 036dcdcec6235d82b008f5c736d27a0d1f90d4a2
提交 | 用户 | 时间
3d2401 1 /**
2  * 详情对话框
3  */
4 var EquipmentInfoInfoDlg = {
5     data: {
6         id: "",
7         equipmentNo: "",
8         equipmentName: "",
9         equipmentType: "",
10         equipmentModel: "",
11         workshopCode: "",
12         productionLineCode: "",
13         locationCode: "",
14         supplierCode: "",
15         spareField1: "",
16         spareField2: "",
17         spareField3: "",
18         spareField4: "",
19         remark: "",
20         createUser: "",
21         createTime: "",
22         updateUser: "",
23         updateTime: ""
24     }
25 };
26
27 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
28     var $ = layui.jquery;
29     var $ax = layui.ax;
30     var form = layui.form;
31     var admin = layui.admin;
32
33     //获取详情信息,填充表单
34     var ajax = new $ax(Feng.ctxPath + "/equipmentInfo/detail?id=" + Feng.getUrlParam("id"));
35     var result = ajax.start();
36     form.val('equipmentInfoForm', result.data);
37
38     $(document).ready(function () {
39         $.ajax({
40             type: "POST",
41             contentType: "application/json;charset=UTF-8",
42             url: Feng.ctxPath + '/workshopInfo/list',
43             success: function (result) {
44                 $.each(result.data, function (index, value) {
45                     $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
46                 });
47                 $('#workshopCode').val(resultForm.data.workshopCode);
48                 layui.form.render("select");//重新渲染 固定写法
49             },
50         });
51         $.ajax({
52             type: "POST",
53             contentType: "application/json;charset=UTF-8",
54             url: Feng.ctxPath + '/lineInfo/list?workshopCode='+resultForm.data.workshopCode,
55             success: function (result) {
56                 console.log(result);
57                 $('#productionLineCode').empty();
58                 $.each(result.data, function (index, value) {
59                     $('#productionLineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
60                 });
61                 $('#productionLineCode').val(resultForm.data.productionLineCode);
62                 layui.form.render("select");//重新渲染 固定写法
63             },
64         });
65         $.ajax({
66             type: "POST",
67             contentType: "application/json;charset=UTF-8",
68             url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+resultForm.data.productionLineCode,
69             success: function (result) {
70                 $('#locationCode').empty();
71                 $.each(result.data, function (index, value) {
72                     $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
73                 });
74                 $('#locationCode').val(resultForm.data.locationCode);
75                 layui.form.render("select");//重新渲染 固定写法
76             },
77         });
78     });
79
80     form.on("select", function (data) {
81         switch(data.elem.id){
82             case 'workshopCode':
83                 $.ajax({
84                     type: "POST",
85                     contentType: "application/json;charset=UTF-8",
86                     url: Feng.ctxPath + '/lineInfo/list?workshopCode='+data.value,
87                     success: function (result) {
88                         $('#productionLineCode').empty();
89                         $.each(result.data, function (index, value) {
90                             $('#productionLineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
91                         });
92                         layui.form.render("select");//重新渲染 固定写法
93                     },
94                 });
95                 break;
96             case 'productionLineCode':
97                 $.ajax({
98                     type: "POST",
99                     contentType: "application/json;charset=UTF-8",
100                     url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
101                     success: function (result) {
102                         $('#locationCode').empty();
103                         $.each(result.data, function (index, value) {
104                             $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
105                         });
106                         layui.form.render("select");//重新渲染 固定写法
107                     },
108                 });
109                 break;
110         }
111     });
112
113     //表单提交事件
114     form.on('submit(btnSubmit)', function (data) {
115         var ajax = new $ax(Feng.ctxPath + "/equipmentInfo/editItem", function (data) {
116             Feng.success("更新成功!");
117             window.location.href = Feng.ctxPath + '/equipmentInfo'
118         }, function (data) {
119             Feng.error("更新失败!" + data.responseJSON.message)
120         });
121         ajax.set(data.field);
122         ajax.start();
123
124         return false;
125     });
126
127     $('#cancel').click(function(){
128         window.location.href = Feng.ctxPath + '/equipmentInfo'
129     });
130 });