懒羊羊
2023-11-14 ee4d94defe7cc7f36f87aebf2e9efed38ba93a40
提交 | 用户 | 时间
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     };
ee4d94 31     $('#imgs').click(function (){
32         console.log("11111111111111");
33         var img = new Image();
34         img.src = "http://localhost:8081/img/9f2f070828381f30fdf1be0da9014c086f06f0ad.jpg";
35         // var height = img.height; //获取图片高度
36         // var width = img.width; //获取图片宽度
37         var height = 500; //获取图片高度
38         var width = 800; //获取图片宽度
39         if (height > 1000 || width > 800) {
40             height = height / 1.5;
41             width = width / 1.5;
42         }
43         var imgHtml = "<img src='http://localhost:8081/img/9f2f070828381f30fdf1be0da9014c086f06f0ad.jpg' style='width: " + width + "px;height:" + height + "px'/>";
44         layer.open({
45             type: 1,
46             offset: 'auto',
47             area: [width + 'px', height + 'px'],
48             shadeClose: true,//点击外围关闭弹窗
49             scrollbar: true,//不现实滚动条
50             title: false, //不显示标题
51             content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
52             cancel: function () {
53
54             }
55         });
56         console.log(height);
57         console.log(width);
58
59     });
60
cd500a 61
62
4779be 63     initLineInfo();
64
65     var ajax = new $ax(Feng.ctxPath + "/workOrder/list?state=3");
66     var result = ajax.start();
67     let msg = result.data[0];
68     $('#workOrder').text(msg.workOrderCode);
69     $('#salesOrderCode').text(msg.salesOrderCode);
70     $('#productCode').text(msg.productCode);
71     $('#productName').text(msg.productName);
72     $('#planQty').text(msg.planQty);
73     $('#planStartTime').text(msg.planStartTime);
74     $('#planEndTime').text(msg.planEndTime);
ffeba3 75     $('#recipeCode').text(msg.recipeCode);
4779be 76     var radioElement = $('#sex1');
77
cd500a 78     var queryData = {};
79     queryData['formulaCode'] = msg.recipeCode;
80     // 渲染表格
81     table.render({
82         elem: '#' + FormulaChildInfo.tableId,
83         url: Feng.ctxPath + '/formulaChildInfo/list',
84         page: false,
85         // height: "full-158",
92cffc 86         // height: 460,
87         height: 400,
cd500a 88         cellMinWidth: 100,
89         where: queryData,
90         cols: FormulaChildInfo.initColumn(),
91         done: function (res, curr, count) {
92             console.log(res);
93             //得到当前页码
94             console.log(curr);
95             //得到数据总量
96             console.log(count);
97             // 根据条件判断加背景色
98             $.each(res.data, function (index, item) {
99                 console.log(item)
100                 console.log(item.spareField1)
101                 if (item.spareField1 === "3") {
102                     // 法1
103                     $("#formulaChildInfoTable").next().find('tbody tr[data-index="' + index +
104                         '"]').css("background-color", "#00ff66");
105                 }
106             });
107         }
108     });
109
4779be 110     function initLineInfo(){
111         $.ajax({
112             type: "POST",
113             contentType: "application/json;charset=UTF-8",
114             url: Feng.ctxPath + '/lineInfo/list',
115             success: function (result) {
116                 var initIpConf = new $ax(Feng.ctxPath + "/kanbanConf/initIpConf");
117                 var initResult = initIpConf.start();
118
119                 $('#lineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
120                 $.each(result.data, function (index, value) {
121                     $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
122                 });
123                 if(initResult.data!==""){
124                     $('#lineCode').val(initResult.data.lineCode);// 下拉菜单里添加元素
125                     $('#locationCode').append(new Option(initResult.data.locationCode));// 下拉菜单里添加元素
126                 }
127                 layui.form.render("select");//重新渲染 固定写法
128             },
129         });
130     }
131
132     form.on("select", function (data) {
133         switch(data.elem.id){
134             case 'lineCode':
135                 console.log(data.value);
136                 if(data.value === ""){
137                     $('#locationCode').empty();
138                     layui.form.render("select");//重新渲染 固定写法
139                 }else {
140                     $.ajax({
141                         type: "POST",
142                         contentType: "application/json;charset=UTF-8",
143                         url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
144                         success: function (result) {
145                             $('#locationCode').empty();
146                             $('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
147
148                             $.each(result.data, function (index, value) {
149                                 $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
150                             });
151                             layui.form.render("select");//重新渲染 固定写法
152                         },
153                     });
154                 }
155                 break;
156             case 'locationCode':
157                 console.log($('#locationCode').val());
158                 console.log($('#lineCode').val());
159                 var getIp = new $ax(Feng.ctxPath + "/kanbanConf/ipSetting?lineCode="+$('#lineCode').val()+"&locationCode="+$('#locationCode').val());
160                 var result = getIp.start();
161                 Feng.info("更新完成!")
162                 break;
163         }
164     });
165
92cffc 166     // //redio闪烁
167     // setInterval(function() {
168     //     $('input[name="sex1"][value="nan1"]').prop('checked', true);
169     // }, 1000);
170     // setInterval(function() {
171     //     radioElement.prop('checked', false);
172     // }, 2000);
4779be 173
174     //Hash地址的定位
175     var layid = location.hash.replace(/^#test=/, '');
176     element.tabChange('test', layid);
177
178     element.on('tab(test)', function(elem){
179         location.hash = 'test='+ $(this).attr('lay-id');
180     });
181
92cffc 182     /**
183      * 基础BOM管理
184      */
185     var ProductBomChildInfo = {
186         tableId: "productBomChildInfoTable"
187     };
188
189     /**
190      * 初始化表格的列
191      */
192     ProductBomChildInfo.initColumn = function () {
193         return [[
194             {field: 'id', hide: true, title: '主键id'},
195             {field: 'opCode', sort: true, title: '工序编码'},
196             {field: 'opName', sort: true, title: '工序名称'},
197             {field: 'materialCode', sort: true, title: '物料编码'},
198             {field: 'costQty', sort: true, title: '单耗'},
199             {field: 'bomCode', sort: true, title: 'BOM编码'},
200         ]];
201     };
202
203     var queryData = {};
204     queryData['bomCode'] = "301002000021";
205     // 渲染表格
206     table.render({
207         elem: '#' + ProductBomChildInfo.tableId,
208         url: Feng.ctxPath + '/productBomChildInfo/list',
209         page: true,
210         height: 460,
211         cellMinWidth: 100,
212         where: queryData,
213         cols: ProductBomChildInfo.initColumn()
214     });
215
216     $("#scanCode").keydown(function(event) {
217         if (event.keyCode === 13) {
218             // 执行您想要的代码
219             var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/addFormulaState?formulaCode="+msg.recipeCode);
220             var result = ajax.start();
221             table.reload("formulaChildInfoTable")
222             return false; // 阻止默认行为
223         }
224     });
225
226     $("#clear").click(function() {
227         var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/clear?formulaCode="+msg.recipeCode);
228         var result = ajax.start();
229         table.reload("formulaChildInfoTable")
230     });
231
4779be 232 });