懒羊羊
2023-11-14 8286c62256f23bc2367a6729c0f46f84215e380b
提交 | 用户 | 时间
8286c6 1 /**
2  * 详情对话框
3  */
4 var RecipeManageInfoDlg = {
5     data: {
6         id: "",
7         productionLine: "",
8         locationCode: "",
9         productCode: "",
10         operationSteps: "",
11         techRequirement: "",
12         operationType: "",
13         stepSort: "",
14         paramCode: "",
15         materialCode: "",
16         picture: "",
17         remarks: "",
18         spareField1: "",
19         spareField2: "",
20         spareField3: "",
21         spareField4: ""
22     }
23 };
24
25 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
26     var $ = layui.jquery;
27     var $ax = layui.ax;
28     var form = layui.form;
29
30     //获取详情信息,填充表单
31     var ajax = new $ax(Feng.ctxPath + "/recipeManage/detail?id=" + Feng.getUrlParam("id"));
32     var resultForm = ajax.start();
33     form.val('recipeManageForm', resultForm.data);
34
35     $(document).ready(function () {
36         $.ajax({
37             type: "POST",
38             contentType: "application/json;charset=UTF-8",
39             url: Feng.ctxPath + '/lineInfo/list',
40             success: function (result) {
41                 console.log(result);
42                 $('#productionLine').empty();
43                 $.each(result.data, function (index, value) {
44                     $('#productionLine').append(new Option(value.lineCode));// 下拉菜单里添加元素
45                 });
46                 $('#productionLine').val(resultForm.data.productionLine);
47                 layui.form.render("select");//重新渲染 固定写法
48             },
49         });
50         $.ajax({
51             type: "POST",
52             contentType: "application/json;charset=UTF-8",
53             url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+resultForm.data.productionLine,
54             success: function (result) {
55                 $('#locationCode').empty();
56                 $.each(result.data, function (index, value) {
57                     $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
58                 });
59                 $('#locationCode').val(resultForm.data.locationCode);
60                 layui.form.render("select");//重新渲染 固定写法
61             },
62         });
63     });
64
65     $('#productCode').click(function () {
66         layer.open({
67             type: 2,
68             area: ['1000px', '600px'],
69             title: '物料信息',
70             content: Feng.ctxPath + '/productionOrdeInfo/materialList',
71             success: function (layero, index) {
72                 window.materialType = '成品';
73             },
74             end: function () {
75                 let msg = JSON.parse(window.localStorage.getItem('message'));
76                 console.log(msg)
77                 $('#productCode').val(msg.materialCode);
78             }
79         });
80     });
81
82     form.on("select", function (data) {
83         switch(data.elem.id){
84             case 'productionLine':
85                 $.ajax({
86                     type: "POST",
87                     contentType: "application/json;charset=UTF-8",
88                     url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
89                     success: function (result) {
90                         $('#locationCode').empty();
91                         $.each(result.data, function (index, value) {
92                             $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
93                         });
94                         layui.form.render("select");//重新渲染 固定写法
95                     },
96                 });
97                 break;
98         }
99     });
100
101     //表单提交事件
102     form.on('submit(btnSubmit)', function (data) {
103         var ajax = new $ax(Feng.ctxPath + "/recipeManage/editItem", function (data) {
104             Feng.success("更新成功!");
105             window.location.href = Feng.ctxPath + '/recipeManage'
106         }, function (data) {
107             Feng.error("更新失败!" + data.responseJSON.message)
108         });
109         ajax.set(data.field);
110         ajax.start();
111
112         return false;
113     });
114
115     $('#cancel').click(function(){
116         window.location.href = Feng.ctxPath + '/recipeManage'
117     });
118 });