| | |
| | | */ |
| | | static encrypt (str, timestamp) { |
| | | let salt = 'mingke' // 盐值 |
| | | return md5(str + salt + timestamp) |
| | | let _str = str + salt + timestamp |
| | | if (_str.length > 8000) { |
| | | _str = _str.slice(_str.length - 8000) |
| | | } |
| | | return md5(_str) |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | item.value = _val ? [moment().subtract(_val[0], 'days').format('YYYY-MM-DD'), |
| | | moment().subtract(_val[1], 'days').format('YYYY-MM-DD')] : '' |
| | | } else if (item.type === 'multiselect') { |
| | | item.value = item.value ? item.value.split(',').filter(Boolean) : [] |
| | | } |
| | | newsearches.push(item) |
| | | }) |
| | |
| | | |
| | | newsearches[item.key] = item.value ? item.value[0] + ' 00:00:00.000' : null |
| | | newsearches[item.key + '1'] = item.value ? _endval + ' 00:00:00.000' : null |
| | | } else if (item.type === 'text') { |
| | | item.key.split(',').forEach(field => { // 综合搜索,所字段拼接 |
| | | newsearches[field] = item.value |
| | | }) |
| | | } else if (item.type === 'multiselect') { |
| | | newsearches[item.key] = item.value.join(',') |
| | | } else { |
| | | newsearches[item.key] = item.value |
| | | } |
| | |
| | | |
| | | let searchText = '' |
| | | searches.forEach(item => { |
| | | if (!item.value) return |
| | | // eslint-disable-next-line |
| | | searchText += (searchText !== '' ? ' ' + 'AND' + ' ' : '') |
| | | if (item.type === 'text' || item.type === 'select') { |
| | | // eslint-disable-next-line |
| | | if (!item.value || (item.type === 'multiselect' && item.value.length === 0)) return |
| | | |
| | | searchText += (searchText !== '' ? ' AND ' : '') |
| | | if (item.type === 'text') { |
| | | let str = item.match === '=' ? '' : '%' |
| | | // eslint-disable-next-line |
| | | searchText += item.key + ' ' + item.match + ' ' + '\'' + str + item.value + str + '\'' |
| | | let fields = item.key.split(',').map(field => { // 综合搜索,所字段拼接 |
| | | return field + ' ' + item.match + ' \'' + str + item.value + str + '\'' |
| | | }) |
| | | |
| | | searchText += '(' + fields.join(' OR ') + ')' |
| | | } else if (item.type === 'select') { |
| | | let str = item.match === '=' ? '' : '%' |
| | | |
| | | searchText += item.key + ' ' + item.match + ' \'' + str + item.value + str + '\'' |
| | | } else if (item.type === 'multiselect') { |
| | | let str = item.match === '=' ? '' : '%' |
| | | let options = item.value.map(val => { |
| | | return item.key + ' ' + item.match + ' \'' + str + val + str + '\'' |
| | | }) |
| | | |
| | | searchText += '(' + options.join(' OR ') + ')' |
| | | } else if (item.type === 'date') { |
| | | let _val = item.value |
| | | let timetail = ' 00:00:00.000' |
| | |
| | | timetail = '' |
| | | } |
| | | |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + _match + ' ' + '\'' + _val + timetail + '\')' |
| | | searchText += '(' + item.key + ' ' + _match + ' \'' + _val + timetail + '\')' |
| | | } else if (item.type === 'datemonth') { // 月-过滤条件,从月开始至结束,结束时间为月末加一天的0点,方式为< |
| | | let _startval = moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000' |
| | | let _endval = moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' |
| | | |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')' |
| | | } else if (item.type === 'dateweek') { // 周-过滤条件 |
| | | let _startval = item.value[0] + ' 00:00:00.000' |
| | | let _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' |
| | | |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')' |
| | | } else if (item.type === 'daterange') { |
| | | let _startval = item.value[0] + ' 00:00:00.000' |
| | | let _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' |
| | | |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')' |
| | | } else { |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + '\')' |
| | | searchText += '(' + item.key + ' ' + item.match + ' \'' + item.value + '\')' |
| | | } |
| | | }) |
| | | return searchText |
| | |
| | | let searchText = '' |
| | | searches.forEach(item => { |
| | | if (!item.value) return |
| | | // eslint-disable-next-line |
| | | searchText += (searchText !== '' ? ' ' + 'AND' + ' ' : '') |
| | | searchText += (searchText !== '' ? ' AND ' : '') |
| | | if (item.type === 'text') { |
| | | let options = item.key.split(',').map(op => { |
| | | // equal时不添加% |
| | | // eslint-disable-next-line |
| | | let str = item.op === 'equal' ? '' : '%' |
| | | // eslint-disable-next-line |
| | | return op + ' ' + item.op + ' ' + '"' + str + item.value + str + '"' |
| | | return op + ' ' + item.op + ' \'' + str + item.value + str + '\'' |
| | | }) |
| | | // eslint-disable-next-line |
| | | searchText += '(' + options.join(' ' + 'OR' + ' ') + ')' |
| | | searchText += '(' + options.join(' OR ') + ')' |
| | | } else if (item.type === 'date') { |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.op + ' ' + '"' + item.value + '")' |
| | | searchText += '(' + item.key + ' ' + item.op + ' \'' + item.value + '\')' |
| | | } else { |
| | | // eslint-disable-next-line |
| | | searchText += '(' + item.key + ' ' + item.op + ' ' + '"' + item.value + '")' |
| | | searchText += '(' + item.key + ' ' + item.op + ' \'' + item.value + '\')' |
| | | } |
| | | }) |
| | | return searchText |
| | |
| | | } else { |
| | | baseurl = 'http://qingqiumarket.cn/' + service |
| | | } |
| | | // if (!/Content\/images\/upload\//.test(url)) { |
| | | // baseurl = baseurl + 'Content/images/upload/' |
| | | // } |
| | | let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url |
| | | return realurl |
| | | } |
| | | |
| | | /** |
| | | * @description 获取下拉搜索查询sql |
| | | * @return {String} item 搜索条件信息 |
| | | */ |
| | | static getSelectQuerySql (item) { |
| | | let _datasource = item.dataSource |
| | | let sql = '' |
| | | |
| | | if (/\s/.test(_datasource)) { // 拼接别名 |
| | | _datasource = '(' + _datasource + ') tb' |
| | | } |
| | | |
| | | if (item.type === 'link') { |
| | | sql = 'select ' + item.valueField + ',' + item.valueText + ',' + item.linkField + ' from ' + _datasource |
| | | } else { |
| | | sql = 'select ' + item.valueField + ',' + item.valueText + ' from ' + _datasource |
| | | } |
| | | |
| | | if (item.orderBy) { |
| | | sql = sql + ' order by ' + item.orderBy + ' ' + item.orderType |
| | | } |
| | | |
| | | return sql |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return {String} type 执行类型 |
| | | * @return {String} table 表名 |
| | | */ |
| | | static getSysDefaultSql (btn, setting, formdata) { |
| | | static getSysDefaultSql (btn, setting, formdata, primaryId) { |
| | | let primaryKey = setting.primaryKey || 'id' |
| | | let _sql = '' |
| | | |
| | | console.log(primaryId) |
| | | if (btn.OpenType === 'pop' && btn.sqlType === 'insert') { |
| | | let keys = [] |
| | | let values = [] |
| | |
| | | keys = keys.join(',') |
| | | values = values.join(',') |
| | | |
| | | _sql = `insert into ${btn.sql} (${keys}, createuserid) select ${values},@userid` |
| | | _sql = `insert into ${btn.sql} (${keys}, createuserid, BID) select ${values},@BID,@userid` |
| | | } else if (btn.OpenType === 'pop' && btn.sqlType === 'update') { |
| | | let _form = [] |
| | | formdata.forEach(item => { |
| | |
| | | } |
| | | }) |
| | | _form = _form.join(',') |
| | | _sql = `update ${btn.sql} set ${_form},modifydate=getdate(),modifyuserid=@userid where ${setting.primaryKey}=@id` |
| | | _sql = `update ${btn.sql} set ${_form},modifydate=getdate(),modifyuserid=@userid where ${primaryKey}=@${primaryKey}` |
| | | } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'LogicDelete') { // 逻辑删除 |
| | | _sql = `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid where ${setting.primaryKey}=@id` |
| | | _sql = `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid where ${primaryKey}=@${primaryKey}` |
| | | } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete') { |
| | | _sql = `insert into snote (remark,createuserid) select '删除表:${btn.sql} 数据: id='+@id,@userid delete ${btn.sql} where ${setting.primaryKey}=@id` |
| | | _sql = `insert into snote (remark,createuserid) select '删除表:${btn.sql} 数据: ${primaryKey}='+@${primaryKey},@userid delete ${btn.sql} where ${primaryKey}=@${primaryKey}` |
| | | } |
| | | |
| | | return _sql |
| | |
| | | let form = '' |
| | | let formParam = '' |
| | | let _columns = [] |
| | | let primaryKey = config.setting.primaryKey || 'ID' |
| | | |
| | | if (config.search && config.search.length > 0) { |
| | | let _fields = new Map() |
| | |
| | | let Ltext = `create proc ${param.innerFunc} |
| | | ( /*${menu.MenuName}*/ |
| | | @BID nvarchar(50)='', |
| | | @ID nvarchar(50)='',${formParam} |
| | | @${primaryKey} nvarchar(50)='',${formParam} |
| | | @PageIndex nvarchar(50)='', |
| | | @PageSize nvarchar(50)='', |
| | | @OrderCol nvarchar(50)='', |
| | |
| | | ROLLBACK TRAN |
| | | |
| | | END` |
| | | console.log(Ltext) |
| | | |
| | | Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') |
| | | |
| | | return Ltext |
| | |
| | | * @description 创建存储过程 |
| | | * @return {String} |
| | | */ |
| | | static getfunc (param, btn, menu, columns) { |
| | | static getfunc (param, btn, menu, config) { |
| | | console.log(menu) |
| | | let form = '' |
| | | let formParam = '' |
| | | let columns = config.columns |
| | | let primaryKey = config.setting.primaryKey || 'ID' |
| | | |
| | | if (param.fields && param.fields.length > 0) { |
| | | let _fields = [] |
| | |
| | | let Ltext = `create proc ${param.funcName} |
| | | ( /*${menu.MenuName} ${btn.label}*/ |
| | | @BID nvarchar(50)='', |
| | | @ID nvarchar(50)='',${formParam} |
| | | @${primaryKey} nvarchar(50)='',${formParam} |
| | | @sEPTMenuNo nvarchar(50)='${param.menuNo}', |
| | | @lang nvarchar(50)='', |
| | | @debug nvarchar(50)='', |