懒羊羊
2023-11-14 8286c62256f23bc2367a6729c0f46f84215e380b
提交 | 用户 | 时间
8286c6 1 /**
2  * 详情对话框
3  */
4 var LocationInfoInfoDlg = {
5     data: {
6         id: "",
7         locationCode: "",
8         locationName: "",
9         locationType: "",
10         workshopCode: "",
11         productionLineCode: "",
12         spareField1: "",
13         spareField2: "",
14         remarks: "",
15         createUser: "",
16         createTime: "",
17         updateUser: "",
18         updateTime: ""
19     }
20 };
21
22 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
23     var $ = layui.jquery;
24     var $ax = layui.ax;
25     var form = layui.form;
26     var admin = layui.admin;
27
28     //获取详情信息,填充表单
29     var ajax = new $ax(Feng.ctxPath + "/locationInfo/detail?id=" + Feng.getUrlParam("id"));
30     var result1 = ajax.start();
31     form.val('locationInfoForm', result1.data);
32     console.log(result1);
33
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                     $('#productionLineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
54                 });
55                 $('#productionLineCode').val(result1.data.productionLineCode);
56                 layui.form.render("select");//重新渲染 固定写法
57             },
58         });
59     });
60     form.on("select", function (data) {
61         if (data.value !== "") {
62             if (data.elem.id === "workshopCode") {
63                 $.ajax({
64                     type: "POST",
65                     contentType: "application/json;charset=UTF-8",
66                     url: Feng.ctxPath + '/lineInfo/list?workshopCode='+data.value,
67                     success: function (result) {
68                         $('#productionLineCode').empty();
69                         $.each(result.data, function (index, value) {
70                             $('#productionLineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
71                         });
72                         $('#productionLineCode').val(result1.data.productionLineCode);
73                         layui.form.render("select");//重新渲染 固定写法
74                     },
75                 });
76             }
77         }
78     });
79
80     //表单提交事件
81     form.on('submit(btnSubmit)', function (data) {
82         var ajax = new $ax(Feng.ctxPath + "/locationInfo/editItem", function (data) {
83             Feng.success("更新成功!");
84             window.location.href = Feng.ctxPath + '/locationInfo'
85         }, function (data) {
86             Feng.error("更新失败!" + data.responseJSON.message)
87         });
88         ajax.set(data.field);
89         ajax.start();
90
91         return false;
92     });
93
94     $('#cancel').click(function(){
95         window.location.href = Feng.ctxPath + '/locationInfo'
96     });
97 });