确认删除框

that.$msgBox
        .confirm({ message: "确认要删除吗" })
        .then(() => {

              that.$store.dispatch("dataLoading", true);

        })
        // eslint-disable-next-line no-unused-vars
        .catch(() => {
          that.$store.dispatch("dataLoading", false);
          //cancel
        });

提示框

that.$msgBox

import store from "../store/index";
let MsgBox = {
  // 删除 system
  alert(message) {

  },
  success(message) {

  },
  warning(message) {

  },
  error(message) {

  },
  confirm(msg) {
  }
};

列表


    options: {
        rootMeta: {
            mkey: "bt-policy",
            field: "manager",
        },
        filter: {
            _menuId: "bt-t-deve-bt-202e6",
            _nodejs: "common-data",
        },
    },

      doctor: {
        data: [],
        value: null,
        name: null,
        loading: false,
        firstLoad:false,
        descriptionEmpty: "数据加载中"
      },
 /* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
export default {
    init(that) {
      this.loadDataDoctor(that);
    },
    loadDataDoctor(that) {
        //过滤条件
        let filterT = {
            pageSize: 2
        };
        filterT = {
            ...filterT,
            ...that.filter
        };
        let metaT =  {
            mkey: "insurance-resource",
            field: "doctor",
          };

        if (that.doctor.firstLoad === true) {
            that.doctor.descriptionEmpty = null; // window.$appConfig.empty.init;
        }
        that.loading = true;
        that.doctor.loading = true;
        that.$bsAjax.getList(metaT.mkey, metaT.field, filterT).then((res) => {
            that.doctor.firstLoad = false;
            that.doctor.descriptionEmpty = window.$appConfig.empty.nodata;
            //debugger;
            if (!res.data || !res.data.data || res.data.success !== true) {
                that.loading = false;
                that.doctor.loading = false;
                return;
            }
            that.doctor.data = res.data.data;

            that.doctor.firstLoad = false;
            that.loading = false;
            that.doctor.loading = false;
        });
    },
}

简单分页

/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
export default {
    options: {

    },
    init(that) {

    },
    loadDataComm(that) {
        //过滤条件
        let filterT = {
            // pageSize: 4
        };
        filterT = {
            ...filterT,
            ...that.filter
        };
        let metaT = that.rootMeta;

        if (that.firstLoad === true) {
            that.used.descriptionEmpty = null; // window.$appConfig.empty.init;
        }
        that.loading = true;
        that.$bsAjax.getPage(metaT.mkey, metaT.field, filterT).then((res) => {
            that.used.firstLoad = false;
            that.used.descriptionEmpty = window.$appConfig.empty.nodata;
            //debugger;
            if (!res.data || !res.data.data || res.data.success !== true) {
                that.used.loading = false;
                return;
            }
            that["tag"] = [];
            that.used.data = res.data.data;
            let obj = {};
            that.used.paging = res.data.paging;

            that.used.firstLoad = false;
            that.used.loading = false;
        }).catch(() => {
            that.used.firstLoad = false;
            that.used.loading = false;
        });
    },
}

分页

 loadDataComm(that) {
        //过滤条件
        let filterT = {
            // pageSize: 4
            //  mercId: that.$route.query.mercId
        };
        filterT = {
            ...filterT,
            ...that.filter
        };
        let metaT = that.rootMeta;

        if (that.firstLoad === true) {
            that.descriptionEmpty = null; // window.$appConfig.empty.init;
        }
        that.loading = true;
        that.$bsAjax.getPage(metaT.mkey, metaT.field, filterT).then((res) => {
            that.firstLoad = false;
            that.descriptionEmpty = window.$appConfig.empty.nodata;
            //debugger;
            if (!res.data || !res.data.data || res.data.success !== true) {
                that.loading = false;
                return;
            }
            that["tag"] = [];
            that.used.data = [...that.used.data, ...res.data.data];
            let obj = {};
            that.used.data = that.used.data.reduce((cur, next) => {
                obj[next.policyId] ? "" : obj[next.policyId] = true && cur.push(next);
                return cur;
            }, [])

            that.used.paging = res.data.paging;
            that.pullToBottom.finished = that.filter.pageIndex >= that.used.paging.totalPage;

            if (!that.pullToBottom.finished) {
                that.pullToBottom.finished = false;
                that.pullToBottom.loading = false;
            } else {
                that.pullToBottom.finished = true;
                that.pullToBottom.loading = false;
            }
            // if (that.used.paging.pageIndex === that.used.paging.totalPage) {
            //     that.pullToBottom.finished = true; //
            // }
            // that.pullToBottom.finished = true; //
            that.firstLoad = false;
            that.loading = false;
        });
    },

局部修改

  onSubmitModify(that, params) {
        let dataT = params;
        let rootMetaT = that.rootMeta;
        let filterT = that.filter;
        that.$store.dispatch("dataLoading", true);
        that.$bsAjax
            .doMofify(rootMetaT.mkey, rootMetaT.field + "_detail", filterT, dataT)
            .then((tempRes) => {
                that.$store.dispatch("dataLoading", false);
                if (tempRes && tempRes.data && tempRes.data.success === true) {
                    that.$msgBox.success(tempRes.data.message);
                    //重新更新数据
                    if (params["isEnabled"]) {
                        that.used.data[params.rowIndex]["isEnabled"].value = params["isEnabled"];
                    }
                    that.used.data = JSON.parse(JSON.stringify(that.used.data));
                }
            });
    },

删除


    onSubmitDel(that, params) {
        let dataT = {
            policyId: params.policyId,
            batO: "d"
        };
        let rootMetaT = that.rootMeta;
        let filterT = that.filter;


        that.$msgBox
            .confirm({
                message: "确认要删除吗"
            })
            .then(() => {

                that.$store.dispatch("dataLoading", true);
                that.$bsAjax
                    .doDelete(rootMetaT.mkey, "manager", filterT, dataT)
                    .then((tempRes) => {
                        that.$store.dispatch("dataLoading", false);
                        if (tempRes && tempRes.data.success === true) {
                            that.$msgBox.success(tempRes.data.message);
                            //重新更新数据
                            that.onRefresh();


                            // that.used.data = JSON.parse(JSON.stringify(that.used.data));
                        }
                    });
            })
            // eslint-disable-next-line no-unused-vars
            .catch(() => {
                that.$store.dispatch("dataLoading", false);
                //cancel
            });




    }

添加


 onSubmitAdd(values, that) {
        if (that.changeField.changed !== true) {
            that.$msgBox.error("无数据变更.");
        } else {
            let dataT = that.changeField;
            let rootMetaT = methodComp.options.rootMeta;
            let filterT = methodComp.options.filter;
            //需要处理的代码 start
            dataT["policyId"] = null;
            //dataT.isEnabled = {
            //    name: "启用",
            //    value: 1
            //};
            //dataT.auditStatus = {
            //    name: "待审核",
            //    value: 0
            //};
            //数据保存加密
            if (that.data.bdBbrIdcard) {
                dataT.bdBbrIdcard = that.$crypto.encryptByDES(that.data.bdBbrIdcard);
            }
            if (that.data.bdTbrIdcard) {
                dataT.bdTbrIdcard = that.$crypto.encryptByDES(that.data.bdTbrIdcard);
            }
            dataT.bdExpand = JSON.stringify(that.data.bdExpand || {});
            if (dataT.checklist) {
                dataT.checklist.forEach(element => {
                    element.description = JSON.stringify(element.description || {});

                });
            }

            //需要处理的代码 end
            that.$store.dispatch("dataLoading", true);
            let thisC = this;
            that.$bsAjax
                .doAdd(rootMetaT.mkey, rootMetaT.field + "_detail", filterT, dataT)
                .then((tempRes) => {
                    that.$store.dispatch("dataLoading", false);
                    if (tempRes && tempRes.data && tempRes.data.success === true) {
                        that.$msgBox.success(tempRes.data.message);
                        that.$refs["refCompSave"].resetChangeField();
                        //结果数据处理  清空数据
                        that.data = JSON.parse(JSON.stringify(methodComp.dataTemp));
                    }
                    //通知子组件数据变更
                    that.value.primaryChangeState = that.$verifyGuid.guid();
                    //清空数据避免错误
                    that.changeField = {};
                    that.changeField = JSON.parse(JSON.stringify(that.changeField));
                });
        }
    },

修改

  onSubmitEdit(values, that) {
        if (that.changeField.changed !== true) {
            that.$msgBox.error("无数据变更.");
        } else {
            let dataT = that.changeField;
            // debugger;
            let rootMetaT = methodComp.options.rootMeta;
            let filterT = methodComp.options.filter;
            // dataT.mercId = null;
            //需要处理的代码 start
            dataT["policyId"] = that.$route.query["policyId"];
            //数据保存加密

            if (that.data.bdBbrIdcard) {
                dataT.bdBbrIdcard = that.$crypto.encryptByDES(that.data.bdBbrIdcard);
            }
            if (that.data.bdTbrIdcard) {
                dataT.bdTbrIdcard = that.$crypto.encryptByDES(that.data.bdTbrIdcard);
            }
            dataT.bdExpand = JSON.stringify(that.data.bdExpand || {});
            if (dataT.checklist) {
                dataT.checklist.forEach(element => {
                    element.description = JSON.stringify(element.description || {});

                });
            }

            //需要处理的代码 end
            that.$store.dispatch("dataLoading", true);
            that.$bsAjax
                .doEdit(rootMetaT.mkey, rootMetaT.field + "_detail", filterT, dataT)
                .then((tempRes) => {
                    that.$store.dispatch("dataLoading", false);
                    if (tempRes && tempRes.data && tempRes.data.success === true) {
                        that.$msgBox.success(tempRes.data.message);

                        //结果数据处理  清空数据
                        that.data = JSON.parse(JSON.stringify(methodComp.dataTemp));
                        that.$refs["refCompSave"].resetChangeField();
                        //重新加载数据,如果存在数据重复情况,考虑使用
                        methodComp.loadDetail(that);
                    }
                    //通知子组件数据变更
                    that.value.primaryChangeState = that.$verifyGuid.guid();
                    //清空数据避免错误     
                    that.changeField = JSON.parse(JSON.stringify(that.changeField));

                });
        }
    },
文档更新时间: 2023-03-15 16:26   作者:admin