yantian yue
2023-10-23 0d7d6a88080dc8759ef84ed5ad7875f25642df6c
提交 | 用户 | 时间
1ac2bc 1 /**
2  * 详情对话框
3  */
4 var WorkOrderInfoDlg = {
5     data: {
6         id: "",
7         workOrderCode: "",
8         salesOrderCode: "",
9         productCode: "",
10         productName: "",
11         planQty: "",
12         produceQty: "",
13         onlineQty: "",
14         planStartTime: "",
15         planEndTime: "",
16         produceStartTime: "",
17         produceEndTime: "",
18         workshopCode: "",
19         lineCode: "",
20         state: "",
21         badQty: "",
22         repairQty: "",
23         scrapQty: "",
24         routeCode: "",
25         bomCode: "",
26         recipeCode: "",
27         spareField1: "",
28         spareField2: "",
29         spareField3: "",
30         createUser: "",
31         createTime: "",
32         updateUser: "",
33         updateTime: "",
34         remark: ""
35     }
36 };
37
38 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
39     var $ = layui.jquery;
40     var $ax = layui.ax;
41     var form = layui.form;
42     var admin = layui.admin;
43     var laydate = layui.laydate;
44
45     //获取详情信息,填充表单
46     var ajax = new $ax(Feng.ctxPath + "/workOrder/detail?id=" + Feng.getUrlParam("id"));
47     var result1 = ajax.start();
48     form.val('workOrderForm', result1.data);
49
50     //初始化时间选择器
51     laydate.render({
52         elem: '#planStartTime',
53         type: 'datetime'
54     });
55     //初始化时间选择器
56     laydate.render({
57         elem: '#planEndTime',
58         type: 'datetime'
59     });
60     //初始化时间选择器
61     laydate.render({
62         elem: '#produceStartTime',
63         type: 'datetime'
64     });
65     //初始化时间选择器
66     laydate.render({
67         elem: '#produceEndTime',
68         type: 'datetime'
69     });
70
71     let workshopCode = result1.data.workshopCode;
72     let lineCode = result1.data.lineCode;
73
74     $(document).ready(function () {
75         $.ajax({
76             type: "POST",
77             contentType: "application/json;charset=UTF-8",
78             url: Feng.ctxPath + '/workshopInfo/list',
79             success: function (result) {
80                 $.each(result.data, function (index, value) {
81                     $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
82                 });
83                 $('#workshopCode').val(workshopCode);
84                 layui.form.render("select");//重新渲染 固定写法
85             },
86         });
87
88         $.ajax({
89             type: "POST",
90             contentType: "application/json;charset=UTF-8",
91             url: Feng.ctxPath + '/lineInfo/list?workshopCode='+workshopCode,
92             success: function (result) {
93                 $('#productionLineCode').empty();
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 + "/workOrder/editItem", function (data) {
128             Feng.success("更新成功!");
129             window.location.href = Feng.ctxPath + '/workOrder'
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 + '/workOrder'
141     });
142 });