懒羊羊
2023-10-10 cd500a4dab1bf530072ff6da83b907eebb48108a
提交 | 用户 | 时间
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     $(document).ready(function () {
54         // $.ajax({
55         //     type: "POST",
56         //     contentType: "application/json;charset=UTF-8",
57         //     url: Feng.ctxPath + '/workshopInfo/list',
58         //     success: function (result) {
59         //         $.each(result.data, function (index, value) {
60         //             $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
61         //         });
62         //         layui.form.render("select");//重新渲染 固定写法
63         //     },
64         // });
65         $.ajax({
66             type: "POST",
67             contentType: "application/json;charset=UTF-8",
68             url: Feng.ctxPath + '/lineInfo/list',
69             success: function (result) {
70                 $.each(result.data, function (index, value) {
71                     $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
72                 });
73                 layui.form.render("select");//重新渲染 固定写法
74             },
75         });
76     });
77
78     // form.on("select", function (data) {
79     //     switch(data.elem.id){
80     //         case 'workshopCode':
81     //             $.ajax({
82     //                 type: "POST",
83     //                 contentType: "application/json;charset=UTF-8",
84     //                 url: Feng.ctxPath + '/lineInfo/list?workshopCode='+data.value,
85     //                 success: function (result) {
86     //                     $('#productionLineCode').empty();
87     //                     $.each(result.data, function (index, value) {
88     //                         $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
89     //                     });
90     //                     if($('#workshopCode').val() === ""||$('#workshopCode').val() === null){
91     //                         layui.$('#lineCode').empty(); // 获取select元素
92     //                     }
93     //                     layui.form.render("select");//重新渲染 固定写法
94     //                 },
95     //             });
96     //             break;
97     //     }
98     // });
99
100     //表单提交事件
101     form.on('submit(btnSubmit)', function (data) {
102         var ajax = new $ax(Feng.ctxPath + "/salesOrder/addItem", function (data) {
103             Feng.success("添加成功!");
104             window.location.href = Feng.ctxPath + '/salesOrder'
105         }, function (data) {
106             Feng.error("添加失败!" + data.responseJSON.message)
107         });
108         ajax.set(data.field);
109         ajax.start();
110
111         return false;
112     });
113
114     $('#cancel').click(function(){
115         window.location.href = Feng.ctxPath + '/salesOrder'
116     });
117
118 });