whychdw
2021-05-26 0449db2d4d4d25a49a855d199695788c7d1ca3d2
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<template>
    <div class="flex-wrapper">
        <test-card :title="info.typeName">
            <div class="form-wrapper">
                <div class="form-item inline">
                    <label class="form-item-label">试验项目名称:</label>
                    <span class="form-item-value">{{info.projectName}}</span>
                </div>
                <div class="form-item inline">
                    <label class="form-item-label">试验创建人:</label>
                    <span class="form-item-value">{{info.username}}</span>
                </div>
                <div class="form-item">
                    <label class="form-item-label">试验创建时间:</label>
                    <span class="form-item-value">{{info.createTime}}</span>
                </div>
                <div class="form-item">
                    <label class="form-item-label">预计完成时间:</label>
                    <span class="form-item-value">{{info.endTime}}</span>
                </div>
                <div class="form-item flex">
                    <label class="form-item-label">试验类型:</label>
                    <div class="form-item-value">
                        <el-input :value="info.typeName" placeholder="试验类型" disabled></el-input>
                    </div>
                </div>
                <div class="form-item flex">
                    <label class="form-item-label">受试设备:</label>
                    <div class="form-item-value">
                        <el-checkbox readonly="readonly">设备一</el-checkbox>
                        <el-checkbox readonly="readonly">设备二</el-checkbox>
                        <el-checkbox readonly="readonly">设备三</el-checkbox>
                    </div>
                </div>
                <div class="form-item flex">
                    <label class="form-item-label">参试人员:</label>
                    <div class="form-item-value">
                        <mw-avatar>{{info.username}}</mw-avatar>
                    </div>
                </div>
            </div>
            <div class="form-footer" slot="footer">
                <el-button type="primary" size="mini" @click="goTest">进入试验</el-button>
            </div>
        </test-card>
        <test-card no-footer v-if="stepShow">
            <div slot="title" class="page-panel-title">
                <span class="title-pillar"></span>
                试验进度
            </div>
            <mw-test-step :list="list"></mw-test-step>
        </test-card>
    </div>
</template>
 
<script>
    import TestCard from "@/components/smallModule/TestCard";
    import MwAvatar from "@/components/smallModule/mwAvatar";
    import MwTestStep from "@/components/smallModule/mwTestStep";
    import {
        getExitTest,
        experimentPoint
    } from "@/pages/test/js/api";
    import {getItemByValue} from "@/assets/js/tools";
    import {constTestType} from "@/pages/test/js/const";
    export default {
        name: "testManagerTesting",
        components: {
            MwTestStep,
            MwAvatar,
            TestCard
        },
        data() {
            return {
                info: {},
                list: [],
                stepShow: false,
                route: "",
            }
        },
        methods: {
            experimentPoint(id) {
                let postData = {
                    experimentId: id
                }
                experimentPoint(postData).then((res) => {
                    let rsData = res.data;
                    if (rsData.code == 1) {
                        rsData.data.map(item => {
                            this.list.push({
                                name: item.name,
                                status: item.status,
                                start: item.startTime ? `开始时间${item.startTime}` : '',
                                end: item.endTime ? `完成时间${item.endTime}` : '',
                                endText: item.averagePower ? `平均功率${item.averagePower}kW` : '',
                            })
                        })
                    }
                }).catch((err) => {
                    console.log(err)
                });
            },
            checkIsTesting() {
                getExitTest().then(res => {
                    let rs = res.data;
                    if (rs.code == 1) {
                        this.info = rs.data;
                        let type = this.info.type;
                        let testInfo = getItemByValue(type, constTestType);
                        if (testInfo != -1) {
                            this.info.typeName = testInfo.label;
                            this.stepShow = testInfo.step;
                            this.route = testInfo.route;
                            // 显示测试步骤
                            if(this.stepShow) {
                                this.experimentPoint(rs.data.id);
                            }
 
                        }else {
                            this.info.typeName = "未知试验类型";
                            this.route = "";
                        }
 
 
                    } else {
                        this.dialogVisible = true;
                    }
                }).catch(error => {
 
                });
            },
            goTest() {
                if(this.route) {
                    this.$router.push(this.route);
                }else {
                    this.$layer.msg('未知试验类型!');
                }
 
            }
        },
        computed: {},
        mounted() {
            this.checkIsTesting()
        },
        destroyed() {
 
        }
    }
</script>
 
<style scoped>
    .flex-wrapper {
        display: flex;
        flex-direction: row;
    }
 
    .form-wrapper {
        color: #999999;
        font-size: 14px;
    }
 
    .form-item {
        margin-bottom: 8px;
    }
 
    .form-item.inline {
        display: inline-block;
        margin-right: 32px;
    }
 
    .form-item.flex {
        display: flex;
        flex-direction: row;
    }
 
    .form-item.flex .form-item-value {
        flex: 1;
    }
 
    .form-item .form-item-label {
        display: inline-block;
        width: 108px;
        line-height: 40px;
        text-align: right;
    }
</style>