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