import Api from "~/service/Api";
import moment from "moment";
import Smpsel from "../model";
import Utils from "~/utils";
export default {
  methods: {
    async handleSearch() {
      this.load = true;
      let rtnmsg = await Api.post("/frontend/smpsel", {
        ...this.model,
        pageNumber: this.pagination.pageNum,
        pageSize: this.pagination.pageSize,
      });
      if (rtnmsg.respCode == SUCCESS) {
        this.load = false;
        this.model.smpgrp.smpsub.lst = [];
        this.model.smpgrp.smpsub.lst = rtnmsg.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() {
      let resetModel = new Smpsel().data
      Utils.copyValueFromVoData(this.model, resetModel);
      this.handleSearch();
    },
    // pageSize改变
    handleSizeChange(val) {
      this.pagination.pageNum = 1;
      this.pagination.pageSize = val;
      this.handleSearch();
    },
    // 页码改变
    handleCurrentChange(val) {
      this.pagination.pageNum = val;
      this.handleSearch();
    },
  },
};