| | |
| | | |
| | | let valid = true // 搜索条件必填验证, 初始搜索条件, 如通过上级透视,写入搜索条件 |
| | | let hasReqFields = false |
| | | let initSearch = config.search.map(item => { |
| | | let _item = fromJS(item).toJS() |
| | | |
| | | if (_item.required === 'true' && !_item.initval) { |
| | | config.search.forEach(item => { |
| | | if (item.required !== 'true') return |
| | | if (!item.initval) { |
| | | valid = false |
| | | } |
| | | if (_item.required === 'true') { |
| | | hasReqFields = true |
| | | } |
| | | return _item |
| | | hasReqFields = true |
| | | }) |
| | | |
| | | initSearch = Utils.initMainSearch(initSearch) |
| | | |
| | | this.setState({ |
| | | loadingview: false, |
| | |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | BID: param && param.BID ? param.BID : '', |
| | | search: Utils.initMainSearch(initSearch), // 搜索条件初始化(含有时间格式,需要转化) |
| | | search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化) |
| | | hasReqFields |
| | | }, () => { |
| | | if (config.setting.onload !== 'false' && valid) { // 初始化可加载 |
| | |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { setting, search, BIDs, loadCustomApi } = this.state |
| | | let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | const { setting, search, BIDs, loadCustomApi, hasReqFields } = this.state |
| | | let requireFields = [] |
| | | |
| | | if (hasReqFields) { |
| | | requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | } |
| | | |
| | | this.setState({ |
| | | selectedData: [], |
| | |
| | | let error = '未知的返回结果!' |
| | | |
| | | if (typeof(res) === 'string') { |
| | | error = res |
| | | error = res.replace(/'/ig, '"') |
| | | } |
| | | |
| | | let _result = { |
| | |
| | | * @description 上级菜单id变化时,刷新数据 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { |
| | | const { config, setting } = this.state |
| | | |
| | | if (config && setting && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | if (this.state.setting) { |
| | | this.loadmaindata() |
| | | } |
| | | this.loadData() |
| | | }) |
| | | } else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | if (this.state.setting) { |
| | | this.setState({}, () => { |
| | | this.loadmaindata() |
| | | }) |
| | | } |
| | | } else if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | let valid = true // 搜索条件必填验证 |
| | | let hasReqFields = false |
| | | config.search.forEach(field => { |
| | | if (field.required === 'true' && !field.initval) { |
| | | if (field.required !== 'true') return |
| | | hasReqFields = true |
| | | if (!field.initval) { |
| | | valid = false |
| | | } |
| | | if (field.required === 'true') { |
| | | hasReqFields = true |
| | | } |
| | | }) |
| | | |
| | |
| | | hasReqFields |
| | | }, () => { |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode) && valid) { // 初始化可加载 |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | |
| | | loadData = () => { |
| | | const { mainSearch, BID } = this.props |
| | | const { setting, search, loadCustomApi } = this.state |
| | | const { setting, search, loadCustomApi, hasReqFields } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | |
| | | let requireFields = [] |
| | | if (hasReqFields) { |
| | | requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | } |
| | | |
| | | if (requireFields.length > 0) { |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | let labels = requireFields.map(item => item.label) |
| | | labels = Array.from(new Set(labels)) |
| | | |
| | |
| | | statFValue: [], |
| | | total: 0 |
| | | }) |
| | | this.handleTableId() |
| | | return |
| | | } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { |
| | | notification.warning({ |
| | |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | selectedData: [] |
| | | }) |
| | | this.handleTableId() |
| | | |
| | | if (setting.interType === 'custom' && loadCustomApi) { |
| | | if (setting.execTime === 'once') { |
| | | this.setState({loadCustomApi: false}) |
| | | } |
| | | |
| | | this.loadOutResource() |
| | | this.loadOutResource(searches) |
| | | if (setting.execType === 'async') { |
| | | this.loadmaindata() |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | loadOutResource = () => { |
| | | const { setting, search, BID } = this.state |
| | | loadOutResource = (searches) => { |
| | | const { BID } = this.props |
| | | const { setting } = this.state |
| | | |
| | | let param = UtilsDM.getPrevQueryParams(setting, search, BID, this.props.menuType) |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType) |
| | | |
| | | if (setting.execType === 'sync') { |
| | | this.setState({ |
| | |
| | | let error = '未知的返回结果!' |
| | | |
| | | if (typeof(res) === 'string') { |
| | | error = res |
| | | error = res.replace(/'/ig, '"') |
| | | } |
| | | |
| | | let _result = { |
| | |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) |
| | | |
| | | if (this.state.BID) { |
| | | param.BID = this.state.BID |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | |
| | | } else { |
| | | param.func = 's_ex_result_back' |
| | | param.s_ex_result = [...lineMap.values()].map((item, index) => ({ |
| | | MenuID: this.state.config.MenuID, |
| | | MenuName: this.state.config.MenuName, |
| | | MenuID: this.props.MenuID, |
| | | MenuName: this.props.Tab.label, |
| | | TableName: item.table, |
| | | LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), |
| | | Sort: index + 1 |
| | |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | |
| | | if (requireFields.length > 0) { |
| | | let labels = requireFields.map(item => item.label) |
| | | labels = Array.from(new Set(labels)) |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: prex + this.state.dict['form.required.input'] + labels.join('、') + ' !', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (this.props.Tab.supMenu && !BID) { // 主表ID不存在时,不查询子表 |
| | | this.setState({ |
| | | data: [], |
| | | selectedData: [], |
| | | statFValue: [], |
| | | total: 0 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType) |
| | | |
| | | this.handleTableId() |
| | | |
| | | if (param.func === 'sPC_Get_TableData') { |
| | | param.menuname = this.props.Tab.label || '' |
| | |
| | | pageIndex: 1, |
| | | search: searches, |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | |
| | | pageSize: pagination.pageSize, |
| | | orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | } |
| | | } |
| | | |
| | |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import options from '@/store/options.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import UtilsUpdate from '@/utils/utils-update.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | | loadCustomApi: true, // 加载外部资源 |
| | | hasReqFields: false |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | let valid = true // 搜索条件必填验证 |
| | | let hasReqFields = false |
| | | config.search.forEach(field => { |
| | | if (field.required === 'true' && !field.initval) { |
| | | if (field.required !== 'true') return |
| | | hasReqFields = true |
| | | if (!field.initval) { |
| | | valid = false |
| | | } |
| | | }) |
| | |
| | | actions: _actions, |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | search: Utils.initMainSearch(config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化) |
| | | hasReqFields |
| | | }, () => { |
| | | if (config.setting.onload !== 'false' && valid) { // 初始化可加载 |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { mainSearch } = this.props |
| | | const { setting, search, hasReqFields, loadCustomApi } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | let requireFields = [] |
| | | |
| | | if (hasReqFields) { |
| | | requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | } |
| | | |
| | | if (requireFields.length > 0) { |
| | | let labels = requireFields.map(item => item.label) |
| | | labels = Array.from(new Set(labels)) |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['form.required.input'] + labels.join('、') + ' !', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未设置正式系统地址!', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | selectedData: [] |
| | | }) |
| | | |
| | | if (setting.interType === 'custom' && loadCustomApi) { |
| | | if (setting.execTime === 'once') { |
| | | this.setState({loadCustomApi: false}) |
| | | } |
| | | |
| | | this.loadOutResource(searches) |
| | | if (setting.execType === 'async') { |
| | | this.loadmaindata() |
| | | } |
| | | } else { |
| | | this.loadmaindata() |
| | | } |
| | | } |
| | | |
| | | loadOutResource = (searches) => { |
| | | const { setting } = this.state |
| | | |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, this.props.BID, this.props.menuType) |
| | | |
| | | if (setting.execType === 'sync') { |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.mk_ex_invoke === 'false') { |
| | | this.loadmaindata() |
| | | } else { |
| | | this.customOuterRequest(res) |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }, () => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | customOuterRequest = (result) => { |
| | | const { setting } = this.state |
| | | let url = '' |
| | | |
| | | if (window.GLOB.systemType === 'production') { |
| | | url = setting.proInterface |
| | | } else { |
| | | url = setting.interface |
| | | } |
| | | |
| | | let mkey = result.mk_api_key || '' |
| | | |
| | | delete result.mk_ex_invoke |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrCode |
| | | delete result.ErrMesg |
| | | delete result.mk_api_key |
| | | |
| | | let param = {} |
| | | |
| | | Object.keys(result).forEach(key => { |
| | | key = key.replace(/^mk_/ig, '') |
| | | param[key] = result[key] |
| | | }) |
| | | |
| | | Api.directRequest(url, setting.method, param).then(res => { |
| | | if (typeof(res) !== 'object' || Array.isArray(res)) { |
| | | let error = '未知的返回结果!' |
| | | |
| | | if (typeof(res) === 'string') { |
| | | error = res.replace(/'/ig, '"') |
| | | } |
| | | |
| | | let _result = { |
| | | mk_api_key: mkey, |
| | | $ErrCode: 'E', |
| | | $ErrMesg: error |
| | | } |
| | | |
| | | this.customCallbackRequest(_result) |
| | | } else { |
| | | res.mk_api_key = mkey |
| | | this.customCallbackRequest(res) |
| | | } |
| | | }, () => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | customCallbackRequest = (result) => { |
| | | const { setting } = this.state |
| | | let lines = [] |
| | | let pre = setting.callbackType === 'script' ? '@' : '' |
| | | |
| | | let errSql = '' |
| | | if (result.$ErrCode === 'E') { |
| | | errSql = ` |
| | | set @ErrorCode='E' |
| | | set @retmsg='${result.$ErrMesg}' |
| | | ` |
| | | delete result.$ErrCode |
| | | delete result.$ErrMesg |
| | | } |
| | | |
| | | let getDefaultSql = (obj, tb, bid, level) => { |
| | | let keys = [] |
| | | let vals = [] |
| | | let subObjs = [] |
| | | let id = Utils.getuuid() |
| | | |
| | | delete obj.$$key |
| | | |
| | | Object.keys(obj).forEach(key => { |
| | | let val = obj[key] |
| | | if (typeof(val) === 'object') { |
| | | if (Array.isArray(val)) { |
| | | val.forEach(item => { |
| | | if (typeof(item) !== 'object' || Array.isArray(item)) return |
| | | if (Object.keys(item).length > 0) { |
| | | item.$$key = tb + '_' + key |
| | | subObjs.push(item) |
| | | } |
| | | }) |
| | | } else if (Object.keys(val).length > 0) { |
| | | val.$$key = tb + '_' + key |
| | | subObjs.push(val) |
| | | } |
| | | } else if (val !== null && val !== undefined) { |
| | | keys.push(key) |
| | | vals.push(`'${val}'`) |
| | | } |
| | | }) |
| | | |
| | | lines.push({ |
| | | table: tb, |
| | | insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, |
| | | select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` |
| | | }) |
| | | |
| | | subObjs.forEach(item => { |
| | | getDefaultSql(item, item.$$key, id, level + 1) |
| | | }) |
| | | } |
| | | |
| | | getDefaultSql(result, setting.cbTable, '', 1) |
| | | |
| | | let lineMap = new Map() |
| | | lines.forEach(line => { |
| | | if (lineMap.has(line.table)) { |
| | | let _line = lineMap.get(line.table) |
| | | _line.selects.push(line.select) |
| | | lineMap.set(line.table, _line) |
| | | } else { |
| | | lineMap.set(line.table, { |
| | | table: line.table, |
| | | insert: line.insert, |
| | | selects: [line.select] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | let param = {} |
| | | |
| | | if (setting.callbackType === 'script') { // 使用自定义脚本 |
| | | let sql = [...lineMap.values()].map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) |
| | | |
| | | if (this.state.BID) { |
| | | param.BID = this.state.BID |
| | | } |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | } else { |
| | | let name = this.props.Tab ? (this.props.Tab.label || '') : '' |
| | | param.func = 's_ex_result_back' |
| | | param.s_ex_result = [...lineMap.values()].map((item, index) => ({ |
| | | MenuID: this.props.MenuID, |
| | | MenuName: name, |
| | | TableName: item.table, |
| | | LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), |
| | | Sort: index + 1 |
| | | })) |
| | | |
| | | if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { |
| | | let sql = [...lineMap.values()].map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | console.info(sql.replace(/\n\s{10}/ig, '\n')) |
| | | } |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | this.loadmaindata() |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }, () => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 子表数据加载 |
| | | */ |
| | |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | |
| | | if (requireFields.length > 0) { |
| | | let labels = requireFields.map(item => item.label) |
| | | labels = Array.from(new Set(labels)) |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['form.required.input'] + labels.join('、') + ' !', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | selectedData: [], |
| | | loading: true |
| | | }) |
| | | |
| | |
| | | pageIndex: 1, |
| | | search: searches |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | |
| | | pageSize: pagination.pageSize, |
| | | orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | }) |
| | | |
| | | _backCustomScript += ` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | |
| | | let sql = [...lineMap.values()].map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | |
| | | message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | return Promise.reject() |
| | | } |
| | | |
| | | if (trigger) { |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal } from 'antd' |
| | | import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal, Radio } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | { |
| | | title: 'SQL', |
| | | dataIndex: 'sql', |
| | | width: '73%', |
| | | width: '60%', |
| | | render: (text) => { |
| | | let title = text.match(/^\s*\/\*.+\*\//) |
| | | title = title && title[0] ? title[0] : '' |
| | |
| | | <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> |
| | | </div> |
| | | ) |
| | | } |
| | | }, |
| | | { |
| | | title: '执行位置', |
| | | dataIndex: 'position', |
| | | width: '13%', |
| | | render: (text, record) => { |
| | | if (record.position === 'front') { |
| | | return 'sql前' |
| | | } else { |
| | | return 'sql后' |
| | | } |
| | | } |
| | | }, |
| | | { |
| | |
| | | const { searches, scripts } = this.props |
| | | |
| | | let _usefulFields = [] |
| | | let scriptsColumns = fromJS(this.state.scriptsColumns).toJS() |
| | | |
| | | if (searches) { |
| | | searches.forEach(item => { |
| | |
| | | } |
| | | }) |
| | | _usefulFields = _usefulFields.join(', ') |
| | | scriptsColumns = scriptsColumns.filter(item => { |
| | | if (item.dataIndex === 'sql') { |
| | | item.width = '70%' |
| | | } |
| | | return item.dataIndex !== 'position' |
| | | }) |
| | | } else { |
| | | _usefulFields = null |
| | | } |
| | | |
| | | this.setState({ |
| | | usefulFields: _usefulFields, |
| | | scripts: fromJS(scripts).toJS() |
| | | scripts: fromJS(scripts).toJS(), |
| | | scriptsColumns |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | let values = { |
| | | uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), |
| | | sql: _sql |
| | | sql: _sql, |
| | | } |
| | | |
| | | if (this.props.form.getFieldValue('position')) { |
| | | values.position = this.props.form.getFieldValue('position') |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | |
| | | } |
| | | |
| | | handleEdit = (record) => { |
| | | const { usefulFields } = this.state |
| | | this.setState({ |
| | | editItem: record |
| | | }) |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql |
| | | }) |
| | | if (usefulFields) { |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql |
| | | }) |
| | | } else { |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql, |
| | | position: record.position || 'back' |
| | | }) |
| | | } |
| | | |
| | | this.scrolltop() |
| | | } |
| | |
| | | id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {!usefulFields ? <Col span={8} style={{whiteSpace: 'nowrap'}}> |
| | | <Form.Item style={{marginBottom: 0}} label="执行位置"> |
| | | {getFieldDecorator('position', { |
| | | initialValue: 'front' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="front">sql前</Radio> |
| | | <Radio value="back">sql后</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={10} className="quick-add"> |
| | | <Form.Item label={'快捷添加'} style={{marginBottom: 0}}> |
| | | <Select |
| | |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.selectScript} |
| | | > |
| | | {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100))`}>默认sql</Select.Option> : null} |
| | | {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100))\n/*@${setting.cbTable}_data table (mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))*/`}>默认sql</Select.Option> : null} |
| | | {systemScripts.map((option, i) => |
| | | <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> |
| | | )} |
| | |
| | | onChange={this.selectScript} |
| | | getPopupContainer={() => document.getElementById('verify-custom-callback-scripts')} |
| | | > |
| | | <Select.Option key="default" value={`declare @${btn.cbTable} table (mk_api_key nvarchar(100))`}>默认sql</Select.Option> |
| | | <Select.Option key="default" value={`declare @${btn.cbTable} table (mk_api_key nvarchar(100))\n/*@${btn.cbTable}_data table (mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))*/`}>默认sql</Select.Option> |
| | | {systemScripts.map((option, i) => |
| | | <Select.Option key={i} value={option.value}>{option.name}</Select.Option> |
| | | )} |
| | |
| | | |
| | | // 测试系统打印查询语句 |
| | | if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) { |
| | | console.info(sql) |
| | | console.info(sql.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | | } |
| | | |
| | |
| | | exec_type: 'y', |
| | | } |
| | | let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) |
| | | Select @ErrorCode='',@retmsg='' |
| | | ${errSql} |
| | | Select @ErrorCode='',@retmsg='' |
| | | ${errSql} |
| | | ` |
| | | let _backCustomScript = '' |
| | | let _backCustomScript = ` |
| | | ` |
| | | |
| | | setting.cbScripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | |
| | | if (script.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | _backCustomScript += ` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | |
| | | sql = _prevCustomScript + sql |
| | | sql = sql + _backCustomScript |
| | | |