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
| <template>
| <div class="pre-option-list">
| <table>
| <thead>
| <tr>
| <th>状态名称</th>
| <th>状态</th>
| </tr>
| </thead>
| <tbody>
| <tr v-for="(item, key) in list" :key="'key'+key">
| <td>{{item.label}}</td>
| <td>
| <el-switch v-model="item.value" @change="changeOption(item)"></el-switch>
| </td>
| </tr>
| </tbody>
| </table>
| </div>
| </template>
|
| <script>
| import MwSwitch from '@/components/smallModule/mwSwitch.vue';
| import {changePreOption, checkPrecondition} from "@/pages/test/js/api";
| export default {
| name: "preOptionList",
| props: {
| type: {
| type: String,
| default: ""
| }
| },
| components: {
| MwSwitch
| },
| data() {
| return {
| list: [
| {
| id: 1,
| key: 1,
| label: '进线屏开关状态',
| value: true,
| on: 1,
| off: 0
| },
| {
| id: 2,
| label: '大功率整流电源电压',
| value: true,
| on: 500,
| off: 400
| },
| {
| id: 3,
| label: '直流配电板A排电压',
| value: true,
| on: 500,
| off: 400
| },
| {
| id: 4,
| label: '直流配电板B排电压',
| value: true,
| on: 0,
| off: 100
| },
| {
| id: 5,
| label: '油站',
| value: true,
| on: 1,
| off: 0
| },
| {
| id: 6,
| label: '水站',
| value: true,
| on: 1,
| off: 0
| },
| {
| id: 7,
| label: '被试电机通讯',
| value: true,
| on: 1,
| off: 0
| },
| ]
| }
| },
| methods: {
| checkPrecondition() {
| checkPrecondition(this.type).then(res => {
| let rs = res.data;
| let data = [];
| if (rs.code != 0) {
| data = rs.data;
| }
| data.map(item=>{
| for(let i=0; i<this.list.length; i++) {
| if(item.name == this.list[i].label) {
| this.list[i].value = item.status?true: false;
| }
| }
| });
| }).catch(error => {
| this.loading = false;
| console.log(error);
| });
| },
| changeOption(data) {
| let value = data.value?data.on:data.off;
| changePreOption(data.id, value).then(res=>{
| let rs = res.data;
| if(rs.code == 1) {
| this.$layer.msg("修改成功");
| }else {
| this.$layer.msg("修改失败");
| }
| this.$nextTick(()=>{
| this.checkPrecondition();
| });
| }).catch(error=>{
|
| });
| }
| },
| mounted() {
| this.checkPrecondition();
| }
| }
| </script>
|
| <style scoped>
| .pre-option-list {
| font-size: 16px;
| color: #FFFFFF;
| }
| .pre-option-list table {
| width: 100%;
| border-collapse: collapse;
| }
|
| .pre-option-list table th,
| .pre-option-list table td {
| border: 2px solid #6261CB;
| padding: 8px 8px;
| text-align: center;
| }
| .pre-option-list table th {
| color: #FFF034;
| border-top: 2px solid #797979;
| border-left: 2px solid #797979;
| border-right: 2px solid #797979;
| }
| </style>
|
|