import commonFunctions from '../../../../mixin/commonFunctions.js';
import buildFn from './buildCommons.js';
import setmod from '~/components/business/setmod/event';
import Api from "../../../../service/Api"
import Utils from "~/utils"
import moment from 'moment'


export default {
	mixins: [commonFunctions],
	methods: {
		async getCshVoList() {
      const rtnmsg = await Api.post('/business/fctcan/getCshVoList', 
        {
          pageNum: this.pagination.pageNum,
          pageSize: this.pagination.pageSize,
          apl: this.model.fcdgrp.apl,
          errflg: this.model.errflg
        });
			if (rtnmsg.respCode === "AAAAAA") {
				this.model.cshVoList = rtnmsg.data.list || [];
        this.pagination.total = rtnmsg.data.total
			}
    },
    
    formSubmit() {
      this.getCshVoList();
    },
    // pageSize改变
    handleSizeChange(val) {
      this.pagination.pageNum = 1;
      this.pagination.pageSize = val;
      this.formSubmit();
    },
    async currentChange(num) {
      this.pagination.pageNum = num;
      this.formSubmit();
    },

		async change() {
			return new Promise(async (resolve) => {
				const rtnmsg = await Api.post('/business/fctcan/change', this.model);
				if (rtnmsg.respCode === SUCCESS) {
					resolve(rtnmsg)
				} else {
					this.$message.error(rtnmsg.respMsg);
				}
			})
    },
    
    //导出excel
    async exportExcel() {
      const loading = this.loading();
      let res = await Api.post("/business/fctcan/exportExcel", {
          ...this.model,
      });
      if (res.respCode === SUCCESS) {
          let name = moment(new Date()).format('yyyy-MM-DD HH:mm:ss');
          Utils.exportToExcel(res.data, "保证金注销_" + name + ".xlsx", "保证金注销");
      }
      loading.close();
    },
	},
};