From 34e7681fd12b1c4e4994d3bea1a553870e10bc50 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 11 三月 2023 17:58:54 +0800 Subject: [PATCH] 2023-03-11 --- src/tabviews/zshare/mutilform/index.jsx | 105 +++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 82 insertions(+), 23 deletions(-) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index e69e00d..a1ea659 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -27,6 +27,7 @@ const MKColor = asyncComponent(() => import('./mkColor')) const MkFormula = asyncComponent(() => import('./mkFormula')) const MkCascader = asyncComponent(() => import('./mkCascader')) +const MkVercode = asyncComponent(() => import('./mkVercode')) const MKEditor = asyncComponent(() => import('@/components/editor')) class MainSearch extends Component { @@ -41,6 +42,10 @@ state = { formlist: [], // 琛ㄥ崟椤� + ID: '', + send_type: '', + timestamp: '', + n_id: '' } record = {} @@ -99,6 +104,12 @@ delete item.style.marginRight } + if (item.type === 'split' && item.splitctrl) { + if (data.hasOwnProperty(item.splitctrl.toLowerCase()) && data[item.splitctrl.toLowerCase()] === '') { + return false + } + } + if (item.type === 'split' || item.type === 'formula') return true if (item.type === 'hint') { if (item.field && data[item.field.toLowerCase()]) { @@ -113,7 +124,7 @@ item.precision = 'second' } - if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'cascader', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color'].includes(item.type)) return false + if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'cascader', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color', 'vercode'].includes(item.type)) return false if (/^\s+$/.test(item.label)) { item.style = item.style || {} @@ -160,6 +171,10 @@ }) } item.oriOptions = fromJS(item.options).toJS() + + if (item.empty === 'hidden' && item.oriOptions.length === 0) { + item.hidden = true + } } let newval = '$empty' @@ -350,7 +365,7 @@ message: formRule.input.formMessage.replace('@max', item.fieldlength) } ] - } else if (item.type === 'linkMain') { + } else if (item.type === 'linkMain' || item.type === 'vercode') { item.rules = [ { required: item.required === 'true', @@ -448,17 +463,19 @@ item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.value === '') } - if (['select', 'link', 'radio'].includes(item.type) && item.resourceType === '0') { // 閫変腑绗竴椤� + if (['select', 'link', 'radio'].includes(item.type)) { // 閫変腑绗竴椤� if (typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { - item.initval = item.options[0] ? item.options[0].value : '' + item.$first = true + item.initval = '' + } + if (item.resourceType === '0') { // 閫変腑绗竴椤� + if (item.$first) { + item.initval = item.options[0] ? item.options[0].value : '' + } } } - if (typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { - record[item.field] = '' - } else { - record[item.field] = item.initval - } + record[item.field] = item.initval if (linkFields[item.field]) { item.linkFields = linkFields[item.field] @@ -506,7 +523,7 @@ this.record = record - this.setState({ formlist }, () => { + this.setState({ formlist, ID: this.props.data ? this.props.data.$$uuid || '' : '' }, () => { if (unload) return if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) { @@ -537,13 +554,17 @@ let cache = action.setting.cache !== 'false' let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud') - let _sql = `Declare @mk_organization nvarchar(512) select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n` + let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` let _sso = _sql deForms.forEach(item => { if (item.database === 'sso') { let sql = _sso + item.base_sql _sso = '' + + sql = sql.replace(/@ID@/ig, `'${this.state.ID || ''}'`) + sql = sql.replace(/@BID@/ig, `'${BID}'`) + if (debug) { console.info(sql) } @@ -551,6 +572,10 @@ } else { let sql = _sql + item.base_sql _sql = '' + + sql = sql.replace(/@ID@/ig, `'${this.state.ID || ''}'`) + sql = sql.replace(/@BID@/ig, `'${BID}'`) + if (debug) { console.info(sql) } @@ -564,8 +589,7 @@ LText: localItems.join(' union all '), obj_name: '', arr_field: '', - table_type: 'Y', - BID: BID || '' + table_type: 'Y' } if (param.LText) { @@ -599,8 +623,7 @@ LText: mainItems.join(' union all '), obj_name: '', arr_field: '', - table_type: 'Y', - BID: BID || '' + table_type: 'Y' } if (mainparam.LText) { @@ -653,16 +676,18 @@ improveSimpleActionForm = (deForms) => { let cache = this.props.action.setting.cache !== 'false' let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud') - let _sql = `Declare @mk_organization nvarchar(512) select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n` + let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` let deffers = deForms.map((form, index) => { let param = { func: 'sPC_Get_SelectedList', LText: _sql + form.base_sql, obj_name: form.field, - arr_field: form.arr_field, - BID: this.props.BID || '' + arr_field: form.arr_field } + + param.LText = param.LText.replace(/@ID@/ig, `'${this.state.ID || ''}'`) + param.LText = param.LText.replace(/@BID@/ig, `'${this.props.BID || ''}'`) if (debug) { console.info(param.LText) @@ -775,7 +800,7 @@ item.options = item.oriOptions } - if (['select', 'link', 'radio'].includes(item.type) && typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { // 閫変腑绗竴椤� + if (['select', 'link', 'radio'].includes(item.type) && item.$first) { // 閫変腑绗竴椤� item.initval = item.options[0] ? item.options[0].value : '' this.record[item.field] = item.initval } @@ -794,6 +819,10 @@ reFieldsVal[n.field] = option[n.field] }) } + } + + if (item.empty === 'hidden' && item.oriOptions.length > 0) { + item.hidden = false } } @@ -945,6 +974,8 @@ content = (<MKTextArea config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})}/>) } else if (item.type === 'rate') { content = (<Rate count={item.rateCount} disabled={item.readonly} style={{color: item.color || '#fadb14'}} onChange={(val) => this.recordChange({[item.field]: val})} character={item.character ? <MkIcon type={item.character}/> : <StarFilled />} allowHalf={item.allowHalf}/>) + } else if (item.type === 'vercode') { + content = (<MkVercode config={item} record={this.record} onSend={(send_type, timestamp, n_id) => this.setState({send_type, timestamp, n_id})} onChange={(val) => this.recordChange({[item.field]: val})} onSubmit={this.props.inputSubmit}/>) } else if (item.type === 'brafteditor') { content = (<MKEditor config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) label = item.hidelabel !== 'true' ? label : '' @@ -976,7 +1007,7 @@ } handleConfirm = () => { - const { formlist } = this.state + const { formlist, send_type, timestamp, n_id } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { @@ -985,7 +1016,7 @@ reject(err) return } - let search = [] + let forms = [] let record = {...this.record, ...values} formlist.forEach(item => { @@ -1027,12 +1058,40 @@ if (item.declareType === 'nvarchar(50)') { _item.type = 'text' } + } else if (item.type === 'vercode') { + _item.type = 'text' + forms.push({ + type: 'text', + readin: false, + writein: false, + fieldlen: 50, + key: 'mk_timestamp', + value: timestamp || '' + }) + + forms.push({ + type: 'text', + readin: false, + writein: false, + fieldlen: 50, + key: 'mk_send_type', + value: send_type || '' + }) + + forms.push({ + type: 'text', + readin: false, + writein: false, + fieldlen: 50, + key: 'mk_n_id', + value: n_id || '' + }) } - search.push(_item) + forms.push(_item) }) - resolve(search) + resolve(forms) }) }) } -- Gitblit v1.8.0