懒羊羊
2024-01-10 1b72fc0dd1d7004de54ab0886e0323cb1b96198d
提交 | 用户 | 时间
71e81e 1 /**
2  * 添加或者修改页面
3  */
4 var BadReasonConfInfoDlg = {
5     data: {
6         id: "",
7         workshopCode: "",
8         productionLine: "",
9         locationCode: "",
10         equipmentNo: "",
11         typeCode: "",
12         typeName: "",
13         badCode: "",
14         badDesc: "",
15         status: "",
16         createUser: "",
17         createTime: "",
18         updateUser: "",
19         updateTime: ""
20     }
21 };
22
23 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
24     var $ = layui.jquery;
25     var $ax = layui.ax;
26     var form = layui.form;
27     var admin = layui.admin;
28
29     $(document).ready(function () {
30         $.ajax({
31             type: "POST",
32             contentType: "application/json;charset=UTF-8",
33             url: Feng.ctxPath + '/workshopInfo/list',
34             success: function (result) {
35                 $.each(result.data, function (index, value) {
36                     $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
37                 });
38                 layui.form.render("select");//重新渲染 固定写法
39             },
40         });
41     });
42
43     form.on("select", function (data) {
44         if (data.elem.id === "workshopCode") {
45             $.ajax({
46                 type: "POST",
47                 contentType: "application/json;charset=UTF-8",
48                 url: Feng.ctxPath + '/lineInfo/list?workshopCode='+ $('#workshopCode').val(),
49                 success: function (result) {
50                     $('#productionLine').empty();
51                     $('#productionLine').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
52                     $.each(result.data, function (index, value) {
53                         $('#productionLine').append(new Option(value.lineCode, value.lineCode));// 下拉菜单里添加元素
54                     });
55                     layui.form.render("select");//重新渲染 固定写法
56                 },
57             });
58         }
59         if (data.elem.id === "productionLine") {
60             $.ajax({
61                 type: "POST",
62                 contentType: "application/json;charset=UTF-8",
63                 url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+ $('#productionLine').val(),
64                 success: function (result) {
65                     $('#locationCode').empty();
66                     $('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
67                     $.each(result.data, function (index, value) {
68                         $('#locationCode').append(new Option(value.locationCode, value.locationCode));// 下拉菜单里添加元素
69                     });
70                     layui.form.render("select");//重新渲染 固定写法
71                 },
72             });
73         }
74     });
75
76     //表单提交事件
77     form.on('submit(btnSubmit)', function (data) {
78         var ajax = new $ax(Feng.ctxPath + "/badReasonConf/addItem", function (data) {
79             Feng.success("添加成功!");
80             window.location.href = Feng.ctxPath + '/badReasonConf'
81         }, function (data) {
82             Feng.error("添加失败!" + data.responseJSON.message)
83         });
84         ajax.set(data.field);
85         ajax.start();
86
87         return false;
88     });
89
90     $('#cancel').click(function(){
91         window.location.href = Feng.ctxPath + '/badReasonConf'
92     });
93
94
95 });