From 9d65dcb2e35f8091f71110c4de7a04215b63b81e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 08 五月 2021 16:59:28 +0800 Subject: [PATCH] 2021-05-08 --- src/tabviews/custom/components/card/table-card/index.jsx | 8 + src/tabviews/custom/components/card/prop-card/index.jsx | 8 + src/tabviews/custom/components/chart/antv-scatter/index.jsx | 8 + src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 8 + src/tabviews/custom/components/code/sand-box/index.jsx | 8 + src/tabviews/custom/components/chart/antv-dashboard/index.jsx | 8 + src/tabviews/custom/components/editor/braft-editor/index.jsx | 8 + src/tabviews/custom/components/share/tabtransfer/index.jsx | 48 +++++--- src/tabviews/zshare/topSearch/index.jsx | 34 +++++ src/tabviews/custom/components/group/normal-group/index.jsx | 48 ++++--- src/tabviews/custom/components/table/normal-table/index.jsx | 29 ++-- src/tabviews/custom/components/chart/antv-pie/index.jsx | 8 + src/tabviews/calendar/index.jsx | 8 - src/tabviews/custom/components/form/normal-form/index.jsx | 8 + src/tabviews/custom/components/carousel/prop-card/index.jsx | 8 + src/tabviews/custom/index.jsx | 52 +++++--- src/tabviews/subtable/index.jsx | 10 - src/tabviews/subtabtable/index.jsx | 9 - src/tabviews/commontable/index.jsx | 9 - src/tabviews/custom/components/card/data-card/index.jsx | 8 + 20 files changed, 231 insertions(+), 104 deletions(-) diff --git a/src/tabviews/calendar/index.jsx b/src/tabviews/calendar/index.jsx index 6141c25..a9bf2a5 100644 --- a/src/tabviews/calendar/index.jsx +++ b/src/tabviews/calendar/index.jsx @@ -218,14 +218,6 @@ let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) if (requireFields.length > 0) { - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - - notification.warning({ - top: 92, - message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', - duration: 3 - }) return } diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 9a243a0..e12bba7 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -446,13 +446,8 @@ }) if (requireFields.length > 0) { - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - - notification.warning({ - top: 92, - message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', - duration: 3 + this.setState({ + loading: false }) return } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 4b857e1..9d6a752 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -251,6 +251,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + this.setState({ loading: true }) diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index 16264c7..4ba5870 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -291,6 +291,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + if (!hastimer) { this.setState({ loading: true diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index 4babfe6..03f794a 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -245,6 +245,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + this.setState({ loading: true }) diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx index d519d08..ce19930 100644 --- a/src/tabviews/custom/components/carousel/prop-card/index.jsx +++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx @@ -214,6 +214,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + this.setState({ loading: true }) diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index 7d31e61..cdafdf7 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -406,6 +406,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + if (!hastimer) { this.setState({ loading: true diff --git a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx index f5f337f..d561d7d 100644 --- a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx +++ b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx @@ -263,6 +263,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + if (!hastimer) { this.setState({ loading: true diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx index 8a74a02..78768e9 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.jsx +++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx @@ -236,6 +236,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + if (!hastimer) { this.setState({ loading: true diff --git a/src/tabviews/custom/components/chart/antv-scatter/index.jsx b/src/tabviews/custom/components/chart/antv-scatter/index.jsx index 0aa4847..516a6a1 100644 --- a/src/tabviews/custom/components/chart/antv-scatter/index.jsx +++ b/src/tabviews/custom/components/chart/antv-scatter/index.jsx @@ -281,6 +281,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + if (!hastimer) { this.setState({ loading: true diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx index 204c9f7..afa5ac5 100644 --- a/src/tabviews/custom/components/code/sand-box/index.jsx +++ b/src/tabviews/custom/components/code/sand-box/index.jsx @@ -146,6 +146,14 @@ searches = mainSearch } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + this.setState({ loading: true }) diff --git a/src/tabviews/custom/components/editor/braft-editor/index.jsx b/src/tabviews/custom/components/editor/braft-editor/index.jsx index 5691f35..3d6c076 100644 --- a/src/tabviews/custom/components/editor/braft-editor/index.jsx +++ b/src/tabviews/custom/components/editor/braft-editor/index.jsx @@ -140,6 +140,14 @@ searches = mainSearch } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + this.setState({ loading: true }) diff --git a/src/tabviews/custom/components/form/normal-form/index.jsx b/src/tabviews/custom/components/form/normal-form/index.jsx index 248b75e..aa6387c 100644 --- a/src/tabviews/custom/components/form/normal-form/index.jsx +++ b/src/tabviews/custom/components/form/normal-form/index.jsx @@ -249,6 +249,14 @@ }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } + this.setState({ loading: true }) diff --git a/src/tabviews/custom/components/group/normal-group/index.jsx b/src/tabviews/custom/components/group/normal-group/index.jsx index bbb9588..2d6e1ff 100644 --- a/src/tabviews/custom/components/group/normal-group/index.jsx +++ b/src/tabviews/custom/components/group/normal-group/index.jsx @@ -44,7 +44,7 @@ // 鑾峰彇涓绘悳绱㈡潯浠� let _mainSearch = mainSearch ? fromJS(mainSearch).toJS() : [] - + let isEmpty = _mainSearch.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0 let params = [] config.components.forEach(item => { if (item.type === 'tabs') return @@ -53,8 +53,32 @@ if (!item.format) return if (item.dataName && (!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && item.setting.sync === 'true') { - let param = this.getDefaultParam(item, _mainSearch) - params.push(param) + if (isEmpty && item.setting.useMSearch === 'true') { + item.setting.sync = 'false' + item.setting.onload = 'false' + } else { + let searchlist = [] + if (item.search && item.search.length > 0) { + searchlist = Utils.initMainSearch(item.search) + } + + let _empty = searchlist.filter(cell => cell.required && (!cell.value || cell.value.length === 0)).length > 0 + + if (_empty) { + item.setting.sync = 'false' + item.setting.onload = 'false' + } else { + if (item.setting.useMSearch === 'true') { + let keys = searchlist.map(item => item.key) + _mainSearch.forEach(item => { + if (!keys.includes(item.key)) { + searchlist.push(item) + } + }) + } + params.push(this.getDefaultParam(item, searchlist)) + } + } } else { item.setting.sync = 'false' } @@ -76,22 +100,8 @@ /** * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ - getDefaultParam = (component, mainSearch) => { - const { columns, search, setting, dataName, format } = component - - let searchlist = [] - if (search && search.length > 0) { - searchlist = Utils.initMainSearch(search) - } - - if (setting.useMSearch === 'true') { - let keys = searchlist.map(item => item.key) - mainSearch.forEach(item => { - if (!keys.includes(item.key)) { - searchlist.push(item) - } - }) - } + getDefaultParam = (component, searchlist) => { + const { columns, setting, dataName, format } = component let arr_field = columns.map(col => col.field) let _dataresource = setting.dataresource diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index 8b8a49b..389ca85 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -58,6 +58,8 @@ _mainSearch = fromJS(mainSearch).toJS() } + let isEmpty = _mainSearch.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0 + let params = [] config.components.forEach(item => { if (item.type === 'tabs' || item.type === 'group') return @@ -66,8 +68,32 @@ if (!item.format) return if (item.dataName && (!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && item.setting.sync === 'true') { - let param = this.getDefaultParam(item, _mainSearch) - params.push(param) + if (isEmpty && item.setting.useMSearch === 'true') { + item.setting.sync = 'false' + item.setting.onload = 'false' + } else { + let searchlist = [] + if (item.search && item.search.length > 0) { + searchlist = Utils.initMainSearch(item.search) + } + + let _empty = searchlist.filter(cell => cell.required && (!cell.value || cell.value.length === 0)).length > 0 + + if (_empty) { + item.setting.sync = 'false' + item.setting.onload = 'false' + } else { + if (item.setting.useMSearch === 'true') { + let keys = searchlist.map(item => item.key) + _mainSearch.forEach(item => { + if (!keys.includes(item.key)) { + searchlist.push(item) + } + }) + } + params.push(this.getDefaultParam(item, searchlist)) + } + } } else { item.setting.sync = 'false' } @@ -91,22 +117,8 @@ /** * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ - getDefaultParam = (component, mainSearch) => { - const { columns, search, setting, dataName, format } = component - - let searchlist = [] - if (search && search.length > 0) { - searchlist = Utils.initMainSearch(search) - } - - if (setting.useMSearch === 'true') { - let keys = searchlist.map(item => item.key) - mainSearch.forEach(item => { - if (!keys.includes(item.key)) { - searchlist.push(item) - } - }) - } + getDefaultParam = (component, searchlist) => { + const { columns, setting, dataName, format } = component let arr_field = columns.map(col => col.field) let _dataresource = setting.dataresource diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index c489646..d22195b 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -133,7 +133,6 @@ async loadmaindata (reset, repage) { const { mainSearch } = this.props const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state - let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -145,17 +144,6 @@ reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 return } - if (requireFields.length > 0) { - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - - notification.warning({ - top: 92, - message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', - duration: 3 - }) - return - } let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -165,6 +153,14 @@ searches.push(item) } }) + } + + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return } this.setState({ @@ -302,11 +298,6 @@ if (config.statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return - let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) - if (requireFields.length > 0) { - return - } - let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 let keys = searches.map(item => item.key.toLowerCase()) @@ -316,6 +307,10 @@ } }) } + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + return + } let _orderBy = orderBy || setting.order let param = UtilsDM.getStatQueryDataParams(setting, config.statFields, searches, _orderBy, BID, this.props.menuType) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 40f0818..cbec0bc 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -190,7 +190,9 @@ }) } - config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs) + let isEmpty = mainSearch.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0 + + config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, isEmpty) this.setState({ BID: BID, @@ -719,7 +721,7 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, mainSearch, inherit, regs) => { + formatSetting = (components, params, mainSearch, inherit, regs, isEmpty) => { return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { @@ -787,8 +789,32 @@ // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ if (component.floor === 1 && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') { - let param = this.getDefaultParam(component, mainSearch) - params.push(param) + if (isEmpty && component.setting.useMSearch === 'true') { + component.setting.sync = 'false' + component.setting.onload = 'false' + } else { + let searchlist = [] + if (component.search && component.search.length > 0) { + searchlist = Utils.initMainSearch(component.search) + } + + let _empty = searchlist.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0 + + if (_empty) { + component.setting.sync = 'false' + component.setting.onload = 'false' + } else { + if (component.setting.useMSearch === 'true') { + let keys = searchlist.map(item => item.key) + mainSearch.forEach(item => { + if (!keys.includes(item.key)) { + searchlist.push(item) + } + }) + } + params.push(this.getDefaultParam(component, searchlist)) + } + } } else if (component.floor === 1) { component.setting.sync = 'false' } @@ -800,22 +826,8 @@ /** * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ - getDefaultParam = (component, mainSearch) => { - const { columns, search, setting, dataName, format } = component - - let searchlist = [] - if (search && search.length > 0) { - searchlist = Utils.initMainSearch(search) - } - - if (setting.useMSearch === 'true') { - let keys = searchlist.map(item => item.key) - mainSearch.forEach(item => { - if (!keys.includes(item.key)) { - searchlist.push(item) - } - }) - } + getDefaultParam = (component, searchlist) => { + const { columns, setting, dataName, format } = component let arr_field = columns.map(col => col.field) let _dataresource = setting.dataresource diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index ade1f1d..3084145 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -356,14 +356,8 @@ } if (requireFields.length > 0) { - let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - - notification.warning({ - top: 92, - message: prex + this.state.dict['form.required.input'] + labels.join('銆�') + ' !', - duration: 3 + this.setState({ + loading: false }) return } else if (this.props.Tab.supMenu && !BID) { // 涓昏〃ID涓嶅瓨鍦ㄦ椂锛屼笉鏌ヨ瀛愯〃 diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index fc1d490..9fb5fdc 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -330,13 +330,8 @@ } if (requireFields.length > 0) { - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - - notification.warning({ - top: 92, - message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', - duration: 3 + this.setState({ + loading: false }) return } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 056869e..1fbf809 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -693,6 +693,20 @@ if (!err) { values = this.addHideFieldValue(values) let searches = this.getFieldsValues(values) + + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + let labels = requireFields.map(item => item.label) + labels = Array.from(new Set(labels)) + + notification.warning({ + top: 92, + message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', + duration: 3 + }) + return + } + this.props.refreshdata(searches) } }) @@ -704,6 +718,12 @@ if (!err) { values = this.addHideFieldValue(values) let searches = this.getFieldsValues(values) + + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + return + } + this.props.refreshdata(searches) } }) @@ -735,6 +755,20 @@ this.setState({}, () => { values = this.addHideFieldValue(values) let searches = this.getFieldsValues(values) + + let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + if (requireFields.length > 0) { + let labels = requireFields.map(item => item.label) + labels = Array.from(new Set(labels)) + + notification.warning({ + top: 92, + message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', + duration: 3 + }) + return + } + this.props.refreshdata(searches) }) } -- Gitblit v1.8.0