dever il y a 2 ans
Parent
commit
fbf8054576
2 fichiers modifiés avec 82 ajouts et 74 suppressions
  1. 2 2
      assets/lib/layui/admin/modules/plugin/skuTable.js
  2. 80 72
      assets/lib/manage/main.js

+ 2 - 2
assets/lib/layui/admin/modules/plugin/skuTable.js

@@ -484,7 +484,7 @@ layui.define(['jquery', 'form', 'upload', 'layer', 'sortable'], function (export
                         table += '<td>';
                         table += `<select style="width: 100%;" name="skus[-1][${item.field}]" lay-verify="${item.verify}" lay-reqtext="${item.reqtext}">`;
                         item.option.forEach(function (o) {
-                            table += `<option value="${o.value}" ${that.options.skuData && that.options.skuData[-1] && that.options.skuData[-1][item.field] && that.options.skuData[item.field] == o.value ? 'selected' : ''}>${o.key}</option>`;
+                            table += `<option value="${o.id}" ${that.options.skuData && that.options.skuData[-1] && that.options.skuData[-1][item.field] && that.options.skuData[item.field] == o.id ? 'selected' : ''}>${o.name}</option>`;
                         });
                         table += '</select>';
                         table += '</td>';
@@ -667,7 +667,7 @@ layui.define(['jquery', 'form', 'upload', 'layer', 'sortable'], function (export
                                 var skuValue = that.getSkuData(that.options.skuData, item, c);
                                 tr += '<td><select style="width: 100%;" name="' + that.makeSkuName(item, c) + '" lay-verify="' + c.verify + '" lay-reqtext="' + c.reqtext + '">';
                                 c.option.forEach(function (o) {
-                                    tr += '<option value="' + o.value + '" ' + (skuValue && skuValue == o.value ? 'selected' : '') + '>' + o.key + '</option>';
+                                    tr += '<option value="' + o.id + '" ' + (skuValue && skuValue == o.id ? 'selected' : '') + '>' + o.name + '</option>';
                                 });
                                 tr += '</select></td>';
                                 break;

+ 80 - 72
assets/lib/manage/main.js

@@ -893,16 +893,19 @@ function inputShowOneValiDate(e)
 
 //批量更新
 var list_mul_state = 1;
-function list_mul(e)
+function list_mul(e, t, url)
 {
-	var type = parseInt($("#mul_type").val());
-	if(type != 1 && type != 2)
-	{
-		alert('您还没有选择数据更新方式');
-		return;
+	if (t == 1) {
+		var type = parseInt($("#mul_type").val());
+		if(type != 1 && type != 2)
+		{
+			showAlert('您还没有选择数据');
+			return;
+		}
 	}
+	
 	if (list_mul_state == 2) {
-		alert('请不要重复点击');
+		showAlert('请不要重复点击');
 		return;
 	}
 	var index = layer.confirm('确定进行此项操作吗?', function()
@@ -911,6 +914,9 @@ function list_mul(e)
 		$('#method').val('mul');
 		$('#function').val('msg');
 		layer.close(index);
+		if (url) {
+			$('#method').val('mul.' + url);
+		}
 		$('#form1').attr('target', 'f1').submit();
 	})
 }
@@ -1029,90 +1035,87 @@ function loading(e, data, type)
 		var value = e.attr('v');
 	} else {
 		var value = e.val();
-		if(e.attr('id') && e.attr('id').indexOf('_temp') != -1)
-		{
+		if (e.attr('id') && e.attr('id').indexOf('_temp') != -1) {
 			var id = e.attr('id').replace('_temp', '');
-			if($('#' + id).length)
-			{
+			if ($('#' + id).length) {
 				var value = $('#' + id).val();
 			}
 		}
 	}
 	
-	if(data.element)
-	{
-		if(data.url)
-		{
+	if (data.element) {
+		if (data.url) {
 			data.value = value;
-			$.getJSON(data.url + '&json=1', data, function(t)
-			{
-				$('#update_'+data.element+'_value').val(t.data);
+			$.getJSON(data.url + '&json=1', data, function(t) {
+				$('#update_'+data.element+'').val(t.data);
 			});
+		} else {
+			$('#update_'+data.element+'').val(value);
 		}
-		else
-		{
-			$('#update_'+data.element+'_value').val(value);
-		}
-	}
-	else if(data.url)
-	{
+	} else if(data.url) {
 		data.value = value;
 		data.where_id = $('#update_where_id').val();
 		data.table = $('#table').val();
 		data.project = $('#project').val();
-
-		$.getJSON(data.url + '&json=1', data, function(s)
-		{
+		var parent = e.parent().parent();
+		var tagName = parent.prop("tagName");
+		$.getJSON(data.url + '&json=1', data, function(s) {
 			t = s.data;
 			if (typeof(t) == 'object') {
 				var d = t.data;
 				t = t.html;
 				if (d) {
 					for(var i in d) {
-						//$('#update_'+i+'_value').val(d[i]);
-						$('#update_'+i).val(d[i]);
+						if (tagName == 'TD') {
+							var p = parent.parent();
+							var ti = p.attr('id') + '_i_' + i;
+							var ue = $('#update_'+ti);
+						} else {
+							var ue = $('#update_'+i);
+						}
+						var div = ue.prop("tagName");
+						if (div == 'DIV') {
+							ue.html(d[i]);
+						} else {
+							ue.val(d[i]);
+						}
 					}
 				}
 			}
-			if(t.indexOf('onblur') != -1)
-			{
-				eval(t);
-			}
-			else
-			{
-				var parent = e.parent().parent();
-				var tagName = parent.prop("tagName");
-				if(t.indexOf('status') == -1)
-				{
-					if(data.type == 1)
-					{
-						$('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
-						{
-							$(this).remove();
-						});
-					}
-					else
-					{
-						$('.checking_-1,.checking_3,.checking_4').each(function()
-						{
-							$(this).remove();
-						});
-					}
 
-					if (!parent.parent().find('.bind_show').length) {
-						if (tagName == 'TD') {
-							parent.next().html('<div class="bind_show">' + t + '</div>');
+			if (t) {
+				if (t.indexOf('onblur') != -1) {
+					eval(t);
+				} else {
+					if (t.indexOf('status') == -1) {
+						if (data.type == 1) {
+							$('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
+							{
+								$(this).remove();
+							});
 						} else {
-							parent.after('<div class="bind_show">' + t + '</div>');
+							$('.checking_-1,.checking_3,.checking_4').each(function()
+							{
+								$(this).remove();
+							});
+						}
+
+						if (!parent.parent().find('.bind_show').length) {
+							if (tagName == 'TD') {
+								parent.next().html('<div class="bind_show">' + t + '</div>');
+							} else {
+								parent.after('<div class="bind_show">' + t + '</div>');
+							}
+							
+						} else if (parent.parent().find('.bind_show').html() != t) {
+							parent.parent().find('.bind_show').html(t);
 						}
-						
-					} else if (parent.parent().find('.bind_show').html() != t) {
-						parent.parent().find('.bind_show').html(t);
-					}
 
-					checkbox();
+						checkbox();
+					}
 				}
 			}
+			
 		});
 	}
 }
@@ -1203,7 +1206,7 @@ function autocomplete()
 
 					var cate = self.attr('complete_cate');
 					if (cate) {
-						request[cate] = $('update_' + cate + '_value').val();
+						request[cate] = $('#update_' + cate).val();
 					}
 					
 			 
@@ -1478,8 +1481,9 @@ function msg(value)
 	}
 	submit();
 	var url = '';
-	if(value.data != 'reload' && value.status == 2)
+	if(value.data != 'reload' && value.status == 2 && value.code == 1)
 	{
+		list_mul_state = 1;
 		showAlert(value.msg, false, '错误提示');
 		//alert(value.data);
 		//location.reload();
@@ -3377,16 +3381,20 @@ function sku(e)
 			var type = 'required';
 			var value = '';
 		}
-		if (data[i]['type'] == 'image') {
-			var icon = '';
-		} else {
+		if (data[i]['type'] == 'input') {
 			var icon = 'layui-icon-cols';
+		} else {
+			var icon = '';
 		}
 		mthead.push({title: data[i]['name'], icon: icon});
-		mtbody.push({type: data[i]['type'], field: i, value: value, verify: type, reqtext: data[i]['name'] + '不能为空'});
-		if (data[i]['type'] != 'image') {
+		var option = {type: data[i]['type'], field: i, value: value, verify: type, reqtext: data[i]['name'] + '不能为空'};
+		if (option.type == 'select') {
+			option.option = eval("(" + data[i]['option'] + ")");
+		}
+		mtbody.push(option);
+		if (option.type != 'image') {
 			thead.push({title: data[i]['name'], icon: 'layui-icon-cols'});
-			tbody.push({type: data[i]['type'], field: i, value: value, verify: type, reqtext: data[i]['name'] + '不能为空'});
+			tbody.push(option);
 		}
 	}
  	var obj = skuTable.render({
@@ -3438,7 +3446,7 @@ function append(self, id)
 	total += append_total;
 	html = html.replaceAll('_-1_', '_' + total + '_');
 	html = html.replaceAll('up_', 'update_');
-	id = 'append_' + id + '_' + total;
+	id = 'update_' + id + '_c_' + total;
 	parent.append('<tr id="'+id+'">' + html + '</tr>');
 	form.render();
 	$('#' + id + " select").each(function()