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