| | |
| | | loading: false, |
| | | } |
| | | |
| | | exec = (innerFunc, newLText, DelText) => { |
| | | exec = (menu, config) => { |
| | | let _grid = [] |
| | | let _fields = [] |
| | | let _index = 1 |
| | | |
| | | config.columns.forEach(item => { |
| | | if (!item.field || item.type === 'colspan') return |
| | | |
| | | let _type = `nvarchar(${item.fieldlength || 50})` |
| | | |
| | | if (item.type === 'number') { |
| | | _type = `decimal(18,${item.decimal ? item.decimal : 0})` |
| | | } else if (item.type === 'picture' || item.type === 'textarea') { |
| | | _type = `nvarchar(${item.fieldlength || 512})` |
| | | } |
| | | |
| | | _grid.push(item.field) |
| | | _fields.push(`select '${item.field}' as gridfield,'${_type}' as fieldtype,'${item.label}' as label,'${_index}' as Sort`) |
| | | _index++ |
| | | }) |
| | | |
| | | let _search = [] |
| | | _index = 1 |
| | | |
| | | if (menu.type !== 'main') { |
| | | if (config.setting.dataresource && /@BID@/ig.test(config.setting.dataresource)) { |
| | | _search.push(`select 'BID' as searchfield,'BID' as label,'0' as Sort,'' as defaultvalue,'required' as DefaultType`) |
| | | _index++ |
| | | } else { |
| | | _search.push(`select 'BID' as searchfield,'BID' as label,'0' as Sort,'' as defaultvalue,'' as DefaultType`) |
| | | _index++ |
| | | } |
| | | } |
| | | |
| | | let _fieldMap = new Map() |
| | | |
| | | config.search.forEach(item => { |
| | | let fields = [item.field] |
| | | let _val = item.initval |
| | | |
| | | if (item.type === 'text') { |
| | | fields = item.field.split(',') |
| | | } |
| | | if (/^date/ig.test(item.type)) { |
| | | _val = '' |
| | | } |
| | | |
| | | if (item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { |
| | | fields = [item.field, item.field] |
| | | } |
| | | |
| | | fields.forEach(cell => { |
| | | let _field = cell |
| | | if (_fieldMap.has(cell)) { |
| | | _field = _field + '1' |
| | | } |
| | | |
| | | _fieldMap.set(cell, true) |
| | | |
| | | _search.push(`select '${_field}' as searchfield,'${item.label}' as label,'${_index}' as Sort,'${_val}' as defaultvalue,'${item.required === 'true' ? 'required' : ''}' as DefaultType`) |
| | | _index++ |
| | | }) |
| | | }) |
| | | |
| | | let searchText = [] |
| | | _fieldMap = new Map() |
| | | |
| | | config.search.forEach((item, i) => { |
| | | if (item.type === 'text') { |
| | | let str = item.match === '=' ? '' : '\'%\'' |
| | | let _fields_ = item.field.split(',').map(field => { // 综合搜索,所字段拼接 |
| | | |
| | | return field + ' ' + item.match + ` ${str ? str + '+' : ''}@` + field + `@${str ? '+' + str : ''}` |
| | | }) |
| | | |
| | | if (_fields_.length === 1) { |
| | | searchText.push(_fields_[0]) |
| | | } else { |
| | | searchText.push('(' + _fields_.join(' OR ') + ')') |
| | | } |
| | | } else if (item.type === 'select') { |
| | | |
| | | searchText.push(item.field + ' ' + item.match + ' @' + item.field + '@') |
| | | } else if (item.type === 'multiselect') { |
| | | |
| | | searchText.push(`@${item.field}@ ` + item.match + ' \'%\'+' + item.field + '+\'%\'') |
| | | } else if (item.type === 'date') { |
| | | let _field = item.field |
| | | if (_fieldMap.has(item.field)) { |
| | | _field = _field + '1' |
| | | } |
| | | |
| | | _fieldMap.set(item.field, true) |
| | | |
| | | searchText.push(item.field + ' ' + item.match + ' @' + _field + '@') |
| | | } else if (item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { |
| | | |
| | | searchText.push('(' + item.field + ' >= @' + item.field + '@ AND ' + item.field + ' < @' + item.field + '1@)') |
| | | } else { |
| | | searchText.push(item.field + ' ' + item.match + ' @' + item.field + '@') |
| | | } |
| | | }) |
| | | |
| | | let param = { |
| | | func: 's_get_para_for_out', |
| | | Menuid: menu.MenuID, |
| | | Menuname: menu.menuName, |
| | | Menuno: menu.menuNo, |
| | | Ltextgridparam: _fields.join(' union all '), |
| | | Ltextsearchparam: _search.join(' union all '), |
| | | AppendWhere: config.setting.queryType === 'query' ? searchText.join(' AND ') : '', |
| | | Ltextgrid: _grid.join(','), |
| | | WhereType: config.setting.queryType === 'statistics' ? 'Statistics' : 'query', |
| | | OrderCol: config.setting.order |
| | | } |
| | | |
| | | param.Ltextsearchparam = Utils.formatOptions(param.Ltextsearchparam) |
| | | param.AppendWhere = Utils.formatOptions(param.AppendWhere) |
| | | |
| | | param.Ltextgridparam = Utils.formatOptions(param.Ltextgridparam) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.Ltextgridparam, param.timestamp) |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | return new Promise(resolve => { |
| | | this.createExec(resolve, innerFunc, newLText, DelText) |
| | | this.createExec(resolve, param) |
| | | }) |
| | | } |
| | | |
| | | createExec = (_resolve, innerFunc, newLText, DelText) => { |
| | | let isExist = false // 存储过程是否存在 |
| | | let cloudText = '' // 云端存储结果 |
| | | let localfunc = '' // 本地存储过程 |
| | | createExec = (_resolve, param) => { |
| | | let _mainParam = JSON.parse(JSON.stringify(param)) |
| | | |
| | | new Promise(resolve => { |
| | | // 获取云端存储过程信息 |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', |
| | | TVPName: innerFunc |
| | | }).then(result => { |
| | | Api.getLocalConfig(param).then(result => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | cloudText = result.TVPText |
| | | resolve(true) |
| | | } |
| | | }) |
| | | }).then(res => { |
| | | if (!res) return res |
| | | // 获取本地存储过程信息 |
| | | if (res === false) return res |
| | | |
| | | let _param = { |
| | | func: 's_get_userproc', |
| | | LText: innerFunc |
| | | if (window.GLOB.mainSystemApi) { |
| | | _mainParam.rduri = window.GLOB.mainSystemApi |
| | | |
| | | return Api.getLocalConfig(_mainParam) |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 处理本地结果 |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | isExist = true |
| | | localfunc = Utils.formatOptions(res.Ltext) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 根据本地及远端结果判断执行动作 |
| | | if ((newLText === localfunc) && (newLText === cloudText)) { |
| | | return 'drop' |
| | | } else if (!localfunc || (cloudText === localfunc)) { |
| | | // 本地存储过程不存在,或云端和本地存储过程一致时,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: innerFunc, |
| | | TVPText: localfunc, |
| | | TypeName: 'P' |
| | | return 'success' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | if (!res || res === 'drop') return res |
| | | if (result === false || result === 'success') return result |
| | | |
| | | // 处理云端更新结果 |
| | | if (!res.status) { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExist) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | if (!res || res === 'create') return res |
| | | |
| | | // 删除存储过程 |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程标志 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | if (!res || res === 'create') return res |
| | | |
| | | // 删除结果处理 |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return true |
| | | return 'success' |
| | | } |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 新建存储过程 |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 处理新建结果 |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | // 结果处理 |
| | | if (res === false) { |
| | | _resolve('error') |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 结果处理 |
| | | if (!res) { |
| | | _resolve('error') |
| | | } else { |
| | | _resolve('success') |
| | | } |
| | | |
| | |
| | | |
| | | return ( |
| | | <Button |
| | | className="mk-btn mk-purple" |
| | | className="mk-btn mk-green" |
| | | onClick={this.props.trigger} |
| | | loading={this.state.loading} |
| | | > |
| | | {this.props.dict['header.menu.func.create']} |
| | | {this.props.dict['header.menu.interface.create']} |
| | | </Button> |
| | | ) |
| | | } |