adddev.vue
6.69 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
<template>
<div>
<el-dialog title="添加设备" :visible.sync="addvdialog" :before-close="closeaddvdialog" width="50%">
<div class="" style="overflow:hidden">
<el-form ref="vforms" :model="vform" label-width="120px">
<el-col :span="12">
<el-form-item label="分析终端编号" prop="vchan_refid" :rules="[
{ required: true, message: '分析终端编号不能为空', trigger: 'blur' }]">
<el-input v-model="vform.vchan_refid"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="vchan_name" label="分析终端名称">
<el-input v-model="vform.vchan_name"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="vchan_prop.type" label="相机属性">
<el-select v-model="vform.vchan_prop.is_dome" placeholder="请选区域">
<el-option label="球机" :value="true"></el-option>
<el-option label="枪机" :value="false"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="vchan_prop.ip" label="IP地址" :rules="[
{ required: true, message: '相机IP不能为空', trigger: 'blur' }]">
<el-input v-model="vform.vchan_prop.ip"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="vchan_prop.port" label="端口号">
<el-input v-model="vform.vchan_prop.port"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="vchan_prop.type" label="协议类型">
<el-select v-model="vform.vchan_prop.video_protocol_id" placeholder="请选协议类型">
<el-option label="RTSP" value="1"></el-option>
<el-option label="枪机" value="2"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="vchan_prop.video_source_url" label="推流地址">
<el-input v-model="vform.vchan_prop.video_source_url"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="vchan_prop.ent_prop" label="相机属性">
<el-select v-model="vform.vchan_prop.ent_prop" placeholder="请选区域">
<el-option label="入口" :value="1"></el-option>
<el-option label="出口" :value="2"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="用户名" prop="vchan_prop.user_name" :rules="[
{ required: true, message: '相机用户名不能为空', trigger: 'blur' }]">
<el-input v-model="vform.vchan_prop.user_name"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="密码" prop="vchan_prop.password" :rules="[
{ required: true, message: '密码不能为空', trigger: 'blur' }]">
<el-input v-model="vform.vchan_prop.password" type="password"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="挂在地址" prop="org_unid" :rules="[
{ required: true, message: '挂载点不能为空', trigger: 'blur' }]">
<el-select v-model="vform.org_unid" placeholder="请选区域">
<el-option v-for="(item,index) in address" :key="index" :label="item.org_name" :value="item.unid"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-form>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="closeaddvdialog">关闭</el-button>
<el-button type="primary" @click="submitvchan">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
vform: {
vchan_refid:'',
org_pid: '',
org_unid:'',
vchan_name: "",
vchan_type:'vchan',
vchan_prop: {
ent_prop:1,
is_dome: false,
ip: null,
port: "",
user_name: "",
password: "",
video_protocol_id: "",
video_source_url: ""
}
}
}
},
props: ["addvdialog","editData","state"],
methods: {
closeaddvdialog(state) {
this.state = "add";
this.$emit("closedialog",state);
},
resetForm(formName) {
this.$refs['vforms'].resetFields();
},
editvchan(){
},
submitvchan() {
let url = this.API.org.getvchan,
data = this.vform;
if(this.state == 'edit'){
url = this.API.org.editvchan(data.id)
data= {
vchan_refid:this.vform.vchan_refid,
org_pid: this.vform.org_pid,
org_unid:this.vform.org_unid,
vchan_name:this.vform.vchan_name,
vchan_type:'vchan',
vchan_prop: {
ent_prop:this.vform.vchan_prop.ent_prop,
is_dome: this.vform.vchan_prop.is_dome,
ip: this.vform.vchan_prop.ip,
port: this.vform.vchan_prop.post,
user_name: this.vform.vchan_prop.user_name,
password:this.vform.vchan_prop.password,
video_protocol_id: this.vform.vchan_prop.video_protocol_id,
video_source_url: this.vform.vchan_prop.video_source_url
}
}
}
this.$refs['vforms'].validate((valid) => {
if (valid) {
this.axios.post(url,data,{
headers:{
"authorization": localStorage.getItem("atoken"),
}}).then(response => {
this.resetForm();
this.closeaddvdialog(1);
this.state = "add";
});
} else {
return false;
}
});
},
deepCopy (data) {
let result = ''
result = JSON.parse(JSON.stringify(data));
return result;
}
},
created(){
debugger
this.faceapi.getAddress().then(res => {
this.address = res.list_data;
})
},
watch:{
editData(val){
console.log(val)
if(val) {
val.org_unid = Number(val.org_unid)
}
this.vform = this.deepCopy(val);
},
state(val){
if(val == 'add'){
this.resetForm();
}
}
}
};
</script>
<style lang="stylus" scoped>
</style>