|
@@ -2005,7 +2005,7 @@ function updateMsg(id)
|
|
|
$("#"+id).submit();
|
|
|
}
|
|
|
|
|
|
-function showAlert(msg, func, title, index)
|
|
|
+function showAlert(msg, func, title, index, t)
|
|
|
{
|
|
|
if (!title) {
|
|
|
title = '提醒您';
|
|
@@ -2015,6 +2015,9 @@ function showAlert(msg, func, title, index)
|
|
|
if (msg.indexOf('<') != -1) {
|
|
|
type = 1;
|
|
|
}
|
|
|
+ if (t) {
|
|
|
+ type = t;
|
|
|
+ }
|
|
|
|
|
|
var config = {
|
|
|
type: 0,
|
|
@@ -2024,17 +2027,20 @@ function showAlert(msg, func, title, index)
|
|
|
content: msg
|
|
|
};
|
|
|
|
|
|
+ if (index) {
|
|
|
+ config.zIndex = index;
|
|
|
+ }
|
|
|
+
|
|
|
config.scrollbar = false;
|
|
|
|
|
|
if (type == 1) {
|
|
|
- if (index) {
|
|
|
- config.zIndex = index;
|
|
|
- config.type = 1;
|
|
|
- config.btn = ['确定'];
|
|
|
- }
|
|
|
+ config.type = 1;
|
|
|
+ config.btn = ['保存', '关闭'];
|
|
|
+ config.area = '800px';
|
|
|
+ } else if (type == 2) {
|
|
|
+ config.type = 1;
|
|
|
+ config.btn = [];
|
|
|
config.area = '800px';
|
|
|
- //config.type = 1;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (func) {
|
|
@@ -2048,28 +2054,46 @@ function showAlert(msg, func, title, index)
|
|
|
layer.close(index);
|
|
|
};
|
|
|
}
|
|
|
+ config.btn2 = function(index)
|
|
|
+ {
|
|
|
+ layer.close(index);
|
|
|
+ };
|
|
|
var index = layer.open(config);
|
|
|
}
|
|
|
|
|
|
-function fastEdit(e, url, title, col, index)
|
|
|
+function fastEdit(e, url, title, col, index, type)
|
|
|
{
|
|
|
var func = function()
|
|
|
{
|
|
|
- submit_action();
|
|
|
+ console.info($(".fast"));
|
|
|
+ $(".fast").submit();
|
|
|
};
|
|
|
|
|
|
var send = {};
|
|
|
- send.col = col;
|
|
|
+ if (col) {
|
|
|
+ send.col = col;
|
|
|
+ }
|
|
|
|
|
|
- $.get(url,send,function(t)
|
|
|
+ $.get(url + '&fast=1',send,function(t)
|
|
|
{
|
|
|
var html = '';
|
|
|
var valid = '';
|
|
|
|
|
|
- if ($(t).find('form').length && $(t).find('#valid').length) {
|
|
|
- var html = $(t).find('form').prop("outerHTML");
|
|
|
- var valid = $(t).find('#valid').prop("outerHTML");
|
|
|
- html = html + valid;
|
|
|
+ if ($(t).find('form').length) {
|
|
|
+ if ($(t).find('form').length > 1) {
|
|
|
+ var form = $(t).find('form').eq(1);
|
|
|
+ form.addClass('layui-card-body');
|
|
|
+ } else {
|
|
|
+ var form = $(t).find('form').eq(0);
|
|
|
+ }
|
|
|
+ form.addClass('fast');
|
|
|
+ form.find('#function').eq(0).val('showYes');
|
|
|
+ var html = form.prop("outerHTML");
|
|
|
+ if ($(t).find('#valid').length) {
|
|
|
+ var valid = $(t).find('#valid').prop("outerHTML");
|
|
|
+ html = html + valid;
|
|
|
+ }
|
|
|
+
|
|
|
if (html.indexOf('left: 740px') != -1) {
|
|
|
html = html.replace('left: 740px', 'left:583px;')
|
|
|
}
|
|
@@ -2078,10 +2102,17 @@ function fastEdit(e, url, title, col, index)
|
|
|
func = false;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ if ($(html).find('.layui-card-body').length > 0) {
|
|
|
+ html = html.replace('class="layui-card-body"', 'class="layui-card-body" style="display:none"');
|
|
|
+ html = html.replaceAll('class="layui-btn layuiadmin-btn-list"', 'class="layui-btn layuiadmin-btn-list" style="display:none"');
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
if (index == 1) {
|
|
|
- showAlert(html, func, title, 19850422);
|
|
|
+ showAlert(html, func, title, 19850422, type);
|
|
|
} else {
|
|
|
- showAlert(html, func, title);
|
|
|
+ showAlert(html, func, title, type);
|
|
|
}
|
|
|
|
|
|
$('.layui-layer-content').css('overflow-x', 'hidden');
|
|
@@ -2125,7 +2156,11 @@ function showToggle(e)
|
|
|
initEditor($(id).find('.editor'));
|
|
|
}
|
|
|
|
|
|
-function select_linkage(level, id, url, name, value, valid, w, total, search, level_param)
|
|
|
+var select_api = {};
|
|
|
+var select_api_name = [];
|
|
|
+var select_api_title = '';
|
|
|
+var select_api_open = '';
|
|
|
+function select_linkage(level, id, url, name, value, valid, w, total, search, level_param, col, api, type, title, open)
|
|
|
{
|
|
|
var e = '#' + id;
|
|
|
var parent = value.split(',');
|
|
@@ -2135,6 +2170,7 @@ function select_linkage(level, id, url, name, value, valid, w, total, search, le
|
|
|
var html = '';
|
|
|
var old = level;
|
|
|
|
|
|
+ var level_name = '';
|
|
|
if (!total) {
|
|
|
level_id = 0;
|
|
|
} else {
|
|
@@ -2143,16 +2179,41 @@ function select_linkage(level, id, url, name, value, valid, w, total, search, le
|
|
|
return;
|
|
|
}
|
|
|
level_id = $(e + '_' + level).val();
|
|
|
+ if (level_id.indexOf('|') != -1) {
|
|
|
+ var temp = level_id.split('|');
|
|
|
+
|
|
|
+ if (level == 1) {
|
|
|
+ select_api_name = [];
|
|
|
+ }
|
|
|
+ level_id = temp[0];
|
|
|
+ level_name = temp[1];
|
|
|
+ select_api_name[level-1] = level_name;
|
|
|
+ }
|
|
|
+
|
|
|
level = parseInt(level) + 1;
|
|
|
}
|
|
|
- $.getJSON(url + '?json=1&callback=?', {level_search:search, level_id:level_id, level_num:level,level_param:level_param}, function(t) {
|
|
|
+
|
|
|
+ var api_name = '';
|
|
|
+ if (col && api) {
|
|
|
+ select_api_title = title;
|
|
|
+ select_api_open = open;
|
|
|
+ if (name.indexOf('_no') == -1) {
|
|
|
+ api_name = name;
|
|
|
+ } else {
|
|
|
+ var t = name.split('_no');
|
|
|
+ api_name = t[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ name += '_no';
|
|
|
+ }
|
|
|
+ $.getJSON(url + '&json=1&callback=?', {level_search:search, level_id:level_id, level_num:level,level_param:level_param}, function(t) {
|
|
|
var check = '';
|
|
|
if (t.status == 1) {
|
|
|
var total = t.data.level_total;
|
|
|
var data = t.data.list;
|
|
|
|
|
|
if(!$(e + '_' + level).length) {
|
|
|
- html = '<select lay-ignore style="display:inline;margin-top:10px;'+w+'" class="layui-input layui-select update_value form-control '+valid+'" id="'+id+'_'+level+'" name="'+name+'[]" onchange="select_linkage(\''+level+'\', \''+id+'\', \''+url+'\', \''+name+'\', \''+value+'\', \''+valid+'\', \''+w+'\', '+total+', \''+search+'\', \''+level_param+'\');">';
|
|
|
+ html = '<select lay-ignore style="display:inline;margin-top:10px;'+w+'" class="layui-input layui-select update_value form-control '+valid+'" id="'+id+'_'+level+'" name="'+name+'[]" onchange="select_linkage(\''+level+'\', \''+id+'\', \''+url+'\', \''+name+'\', \''+value+'\', \''+valid+'\', \''+w+'\', '+total+', \''+search+'\', \''+level_param+'\', \''+col+'\', \''+api+'\', \''+type+'\', \''+title+'\', \''+open+'\');">';
|
|
|
}
|
|
|
|
|
|
for (a in data) {
|
|
@@ -2161,7 +2222,11 @@ function select_linkage(level, id, url, name, value, valid, w, total, search, le
|
|
|
if (cur == data[a].value) {
|
|
|
check = ' selected';
|
|
|
}
|
|
|
- html += '<option value="'+data[a].value+'" '+check+'>'+data[a].name+'</option>';
|
|
|
+ var v = data[a].value;
|
|
|
+ if (col && api) {
|
|
|
+ v = data[a].value + '|' + data[a].name;
|
|
|
+ }
|
|
|
+ html += '<option value="'+v+'" '+check+'>'+data[a].name+'</option>';
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2177,6 +2242,31 @@ function select_linkage(level, id, url, name, value, valid, w, total, search, le
|
|
|
$(e + '_' + old).nextAll('select').remove();
|
|
|
$(e + '_' + old).next('span').nextAll('span').remove();
|
|
|
}
|
|
|
+ if (col && api && level_id > 0) {
|
|
|
+ var send = {};
|
|
|
+ send[col] = level_id;
|
|
|
+ $.getJSON(api + '&json=1&callback=?', send, function(r) {
|
|
|
+ var h = '<ul style="list-style:none;margin-top: 20px;display:;" class="">';
|
|
|
+
|
|
|
+ if (type == 'checkbox') {
|
|
|
+ h += '<li style="display:inline;margin-left:15px;"><input class="update_value" type="checkbox" onclick="select_linkage_check_all($(this), \'check_level_'+level_id+'\', \''+level_id+'\', \''+select_api_name.join('->')+'\', \''+e+'\', \''+api_name+'\')" value=""/> 全选</li>';
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var i in r.data) {
|
|
|
+ if (r.data[i]['name']) {
|
|
|
+ var checked = false;
|
|
|
+ if (select_api['level_' + level_id] && select_api['level_' + level_id]['value'] && select_api['level_' + level_id]['value']['id_' + r.data[i]['id']] && select_api['level_' + level_id]['value']['id_' + r.data[i]['id']]['state'] == 1) {
|
|
|
+ checked = true;
|
|
|
+ }
|
|
|
+ h += '<li style="display:inline;margin-left:15px;"><input onclick="select_linkage_check($(this), \''+level_id+'\', \''+select_api_name.join('->')+'\', \''+e+'\', \''+api_name+'\')" '+(checked ? 'checked' : '')+' class="update_value check_level_'+level_id+'" type="' + type + '" id="'+id+'_'+r.data[i]['id']+'" value="'+r.data[i]['id']+'|' + r.data[i]['name'] + '"/> ' + r.data[i]['name'] + '</li>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ h += '</ul>';
|
|
|
+ $(e + '_content').html(h);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
if ($('#' + name + '_level_value').length) {
|
|
@@ -2189,6 +2279,89 @@ function select_linkage(level, id, url, name, value, valid, w, total, search, le
|
|
|
}
|
|
|
*/
|
|
|
});
|
|
|
+ if (col && api) {
|
|
|
+ select_linkage_check_show(e, api_name);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function select_linkage_check_all(e, cur, level_id, level_name, id, api_name)
|
|
|
+{
|
|
|
+ var checked = e.prop('checked');
|
|
|
+ $('.' + cur).each(function() {
|
|
|
+ $(this).prop('checked', checked);
|
|
|
+ select_linkage_check($(this), level_id, level_name, id, api_name);
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function select_linkage_check(e, level_id, level_name, id, api_name, cid)
|
|
|
+{
|
|
|
+ var level_key = 'level_' + level_id;
|
|
|
+ if (!select_api[level_key]) {
|
|
|
+ select_api[level_key] = {};
|
|
|
+ select_api[level_key]['id'] = level_id;
|
|
|
+ select_api[level_key]['name'] = level_name;
|
|
|
+ select_api[level_key]['value'] = {};
|
|
|
+ }
|
|
|
+
|
|
|
+ var value = e.val();
|
|
|
+ var temp = value.split('|');
|
|
|
+ var key = 'id_' + temp[0];
|
|
|
+ if (e.prop('checked')) {
|
|
|
+ select_api[level_key]['value'][key] = {};
|
|
|
+ select_api[level_key]['value'][key]['id'] = temp[0];
|
|
|
+ select_api[level_key]['value'][key]['name'] = temp[1];
|
|
|
+ select_api[level_key]['value'][key]['state'] = 1;
|
|
|
+ } else {
|
|
|
+ if (select_api[level_key] && select_api[level_key]['value'] && select_api[level_key]['value'][key]) {
|
|
|
+ select_api[level_key]['value'][key]['state'] = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cid) {
|
|
|
+ $(cid).prop('checked', false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ select_linkage_check_show(id, api_name);
|
|
|
+}
|
|
|
+
|
|
|
+function select_linkage_check_show(id, api_name)
|
|
|
+{
|
|
|
+ if (select_api) {
|
|
|
+ var select_api_json = JSON.stringify(select_api);
|
|
|
+
|
|
|
+ var html = '<div style="margin-top: 20px;display:;border: 1px solid #5050b1;padding: 10px;">';
|
|
|
+
|
|
|
+ for (var i in select_api) {
|
|
|
+
|
|
|
+ if (select_api[i]['value']) {
|
|
|
+ html += '[' + select_api[i]['name'] + ']:<ul style="list-style:none;" class="">';
|
|
|
+ for (var j in select_api[i]['value']) {
|
|
|
+
|
|
|
+ var n = ' ' + select_api[i]['value'][j]['name'];
|
|
|
+
|
|
|
+ if (select_api_open) {
|
|
|
+ var o = select_api_open.replace('{id}', select_api[i]['value'][j]['id']);
|
|
|
+ n = '<a href="javascript:;" onclick="fastEdit($(this), \''+o+'\', \''+select_api_title+'\', \'\', 1,1)">'+n+'</a>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (select_api[i]['value'][j]['state'] == 2) {
|
|
|
+ n += '[已删除]';
|
|
|
+ var checked = false;
|
|
|
+ } else {
|
|
|
+ var checked = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ html += '<li style="display:inline;margin-left:15px;"><input onclick="select_linkage_check($(this), \''+select_api[i]['id']+'\', \''+select_api[i]['name']+'\', \''+id+'\', \''+api_name+'\', \''+id+'_'+select_api[i]['value'][j]['id']+'\')" '+(checked ? 'checked' : '')+' class="update_value" type="checkbox" id="s_'+select_api[i]['value'][j]['id']+'_test" name="s_'+select_api[i]['value'][j]['id']+'_test" value="'+select_api[i]['value'][j]['id']+'|' + select_api[i]['value'][j]['name'] + '"/>'+n+'</li>';
|
|
|
+ }
|
|
|
+ html += '</ul>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ html += '</div>';
|
|
|
+
|
|
|
+ html += '<textarea name="'+api_name+'" style="display:none">'+select_api_json+'</textarea>';
|
|
|
+ $(id + '_data').html(html);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -2634,4 +2807,8 @@ $("textarea").on("postpaste", function()
|
|
|
$(this).val(toMarkdown($(this).val()));
|
|
|
}
|
|
|
}).pasteEvents();
|
|
|
-
|
|
|
+
|
|
|
+function showYes()
|
|
|
+{
|
|
|
+ showAlert('保存成功');
|
|
|
+}
|