import {deviceDetailInfo} from "@/api/dev/deviceInfoApi";

let query = {
    page: 1,
    limit: 10,
    productName: null,
    deviceCode: null,
    planId: null,
}
export default {
    name: "planChooseDevice",
    props: {planId: {required: true}, selectChangeFunc: {required: true, type: Function}},
    data() {
        return {
            showSearch:true,
            loading: false,
            query:{...query},
            list: [],
            total:0,
        }
    },
    created(){
        this.query = {...query,planId:this.planId}
        this.getList()
    },
    methods: {
        onReset(){
            this.query = {...query,planId:this.planId}
            this.getList()
        },
        getList() {
            this.loading = true
            deviceDetailInfo(this.query)
                .then((res) => {
                    this.loading = false
                    if(res.code!=20000){
                        this.$message.error(res.message)
                        return
                    }
                    this.list = res.data.list || [];
                    this.total = res.data.total || 0;
                })
                .catch(() => {
                    this.loading = false
                    this.list =  [];
                    this.total =  0;
                });
        },
    },
}
