yantian yue
2023-10-23 0d7d6a88080dc8759ef84ed5ad7875f25642df6c
提交 | 用户 | 时间
3d2401 1 /**
2  * 添加或者修改页面
3  */
4 var LocationInfoInfoDlg = {
5     data: {
6         id: "",
7         locationCode: "",
8         locationName: "",
9         locationType: "",
10         workshopCode: "",
11         productionLineCode: "",
12         spareField1: "",
13         spareField2: "",
14         remarks: "",
15         createUser: "",
16         createTime: "",
17         updateUser: "",
18         updateTime: ""
19     }
20 };
21
22 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
23     var $ = layui.jquery;
24     var $ax = layui.ax;
25     var form = layui.form;
26     var admin = layui.admin;
27
28     $(document).ready(function () {
29         getDictType();
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                     $('#productionLineCode').empty();
51                     $('#productionLineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
52
53                     $.each(result.data, function (index, value) {
54                         $('#productionLineCode').append(new Option(value.lineCode, value.lineCode));// 下拉菜单里添加元素
55                     });
56                     layui.form.render("select");//重新渲染 固定写法
57                 },
58             });
59         }
60     });
61
62     function getDictType(){
63         $.ajax({
64             type: "POST",
65             contentType: "application/json;charset=UTF-8",
66             url: Feng.ctxPath + '/dict/list?dictTypeId=1703969868646158337',
67             success: function (result) {
68                 $.each(result.data, function (index, value) {
69                     $('#locationType').append(new Option(value.name,value.code));// 下拉菜单里添加元素
70                 });
71                 layui.form.render("select");//重新渲染 固定写法
72             },
73         });
74     }
75
76     //表单提交事件
77     form.on('submit(btnSubmit)', function (data) {
78         var ajax = new $ax(Feng.ctxPath + "/locationInfo/addItem", function (data) {
79             Feng.success("添加成功!");
80             window.location.href = Feng.ctxPath + '/locationInfo'
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 + '/locationInfo'
92     });
93
94 });