From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 二月 2022 11:48:29 +0800 Subject: [PATCH] 2022-02-09 --- src/templates/zshare/createinterface/index.jsx | 78 ++++++++++++++++++++++++++------------- 1 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/templates/zshare/createinterface/index.jsx b/src/templates/zshare/createinterface/index.jsx index 0100d2f..275251a 100644 --- a/src/templates/zshare/createinterface/index.jsx +++ b/src/templates/zshare/createinterface/index.jsx @@ -7,6 +7,7 @@ import MutilForm from './mutilform' import Utils from '@/utils/utils.js' import options from '@/store/options.js' +import { updateForm } from '@/utils/utils-update.js' import Api from '@/api' import './index.scss' @@ -422,20 +423,14 @@ _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') { @@ -452,7 +447,7 @@ fieldlen: _fieldlen, key: cell.field, required: cell.required === 'true' ? 'required' : '', - writein: cell.required !== 'false', + writein: cell.writein !== 'false', value: cell.initval || '' } @@ -462,6 +457,8 @@ _fieldtype = 'datetime' } else if (_field.type === 'number') { _fieldtype = `decimal(18,${_fieldlen})` + } else if (_field.type === 'rate') { + _fieldtype = `decimal(18,2)` } _field.fieldtype = _fieldtype @@ -471,7 +468,7 @@ _field.value = '' } - return _field + formlist.push(_field) }) } resolve(true) @@ -668,6 +665,8 @@ _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}`) @@ -709,7 +708,8 @@ } _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@ ` @@ -719,10 +719,10 @@ ` } - 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) { @@ -954,8 +954,10 @@ receiptKeys.push('bid') } + let _insertsql = '' + let _updatesql = '' // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄� - if (_actionType === 'insert') { + if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { let keys = [] let values = [] @@ -963,7 +965,7 @@ if (item.writein === false) return keys.push(item.key.toLowerCase()) - values.push('@' + item.key + '@') + values.push('@' + item.key) }) if (!keys.includes(primaryKey.toLowerCase())) { @@ -990,10 +992,12 @@ keys = keys.join(',') values = values.join(',') - _sql += ` + _insertsql = ` /* 榛樿sql */ insert into ${btn.sql} (${keys}) select ${values};` - } else if (_actionType === 'update') { + } + + if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { let _form = [] let _arr = [] @@ -1001,7 +1005,7 @@ if (item.writein === false) return _arr.push(item.key.toLowerCase()) - _form.push(item.key + `=@${item.key}@`) + _form.push(item.key + `=@${item.key}`) }) if (!_arr.includes('modifydate')) { @@ -1009,6 +1013,9 @@ } if (!_arr.includes('modifyuserid')) { _form.push('modifyuserid=@userid@') + } + if (!_arr.includes('modifyuser')) { + _form.push('modifyuser=@username') } if (hasvoucher) { if (!_arr.includes('bvoucher')) { @@ -1033,13 +1040,32 @@ } _form = _form.join(',') - _sql += ` + _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 += ` /* 榛樿sql */ - update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKey}@;` + update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuser=@username,modifyuserid=@userid@ where ${primaryKey}=@${primaryKey}@;` } else if (_actionType === 'delete') { // 鐗╃悊鍒犻櫎 let _msg = '' @@ -1086,11 +1112,11 @@ 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} -- Gitblit v1.8.0