懒羊羊
2023-10-10 cd500a4dab1bf530072ff6da83b907eebb48108a
提交 | 用户 | 时间
1ac2bc 1 /**
2  * 添加或者修改页面
3  */
4 var ProductBomChildInfoInfoDlg = {
5     data: {
6         id: "",
7         opCode: "",
8         opName: "",
9         materialCode: "",
10         materialName: "",
11         costQty: "",
12         unit: "",
13         spareField1: "",
14         spareField2: "",
15         spareField3: "",
16         remark: "",
17         bomCode: ""
18     }
19 };
20
21 layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
22     var $ = layui.jquery;
23     var $ax = layui.ax;
24     var form = layui.form;
25     var admin = layui.admin;
26
27     getOpList();
28
29     function getOpList(){
30         $.ajax({
31             type: "POST",
32             contentType: "application/json;charset=UTF-8",
33             url: Feng.ctxPath + '/opInfo/list?status=ENABLE',
34             success: function (result) {
35                 $.each(result.data, function (index, value) {
36                     $('#opCode').append(new Option(value.opCode));// 下拉菜单里添加元素
37                 });
38                 console.log(result)
39                 layui.form.render("select");//重新渲染 固定写法
40             },
41         });
42     }
43
44     // $('#materialCode').click(function (){
45     //     layer.open({
46     //         type: 2,
47     //         area: ['1000px', '600px'],
48     //         // title: '设备列表',
49     //         content: Feng.ctxPath + '/materialInfo/materialInfoListOpen',
50     //         end: function () {
51     //             let msg = JSON.parse(window.localStorage.getItem('message'));
52     //             $('#materialCode').val(msg.materialCode);
53     //             $('#materialName').val(msg.materialName);
54     //             $('#unit').val(msg.unit);
55     //             console.log(msg);
56     //         }
57     //     });
58     // });
59
60     //表单提交事件
61     form.on('submit(btnSubmit)', function (data) {
62         var ajax = new $ax(Feng.ctxPath + "/productBomChildInfo/addItem", function (data) {
63             Feng.success("添加成功!");
64             admin.putTempData('formOk', true);
65             admin.closeThisDialog();
66             // window.location.href = Feng.ctxPath + '/productBomChildInfo/bomChildHomePage'
67             // window.location.href = Feng.ctxPath + '/productBomChildInfo?bomCode='+ $("#bomCode").val()
68             // window.location.href = Feng.ctxPath + '/productBomChildInfo?bomCode='+ $("#bomCode").val()
69         }, function (data) {
70             Feng.error("添加失败!" + data.responseJSON.message)
71         });
72         ajax.set(data.field);
73         ajax.start();
74
75         return false;
76     });
77
78     $('#cancel').click(function(){
79         // window.location.href = Feng.ctxPath + '/productBomChildInfo'
80         admin.closeThisDialog();
81     });
82
83 });