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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<template>
<div class="form-container">
<van-form @submit="onSubmit">
<van-field
class="field-form-item"
readonly
clickable
required
name="organName"
:value="boxInfo.organName"
label="机顶盒所属单位"
placeholder="请选择组织单位"
:right-icon="showOrg ? 'arrow-up' : 'arrow-down'"
@click="showOrg = true"
:rules="[
{ required: true, message: '请选择组织单位', trigger: 'change'}
]"
/>
<van-popup v-model="showOrg" position="bottom">
<van-picker
show-toolbar
:columns="orgNameList"
@confirm="onConfirmOrg"
@cancel="showOrg = false"
/>
</van-popup>
<van-field
class="field-form-item"
v-model="boxInfo.macURL"
required
name="macURL"
label="机顶盒Mac地址"
placeholder="请填写机顶盒Mac地址"
:rules="[
{ required: true, message: '请填写机顶盒Mac地址', trigger: ['blur', 'change'] },
{ pattern: /^[A-Fa-f0-9]{2}([-:]?[A-Fa-f0-9]{2})([-:.]?[A-Fa-f0-9]{2})([-:]?[A-Fa-f0-9]{2})([-:.]?[A-Fa-f0-9]{2})([-:]?[A-Fa-f0-9]{2})$/, message: '请填写正确的Mac地址', trigger: ['blur', 'change']}
]"
/>
<div class="form-page-button">
<van-button type="default" native-type="submit" v-if="actived === '1'"
>激活</van-button
>
<van-button type="default" native-type="submit" v-if="actived === '2'"
>上报</van-button
>
</div>
</van-form>
</div>
</template>
<script>
export default {
props: ["actived"],
data() {
return {
boxInfo: {},
orgNameList: [],
orgList: [],
showOrg: false,
showUser: false,
};
},
mounted() {
this.getorganName();
},
methods: {
// 获取所属单位
getorganName() {
let vm = this;
vm.$https({
url: "boxOperation/getList",
method: "get",
authType: this.backToken,
})
.then((res) => {
if (res.data.resultCode === "200") {
if(this.actived==='1'){
this.orgList = res.data.data.filter(item=>item.status !==2)
}
if(this.actived==='2'){
this.orgList = res.data.data.filter(item=>item.status===2)
}
vm.orgNameList = this.orgList.map((item) => item.organName);
}
})
.catch(function (err) {
console.log(err);
});
},
onConfirmOrg(value, index) {
this.boxInfo.organName = value;
this.boxInfo.organId = this.orgList[index].organId;
this.boxInfo.id = this.orgList[index].id;
this.showOrg = false;
},
onSubmit() {
if (this.actived === "1") {
// 激活
this.submitData("2");
} else {
// 上报
this.submitData("3");
}
},
submitData(status) {
let vm = this;
const param = {
organName: this.boxInfo.organName,
organId: this.boxInfo.organId,
id: this.boxInfo.id,
mac: this.boxInfo.macURL,
status: status,
};
vm.$https(
{
url: "boxOperation/update",
method: "put",
authType: this.backToken,
},
vm.$qs.stringify(param)
)
.then((res) => {
if (res.data.resultCode === "200") {
if(status === '2'){
this.$router.replace({path:"/success",query:{txt:'激活成功!机顶盒登录密码为'+res.data.data+',该密码为机顶盒登录密码,请妥善保存。',url:'/opt'}})
}else{
this.$router.replace({path:"/success",query:{txt:'上报成功',url:'/opt'}})
}
} else {
this.$toast(res.data.message);
}
})
.catch(function (err) {
console.log(err);
});
},
},
};
</script>
<style lang="scss">
.form-container {
.van-form {
padding: 24px;
background: #ffffff;
border-radius: 0 0 4px 4px;
.van-field {
background: #f5f5f5;
border-radius: 4px;
.van-field__left-icon {
margin-right: 12px;
}
}
.van-cell--required::before {
left: -10px;
color:#A4151D;
}
}
.form-page-button {
text-align: center;
background: #a4151d;
border-radius: 4px;
position: absolute;
bottom: 40px;
left: 24px;
right: 24px;
box-sizing: border-box;
.van-button {
font-size: 16px;
color: #fff;
background-color: transparent;
border: none;
}
}
.field-form-item.van-cell {
display: block;
padding: 8px 0 16px 0;
background-color: transparent;
border-bottom: none;
.van-field__label {
width: 100%;
color: #333;
font-size: 14px;
font-weight: normal;
margin-bottom: 16px;
}
.van-field__value {
background: #f5f5f5;
border-radius: 4px;
padding: 8px 20px;
}
&::after {
border: none;
}
.van-field__control {
color: #333;
font-size: 14px;
font-weight: normal;
}
}
.van-tabs__nav--card {
margin: 0;
}
}
</style>