admin
2024-01-08 22f70cc8b2ba603e82bba058db320dced48f9470
提交 | 用户 | 时间
71e81e 1 /**
2  * 详情对话框
3  */
4 var KanbanConfInfoDlg = {
5     data: {
6         id: "",
7         pageCode: "",
8         ipAddress: "",
9         macAddress: "",
10         workshopCode: "",
11         workshopName: "",
12         lineCode: "",
13         lineName: "",
14         locationCode: "",
15         locationName: "",
16         warehouseCode: "",
17         warehouseName: ""
18     }
19 };
20
21 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
22     var $ = layui.jquery;
23     var $ax = layui.ax;
24     var form = layui.form;
25     var admin = layui.admin;
26
27     //获取详情信息,填充表单
28     var ajax = new $ax(Feng.ctxPath + "/kanbanConf/detail?id=" + Feng.getUrlParam("id"));
29     var resultForm = ajax.start();
30     form.val('kanbanConfForm', resultForm.data);
31     console.log(resultForm);
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                 $('#workshopCode').val(resultForm.data.workshopCode);
43                 layui.form.render("select");//重新渲染 固定写法
44             },
45         });
46         $.ajax({
47             type: "POST",
48             contentType: "application/json;charset=UTF-8",
49             url: Feng.ctxPath + '/lineInfo/list?workshopCode='+resultForm.data.workshopCode,
50             success: function (result) {
51                 console.log(result);
52                 $('#lineCode').empty();
53                 $.each(result.data, function (index, value) {
54                     $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
55                 });
56                 $('#lineCode').val(resultForm.data.lineCode);
57                 layui.form.render("select");//重新渲染 固定写法
58             },
59         });
60         $.ajax({
61             type: "POST",
62             contentType: "application/json;charset=UTF-8",
63             url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+resultForm.data.lineCode,
64             success: function (result) {
65                 $('#locationCode').empty();
66                 $.each(result.data, function (index, value) {
67                     $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
68                 });
69                 $('#locationCode').val(resultForm.data.locationCode);
70                 layui.form.render("select");//重新渲染 固定写法
71             },
72         });
73     });
74
75     form.on("select", function (data) {
76         switch(data.elem.id){
77             case 'workshopCode':
78                 $.ajax({
79                     type: "POST",
80                     contentType: "application/json;charset=UTF-8",
81                     url: Feng.ctxPath + '/lineInfo/list?workshopCode='+data.value,
82                     success: function (result) {
83                         $('#lineCode').empty();
84                         $.each(result.data, function (index, value) {
85                             $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
86                         });
87                         layui.form.render("select");//重新渲染 固定写法
88                     },
89                 });
90                 break;
91             case 'lineCode':
92                 $.ajax({
93                     type: "POST",
94                     contentType: "application/json;charset=UTF-8",
95                     url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
96                     success: function (result) {
97                         $('#locationCode').empty();
98                         $.each(result.data, function (index, value) {
99                             $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
100                         });
101                         layui.form.render("select");//重新渲染 固定写法
102                     },
103                 });
104                 break;
105         }
106     });
107
108     //表单提交事件
109     form.on('submit(btnSubmit)', function (data) {
110         var ajax = new $ax(Feng.ctxPath + "/kanbanConf/editItem", function (data) {
111             Feng.success("更新成功!");
112             window.location.href = Feng.ctxPath + '/kanbanConf'
113         }, function (data) {
114             Feng.error("更新失败!" + data.responseJSON.message)
115         });
116         ajax.set(data.field);
117         ajax.start();
118
119         return false;
120     });
121
122     $('#cancel').click(function(){
123         window.location.href = Feng.ctxPath + '/kanbanConf'
124     });
125 });