<template src='./cncTestLists.html'>
</template>

<script>
    import HeaderMain from "../../components/HeaderMain";
    import api from '../../api/editor'
    export default {
        components: {
            HeaderMain
        },
        data() {
            return {
                houseList: [],
                value: '',
                isShowDialog: false,
                pageModel: null,
                loading: true,
                currentProject: "所属项目",
                currentProjectHouseId: "",
            }
        },
        created() {
            this.houseList = [];
            api.houseList().then((res) => {
                if (res.success) {
                    this.houseList = res.list;
                }
            });

            this.getCncTestcaseList();
        },
        methods: {
            getCncTestcaseList() {
                let data = {
                    "houseId": this.currentProjectHouseId,
                    "pageNo": 1,
                    "pageSize": 20,
                    "uid": ""
                }
                api.cncTestcaseList(data).then((res) => {
                    if (res.success) {
                        this.pageModel = res.pageModel;
                    }
                })
            },
            cncTestDetail(testcaseId) {
                let data = {
                    "testcaseId": testcaseId,
                }
                api.cncTestDetail(data).then((res) => {
                    if (res.success) {
                       console.log("cncTestDetail",res)
                    }
                })
            },
            showQRDialog(testcaseId) {
                this.isShowDialog = true;
                this.loading = true;
                this.cncTestDetail(testcaseId);
                setTimeout(() => {
                    this.$refs.dialogQR.scroll(0, 0)
                }, 1);
                setTimeout(() => {
                    this.loading = false;
                }, 3000);
            },
            close() {
                this.isShowDialog = false;
            },
            handleCommand(command) {
                this.houseList.forEach(element => {
                    if (element.houseId === command) {
                        this.currentProject = element.houseName;
                        this.currentProjectHouseId = element.houseId;
                        this.getCncTestcaseList();
                        return true
                    } else {
                        this.currentProjectHouseId = "";
                        return false
                    }
                });

            }
        },
    }
</script>
<style lang="scss" scoped>
    @import './cncTestLists.scss';
</style>