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