| | |
| | | } |
| | | |
| | | /** |
| | | * @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 + '\')' |
| | |
| | | */ |
| | | static getfunc (param) { |
| | | let form = '' |
| | | let formParam = '' |
| | | |
| | | if (param.fields && param.fields.length > 0) { |
| | | let _fields = [] |
| | | param.fields.forEach(item => { |
| | | if (item.field) { |
| | | let type = '' |
| | | if (item.type.match(/date/ig)) { |
| | | type = 'datetime is null' |
| | | } else if (item.type === 'number') { |
| | | type = `decimal(18,${item.decimal})=0` |
| | | } else { |
| | | type = 'nvarchar(50)=\'\'' |
| | | } |
| | | formParam = formParam + `mchr13k@${item.field} ${type},` |
| | | |
| | | _fields.push(item.field) |
| | | } |
| | | }) |
| | |
| | | field3 = field3.join(',') |
| | | |
| | | form = ` |
| | | insert into ${param.name} (${field1}) select ${field2},@UserID |
| | | insert into ${param.name} (${field1},createuserid) select ${field2},@UserID |
| | | |
| | | update ${param.name} set ${field3},modifydate=getdate(),modifyuserid=@UserID |
| | | ` |
| | | } |
| | | |
| | | let Ltext = `create proc ${param.name} |
| | | let Ltext = `create proc ${param.funcName} |
| | | ( |
| | | @BID nvarchar(50)='', |
| | | @ID nvarchar(50)='', |
| | | 表单传值,文本用nvarchar(50)='',日期用datetime is null ,数值用decimal(18,小数点位数)=0, |
| | | @sEPTMenuNo='', --传菜单参数 |
| | | @ID nvarchar(50)='',${formParam} |
| | | @sEPTMenuNo nvarchar(50)='${param.menuNo}', |
| | | @lang nvarchar(50)='', |
| | | @debug nvarchar(50)='', |
| | | @LoginUID nvarchar(50)='', |
| | |
| | | /* |
| | | 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} |
| | |
| | | ROLLBACK TRAN |
| | | |
| | | END` |
| | | Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') |
| | | console.log(Ltext) |
| | | Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') |
| | | return Ltext |
| | | } |
| | | } |