yantian yue
2023-10-17 487b2f2a353b89ab46cd9b784226b600b7b915b8
提交 | 用户 | 时间
3d2401 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
33     $(document).ready(function () {
34         getDictType();
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     function getDictType(){
81         $.ajax({
82             type: "POST",
83             contentType: "application/json;charset=UTF-8",
84             url: Feng.ctxPath + '/dict/list?dictTypeId=1703969868646158337',
85             success: function (result) {
86                 $.each(result.data, function (index, value) {
87                     $('#locationType').append(new Option(value.name,value.code));// 下拉菜单里添加元素
88                 });
89                 layui.form.render("select");//重新渲染 固定写法
90             },
91         });
92     }
93
94     //表单提交事件
95     form.on('submit(btnSubmit)', function (data) {
96         var ajax = new $ax(Feng.ctxPath + "/locationInfo/editItem", function (data) {
97             Feng.success("更新成功!");
98             window.location.href = Feng.ctxPath + '/locationInfo'
99         }, function (data) {
100             Feng.error("更新失败!" + data.responseJSON.message)
101         });
102         ajax.set(data.field);
103         ajax.start();
104
105         return false;
106     });
107
108     $('#cancel').click(function(){
109         window.location.href = Feng.ctxPath + '/locationInfo'
110     });
111 });