{…params.query, … { localCacheKey: localKey } }

1、localCacheKey如果设置了,会把结构数据存储在本地,frowWs表示来自websoket请求

 that.$bsAjax.getBridge(
            params.mkey,
            params.field, {
                ...params.query,
                ... {
                    _localCacheKey: localKey,
                    _frowWs: options.frowWs
                }
            },
            params.type
        ).then((res) => {
let thisT = this;

        const params = {
            userId: (that.$loginAuth.getUser() || {}).userId,
            mkey: that.meta.mkey,
            field: that.meta.field,
            query: {
                _menuId: that.meta.menuId
            },
            type: "page"
        }
        const localKey = that.$crypto.md5(JSON.stringify(params));
        let dataC = null;
        if (that.fromWs !== true) {
            dataC = that.$localStorage.getLocalStore(localKey);
        }

if (res.data && res.data.data && res.data.success === true) {
                that.$localforageCache.setItem(localKey, {
                    data: res.data,
                    // eslint-disable-next-line no-undef
                    timestamp: dayjs().valueOf()
                }).then(function(value) {
                    that.$localStorage.setLocalStore(localKey, true);
                }).catch(function(err) {
                    console.log(err);
                });
            }

    this.onWsWsPull();
,
    /* eslint-disable */
    // #region websoket
    onWsWsPull() {
      let that = this;
      that.$reqWs.pull(
        (res) => {        
          $methodBridge.loadBridgeData(that, {...that.currentTempV,...{fromWs:true}});
        },
        {
          ownerId: that.$store.getters.ownerId,
          mkey: that.config.response.mkey,
          subBeforeKey: "bridge",
        }
      );
    },
    // #endregion websoket


   const localKey = that.$crypto.md5(JSON.stringify(params));
        let dataC = null;
        if (item.fromWs !== true) {
            dataC = that.$localStorage.getLocalStore(localKey);
        }
        if (dataC) {
            that.loading = true;
            that.$localforageCache.getItem(localKey).then(function(value) {
                thisT.doConvert(that, item, { data: value.data });
                that.loading = false;
            }).catch(function(err) {
                console.log(err);
                that.loading = false;
            });
            console.log('loadBridgeData-cache');
            return;
        }
/* eslint-disable no-unused-vars */
export default {
    handleLoadTableBridge(that) {
        //加载配置数\据
        that.config.table.attrs.loading = true;
        let thisT = this;

        const params = {
            userId: (that.$loginAuth.getUser() || {}).userId,
            mkey: that.meta.mkey,
            field: that.meta.field,
            query: {
                _menuId: that.meta.menuId
            },
            type: "page"
        }
        const localKey = that.$crypto.md5(JSON.stringify(params));
        let dataC = null;
        if (that.fromWs !== true) {
            dataC = that.$localStorage.getLocalStore(localKey);
        }
        if (dataC) {
            that.config.table.attrs.loading = true;
            that.$localforageCache.getItem(localKey).then(function(value) {
                thisT.doConvert(that, { data: value.data });
                that.config.table.attrs.loading = false;
            }).catch(function(err) {
                console.log(err);
                that.config.table.attrs.loading = false;
            });
            console.log('loadBridgeDataBoTable-cache');
            return;
        }

        that.$bsAjax.getBridge(
            params.mkey,
            params.field,
            params.query,
            params.type
        ).then((res) => {
            if (res.data && res.data.data && res.data.success === true) {
                that.$localforageCache.setItem(localKey, {
                    data: res.data,
                    // eslint-disable-next-line no-undef
                    timestamp: dayjs().valueOf()
                }).then(function(value) {
                    that.$localStorage.setLocalStore(localKey, true);
                }).catch(function(err) {
                    console.log(err);
                });
            }
            //执行结果处理
            thisT.doConvert(that, res);
            that.config.table.attrs.loading = false;
        }).catch(res => {
            that.config.table.attrs.loading = false;
        });

        //处理进度条没有隐藏问题
        that.hanldeHideLoading();

        //通知根组件数据需要变更
        if (that.onCallbackRootData) {
            that.onCallbackRootData(thatRoot => {
                thatRoot.primaryActionChangeState = that.$verifyGuid.guid();
            })
        }
    },
    doConvert(that, res) {
        if (!res.data || !res.data.data || res.data.success !== true) {
            that.config.table.attrs.loading = false;
            return;
        }

        that.config.table.attrs.loading = false;
        that.config.table = res.data.data.table;
        that.config.search = res.data.data.search;
        that.config.primaryId = res.data.data.primaryId;

        //通知根组件数据需要变更  设置主键字段
        if (that.onCallbackRootData) {
            that.onCallbackRootData(thatRoot => {
                thatRoot.value.primaryId = that.config.primaryId;
            })
        }
        // that.rowKey=that.config.primaryId[0].field;
        that.$emit("on-menu-func", res.data.data.menuFunc || {});
        that.handleSetTableOptions();
        if (that.dataFishBridge === false) {
            that.dataFish = that.dataFish + 1;
            that.dataFishBridge = true;
        }
    }
}
文档更新时间: 2021-11-15 11:14   作者:admin