nationalStandard.vue
5.15 KB
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
<template>
<div class="innnerBox">
<div class="title">sip视频设置</div>
<el-form
:model="sipSetting"
ref="form"
:rules="rules"
label-width="100px"
class="demo-ruleForm"
inline-message
hide-required-asterisk
>
<el-form-item label="用户名" prop="sip_username">
<div style="width: 30%;">
<el-input
v-model="sipSetting.sip_username"
autocomplete="off"
></el-input>
</div>
</el-form-item>
<el-form-item label="密码" prop="sip_password">
<div style="width: 30%;">
<el-input
type="password"
v-model="sipSetting.sip_password"
autocomplete="off"
></el-input>
</div>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addSip('form')" v-if="!isGetted"
>提交</el-button
>
<el-button type="primary" @click="editSip('form')" v-if="isGetted"
>编辑</el-button
>
<el-button type="primary" @click="delFun()" v-if="isGetted"
>删除</el-button
>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
data() {
var validateUser = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入用户名"));
} else {
callback();
}
};
var validatePass = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入密码"));
} else {
callback();
}
};
return {
rules: {
sip_username: [{ validator: validateUser, trigger: "change" }],
sip_password: [{ validator: validatePass, trigger: "change" }]
},
user_unid: localStorage.getItem("user_unid"),
dev_unid: localStorage.getItem("dev_unid"),
isGetted: false,
sipSetting: {
sip_username: "", // string
sip_password: ""
},
sip_unid: ""
};
},
watch: {},
components: {},
mounted() {
this.getSipParam();
},
methods: {
addSip(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
this.$api.resource
.addSip(this.sipSetting, this.dev_unid, this.user_unid)
.then(res => {
// console.log(res.data);
if (res.ecode == 200) {
this.isGetted = true;
this.$message({
type: "success",
message: res.enote
});
} else {
this.isGetted = false;
this.$message({
type: "error",
message: res.enote
});
}
});
} else {
return false;
}
});
},
editSip(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
this.$api.resource
.editSip(
this.sipSetting,
this.dev_unid,
this.user_unid,
this.sip_unid
)
.then(res => {
// console.log(res.data);
if (res.ecode == 200) {
this.$message({
type: "success",
message: "修改成功!"
});
} else {
this.$message({
type: "error",
message: res.enote
});
}
});
} else {
return false;
}
});
},
delFun() {
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.$api.resource
.delSip(
this.sipSetting,
this.dev_unid,
this.user_unid,
this.sip_unid
)
.then(res => {
if (res.ecode == 200) {
this.$message({
type: "success",
message: "删除成功!"
});
for (let j in this.sipSetting) {
this.sipSetting[j] = "";
}
this.isGetted = false;
} else {
this.$message({
type: "error",
message: res.enote
});
}
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消"
});
});
},
getSipParam() {
this.$api.resource.getsip({}, this.dev_unid, this.user_unid).then(res => {
if (res.ecode) {
this.isGetted = false;
} else {
this.isGetted = true;
this.sipSetting.sip_username = res.sip_username;
this.sipSetting.sip_password = res.sip_password;
this.sip_unid = res.sip_unid;
}
});
}
}
};
</script>
<style lang="scss" scoped>
.title {
height: 30px;
line-height: 30px;
padding-left: 30px;
font-size: 14px;
background: #3bb7ff;
color: #ffffff;
margin-bottom: 20px;
}
</style>