| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <confirm-dialog
- ref="dialog"
- :title="dialogTitle"
- @confirm="onConfirm"
- >
- <div class="c-grid-form u-align-self--center">
- <span class="c-grid-form__label u-required">
- 厂商
- </span>
- <el-select
- v-model="item.manufacturerKey"
- class="u-width"
- placeholder="请选择厂商"
- >
- <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>
- <el-input
- v-model.trim="item.model"
- placeholder="最多50个字符"
- maxlength="50"
- clearable
- />
- <span class="c-grid-form__label u-required">
- 标识
- </span>
- <el-input
- v-model.trim="item.identifier"
- placeholder="仅支持数字和字母,最多30个字符"
- 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-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>
- <div
- class="has-info"
- data-info="备注将用于多摄像头展示时的区分"
- >
- <el-input
- v-model.trim="item.remark"
- placeholder="最多30个字符"
- maxlength="30"
- clearable
- />
- </div>
- </div>
- </confirm-dialog>
- </template>
- <script>
- import {
- ThirdPartyDeviceInfo,
- CameraToThirdPartyMap
- } from '@/constant'
- import {
- getManufacturersByType,
- addCamera,
- updateCamera
- } from '@/api/external'
- export default {
- name: 'CameraConfigDialog',
- data () {
- return {
- item: {},
- manufacturerOptions: []
- }
- },
- computed: {
- dialogTitle () {
- return this.item?.id ? '编辑摄像头' : ''
- }
- },
- methods: {
- 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 () {
- return getManufacturersByType(CameraToThirdPartyMap[this.item.cameraType])
- },
- onConfirm (done) {
- if (!this.item.manufacturerKey) {
- this.$message({
- type: 'warning',
- message: '请选择厂商'
- })
- return
- }
- if (!this.item.model) {
- this.$message({
- type: 'warning',
- message: '请填写型号'
- })
- return
- }
- if (!this.item.identifier) {
- this.$message({
- type: 'warning',
- message: '请填写唯一标识'
- })
- return
- }
- if (!/^[0-9a-zA-Z]+$/.test(this.item.identifier)) {
- this.$message({
- type: 'warning',
- message: '唯一标识格式错误仅支持数字和字母'
- })
- return
- }
- if (!this.item.username && !this.item.id) {
- this.$message({
- type: 'warning',
- message: '请填写账号'
- })
- return
- }
- 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
- const isAdd = this.item.id ? updateCamera : addCamera
- isAdd({
- manufacturerName: this.manufacturerOptions.find(({ manufacturerKey }) => manufacturerKey === key).manufacturerName,
- camProvider: 0,
- ...this.item
- }).then(() => {
- done()
- this.$emit('confirm', this.item)
- })
- }
- }
- }
- </script>
|