|
|
@@ -15,6 +15,14 @@
|
|
|
@confirm="onConfirm"
|
|
|
>
|
|
|
<div class="c-grid-form u-align-self--center">
|
|
|
+ <span class="c-grid-form__label u-required">厂商</span>
|
|
|
+ <schema-select
|
|
|
+ ref="manufacturer"
|
|
|
+ v-model="item.manufacturerKey"
|
|
|
+ class="u-width"
|
|
|
+ placeholder="请选择厂商"
|
|
|
+ :schema="manufacturerSelectSchema"
|
|
|
+ />
|
|
|
<span class="c-grid-form__label u-required">名称</span>
|
|
|
<el-input
|
|
|
v-model.trim="item.name"
|
|
|
@@ -45,7 +53,10 @@
|
|
|
|
|
|
<script>
|
|
|
import { CameraToThirdPartyMap } from '@/constant'
|
|
|
-import { getThirdPartyDevices } from '@/api/external'
|
|
|
+import {
|
|
|
+ getManufacturersByType,
|
|
|
+ getThirdPartyDevices
|
|
|
+} from '@/api/external'
|
|
|
import {
|
|
|
addCamera,
|
|
|
deleteCamera
|
|
|
@@ -64,8 +75,15 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
+ const manufacturerSelectSchema = {
|
|
|
+ remote: this.getManufacturersByType,
|
|
|
+ value: 'manufacturerKey',
|
|
|
+ label: 'manufacturerName'
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
item: {},
|
|
|
+ manufacturerSelectSchema,
|
|
|
schema: {
|
|
|
list: this.getThirdPartyDevices,
|
|
|
buttons: [
|
|
|
@@ -98,6 +116,9 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ getManufacturersByType () {
|
|
|
+ return getManufacturersByType(CameraToThirdPartyMap[this.type])
|
|
|
+ },
|
|
|
getThirdPartyDevices (params) {
|
|
|
return getThirdPartyDevices({
|
|
|
cameraType: this.type,
|
|
|
@@ -108,14 +129,22 @@ export default {
|
|
|
onAdd () {
|
|
|
this.item = {
|
|
|
cameraType: this.type,
|
|
|
- name: '',
|
|
|
identifier: '',
|
|
|
+ manufacturerKey: '',
|
|
|
+ name: '',
|
|
|
username: '',
|
|
|
password: ''
|
|
|
}
|
|
|
this.$refs.editDialog.show()
|
|
|
},
|
|
|
onConfirm (done) {
|
|
|
+ if (!this.item.manufacturerKey) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请选择厂商'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
if (!this.item.name) {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
|
@@ -151,7 +180,11 @@ export default {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- addCamera(this.item).then(() => {
|
|
|
+ const key = this.item.manufacturerKey
|
|
|
+ addCamera({
|
|
|
+ manufacturerName: this.$refs.manufacturer.getOptions().find(({ value }) => value === key).label,
|
|
|
+ ...this.item
|
|
|
+ }).then(() => {
|
|
|
this.$refs.table.resetCondition({ name: this.item.name })
|
|
|
done()
|
|
|
})
|