懒羊羊
2023-12-04 b3e9a47f4c17c0d708398698432a109420e7d9e1
提交 | 用户 | 时间
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",
b3e9a4 143                         url: Feng.ctxPath + '/opInfo/list?lineCode='+data.value,
4779be 144                         success: function (result) {
145                             $('#locationCode').empty();
146                             $('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
147
148                             $.each(result.data, function (index, value) {
b3e9a4 149                                 $('#locationCode').append(new Option(value.opCode));// 下拉菜单里添加元素
4779be 150                             });
151                             layui.form.render("select");//重新渲染 固定写法
152                         },
153                     });
154                 }
155                 break;
156             case 'locationCode':
157                 var getIp = new $ax(Feng.ctxPath + "/kanbanConf/ipSetting?lineCode="+$('#lineCode').val()+"&locationCode="+$('#locationCode').val());
158                 var result = getIp.start();
159                 Feng.info("更新完成!")
160                 break;
161         }
162     });
163
92cffc 164     // //redio闪烁
165     // setInterval(function() {
166     //     $('input[name="sex1"][value="nan1"]').prop('checked', true);
167     // }, 1000);
168     // setInterval(function() {
169     //     radioElement.prop('checked', false);
170     // }, 2000);
4779be 171
172     //Hash地址的定位
173     var layid = location.hash.replace(/^#test=/, '');
174     element.tabChange('test', layid);
175
176     element.on('tab(test)', function(elem){
177         location.hash = 'test='+ $(this).attr('lay-id');
178     });
179
92cffc 180     /**
181      * 基础BOM管理
182      */
183     var ProductBomChildInfo = {
184         tableId: "productBomChildInfoTable"
185     };
186
187     /**
188      * 初始化表格的列
189      */
190     ProductBomChildInfo.initColumn = function () {
191         return [[
192             {field: 'id', hide: true, title: '主键id'},
193             {field: 'opCode', sort: true, title: '工序编码'},
194             {field: 'opName', sort: true, title: '工序名称'},
195             {field: 'materialCode', sort: true, title: '物料编码'},
196             {field: 'costQty', sort: true, title: '单耗'},
197             {field: 'bomCode', sort: true, title: 'BOM编码'},
198         ]];
199     };
200
201     var queryData = {};
202     queryData['bomCode'] = "301002000021";
203     // 渲染表格
204     table.render({
205         elem: '#' + ProductBomChildInfo.tableId,
206         url: Feng.ctxPath + '/productBomChildInfo/list',
207         page: true,
208         height: 460,
209         cellMinWidth: 100,
210         where: queryData,
211         cols: ProductBomChildInfo.initColumn()
212     });
213
214     $("#scanCode").keydown(function(event) {
215         if (event.keyCode === 13) {
216             // 执行您想要的代码
217             var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/addFormulaState?formulaCode="+msg.recipeCode);
218             var result = ajax.start();
219             table.reload("formulaChildInfoTable")
220             return false; // 阻止默认行为
221         }
222     });
223
224     $("#clear").click(function() {
225         var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/clear?formulaCode="+msg.recipeCode);
226         var result = ajax.start();
227         table.reload("formulaChildInfoTable")
228     });
229
4779be 230 });