懒羊羊
2023-11-14 036dcdcec6235d82b008f5c736d27a0d1f90d4a2
提交 | 用户 | 时间
1ac2bc 1 /**
2  * 详情对话框
3  */
4 var SalesOrderInfoDlg = {
5     data: {
6         id: "",
7         salesOrderCode: "",
8         customerNo: "",
9         cargoNo: "",
10         productCode: "",
11         productName: "",
12         planNumber: "",
13         planStartTime: "",
14         planEndTime: "",
15         workshopCode: "",
16         lineCode: "",
17         deliveryTime: "",
18         state: "",
19         orderSource: "",
20         spareField1: "",
21         spareField2: "",
22         spareField3: "",
23         createUser: "",
24         createTime: "",
25         updateUser: "",
26         updateTime: "",
27         remark: ""
28     }
29 };
30
31 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
32     var $ = layui.jquery;
33     var $ax = layui.ax;
34     var form = layui.form;
35     var admin = layui.admin;
36     var laydate = layui.laydate;
37
38     //初始化时间选择器
39     laydate.render({
40         elem: '#planStartTime',
41         type: 'datetime'
42     });
43     //初始化时间选择器
44     laydate.render({
45         elem: '#planEndTime',
46         type: 'datetime'
47     });
48     //初始化时间选择器
49     laydate.render({
50         elem: '#deliveryTime',
51         type: 'datetime'
52     });
53
54     //获取详情信息,填充表单
55     var ajax = new $ax(Feng.ctxPath + "/salesOrder/detail?id=" + Feng.getUrlParam("id"));
56     var result1 = ajax.start();
57     form.val('salesOrderForm', result1.data);
58
59     let workshopCode = result1.data.workshopCode;
60     let lineCode = result1.data.lineCode;
61
62     $(document).ready(function () {
63         // $.ajax({
64         //     type: "POST",
65         //     contentType: "application/json;charset=UTF-8",
66         //     url: Feng.ctxPath + '/workshopInfo/list',
67         //     success: function (result) {
68         //         $.each(result.data, function (index, value) {
69         //             $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
70         //         });
71         //         $('#workshopCode').val(workshopCode);
72         //         layui.form.render("select");//重新渲染 固定写法
73         //     },
74         // });
75
76         // $.ajax({
77         //     type: "POST",
78         //     contentType: "application/json;charset=UTF-8",
79         //     url: Feng.ctxPath + '/lineInfo/list?workshopCode='+workshopCode,
80         //     success: function (result) {
81         //         $('#productionLineCode').empty();
82         //         $.each(result.data, function (index, value) {
83         //             $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
84         //         });
85         //         $('#lineCode').val(lineCode);
86         //         layui.form.render("select");//重新渲染 固定写法
87         //     },
88         // });
89         $.ajax({
90             type: "POST",
91             contentType: "application/json;charset=UTF-8",
92             url: Feng.ctxPath + '/lineInfo/list',
93             success: function (result) {
94                 $.each(result.data, function (index, value) {
95                     $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
96                 });
97                 $('#lineCode').val(lineCode);
98                 layui.form.render("select");//重新渲染 固定写法
99             },
100         });
101     });
102
103     // form.on("select", function (data) {
104     //     switch(data.elem.id){
105     //         case 'workshopCode':
106     //             $.ajax({
107     //                 type: "POST",
108     //                 contentType: "application/json;charset=UTF-8",
109     //                 url: Feng.ctxPath + '/lineInfo/list?workshopCode='+workshopCode,
110     //                 success: function (result) {
111     //                     $('#lineCode').empty();
112     //                     $.each(result.data, function (index, value) {
113     //                         $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
114     //                     });
115     //                     if($('#workshopCode').val() === ""||$('#workshopCode').val() === null){
116     //                         layui.$('#lineCode').empty(); // 获取select元素
117     //                     }
118     //                     layui.form.render("select");//重新渲染 固定写法
119     //                 },
120     //             });
121     //             break;
122     //     }
123     // });
124
125     //表单提交事件
126     form.on('submit(btnSubmit)', function (data) {
127         var ajax = new $ax(Feng.ctxPath + "/salesOrder/editItem", function (data) {
128             Feng.success("更新成功!");
129             window.location.href = Feng.ctxPath + '/salesOrder'
130         }, function (data) {
131             Feng.error("更新失败!" + data.responseJSON.message)
132         });
133         ajax.set(data.field);
134         ajax.start();
135
136         return false;
137     });
138
139     $('#cancel').click(function(){
140         window.location.href = Feng.ctxPath + '/salesOrder'
141     });
142 });