|
|
@@ -1,20 +1,25 @@
|
|
|
<template>
|
|
|
<confirm-dialog
|
|
|
ref="dialog"
|
|
|
- title="新增摄像头"
|
|
|
+ :title="dialogTitle"
|
|
|
@confirm="onConfirm"
|
|
|
>
|
|
|
<div class="c-grid-form u-align-self--center">
|
|
|
<span class="c-grid-form__label u-required">
|
|
|
厂商
|
|
|
</span>
|
|
|
- <schema-select
|
|
|
- ref="manufacturer"
|
|
|
+ <el-select
|
|
|
v-model="item.manufacturerKey"
|
|
|
class="u-width"
|
|
|
placeholder="请选择厂商"
|
|
|
- :schema="manufacturerSelectSchema"
|
|
|
- />
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(option, index) in manufacturerOptions"
|
|
|
+ :key="index"
|
|
|
+ :value="option.manufacturerKey"
|
|
|
+ :label="option.manufacturerName"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
<span class="c-grid-form__label u-required">
|
|
|
型号
|
|
|
</span>
|
|
|
@@ -33,17 +38,51 @@
|
|
|
maxlength="30"
|
|
|
clearable
|
|
|
/>
|
|
|
+ <template v-if="!item.id">
|
|
|
+ <span class="c-grid-form__label u-required">
|
|
|
+ 账号
|
|
|
+ </span>
|
|
|
+ <el-input v-model.trim="item.username" />
|
|
|
+ <span class="c-grid-form__label u-required">
|
|
|
+ 密码
|
|
|
+ </span>
|
|
|
+ <el-input
|
|
|
+ v-model.trim="item.password"
|
|
|
+ class="u-password"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
<span class="c-grid-form__label u-required">
|
|
|
- 账号
|
|
|
- </span>
|
|
|
- <el-input v-model.trim="item.username" />
|
|
|
- <span class="c-grid-form__label u-required">
|
|
|
- 密码
|
|
|
+ 通过视频服务器
|
|
|
</span>
|
|
|
- <el-input
|
|
|
- v-model.trim="item.password"
|
|
|
- class="u-password"
|
|
|
- />
|
|
|
+ <el-select
|
|
|
+ v-model="item.throughEvs"
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ label="是"
|
|
|
+ value="1"
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="否"
|
|
|
+ value="0"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <template v-if="item.throughEvs == '1'">
|
|
|
+ <span class="c-grid-form__label u-required">
|
|
|
+ 服务器通道号
|
|
|
+ </span>
|
|
|
+ <el-input-number
|
|
|
+ v-model="item.evsChannel"
|
|
|
+ controls-position="right"
|
|
|
+ />
|
|
|
+ <span class="c-grid-form__label u-required">
|
|
|
+ 服务器编号
|
|
|
+ </span>
|
|
|
+ <el-input-number
|
|
|
+ v-model="item.evsLocation"
|
|
|
+ controls-position="right"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
<span class="c-grid-form__label">
|
|
|
备注
|
|
|
</span>
|
|
|
@@ -69,32 +108,56 @@ import {
|
|
|
} from '@/constant'
|
|
|
import {
|
|
|
getManufacturersByType,
|
|
|
- addCamera
|
|
|
+ addCamera,
|
|
|
+ updateCamera
|
|
|
} from '@/api/external'
|
|
|
|
|
|
export default {
|
|
|
name: 'CameraConfigDialog',
|
|
|
data () {
|
|
|
return {
|
|
|
- manufacturerSelectSchema: {
|
|
|
- remote: this.getManufacturersByType,
|
|
|
- value: 'manufacturerKey',
|
|
|
- label: 'manufacturerName'
|
|
|
- },
|
|
|
- item: {}
|
|
|
+ item: {},
|
|
|
+ manufacturerOptions: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ dialogTitle () {
|
|
|
+ return this.item?.id ? '编辑摄像头' : ''
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- show (type) {
|
|
|
- this.item = {
|
|
|
- cameraType: type,
|
|
|
- identifier: '',
|
|
|
- manufacturerKey: '',
|
|
|
- model: '',
|
|
|
- remark: ThirdPartyDeviceInfo[CameraToThirdPartyMap[type]],
|
|
|
- username: '',
|
|
|
- password: ''
|
|
|
+ async show (type, options) {
|
|
|
+ const result = await getManufacturersByType(CameraToThirdPartyMap[type])
|
|
|
+ this.manufacturerOptions = result.data
|
|
|
+ if (options) {
|
|
|
+ this.item = {
|
|
|
+ id: options.id,
|
|
|
+ cameraType: type,
|
|
|
+ identifier: options.identifier,
|
|
|
+ manufacturerKey: options.manufacturerKey,
|
|
|
+ model: options.model,
|
|
|
+ remark: ThirdPartyDeviceInfo[CameraToThirdPartyMap[type]],
|
|
|
+ username: options.username,
|
|
|
+ password: options.password,
|
|
|
+ throughEvs: String(options.throughEvs || 0),
|
|
|
+ evsChannel: options.evsChannel,
|
|
|
+ evsLocation: options.evsLocation
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.item = {
|
|
|
+ cameraType: type,
|
|
|
+ identifier: '',
|
|
|
+ manufacturerKey: '',
|
|
|
+ model: '',
|
|
|
+ remark: ThirdPartyDeviceInfo[CameraToThirdPartyMap[type]],
|
|
|
+ username: '',
|
|
|
+ password: '',
|
|
|
+ throughEvs: '',
|
|
|
+ evsChannel: 0,
|
|
|
+ evsLocation: 0
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
this.$refs.dialog.show()
|
|
|
},
|
|
|
getManufacturersByType () {
|
|
|
@@ -129,23 +192,31 @@ export default {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- if (!this.item.username) {
|
|
|
+ if (!this.item.username && !this.item.id) {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
|
message: '请填写账号'
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- if (!this.item.password) {
|
|
|
+ if (!this.item.password && !this.item.id) {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
|
message: '请填写密码'
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+ if (!this.item.throughEvs) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请选择是否通过视频服务器'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
const key = this.item.manufacturerKey
|
|
|
- addCamera({
|
|
|
- manufacturerName: this.$refs.manufacturer.getOptions().find(({ value }) => value === key).label,
|
|
|
+ const isAdd = this.item.id ? updateCamera : addCamera
|
|
|
+ isAdd({
|
|
|
+ manufacturerName: this.manufacturerOptions.find(({ manufacturerKey }) => manufacturerKey === key).manufacturerName,
|
|
|
camProvider: 0,
|
|
|
...this.item
|
|
|
}).then(() => {
|