懒羊羊
2024-01-10 1b72fc0dd1d7004de54ab0886e0323cb1b96198d
提交 | 用户 | 时间
71e81e 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         $.ajax({
30             type: "POST",
31             contentType: "application/json;charset=UTF-8",
32             url: Feng.ctxPath + '/workshopInfo/list',
33             success: function (result) {
34                 $.each(result.data, function (index, value) {
35                     $('#workshopCode').append(new Option(value.workshopCode));// 下拉菜单里添加元素
36                 });
37                 layui.form.render("select");//重新渲染 固定写法
38             },
39         });
40     });
41
42     form.on("select", function (data) {
43         if (data.elem.id === "workshopCode") {
44             $.ajax({
45                 type: "POST",
46                 contentType: "application/json;charset=UTF-8",
47                 url: Feng.ctxPath + '/lineInfo/list?workshopCode='+ $('#workshopCode').val(),
48                 success: function (result) {
49                     $('#productionLineCode').empty();
50                     $('#productionLineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
51
52                     $.each(result.data, function (index, value) {
53                         $('#productionLineCode').append(new Option(value.lineCode, value.lineCode));// 下拉菜单里添加元素
54                     });
55                     layui.form.render("select");//重新渲染 固定写法
56                 },
57             });
58         }
59     });
60
61     //表单提交事件
62     form.on('submit(btnSubmit)', function (data) {
63         var ajax = new $ax(Feng.ctxPath + "/locationInfo/addItem", function (data) {
64             Feng.success("添加成功!");
65             window.location.href = Feng.ctxPath + '/locationInfo'
66         }, function (data) {
67             Feng.error("添加失败!" + data.responseJSON.message)
68         });
69         ajax.set(data.field);
70         ajax.start();
71
72         return false;
73     });
74
75     $('#cancel').click(function(){
76         window.location.href = Feng.ctxPath + '/locationInfo'
77     });
78
79 });