import Api from "~/service/Api";
import moment from "moment";

export default {
  methods: {
    async handleSearch() {
      let rcvdatsta = this.model.sndp.rcvdatsta;
      if (!rcvdatsta || rcvdatsta == "") {
        this.$notify.error({
          title: this.$t("financing.错误"),
          message: this.$t("financing.查询开始日期必输!"),
        });
        return;
      }
      let rcvdatend = this.model.sndp.rcvdatend;
      if (!rcvdatend || rcvdatend == "") {
        this.$notify.error({
          title: this.$t("financing.错误"),
          message: this.$t("financing.查询结束日期必输!"),
        });
        return;
      }

      this.load = true;
      let rtnmsg = await Api.post("/frontend/msgsel/query", {
        ...this.model.sndp,
        dir: ">",
        pageNum: this.pagination.pageNum,
        pageSize: this.pagination.pageSize
      });
      if (rtnmsg.respCode == SUCCESS) {
        this.load = false;
        this.stmData.data = [];
        const { list } = rtnmsg.data;
        this.stmData.data = list;
        this.pagination = {
          pageNum: rtnmsg.data.pageNum || 1,
          pageSize: rtnmsg.data.pageSize || 10,
          total: parseInt(rtnmsg.data.total),
        };
      } else {
        this.$notify.error({
          title: this.$t("financing.错误"),
          message: this.$t("financing.服务请求失败!"),
        });
      }
      this.load = false;
    },
    async handleReset() {
      this.model.sndp.msgtyp = "";
      this.model.sndp.rcvdatsta = new Date();
      this.model.sndp.rcvdatend = new Date();
      this.model.sndp.subtyp = "";
      this.model.sndp.sndbak = "";
      this.model.sndp.revbak = "";
      this.model.sndp.actbic = "";
      this.model.sndp.othref = "";
      this.model.sndp.ownref = "";
      this.model.sndp.cur = "";
      this.model.sndp.act = "";
      this.model.sndp.amtmin = "";
      this.model.sndp.amtmax = "";
      this.model.sndp.chnipt = "";
      this.model.sndp.rspsta = "";
      this.model.sndp.dtlchg = "";
      this.model.sndp.sta = "";
    },
    // pageSize改变
    handleSizeChange(val) {
      this.pagination.pageNum = 1;
      this.pagination.pageSize = val;
      this.handleSearch();
    },
    // 页码改变
    handleCurrentChange(val) {
      this.pagination.pageNum = val;
      this.handleSearch();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    addClick() {
      this.addDialogVisiable = true;
    },
    handleClose() {
      this.addDialogVisiable = false;
    },
    handleOn() {
      this.addDialogVisiable = false;
    },
    fentanClick() {
      this.dialogVisible = true;
    },
    closeDialogOpen() {
      this.dialogVisible = false;
    },
    testClick() {
      this.addDialogVisiable1 = true
    }
  },
};