cl
2024-01-23 6dadf36ef118fbb3b2cd5aca94cde88e29fb55dc
提交 | 用户 | 时间
71e81e 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 resultForm = ajax.start();
36     form.val('equipmentInfoForm', resultForm.data);
37     console.log(resultForm);
38
39     $(document).ready(function () {
40         $.ajax({
41             type: "POST",
42             contentType: "application/json;charset=UTF-8",
43             url: Feng.ctxPath + '/workshopInfo/list',
44             success: function (result) {
45                 $.each(result.data, function (index, value) {
46                     $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
47                 });
48                 $('#workshopCode').val(resultForm.data.workshopCode);
49                 layui.form.render("select");//重新渲染 固定写法
50             },
51         });
52         $.ajax({
53             type: "POST",
54             contentType: "application/json;charset=UTF-8",
55             url: Feng.ctxPath + '/lineInfo/list?workshopCode='+resultForm.data.workshopCode,
56             success: function (result) {
57                 console.log(result);
58                 $('#productionLineCode').empty();
59                 $.each(result.data, function (index, value) {
60                     $('#productionLineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
61                 });
62                 $('#productionLineCode').val(resultForm.data.productionLineCode);
63                 layui.form.render("select");//重新渲染 固定写法
64             },
65         });
66         $.ajax({
67             type: "POST",
68             contentType: "application/json;charset=UTF-8",
69             url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+resultForm.data.productionLineCode,
70             success: function (result) {
71                 $('#locationCode').empty();
72                 $.each(result.data, function (index, value) {
73                     $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
74                 });
75                 $('#locationCode').val(resultForm.data.locationCode);
76                 layui.form.render("select");//重新渲染 固定写法
77             },
78         });
79     });
80
81     form.on("select", function (data) {
82         switch(data.elem.id){
83             case 'workshopCode':
84                 $.ajax({
85                     type: "POST",
86                     contentType: "application/json;charset=UTF-8",
87                     url: Feng.ctxPath + '/lineInfo/list?workshopCode='+data.value,
88                     success: function (result) {
89                         $('#productionLineCode').empty();
90                         $.each(result.data, function (index, value) {
91                             $('#productionLineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
92                         });
93                         layui.form.render("select");//重新渲染 固定写法
94                     },
95                 });
96                 break;
97             case 'productionLineCode':
98                 $.ajax({
99                     type: "POST",
100                     contentType: "application/json;charset=UTF-8",
101                     url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
102                     success: function (result) {
103                         $('#locationCode').empty();
104                         $.each(result.data, function (index, value) {
105                             $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
106                         });
107                         layui.form.render("select");//重新渲染 固定写法
108                     },
109                 });
110                 break;
111         }
112     });
113
114     //表单提交事件
115     form.on('submit(btnSubmit)', function (data) {
116         var ajax = new $ax(Feng.ctxPath + "/equipmentInfo/editItem", function (data) {
117             Feng.success("更新成功!");
118             window.location.href = Feng.ctxPath + '/equipmentInfo'
119         }, function (data) {
120             Feng.error("更新失败!" + data.responseJSON.message)
121         });
122         ajax.set(data.field);
123         ajax.start();
124
125         return false;
126     });
127
128     $('#cancel').click(function(){
129         window.location.href = Feng.ctxPath + '/equipmentInfo'
130     });
131 });