From b3852c89968e9d5d6a3b9a4998d869bfbbfd1842 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 01 十二月 2020 18:19:04 +0800 Subject: [PATCH] 2020-12-01 --- src/tabviews/zshare/mutilform/index.jsx | 118 +++++++++++++++++++++++++--------------------------------- 1 files changed, 51 insertions(+), 67 deletions(-) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 2767199..1160ba3 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -66,6 +66,7 @@ let formlist = [] let encrypts = [] let intercepts = [] + let _inputfields = [] if (action.groups.length > 0) { action.groups.forEach(group => { @@ -85,29 +86,32 @@ formlist = action.fields } - let _inputfields = formlist.filter(item => (item.type === 'text' || item.type === 'number') && item.field) // 鐢ㄤ簬杩囨护涓嬫媺鑿滃崟鍏宠仈琛ㄥ崟 + let linkFields = {} // 鍏宠仈鑿滃崟 + let supItemVal = {} // 涓婄骇鑿滃崟鍒濆鍊� + let deForms = [] // 闇�瑕佸姩鎬佽幏鍙栦笅鎷夎彍鍗曠殑琛ㄥ崟 + + formlist.forEach(item => { + if (item.type === 'text' || item.type === 'number') { // 鐢ㄤ簬杩囨护涓嬫媺鑿滃崟鍏宠仈琛ㄥ崟 + _inputfields.push(item.field) + } else if (item.type === 'textarea' && item.encryption === 'true') { // 鍔犲瘑瀛楁 + encrypts.push(item.field) + } else if (item.type === 'link') { + linkFields[item.linkField] = linkFields[item.linkField] || [] + linkFields[item.linkField].push(item.field) + } + if (item.interception === 'true') { // 瀛楃鎴彇瀛楁 + intercepts.push(item.field) + } + }) formlist = formlist.map(item => { if (item.type === 'title') return item - - // 鍔犲瘑瀛楁 - if (item.type === 'textarea' && item.encryption === 'true') { - encrypts.push(item.field) - } - - // 瀛楃鎴彇瀛楁 - if (item.interception === 'true') { - intercepts.push(item.field) - } // 鏁版嵁鑷姩濉厖 let _readin = item.readin !== 'false' if (item.type === 'linkMain' || item.type === 'funcvar') { _readin = false } - - // 鐢ㄤ簬鍙楁帶鍊肩殑琛ㄥ崟锛岄殣钘忔椂浼犻粯璁ゅ��(鏈娇鐢紵) - item.initVal = typeof(item.initval) === 'object' ? fromJS(item.initval).toJS() : item.initval let _fieldlen = item.fieldlength || 50 if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { @@ -122,29 +126,22 @@ writein[item.field] = item.writein !== 'false' fieldlen[item.field] = _fieldlen - if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect' || item.type === 'radio' || item.type === 'checkbox') { - if (item.setAll === 'true' && (item.type === 'select' || item.type === 'link' || item.type === 'radio')) { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: item.emptyText || '绌�' - }) - } + if (item.setAll === 'true' && (item.type === 'select' || item.type === 'link' || item.type === 'radio')) { // 娣诲姞绌哄�� + item.options.unshift({ + key: Utils.getuuid(), + Value: '', + Text: item.emptyText || '绌�' + }) + } - // 淇濆瓨鍒濆鍒楄〃锛岀敤浜庤仈鍔ㄨ彍鍗曟帶鍒� - item.oriOptions = fromJS(item.options).toJS() + item.oriOptions = item.options ? fromJS(item.options).toJS() : null // 淇濆瓨鍒濆鍒楄〃锛岀敤浜庤仈鍔ㄨ彍鍗曟帶鍒� - // 涓嬬骇琛ㄥ崟鎺у埗-瀛楁鍐欏叆 - if (item.type === 'select' || item.type === 'radio') { - if (item.linkSubField && item.linkSubField.length > 0) { - item.linkSubField = item.linkSubField.filter(_item => _inputfields.includes(_item)) - } - if (item.linkSubField && item.linkSubField.length === 0) { - item.linkSubField = null - } - } else { - item.linkSubField = null - } + // 涓嬬骇琛ㄥ崟鎺у埗-瀛楁鍐欏叆 + if ((item.type === 'select' || item.type === 'radio') && item.linkSubField && item.linkSubField.length > 0) { + item.linkSubField = item.linkSubField.filter(_item => _inputfields.includes(_item)) + } + if (item.linkSubField && item.linkSubField.length === 0) { + item.linkSubField = null } let newval = '' @@ -226,31 +223,30 @@ item.supvalue = supvals } + if (linkFields[item.field]) { + item.linkFields = linkFields[item.field] + } + supItemVal[item.field] = item.initval + + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && item.resourceType === '1') { + deForms.push(item) + } + return item }) formlist = formlist.map(item => { if (item.type === 'link') { - let supItem = formlist.filter(form => form.field === item.linkField)[0] + item.supInitVal = '' - // 鍏宠仈鏄剧ず鍒椾腑鐨勫瓧娈靛�硷紝閫氳繃璇ュ�艰繃婊や笅鎷夐�夐」 - if (!supItem && data && data.hasOwnProperty(item.linkField)) { - supItem = {initval: data[item.linkField]} + if (supItemVal[item.linkField]) { + item.supInitVal = supItemVal[item.linkField] + } else if (data && data.hasOwnProperty(item.linkField)) { + item.supInitVal = data[item.linkField] } - if (!supItem) { - notification.warning({ - top: 92, - message: '鏈煡璇㈠埌琛ㄥ崟銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', - duration: 5 - }) - item.supInitVal = '' - } else { - item.supInitVal = supItem.initval - item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval) - } + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) } - return item }) @@ -281,19 +277,16 @@ this.setState({ loaded: true }) - this.improveActionForm() + this.improveActionForm(deForms) }) } /** * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 */ - improveActionForm = () => { + improveActionForm = (deForms) => { const { BID, menuType } = this.props const { formlist } = this.state - - // 闇�瑕佸姩鎬佽幏鍙栦笅鎷夎彍鍗曠殑琛ㄥ崟 - let deForms = formlist.filter(item => ['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && item.resourceType === '1' && (item.type === 'link' || item.hidden !== 'true')) if (deForms.length === 0) { return @@ -445,11 +438,7 @@ this.setState({ formlist: _formlist.map(item => { if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) - } else { - item.options = item.oriOptions - } + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } @@ -542,11 +531,7 @@ this.setState({ formlist: _formlist.map(item => { if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) - } else { - item.options = item.oriOptions - } + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } @@ -1291,7 +1276,6 @@ return item }) } - resolve(search) } else { reject(err) -- Gitblit v1.8.0