|
|
@@ -1,5 +1,10 @@
|
|
|
<template>
|
|
|
- <div class="l-flex--col has-padding">
|
|
|
+ <wrapper
|
|
|
+ fill
|
|
|
+ margin
|
|
|
+ padding
|
|
|
+ background
|
|
|
+ >
|
|
|
<c-table
|
|
|
ref="table"
|
|
|
:curr="currOptions"
|
|
|
@@ -140,12 +145,6 @@
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
- prop="remark"
|
|
|
- label="备注"
|
|
|
- align="center"
|
|
|
- show-overflow-tooltip
|
|
|
- />
|
|
|
<el-table-column
|
|
|
label="操作"
|
|
|
align="center"
|
|
|
@@ -157,7 +156,7 @@
|
|
|
class="c-table__btn u-pointer"
|
|
|
@click.stop="toEditDevice(scope.row)"
|
|
|
>
|
|
|
- 编辑
|
|
|
+ 查看
|
|
|
</div>
|
|
|
<permission v-if="scope.row.isMaster">
|
|
|
<div
|
|
|
@@ -218,7 +217,7 @@
|
|
|
class="c-form__item"
|
|
|
placeholder="请选择产品"
|
|
|
:loading="fetching"
|
|
|
- :disabled="isSub || !isAdd"
|
|
|
+ :disabled="isSub"
|
|
|
@visible-change="getProducts"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -235,7 +234,6 @@
|
|
|
v-model.trim="currObj.serialNumber"
|
|
|
class="c-form__item"
|
|
|
maxlength="50"
|
|
|
- :disabled="!isAdd"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="c-form__section extra o-mac">
|
|
|
@@ -244,11 +242,10 @@
|
|
|
v-model.trim="currObj.mac"
|
|
|
class="c-form__item"
|
|
|
maxlength="17"
|
|
|
- :disabled="!isAdd"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="c-form__section">
|
|
|
- <span class="c-form__label">备注:</span>
|
|
|
+ <span class="c-form__label required">地址:</span>
|
|
|
<el-input
|
|
|
v-model="currObj.remark"
|
|
|
class="c-form__item"
|
|
|
@@ -298,7 +295,7 @@
|
|
|
@choose="toChoose"
|
|
|
/>
|
|
|
</el-dialog>
|
|
|
- </div>
|
|
|
+ </wrapper>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
@@ -361,13 +358,11 @@ export default {
|
|
|
return this.isSub ? '备份设备' : '设备'
|
|
|
},
|
|
|
products () {
|
|
|
- return this.isAdd
|
|
|
- ? this.isSub
|
|
|
- ? [{ value: this.$master.productId, label: this.$master.productName }]
|
|
|
- : this.loaded
|
|
|
- ? this.productOptions.slice(1)
|
|
|
- : []
|
|
|
- : [{ value: this.currObj.productId, label: this.$productName }]
|
|
|
+ return this.isSub
|
|
|
+ ? [{ value: this.$master.productId, label: this.$master.productName }]
|
|
|
+ : this.loaded
|
|
|
+ ? this.productOptions.slice(1)
|
|
|
+ : []
|
|
|
},
|
|
|
tableData () {
|
|
|
const arr = []
|
|
|
@@ -396,6 +391,15 @@ export default {
|
|
|
return this.device?.name
|
|
|
}
|
|
|
},
|
|
|
+ beforeRouteLeave (to, from, next) {
|
|
|
+ if (to.name === 'device-detail') {
|
|
|
+ this.$store.dispatch('addCacheRoutes', 'Device')
|
|
|
+ }
|
|
|
+ next()
|
|
|
+ },
|
|
|
+ activated () {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
methods: {
|
|
|
_getProducts () {
|
|
|
this.fetching = true
|
|
|
@@ -479,10 +483,6 @@ export default {
|
|
|
item.loading = false
|
|
|
})
|
|
|
},
|
|
|
- beforeEdit ({ id, name, productId, productName, serialNumber, mac, remark }) {
|
|
|
- this.$productName = productName
|
|
|
- return { id, name, productId, mac, serialNumber, remark }
|
|
|
- },
|
|
|
afterAdd () {
|
|
|
const params = this.options.params
|
|
|
if (params.name && !(new RegExp(params.name).test(this.currObj.name))) {
|
|
|
@@ -529,6 +529,13 @@ export default {
|
|
|
return false
|
|
|
}
|
|
|
item.mac = item.mac.toLowerCase()
|
|
|
+ if (!item.remark) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '地址不能为空'
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
return true
|
|
|
},
|
|
|
close () {
|
|
|
@@ -542,9 +549,15 @@ export default {
|
|
|
this.toAdd()
|
|
|
},
|
|
|
toEditDevice (item) {
|
|
|
- this.isSub = !item.isMaster
|
|
|
- this.$master = item.parent
|
|
|
- this.toEdit(item)
|
|
|
+ this.$router.push({
|
|
|
+ name: 'device-detail',
|
|
|
+ params: {
|
|
|
+ id: item.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // this.isSub = !item.isMaster
|
|
|
+ // this.$master = item.parent
|
|
|
+ // this.toEdit(item)
|
|
|
},
|
|
|
reloadSubDevices (item) {
|
|
|
item.loaded = false
|
|
|
@@ -554,7 +567,7 @@ export default {
|
|
|
toSave () {
|
|
|
if (this.isSub) {
|
|
|
if (this.check(this.currObj)) {
|
|
|
- (this.isAdd ? addSubDevice(this.$master, this.currObj) : this.proxy.update(this.currObj)).then(() => {
|
|
|
+ addSubDevice(this.$master, this.currObj).then(() => {
|
|
|
this.reloadSubDevices(this.$master)
|
|
|
this.close()
|
|
|
})
|