yantian yue
2023-10-18 f4a3430eb6b6800d4ef7330293dd8fb834eee196
提交 | 用户 | 时间
4779be 1 layui.use(['form', 'table', 'admin', 'ax', 'func','element'], function () {
2     var $ = layui.$;
3     var table = layui.table;
4     var $ax = layui.ax;
5     var admin = layui.admin;
6     var func = layui.func;
7     var form = layui.form;
8     var element = layui.element;
9
cd500a 10     /**
11      * 配方配置子信息管理
12      */
13     var FormulaChildInfo = {
14         tableId: "formulaChildInfoTable"
15     };
16
17     $('#imgs').attr("src", "http://localhost:8081/img/9f2f070828381f30fdf1be0da9014c086f06f0ad.jpg");
18
19     /**
20      * 初始化表格的列
21      */
22     FormulaChildInfo.initColumn = function () {
23         return [[
24             {field: 'id', hide: true, title: 'id'},
25             {type:"numbers" ,title:'工步',width:40},
26             {field: 'operationSteps', sort: true, title: '操作内容'},
27             {field: 'techRequirement', sort: true, title: '技术要求'},
28             {field: 'operationType', sort: true, title: '类型'},
29         ]];
30     };
31
32
4779be 33     initLineInfo();
34
35     var ajax = new $ax(Feng.ctxPath + "/workOrder/list?state=3");
36     var result = ajax.start();
37     let msg = result.data[0];
38     $('#workOrder').text(msg.workOrderCode);
39     $('#salesOrderCode').text(msg.salesOrderCode);
40     $('#productCode').text(msg.productCode);
41     $('#productName').text(msg.productName);
42     $('#planQty').text(msg.planQty);
43     $('#planStartTime').text(msg.planStartTime);
44     $('#planEndTime').text(msg.planEndTime);
ffeba3 45     $('#recipeCode').text(msg.recipeCode);
4779be 46     var radioElement = $('#sex1');
47
cd500a 48     var queryData = {};
49     queryData['formulaCode'] = msg.recipeCode;
50     // 渲染表格
51     table.render({
52         elem: '#' + FormulaChildInfo.tableId,
53         url: Feng.ctxPath + '/formulaChildInfo/list',
54         page: false,
55         // height: "full-158",
92cffc 56         // height: 460,
57         height: 400,
cd500a 58         cellMinWidth: 100,
59         where: queryData,
60         cols: FormulaChildInfo.initColumn(),
61         done: function (res, curr, count) {
62             console.log(res);
63             //得到当前页码
64             console.log(curr);
65             //得到数据总量
66             console.log(count);
67             // 根据条件判断加背景色
68             $.each(res.data, function (index, item) {
69                 console.log(item)
70                 console.log(item.spareField1)
71                 if (item.spareField1 === "3") {
72                     // 法1
73                     $("#formulaChildInfoTable").next().find('tbody tr[data-index="' + index +
74                         '"]').css("background-color", "#00ff66");
75                 }
76             });
77         }
78     });
79
4779be 80     function initLineInfo(){
81         $.ajax({
82             type: "POST",
83             contentType: "application/json;charset=UTF-8",
84             url: Feng.ctxPath + '/lineInfo/list',
85             success: function (result) {
86                 var initIpConf = new $ax(Feng.ctxPath + "/kanbanConf/initIpConf");
87                 var initResult = initIpConf.start();
88
89                 $('#lineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
90                 $.each(result.data, function (index, value) {
91                     $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
92                 });
93                 if(initResult.data!==""){
94                     $('#lineCode').val(initResult.data.lineCode);// 下拉菜单里添加元素
95                     $('#locationCode').append(new Option(initResult.data.locationCode));// 下拉菜单里添加元素
96                 }
97                 layui.form.render("select");//重新渲染 固定写法
98             },
99         });
100     }
101
102     form.on("select", function (data) {
103         switch(data.elem.id){
104             case 'lineCode':
105                 console.log(data.value);
106                 if(data.value === ""){
107                     $('#locationCode').empty();
108                     layui.form.render("select");//重新渲染 固定写法
109                 }else {
110                     $.ajax({
111                         type: "POST",
112                         contentType: "application/json;charset=UTF-8",
113                         url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
114                         success: function (result) {
115                             $('#locationCode').empty();
116                             $('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
117
118                             $.each(result.data, function (index, value) {
119                                 $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
120                             });
121                             layui.form.render("select");//重新渲染 固定写法
122                         },
123                     });
124                 }
125                 break;
126             case 'locationCode':
127                 console.log($('#locationCode').val());
128                 console.log($('#lineCode').val());
129                 var getIp = new $ax(Feng.ctxPath + "/kanbanConf/ipSetting?lineCode="+$('#lineCode').val()+"&locationCode="+$('#locationCode').val());
130                 var result = getIp.start();
131                 Feng.info("更新完成!")
132                 break;
133         }
134     });
135
92cffc 136     // //redio闪烁
137     // setInterval(function() {
138     //     $('input[name="sex1"][value="nan1"]').prop('checked', true);
139     // }, 1000);
140     // setInterval(function() {
141     //     radioElement.prop('checked', false);
142     // }, 2000);
4779be 143
144     //Hash地址的定位
145     var layid = location.hash.replace(/^#test=/, '');
146     element.tabChange('test', layid);
147
148     element.on('tab(test)', function(elem){
149         location.hash = 'test='+ $(this).attr('lay-id');
150     });
151
92cffc 152     /**
153      * 基础BOM管理
154      */
155     var ProductBomChildInfo = {
156         tableId: "productBomChildInfoTable"
157     };
158
159     /**
160      * 初始化表格的列
161      */
162     ProductBomChildInfo.initColumn = function () {
163         return [[
164             {field: 'id', hide: true, title: '主键id'},
165             {field: 'opCode', sort: true, title: '工序编码'},
166             {field: 'opName', sort: true, title: '工序名称'},
167             {field: 'materialCode', sort: true, title: '物料编码'},
168             {field: 'costQty', sort: true, title: '单耗'},
169             {field: 'bomCode', sort: true, title: 'BOM编码'},
170         ]];
171     };
172
173     var queryData = {};
174     queryData['bomCode'] = "301002000021";
175     // 渲染表格
176     table.render({
177         elem: '#' + ProductBomChildInfo.tableId,
178         url: Feng.ctxPath + '/productBomChildInfo/list',
179         page: true,
180         height: 460,
181         cellMinWidth: 100,
182         where: queryData,
183         cols: ProductBomChildInfo.initColumn()
184     });
185
186     $("#scanCode").keydown(function(event) {
187         if (event.keyCode === 13) {
188             // 执行您想要的代码
189             var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/addFormulaState?formulaCode="+msg.recipeCode);
190             var result = ajax.start();
191             table.reload("formulaChildInfoTable")
192             return false; // 阻止默认行为
193         }
194     });
195
196     $("#clear").click(function() {
197         var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/clear?formulaCode="+msg.recipeCode);
198         var result = ajax.start();
199         table.reload("formulaChildInfoTable")
200     });
201
4779be 202 });