|
|
@@ -5,7 +5,7 @@ const query = function getQueryForm(data) {
|
|
|
this.method = data.method || 'get';
|
|
|
this.url = data.url || getPathname();
|
|
|
this.condition = data.condition;
|
|
|
- this.paginations =data.paginations ? data.paginations : [50, 100, 200, 500,1000] ;
|
|
|
+ this.paginations = data.paginations ? data.paginations : [50, 100, 200, 500, 1000];
|
|
|
this.isPaginations = data.isPaginations !== false;
|
|
|
this.keydownfun = data.keydownfun || undefined;
|
|
|
this.selectChange = data.selectChange || undefined;
|
|
|
@@ -19,20 +19,20 @@ const query = function getQueryForm(data) {
|
|
|
this.pervPage = pervPage;
|
|
|
this.goPage = goPage;
|
|
|
this.getSearchData = getSearchData;
|
|
|
- this.autoSubmit = (data.autoSubmit !== false) ;
|
|
|
+ this.autoSubmit = (data.autoSubmit !== false);
|
|
|
this.param = data.param || [];
|
|
|
this.appendDom = data.appendDom || undefined;
|
|
|
|
|
|
// 提交表单
|
|
|
this.onsubmit = function () {
|
|
|
- if(!this.autoSubmit){
|
|
|
+ if (!this.autoSubmit) {
|
|
|
return;
|
|
|
}
|
|
|
saveSearchOnCookie();
|
|
|
- let form = $("<form method='" + _this.method +"'></form>");
|
|
|
+ let form = $("<form method='" + _this.method + "'></form>");
|
|
|
for (const key in _data) {
|
|
|
let map = _data[key];
|
|
|
- if(map['required'] == true && (map.value === '' || map.value===null || map.value === undefined))return;
|
|
|
+ if (map['required'] == true && (map.value === '' || map.value === null || map.value === undefined)) return;
|
|
|
if (["string", "number"].includes(fetchJsType(map.value)) && map.value !== '') {
|
|
|
// if(map.value){
|
|
|
// let string = new String(map.value);
|
|
|
@@ -42,14 +42,14 @@ const query = function getQueryForm(data) {
|
|
|
// }
|
|
|
// }
|
|
|
//form.append("<input name='" + key + "' value='" + map.value.replace(" ","%20") + "'>");
|
|
|
- form.append("<input name='" + key + "' value='" + encodeURIComponent(map.value) + "'>")
|
|
|
+ form.append("<input name='" + key + "' value='" + encodeURIComponent(map.value) + "'>")
|
|
|
} else if ('array' === fetchJsType(map.value)) {
|
|
|
let string = map.value.join(',');
|
|
|
//form.append("<input name='" + key + "' value='" + string.replace(" ","%20") + "'>");
|
|
|
form.append("<input name='" + key + "' value='" + encodeURIComponent(string) + "'>")
|
|
|
}
|
|
|
}
|
|
|
- for (let key in this.param){
|
|
|
+ for (let key in this.param) {
|
|
|
form.append("<input type='text' name='" + key + "' value='" + this.param[key] + "'>");
|
|
|
}
|
|
|
if (_this.method !== 'get') {
|
|
|
@@ -75,7 +75,7 @@ const query = function getQueryForm(data) {
|
|
|
let _hidden_div = null;
|
|
|
let _parentNode_top = null;
|
|
|
let _page = '';
|
|
|
-
|
|
|
+ let _toggle_btn = null;
|
|
|
this.init = function () {
|
|
|
_parentNode = $(_this.el);
|
|
|
_form = $("<div ></div>");
|
|
|
@@ -92,26 +92,48 @@ const query = function getQueryForm(data) {
|
|
|
$('[data-toggle="tooltip"]').tooltip({'trigger': 'hover'})
|
|
|
}
|
|
|
|
|
|
+ function isSmallScreen() {
|
|
|
+ return $(window).width() <= 640;
|
|
|
+ }
|
|
|
+
|
|
|
+ function getToggleBtn(){
|
|
|
+ _toggle_btn = $("<button type='button' class='btn btn-sm btn-success position-fixed' style='left:-5px;top:290px;z-index:10;width: 25px;'>展开</button>")
|
|
|
+ _toggle_btn.click(function(){
|
|
|
+ if(_toggle_btn.text() === "展开"){
|
|
|
+ _toggle_btn.text("收缩");
|
|
|
+ _table.removeClass("d-none")
|
|
|
+ _table.css("z-index",9);
|
|
|
+ }else if(_toggle_btn.text() === "收缩"){
|
|
|
+ _toggle_btn.text("展开");
|
|
|
+ _table.addClass("d-none")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return _toggle_btn;
|
|
|
+ }
|
|
|
+
|
|
|
// form fixed
|
|
|
function parentNodeFloat() {
|
|
|
_parentNode_top = _parentNode.offset().top;
|
|
|
let height = _parentNode.height();
|
|
|
- let dom = _this.appendDom ? $("#"+_this.appendDom+"") : null;
|
|
|
- $(window).scroll(function(){
|
|
|
+ let dom = _this.appendDom ? $("#" + _this.appendDom + "") : null;
|
|
|
+ $(window).scroll(function () {
|
|
|
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
|
+ if(isSmallScreen()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (scrollTop > _parentNode_top) {
|
|
|
_form.addClass('fixed-top');
|
|
|
_parentNode.height(height);
|
|
|
- if (dom){
|
|
|
- dom.css('position','fixed');
|
|
|
- dom.css('background','rgb(255, 255, 255)');
|
|
|
- dom.css('top',height);
|
|
|
- dom.css('z-index',1000);
|
|
|
+ if (dom) {
|
|
|
+ dom.css('position', 'fixed');
|
|
|
+ dom.css('background', 'rgb(255, 255, 255)');
|
|
|
+ dom.css('top', height);
|
|
|
+ dom.css('z-index', 1000);
|
|
|
}
|
|
|
} else {
|
|
|
_form.removeClass('fixed-top');
|
|
|
- if (dom){
|
|
|
- dom.attr('style','');
|
|
|
+ if (dom) {
|
|
|
+ dom.attr('style', '');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -130,14 +152,16 @@ const query = function getQueryForm(data) {
|
|
|
_table.html('');
|
|
|
_table.append(crateClearBtn());
|
|
|
_table.append(createPagination());
|
|
|
+ let isSmall = isSmallScreen();
|
|
|
_baseData.condition.forEach(function (conditions, index, arrays) {
|
|
|
let tr = $("<tr></tr>");
|
|
|
conditions.forEach(function (condition, index, array) {
|
|
|
+ if (isSmall) tr = $("<tr></tr>");
|
|
|
let td = $("<td style='width: 260px'></td>");
|
|
|
if ([null, '', undefined].includes(condition.type) && ![null, undefined].includes(condition.name)) {
|
|
|
condition.type = 'input';
|
|
|
}
|
|
|
- if (['dateTime_dateTime','dateTimeLocal', 'input_input'].includes(condition.type)) {
|
|
|
+ if (['dateTime_dateTime', 'dateTimeLocal', 'input_input'].includes(condition.type)) {
|
|
|
td = $("<td style='width: 330px'</td>")
|
|
|
} else if (['select_multiple_select', 'time', 'dateTime_select'].includes(condition.type)) {
|
|
|
td = $("<td style='width: 280px'</td>");
|
|
|
@@ -146,14 +170,25 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
td.append(createModule(condition));
|
|
|
tr.append(td);
|
|
|
+ if (isSmall) {
|
|
|
+ _table.append(tr);
|
|
|
+ }
|
|
|
})
|
|
|
- _table.append(tr);
|
|
|
- if (arrays.length === index + 1) {
|
|
|
- let td = $("<td ></td>");
|
|
|
- tr.append(td.append(createSearchBt()));
|
|
|
+ if (!isSmall) {
|
|
|
+ _table.append(tr);
|
|
|
+ if (arrays.length === index + 1) {
|
|
|
+ let td = $("<td ></td>");
|
|
|
+ tr.append(td.append(createSearchBt()));
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
})
|
|
|
+ if (isSmall) {
|
|
|
+ let tr = $("<tr></tr>");
|
|
|
+ let td = $("<td style='width: 260px'></td>");
|
|
|
+ _table.append(tr.append(td.append(createSearchBt())));
|
|
|
+ _table.addClass("d-none").addClass("position-fixed").css({"z-index":"9","top":0});
|
|
|
+ _form.append(getToggleBtn());
|
|
|
+ }
|
|
|
$.cookie.raw = true;
|
|
|
$.cookie.json = true;
|
|
|
setTableWidth();
|
|
|
@@ -164,11 +199,11 @@ const query = function getQueryForm(data) {
|
|
|
_baseData.condition.forEach(function (conditions, xindex, xarrays) {
|
|
|
let _width = 0;
|
|
|
conditions.forEach(function (condition, index, array) {
|
|
|
- if (['input','dateMonth', 'select', 'dateTime', 'input_select'].includes(condition.type)) {
|
|
|
+ if (['input', 'dateMonth', 'select', 'dateTime', 'input_select'].includes(condition.type)) {
|
|
|
_width += 260;
|
|
|
- } else if (['dateTime_dateTime','dateTimeLocal', 'input_input'].includes(condition.type)) {
|
|
|
+ } else if (['dateTime_dateTime', 'dateTimeLocal', 'input_input'].includes(condition.type)) {
|
|
|
_width += 330;
|
|
|
- } else if (['select_multiple_select','search_select'].includes(condition.type)) {
|
|
|
+ } else if (['select_multiple_select', 'search_select'].includes(condition.type)) {
|
|
|
_width += 280;
|
|
|
} else if (['checkbox'].includes(condition.type)) {
|
|
|
_width += 260;
|
|
|
@@ -186,9 +221,14 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
- _parentNode.css('min-width', 1920 - 30)
|
|
|
- _parentNode.css('max-width', (max_width || window.screen.availWidth) - 30);
|
|
|
- _table.css('width', max_width + 'px');
|
|
|
+ if (isSmallScreen()) {
|
|
|
+ _parentNode.css("width", 340 + "px");
|
|
|
+ _table.css("width", 340 + "px").addClass("m-0");
|
|
|
+ } else {
|
|
|
+ _parentNode.css('min-width', 1920 - 30)
|
|
|
+ _parentNode.css('max-width', (max_width || window.screen.availWidth) - 30);
|
|
|
+ _table.css('width', max_width + 'px');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 清空筛选按钮
|
|
|
@@ -200,7 +240,7 @@ const query = function getQueryForm(data) {
|
|
|
})
|
|
|
let tr = $("<tr ><td colspan='10'></td></tr>");
|
|
|
tr.find('td').append(clearbtn);
|
|
|
- _clearTr = tr;
|
|
|
+ _clearTr = tr;
|
|
|
return tr;
|
|
|
}
|
|
|
|
|
|
@@ -215,7 +255,7 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
if (controlJsType(_this._onsubmit, 'fun')) {
|
|
|
_this._onsubmit();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
_this.onsubmit();
|
|
|
}
|
|
|
})
|
|
|
@@ -225,7 +265,7 @@ const query = function getQueryForm(data) {
|
|
|
// create _pagination
|
|
|
function createPagination() {
|
|
|
let isPaginations = _this.isPaginations ? '' : 'hidden';
|
|
|
- _pagination = $("<select id='paginate' "+isPaginations+" name='paginate' class='form-control form-control-sm' style='vertical-align: middle; max-width: 150px;'></select>");
|
|
|
+ _pagination = $("<select id='paginate' " + isPaginations + " name='paginate' class='form-control form-control-sm' style='vertical-align: middle; max-width: 150px;'></select>");
|
|
|
let tr = $("<tr ><td colspan='10'><div class='col p-0' style='height: 100%'></div></td></tr>");
|
|
|
tr.find('div').append(_pagination);
|
|
|
_this.paginations.forEach(function (map) {
|
|
|
@@ -273,13 +313,13 @@ const query = function getQueryForm(data) {
|
|
|
// 数据清空
|
|
|
function clearData() {
|
|
|
saveCookie({});
|
|
|
- let url=_this.url;
|
|
|
- if (_this.param !== []){
|
|
|
+ let url = _this.url;
|
|
|
+ if (_this.param !== []) {
|
|
|
url += "?";
|
|
|
- let i=0;
|
|
|
- for (let key in _this.param){
|
|
|
- if (i!==0) url += "&";
|
|
|
- url += key+"="+_this.param[key];
|
|
|
+ let i = 0;
|
|
|
+ for (let key in _this.param) {
|
|
|
+ if (i !== 0) url += "&";
|
|
|
+ url += key + "=" + _this.param[key];
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
@@ -346,13 +386,13 @@ const query = function getQueryForm(data) {
|
|
|
|
|
|
// dateMonth
|
|
|
function getDateMonth(condition) {
|
|
|
- let dateMonth = $("<input name = '"+ condition.name +"' type='month' class='form-control form-control-sm' style='vertical-align: middle; max-width: 200px;' placeholder='" + condition.placeholder + "' autocomplete='off' data-toggle='tooltip' >");
|
|
|
+ let dateMonth = $("<input name = '" + condition.name + "' type='month' class='form-control form-control-sm' style='vertical-align: middle; max-width: 200px;' placeholder='" + condition.placeholder + "' autocomplete='off' data-toggle='tooltip' >");
|
|
|
dateMonth.attr('title', condition.tip === undefined ? '' : condition.tip);
|
|
|
- dateMonth.blur(function(){
|
|
|
+ dateMonth.blur(function () {
|
|
|
modifyData({name: condition.name, type: 'dateMonth', value: this.value, mold: 'dateMonth'});
|
|
|
});
|
|
|
- dateMonth.keypress(function(event){
|
|
|
- if(event.which === 13){
|
|
|
+ dateMonth.keypress(function (event) {
|
|
|
+ if (event.which === 13) {
|
|
|
modifyData({name: condition.name, type: 'input', value: this.value, mold: 'input'});
|
|
|
}
|
|
|
});
|
|
|
@@ -363,11 +403,11 @@ const query = function getQueryForm(data) {
|
|
|
function getInput(condition) {
|
|
|
let input = $("<input name='" + condition.name + "' class='form-control form-control-sm' style='vertical-align: middle; max-width: 200px;' placeholder='" + condition.placeholder + "' autocomplete='off' data-toggle='tooltip' data-placement='top' >");
|
|
|
input.attr('title', condition.tip === undefined ? '' : condition.tip);
|
|
|
- input.blur(function(){
|
|
|
+ input.blur(function () {
|
|
|
modifyData({name: condition.name, type: 'input', value: this.value, mold: 'input'});
|
|
|
});
|
|
|
- input.keypress(function(event){
|
|
|
- if(event.which === 13)modifyData({name: condition.name, type: 'input', value: this.value, mold: 'input'});
|
|
|
+ input.keypress(function (event) {
|
|
|
+ if (event.which === 13) modifyData({name: condition.name, type: 'input', value: this.value, mold: 'input'});
|
|
|
});
|
|
|
return input;
|
|
|
}
|
|
|
@@ -403,7 +443,7 @@ const query = function getQueryForm(data) {
|
|
|
placeholder = condition.placeholder[1];
|
|
|
}
|
|
|
fillSelectOption(select, condition.data, placeholder);
|
|
|
- input.blur(function(){
|
|
|
+ input.blur(function () {
|
|
|
let value = this.value;
|
|
|
let data = condition.data.filter(function (map) {
|
|
|
return map.value.includes(value);
|
|
|
@@ -411,8 +451,8 @@ const query = function getQueryForm(data) {
|
|
|
fillSelectOption(select, data || condition.data);
|
|
|
select.val(_data[condition.name].select);
|
|
|
});
|
|
|
- input.keypress(function(event){
|
|
|
- if(event.which === 13){
|
|
|
+ input.keypress(function (event) {
|
|
|
+ if (event.which === 13) {
|
|
|
let value = this.value;
|
|
|
let data = condition.data.filter(function (map) {
|
|
|
return map.value.includes(value);
|
|
|
@@ -434,11 +474,16 @@ const query = function getQueryForm(data) {
|
|
|
input.attr('title', controlJsType(condition.tip[0], 'undefined') ? '' : condition.tip[0]);
|
|
|
let select = $("<select class='form-control form-control-sm ml-2' name='" + condition.name[1] + "' style='max-width: 200px;' title='" + condition.tip[1] + "''>");
|
|
|
fillSelectOption(select, condition.data);
|
|
|
- input.blur(function(){
|
|
|
+ input.blur(function () {
|
|
|
modifyData({name: this.name, type: 'input_select_longtext', value: this.value, mold: 'input'});
|
|
|
});
|
|
|
- input.keypress(function(event){
|
|
|
- if(event.which === 13)modifyData({name: this.name, type: 'input_select_longtext', value: this.value, mold: 'input'});
|
|
|
+ input.keypress(function (event) {
|
|
|
+ if (event.which === 13) modifyData({
|
|
|
+ name: this.name,
|
|
|
+ type: 'input_select_longtext',
|
|
|
+ value: this.value,
|
|
|
+ mold: 'input'
|
|
|
+ });
|
|
|
});
|
|
|
select.change(function () {
|
|
|
modifyData({name: this.name, type: 'input_select_longtext', value: this.value, mold: 'select'});
|
|
|
@@ -458,7 +503,7 @@ const query = function getQueryForm(data) {
|
|
|
|
|
|
//dateTimeLocal
|
|
|
function getDateTimeLocal(condition) {
|
|
|
- let dateTimeLocal = $("<input name = '"+ condition.name +"' type='datetime-local' step='01' class='form-control form-control-sm' style='vertical-align: middle; max-width: 280px;' placeholder='" + condition.placeholder + "' autocomplete='off' data-toggle='tooltip' data-placement='top' >");
|
|
|
+ let dateTimeLocal = $("<input name = '" + condition.name + "' type='datetime-local' step='01' class='form-control form-control-sm' style='vertical-align: middle; max-width: 280px;' placeholder='" + condition.placeholder + "' autocomplete='off' data-toggle='tooltip' data-placement='top' >");
|
|
|
dateTimeLocal.attr('title', condition.tip === undefined ? '' : condition.tip);
|
|
|
dateTimeLocal.bind('input propertychange', function () {
|
|
|
modifyData({name: condition.name, type: 'dateTimeLocal', value: this.value, mold: 'dateTimeLocal'});
|
|
|
@@ -474,12 +519,12 @@ const query = function getQueryForm(data) {
|
|
|
let min = $("<input id='" + condition.name + "_min' class='form-control form-control-sm ml-2' style='max-width: 100px;' placeholder='00:00' data-toggle='tooltip' data-placement='top' >");
|
|
|
min.attr('title', controlJsType(condition.tip[1], 'undefined') ? '' : condition.tip[1]);
|
|
|
dateTime.bind('input propertychange', function () {
|
|
|
- let value = this.value !== '' ? this.value + ' ' +(!!min.val() ? min.val() :'23:59' ) : '';
|
|
|
- modifyData( {name: condition.name, type: 'time', value: value, mold: 'time'});
|
|
|
+ let value = this.value !== '' ? this.value + ' ' + (!!min.val() ? min.val() : '23:59') : '';
|
|
|
+ modifyData({name: condition.name, type: 'time', value: value, mold: 'time'});
|
|
|
// modifyData({name: condition.name, type: 'dateTime', value: this.value, mold: 'dateTime'});
|
|
|
});
|
|
|
min.bind('input propertychange', function () {
|
|
|
- if (['null', 'undefined', ''].includes(dateTime.val()))return;
|
|
|
+ if (['null', 'undefined', ''].includes(dateTime.val())) return;
|
|
|
let value = ['null', 'undefined', ''].includes(dateTime.val()) ? '' : dateTime.val() + ' ' + min.val();
|
|
|
modifyData({name: condition.name, type: 'time', value: value, mold: 'time'});
|
|
|
})
|
|
|
@@ -494,17 +539,27 @@ const query = function getQueryForm(data) {
|
|
|
let input2 = $("<input name='" + condition.name[1] + "' class='form-control form-control-sm ml-2' style='vertical-align: middle; max-width: 150px;' placeholder='" + condition.placeholder[1] + "' data-toggle='tooltip' data-placement='top' title='" + condition.tip[1] + "'>");
|
|
|
input2.attr('title', controlJsType(condition.tip[1], 'undefined') ? '' : condition.tip[1]);
|
|
|
|
|
|
- input1.blur(function(){
|
|
|
+ input1.blur(function () {
|
|
|
modifyData({name: this.name, type: 'input_input', value: this.value, mold: 'input'});
|
|
|
});
|
|
|
- input1.keypress(function(event){
|
|
|
- if(event.which === 13)modifyData({name: this.name, type: 'input_input', value: this.value, mold: 'input'});
|
|
|
+ input1.keypress(function (event) {
|
|
|
+ if (event.which === 13) modifyData({
|
|
|
+ name: this.name,
|
|
|
+ type: 'input_input',
|
|
|
+ value: this.value,
|
|
|
+ mold: 'input'
|
|
|
+ });
|
|
|
});
|
|
|
- input2.blur(function(){
|
|
|
+ input2.blur(function () {
|
|
|
modifyData({name: this.name, type: 'input_input', value: this.value, mold: 'input'});
|
|
|
});
|
|
|
- input2.keypress(function(event){
|
|
|
- if(event.which === 13)modifyData({name: this.name, type: 'input_input', value: this.value, mold: 'input'});
|
|
|
+ input2.keypress(function (event) {
|
|
|
+ if (event.which === 13) modifyData({
|
|
|
+ name: this.name,
|
|
|
+ type: 'input_input',
|
|
|
+ value: this.value,
|
|
|
+ mold: 'input'
|
|
|
+ });
|
|
|
});
|
|
|
return div.append(input1).append(input2);
|
|
|
}
|
|
|
@@ -540,7 +595,7 @@ const query = function getQueryForm(data) {
|
|
|
|
|
|
fillSelectOption(select, condition.data)
|
|
|
dateTime.bind('input propertychange', function () {
|
|
|
- modifyData( {name: this.name, type: 'dateTime_select', value: this.value, mold: 'dateTime'});
|
|
|
+ modifyData({name: this.name, type: 'dateTime_select', value: this.value, mold: 'dateTime'});
|
|
|
})
|
|
|
select.change(function () {
|
|
|
modifyData({name: this.name, type: 'dateTime_select', value: this.value, mold: 'select'});
|
|
|
@@ -576,27 +631,27 @@ const query = function getQueryForm(data) {
|
|
|
check.click(function () {
|
|
|
_data[condition.name].value = [];
|
|
|
_data[condition.name].select = [];
|
|
|
- if (check[0].checked === true){
|
|
|
+ if (check[0].checked === true) {
|
|
|
condition.data.forEach(function (data) {
|
|
|
_data[condition.name].value.push(data.name);
|
|
|
if (_data[condition.name].select) _data[condition.name].select.push(data.name);
|
|
|
else _data[condition.name].select = [data.name];
|
|
|
});
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
let dom = {
|
|
|
name: condition.name,
|
|
|
mold: 'select_multiple_select',
|
|
|
value: [],
|
|
|
- select:[],
|
|
|
+ select: [],
|
|
|
};
|
|
|
modifyData(dom);
|
|
|
}
|
|
|
redenerUl(ul);
|
|
|
});
|
|
|
- check.mouseleave(()=>{
|
|
|
+ check.mouseleave(() => {
|
|
|
isMouseenterCheckBox = false;
|
|
|
});
|
|
|
- check.mouseenter(()=>{
|
|
|
+ check.mouseenter(() => {
|
|
|
isMouseenterCheckBox = true;
|
|
|
});
|
|
|
|
|
|
@@ -651,12 +706,12 @@ const query = function getQueryForm(data) {
|
|
|
})*/
|
|
|
ul_div.hide();
|
|
|
ul_div.mouseleave(function () {
|
|
|
- if(_data[condition.name].value.length>0){
|
|
|
+ if (_data[condition.name].value.length > 0) {
|
|
|
// _this.onsubmit();
|
|
|
ul_div.hide();
|
|
|
return;
|
|
|
}
|
|
|
- if (!isMouseenterCheckBox){
|
|
|
+ if (!isMouseenterCheckBox) {
|
|
|
ul_div.hide();
|
|
|
}
|
|
|
});
|
|
|
@@ -725,10 +780,10 @@ const query = function getQueryForm(data) {
|
|
|
li.click(function () {
|
|
|
let value = li.attr('value');
|
|
|
let dom_data = _data[name].value;
|
|
|
- if(!dom_data){
|
|
|
+ if (!dom_data) {
|
|
|
dom_data = [];
|
|
|
}
|
|
|
- if (controlJsType(dom_data,'string')){
|
|
|
+ if (controlJsType(dom_data, 'string')) {
|
|
|
dom_data = [dom_data];
|
|
|
}
|
|
|
if (dom_data.includes(value)) {
|
|
|
@@ -755,11 +810,11 @@ const query = function getQueryForm(data) {
|
|
|
let label = $('#' + name + '_lab');
|
|
|
let select = $('#' + name + '_sel');
|
|
|
let dom_data = _data[name].value;
|
|
|
- if (dom_data && dom_data.length === 1 ) {
|
|
|
+ if (dom_data && dom_data.length === 1) {
|
|
|
select.show();
|
|
|
select.val(dom_data[0]);
|
|
|
label.hide();
|
|
|
- }else if(controlJsType(dom_data,'string')){
|
|
|
+ } else if (controlJsType(dom_data, 'string')) {
|
|
|
select.show();
|
|
|
select.val(dom_data);
|
|
|
label.hide();
|
|
|
@@ -775,10 +830,10 @@ const query = function getQueryForm(data) {
|
|
|
_data[dom.name].value = dom.value;
|
|
|
_data[dom.name].select = dom.value;
|
|
|
redenerSearchFormOnData(dom.name, dom.value, dom.mold);
|
|
|
- let killings=_data[dom.name].killings;
|
|
|
- if(killings){
|
|
|
- killings.forEach(function(targetName){
|
|
|
- _data[targetName].value= '';
|
|
|
+ let killings = _data[dom.name].killings;
|
|
|
+ if (killings) {
|
|
|
+ killings.forEach(function (targetName) {
|
|
|
+ _data[targetName].value = '';
|
|
|
redenerSearchFormOnData(_data[targetName].name, '', _data[targetName].mold);
|
|
|
})
|
|
|
}
|
|
|
@@ -791,18 +846,21 @@ const query = function getQueryForm(data) {
|
|
|
* {date_relevance:{date:['',''],relevance:'',killing:'',default:[]}}
|
|
|
* */
|
|
|
let rules = _data[dom.name].rules;
|
|
|
- if (rules && JSON.stringify(rules) !== '{}'){
|
|
|
- if (rules['son']){
|
|
|
- for (let key in rules['son']){
|
|
|
- if (!dom.value){
|
|
|
+ if (rules && JSON.stringify(rules) !== '{}') {
|
|
|
+ if (rules['son']) {
|
|
|
+ for (let key in rules['son']) {
|
|
|
+ if (!dom.value) {
|
|
|
redenerSearchFormOnData(_data[key].name, '', _data[key].mold);
|
|
|
continue;
|
|
|
}
|
|
|
- if (!_data[key].value){
|
|
|
- if (rules['son'][key].required_without_all_if && Array.isArray(rules['son'][key].required_without_all_if)){
|
|
|
+ if (!_data[key].value) {
|
|
|
+ if (rules['son'][key].required_without_all_if && Array.isArray(rules['son'][key].required_without_all_if)) {
|
|
|
let sign = true;
|
|
|
rules['son'][key].required_without_all_if.some(function (name) {
|
|
|
- if (_data[name].value){ sign=false; return true;}
|
|
|
+ if (_data[name].value) {
|
|
|
+ sign = false;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
});
|
|
|
if (sign) {
|
|
|
_data[_data[key].name].mold = _data[key].mold;
|
|
|
@@ -814,7 +872,7 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (rules['date_relevance']){
|
|
|
+ if (rules['date_relevance']) {
|
|
|
if (!rules['date_relevance']['date']
|
|
|
|| !Array.isArray(rules['date_relevance']['date'])
|
|
|
|| rules['date_relevance']['date'].length !== 2
|
|
|
@@ -822,36 +880,36 @@ const query = function getQueryForm(data) {
|
|
|
let start = _data[rules['date_relevance']['date'][0]];
|
|
|
let end = _data[rules['date_relevance']['date'][1]];
|
|
|
let relevance = _data[rules['date_relevance']['relevance']];
|
|
|
- if (dom.name === rules['date_relevance']['relevance']){
|
|
|
- if (relevance.value){
|
|
|
+ if (dom.name === rules['date_relevance']['relevance']) {
|
|
|
+ if (relevance.value) {
|
|
|
let today = getToday();
|
|
|
- let tarDate = getSubDate(getToday(),relevance.value);
|
|
|
- _data[end.name].value = today+" 23:59";
|
|
|
- _data[start.name].value = tarDate+" 00:00";
|
|
|
+ let tarDate = getSubDate(getToday(), relevance.value);
|
|
|
+ _data[end.name].value = today + " 23:59";
|
|
|
+ _data[start.name].value = tarDate + " 00:00";
|
|
|
/*redenerSearchFormOnData(end.name, tarDate+" 23:59", end.mold);
|
|
|
redenerSearchFormOnData(start.name, tarDate+" 00:00", start.mold);*/
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- if (!start.value || !end.value){
|
|
|
- if (rules['date_relevance']['killing'] === 'date'){
|
|
|
+ if (!start.value || !end.value) {
|
|
|
+ if (rules['date_relevance']['killing'] === 'date') {
|
|
|
_data[start.name].value = '';
|
|
|
redenerSearchFormOnData(start.name, '', start.mold);
|
|
|
_data[start.name].value = '';
|
|
|
redenerSearchFormOnData(end.name, '', end.mold);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
_data[relevance.name].value = '';
|
|
|
redenerSearchFormOnData(relevance.name, '', relevance.mold);
|
|
|
}
|
|
|
}
|
|
|
- if (start.value && end.value){
|
|
|
- start.value = start.value.replace('+',' ');
|
|
|
- end.value = end.value.replace('+',' ');
|
|
|
- let diff = getDiffDay(start.value,end.value);
|
|
|
- if (rules['date_relevance']['default'] && rules['date_relevance']['default'].includes(diff)){
|
|
|
+ if (start.value && end.value) {
|
|
|
+ start.value = start.value.replace('+', ' ');
|
|
|
+ end.value = end.value.replace('+', ' ');
|
|
|
+ let diff = getDiffDay(start.value, end.value);
|
|
|
+ if (rules['date_relevance']['default'] && rules['date_relevance']['default'].includes(diff)) {
|
|
|
_data[relevance.name].value = diff;
|
|
|
- redenerSearchFormOnData(relevance.name, diff, relevance.mold);}
|
|
|
- else {
|
|
|
+ redenerSearchFormOnData(relevance.name, diff, relevance.mold);
|
|
|
+ } else {
|
|
|
_data[relevance.name].value = '';
|
|
|
redenerSearchFormOnData(relevance.name, '', relevance.mold);
|
|
|
}
|
|
|
@@ -859,13 +917,14 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- function getDiffDay(startDate,endDate) {
|
|
|
+
|
|
|
+ function getDiffDay(startDate, endDate) {
|
|
|
startDate = new Date(startDate);
|
|
|
endDate = new Date(endDate);
|
|
|
- return Math.floor((endDate.getTime() - startDate.getTime())/(24*3600*1000));
|
|
|
+ return Math.floor((endDate.getTime() - startDate.getTime()) / (24 * 3600 * 1000));
|
|
|
}
|
|
|
|
|
|
- function getSubDate(date,value) {
|
|
|
+ function getSubDate(date, value) {
|
|
|
date = new Date(date);
|
|
|
date.setDate(date.getDate() - value);
|
|
|
return dateFormat(date);
|
|
|
@@ -877,10 +936,10 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
|
|
|
function dateFormat(date) {
|
|
|
- let year=date.getFullYear();
|
|
|
- let month=(date.getMonth()+1)<10 ? '0'+(date.getMonth()+1) : date.getMonth()+1;
|
|
|
- let day=date.getDate()<10 ? '0'+date.getDate() : date.getDate();
|
|
|
- return year+"-"+month+"-"+day;
|
|
|
+ let year = date.getFullYear();
|
|
|
+ let month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
|
|
|
+ let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
|
|
|
+ return year + "-" + month + "-" + day;
|
|
|
}
|
|
|
|
|
|
// save search on cookie
|
|
|
@@ -1061,12 +1120,12 @@ const query = function getQueryForm(data) {
|
|
|
|
|
|
function rendererSearchFormOnTime(key, value, mold) {
|
|
|
if (![undefined, null, ''].includes(value)) {
|
|
|
- $(_form).find("input[name="+key+"]").val(value.substring(0, 10)).addClass('bg-warning');
|
|
|
+ $(_form).find("input[name=" + key + "]").val(value.substring(0, 10)).addClass('bg-warning');
|
|
|
if (value.length > 11 + 5) {
|
|
|
$(_form).find("input[name='" + key + "_tim']").val(value.substring(11, 5));
|
|
|
}
|
|
|
} else {
|
|
|
- $(_form).find("input[name="+key+"]").val("").removeClass('bg-warning');
|
|
|
+ $(_form).find("input[name=" + key + "]").val("").removeClass('bg-warning');
|
|
|
$(_form).find("input[name='" + key + "_tim']").val("");
|
|
|
}
|
|
|
}
|
|
|
@@ -1080,7 +1139,7 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
} else {
|
|
|
if (![undefined, null, ''].includes(_data[key].value)) {
|
|
|
- if(controlJsType(_data[key].value,'array') && _data[key].value.length === 0 ){
|
|
|
+ if (controlJsType(_data[key].value, 'array') && _data[key].value.length === 0) {
|
|
|
continue;
|
|
|
}
|
|
|
bool = true;
|
|
|
@@ -1101,14 +1160,14 @@ const query = function getQueryForm(data) {
|
|
|
setTimeout(function () {
|
|
|
if (_this.keydownSearch) _this.onsubmit();
|
|
|
if (controlJsType(_this.keydownfun, 'fun')) _this.keydownfun();
|
|
|
- },100);
|
|
|
+ }, 100);
|
|
|
}
|
|
|
});
|
|
|
$(_form).find("input[type='date']").change(function (e) {
|
|
|
setTimeout(function () {
|
|
|
// if (_this.keydownSearch)_this.onsubmit();
|
|
|
if (controlJsType(_this.keydownfun, 'fun')) _this.keydownfun();
|
|
|
- },100);
|
|
|
+ }, 100);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -1119,7 +1178,7 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
|
|
|
function redenerSearchFormOnData(key, value, mold) {
|
|
|
- if (mold === 'input' ||mold === 'dateTime' || mold === 'dateTimeLocal' || mold === 'dateMonth') {
|
|
|
+ if (mold === 'input' || mold === 'dateTime' || mold === 'dateTimeLocal' || mold === 'dateMonth') {
|
|
|
rendererSearchFormOnInput(key, value, mold);
|
|
|
} else if (mold === 'select') {
|
|
|
rendererSearchFormOnSelect(key, value, mold);
|
|
|
@@ -1136,7 +1195,7 @@ const query = function getQueryForm(data) {
|
|
|
function switchData() {
|
|
|
_this.condition.forEach(function (conditions) {
|
|
|
conditions.forEach(function (condition) {
|
|
|
- if (['input', 'select', 'dateTime','dateTimeLocal', 'dateMonth', 'search_select', 'time', 'select_multiple_select','checkbox'].includes(condition.type)) {
|
|
|
+ if (['input', 'select', 'dateTime', 'dateTimeLocal', 'dateMonth', 'search_select', 'time', 'select_multiple_select', 'checkbox'].includes(condition.type)) {
|
|
|
if (!condition.select) {
|
|
|
condition.select = '';
|
|
|
}
|
|
|
@@ -1146,15 +1205,15 @@ const query = function getQueryForm(data) {
|
|
|
value: condition.value,
|
|
|
select: condition.select,
|
|
|
mold: ['input', 'dateTime'].includes(condition.type) ? 'input' : condition.type,
|
|
|
- data:condition.data,
|
|
|
- killings:condition.killings,
|
|
|
- rules:condition.rules,
|
|
|
- required:condition.required,
|
|
|
+ data: condition.data,
|
|
|
+ killings: condition.killings,
|
|
|
+ rules: condition.rules,
|
|
|
+ required: condition.required,
|
|
|
}
|
|
|
if (condition.type === 'search_select') {
|
|
|
data.mold = 'select';
|
|
|
}
|
|
|
- if(condition.type === 'select_multiple_select'){
|
|
|
+ if (condition.type === 'select_multiple_select') {
|
|
|
data.value = [];
|
|
|
}
|
|
|
_data[condition.name] = data;
|
|
|
@@ -1173,15 +1232,15 @@ const query = function getQueryForm(data) {
|
|
|
value: condition.value[index],
|
|
|
select: condition.select[index],
|
|
|
mold: ['input', 'dateTime'].includes(types[index]) ? 'input' : types[index],
|
|
|
- killings:condition.killings,
|
|
|
- rules:condition.rules,
|
|
|
- required:condition.required,
|
|
|
+ killings: condition.killings,
|
|
|
+ rules: condition.rules,
|
|
|
+ required: condition.required,
|
|
|
}
|
|
|
- if(condition.killings&&Array.isArray(condition.killings)){
|
|
|
- data.killings=condition.killings[index];
|
|
|
+ if (condition.killings && Array.isArray(condition.killings)) {
|
|
|
+ data.killings = condition.killings[index];
|
|
|
}
|
|
|
- if(condition.rules&&Array.isArray(condition.rules)){
|
|
|
- data.rules=condition.rules[index];
|
|
|
+ if (condition.rules && Array.isArray(condition.rules)) {
|
|
|
+ data.rules = condition.rules[index];
|
|
|
}
|
|
|
_data[_name] = data;
|
|
|
})
|
|
|
@@ -1271,7 +1330,7 @@ const query = function getQueryForm(data) {
|
|
|
data = (data.substr(1)).split('&');
|
|
|
data = convertArrayToObj(data);
|
|
|
for (const key in data) {
|
|
|
- if(!data[key] || _this.param[key]){
|
|
|
+ if (!data[key] || _this.param[key]) {
|
|
|
continue;
|
|
|
}
|
|
|
if (key === 'paginate') {
|
|
|
@@ -1283,13 +1342,13 @@ const query = function getQueryForm(data) {
|
|
|
}
|
|
|
} else if (key === 'page') {
|
|
|
_page = data[key];
|
|
|
- } else if(_data[key].type === 'select_multiple_select' ){
|
|
|
- if(!_data[key]){
|
|
|
+ } else if (_data[key].type === 'select_multiple_select') {
|
|
|
+ if (!_data[key]) {
|
|
|
_data[key].value = [];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
_data[key].value = data[key].split(',');
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
_data[key].value = data[key];
|
|
|
}
|
|
|
}
|
|
|
@@ -1335,20 +1394,20 @@ const query = function getQueryForm(data) {
|
|
|
// paginate
|
|
|
function pervPage() {
|
|
|
let obj = getSearchData();
|
|
|
- if(!!obj['page'] && obj['page']>1){
|
|
|
- obj['page'] = obj['page']-1;
|
|
|
+ if (!!obj['page'] && obj['page'] > 1) {
|
|
|
+ obj['page'] = obj['page'] - 1;
|
|
|
}
|
|
|
return getSearchUri(obj);
|
|
|
}
|
|
|
|
|
|
function nextPage() {
|
|
|
let obj = getSearchData();
|
|
|
- if(!!obj['page'] ){
|
|
|
- obj['page'] = obj['page']+1;
|
|
|
- }else{
|
|
|
+ if (!!obj['page']) {
|
|
|
+ obj['page'] = obj['page'] + 1;
|
|
|
+ } else {
|
|
|
obj['page'] = 2;
|
|
|
}
|
|
|
- if(!obj['paginate']){
|
|
|
+ if (!obj['paginate']) {
|
|
|
obj['paginate'] = 50;
|
|
|
}
|
|
|
return getSearchUri(obj);
|
|
|
@@ -1357,19 +1416,19 @@ const query = function getQueryForm(data) {
|
|
|
function getSearchObj() {
|
|
|
let data = window.location.search;
|
|
|
data = decodeURIComponent(data);
|
|
|
- if(!data){
|
|
|
+ if (!data) {
|
|
|
return {};
|
|
|
}
|
|
|
let saveData = {};
|
|
|
data = data.substr(1).split('&');
|
|
|
data.forEach(function (map) {
|
|
|
- let arr = map.split('&'),key = arr[0],value = arr[1];
|
|
|
- if(!!value){
|
|
|
+ let arr = map.split('&'), key = arr[0], value = arr[1];
|
|
|
+ if (!!value) {
|
|
|
if (!saveData[key]) {
|
|
|
saveData[key] = value;
|
|
|
} else {
|
|
|
if (controlJsType(data[key], 'string')) {
|
|
|
- saveData[key] = [saveData[key] , value];
|
|
|
+ saveData[key] = [saveData[key], value];
|
|
|
} else if (controlJsType(data[key], 'array')) {
|
|
|
saveData[key].push(value);
|
|
|
}
|
|
|
@@ -1379,19 +1438,20 @@ const query = function getQueryForm(data) {
|
|
|
return saveData;
|
|
|
}
|
|
|
|
|
|
- function getPage(){
|
|
|
- return getSearchObj()['page'];
|
|
|
+ function getPage() {
|
|
|
+ return getSearchObj()['page'];
|
|
|
}
|
|
|
+
|
|
|
// paginate
|
|
|
function pervPage() {
|
|
|
let obj = getSearchData();
|
|
|
_page = getPage();
|
|
|
- if(!obj['paginate']){
|
|
|
+ if (!obj['paginate']) {
|
|
|
obj['paginate'] = 50;
|
|
|
}
|
|
|
- if(Number(_page)>1){
|
|
|
- _page= Number(_page)-1;
|
|
|
- }else{
|
|
|
+ if (Number(_page) > 1) {
|
|
|
+ _page = Number(_page) - 1;
|
|
|
+ } else {
|
|
|
_page = 1;
|
|
|
}
|
|
|
return getSearchUri(obj);
|
|
|
@@ -1400,30 +1460,32 @@ const query = function getQueryForm(data) {
|
|
|
function nextPage() {
|
|
|
let obj = getSearchData();
|
|
|
_page = getPage();
|
|
|
- if(!_page){_page=1;}
|
|
|
- if(_page){
|
|
|
- _page = Number(_page)+ 1;
|
|
|
+ if (!_page) {
|
|
|
+ _page = 1;
|
|
|
+ }
|
|
|
+ if (_page) {
|
|
|
+ _page = Number(_page) + 1;
|
|
|
}
|
|
|
- if(!obj['paginate']){
|
|
|
+ if (!obj['paginate']) {
|
|
|
obj['paginate'] = 50;
|
|
|
}
|
|
|
return getSearchUri(obj);
|
|
|
}
|
|
|
|
|
|
- function goPage(page){
|
|
|
+ function goPage(page) {
|
|
|
let obj = getSearchData();
|
|
|
_page = page;
|
|
|
return getSearchUri(obj);
|
|
|
}
|
|
|
|
|
|
- function getSearchUri(obj){
|
|
|
+ function getSearchUri(obj) {
|
|
|
let string = "?";
|
|
|
for (const key in obj) {
|
|
|
- if(controlJsType(obj[key],['string','number'])){
|
|
|
- string+= key + "=" + obj[key]+'&';
|
|
|
- }else if( controlJsType(obj[key],'array')&&obj[key].length > 0){
|
|
|
- obj[key].forEach(function(value){
|
|
|
- string+=key + "=" + value+'&';
|
|
|
+ if (controlJsType(obj[key], ['string', 'number'])) {
|
|
|
+ string += key + "=" + obj[key] + '&';
|
|
|
+ } else if (controlJsType(obj[key], 'array') && obj[key].length > 0) {
|
|
|
+ obj[key].forEach(function (value) {
|
|
|
+ string += key + "=" + value + '&';
|
|
|
})
|
|
|
}
|
|
|
}
|