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