cl
2024-01-19 e0fac38b26845f25de479783e0c76cf12a5311e0
提交 | 用户 | 时间
71e81e 1 /**
2  * 详情对话框
3  */
4 var ScrapCategoryConfInfoDlg = {
5     data: {
6         id: "",
7         lineCode: "",
8         lineName: "",
9         locationCode: "",
10         locationName: "",
11         scrapCategory: "",
12         scrapReason: "",
13         state: "",
14         spareField1: "",
15         spareField2: "",
16         remarks: "",
17         createUser: "",
18         updateUser: "",
19         updateTime: "",
20         createTime: ""
21     }
22 };
23
24 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
25     var $ = layui.jquery;
26     var $ax = layui.ax;
27     var form = layui.form;
28     var admin = layui.admin;
29
30     //获取详情信息,填充表单
31     var ajax = new $ax(Feng.ctxPath + "/scrapCategoryConf/detail?id=" + Feng.getUrlParam("id"));
32     var result1 = ajax.start();
33     form.val('scrapCategoryConfForm', result1.data);
34
35     $(document).ready(function () {
36         $.ajax({
37             type: "POST",
38             contentType: "application/json;charset=UTF-8",
39             url: Feng.ctxPath + '/lineInfo/list',
40             success: function (result) {
41                 console.log(result);
42                 $('#lineCode').empty();
43                 $.each(result.data, function (index, value) {
44                     $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
45                 });
46                 $('#lineCode').val(result1.data.lineCode);
47                 layui.form.render("select");//重新渲染 固定写法
48             },
49         });
50         $.ajax({
51             type: "POST",
52             contentType: "application/json;charset=UTF-8",
53             url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+result1.data.lineCode,
54             success: function (result) {
55                 $('#locationCode').empty();
56                 $.each(result.data, function (index, value) {
57                     $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
58                 });
59                 $('#locationCode').val(result1.data.locationCode);
60                 layui.form.render("select");//重新渲染 固定写法
61             },
62         });
63     });
64
65     form.on("select", function (data) {
66         switch(data.elem.id){
67             case 'lineCode':
68                 $.ajax({
69                     type: "POST",
70                     contentType: "application/json;charset=UTF-8",
71                     url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+$("#lineCode").val(),
72                     success: function (result) {
73                         $('#locationCode').empty();
74                         $('#locationCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
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 + "/scrapCategoryConf/editItem", function (data) {
88             Feng.success("更新成功!");
89             window.location.href = Feng.ctxPath + '/scrapCategoryConf'
90
91         }, function (data) {
92             Feng.error("更新失败!" + data.responseJSON.message)
93         });
94         ajax.set(data.field);
95         ajax.start();
96
97         return false;
98     });
99
100     $('#cancel').click(function(){
101         window.location.href = Feng.ctxPath + '/scrapCategoryConf'
102     });
103
104 });