import Api from "~/service/Api"
import commonFunctions from '~/mixin/commonFunctions.js';
import operationFunc from "~/mixin/commonDepend";
export default {
	mixins: [commonFunctions, operationFunc],
	methods: {
		 handleReset() {
			this.model.ptyExtkey = "";
      this.model.opndatfrom = new Date();
      this.model.opndatto = new Date((new Date).getTime() - (7 * 24 * 60 * 60 * 1000));
			this.model.gidopentyps =[];
		},
		async handleSearch() {
      if (this.model.opndatfrom == null || this.model.opndatfrom == '') {
        this.$notify.error({ title: '错误', message: '收费开始日期必输!' });
        return;
      }
      if (this.model.opndatto == null || this.model.opndatto == '') {
        this.$notify.error({ title: '错误', message: '收费结束日期必输!' });
        return;
      }
      if (this.model.opndatfrom != null && this.model.opndatto != null) {
        if (new Date(this.model.opndatfrom).getTime() > new Date(this.model.opndatto).getTime()) {
          this.$notify.error({ title: '错误', message: '收费开始日期应小于结束日期!' });
          return
        }
        if (new Date(this.model.opndatto).getTime() - new Date(this.model.opndatfrom).getTime() > 365 * 24 * 60 * 60 * 1000 * 5) {
          this.$notify.error({ title: '错误', message: '收费时间跨度不应超过5年!' });
          return
        }
      }
      this.model.branch = JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber
			const loading = this.loading()
			let rtnmsg = await Api.post("/business/comsel/getDatasByQueryCondition",
				{
					...this.model,
					pageNum: this.pagination.pageNum,
					pageSize: this.pagination.pageSize
				});

			if (rtnmsg.respCode == SUCCESS) {
				this.comfecList = rtnmsg.data.list;
				this.pagination = {
					pageNum: rtnmsg.data.pageNum,
					pageSize: rtnmsg.data.pageSize,
					total: rtnmsg.data.total
				};
			} else {
				this.comfecList = []
				this.pagination = {
					pageNum: 1,
					pageSize: 10,
					total: 0
				};
			}
			loading.close()
		},
		formSerach(){
			this.$refs.multipleTable.clearSelection();
			this.handleSearch()
		},
		// pageSize改变
		handleSizeChange(val) {
			this.pagination.pageNum = 1;
			this.pagination.pageSize = val;
			this.handleSearch();
		},
		handleCurrentChange(val){
			this.pagination.pageNum = val
			this.handleSearch()
		}
	}
}