From 7b0dbecd1d6155d26ec67be0a47a16264c738c85 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 09 五月 2023 14:48:10 +0800 Subject: [PATCH] 2023-05-09 --- src/tabviews/zshare/actionList/normalbutton/index.jsx | 157 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 103 insertions(+), 54 deletions(-) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 4b9f777..3cab100 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -144,7 +144,7 @@ if (data.length > 0) { data.forEach(item => { let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' - if (btn.controlVals.includes(s)) { + if (btn.controlVals.includes(s) || item.$lock) { disabled = true } }) @@ -601,7 +601,7 @@ param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions, Utils.getAllSearchOptions) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� if (btn.output) { param.key_back_type = 'Y' } @@ -855,17 +855,20 @@ if (!_initvars.includes(_key)) { _initvars.push(_key) + let val = form.value if (form.type === 'number' || form.type === 'rate') { - let val = form.value if (isNaN(val)) { val = 0 } _initFormfields.push(`@${_key}=${val}`) } else if (['date', 'datemonth'].includes(form.type)) { - _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`) + _initFormfields.push(`@${_key}='${val || '1949-10-01'}'`) } else { - _initFormfields.push(`@${_key}='${form.value}'`) + if (/'/.test(val)) { + val = val.replace(/'/ig, '"') + } + _initFormfields.push(`@${_key}='${val}'`) } } @@ -890,15 +893,16 @@ } }) + let _data = {} if (data) { Object.keys(data).forEach(key => { - data[key.toLowerCase()] = data[key] + _data[key.toLowerCase()] = data[key] }) } // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃) if (data && btn.Ot !== 'notRequired' && columns && columns.length > 0) { - datavars = {...data, ...datavars} + datavars = {..._data, ...datavars} const setField = (col) => { if (!col.field) return @@ -909,6 +913,10 @@ if (col.datatype && /^date/ig.test(col.datatype) && !_val) { _val = '1949-10-01' + } + + if (/'/.test(_val)) { + _val = _val.replace(/'/ig, '"') } _initvars.push(_key) @@ -956,7 +964,7 @@ _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),@ModularDetailCode nvarchar(50), @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),@bid nvarchar(50)${_declarefields} + Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50), @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),@mk_deleted int,@bid nvarchar(50)${_declarefields} ` let userName = sessionStorage.getItem('User_Name') || '' @@ -979,7 +987,7 @@ // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁 _sql += ` /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */ - select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @bid='${BID}', @BillCode='', @ModularDetailCode='' + select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @mk_deleted=1, @bid='${BID}', @BillCode='', @ModularDetailCode='' ` // 琛ㄥ崟鍙橀噺璧嬪�� @@ -1734,6 +1742,7 @@ outerOuterRequest = (params, result, record, _resolve) => { const { btn } = this.props let outParam = JSON.parse(JSON.stringify(result)) + let ver_token = false if (btn.outerFunc) { result.func = btn.outerFunc @@ -1772,6 +1781,7 @@ } else { result.$token = btn.exInterface || '' } + ver_token = true } else { if (window.GLOB.systemType === 'production' && btn.proInterface) { result.rduri = btn.proInterface @@ -1788,6 +1798,10 @@ Api.genericInterface(result).then(res => { if (!res) return // LoginError鏃朵腑鏂姹� + if (ver_token && res.ErrMesg === 'token_error') { + this.execError(res) + return + } this.outerCallbackRequest(params, res, record, outParam, _resolve) }, () => { this.outerCallbackRequest(params, {status: false, message: 500, ErrCode: 'E', ErrMesg: 500}, record, outParam, _resolve) @@ -1962,8 +1976,9 @@ const { btn } = this.props const { btnconfig, autoMatic } = this.state - if (res.message && /^@speak@/.test(res.message)) { - res.message = res.message.replace('@speak@', '') + let sign = '' + if (/^@speak@/i.test(res.message)) { + res.message = res.message.replace(/^@speak@/i, '') let val = res.message.match(/<<.*>>/) res.message = res.message.replace(/\s*<<.*>>\s*/g, '') val = val ? val[0].replace(/<<|>>/g, '') : '' @@ -1977,6 +1992,9 @@ if (!res.message) { res.ErrCode = '-1' } + } else if (/@close_tab@|@close_popup@|@goback@/i.test(res.message)) { + sign = res.message.match(/@close_tab@|@close_popup@|@goback@/i)[0].toLowerCase() + res.message = res.message.replace(/@close_tab@|@close_popup@|@goback@/i, '') } if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 鎵ц鎴愬姛 @@ -2032,9 +2050,9 @@ return } - if (btn.execSuccess === 'closetab') { + if (btn.execSuccess === 'closetab' || sign === '@close_tab@') { MKEmitter.emit('closeTabView', btn.$MenuID) - } else if (btn.execSuccess === 'closepoptab') { + } else if (btn.execSuccess === 'closepoptab' || sign === '@close_popup@') { MKEmitter.emit('popclose') } else if (btn.execSuccess !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines) @@ -2350,12 +2368,13 @@ * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execError = (res) => { + execError = (res = {}) => { const { btn } = this.props const { btnconfig, autoMatic } = this.state - if (res.message && /^@speak@/.test(res.message)) { - res.message = res.message.replace('@speak@', '') + let sign = '' + if (/^@speak@/i.test(res.message)) { + res.message = res.message.replace(/^@speak@/i, '') let val = res.message.match(/<<.*>>/) res.message = res.message.replace(/\s*<<.*>>\s*/g, '') val = val ? val[0].replace(/<<|>>/g, '') : '' @@ -2369,6 +2388,9 @@ if (!res.message) { res.ErrCode = '-1' } + } else if (/@close_tab@|@close_popup@|@goback@/i.test(res.message)) { + sign = res.message.match(/@close_tab@|@close_popup@|@goback@/i)[0].toLowerCase() + res.message = res.message.replace(/@close_tab@|@close_popup@|@goback@/i, '') } if (res.ErrCode === 'E' && !autoMatic) { @@ -2416,13 +2438,29 @@ MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus) } - if (btn.execError === 'closepoptab') { + if (sign === '@close_tab@') { + MKEmitter.emit('closeTabView', btn.$MenuID) + } else if (btn.execError === 'closepoptab' || sign === '@close_popup@') { MKEmitter.emit('popclose') } else if (btn.execError !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) - } else if (btn.OpenType === 'form' && btn.formType !== 'counter') { + } + if (btn.OpenType === 'form') { let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null - this.setState({check: data && data[btn.field] === btn.openVal}) + + if (btn.formType === 'counter') { + let count = 0 + if (data && data[btn.field]) { + count = +data[btn.field] + if (isNaN(count)) { + count = 0 + } + } + + this.setState({count: count }) + } else { + this.setState({check: data && data[btn.field] === btn.openVal}) + } } if (window.GLOB.breakpoint) { @@ -2576,49 +2614,50 @@ btnconfig.fields.forEach(item => { if (!item.field) return + let _item = { key: item.field, readin: item.readin !== 'false' && item.readin !== 'top', fieldlen: item.fieldlength || 50, writein: item.writein !== 'false', - type: item.type - } - - let _initval = item.initval - let _readin = item.readin !== 'false' - let _format = item.precision || 'day' // 鏃堕棿鏍煎紡鍖� - - if (item.type === 'funcvar') { - _initval = '' - _readin = false - _item.readin = false - } else if (item.type === 'linkMain') { - _readin = false - _item.readin = false - } else if (item.type === 'date') { - if (_format !== 'day') { - _format = 'YYYY-MM-DD HH:mm:ss' - } else { - _format = 'YYYY-MM-DD' - } - } else if (item.type === 'datetime') { - _item.type = 'date' - _format = 'YYYY-MM-DD HH:mm:ss' + type: item.type, + value: item.initval } let key = item.field.toLowerCase() + let _readin = item.readin !== 'false' - if (_item.type === 'linkMain' && BData.hasOwnProperty(key)) { - _initval = BData[key] - } else if (_readin && _data.hasOwnProperty(key)) { - _initval = _data[key] - } else if (_item.type === 'date' && _initval) { - _initval = moment().subtract(_initval, 'days').format(_format) - } else if (_item.type === 'datemonth' && _initval) { - _initval = moment().subtract(_initval, 'month').format('YYYY-MM') + if (_item.type === 'date') { // 鏃堕棿鍏煎 + _item.precision = item.precision || 'day' + } else if (_item.type === 'datetime') { + _item.type = 'date' + _item.precision = 'second' + } else if (['funcvar', 'linkMain'].includes(_item.type)) { + _readin = false + _item.readin = false + } else if (['select', 'link', 'radio'].includes(_item.type)) { // 閫変腑绗竴椤� + if (/^\s*\$first\s*$/.test(_item.value)) { + _item.value = '' + + if (item.resourceType === '0' && item.options[0] && item.options[0].Value) { + _item.value = item.options[0].Value + } + } } - _item.value = _initval === undefined ? '' : _initval + if (_item.type === 'funcvar') { + _item.value = '' + } else if (_item.type === 'linkMain' && BData.hasOwnProperty(key)) { + _item.value = BData[key] + } else if (_readin && _data.hasOwnProperty(key)) { + _item.value = _data[key] + } else if (_item.type === 'date' && _item.value) { + _item.value = moment().subtract(_item.value, 'days').format(_item.precision === 'day' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss') + } else if (_item.type === 'datemonth' && _item.value) { + _item.value = moment().subtract(_item.value, 'month').format('YYYY-MM') + } + + _item.value = _item.value === undefined ? '' : _item.value if (_item.type === 'number' || item.declare === 'decimal') { _item.type = 'number' @@ -2640,9 +2679,19 @@ _item.value = _item.value.slice(-item.fieldlength) } } - } else if (_item.type.indexOf('date') > -1) { - if (item.declareType === 'nvarchar(50)') { - _item.type = 'text' + } else if (_item.type === 'datemonth') { + _item.type = 'text' + } else if (_item.type === 'date') { + _item.type = item.declareType === 'nvarchar(50)' ? 'text' : 'date' + } else if (_item.type === 'switch' || _item.type === 'check') { + if (_readin) { + _item.value = _item.value === item.openVal ? item.openVal : item.closeVal + } else { + if (item.initval === true) { + _item.value = item.openVal + } else { + _item.value = item.closeVal + } } } else if (_item.type === 'rate') { let count = item.rateCount || 5 -- Gitblit v1.8.0