rabin 2 years ago
parent
commit
ce57d2f930

+ 30 - 1
assets/lib/layui/admin/modules/plugin/formselects/formselects.js

@@ -36,6 +36,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
         LABEL = 'xm-select-label',
         SEARCH = 'xm-select-search',
         SEARCH_TYPE = 'xm-select-search-type',
+        CALL = 'xm-select-callback',
+        CALLPARAM = 'xm-select-callback-param',
         SHOW_COUNT = 'xm-select-show-count',
         CREATE = 'xm-select-create',
         CREATE_LONG = 'xm-select-create-long',
@@ -253,6 +255,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
                 max: othis.attr(MAX) - 0,
                 isSearch: othis.attr(SEARCH) != undefined,
                 searchUrl: othis.attr(SEARCH),
+                callback: othis.attr(CALL),
+                callbackParam: othis.attr(CALLPARAM),
                 isCreate: othis.attr(CREATE) != undefined,
                 radio: othis.attr(RADIO) != undefined,
                 skin: othis.attr(SKIN),
@@ -321,6 +325,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
             if (fs.config.isSearch) {
                 ajaxs[id] = $.extend({}, ajax, { searchUrl: fs.config.searchUrl }, ajaxs[id]);
                 ajaxs[id].searchUrl = fs.config.searchUrl;
+                ajaxs[id].callback = fs.config.callback;
+                ajaxs[id].callbackParam = fs.config.callbackParam;
                 $(document).on('input', 'div.' + PNAME + '[FS_ID="' + id + '"] .' + INPUT, function (e) {
                     _this2.search(id, e, fs.config.searchUrl);
                 });
@@ -481,7 +487,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
                     res = newRes;
                 }
                 if (res[ajaxConfig.response.statusName] != ajaxConfig.response.statusCode) {
-                    reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text(res[ajaxConfig.response.msgName]);
+                    reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
+                    _this5.renderData(id, [], isLinkage, linkageWidth, isSearch, isReplace);
+                     data[id].config.isEmpty = true;
                 } else {
                     reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
                     _this5.renderData(id, res[ajaxConfig.response.dataName], isLinkage, linkageWidth, isSearch, isReplace);
@@ -1227,6 +1235,25 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
 
         this.commonHandler(id, div);
 
+        var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+        if (ajaxConfig.callback) {
+            $('#' + id).attr('v', val.id);
+            var param = eval('(' + ajaxConfig.callbackParam + ')');
+            if (param['col']) {
+                if (param['col'].indexOf(',') != -1) {
+                    var temp = param['col'].split(',');
+                    for (var i in temp) {
+                        if (val[temp[i]]) {
+                            param[temp[i]] = val[temp[i]];
+                        }
+                    }
+                } else if (val[param['col']]) {
+                    param[param['col']] = val[param['col']];
+                }
+            }
+            loading($('#' + id), param, 1);
+        }
+
         !notOn && endOn && endOn instanceof Function && endOn(id, vals.concat([]), val, isAdd, dd && dd.hasClass(DISABLED));
     };
 
@@ -1670,6 +1697,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
             max: options.max,
             isSearch: options.isSearch,
             searchUrl: options.searchUrl,
+            callback: options.callback,
+            callbackParam: options.callbackParam,
             isCreate: options.isCreate,
             radio: options.radio,
             skin: options.skin,

+ 21 - 10
assets/lib/manage/main.js

@@ -1017,18 +1017,22 @@ function selector(e)
 
 
 //根据e的值,来载入其他数据
-function loading(e, data)
+function loading(e, data, type)
 {
-	var value = e.val();
-	if(e.attr('id') && e.attr('id').indexOf('_temp') != -1)
-	{
-		var id = e.attr('id').replace('_temp', '');
-		if($('#' + id).length)
+	if (type == 1) {
+		var value = e.attr('v');
+	} else {
+		var value = e.val();
+		if(e.attr('id') && e.attr('id').indexOf('_temp') != -1)
 		{
-			var value = $('#' + id).val();
+			var id = e.attr('id').replace('_temp', '');
+			if($('#' + id).length)
+			{
+				var value = $('#' + id).val();
+			}
 		}
 	}
-
+	
 	if(data.element)
 	{
 		if(data.url)
@@ -1059,7 +1063,8 @@ function loading(e, data)
 				t = t.html;
 				if (d) {
 					for(var i in d) {
-						$('#update_'+i+'_value').val(d[i]);
+						//$('#update_'+i+'_value').val(d[i]);
+						$('#update_'+i).val(d[i]);
 					}
 				}
 			}
@@ -1070,6 +1075,7 @@ function loading(e, data)
 			else
 			{
 				var parent = e.parent().parent();
+				var tagName = parent.prop("tagName");
 				if(t.indexOf('status') == -1)
 				{
 					if(data.type == 1)
@@ -1088,7 +1094,12 @@ function loading(e, data)
 					}
 
 					if (!parent.parent().find('.bind_show').length) {
-						parent.after('<div class="bind_show">' + t + '</div>');
+						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);
 					}