...
|
...
|
@@ -38,7 +38,26 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl |
|
|
noticeTimely.state = noticeTimely.state == 2 ? 1 : 0;
|
|
|
form.val('form-noticeTimely-add', noticeTimely);
|
|
|
$('[name="templates"]').val(noticeTimely.templates);
|
|
|
bloatedSite(noticeTimely.site);
|
|
|
|
|
|
var setting = noticeTimely.msgSetting;
|
|
|
if(setting){
|
|
|
try{
|
|
|
// "[{\"fieldName\":\"noticeType\",\"condition\":\"2\",\"conditionVal\":\"2\",\"msgLevel\":\"3\"}]"
|
|
|
var arr = JSON.parse(setting);
|
|
|
if(arr){
|
|
|
$(arr).each(function (i,v){
|
|
|
addCondition(v);
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}catch (e) {
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//bloatedSite(noticeTimely.site);
|
|
|
bloatedParameter(noticeTimely);
|
|
|
if (response.data) {
|
|
|
$.each(response.data, function (i, v) {
|
...
|
...
|
@@ -110,30 +129,60 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl |
|
|
player.play();
|
|
|
});
|
|
|
|
|
|
//添加消息状态
|
|
|
$("#editNoticeTimelyParamBtn").on("click",function () {
|
|
|
|
|
|
let testStatus = $('#layui-notice_timely_sql_test').attr('test-status');
|
|
|
if(!testStatus || testStatus != 'success'){
|
|
|
layer.msg('请先测试脚本!', {icon: 7,time:3000});
|
|
|
return;
|
|
|
}
|
|
|
function addCondition(defVal){
|
|
|
var settingItem = $('#notice_timely_param_level');
|
|
|
|
|
|
var html = $("#noticeTimelyParamAddRowHtml").html();
|
|
|
$('#notice_timely_param_level').append(html);
|
|
|
settingItem.append(html);
|
|
|
$('#notice_timely_param_sql').removeClass('hide');
|
|
|
$('#notice_timely_param_level').removeClass('hide');
|
|
|
var number = $('#notice_timely_param_level').find('.notice_time_select_sql_value').length;
|
|
|
settingItem.removeClass('hide');
|
|
|
var number = settingItem.find('.notice_time_select_sql_value').length;
|
|
|
getRowName();
|
|
|
var ht = '';
|
|
|
rowNames.forEach(item => {
|
|
|
ht += '<option value="' + item + '">' + item + '</option>'
|
|
|
})
|
|
|
$('#notice_timely_param_level').find('.notice_time_select_sql_value').eq(number - 1).append(ht);
|
|
|
settingItem.find('.notice_time_select_sql_value').eq(number - 1).append(ht);
|
|
|
if (identifying == 0) {
|
|
|
$('#notice_timely_param_level').find('.notice_time_select_colour').eq(0).val(grade);
|
|
|
settingItem.find('.notice_time_select_colour').eq(0).val(grade);
|
|
|
identifying = 1;
|
|
|
}
|
|
|
|
|
|
settingItem.find('.delete-condition').eq(0).attr('id','id'+(new Date()).getTime());
|
|
|
|
|
|
settingItem.find('.delete-condition').on('click',function (){
|
|
|
var that = $(this);
|
|
|
layer.confirm('确认要删除吗?', {icon: 3}, function (index) {
|
|
|
that.parent().parent().remove();
|
|
|
layer.close(index);
|
|
|
});
|
|
|
})
|
|
|
|
|
|
if(defVal){
|
|
|
// 设置默认值
|
|
|
settingItem.find('.notice_time_select_sql_value').val(defVal.fieldName);
|
|
|
settingItem.find('.notice_time_select_symbol').val(defVal.condition);
|
|
|
settingItem.find('.layui-notice-time-btn').val(defVal.conditionVal);
|
|
|
settingItem.find('.notice_time_select_colour').val(defVal.msgLevel);
|
|
|
|
|
|
setDetailsTags(rowNames);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//添加消息状态
|
|
|
$("#editNoticeTimelyParamBtn").on("click",function () {
|
|
|
|
|
|
var rowNames = getRowName();
|
|
|
if(rowNames && rowNames.length == 0){
|
|
|
let testStatus = $('#layui-notice_timely_sql_test').attr('test-status');
|
|
|
if(!testStatus || testStatus != 'success'){
|
|
|
layer.msg('请先测试脚本!', {icon: 7,time:3000});
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
addCondition();
|
|
|
|
|
|
})
|
|
|
//写入标签内容
|
|
|
function writeTagsInfo(data) {
|
...
|
...
|
@@ -348,12 +397,16 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl |
|
|
}
|
|
|
|
|
|
//测试按钮点击
|
|
|
$('#layui-notice_timely_sql_test').unbind("click").on("click", function () {
|
|
|
$('#layui-notice_timely_sql_test').unbind("click").on("click", function (e) {
|
|
|
e.preventDefault();
|
|
|
var sql = $('#layui-notice_timely_sql').val();
|
|
|
var type = $('#noticeTimely_type').val();
|
|
|
|
|
|
admin.req({
|
|
|
url: common.domainName + '/api-web/noticeTimely/executeSql'
|
|
|
, data: {
|
|
|
sql: sql
|
|
|
sql: sql,
|
|
|
type:type
|
|
|
}
|
|
|
, success: function (res) {
|
|
|
if (res && res.data && res.data.length > 0) {
|
...
|
...
|
@@ -363,23 +416,15 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl |
|
|
var list = res.data;
|
|
|
//默认取值第一个
|
|
|
var keys = Object.keys(list[0]);
|
|
|
var details_tags = '';
|
|
|
var html = '';
|
|
|
keys.forEach(item => {
|
|
|
html += '<option value="' + item + '">' + item + '</option>'
|
|
|
|
|
|
//
|
|
|
details_tags += `<span id="tags_span_${item}" class="layui-badge layui-bg-blue" style="margin: 3px;" ><em>${item}</em></span>`;
|
|
|
})
|
|
|
$.each($('.notice_time_select_sql_value'), function (i, v) {
|
|
|
$(this).empty();
|
|
|
$(this).append(html);
|
|
|
})
|
|
|
|
|
|
$('#details_tags').append(details_tags);
|
|
|
$('#details_tags span').on('click',function (){
|
|
|
$('[name="templates"]').val($('[name="templates"]').val() + '#{'+$(this).text() + '}');
|
|
|
});
|
|
|
setDetailsTags(keys);
|
|
|
layer.msg('脚本验证通过!', {icon: 1, time: 3000});
|
|
|
} else {
|
|
|
layer.msg('脚本验证失败,请检查!', {icon: 7, time: 3000});
|
...
|
...
|
@@ -388,21 +433,28 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl |
|
|
});
|
|
|
});
|
|
|
|
|
|
function setDetailsTags(arr){
|
|
|
|
|
|
$('#details_tags').find('.layui-badge').remove();
|
|
|
|
|
|
var details_tags = '';
|
|
|
arr.forEach(item => {
|
|
|
details_tags += `<span id="tags_span_${item}" class="layui-badge layui-bg-blue" style="margin: 3px;" ><em>${item}</em></span>`;
|
|
|
})
|
|
|
|
|
|
$('#details_tags').append(details_tags);
|
|
|
$('#details_tags span').on('click',function (){
|
|
|
$('[name="templates"]').val($('[name="templates"]').val() + '#{'+$(this).text() + '}');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//获取配置参数
|
|
|
function getParam() {
|
|
|
debugger
|
|
|
var map = getRowName();
|
|
|
var pa = '';
|
|
|
map.rowNameList.forEach(item => {
|
|
|
pa += '#{' + item + '},';
|
|
|
})
|
|
|
if (pa != '') {
|
|
|
pa = pa.substring(0, pa.length - 1);
|
|
|
}
|
|
|
|
|
|
//获取模板和等级
|
|
|
var obj = {
|
|
|
msgSetting: '',
|
|
|
templates: pa
|
|
|
msgSetting: null,
|
|
|
templates: null
|
|
|
};
|
|
|
|
|
|
var errMsg = '';
|
...
|
...
|
@@ -410,7 +462,19 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl |
|
|
if (!$('#notice_timely_param_sql').hasClass('hide')) {
|
|
|
// 获取模板信息
|
|
|
var val = $('#notice_timely_param_sql').find('textarea[name="templates"]').eq(0).val();
|
|
|
obj.templates = val ? val : pa;
|
|
|
if(!val || val == '' || val == null){
|
|
|
var map = getRowName();
|
|
|
var pa = '';
|
|
|
map.rowNameList.forEach(item => {
|
|
|
pa += '#{' + item + '},';
|
|
|
})
|
|
|
if (pa != '') {
|
|
|
pa = pa.substring(0, pa.length - 1);
|
|
|
}
|
|
|
val = pa;
|
|
|
}
|
|
|
|
|
|
obj.templates = val;
|
|
|
|
|
|
var arr = [];
|
|
|
// 获取条件行
|
...
|
...
|
|