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

export default {
    methods: {
        async handleSearch() {
            console.log("serach......");

            let opndatfrom = this.model.infcon.opndatfrom;
            if (!opndatfrom || opndatfrom == "") {
                this.$notify.error({
                    title: this.$t("financing.错误"),
                    message: this.$t("financing.查询开始日期必输!"),
                });
                return;
            }
            let opndatto = this.model.infcon.opndatto;
            if (!opndatto || opndatto == "") {
                this.$notify.error({
                    title: this.$t("financing.错误"),
                    message: this.$t("financing.查询结束日期必输!"),
                });
                return;
            }

            this.load = true;
            let rtnmsg = await Api.post("/funds/fxdsel/query", {
                ...this.model.infcon,
                dir: ">",
                pageNum: this.pagination.pageNum,
                pageSize: this.pagination.pageSize,
                opndatfrom: moment(opndatfrom).format("YYYY-MM-DD"),
                opndatto: moment(opndatto).format("YYYY-MM-DD"),
            });
            if (rtnmsg.respCode == SUCCESS) {
                this.load = false;
                this.stmData.data = [];
                this.stmData.data = rtnmsg.data.list;
                this.pagination = {
                    pageNum: rtnmsg.data.pageNum || 1,
                    pageSize: rtnmsg.data.pageSize || 10,
                    total: rtnmsg.data.total,
                };
            } else {
                this.$notify.error({
                    title: this.$t("financing.错误"),
                    message: this.$t("financing.服务请求失败!"),
                });
            }
            this.load = false;
        },
        async handleReset() {
            this.model.infcon.seaownref = "";
            this.model.infcon.opndatfrom = new Date();
            this.model.infcon.opndatto = new Date();
            this.model.infcon.nam = "";
            this.model.infcon.seacur = "";
            this.model.infcon.eaamtfr = "";
            this.model.infcon.eaamtto = "";

            this.model.infcon.ownusr = "";
            this.model.infcon.usr = "";
            this.model.infcon.acc = "";
            this.model.infcon.acc2 = "";

            this.model.infcon.searef = "";
            this.model.infcon.ptyextkey = "";
            this.model.infcon.ptynam = "";
            this.model.infcon.seapty = "";
            this.model.infcon.searol = "";
            this.model.infcon.usrextkey = "";
            this.model.infcon.seasta = "";
            this.model.infcon.accmng = "";
            this.model.infcon.fxtyp = "";
        },
        // pageSize改变
        handleSizeChange(val) {
            this.pagination.pageNum = 1;
            this.pagination.pageSize = val;
            this.handleSearch();
        },
        // 页码改变
        handleCurrentChange(val) {
            this.pagination.pageNum = val;
            this.handleSearch();
        },

        //进入即期结汇交易
toFxtssb() {
    this.routerPush({
        path: '/business/fxtssb',
    });
},
//进入即期售汇交易
toFxtsss() {
    this.routerPush({
        path: '/business/fxtsss',
    });
},
//进入结售汇平盘登记交易
toFxtlop() {
    this.routerPush({
        path: '/business/fxtlop',
    });
},
//进入外币兑换平盘登记交易
toFxtfop() {
    this.routerPush({
        path: '/business/fxtfop',
    });
},

        
    },
};