data 公共分页部分


        //===========公共分页部分  start
        data() {
            return {
                filter: {
                    word: null
                },
                userActions: [],
                descriptionEmpty: "数据加载中",
                firstLoad: true,
                loading: false,
                used: {
                    data: [],
                    paging: {
                        totalCount: 0,
                        totalPage: 0
                    }
                },
                pullToBottom: {
                    loading: true,
                    finished: false,
                    error: false,
                    errorText: "请求失败,点击重新加载",
                    finishedText: "没有更多了",
                }
            };
        },
        //===========公共分页部分 end

method 1


  querySearch(queryString, cb) {
        var restaurants = this.options;
        let that = this;
        //#region  元配置信息
        let rootMeta = {
          mkey: that.item.attrs['remote-mkey'],
          field: that.item.attrs['remote-res-field'],
          url: that.item.attrs['remote-url'],
        };
        let filterO = {
          _menuId: that.item.attrs['remote-menuId'] || '',
          _nodejs: that.item.attrs['remote-nodejs'] || "common-data",
          pageSize: 50
        };
        //#endregion 元配置信息
        that.used.data=[];
        // 数据二次处理
        const callback = (thatN, dataColN, methodDataN) => {
          // thisT.callbackMyBiz(thatN, dataColN, methodDataN); 
          const field = that.item.attrs['remote-data-field'];
          if((thatN.used.data||[]).length===0){
            thatN.$msgBox.error(`关键字【${queryString}】,未查询到数据。`);
            cp([]);
            return;
          }
          cb(field ? thatN.used.data.map(temp => {
            temp.value = temp[field || 'value'];
            return temp;
          }) : thatN.used.data);
        }
        that.filter[that.item.attrs['remote-query-field']] = queryString;
        //#region 内置扩展条件
        if (that.item.attrs['remote-params']) {
          that.item.attrs['remote-params'].split('|').forEach(temp => {
            if (temp && temp.includes(':')) {
              that.filter[temp.split(':')[0]] = temp.split(':')[1];
            }
          });
        }
        //#endregion 内置扩展条件
        that.$bsAjax.getBizPage(that, {
          options: {
            // 如果多个需要
            primarys: [{ field: that.item.attrs['remote-primary-field'] }],
            rootMeta: rootMeta, filter: filterO,
          },
        }, { ...that.filter, ...filterO }, rootMeta, {}, callback);
        // 调用 callback 返回建议列表的数据
      },

method 2

/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
// 搜索结果,查找带回添加到子表
export default {
    init(that) {
        that.used.data = [];
        this.loadDataComm(that);
    },
    /**
     * @param {*} that 
     * @param {外部扩展过滤参数} filter 
     * @param {外部扩展meta元素} meta 
     * @param {description/loading/data} dataCol 
     */
    loadDataComm(that) {
        this.querySearch(that, that.filter.word, (data => {
            console.log(data);
        }));
    },
    querySearch(that, queryString, cb) {
        // var restaurants = this.options;
        // let that = this;
        //#region  元配置信息
        let rootMeta = {
            mkey: 'his-codex', //that.item.attrs['lookup-add-remote-mkey'],
            field: 'manager',// that.item.attrs['lookup-add-remote-res-field'],
            url: that.item.attrs['lookup-add-remote-url'],
        };
        let filterO = {
            _menuId: that.item.attrs['lookup-add-remote-menuId'] || '',
            _nodejs: that.item.attrs['lookup-add-remote-nodejs'] || "common-data",
            pageSize: 50
        };
        //#endregion 元配置信息
        that.used.data = [];
        // 数据二次处理
        const callback = (thatN, dataColN, methodDataN) => {
            // thisT.callbackMyBiz(thatN, dataColN, methodDataN); 
            const field = that.item.attrs['lookup-add-remote-data-field'];
            if ((thatN.used.data || []).length === 0) {
                thatN.$msgBox.error(`关键字【${queryString}】,未查询到数据。`);
                cp([]);
                return;
            }
            cb(field ? thatN.used.data.map(temp => {
                temp.value = temp[field || 'value'];
                return temp;
            }) : thatN.used.data);
        }
        that.filter[that.item.attrs['lookup-add-remote-query-field']] = queryString;
        //#region 内置扩展条件
        if (that.item.attrs['lookup-add-remote-params']) {
            that.item.attrs['lookup-add-remote-params'].split('|').forEach(temp => {
                if (temp && temp.includes(':')) {
                    that.filter[temp.split(':')[0]] = temp.split(':')[1];
                }
            });
        }
        //#endregion 内置扩展条件
        that.$bsAjax.getBizPage(that, {
            options: {
                // 如果多个需要
                primarys: [{ field: that.item.attrs['lookup-add-remote-primary-field'] }],
                rootMeta: rootMeta, filter: filterO,
            },
        }, { ...that.filter, ...filterO }, rootMeta, {}, callback);
        // 调用 callback 返回建议列表的数据
    }
}
文档更新时间: 2022-12-16 19:01   作者:admin