From 375fde866b184db1f63073c47b14a31c2114a4d1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 08 一月 2024 14:50:39 +0800 Subject: [PATCH] 2024-01-08 --- src/templates/zshare/verifycard/index.jsx | 695 ++++++++++++++++++++++++++++----------------------------- 1 files changed, 341 insertions(+), 354 deletions(-) diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index a74034f..606f277 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -30,7 +30,6 @@ class VerifyCard extends Component { static propTpyes = { - btnTab: PropTypes.any, // 琛ㄥ崟鏍囩椤碉紙鎸夐挳锛夊弬鏁� config: PropTypes.any, // 琛ㄥ崟鏍囩椤靛弬鏁� card: PropTypes.object, // 鎸夐挳淇℃伅 columns: PropTypes.array @@ -598,7 +597,7 @@ } UNSAFE_componentWillMount() { - const { columns, config, card, btnTab } = this.props + const { columns, config, card } = this.props const { appType } = this.state let _verify = fromJS(card.verify || {}).toJS() @@ -703,105 +702,131 @@ oriVerify: fromJS(_verify).toJS() }) - if (card.intertype === 'inner') { - return + if (card.intertype === 'inner') return + + let _fields = [] + if (card.OpenType === 'form') { + _fields.push({ + field: card.field, + label: card.label, + type: 'text' + }) + } else if (card.modal && (card.OpenType === 'pop' || !card.OpenType)) { + _fields = card.modal.fields || [] } - new Promise(resolve => { - let _fields = [] - if (card.OpenType === 'form') { - _fields.push({ - field: card.field, - label: card.label, - type: 'text' - }) - resolve(_fields) - } else if (card.modal && (card.OpenType === 'pop' || !card.OpenType)) { - _fields = card.modal.fields || [] - resolve(_fields) - // } else if (card.OpenType === 'pop') { - // Api.getCloudConfig({ - // func: 'sPC_Get_LongParam', - // MenuID: card.uuid - // }).then(res => { - // if (res.status) { - // let _LongParam = '' - // if (res.LongParam) { - // try { - // _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - // } catch (e) { - // console.warn('Parse Failure') - // _LongParam = '' - // } - // } - - // if (!_LongParam) { - // message.warning('鏈幏鍙栧埌琛ㄥ崟淇℃伅锛岄儴鍒嗛獙璇佸皢鏃犳硶璁剧疆锛�') - // } else { - // _LongParam = updateForm(_LongParam) - // _fields = _LongParam.fields || [] - // } - // } else { - // notification.warning({ - // top: 92, - // message: res.message, - // duration: 5 - // }) - // } - // resolve(_fields) - // }) + let _usefulfields = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode', 'tbid', 'mk_deleted'] + let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@RoleID nvarchar(512)', '@mk_departmentcode nvarchar(512)', '@mk_organization nvarchar(512)', '@mk_user_type nvarchar(20)', '@mk_nation nvarchar(50)', '@mk_province nvarchar(50)', '@mk_city nvarchar(50)', '@mk_district nvarchar(50)', '@mk_address nvarchar(100)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)', '@bid nvarchar(50)', '@tbid nvarchar(50)', '@mk_deleted int'] + let _select = ['@UserName=\'\'', '@FullName=\'\'', '@RoleID=\'\'', '@mk_departmentcode=\'\'', '@mk_organization=\'\'', '@mk_user_type=\'\'', '@mk_nation=\'\'', '@mk_province=\'\'', '@mk_city=\'\'', '@mk_district=\'\'', '@mk_address=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'', '@bid=\'\'', '@mk_deleted=1'] + let fieldArr = _usefulfields.map(_f => _f.toLowerCase()) + let hasBid = false + + _usefulfields = [] + + fieldArr.push('bid') + + let verIndex = _fields.findIndex(item => item.type === 'vercode') + if (verIndex > -1) { + _fields = fromJS(_fields).toJS() + _fields.splice(verIndex, 0, { + type: 'text', + fieldlength: 50, + writein: 'false', + field: 'mk_timestamp' + }, { + type: 'text', + fieldlength: 50, + writein: 'false', + field: 'mk_send_type' + }, { + type: 'text', + fieldlength: 50, + writein: 'false', + field: 'mk_n_id' + }) + } + + _fields = _fields.filter(_f => _f.field) + _fields.forEach(_f => { + if (_f.field.toLowerCase() === 'bid') { + hasBid = true + } + + if (fieldArr.includes(_f.field.toLowerCase())) return + + fieldArr.push(_f.field.toLowerCase()) + + _usefulfields.push(_f.field) + + let _fieldlen = _f.fieldlength || 50 + + if (_f.type === 'number') { + _fieldlen = _f.decimal ? _f.decimal : 0 + } + + if (_fieldlen > 4000) { + _fieldlen = 'max' + } + + let _type = `nvarchar(${_fieldlen})` + + if (_f.type.match(/date/ig)) { + _type = 'datetime' + _select.push(`@${_f.field}='1949-10-01'`) + } else if (_f.type === 'number') { + _type = `decimal(18,${_fieldlen})` + _select.push(`@${_f.field}=0`) + } else if (_f.declare === 'decimal') { + _type = `decimal(18,${_f.decimal || 0})` + _select.push(`@${_f.field}=0`) + } else if (_f.type === 'rate') { + _type = `decimal(18,2)` + _select.push(`@${_f.field}=0`) } else { - resolve(_fields) - } - }).then(_fields => { - let _usefulfields = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode', 'tbid', 'mk_deleted'] - let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@RoleID nvarchar(512)', '@mk_departmentcode nvarchar(512)', '@mk_organization nvarchar(512)', '@mk_user_type nvarchar(20)', '@mk_nation nvarchar(50)', '@mk_province nvarchar(50)', '@mk_city nvarchar(50)', '@mk_district nvarchar(50)', '@mk_address nvarchar(100)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)', '@bid nvarchar(50)', '@tbid nvarchar(50)', '@mk_deleted int'] - let _select = ['@UserName=\'\'', '@FullName=\'\'', '@RoleID=\'\'', '@mk_departmentcode=\'\'', '@mk_organization=\'\'', '@mk_user_type=\'\'', '@mk_nation=\'\'', '@mk_province=\'\'', '@mk_city=\'\'', '@mk_district=\'\'', '@mk_address=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'', '@bid=\'\'', '@mk_deleted=1'] - let fieldArr = _usefulfields.map(_f => _f.toLowerCase()) - let hasBid = false - - _usefulfields = [] - - fieldArr.push('bid') - - let verIndex = _fields.findIndex(item => item.type === 'vercode') - if (verIndex > -1) { - _fields = fromJS(_fields).toJS() - _fields.splice(verIndex, 0, { - type: 'text', - fieldlength: 50, - writein: 'false', - field: 'mk_timestamp' - }, { - type: 'text', - fieldlength: 50, - writein: 'false', - field: 'mk_send_type' - }, { - type: 'text', - fieldlength: 50, - writein: 'false', - field: 'mk_n_id' - }) + _select.push(`@${_f.field}=''`) } - _fields = _fields.filter(_f => _f.field) - _fields.forEach(_f => { - if (_f.field.toLowerCase() === 'bid') { - hasBid = true + _declare.push(`@${_f.field} ${_type}`) + }) + + let uniqueFields = fromJS(_fields).toJS() + + if (!hasBid) { // 鍞竴鎬ч獙璇佹坊鍔燘ID + uniqueFields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) + _fields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) + } + + let unionFields = fromJS(_fields).toJS() + let formArr = _fields.map(_f => _f.field.toLowerCase()) + + if (card.Ot !== 'notRequired' && columns) { + columns.forEach(_f => { + if (!_f.field) return + + let key = _f.field.toLowerCase() + + if (!formArr.includes(key)) { + formArr.push(key) + unionFields.push(_f) } - if (fieldArr.includes(_f.field.toLowerCase())) return + if (fieldArr.includes(key)) return - fieldArr.push(_f.field.toLowerCase()) - + fieldArr.push(key) _usefulfields.push(_f.field) - let _fieldlen = _f.fieldlength || 50 + if (_f.datatype) { // 鑷畾涔夊瓧娈� + if (/decimal/ig.test(_f.datatype)) { + _select.push(`@${_f.field}=0`) + } else { + _select.push(`@${_f.field}=''`) + } - if (_f.type === 'number') { - _fieldlen = _f.decimal ? _f.decimal : 0 + _declare.push(`@${_f.field} ${_f.datatype}`) + return } + + let _fieldlen = _f.fieldlength || 50 if (_fieldlen > 4000) { _fieldlen = 'max' @@ -809,17 +834,13 @@ let _type = `nvarchar(${_fieldlen})` - if (_f.type.match(/date/ig)) { - _type = 'datetime' - _select.push(`@${_f.field}='1949-10-01'`) - } else if (_f.type === 'number') { - _type = `decimal(18,${_fieldlen})` - _select.push(`@${_f.field}=0`) - } else if (_f.declare === 'decimal') { - _type = `decimal(18,${_f.decimal || 0})` - _select.push(`@${_f.field}=0`) - } else if (_f.type === 'rate') { - _type = `decimal(18,2)` + if (_f.type === 'number') { + _type = `decimal(18,${_f.decimal ? _f.decimal : 0})` + } else if (_f.type === 'picture' || _f.type === 'textarea') { + _type = `nvarchar(${_fieldlen})` + } + + if (_f.type === 'number') { _select.push(`@${_f.field}=0`) } else { _select.push(`@${_f.field}=''`) @@ -827,271 +848,206 @@ _declare.push(`@${_f.field} ${_type}`) }) + } - let uniqueFields = fromJS(_fields).toJS() + let _sql = `Declare ${_declare.join(', ')} + Select ${_select.join(', ')} + ` - if (!hasBid) { // 鍞竴鎬ч獙璇佹坊鍔燘ID - uniqueFields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) - _fields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) - } + // 榛樿sql + let _defaultsql = '' + let _insertsql = '' + let _updatesql = '' + let _primaryKey = config.setting.primaryKey || 'id' - let hasColumn = false - if (columns && columns.length > 0) { - if (btnTab) { // 琛ㄥ崟鏍囩 - hasColumn = btnTab.Ot !== 'notRequired' - } else if (card.Ot !== 'notRequired') { - hasColumn = true - } - } + if (this.props.side === 'sub') { + _primaryKey = config.setting.subKey || 'id' + } - let unionFields = fromJS(_fields).toJS() - let formArr = _fields.map(_f => _f.field.toLowerCase()) + if (card.sqlType === 'insert' || card.sqlType === 'insertOrUpdate') { + let keys = [] + let values = [] - if (hasColumn) { - columns.forEach(_f => { - if (_f.field && !formArr.includes(_f.field.toLowerCase())) { - formArr.push(_f.field.toLowerCase()) - unionFields.push(_f) - } - if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return + _fields.forEach(item => { + if (!item.field || item.writein === 'false') return - fieldArr.push(_f.field.toLowerCase()) - _usefulfields.push(_f.field) + keys.push(item.field.toLowerCase()) - if (_f.datatype) { // 鑷畾涔夊瓧娈� - if (/decimal/ig.test(_f.datatype)) { - _select.push(`@${_f.field}=0`) - } else { - _select.push(`@${_f.field}=''`) - } - - _declare.push(`@${_f.field} ${_f.datatype}`) - return - } - - let _fieldlen = _f.fieldlength || 50 - - if (_fieldlen > 4000) { - _fieldlen = 'max' - } - - let _type = `nvarchar(${_fieldlen})` - - if (_f.type === 'number') { - _type = `decimal(18,${_f.decimal ? _f.decimal : 0})` - } else if (_f.type === 'picture' || _f.type === 'textarea') { - _type = `nvarchar(${_fieldlen})` - } - - if (_f.type === 'number') { - _select.push(`@${_f.field}=0`) - } else { - _select.push(`@${_f.field}=''`) - } - - _declare.push(`@${_f.field} ${_type}`) - }) - } - - let _sql = `Declare ${_declare.join(', ')} - Select ${_select.join(', ')} - ` - - // 榛樿sql - let _defaultsql = '' - let _insertsql = '' - let _updatesql = '' - let _primaryKey = config.setting.primaryKey || 'id' - - if (this.props.side === 'sub') { - _primaryKey = config.setting.subKey || 'id' - } - - if (card.sqlType === 'insert' || card.sqlType === 'insertOrUpdate') { - let keys = [] - let values = [] - - _fields.forEach(item => { - if (!item.field || item.writein === 'false') return - - keys.push(item.field.toLowerCase()) - - if (item.field.toLowerCase() === 'bid' && item.uuid === 'BID') { - values.push('@BID@') - } else { - values.push('@' + item.field) - } - }) - - if (!keys.includes(_primaryKey.toLowerCase())) { - keys.push(_primaryKey.toLowerCase()) - values.push('@ID@') - } - if (!keys.includes('createuserid')) { - keys.push('createuserid') - values.push('@userid@') - } - if (!keys.includes('createuser')) { - keys.push('createuser') - values.push('@username') - } - if (!keys.includes('createstaff')) { - keys.push('createstaff') - values.push('@fullname') - } - if (!keys.includes('bid')) { - keys.push('bid') + if (item.field.toLowerCase() === 'bid' && item.uuid === 'BID') { values.push('@BID@') - } - if (!keys.includes('typename')) { - keys.push('typename') - values.push('@typename@') - } - - keys = keys.join(', ') - values = values.join(', ') - _insertsql = `insert into ${card.sql} (${keys}) select ${values};` - } - - if (card.sqlType === 'update' || card.sqlType === 'audit' || card.sqlType === 'insertOrUpdate') { - let _form = [] - let _arr = [] - - _fields.forEach(item => { - if (!item.field || item.writein === 'false' || item.uuid === 'BID') return - - _arr.push(item.field.toLowerCase()) - if (item.field.toLowerCase() === 'bid') { - _form.push(item.field + '=@BID@') - } else { - _form.push(item.field + '=@' + item.field) - } - }) - - if (this.props.card.sqlType === 'audit') { - if (!_arr.includes('submitdate')) { - _form.push('submitdate=getdate()') - } - if (!_arr.includes('submituser')) { - _form.push('submituser=@username') - } - if (!_arr.includes('submitstaff')) { - _form.push('submitstaff=@fullname') - } - if (!_arr.includes('submituserid')) { - _form.push('submituserid=@userid@') - } - if (!_arr.includes('typename')) { - _form.push(`typename=@typename@`) - } } else { - if (!_arr.includes('modifydate')) { - _form.push('modifydate=getdate()') - } - if (!_arr.includes('modifyuser')) { - _form.push('modifyuser=@username') - } - if (!_arr.includes('modifystaff')) { - _form.push('modifystaff=@fullname') - } - if (!_arr.includes('modifyuserid')) { - _form.push('modifyuserid=@userid@') - } - if (!_arr.includes('typename')) { - _form.push(`typename=@typename@`) - } + values.push('@' + item.field) } - - if (_verify.voucher && _verify.voucher.enabled) { - if (!_arr.includes('bvoucher')) { - _form.push('BVoucher=@BVoucher') - } - if (!_arr.includes('fibvoucherdate')) { - _form.push('FIBVoucherDate=@FIBVoucherDate') - } - if (!_arr.includes('fiyear')) { - _form.push('FiYear=@FiYear') - } - } - - _form = _form.join(', ') - _updatesql = `update ${card.sql} set ${_form} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};` - } - - if (card.sqlType === 'insert') { - _defaultsql = _insertsql - } else if (card.sqlType === 'update' || card.sqlType === 'audit') { - _defaultsql = _updatesql - } else if (card.sqlType === 'insertOrUpdate') { - _defaultsql += `select @tbid='' - select @tbid='X' from ${card.sql} where ${_primaryKey}=@ID@ - if @tbid='' - begin - ${_insertsql} - end - else - begin - ${_updatesql} - end - ` - } else if (card.sqlType === 'LogicDelete' || card.sqlType === 'custom') { - let _voucher = '' - if (_verify.voucher && _verify.voucher.enabled) { - _voucher = ',BVoucher=@BVoucher,FIBVoucherDate=@FIBVoucherDate,FiYear=@FiYear' - } - _defaultsql = `update ${card.sql} set deleted=@mk_deleted,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@${_voucher} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};` - } else if (card.sqlType === 'delete') { - let _msg = '' - if (columns && columns.length > 0 && card.Ot !== 'notRequired') { - let _index = 0 - columns.forEach(col => { - if (!col.field || col.Hide === 'true' || _index >= 4) return - - _msg += col.label + '=\'\',' - _index++ - }) - } - _defaultsql += `insert into snote (remark,createuserid,CreateUser,CreateStaff,typename) select left('鍒犻櫎琛�:${card.sql} 鏁版嵁: ${_msg}${_primaryKey}='+@ID@,200),@userid@,@username,@fullname,@typename@ delete ${card.sql} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};` - } - - let _columns = [] - if (columns) { - _columns = fromJS(columns).toJS() - let hasbid = false - _columns = _columns.filter(col => { - if (col.field && col.field.toLowerCase() === 'bid') { - hasbid = true - } - - return !!col.field - }) - - if (!hasbid) { - _columns.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) - } - } - - this.setState({ - fields: _fields, - columnsFields: _columns, - initsql: _sql, - defaultsql: _defaultsql, - usefulfields: _usefulfields.join(', '), - uniqueColumns: this.state.uniqueColumns.map(col => { - if (col.dataIndex === 'field') { - col.options = uniqueFields - } - return col - }), - onceUniqueColumns: this.state.onceUniqueColumns.map(col => { - if (col.dataIndex === 'field') { - col.options = _columns - } - return col - }), - unionFields, - uniqueFields }) + + if (!keys.includes(_primaryKey.toLowerCase())) { + keys.push(_primaryKey.toLowerCase()) + values.push('@ID@') + } + if (!keys.includes('createuserid')) { + keys.push('createuserid') + values.push('@userid@') + } + if (!keys.includes('createuser')) { + keys.push('createuser') + values.push('@username') + } + if (!keys.includes('createstaff')) { + keys.push('createstaff') + values.push('@fullname') + } + if (!keys.includes('bid')) { + keys.push('bid') + values.push('@BID@') + } + if (!keys.includes('typename')) { + keys.push('typename') + values.push('@typename@') + } + + keys = keys.join(', ') + values = values.join(', ') + _insertsql = `insert into ${card.sql} (${keys}) select ${values};` + } + + if (card.sqlType === 'update' || card.sqlType === 'audit' || card.sqlType === 'insertOrUpdate') { + let _form = [] + let _arr = [] + + _fields.forEach(item => { + if (!item.field || item.writein === 'false' || item.uuid === 'BID') return + + _arr.push(item.field.toLowerCase()) + if (item.field.toLowerCase() === 'bid') { + _form.push(item.field + '=@BID@') + } else { + _form.push(item.field + '=@' + item.field) + } + }) + + if (this.props.card.sqlType === 'audit') { + if (!_arr.includes('submitdate')) { + _form.push('submitdate=getdate()') + } + if (!_arr.includes('submituser')) { + _form.push('submituser=@username') + } + if (!_arr.includes('submitstaff')) { + _form.push('submitstaff=@fullname') + } + if (!_arr.includes('submituserid')) { + _form.push('submituserid=@userid@') + } + if (!_arr.includes('typename')) { + _form.push(`typename=@typename@`) + } + } else { + if (!_arr.includes('modifydate')) { + _form.push('modifydate=getdate()') + } + if (!_arr.includes('modifyuser')) { + _form.push('modifyuser=@username') + } + if (!_arr.includes('modifystaff')) { + _form.push('modifystaff=@fullname') + } + if (!_arr.includes('modifyuserid')) { + _form.push('modifyuserid=@userid@') + } + if (!_arr.includes('typename')) { + _form.push(`typename=@typename@`) + } + } + + if (_verify.voucher && _verify.voucher.enabled) { + if (!_arr.includes('bvoucher')) { + _form.push('BVoucher=@BVoucher') + } + if (!_arr.includes('fibvoucherdate')) { + _form.push('FIBVoucherDate=@FIBVoucherDate') + } + if (!_arr.includes('fiyear')) { + _form.push('FiYear=@FiYear') + } + } + + _form = _form.join(', ') + _updatesql = `update ${card.sql} set ${_form} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};` + } + + if (card.sqlType === 'insert') { + _defaultsql = _insertsql + } else if (card.sqlType === 'update' || card.sqlType === 'audit') { + _defaultsql = _updatesql + } else if (card.sqlType === 'insertOrUpdate') { + _defaultsql += `select @tbid='' + select @tbid='X' from ${card.sql} where ${_primaryKey}=@ID@ + if @tbid='' + begin + ${_insertsql} + end + else + begin + ${_updatesql} + end + ` + } else if (card.sqlType === 'LogicDelete' || card.sqlType === 'custom') { + let _voucher = '' + if (_verify.voucher && _verify.voucher.enabled) { + _voucher = ',BVoucher=@BVoucher,FIBVoucherDate=@FIBVoucherDate,FiYear=@FiYear' + } + _defaultsql = `update ${card.sql} set deleted=@mk_deleted,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@${_voucher} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};` + } else if (card.sqlType === 'delete') { + let _msg = '' + if (columns && columns.length > 0 && card.Ot !== 'notRequired') { + let _index = 0 + columns.forEach(col => { + if (!col.field || col.Hide === 'true' || _index >= 4) return + + _msg += col.label + '=\'\',' + _index++ + }) + } + _defaultsql += `insert into snote (remark,createuserid,CreateUser,CreateStaff,typename) select left('鍒犻櫎琛�:${card.sql} 鏁版嵁: ${_msg}${_primaryKey}='+@ID@,200),@userid@,@username,@fullname,@typename@ delete ${card.sql} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};` + } + + let _columns = [] + if (columns) { + _columns = fromJS(columns).toJS() + let hasbid = false + _columns = _columns.filter(col => { + if (col.field && col.field.toLowerCase() === 'bid') { + hasbid = true + } + + return !!col.field + }) + + if (!hasbid) { + _columns.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' }) + } + } + + this.setState({ + fields: _fields, + columnsFields: _columns, + initsql: _sql, + defaultsql: _defaultsql, + usefulfields: _usefulfields.join(', '), + uniqueColumns: this.state.uniqueColumns.map(col => { + if (col.dataIndex === 'field') { + col.options = uniqueFields + } + return col + }), + onceUniqueColumns: this.state.onceUniqueColumns.map(col => { + if (col.dataIndex === 'field') { + col.options = _columns + } + return col + }), + unionFields, + uniqueFields }) } @@ -1287,6 +1243,8 @@ } scriptsChange = (values) => { + const { columns, card } = this.props + let verify = fromJS(this.state.verify).toJS() if (values.uuid) { @@ -1302,6 +1260,35 @@ verify.scripts.push(values) } + if (/@bvoucher(\s|\))/ig.test(values.sql)) { + if (verify.voucher && verify.voucher.enabled) { + + } else if (card.Ot !== 'notRequired' && columns) { + let hasvoucher = false + columns.forEach(_f => { + if (!_f.field) return + + if (_f.field.toLowerCase() === 'bvoucher') { + hasvoucher = true + } + }) + + if (!hasvoucher) { + notification.warning({ + top: 92, + message: '鏈惎鐢ㄥ垱寤哄嚟璇侊紝涓斿瓧娈甸泦涓笉瀛樺湪鍑瘉瀛楁锛坆voucher锛夈��', + duration: 5 + }) + } + } else { + notification.warning({ + top: 92, + message: '鏈惎鐢ㄥ垱寤哄嚟璇侊紝涓斿瓧娈甸泦涓笉瀛樺湪鍑瘉瀛楁锛坆voucher锛夈��', + duration: 5 + }) + } + } + MKEmitter.emit('editLineId', values.uuid) this.setState({ verify }) -- Gitblit v1.8.0