whychdw
2021-06-03 2baa58f9515a661d53118344e237e3441300b24f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
    <div class="el-dialog-wrapper">
        <el-dialog
            :visible.sync="pointDialog" class="position-absolute dialog-center dialog-no-header" width="840px"
            top="0" :modal="false" :destroy-on-close="true" :close-on-press-escape="false" :close-on-click-modal="false"
            :modal-append-to-body="false">
            <point-test :point="point" :type="type" @proceedTest="proceedTest" :end="endTest"></point-test>
        </el-dialog>
        <el-dialog
            :visible.sync="resultDialog" class="position-absolute dialog-center dialog-no-header" width="840px"
            top="0" :modal="false" :destroy-on-close="true" :close-on-press-escape="false" :close-on-click-modal="false"
            :modal-append-to-body="false">
            <point-result-test :point="prePoint" @preStep="preStep" @nextStep="nextStep" @completeTest="completeTest" :end="endTest"></point-result-test>
        </el-dialog>
        <complete-test-dialog :visible.sync="completeDialog" :type="type"></complete-test-dialog>
    </div>
</template>
 
<script>
import PointTest from "@/pages/test/dialog/pointTest";
import PointResultTest from "@/pages/test/dialog/pointResultTest";
import {startPointTest, completeTest} from "@/pages/test/js/api";
import CompleteTestDialog from "@/pages/test/dialog/completeTestDialog";
export default {
    name: "testStepDialog",
    components: {CompleteTestDialog, PointResultTest, PointTest},
    props: {
        type: {
            type: String,
            default: ""
        },
        step: {
            type: [Number, String],
            default: -1
        },
        list: {
            type: Array,
            default(){
                return []
            }
        },
        end: {
            type: Boolean,
            default: false,
        },
        progress: {
            type: Boolean,
            default: false,
        }
    },
    watch: {
        step() {
            this.checkStep();
        },
        end() {
            this.checkStep();
        },
        progress() {
            this.checkStep();
        }
    },
    data() {
        return {
            pointDialog: false,
            resultDialog: false,
            prePoint: {},
            point: {},
            endTest: false,
            completeDialog: false,
        }
    },
    methods: {
        checkStep() {
            if(this.step != -1 && !this.progress) {
                this.changeDialog();
            }
        },
        changeDialog() {
            this.point = this.list[this.step];
            if(this.step == 0) {
                this.pointDialog = true;
            }else if(this.end) {
                this.prePoint = this.list[this.step];
                this.endTest = true;
                this.resultDialog = true;
            } else{
                this.prePoint = this.list[this.step-1];
                this.resultDialog = true;
            }
        },
        preStep() {
            this.resultDialog = false;
            this.endTest = false;
        },
        nextStep() {
            this.resultDialog = false;
            this.pointDialog = true;
        },
        proceedTest(data) {
            this.pointDialog = false;
            startPointTest(data).then(res=>{
                let rs = res.data;
                if(rs.code == 1) {
                    console.log(rs.data);
                }
            }).catch(error=>{
                console.log(error);
            });
        },
        completeTest(data) {
            completeTest(data.experimentId).then(res=>{
                let rs = res.data;
                if(rs.code == 1) {
                    this.resultDialog = false;
                    this.completeDialog = true;
                }else {
                    this.$layer.msg("完成试验失败!");
                }
            }).catch(error=>{
 
            });
        }
    },
    mounted() {
        this.checkStep();
    }
}
</script>
 
<style scoped>
 
</style>