yantian yue
2023-10-23 0d7d6a88080dc8759ef84ed5ad7875f25642df6c
提交 | 用户 | 时间
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     $(document).ready(function () {
35         $.ajax({
36             type: "POST",
37             contentType: "application/json;charset=UTF-8",
38             url: Feng.ctxPath + '/workshopInfo/list',
39             success: function (result) {
40                 $.each(result.data, function (index, value) {
41                     $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
42                 });
43                 layui.form.render("select");//重新渲染 固定写法
44             },
45         });
46     });
47
48     form.on("select", function (data) {
49         switch(data.elem.id){
50             case 'workshopCode':
51                 $.ajax({
52                     type: "POST",
53                     contentType: "application/json;charset=UTF-8",
54                     url: Feng.ctxPath + '/lineInfo/list?workshopCode='+data.value,
55                     success: function (result) {
56                         $('#productionLineCode').empty();
57                         $('#productionLineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
58
59                         $.each(result.data, function (index, value) {
60                             $('#productionLineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
61                         });
62                         layui.form.render("select");//重新渲染 固定写法
63                     },
64                 });
65                 break;
66             case 'productionLineCode':
67                 $.ajax({
68                     type: "POST",
69                     contentType: "application/json;charset=UTF-8",
70                     url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
71                     success: function (result) {
72                         $('#locationCode').empty();
73                         $('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
74
75                         $.each(result.data, function (index, value) {
76                             $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
77                         });
78                         layui.form.render("select");//重新渲染 固定写法
79                     },
80                 });
81                 break;
82         }
83     });
84
85     //表单提交事件
86     form.on('submit(btnSubmit)', function (data) {
87         var ajax = new $ax(Feng.ctxPath + "/equipmentInfo/addItem", function (data) {
88             Feng.success("添加成功!");
89             window.location.href = Feng.ctxPath + '/equipmentInfo'
90         }, function (data) {
91             Feng.error("添加失败!" + data.responseJSON.message)
92         });
93         ajax.set(data.field);
94         ajax.start();
95
96         return false;
97     });
98
99     $('#cancel').click(function(){
100         window.location.href = Feng.ctxPath + '/equipmentInfo'
101     });
102
103 });