| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Button, notification, Modal } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import MutilForm from './mutilform' |
| | | import Utils from '@/utils/utils.js' |
| | | import { updateForm } from '@/utils/utils-update.js' |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | | |
| | | class CreateFunc extends Component { |
| | | class CreateInterface extends Component { |
| | | static propTypes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | trigger: PropTypes.func |
| | | } |
| | | |
| | |
| | | } |
| | | }) |
| | | |
| | | let _customScript = '' |
| | | config.setting.scripts && config.setting.scripts.forEach(script => { |
| | | if (script.status !== 'false') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | if (_customScript) { |
| | | _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg ='' |
| | | ${_customScript} |
| | | ` |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_get_para_for_out', |
| | | Menuid: menu.MenuID, |
| | |
| | | Ltextsearchparam: _search.join(' union all '), |
| | | AppendWhere: config.setting.queryType === 'query' ? searchText.join(' AND ') : '', |
| | | WhereType: config.setting.queryType === 'statistics' ? 'Statistics' : 'query', |
| | | custom_script: _customScript, |
| | | default_sql: config.setting.default || 'true', |
| | | OrderCol: config.setting.order |
| | | } |
| | | |
| | | param.Ltextsearchparam = Utils.formatOptions(param.Ltextsearchparam) |
| | | param.AppendWhere = Utils.formatOptions(param.AppendWhere) |
| | | param.custom_script = Utils.formatOptions(param.custom_script) |
| | | |
| | | this.setState({ |
| | | type: 'out', |
| | |
| | | required: true, |
| | | options: [{ |
| | | value: 'Y', |
| | | text: this.props.dict['header.form.true'] |
| | | text: '是' |
| | | }, { |
| | | value: 'N', |
| | | text: this.props.dict['header.form.false'] |
| | | text: '否' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | |
| | | required: true, |
| | | options: [{ |
| | | value: 'Y', |
| | | text: this.props.dict['header.form.true'] |
| | | text: '是' |
| | | }, { |
| | | value: 'N', |
| | | text: this.props.dict['header.form.false'] |
| | | text: '否' |
| | | }] |
| | | }] |
| | | }) |
| | |
| | | |
| | | if (type === 'out') { |
| | | this.FormRef.handleConfirm().then(res => { |
| | | |
| | | this.setState({ |
| | | type: '', |
| | | loading: true, |
| | |
| | | }) |
| | | } else { |
| | | this.FormRef.handleConfirm().then(res => { |
| | | |
| | | this.setState({ |
| | | type: '', |
| | | btn: null, |
| | |
| | | visible: false, |
| | | param: null |
| | | }) |
| | | |
| | | |
| | | if (res.TryType === 'Y' && res.array_name) { |
| | | res.Return = 'N' |
| | | } |
| | | |
| | | this.createBtnInterfaceExec({...param, ...res}, config, btn) |
| | | }) |
| | | } |
| | |
| | | param.Ltextgrid = _grid.join(',') |
| | | param.Ltextgridparam = _fields.join(' union all ') |
| | | param.Ltextgridparam = Utils.formatOptions(param.Ltextgridparam) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.Ltextgridparam, param.timestamp) |
| | | |
| | | delete param.hidden |
| | | |
| | | let _mainParam = JSON.parse(JSON.stringify(param)) |
| | | let _mainParam = fromJS(param).toJS() |
| | | |
| | | new Promise(resolve => { |
| | | // 获取云端存储过程信息 |
| | | Api.getLocalConfig(param).then(result => { |
| | | Api.genericInterface(param).then(result => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }).then(res => { |
| | | if (res === false) return res |
| | | |
| | | if (window.GLOB.mainSystemApi) { |
| | | _mainParam.rduri = window.GLOB.mainSystemApi |
| | | |
| | | return Api.getLocalConfig(_mainParam) |
| | | } |
| | | return 'success' |
| | | return Api.getCloudConfig(_mainParam) |
| | | }).then(result => { |
| | | if (result === false || result === 'success') return result |
| | | |
| | |
| | | * @description 触发创建写入接口(按钮) |
| | | */ |
| | | triggerInInterface = (btn, config, menu) => { |
| | | if (!['pop', 'exec', 'prompt'].includes(btn.OpenType) || btn.funcType || btn.intertype !== 'inner' || btn.innerFunc ) { |
| | | if (!['pop', 'exec', 'prompt'].includes(btn.OpenType) || btn.funcType || btn.intertype !== 'system') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '打开方式为 弹窗(表单)、提示框或直接执行,且使用系统函数时,才可以创建接口!', |
| | | message: '打开方式为 弹窗(表单)、提示框或直接执行,且接口类型为系统时,才可以创建接口!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | Ltextgridparam: '', |
| | | Ltexttableparam: '', |
| | | Ltext: '', |
| | | menuType: menu.type |
| | | menuType: menu.type, |
| | | systemType: window.GLOB.sysType |
| | | } |
| | | |
| | | this.setState({ |
| | | type: 'inner', |
| | | param: param, |
| | | visible: true, |
| | | btn: JSON.parse(JSON.stringify(btn)), |
| | | config: JSON.parse(JSON.stringify(config)), |
| | | btn: fromJS(btn).toJS(), |
| | | config: fromJS(config).toJS(), |
| | | formlist: [{ |
| | | type: 'text', |
| | | key: 'KunName', |
| | |
| | | type: 'radio', |
| | | key: 'TryType', |
| | | label: '事务', |
| | | initval: 'N', |
| | | initval: 'Y', |
| | | required: true, |
| | | options: [{ |
| | | value: 'Y', |
| | |
| | | key: 'Return', |
| | | label: '回执', |
| | | initval: 'N', |
| | | tooltip: '当选择需要事务,且填入了数组名称时,将不存在回执信息。', |
| | | required: true, |
| | | options: [{ |
| | | value: 'Y', |
| | |
| | | value: 'N', |
| | | text: '不需要' |
| | | }] |
| | | }, { |
| | | type: 'text', |
| | | key: 'array_name', |
| | | label: '数组名称', |
| | | initval: menu.menuNo + btn.uuid.substr(-4), |
| | | tooltip: '批量操作时,需要填写数组名称。', |
| | | required: false |
| | | }] |
| | | }) |
| | | } |
| | |
| | | |
| | | new Promise(resolve => { |
| | | if (btn.OpenType === 'pop') { |
| | | Api.getSystemConfig({ |
| | | Api.getCloudConfig({ |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: btn.uuid |
| | | }).then(result => { |
| | |
| | | _LongParam = '' |
| | | } |
| | | } |
| | | let fields = [] |
| | | |
| | | if (_LongParam && _LongParam.type === 'Modal') { |
| | | if (_LongParam.groups.length > 0) { |
| | | _LongParam.groups.forEach(group => { |
| | | fields = [...fields, ...group.sublist] |
| | | }) |
| | | } else { |
| | | fields = _LongParam.fields |
| | | } |
| | | _LongParam = updateForm(_LongParam) |
| | | } |
| | | |
| | | if (fields && fields.length > 0) { |
| | | formlist = fields.map(cell => { |
| | | if (_LongParam && _LongParam.fields.length > 0) { |
| | | _LongParam.fields.forEach(cell => { |
| | | if (!cell.field) return |
| | | let _fieldlen = cell.fieldlength || 50 |
| | | |
| | | if (cell.type === 'textarea' || cell.type === 'fileupload' || cell.type === 'multiselect') { |
| | |
| | | fieldlen: _fieldlen, |
| | | key: cell.field, |
| | | required: cell.required === 'true' ? 'required' : '', |
| | | writein: cell.writein !== 'false', |
| | | value: cell.initval || '' |
| | | } |
| | | |
| | |
| | | _fieldtype = 'datetime' |
| | | } else if (_field.type === 'number') { |
| | | _fieldtype = `decimal(18,${_fieldlen})` |
| | | } else if (_field.type === 'rate') { |
| | | _fieldtype = `decimal(18,2)` |
| | | } |
| | | |
| | | _field.fieldtype = _fieldtype |
| | |
| | | _field.value = '' |
| | | } |
| | | |
| | | return _field |
| | | formlist.push(_field) |
| | | }) |
| | | } |
| | | resolve(true) |
| | |
| | | param.Ltexttableparam.unshift(`select 'BID' as searchfield,'BID' as label,'0' as Sort,'nvarchar(50)' as fieldtype,'required' as requiredtype,'' as defaultvalue`) |
| | | } |
| | | |
| | | if (btn.Ot !== 'notRequired' && !_keys.includes(config.setting.primaryKey.toLowerCase())) { |
| | | param.Ltexttableparam.unshift(`select '${config.setting.primaryKey}' as searchfield,'${config.setting.primaryKey}' as label,'1' as Sort,'nvarchar(50)' as fieldtype,'required' as requiredtype,'' as defaultvalue`) |
| | | if (btn.Ot !== 'notRequired' && !_keys.includes('id')) { |
| | | param.Ltexttableparam.unshift(`select 'ID' as searchfield,'ID' as label,'1' as Sort,'nvarchar(50)' as fieldtype,'required' as requiredtype,'' as defaultvalue`) |
| | | } |
| | | |
| | | param.Ltexttableparam = param.Ltexttableparam.join(' union all ') |
| | |
| | | param.Ltextgridparam = Utils.formatOptions(param.Ltextgridparam) |
| | | param.Ltexttableparam = Utils.formatOptions(param.Ltexttableparam) |
| | | |
| | | param.Ltext = this.getSysDefaultSql(btn, config, formlist, receipt, BID) |
| | | param.Ltext = this.getInterfaceSysDefaultSql(btn, config, formlist, receipt, BID) |
| | | param.Ltext = Utils.formatOptions(param.Ltext) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.Ltext, param.timestamp) |
| | | |
| | | delete param.menuType |
| | | |
| | | _mainParam = JSON.parse(JSON.stringify(param)) |
| | | _mainParam = fromJS(param).toJS() |
| | | |
| | | return Api.getLocalConfig(param) |
| | | return Api.genericInterface(param) |
| | | }).then(res => { |
| | | if (res === false) return res |
| | | |
| | |
| | | }).then(res => { |
| | | if (res === false) return res |
| | | |
| | | if (window.GLOB.mainSystemApi) { |
| | | _mainParam.rduri = window.GLOB.mainSystemApi |
| | | |
| | | return Api.getLocalConfig(_mainParam) |
| | | } |
| | | return 'success' |
| | | return Api.getCloudConfig(_mainParam) |
| | | }).then(res => { |
| | | if (res === false || res === 'success') return res |
| | | if (res === false) return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | |
| | | }) |
| | | } |
| | | |
| | | getSysDefaultSql = (btn, config, formlist, receipt, BID) => { |
| | | getInterfaceSysDefaultSql = (btn, config, formlist, receipt, BID) => { |
| | | let setting = config.setting |
| | | let primaryKey = setting.primaryKey || 'id' |
| | | let columns = config.columns.filter(col => !!col.field) |
| | | let verify = btn.verify || {} |
| | | |
| | | let _initCustomScript = '' // 初始化脚本 |
| | | let _prevCustomScript = '' // 默认sql前执行脚本 |
| | | let _backCustomScript = '' // 默认sql后执行脚本 |
| | | |
| | | verify.scripts && verify.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | if (item.position === 'init') { |
| | | _initCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${item.sql} |
| | | ` |
| | | } else if (item.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${item.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${item.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | // 需要声明的变量集 |
| | | let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode'] |
| | | |
| | | // 系统变量声明与设置初始值 |
| | | let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50) |
| | | ` |
| | | let _sql = '' |
| | | |
| | | let _initvars = [] // 已赋值字段集 |
| | | let _initfields = [] |
| | |
| | | _type = 'datetime' |
| | | } else if (form.type === 'number') { |
| | | _type = `decimal(18,${form.fieldlen})` |
| | | } else if (form.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | } |
| | | |
| | | _declarefields.push(`@${_key} ${_type}`) |
| | |
| | | // 变量声明 |
| | | _declarefields = _declarefields.join(',') |
| | | if (_declarefields) { |
| | | _sql += `,${_declarefields} |
| | | ` |
| | | _declarefields = ',' + _declarefields |
| | | } |
| | | _sql = `/* 系统生成 */ |
| | | Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} |
| | | |
| | | select @UserName='',@FullName='' |
| | | select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ |
| | | ` |
| | | |
| | | // 变量赋值 |
| | | if (_initfields.length > 0) { |
| | |
| | | ` |
| | | } |
| | | |
| | | if (_initcolumnfields.length > 0) { |
| | | _sql += `select ${_initcolumnfields.join(',')} from ${setting.dataresource} where ${primaryKey}=@ID@ |
| | | ` |
| | | } |
| | | // if (_initcolumnfields.length > 0) { |
| | | // _sql += `select ${_initcolumnfields.join(',')} from (${setting.dataresource})tb where ${primaryKey}=@ID@ |
| | | // ` |
| | | // } |
| | | |
| | | // 去除禁用的验证 |
| | | if (verify.contrasts) { |
| | |
| | | } |
| | | |
| | | // 初始化凭证及用户信息字段 |
| | | _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='' |
| | | _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='', @BillCode='', @ModularDetailCode='' |
| | | ` |
| | | |
| | | if (_initCustomScript) { |
| | | _sql += _initCustomScript |
| | | } |
| | | |
| | | // 启用账期验证 |
| | | if (verify.accountdate === 'true') { |
| | | _sql += `exec s_FIBVoucherDateCheck @ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT |
| | | _sql += ` |
| | | /* 账期验证 */ |
| | | exec s_FIBVoucherDateCheck @ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT |
| | | if @ErrorCode!='' |
| | | GOTO aaa |
| | | ` |
| | | } |
| | | |
| | | // 失效验证,添加数据时不用 |
| | | if (btn.sqlType !== 'insert' && verify.invalid === 'true') { |
| | | if (btn.sqlType !== 'insert' && verify.invalid === 'true' && setting.dataresource) { |
| | | let datasource = setting.dataresource |
| | | if (/\s/.test(datasource)) { // 拼接别名 |
| | | if (/\s/.test(datasource) && !/tb$/.test(datasource)) { // 拼接别名 |
| | | datasource = '(' + datasource + ') tb' |
| | | } |
| | | |
| | | _sql += `select @tbid='', @ErrorCode='',@retmsg='' |
| | | // 自定义脚本 |
| | | if (setting.interType === 'system' && setting.scripts && setting.scripts.length > 0) { |
| | | let _customScript = '' |
| | | setting.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | _customScript += ` |
| | | ${item.sql} |
| | | ` |
| | | }) |
| | | _sql += ` |
| | | /* 数据源自定义脚本,请注意变量定义是否重复 */ |
| | | ${_customScript} |
| | | ` |
| | | } |
| | | |
| | | _sql += ` |
| | | /* 失效验证 */ |
| | | select @tbid='', @ErrorCode='',@retmsg='' |
| | | select @tbid=${primaryKey} from ${datasource} where ${primaryKey} =@${primaryKey}@ |
| | | If @tbid='' |
| | | Begin |
| | |
| | | // 比较验证 |
| | | if (verify.contrasts && verify.contrasts.length > 0) { |
| | | verify.contrasts.forEach(item => { |
| | | _sql += `If ${item.frontfield} ${item.operator} ${item.backfield} |
| | | _sql += ` |
| | | /* 比较验证 */ |
| | | If ${item.frontfield} ${item.operator} ${item.backfield} |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | } |
| | | |
| | | // 自定义验证 |
| | | if (verify.customverifys && verify.customverifys.length > 0) { |
| | | verify.customverifys.forEach(item => { |
| | | _sql += ` |
| | | /* 自定义验证 */ |
| | | select @tbid='', @ErrorCode='',@retmsg='' |
| | | select top 1 @tbid='X' from (${item.sql}) a |
| | | If @tbid ${item.result === 'true' ? '!=' : '='}'' |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | } |
| | | |
| | | // 单号生成,使用上级id(BID)或列表数据,声明变量(检验) |
| | | if (verify.billcodes && verify.billcodes.length > 0) { |
| | | verify.billcodes.forEach(item => { |
| | | let _ModularDetailCode = '' |
| | | let _lpline = '' |
| | | if (item.TypeCharOne === 'Lp') { |
| | | if (item.linkField === 'BID' && BID) { // 替换bid |
| | | _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)` |
| | | } else { |
| | | _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField}@,48)` |
| | | } |
| | | _ModularDetailCode = '@ModularDetailCode' |
| | | } else if (item.TypeCharOne === 'BN') { |
| | | |
| | | _ModularDetailCode = `'${item.TypeCharOne + '@' + item.linkField}@'` |
| | | } else { |
| | | _ModularDetailCode = `'${item.ModularDetailCode}'` |
| | | } |
| | | |
| | | let _declare = '' |
| | | let _key = item.field.toLowerCase() |
| | | |
| | | if (!_vars.includes(_key)) { |
| | | _declare = `Declare @${_key} nvarchar(50)` |
| | | _vars.push(_key) |
| | | } |
| | | |
| | | _sql += ` |
| | | /* 单号生成 */ |
| | | ${_declare} |
| | | select @BillCode='', @${_key}='', @ModularDetailCode='' |
| | | ${_lpline} |
| | | exec s_get_BillCode |
| | | @ModularDetailCode=${_ModularDetailCode}, |
| | | @Type=${item.Type}, |
| | | @TypeCharOne='${item.TypeCharOne}', |
| | | @TypeCharTwo ='${item.TypeCharTwo}', |
| | | @BillCode =@BillCode output, |
| | | @ErrorCode =@ErrorCode output, |
| | | @retmsg=@retmsg output |
| | | if @ErrorCode!='' |
| | | goto aaa |
| | | set @${_key}=@BillCode |
| | | ` |
| | | }) |
| | | } |
| | |
| | | ` |
| | | }) |
| | | } |
| | | |
| | | // 自定义验证 |
| | | if (verify.customverifys && verify.customverifys.length > 0) { |
| | | verify.customverifys.forEach(item => { |
| | | _sql += `select @tbid='', @ErrorCode='',@retmsg='' |
| | | select top 1 @tbid='X' from (${item.sql}) a |
| | | If @tbid ${item.result === 'true' ? '!=' : '='}'' |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | } |
| | | |
| | | // 单号生成,使用上级id(BID)或列表数据,声明变量(检验) |
| | | if (verify.billcodes && verify.billcodes.length > 0) { |
| | | verify.billcodes.forEach(item => { |
| | | let _ModularDetailCode = '' |
| | | let _lpline = '' |
| | | if (item.TypeCharOne === 'Lp') { |
| | | if (item.linkField === 'BID' && BID) { // 替换bid |
| | | _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@BID@,48)` |
| | | } else { |
| | | _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@${item.linkField}@,48)` |
| | | } |
| | | _ModularDetailCode = '@ModularDetailCode' |
| | | } else if (item.TypeCharOne === 'BN') { |
| | | |
| | | _ModularDetailCode = `'${item.TypeCharOne + '@' + item.linkField}@'` |
| | | } else { |
| | | _ModularDetailCode = `'${item.ModularDetailCode}'` |
| | | } |
| | | |
| | | let _declare = '' |
| | | let _key = item.field.toLowerCase() |
| | | |
| | | if (!_vars.includes(_key)) { |
| | | _declare = `Declare @${_key} nvarchar(50)` |
| | | _vars.push(_key) |
| | | } |
| | | |
| | | _sql += `${_declare} |
| | | select @BillCode='', @${_key}='', @ModularDetailCode='' |
| | | ${_lpline} |
| | | exec s_get_BillCode |
| | | @ModularDetailCode=${_ModularDetailCode}, |
| | | @Type=${item.Type}, |
| | | @TypeCharOne='${item.TypeCharOne}', |
| | | @TypeCharTwo ='${item.TypeCharTwo}', |
| | | @BillCode =@BillCode output, |
| | | @ErrorCode =@ErrorCode output, |
| | | @retmsg=@retmsg output |
| | | if @ErrorCode!='' |
| | | goto aaa |
| | | set @${_key}=@BillCode |
| | | ` |
| | | }) |
| | | } |
| | | |
| | | let hasvoucher = false |
| | | |
| | |
| | | ` |
| | | } |
| | | |
| | | if (_prevCustomScript) { |
| | | _sql += _prevCustomScript |
| | | } |
| | | |
| | | let _actionType = null |
| | | let receiptKeys = [] // 回执字段 |
| | | |
| | |
| | | receiptKeys.push('bid') |
| | | } |
| | | |
| | | // 用于取用户信息 |
| | | let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ |
| | | ` |
| | | |
| | | let _insertsql = '' |
| | | let _updatesql = '' |
| | | // 添加、修改、逻辑删除、物理删除 |
| | | if (_actionType === 'insert') { |
| | | if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { |
| | | let keys = [] |
| | | let values = [] |
| | | |
| | | formlist.forEach(item => { |
| | | if (item.writein === false) return |
| | | |
| | | keys.push(item.key.toLowerCase()) |
| | | values.push('@' + item.key + '@') |
| | | values.push('@' + item.key) |
| | | }) |
| | | |
| | | if (!keys.includes(primaryKey.toLowerCase())) { |
| | |
| | | |
| | | keys = keys.join(',') |
| | | values = values.join(',') |
| | | _sql += _user |
| | | _sql += `insert into ${btn.sql} (${keys}) select ${values};` |
| | | } else if (_actionType === 'update') { |
| | | _insertsql = ` |
| | | /* 默认sql */ |
| | | insert into ${btn.sql} (${keys}) select ${values};` |
| | | } |
| | | |
| | | if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { |
| | | let _form = [] |
| | | let _arr = [] |
| | | |
| | | formlist.forEach(item => { |
| | | _arr.push(item.key.toLowerCase()) |
| | | if (item.writein === false) return |
| | | |
| | | _form.push(item.key + `=@${item.key}@`) |
| | | _arr.push(item.key.toLowerCase()) |
| | | _form.push(item.key + `=@${item.key}`) |
| | | }) |
| | | |
| | | if (!_arr.includes('modifydate')) { |
| | |
| | | } |
| | | if (!_arr.includes('modifyuserid')) { |
| | | _form.push('modifyuserid=@userid@') |
| | | } |
| | | if (!_arr.includes('modifyuser')) { |
| | | _form.push('modifyuser=@username') |
| | | } |
| | | if (hasvoucher) { |
| | | if (!_arr.includes('bvoucher')) { |
| | |
| | | } |
| | | |
| | | _form = _form.join(',') |
| | | _sql += `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKey}@;` |
| | | _updatesql = ` |
| | | /* 默认sql */ |
| | | update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKey}@;` |
| | | } |
| | | |
| | | if (_actionType === 'insert') { |
| | | _sql += _insertsql |
| | | } else if (_actionType === 'update' || _actionType === 'audit') { |
| | | _sql += _updatesql |
| | | } else if (_actionType === 'insertOrUpdate') { |
| | | _sql += ` |
| | | select @tbid='' |
| | | select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@ |
| | | if @tbid='' |
| | | begin |
| | | ${_insertsql} |
| | | end |
| | | else |
| | | begin |
| | | ${_updatesql} |
| | | end |
| | | ` |
| | | } else if (_actionType === 'LogicDelete') { // 逻辑删除 |
| | | _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKey}@;` |
| | | _sql += ` |
| | | /* 默认sql */ |
| | | update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@ where ${primaryKey}=@${primaryKey}@;` |
| | | |
| | | } else if (_actionType === 'delete') { // 物理删除 |
| | | let _msg = '' |
| | |
| | | } |
| | | }) |
| | | } |
| | | _sql += _user |
| | | _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@${primaryKey}@,@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKey}@;` |
| | | _sql += ` |
| | | /* 默认sql */ |
| | | insert into snote (remark,createuserid,CreateUser,CreateStaff) select '删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@${primaryKey}@,@userid@,@username,@fullname |
| | | delete ${btn.sql} where ${primaryKey}=@${primaryKey}@;` |
| | | } |
| | | |
| | | // 拼接自定义脚本 |
| | | if (verify.scripts && verify.scripts.length > 0) { |
| | | let _scripts = '' |
| | | verify.scripts.forEach(item => { |
| | | _scripts += ` |
| | | ${item.sql}` |
| | | }) |
| | | _sql += `${_scripts}` |
| | | if (_backCustomScript) { |
| | | _sql += _backCustomScript |
| | | } |
| | | |
| | | let _ltext = '' |
| | |
| | | onClick={this.props.trigger} |
| | | loading={this.state.loading} |
| | | > |
| | | {this.props.dict['header.menu.interface.create']} |
| | | 创建接口 |
| | | </Button> |
| | | {/* 接口选项 */} |
| | | <Modal |
| | | title={this.props.dict['header.menu.interface.create']} |
| | | title="创建接口" |
| | | visible={this.state.visible} |
| | | width={500} |
| | | maskClosable={false} |
| | |
| | | destroyOnClose |
| | | > |
| | | <MutilForm |
| | | dict={this.props.dict} |
| | | formlist={this.state.formlist} |
| | | wrappedComponentRef={(inst) => this.FormRef = inst} |
| | | /> |
| | |
| | | } |
| | | } |
| | | |
| | | export default CreateFunc |
| | | export default CreateInterface |