| | |
| | | } |
| | | |
| | | /** |
| | | * @description 初始化搜索条件 |
| | | * @param {Array} searches 搜索条件 |
| | | * @return {String} searches 格式化后结果 |
| | | */ |
| | | static initMainSearch (searches) { |
| | | if (!searches || searches.length === 0) return [] |
| | | |
| | | let newsearches = [] |
| | | searches.forEach(search => { |
| | | let item = { |
| | | key: search.field, |
| | | match: search.match, |
| | | type: search.type, |
| | | value: search.initval |
| | | } |
| | | if (item.type === 'date') { |
| | | item.value = item.value ? moment().subtract(item.value, 'days').format('YYYY-MM-DD') : '' |
| | | } else if (item.type === 'datemonth') { |
| | | item.value = item.value ? moment().subtract(item.value, 'month').format('YYYY-MM') : '' |
| | | } else if (item.type === 'dateweek') { |
| | | item.value = item.value ? [moment().subtract(item.value * 7, 'days').startOf('week').format('YYYY-MM-DD'), |
| | | moment().subtract(item.value * 7, 'days').endOf('week').format('YYYY-MM-DD')] : '' |
| | | } else if (item.type === 'daterange') { |
| | | item.value = item.value ? [moment().subtract(item.value, 'days').format('YYYY-MM-DD'), |
| | | moment().subtract(item.value === 1 ? 1 : 0, 'days').format('YYYY-MM-DD')] : '' |
| | | } |
| | | newsearches.push(item) |
| | | }) |
| | | |
| | | return newsearches |
| | | } |
| | | |
| | | /** |
| | | * @description 拼接搜索条件 |
| | | * @param {Array} searches 搜索条件 |
| | | * @return {String} searchText 拼接结果 |
| | | */ |
| | | static mainjointsearchkey (searches) { |
| | | static joinMainSearchkey (searches) { |
| | | if (!searches || searches.length === 0) return '' |
| | | |
| | | if (searches[0].hasOwnProperty('initval')) { |
| | | let newsearches = [] |
| | | searches.forEach(search => { |
| | | let item = { |
| | | key: search.field, |
| | | match: search.match, |
| | | type: search.type, |
| | | value: search.initval |
| | | } |
| | | if (item.type === 'date') { |
| | | item.value = item.value ? moment().subtract(item.value, 'days').format('YYYY-MM-DD') : '' |
| | | } else if (item.type === 'datemonth') { |
| | | item.value = item.value ? moment().subtract(item.value, 'month').format('YYYY-MM') : '' |
| | | } else if (item.type === 'dateweek') { |
| | | item.value = item.value ? [moment().subtract(item.value * 7, 'days').startOf('week').format('YYYY-MM-DD'), |
| | | moment().subtract(item.value * 7, 'days').endOf('week').format('YYYY-MM-DD')] : '' |
| | | } else if (item.type === 'daterange') { |
| | | item.value = item.value ? [moment().subtract(item.value, 'days').format('YYYY-MM-DD'), |
| | | moment().subtract(item.value === 1 ? 1 : 0, 'days').format('YYYY-MM-DD')] : '' |
| | | } |
| | | newsearches.push(item) |
| | | }) |
| | | searches = newsearches |
| | | } |
| | | |
| | | let searchText = '' |
| | | searches.forEach(item => { |
| | |
| | | let str = item.match === '=' ? '' : '%' |
| | | // eslint-disable-next-line |
| | | searchText += item.key + ' ' + item.match + ' ' + '\'' + str + item.value + str + '\'' |
| | | } else if (item.type === 'date' || item.type === 'datemonth') { |
| | | } else if (item.type === 'date') { |
| | | let timetail = ' 00:00:00.000' |
| | | if (item.match === '<' || item.match === '<=') { |
| | | timetail = ' 23:59:59.999' |
| | | } |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + timetail + '\')' |
| | | } else if (item.type === 'datemonth') { |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + '\')' |
| | | } else if (item.type === 'dateweek') { |
| | | let stimetail = ' 00:00:00.000' |
| | | let etimetail = ' 23:59:59.999' |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + '\' AND \'' + item.value[1] + '\')' |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + stimetail + '\' AND \'' + item.value[1] + etimetail + '\')' |
| | | } else if (item.type === 'daterange') { |
| | | let stimetail = ' 00:00:00.000' |
| | | let etimetail = ' 23:59:59.999' |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + '\' AND \'' + item.value[1] + '\')' |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + stimetail + '\' AND \'' + item.value[1] + etimetail + '\')' |
| | | } else { |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + '\')' |
| | |
| | | /* |
| | | select top 10 * from sProcExcep order by id desc |
| | | |
| | | declare @UserName nvarchar(50),@FullName nvarchar(50) |
| | | declare @UserName nvarchar(50),@FullName nvarchar(50) |
| | | |
| | | select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID |
| | | ${form} |