export default {
    props: {
        type: {
            type: Number,
            default: 1
        }
    },
    data() {
        return {
            list: [],
            editInfo: {},
            queryParams: {
                pageSize: 10,
                pageNum: 1,
            },
            total: 0,
        }
    },
    methods: {
        onRefresh() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        getList() {
            uni.$u.api.inquiryVerificationList(this.queryParams, {
                type: this.type,
            }).then(res => {
                if (this.queryParams.pageNum === 1) {
                    this.list = res.rows;
                } else {
                    this.list = this.list.concat(res.rows);
                }
                this.total = res.total;
            })
        },
        loadMore(){
            if (this.list.length >= this.total) {
                uni.$u.toast('没有更多了');
                return;
            }
            this.queryParams.pageNum++;
            this.getList();
        },
        formtterStatus(status) {
            if(this.type == 1){
                return status == '1' ? '待询价' : '询价完成'
            }
            if(this.type == 2){
                return status == '1' ? '待核价' : '核价完成'
            }
        },
        handleClick(item) {
            this.editInfo = item;
            this.$nextTick(() => {
                this.$refs.addInquiryDialog.showDialog();
            })
        },
        handleInquirySuccess() {
            this.$refs.addInquiryDialog.closeDialog();
        },
        handleInquiryCancel() {
            this.queryParams.pageNum = 1;
            this.getList();
            this.$refs.addInquiryDialog.closeDialog();
        },
    }
}