|
@@ -142,8 +142,7 @@
|
142
|
142
|
$("#brand").empty();
|
143
|
143
|
$("#brand").append('<option value="">品牌</option>');
|
144
|
144
|
$.each($.parseJSON(data), function(idx, obj) {
|
145
|
|
- $("#brand").append("<option value=\""+obj.id+"\">"+obj.varietyDetails+"</option>");
|
146
|
|
- });
|
|
145
|
+ $("#brand").append("<option value=\""+obj.id+"\" data-variety-id=\""+obj.varietyId+"\">"+obj.varietyDetails+"</option>"); });
|
147
|
146
|
|
148
|
147
|
layui.form.render("select");
|
149
|
148
|
},error:function (xhr, status, error) {
|
|
@@ -173,7 +172,6 @@
|
173
|
172
|
type: 'post',
|
174
|
173
|
data:{'id':data.value},
|
175
|
174
|
success: function (data) {
|
176
|
|
- layer.alert('请求失败: ' + data);
|
177
|
175
|
$("#productName").empty();$("#productCode").empty();$("#varietyDetailId").empty();
|
178
|
176
|
|
179
|
177
|
// $("#productName").append('<option value="">物料描述</option>');
|
|
@@ -207,21 +205,97 @@
|
207
|
205
|
layer.alert('请求失败: ' + error);
|
208
|
206
|
}});
|
209
|
207
|
});
|
|
208
|
+ function fillRowData(rowElement, data) {
|
|
209
|
+ var fieldMapping = {
|
|
210
|
+ 'productCode': 'productCode',
|
|
211
|
+ 'productName': 'productName',
|
|
212
|
+ 'color': 'color',
|
|
213
|
+ 'position': 'position',//镜片位置
|
|
214
|
+ 'sphericalLens': 'sphericalLens',
|
|
215
|
+ 'cylindricalLens': 'cylindricalLens',
|
|
216
|
+ 'axis': 'axis',
|
|
217
|
+ 'channel': 'channel',
|
|
218
|
+ 'add': 'add',
|
|
219
|
+ 'remarks': 'remarks',
|
|
220
|
+ 'retailPrice': 'retailPrice',
|
|
221
|
+ 'rangeDescription': 'rangeDescription',
|
|
222
|
+ 'singleEyePupillaryDistanceRight': 'singleEyePupillaryDistanceRight',
|
|
223
|
+ 'pupillaryHeight': 'pupillaryHeight',
|
|
224
|
+ 'lensEdgeDistance': 'lensEdgeDistance',
|
|
225
|
+ 'frontAngle': 'frontAngle',
|
|
226
|
+ 'frameSurface': 'frameSurface',
|
|
227
|
+ 'diopterRange': 'diopterRange',
|
|
228
|
+ 'habitReadingDistance': 'habitReadingDistance',
|
|
229
|
+ 'nearUsePupillaryDistance': 'nearUsePupillaryDistance',
|
|
230
|
+ 'nvb': 'nvb',
|
|
231
|
+ 'mainVision': 'mainVision',
|
|
232
|
+ 'ercd': 'ercd',
|
|
233
|
+ };
|
210
|
234
|
|
|
235
|
+ $.each(fieldMapping, function(inputName, dataField) {
|
|
236
|
+ if (data[dataField]) {
|
|
237
|
+ rowElement.find('input[name="' + inputName + '"]').val(data[dataField]);
|
|
238
|
+ }
|
|
239
|
+ });
|
|
240
|
+ }
|
211
|
241
|
//因为动态添加的元素class属性是无效的,所以不能用$('.add').click(function(){});
|
212
|
242
|
window.addtable= function(){
|
213
|
|
- var selectedVarietyDetailId = $('#productName option:selected').data('variety-detail-id') ||
|
214
|
|
- $('#productCode option:selected').data('variety-detail-id');
|
215
|
|
- layer.alert(selectedVarietyDetailId);
|
|
243
|
+ var html = '<tr>'+
|
|
244
|
+ '<td style = "width: 100px"><input type="button" class="layui-btn layui-btn-radius" onclick="dele(this)" value="删除" /></td>'+
|
|
245
|
+ '<td style = "width: 200px"> <input type="text" name="materialCode" required lay-verify="required" placeholder="物料编码" autocomplete="off" class="layui-input" readonly="true" value="'+ $('#productCode option:selected').text()+'"/></td>'+
|
|
246
|
+ '<td style = "width: 500px"> <input type="text" name="materialDetile" required lay-verify="required" placeholder="物料描述" autocomplete="off" class="layui-input" readonly="true" value="'+$('#productName option:selected').text()+'"/></td>'+
|
|
247
|
+ '<td style = "width: 100px">' +
|
|
248
|
+ '<select name="colour" class="county-selector" placeholder="颜色" lay-filter="productName">'+
|
|
249
|
+ '</select></td>'+
|
|
250
|
+ '<td style="width:200px">'+
|
|
251
|
+ '<select name="position" placeholder="位置" lay-verify="required">'+
|
|
252
|
+ '<option value="">--请选择--</option>'+
|
|
253
|
+ '<option value="L">L</option>'+
|
|
254
|
+ '<option value="R">R</option>'+
|
|
255
|
+ '</select></td>'+
|
|
256
|
+ '<td style = "width: 150px"> <input type="text" name="sphericalLens" placeholder="球镜" autocomplete="off" class="layui-input"></td>'+
|
|
257
|
+ '<td style = "width: 150px"> <input type="text" name="cylindricalLens" placeholder="柱镜" autocomplete="off" class="layui-input"></td>'+
|
|
258
|
+ '<td style = "width: 150px"> <input type="text" name="axis" placeholder="轴位" autocomplete="off" class="layui-input"></td>'+
|
|
259
|
+ '<td style = "width: 100px">' +
|
|
260
|
+ '<select name="channel" class="county-selector" placeholder="通道" lay-filter="productName">'+
|
|
261
|
+ '</select></td>'+
|
|
262
|
+ '<td style = "width: 150px"> <input type="text" name="addNum" placeholder="下加光" autocomplete="off" class="layui-input"></td>'+
|
|
263
|
+ '<td style = "width: 300px"> <input type="text" name="remarks" placeholder="备注" autocomplete="off" class="layui-input"></td>'+
|
|
264
|
+ '<td style = "width: 150px"> <input type="text" name="retailPrice" required lay-verify="required" placeholder="零售价" autocomplete="off" class="layui-input" /></td>'+
|
|
265
|
+ '<td style = "width: 300px"> <input type="text" name="rangeDescription" placeholder="光度范围" autocomplete="off" class="layui-input"></td>'+
|
|
266
|
+ '<td style = "width: 150px"> <input type="text" name="diopterRange" placeholder="光度说明" autocomplete="off" class="layui-input"></td>'+
|
|
267
|
+ '<td style = "width: 150px"> <input type="text" name="singleEyePupillaryDistance" placeholder="单眼瞳距" autocomplete="off" class="layui-input"></td>'+
|
|
268
|
+ '<td style = "width: 150px"> <input type="text" name="pupillaryHeight" placeholder="单眼瞳高" autocomplete="off" class="layui-input"></td>'+
|
|
269
|
+ '<td style = "width: 150px"> <input type="text" name="lensEdgeDistance" placeholder="镜眼距离" autocomplete="off" class="layui-input"></td>'+
|
|
270
|
+ '<td style = "width: 150px"> <input type="text" name="frontAngle" placeholder="前倾角" autocomplete="off" class="layui-input"></td>'+
|
|
271
|
+ '<td style = "width: 150px"> <input type="text" name="frameSurface" placeholder="镜架面弯" autocomplete="off" class="layui-input"></td>'+
|
|
272
|
+ '<td style = "width: 150px"> <input type="text" name="habitReadingDistance" placeholder="习惯阅读距离" autocomplete="off" class="layui-input"></td>'+
|
|
273
|
+ '<td style = "width: 150px"> <input type="text" name="nearUsePupillaryDistance" placeholder="近用瞳距" autocomplete="off" class="layui-input"></td>'+
|
|
274
|
+ '<td style = "width: 150px"> <input type="text" name="nvb" placeholder="NVB" autocomplete="off" class="layui-input"></td>'+
|
|
275
|
+ '<td style = "width: 75px"> <input type="text" name="mainVision" placeholder="主视眼" autocomplete="off" class="layui-input"></td>'+
|
|
276
|
+ '<td style = "width: 150px"> <input type="text" name="ercd" placeholder="ERCD" autocomplete="off" class="layui-input"></td>'+
|
|
277
|
+
|
|
278
|
+ '</tr>';
|
|
279
|
+ //添加到表格最后
|
|
280
|
+ $(html).appendTo($('#table tbody:last'));
|
|
281
|
+
|
|
282
|
+ var newRow = $('#table tbody tr:last');
|
|
283
|
+ var varietyId = $('#brand option:selected').data('variety-id');
|
|
284
|
+ var selectedVarietyDetailId = $('#productName option:selected').data('variety-id');
|
|
285
|
+ var selectedVarietyDetailId = $('#productName option:selected').data('variety-detail-id');
|
|
286
|
+ var currentRowColourId = 'colour_' + Date.now();
|
|
287
|
+ var currentRowChannelId = 'channel_' + Date.now();
|
|
288
|
+ newRow.find('select[name="colour"]').attr('id', currentRowColourId);
|
|
289
|
+ newRow.find('select[name="channel"]').attr('id', currentRowChannelId);
|
216
|
290
|
$.ajax({
|
217
|
291
|
url: 'selectColour',
|
218
|
292
|
type: 'post',
|
219
|
293
|
data:{'id':selectedVarietyDetailId},
|
220
|
294
|
success: function (data) {
|
221
|
|
- $("#colour").empty();
|
222
|
|
- $("#colour").append('<option value="">颜色</option>');
|
|
295
|
+ $("#" + currentRowColourId).empty();
|
|
296
|
+ $("#" + currentRowColourId).append('<option value="">颜色</option>');
|
223
|
297
|
$.each($.parseJSON(data), function(idx, obj) {
|
224
|
|
- $("#colour").append("<option value=\""+obj.id+"\">"+obj.colour+"</option>");
|
|
298
|
+ $("#" + currentRowColourId).append("<option value=\""+obj.colour+"\">"+obj.colour+"</option>");
|
225
|
299
|
});
|
226
|
300
|
|
227
|
301
|
layui.form.render("select");
|
|
@@ -229,58 +303,36 @@
|
229
|
303
|
layer.alert('请求失败: ' + error);
|
230
|
304
|
}});
|
231
|
305
|
$.ajax({
|
232
|
|
- url: 'productionheader',
|
|
306
|
+ url:'selectChannel',
|
233
|
307
|
type: 'post',
|
234
|
|
- data:{'id':selectedVarietyDetailId},
|
|
308
|
+ data:{'id':varietyId},
|
235
|
309
|
success: function (data) {
|
236
|
|
- layer.alert('请求失败: ' + data);
|
237
|
|
- $("#productName").empty();$("#productCode").empty();$("#varietyDetailId").empty();
|
238
|
|
-
|
|
310
|
+ $("#" + currentRowChannelId).empty(); // 使用当前行的唯一ID
|
|
311
|
+ $("#" + currentRowChannelId).append('<option value="">通道</option>'); // 添加默认选项
|
239
|
312
|
$.each($.parseJSON(data), function(idx, obj) {
|
240
|
|
- $("#productName").append("<option value=\""+obj.productName+"\" data-variety-detail-id=\""+obj.varietyDetailId+"\">"+obj.productName+"</option>");
|
241
|
|
- $("#productCode").append("<option value=\""+obj.productCode+"\" data-variety-detail-id=\""+obj.varietyDetailId+"\">"+obj.productCode+"</option>");
|
242
|
|
-
|
|
313
|
+ $("#" + currentRowChannelId).append("<option value=\""+obj.td+"\">"+obj.td+"</option>"); // 使用当前行的唯一ID
|
243
|
314
|
});
|
244
|
|
- layui.form.render("select");
|
|
315
|
+ layui.form.render("select"); // 重新渲染表单
|
|
316
|
+ },
|
|
317
|
+ error:function (xhr, status, error) {
|
|
318
|
+ layer.alert('请求失败: ' + error);
|
|
319
|
+ }
|
|
320
|
+ })
|
|
321
|
+ $.ajax({
|
|
322
|
+ url: 'productionheader',
|
|
323
|
+ type: 'post',
|
|
324
|
+ data:{'id':selectedVarietyDetailId},
|
|
325
|
+ success: function (data) {
|
|
326
|
+ var parsedData = $.parseJSON(data);
|
|
327
|
+ if (parsedData && parsedData.length > 0) {
|
|
328
|
+ // 使用第一个对象的数据填充行
|
|
329
|
+ var rowData = parsedData[0];
|
|
330
|
+ fillRowData(newRow, rowData);
|
|
331
|
+ }
|
245
|
332
|
},error:function (xhr, status, error) {
|
246
|
333
|
layer.alert('请求失败: ' + error);
|
247
|
334
|
}});
|
248
|
|
- var html = '<tr>'+
|
249
|
|
- '<td style = "width: 100px"><input type="button" class="layui-btn layui-btn-radius" onclick="dele(this)" value="删除" /></td>'+
|
250
|
|
- '<td style = "width: 200px"> <input type="text" name="materialCode" required lay-verify="required" placeholder="物料编码" autocomplete="off" class="layui-input" readonly="true" value="'+ $('#productCode option:selected').text()+'"/></td>'+
|
251
|
|
- '<td style = "width: 500px"> <input type="text" name="materialDetile" required lay-verify="required" placeholder="物料描述" autocomplete="off" class="layui-input" readonly="true" value="'+$('#productName option:selected').text()+'"/></td>'+
|
252
|
|
- '<td style = "width: 100px">' +
|
253
|
|
- '<select name="colour" id ="colour" class="county-selector" placeholder="颜色" lay-filter="productName">'+
|
254
|
|
- '</select></td>'+
|
255
|
|
- '<td style="width:200px">'+
|
256
|
|
- '<select name="WZ" lay-verify="required">'+
|
257
|
|
- '<option value="">--请选择--</option>'+
|
258
|
|
- '<option value="L">L</option>'+
|
259
|
|
- '<option value="R">R</option>'+
|
260
|
|
- '</select></td>'+
|
261
|
|
- '<td style = "width: 150px"> <input type="text" name="SPH" placeholder="球镜" autocomplete="off" class="layui-input"></td>'+
|
262
|
|
- '<td style = "width: 150px"> <input type="text" name="CYL" placeholder="柱镜" autocomplete="off" class="layui-input"></td>'+
|
263
|
|
- '<td style = "width: 150px"> <input type="text" name="AXIS" placeholder="轴位" autocomplete="off" class="layui-input"></td>'+
|
264
|
|
- '<td style = "width: 150"> <input type="text" name="YULIU1" placeholder="通道" autocomplete="off" class="layui-input"></td>'+
|
265
|
|
- '<td style = "width: 150px"> <input type="text" name="XADD" placeholder="下加光" autocomplete="off" class="layui-input"></td>'+
|
266
|
|
- '<td style = "width: 300px"> <input type="text" name="MARK" placeholder="备注" autocomplete="off" class="layui-input"></td>'+
|
267
|
|
- '<td style = "width: 150px"> <input type="text" name="NUM" required lay-verify="required" placeholder="零售价" autocomplete="off" class="layui-input" /></td>'+
|
268
|
|
- '<td style = "width: 300px"> <input type="text" name="CVA" placeholder="光度范围" autocomplete="off" class="layui-input"></td>'+
|
269
|
|
- '<td style = "width: 150px"> <input type="text" name="SD" placeholder="光度说明" autocomplete="off" class="layui-input"></td>'+
|
270
|
|
- '<td style = "width: 150px"> <input type="text" name="PDFOD" placeholder="单眼瞳距" autocomplete="off" class="layui-input"></td>'+
|
271
|
|
- '<td style = "width: 150px"> <input type="text" name="PH" placeholder="单眼瞳高" autocomplete="off" class="layui-input"></td>'+
|
272
|
|
- '<td style = "width: 150px"> <input type="text" name="FRAMEBRIDGEWIDTH" placeholder="镜眼距离" autocomplete="off" class="layui-input"></td>'+
|
273
|
|
- '<td style = "width: 150px"> <input type="text" name="OPTICBC" placeholder="前倾角" autocomplete="off" class="layui-input"></td>'+
|
274
|
|
- '<td style = "width: 150px"> <input type="text" name="FRAMESHAPE" placeholder="镜架面弯" autocomplete="off" class="layui-input"></td>'+
|
275
|
|
- '<td style = "width: 150px"> <input type="text" name="FRAMEHEIGHT" placeholder="习惯阅读距离" autocomplete="off" class="layui-input"></td>'+
|
276
|
|
- '<td style = "width: 150px"> <input type="text" name="PRISM" placeholder="近用瞳距" autocomplete="off" class="layui-input"></td>'+
|
277
|
|
- '<td style = "width: 150px"> <input type="text" name="RS" placeholder="NVB" autocomplete="off" class="layui-input"></td>'+
|
278
|
|
- '<td style = "width: 75px"> <input type="text" name="LRS" placeholder="主视眼" autocomplete="off" class="layui-input"></td>'+
|
279
|
|
- '<td style = "width: 150px"> <input type="text" name="CRS" placeholder="ERCD" autocomplete="off" class="layui-input"></td>'+
|
280
|
335
|
|
281
|
|
- '</tr>';
|
282
|
|
- //添加到表格最后
|
283
|
|
- $(html).appendTo($('#table tbody:last'));
|
284
|
336
|
form.render();
|
285
|
337
|
}
|
286
|
338
|
window.dele= function (obj){
|
|
@@ -304,6 +356,11 @@
|
304
|
356
|
window.adddata= function() {
|
305
|
357
|
table=document.getElementById("table");
|
306
|
358
|
let tr=table.getElementsByTagName("tr");
|
|
359
|
+
|
|
360
|
+/* let productCode=table.getElementsByName("materialCode");
|
|
361
|
+ let productName=table.getElementsByName("materialDetile");
|
|
362
|
+ let colour=table.getElementsByName("colour");*/
|
|
363
|
+
|
307
|
364
|
var arrayObj = new Array();
|
308
|
365
|
for (var i=0; i<tr.length; i++){
|
309
|
366
|
let target=tr[i].querySelectorAll("[name]"),obj={};
|