| | |
| | | } |
| | | |
| | | if (config.systemRun === 'backend') { |
| | | GLOB.debugger = false |
| | | Object.defineProperty(window, 'backend', { |
| | | writable: false, |
| | | value: true |
| | |
| | | |
| | | window.GLOB.CacheData.set(MenuID, urlparam) |
| | | |
| | | // if (window.backend && config.allSqls) { |
| | | // let keys = Object.keys(urlparam) |
| | | // config.allSqls.forEach(item => { |
| | | // if (item.type === 'datasource') { |
| | | // item.urlkeys = keys |
| | | // item.urlparam = urlparam |
| | | // if (config.flow_code) { |
| | | // item.works_flow_code = config.flow_code |
| | | // } |
| | | // } |
| | | // window.GLOB.CacheData.set('sql_' + item.uuid, item) |
| | | // }) |
| | | // } |
| | | if (window.backend && config.allSqls) { |
| | | let keys = Object.keys(urlparam) |
| | | config.allSqls.forEach(item => { |
| | | if (item.type === 'datasource') { |
| | | item.urlkeys = keys |
| | | item.urlparam = urlparam |
| | | if (config.flow_code) { |
| | | item.works_flow_code = config.flow_code |
| | | } |
| | | } |
| | | window.GLOB.CacheData.set('sql_' + item.uuid, item) |
| | | }) |
| | | } |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | |
| | | } else if (type === 'dateweek' || type === 'daterange' || type === 'range') { |
| | | reOptions.match = matchReg.class5 |
| | | } else if (type === 'checkcard') { |
| | | if (this.record.multiple === 'false') { |
| | | if (this.record.multiple === 'false' || this.record.multiple === 'dropdown') { |
| | | reOptions.match = matchReg.class1 |
| | | } else if (this.record.multiple === 'true') { |
| | | reOptions.match = matchReg.class3 |
| | |
| | | let _quot = sql.match(/'{1}/g) |
| | | let _lparen = sql.match(/\({1}/g) |
| | | let _rparen = sql.match(/\){1}/g) |
| | | let _ch_b = sql.match(/\$check@/ig) |
| | | let _ch_d = sql.match(/@check\$/ig) |
| | | let _m_b = sql.match(/\$@/ig) |
| | | let _m_d = sql.match(/@\$/ig) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | _ch_b = _ch_b ? _ch_b.length : 0 |
| | | _ch_d = _ch_d ? _ch_d.length : 0 |
| | | _m_b = _m_b ? _m_b.length : 0 |
| | | _m_d = _m_d ? _m_d.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (_ch_b !== _ch_d) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中 $check@ 与 @check$ 必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (_m_b !== _m_d) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中 $@ 与 @$ 必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | |
| | | |
| | | let filterComponent = (components, mainSearch) => { |
| | | components.forEach(item => { |
| | | item.$menuname = (config.MenuName || '') + '-' + (item.name || '') |
| | | |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | let _mainSearch = mainSearch || [] |
| | |
| | | |
| | | let getSearches = (searches) => { |
| | | let sFields = [] |
| | | let query = false |
| | | searches.forEach(item => { |
| | | if (!item.field) return |
| | | |
| | |
| | | } else { |
| | | sFields.push(item.field) |
| | | } |
| | | |
| | | if (query) return |
| | | |
| | | query = item.query !== 'false' |
| | | }) |
| | | |
| | | return { sFields, query } |
| | | return sFields |
| | | } |
| | | |
| | | let getSysDefaultSql = (btn, component) => { |
| | |
| | | searches = [...searches, ...mainSearch] |
| | | } |
| | | item.$searches = fromJS(searches).toJS() |
| | | let { sFields, query } = getSearches(searches) |
| | | let sFields = getSearches(searches) |
| | | |
| | | let _columns = [] |
| | | if (item.subtype === 'dualdatacard') { |
| | |
| | | } |
| | | }) |
| | | |
| | | if (_customScript || _tailScript) { |
| | | _tailScript += `${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } |
| | | |
| | | let _search = '' |
| | | if (item.setting.execute !== 'false') { |
| | | _dataresource = item.setting.dataresource || '' |
| | | _search = '@mk_search@' |
| | | } |
| | | |
| | | if (/\s/.test(_dataresource)) { |
| | |
| | | |
| | | item.setting.dataresource = _dataresource |
| | | item.setting.customScript = _customScript |
| | | |
| | | let _search = '@search@' |
| | | if (item.setting.queryType === 'statistics' || !query) { |
| | | _search = '' |
| | | } |
| | | |
| | | let testSql = _dataresource + _customScript + _tailScript |
| | | |
| | |
| | | let secSql = [`@ErrorCode='',@retmsg =''`] |
| | | |
| | | let reps = [] |
| | | if (_customScript || _tailScript) { |
| | | reps.push('UserID', 'time_id') |
| | | } |
| | | |
| | | let syses = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address'] |
| | | syses.forEach(s => { |
| | |
| | | let LText = '' |
| | | let DateCount = '' |
| | | if (_dataresource) { |
| | | /*system_query*/ |
| | | if (/@pageSize@|@orderBy@|@mk_total/i.test(testSql)) { |
| | | LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} ` |
| | | LText = `select ${arr_field} from ${_dataresource} ${_search} ` |
| | | } else if (item.setting.laypage === 'true' && item.setting.order) { |
| | | LText = `/*system_query*/select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` |
| | | LText = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` |
| | | reps.push('pageSize', 'orderBy', 'pageIndex') |
| | | if (item.subtype === 'dualdatacard') { |
| | | DateCount = `/*system_query*/select count(1) as total from (select distinct ${item.setting.primaryKey || 'ID'} from ${_dataresource} ${_search})a` |
| | | DateCount = `select count(1) as total from (select distinct ${item.setting.primaryKey || 'ID'} from ${_dataresource} ${_search})a` |
| | | } else { |
| | | DateCount = `/*system_query*/select count(1) as total from ${_dataresource} ${_search}` |
| | | DateCount = `select count(1) as total from ${_dataresource} ${_search}` |
| | | } |
| | | } else if (item.setting.$top) { |
| | | if (item.setting.order) { |
| | | LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` |
| | | LText = `select top 1 ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` |
| | | reps.push('orderBy') |
| | | } else { |
| | | LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search} ` |
| | | LText = `select top 1 ${arr_field} from ${_dataresource} ${_search} ` |
| | | } |
| | | } else if (item.setting.order) { |
| | | LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` |
| | | LText = `select ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` |
| | | reps.push('orderBy') |
| | | } else { |
| | | LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} ` |
| | | LText = `select ${arr_field} from ${_dataresource} ${_search} ` |
| | | } |
| | | } |
| | | |
| | | if (_customScript) { |
| | | _customScript = `${decSql} |
| | | ${_customScript} |
| | | ` |
| | | if (DateCount) { |
| | | DateCount = `${DateCount} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode,@retmsg,@UserID@ |
| | | ` |
| | | } else if (LText) { |
| | | LText = `${LText} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode,@retmsg,@UserID@ |
| | | ` |
| | | } else { |
| | | _customScript = `${_customScript} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } |
| | | } else if (_tailScript && DateCount) { |
| | | LText = `${decSql} |
| | | ${LText} |
| | | ` |
| | | DateCount = `${DateCount} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } else if (_tailScript) { |
| | | LText = `${decSql} |
| | | ${LText} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } else { |
| | | LText = `${decSql} |
| | | ${LText} |
| | | ` |
| | | } |
| | | |
| | | reps = Array.from(new Set(reps)) |
| | | |
| | | // LText = LText.replace(/\n\s{6,8}/g, '\n') |
| | | // DateCount = DateCount.replace(/\n\s{6,8}/g, '\n') |
| | | // _customScript = _customScript.replace(/\n\s{6,8}/g, '\n') |
| | | // LText = LText.replace(/\n\s+\/\*/g, `\n/*`) |
| | | // DateCount = DateCount.replace(/\n\s+\/\*/g, `\n/*`) |
| | | // _customScript = _customScript.replace(/\n\s+\/\*/g, `\n/*`) |
| | | let sub_name = '' |
| | | let tabid = '' |
| | | let parid = '' |
| | | let sub_field = '' |
| | | |
| | | if (item.subtype === 'dualdatacard') { |
| | | arr_field = item.columns.map(col => col.field).join(',') |
| | | sub_name = item.setting.subdata |
| | | tabid = item.setting.primaryKey || '' |
| | | parid = item.setting.subBID || '' |
| | | sub_field = item.subColumns.map(col => col.field).join(',') |
| | | } |
| | | |
| | | let sql = `SELECT obj_name='@mk_obj_name@',prm_field='',str_field='', |
| | | arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}' |
| | | ` |
| | | |
| | | if (DateCount) { |
| | | sql += `UNION ALL |
| | | SELECT obj_name='DateCount',prm_field='total',str_field='', |
| | | arr_field='',tabid='',parid='',sub_name='',sub_field='' |
| | | ` |
| | | } |
| | | |
| | | sql += ` |
| | | ${decSql} |
| | | ${_customScript} |
| | | ${LText} |
| | | ${DateCount} |
| | | ${_tailScript} |
| | | ` |
| | | |
| | | reps.forEach(n => { |
| | | if (['orderBy', 'pageSize', 'pageIndex'].includes(n)) return |
| | | |
| | | LText = LText.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) |
| | | DateCount = DateCount.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) |
| | | _customScript = _customScript.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) |
| | | sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) |
| | | }) |
| | | if (/\$@/ig.test(testSql)) { |
| | | LText = LText.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') |
| | | DateCount = DateCount.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') |
| | | _customScript = _customScript.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') |
| | | if (/\$@/ig.test(sql)) { |
| | | sql = sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') |
| | | reps.push('datam_begin', 'datam_end') |
| | | } |
| | | if (/@db@/ig.test(testSql)) { |
| | | if (/@db@/ig.test(sql)) { |
| | | reps.push('db') |
| | | } |
| | | reps.push('mk_obj_name') |
| | | |
| | | // let sql = '' |
| | | // let sub_name = '' |
| | | // let tabid = '' |
| | | // let parid = '' |
| | | // let sub_field = '' |
| | | sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '') |
| | | |
| | | // if (item.subtype === 'dualdatacard') { |
| | | // arr_field = item.columns.map(col => col.field).join(',') |
| | | // sub_name = item.setting.subdata |
| | | // tabid = item.setting.primaryKey || '' |
| | | // parid = item.setting.subBID || '' |
| | | // sub_field = item.subColumns.map(col => col.field).join(',') |
| | | // } |
| | | |
| | | // sql += ` |
| | | // SELECT obj_name='data',prm_field='',str_field='', |
| | | // arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}' |
| | | // ` |
| | | |
| | | // if (DateCount) { |
| | | // sql += `UNION ALL |
| | | // SELECT obj_name='DateCount',prm_field='total',str_field='', |
| | | // arr_field='',tabid='',parid='',sub_name='',sub_field='' |
| | | // ` |
| | | // } |
| | | |
| | | return {LText, DateCount, customScript: _customScript, reps} |
| | | return {LText: sql, reps} |
| | | } |
| | | |
| | | let getExcelInSql = (item) => { |
| | |
| | | item.dataSource = '(' + item.dataSource + ') tb' |
| | | } |
| | | |
| | | let sql = '' |
| | | let LText = '' |
| | | let DateCount = '' |
| | | let _search = '' |
| | | let reps = [] |
| | | let sFields = [] |
| | | |
| | | if (item.searchKey) { |
| | | _search = '@search@' |
| | | _search = '@mk_search@' |
| | | sFields = item.searchKey.split(',') |
| | | } |
| | | |
| | |
| | | } |
| | | }) |
| | | |
| | | if (item.laypage === 'true') { |
| | | sql = `/*system_query*/select top @pageSize@ ${arrfield} from (select ${arrfield} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${item.dataSource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` |
| | | DateCount = `/*system_query*/select count(1) as total from ${item.dataSource} ${_search}` |
| | | |
| | | reps.push('pageSize', 'orderBy', 'pageIndex') |
| | | } else { |
| | | sql = `/*system_query*/select ${arrfield} from ${item.dataSource} ${_search} order by @orderBy@ ` |
| | | reps.push('orderBy') |
| | | } |
| | | |
| | | let decSql = [] |
| | | let secSql = [] |
| | | |
| | | let syses = ['mk_departmentcode', 'mk_organization', 'mk_user_type'] |
| | | syses.forEach(s => { |
| | | if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(sql)) { |
| | | if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(item.dataSource)) { |
| | | if (['mk_departmentcode', 'mk_organization'].includes(s)) { |
| | | decSql.push(`@${s} nvarchar(512)`) |
| | | } else { |
| | |
| | | secSql = secSql.join(',') |
| | | |
| | | if (decSql) { |
| | | sql = `Declare ${decSql} select ${secSql} |
| | | ${sql} |
| | | decSql = `Declare ${decSql} select ${secSql}` |
| | | } |
| | | |
| | | if (item.laypage === 'true') { |
| | | /*system_query*/ |
| | | LText = `select top @pageSize@ ${arrfield} from (select ${arrfield} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${item.dataSource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` |
| | | DateCount = `select count(1) as total from ${item.dataSource} ${_search}` |
| | | |
| | | reps.push('pageSize', 'orderBy', 'pageIndex') |
| | | } else { |
| | | LText = `select ${arrfield} from ${item.dataSource} ${_search} order by @orderBy@ ` |
| | | reps.push('orderBy') |
| | | } |
| | | |
| | | let sql = `SELECT obj_name='data',prm_field='',str_field='', |
| | | arr_field='${arrfield}',tabid='',parid='',sub_name='',sub_field='' |
| | | ` |
| | | |
| | | if (DateCount) { |
| | | sql += `UNION ALL |
| | | SELECT obj_name='DateCount',prm_field='total',str_field='', |
| | | arr_field='',tabid='',parid='',sub_name='',sub_field='' |
| | | ` |
| | | } |
| | | |
| | | sql += ` |
| | | ${decSql} |
| | | ${LText} |
| | | ${DateCount} |
| | | ` |
| | | |
| | | reps.forEach(n => { |
| | | if (['orderBy', 'pageSize', 'pageIndex'].includes(n)) return |
| | | |
| | | sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) |
| | | DateCount = DateCount.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) |
| | | }) |
| | | if (/\$@/ig.test(sql)) { |
| | | sql = sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') |
| | | DateCount = DateCount.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') |
| | | reps.push('datam_begin', 'datam_end') |
| | | } |
| | | if (/@db@/ig.test(sql)) { |
| | | reps.push('db') |
| | | } |
| | | |
| | | return {LText: sql, DateCount, reps} |
| | | |
| | | sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '') |
| | | |
| | | return {LText: sql, reps} |
| | | } |
| | | |
| | | let _mainSearch = [] |
| | |
| | | let param = null |
| | | |
| | | if (setting.interType === 'system') { |
| | | param = this.getDefaultQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) |
| | | if (window.backend && window.GLOB.CacheData.has('sql_' + setting.uuid) && !window.GLOB.mkHS) { |
| | | param = this.getDefaultQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) |
| | | this.getBackendQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) |
| | | } else { |
| | | param = this.getDefaultQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) |
| | | } |
| | | } else { |
| | | param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, id, year) |
| | | } |
| | |
| | | param.menuname = setting.$name |
| | | } |
| | | |
| | | // if (window.backend && window.GLOB.CacheData.has('sql_' + setting.uuid)) { |
| | | // let item = window.GLOB.CacheData.get('sql_' + setting.uuid) |
| | | |
| | | // let values = { |
| | | // userid: sessionStorage.getItem('UserID') || '', |
| | | // time_id: Utils.getguid(), |
| | | // username: userName, |
| | | // fullname: fullName, |
| | | // roleid: RoleID, |
| | | // mk_departmentcode: departmentcode, |
| | | // mk_organization: organization, |
| | | // mk_user_type: mk_user_type, |
| | | // mk_nation: nation, |
| | | // mk_province: province, |
| | | // mk_city: city, |
| | | // mk_district: district, |
| | | // mk_address: address, |
| | | // orderby: orderBy, |
| | | // pagesize: setting.laypage ? pageSize : '9999', |
| | | // pageindex: pageIndex, |
| | | // id: id || '', |
| | | // bid: BID || '', |
| | | // loginuid: sessionStorage.getItem('LoginUID') || '', |
| | | // sessionuid: localStorage.getItem('SessionUid') || '', |
| | | // appkey: window.GLOB.appkey || '', |
| | | // lang: sessionStorage.getItem('lang'), |
| | | // typename: 'admin', |
| | | // datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | // datam_begin: sessionStorage.getItem('dataM') === 'true' ? '/*' : '', |
| | | // datam_end: sessionStorage.getItem('dataM') === 'true' ? '*/' : '', |
| | | // } |
| | | |
| | | // if (setting.hasExtend) { |
| | | // values.mk_time = setting.extendTime |
| | | // } |
| | | // if (setting.$re_year) { |
| | | // values.mk_year = year |
| | | // } |
| | | // if (window.GLOB.externalDatabase !== null) { |
| | | // values.db = window.GLOB.externalDatabase |
| | | // } |
| | | // if (item.works_flow_code) { |
| | | // values.works_flow_code = item.works_flow_code |
| | | // } |
| | | // item.urlkeys.forEach(key => { |
| | | // values[key] = item.urlparam[key] |
| | | // }) |
| | | |
| | | // let Ltext = item.LText |
| | | // let DateCount = item.DateCount |
| | | // let customScript = item.customScript |
| | | |
| | | // item.reps.forEach(n => { |
| | | // let key = n.toLowerCase() |
| | | // if (values.hasOwnProperty(key)) { |
| | | // Ltext = Ltext.replace(new RegExp('@' + key + '@', 'ig'), values[key]) |
| | | // DateCount = DateCount.replace(new RegExp('@' + key + '@', 'ig'), values[key]) |
| | | // customScript = customScript.replace(new RegExp('@' + key + '@', 'ig'), values[key]) |
| | | // } |
| | | // }) |
| | | |
| | | // if (search.length) { |
| | | |
| | | // } |
| | | // } |
| | | |
| | | param.custom_script = Utils.formatOptions(_customScript, param.exec_type) |
| | | param.LText = Utils.formatOptions(LText, param.exec_type) |
| | | param.DateCount = Utils.formatOptions(DateCount, param.exec_type) |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统存储过程的参数 |
| | | */ |
| | | static getBackendQueryParam (setting, search, orderBy, pageIndex, pageSize, id, BID, year) { |
| | | let item = window.GLOB.CacheData.get('sql_' + setting.uuid) |
| | | |
| | | let param = {} |
| | | |
| | | let searchKeys = null |
| | | if (setting.dataresource) { |
| | | searchKeys = [] |
| | | |
| | | if (search.length) { |
| | | searchKeys = Utils.getSearchkeys(search) |
| | | } |
| | | |
| | | if (id) { |
| | | if (/^excel:/.test(id)) { |
| | | id = id.replace(/^excel:/, '') |
| | | searchKeys.push({ |
| | | key: setting.primaryKey || 'ID', |
| | | match: 'in', |
| | | type: 'text_in', |
| | | value: id |
| | | }) |
| | | } else { |
| | | searchKeys.push({ |
| | | key: setting.primaryKey || 'ID', |
| | | match: '=', |
| | | type: 'text', |
| | | value: id |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | let values = { |
| | | userid: sessionStorage.getItem('UserID') || '', |
| | | time_id: Utils.getguid(), |
| | | username: sessionStorage.getItem('User_Name') || '', |
| | | fullname: sessionStorage.getItem('Full_Name') || '', |
| | | roleid: sessionStorage.getItem('role_id') || '', |
| | | mk_departmentcode: sessionStorage.getItem('departmentcode') || '', |
| | | mk_organization: sessionStorage.getItem('organization') || '', |
| | | mk_user_type: sessionStorage.getItem('mk_user_type') || '', |
| | | mk_nation: sessionStorage.getItem('nation') || '', |
| | | mk_province: sessionStorage.getItem('province') || '', |
| | | mk_city: sessionStorage.getItem('city') || '', |
| | | mk_district: sessionStorage.getItem('district') || '', |
| | | mk_address: sessionStorage.getItem('address') || '', |
| | | orderby: orderBy, |
| | | pagesize: setting.laypage ? pageSize : '9999', |
| | | pageindex: pageIndex, |
| | | id: id || '', |
| | | bid: BID || '', |
| | | loginuid: sessionStorage.getItem('LoginUID') || '', |
| | | sessionuid: localStorage.getItem('SessionUid') || '', |
| | | appkey: window.GLOB.appkey || '', |
| | | lang: sessionStorage.getItem('lang'), |
| | | typename: 'admin', |
| | | datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | // datam_begin: sessionStorage.getItem('dataM') === 'true' ? '/*' : '', |
| | | // datam_end: sessionStorage.getItem('dataM') === 'true' ? '*/' : '', |
| | | mk_obj_name: 'data' |
| | | } |
| | | |
| | | if (setting.hasExtend) { |
| | | values.mk_time = setting.extendTime |
| | | } |
| | | if (setting.$re_year) { |
| | | values.mk_year = year |
| | | } |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | values.db = window.GLOB.externalDatabase |
| | | } |
| | | if (item.works_flow_code) { |
| | | values.works_flow_code = item.works_flow_code |
| | | } |
| | | |
| | | item.urlkeys.forEach(key => { |
| | | values[key] = item.urlparam[key] |
| | | }) |
| | | |
| | | let allSearch = Utils.getAllSearchOptions(search) |
| | | |
| | | allSearch.forEach(cell => { |
| | | values[cell.key.toLowerCase()] = cell.value |
| | | }) |
| | | |
| | | let list = [] |
| | | |
| | | if (searchKeys) { |
| | | list.push({ |
| | | key: 'mk_search', |
| | | value: searchKeys |
| | | }) |
| | | } |
| | | |
| | | let sql = item.sql |
| | | |
| | | item.reps.forEach(n => { |
| | | let key = n.toLowerCase() |
| | | if (values.hasOwnProperty(key)) { |
| | | list.push({ |
| | | key: n, |
| | | value: values[key] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | // let list = [ |
| | | // { |
| | | // key: "mk_search", |
| | | // value: [ |
| | | // { key: "nvarchar1,nvarchar3", match: "like", type: "text_or", value: "www" }, |
| | | // { key: "int2", match: ">=", type: "number", value: "0" }, |
| | | // { key: "int2", match: "<=", type: "number", value: "50" } |
| | | // ] |
| | | // }, |
| | | // { key: "mk_obj_name", value: "data" }, |
| | | // { key: "pageSize", value: 10 }, |
| | | // { key: "orderBy", value: "ID desc" }, |
| | | // { key: "pageIndex", value: 1 }, |
| | | // { |
| | | // key: 'mk_excel_data', |
| | | // value: [[`'1'`, `'2'`, `'3'`, `'4'`, `'5'`], [`'6'`, `'7'`, `'8'`, `'9'`, `'10'`]] |
| | | // }, |
| | | // { |
| | | // key: 'mk_outer_params', |
| | | // value: [ |
| | | // { |
| | | // tb: '#tb1', |
| | | // keys: ['[nvarchar1]', '[nvarchar2]', '[nvarchar3]', '[mk_level]','[mk_id]','[mk_bid]'], |
| | | // values: [[`'1'`, `'2'`, `'3'`, `'4'`, `'5'`, `'6'`], [`'7'`, `'8'`, `'9'`, `'10'`, `'11'`, `'12'`]] |
| | | // }, |
| | | // { |
| | | // tb: '@tb2', |
| | | // keys: ['[field1]', '[field2]', '[field3]', '[mk_level]','[mk_id]','[mk_bid]'], |
| | | // values: [[`'1'`, `'2'`, `'3'`, `'4'`, `'5'`, `'6'`], [`'7'`, `'8'`, `'9'`, `'10'`, `'11'`, `'12'`]] |
| | | // } |
| | | // ] |
| | | // }, |
| | | // ] |
| | | |
| | | list.forEach(cell => { |
| | | if (cell.key === 'mk_outer_params') { |
| | | let mk_outer_params = [] |
| | | cell.value.forEach(n => { |
| | | mk_outer_params.push(` Insert into ${n.tb} (${n.keys.join(',')}) `) |
| | | let vals = [] |
| | | n.values.forEach(m => { |
| | | vals.push(` Select ${m.join(',')} `) |
| | | }) |
| | | mk_outer_params.push(vals.join(' Union all ')) |
| | | }) |
| | | mk_outer_params = mk_outer_params.join('') |
| | | sql = sql.replace(/@mk_outer_params@/ig, mk_outer_params) |
| | | } else if (cell.key === 'mk_excel_data') { |
| | | let mk_excel_data = [] |
| | | cell.value.forEach(n => { |
| | | mk_excel_data.push(`Select ${n.join(',')}`) |
| | | }) |
| | | mk_excel_data = mk_excel_data.join(' Union all ') |
| | | sql = sql.replace(/@mk_excel_data@/ig, mk_excel_data) |
| | | } else if (cell.key === 'datam_begin' || cell.key === 'mk_check_begin') { |
| | | if (cell.value === 'Y') { |
| | | sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '/*') |
| | | } else { |
| | | sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '') |
| | | } |
| | | } else if (cell.key === 'datam_end' || cell.key === 'mk_check_end') { |
| | | if (cell.value === 'Y') { |
| | | sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '*/') |
| | | } else { |
| | | sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '') |
| | | } |
| | | } else if (cell.key === 'mk_search') { |
| | | let mk_search = [] |
| | | |
| | | cell.value.forEach(n => { |
| | | let str = n.match === 'like' || n.match === 'not like' ? '%' : '' |
| | | if (n.type === 'text_or') { |
| | | let vals = n.key.split(',').map(key => { |
| | | return `${key} ${n.match} '${str}${n.value}${str}'` |
| | | }) |
| | | |
| | | mk_search.push(`(${vals.join(' OR ')})`) |
| | | } else if (n.type === 'text_multi') { |
| | | mk_search.push(`'${n.value}' ${n.match} '%'+${n.key}+'%'`) |
| | | } else if (n.type === 'number') { |
| | | mk_search.push(`${n.key} ${n.match} ${n.value}`) |
| | | } else if (n.type === 'text_in') { |
| | | mk_search.push(`${n.key} in (select ID from dbo.SplitComma('${n.value}'))`) |
| | | } else { |
| | | mk_search.push(`${n.key} ${n.match} '${str}${n.value}${str}'`) |
| | | } |
| | | }) |
| | | |
| | | if (mk_search.length === 0) { |
| | | mk_search = '' |
| | | } else { |
| | | mk_search = 'where ' + mk_search.join(' AND ') |
| | | } |
| | | |
| | | sql = sql.replace(/@mk_search@/ig, mk_search) |
| | | } else { |
| | | sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), cell.value) |
| | | } |
| | | }) |
| | | |
| | | param.list = [ |
| | | { |
| | | id: item.v_id, |
| | | regExps: list, |
| | | menuname: setting.$name || '', |
| | | s_debug_type: window.GLOB.probation ? 'Y' : '', |
| | | // md5_id: window.GLOB.probation ? md5(JSON.stringify(list)) : '', |
| | | } |
| | | ] |
| | | |
| | | if (setting.database === 'sso' && window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | return param |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统存储过程合计值的参数 |
| | | */ |
| | | static getStatQueryDataParams (setting, statFields, search, orderBy, BID) { |
| | |
| | | return searchText.join(' AND ') |
| | | } |
| | | |
| | | static getSearchkeys (searches) { |
| | | let searchText = [] |
| | | |
| | | searches.forEach(item => { |
| | | if (item.forbid || !item.value) return |
| | | |
| | | let cell = { |
| | | key: item.key, |
| | | match: item.match, |
| | | type: 'text', |
| | | value: item.value |
| | | } |
| | | |
| | | if (item.type === 'text' || item.type === 'select') { // 综合搜索,文本或下拉,所有字段拼接 |
| | | if (/,/.test(item.key)) { |
| | | cell.type = 'text_or' |
| | | } |
| | | } else if (item.type === 'multi') { |
| | | cell.type = 'text_multi' |
| | | } else if (item.type === 'date') { |
| | | let _val = item.value |
| | | let timetail = '' |
| | | |
| | | if (item.match === '<' || item.match === '<=') { // 时间为<=时,匹配后一天的0点,匹配方式为< |
| | | cell.match = '<' |
| | | if (item.precision === 'day') { |
| | | _val = moment(_val, 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') |
| | | } |
| | | } |
| | | if (item.match === '=') { |
| | | timetail = '' |
| | | } else if (item.precision === 'day') { |
| | | timetail = ' 00:00:00.000' |
| | | } else if (item.precision === 'hour') { |
| | | timetail = ':00:00.000' |
| | | } else if (item.precision === 'minute') { |
| | | timetail = ':00.000' |
| | | } else if (item.precision === 'second') { |
| | | timetail = '.000' |
| | | } |
| | | |
| | | cell.value = _val + timetail |
| | | } |
| | | |
| | | if (item.type === 'datemonth') { // 月-过滤条件,从月开始至结束,结束时间为月末加一天的0点,方式为< |
| | | if (item.match === '=') { |
| | | searchText.push(cell) |
| | | } else { |
| | | 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' |
| | | |
| | | searchText.push({ |
| | | key: item.key, |
| | | match: '>=', |
| | | type: 'text', |
| | | value: _startval |
| | | }, { |
| | | key: item.key, |
| | | match: '<', |
| | | type: 'text', |
| | | value: _endval |
| | | }) |
| | | } |
| | | } else if (item.type === 'dateweek') { // 周-过滤条件 |
| | | let _startval = moment(item.value, 'YYYY-MM-DD' ).startOf('week').format('YYYY-MM-DD') + ' 00:00:00.000' |
| | | let _endval = moment(item.value, 'YYYY-MM-DD').endOf('week').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' |
| | | |
| | | searchText.push({ |
| | | key: item.key, |
| | | match: '>=', |
| | | type: 'text', |
| | | value: _startval |
| | | }, { |
| | | key: item.key, |
| | | match: '<', |
| | | type: 'text', |
| | | value: _endval |
| | | }) |
| | | } else if (item.type === 'daterange') { |
| | | let val = item.value.split(',') |
| | | let _startval = '' |
| | | let _endval = '' |
| | | |
| | | if (item.precision === 'day') { |
| | | _startval = val[0] + ' 00:00:00.000' |
| | | _endval = moment(val[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' |
| | | } else if (item.precision === 'hour') { |
| | | _startval = val[0] + ':00:00.000' |
| | | _endval = val[1] + ':00:00.000' |
| | | } else if (item.precision === 'minute') { |
| | | _startval = val[0] + ':00.000' |
| | | _endval = val[1] + ':00.000' |
| | | } else if (item.precision === 'second') { |
| | | _startval = val[0] + '.000' |
| | | _endval = val[1] + '.000' |
| | | } |
| | | |
| | | let _skey = item.key |
| | | let _ekey = item.key |
| | | |
| | | if (/,/.test(item.key)) { |
| | | _skey = item.key.split(',')[0] |
| | | _ekey = item.key.split(',')[1] |
| | | } |
| | | |
| | | searchText.push({ |
| | | key: _skey, |
| | | match: '>=', |
| | | type: 'text', |
| | | value: _startval |
| | | }, { |
| | | key: _ekey, |
| | | match: '<', |
| | | type: 'text', |
| | | value: _endval |
| | | }) |
| | | } else if (item.type === 'range') { |
| | | let val = item.value.split(',') |
| | | |
| | | searchText.push({ |
| | | key: item.key, |
| | | match: '>=', |
| | | type: 'number', |
| | | value: val[0] || -999999999 |
| | | }, { |
| | | key: item.key, |
| | | match: '<=', |
| | | type: 'number', |
| | | value: val[1] || 999999999 |
| | | }) |
| | | } else { |
| | | searchText.push(cell) |
| | | } |
| | | }) |
| | | |
| | | return searchText |
| | | } |
| | | |
| | | /** |
| | | * @description 获取搜索用于正则替换 |
| | | * @param {Array} searches 搜索条件 |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import { langs } from '@/store/options' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js' |
| | | import { getTables, getFuncsAndInters, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | |
| | | import '@/assets/css/design.scss' |
| | |
| | | } else if (this.checklog()) { |
| | | if (sessionStorage.getItem('langList') && !config.trans) { |
| | | |
| | | // } else if (window.backend && config.enabled && !config.allSqls) { |
| | | } else if (window.backend && config.enabled && !config.allSqls) { |
| | | |
| | | } else { |
| | | notification.success({ |
| | |
| | | delete config.force |
| | | } |
| | | |
| | | // let sqls = [] |
| | | // delete config.allSqls |
| | | // if (window.backend && config.enabled) { |
| | | // sqls = getAllSqls(config) |
| | | let long_data = '' |
| | | delete config.allSqls |
| | | if (window.backend && config.enabled) { |
| | | let sqls = getAllSqls(config) |
| | | let _t = moment().format('YYYYMMDDHHmmss') |
| | | let getguid = () => { |
| | | let uuid = '' |
| | | for (let i = 0; i < 18; i++) { |
| | | uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65) |
| | | } |
| | | return uuid |
| | | } |
| | | |
| | | // config.allSqls = sqls |
| | | // } |
| | | long_data = [] |
| | | |
| | | config.allSqls = sqls.map(item => { |
| | | let v_id = _t + getguid() |
| | | long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`) |
| | | |
| | | return { |
| | | uuid: item.uuid, |
| | | v_id: v_id, |
| | | type: item.type, |
| | | reps: item.reps, |
| | | sql: item.LText |
| | | } |
| | | }) |
| | | |
| | | long_data = long_data.join(';') |
| | | } |
| | | |
| | | if (config.cacheUseful !== 'true') { |
| | | config.components = this.resetSyncQuery(config.components) |
| | |
| | | MenuName: config.MenuName || '', |
| | | PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, urlFields}), |
| | | open_edition: config.open_edition, |
| | | // LText: '', |
| | | // LTexttb: '', |
| | | long_data: long_data, |
| | | debug_md5: key, |
| | | debug_url: url, |
| | | debug_list: window.btoa(tbs), |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import { langs } from '@/store/options' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js' |
| | | import { getTables, getFuncsAndInters, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' |
| | | import SourceElement from '@/templates/zshare/dragsource' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Source from './source' |
| | |
| | | } else if (this.checklog()) { |
| | | if (sessionStorage.getItem('langList') && !config.trans) { |
| | | |
| | | // } else if (window.backend && config.enabled && !config.allSqls) { |
| | | } else if (window.backend && config.enabled && !config.allSqls) { |
| | | |
| | | } else { |
| | | notification.success({ |
| | |
| | | delete config.force |
| | | } |
| | | |
| | | // let sqls = [] |
| | | // delete config.allSqls |
| | | // if (window.backend && config.enabled) { |
| | | // sqls = getAllSqls(config) |
| | | let long_data = '' |
| | | delete config.allSqls |
| | | if (window.backend && config.enabled) { |
| | | let sqls = getAllSqls(config) |
| | | let _t = moment().format('YYYYMMDDHHmmss') |
| | | let getguid = () => { |
| | | let uuid = '' |
| | | for (let i = 0; i < 18; i++) { |
| | | uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65) |
| | | } |
| | | return uuid |
| | | } |
| | | |
| | | // config.allSqls = sqls |
| | | // } |
| | | long_data = [] |
| | | |
| | | config.allSqls = sqls.map(item => { |
| | | let v_id = _t + getguid() |
| | | long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`) |
| | | |
| | | return { |
| | | uuid: item.uuid, |
| | | v_id: v_id, |
| | | type: item.type, |
| | | reps: item.reps, |
| | | sql: item.LText |
| | | } |
| | | }) |
| | | |
| | | long_data = long_data.join(';') |
| | | } |
| | | |
| | | let tbs = [] |
| | | let btns = this.getMenuMessage(tbs) |
| | |
| | | MenuName: config.MenuName || '', |
| | | PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, urlFields}), |
| | | open_edition: config.open_edition, |
| | | // LText: '', |
| | | // LTexttb: '', |
| | | long_data: long_data, |
| | | debug_md5: key, |
| | | debug_url: url, |
| | | debug_list: window.btoa(tbs), |