From 97e18fa9b628357fa43013cfefc96eec078de25e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 16 一月 2023 15:58:12 +0800 Subject: [PATCH] 2023-01-16 --- src/tabviews/custom/components/card/table-card/index.jsx | 15 ++++- src/tabviews/custom/components/carousel/data-card/index.jsx | 14 +++- src/tabviews/custom/components/card/prop-card/index.jsx | 19 +++++- src/tabviews/custom/components/carousel/prop-card/index.jsx | 19 +++++- src/tabviews/custom/components/code/sand-box/index.jsx | 15 ++++- src/tabviews/custom/components/card/balcony/index.jsx | 20 +++++- src/tabviews/custom/components/tree/antd-tree/index.jsx | 18 ++++- src/tabviews/custom/components/table/normal-table/index.jsx | 18 ++++- src/tabviews/custom/components/timeline/normal-timeline/index.jsx | 13 +++- src/tabviews/custom/components/card/data-card/index.jsx | 20 ++++-- 10 files changed, 133 insertions(+), 38 deletions(-) diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx index 2103653..bf037dd 100644 --- a/src/tabviews/custom/components/card/balcony/index.jsx +++ b/src/tabviews/custom/components/card/balcony/index.jsx @@ -31,6 +31,8 @@ checked: false } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -59,16 +61,21 @@ _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } else if (_sync && initdata) { _data = initdata if (Array.isArray(_data)) { _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { _data = window.GLOB.CacheData.get(_config.wrap.publicId) _data = fromJS(_data).toJS() + this.loaded = true + } else if (_config.wrap.datatype === 'static') { + this.loaded = true } _data.$$BID = BID || '' @@ -127,7 +134,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('syncBalconyData', this.syncBalconyData) @@ -144,9 +151,9 @@ this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return let _data = res[0] _data.$$uuid = _data[config.setting.primaryKey] || '' @@ -192,6 +199,9 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.loaded = true + this.setState({sync: false, data: _data}) } } @@ -205,6 +215,8 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.loaded = true this.setState({data: _data}) } @@ -313,6 +325,7 @@ this.setState({ data: {$$BID: BID || '', $$BData: BData, $$empty: true}, }) + this.loaded = true return } @@ -331,6 +344,7 @@ if (result.status) { let _data = {} + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 59573bf..7a4dd46 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -46,6 +46,8 @@ supComs: null } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -102,10 +104,10 @@ let _data = null let _sync = _config.setting.sync === 'true' - if (_config.setting.sync === 'true' && data) { + if (_sync && data) { _data = data[_config.dataName] || [] _sync = false - } else if (_config.setting.sync === 'true' && initdata) { + } else if (_sync && initdata) { _data = initdata || [] _sync = false } @@ -173,6 +175,8 @@ _config.wrap.wrapClass = `${_config.wrap.selStyle} ${_config.wrap.cardType || ''} ${_config.wrap.scale}` + this.loaded = _data !== null + this.setState({ supComs, selected, @@ -196,7 +200,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('mkCheckAll', this.mkCheckAll) @@ -215,10 +219,9 @@ }) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return - + if (!res || this.loaded) return let _data = res.map((item, index) => { item.key = index item.$$uuid = item[config.setting.primaryKey] || '' @@ -274,6 +277,8 @@ } } } + + this.loaded = true this.setState({sync: false, data: _data}) } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { @@ -548,6 +553,8 @@ const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� + this.loaded = true + this.setState({ activeKey: '', selectKeys: [], @@ -605,6 +612,7 @@ start = config.setting.pageSize * (pageIndex - 1) + 1 } + this.loaded = true if (config.$cache && pageIndex === 1) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index 0bf5812..2ad4a02 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -31,6 +31,8 @@ selected: 'false', } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -60,16 +62,21 @@ _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } else if (_sync && initdata) { _data = initdata if (Array.isArray(_data)) { _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { _data = window.GLOB.CacheData.get(_config.wrap.publicId) _data = fromJS(_data).toJS() + this.loaded = true + } else if (_config.wrap.datatype === 'static') { + this.loaded = true } _data.$$BID = BID || '' @@ -157,7 +164,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) @@ -173,9 +180,9 @@ this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return let _data = res[0] _data.$$uuid = _data[config.setting.primaryKey] || '' @@ -221,6 +228,8 @@ _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' + this.loaded = true + this.setState({sync: false, data: _data}, () => { if (selected !== 'false') { this.checkTopLine() @@ -245,6 +254,8 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.loaded = true this.setState({data: _data}, () => { if (selected !== 'false') { @@ -371,6 +382,7 @@ this.setState({ data: {$$BID: BID || '', $$BData: BData, $$empty: true}, }) + this.loaded = true return } @@ -394,6 +406,7 @@ if (result.status) { let _data = {} + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index 9ac25a4..5629e18 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -34,6 +34,8 @@ BData: '' } + loaded = false + /** * @description 鍒濆鍖栧鐞� * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦 @@ -104,6 +106,8 @@ _config.wrap.pagestyle = _config.wrap.pagestyle || 'page' + this.loaded = _data !== null + this.setState({ sync: _sync, BID: BID || '', @@ -122,7 +126,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) @@ -140,9 +144,9 @@ }) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return let _data = res.map((item, index) => { item.key = index @@ -192,6 +196,8 @@ item.$Index = index + 1 + '' return item }) + + this.loaded = true this.setState({sync: false, data: _data}) } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { @@ -278,6 +284,8 @@ data: [], total: 0 }) + + this.loaded = true return } @@ -312,6 +320,7 @@ start = config.setting.pageSize * (pageIndex - 1) + 1 } + this.loaded = true if (config.$cache && pageIndex === 1) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/carousel/data-card/index.jsx b/src/tabviews/custom/components/carousel/data-card/index.jsx index 966e472..90e9116 100644 --- a/src/tabviews/custom/components/carousel/data-card/index.jsx +++ b/src/tabviews/custom/components/carousel/data-card/index.jsx @@ -32,6 +32,8 @@ visible: false } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -62,6 +64,7 @@ } if (_data) { + this.loaded = true _data = _data.map((item, index) => { item.key = index item.$$uuid = item[_config.setting.primaryKey] || '' @@ -117,7 +120,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) @@ -130,9 +133,9 @@ }) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return let _data = res.map((item, index) => { item.key = index @@ -167,6 +170,8 @@ item.$Index = index + 1 return item }) + + this.loaded = true this.setState({sync: false, data: _data}, () => { this.openModal() @@ -271,6 +276,8 @@ data: [], loading: false }) + + this.loaded = true return } @@ -291,6 +298,7 @@ let result = await Api.genericInterface(param) if (result.status) { + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx index 3d4652c..0b5782b 100644 --- a/src/tabviews/custom/components/carousel/prop-card/index.jsx +++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx @@ -31,6 +31,8 @@ visible: false } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -51,7 +53,7 @@ BID = BData.$BID || '' } - if (_config.setting && _config.wrap.datatype === 'dynamic') { + if (_config.wrap.datatype === 'dynamic') { _sync = _config.setting.sync === 'true' if (_sync && data) { @@ -60,13 +62,17 @@ _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } else if (_sync && initdata) { _data = initdata if (Array.isArray(_data)) { _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } + } else if (_config.wrap.datatype === 'static') { + this.loaded = true } _data.$$uuid = _data[_config.setting.primaryKey] || '' @@ -117,7 +123,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) @@ -131,9 +137,9 @@ }) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return let _data = res[0] _data.$$uuid = _data[config.setting.primaryKey] || '' @@ -177,6 +183,8 @@ _data.$$uuid = _data[config.setting.primaryKey] || '' _data.$$BID = BID || '' _data.$$BData = BData || '' + + this.loaded = true this.setState({sync: false, data: _data}, () => { if (config.wrap.display === 'modal') { @@ -282,6 +290,8 @@ this.setState({ data: {$$BID: BID || '', $$BData: BData, $$empty: true} }) + + this.loaded = true return } @@ -305,6 +315,7 @@ if (result.status) { let _data = {} + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx index 0663d06..a9edce6 100644 --- a/src/tabviews/custom/components/code/sand-box/index.jsx +++ b/src/tabviews/custom/components/code/sand-box/index.jsx @@ -24,6 +24,8 @@ html: '', } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -49,12 +51,15 @@ if (_sync && data) { _data = data[_config.dataName] || {} _sync = false + this.loaded = true } else if (_sync && initdata) { _data = initdata || {} _sync = false + this.loaded = true } } else { _data = {} + this.loaded = true } if (_config.css) { @@ -84,13 +89,13 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return this.setState({data: res[0]}, () => { this.renderView() @@ -121,6 +126,8 @@ if (nextProps.data && nextProps.data[config.dataName]) { _data = nextProps.data[config.dataName] } + + this.loaded = true this.setState({sync: false, data: _data}) @@ -159,6 +166,7 @@ data: {}, loading: false }) + this.loaded = true return } @@ -180,6 +188,7 @@ if (result.status) { let _data = result.data || {} + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 1d2123d..8369017 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -45,6 +45,8 @@ statFValue: [] // 鍚堣鍊� } + loaded = false + /** * @description 鍒濆鍖栧鐞� * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦 @@ -84,15 +86,16 @@ setting.orisel = true } - if (_config.setting.sync === 'true' && data) { + if (_sync && data) { _data = data[_config.dataName] || [] _sync = false - } else if (_config.setting.sync === 'true' && initdata) { + } else if (_sync && initdata) { _data = initdata || [] _sync = false } if (_data) { + this.loaded = true _data = _data.map((item, index) => { item.key = index item.$$uuid = item[_config.setting.primaryKey] || '' @@ -205,6 +208,8 @@ if (setting.$hasSyncModule) { MKEmitter.emit('syncBalconyData', config.uuid, [], false) } + + this.loaded = true return } @@ -234,6 +239,7 @@ let result = await Api.genericInterface(param) if (result.status) { + this.loaded = true if (config.$cache && pageIndex === 1) { Api.writeCacheConfig(config.uuid, result.data || '') } @@ -648,6 +654,8 @@ } } + this.loaded = true + this.setState({sync: false, data: _data}) } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { this.setState({pageIndex: 1}, () => { @@ -661,7 +669,7 @@ } componentDidMount () { - const { config, sync, setting } = this.state + const { config, setting } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) @@ -680,9 +688,9 @@ }) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return this.setState({data: res.map((item, index) => { item.key = index diff --git a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx index 5f3a704..d8ed53e 100644 --- a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx +++ b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx @@ -32,6 +32,8 @@ description: false } + loaded = false + /** * @description 鍒濆鍖栧鐞� * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦 @@ -66,6 +68,7 @@ } if (_data) { + this.loaded = true _data = _data.map((item, index) => { item.key = index item.$$uuid = item[_config.setting.primaryKey] || '' @@ -110,7 +113,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) @@ -124,9 +127,9 @@ }) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return this.setState({data: res.map((item, index) => { item.key = index @@ -175,6 +178,8 @@ item.$Index = index + 1 + '' return item }) + + this.loaded = true this.setState({sync: false, data: _data}) } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { @@ -260,6 +265,7 @@ this.setState({ data: [], }) + this.loaded = true return } @@ -294,6 +300,7 @@ let result = await Api.genericInterface(param) if (result.status) { + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx index a8f6605..688fe7a 100644 --- a/src/tabviews/custom/components/tree/antd-tree/index.jsx +++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx @@ -34,6 +34,8 @@ selected: false // 閫変腑棣栬 } + loaded = false + UNSAFE_componentWillMount () { const { config, data, initdata } = this.props let _config = fromJS(config).toJS() @@ -52,15 +54,17 @@ BID = BData.$BID || '' } - if (config.setting.sync === 'true' && data) { + if (_sync && data) { _data = data[config.dataName] || [] _sync = false - } else if (config.setting.sync === 'true' && initdata) { + } else if (_sync && initdata) { _data = initdata || [] _sync = false } _config.wrap.contentHeight = config.wrap.title || config.wrap.searchable === 'true' ? 'calc(100% - 45px)' : '100%' + + this.loaded = _data !== null this.setState({ selected: _config.wrap.selected === 'true', @@ -92,6 +96,8 @@ _data = nextProps.data[config.dataName] || [] } + this.loaded = true + this.setState({sync: false, data: _data}, () => { this.handleData() }) @@ -107,7 +113,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) @@ -119,9 +125,9 @@ }) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return this.setState({data: res}, () => { this.handleData() @@ -175,6 +181,7 @@ }, () => { this.handleData() }) + this.loaded = true return } @@ -196,6 +203,7 @@ let result = await Api.genericInterface(param) if (result.status) { + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } -- Gitblit v1.8.0