|
@@ -3,12 +3,12 @@
|
|
|
<!-- 新增 -->
|
|
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="getDialog()"
|
|
|
v-hasPermi="['channel:custom:add']">
|
|
|
- 新增规则
|
|
|
+ 新增频道配置
|
|
|
</el-button>
|
|
|
<!-- 列表 -->
|
|
|
<el-table :data="tableData" v-loading="loading">
|
|
|
<el-table-column label="序号" align="center" type="index" />
|
|
|
- <el-table-column label="规则名称" prop="name" align="center" />
|
|
|
+ <el-table-column label="频道配置名称" prop="name" align="center" />
|
|
|
<el-table-column label="部署形式" prop="type" align="center" :formatter="typeFormatter" />
|
|
|
<el-table-column label="设备" prop="deviceIds" align="center" :formatter="devFormatter"
|
|
|
show-overflow-tooltip />
|
|
@@ -16,19 +16,22 @@
|
|
|
<template slot-scope="scope">
|
|
|
<el-button type="text" @click="getDialog(scope.row, scope.$index)"
|
|
|
v-hasPermi="['channel:custom:edit']">编辑</el-button>
|
|
|
+ <el-button v-if="scope.$index !== 0" type="delete" @click="getDelete(scope.row)"
|
|
|
+ v-hasPermi="['channel:custom:delete']">
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<!-- 弹窗 -->
|
|
|
<el-dialog :visible.sync="dialogVisible" :title="title" width="950px">
|
|
|
- <el-form label-width="100px">
|
|
|
- <el-form-item v-if="index !== 1" label="规则名称:" style="width: 300px">
|
|
|
+ <el-form label-width="auto">
|
|
|
+ <el-form-item v-if="index !== 1" label="频道配置名称:" style="width: 300px">
|
|
|
<el-input v-model="dialogForm.name" placeholder="请输入规则名称" />
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="index !== 1" label="关联设备:">
|
|
|
<el-select v-model="ids" multiple placeholder="请选择关联设备">
|
|
|
- <el-option v-for="item in devOptions" :key="item.label" :value="item.value.toString()"
|
|
|
- :label="item.label" />
|
|
|
+ <el-option v-for="item in devOptions" :key="item.label" :value="item.value.toString()" :label="item.label" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="title === '编辑'" label="内容列表:">
|
|
@@ -58,11 +61,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { channelPage, page, create, editPage } from '@/api/channel/custom'
|
|
|
-import { devMixin } from '@/mixin/index'
|
|
|
+import { channelPage, page, create, editPage, getRemove, devList } from '@/api/channel/custom'
|
|
|
export default {
|
|
|
dicts: ['deployment_form'],
|
|
|
- mixins: [devMixin],
|
|
|
data() {
|
|
|
return {
|
|
|
// 遮罩层
|
|
@@ -74,6 +75,9 @@ export default {
|
|
|
// 弹窗
|
|
|
dialogVisible: false,
|
|
|
title: '',
|
|
|
+ // 设备
|
|
|
+ devOptions: [],
|
|
|
+ allDevOptions: [],
|
|
|
// 表单
|
|
|
form: {
|
|
|
pageNum: 1,
|
|
@@ -90,6 +94,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ this.getDevList()
|
|
|
this.getList()
|
|
|
},
|
|
|
methods: {
|
|
@@ -104,6 +109,21 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ // 全部设备
|
|
|
+ getDevList() {
|
|
|
+ devList(1).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.allDevOptions = []
|
|
|
+ res.data.map(i => {
|
|
|
+ this.allDevOptions.push({
|
|
|
+ value: i.clientTypeId,
|
|
|
+ label: i.name
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
// 编辑
|
|
|
edit(e) {
|
|
|
this.$router.push({
|
|
@@ -116,10 +136,41 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ // 删除
|
|
|
+ getDelete(row) {
|
|
|
+ this.$confirm(`是否删除${row.name}?`, '提示', {
|
|
|
+ 'confirmButtonText': '确定',
|
|
|
+ 'cancelButtonText': '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ getRemove(row.id).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('删除成功!')
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
// 弹窗
|
|
|
getDialog(row, index) {
|
|
|
this.dialogVisible = true
|
|
|
this.index = index + 1
|
|
|
+
|
|
|
+ // 新增 / 编辑时的设备
|
|
|
+ let type = row ? 1 : 0
|
|
|
+ devList(type).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.devOptions = []
|
|
|
+ res.data.map(i => {
|
|
|
+ this.devOptions.push({
|
|
|
+ value: i.clientTypeId,
|
|
|
+ label: i.name
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
if (row) {
|
|
|
this.title = '编辑'
|
|
|
this.dialogForm = row
|
|
@@ -169,7 +220,7 @@ export default {
|
|
|
return this.selectDictLabel(this.dict.type.deployment_form, row.type)
|
|
|
},
|
|
|
devFormatter(row) {
|
|
|
- return row.deviceIds ? row.deviceIds.split(',').map(i => this.selectDictLabel(this.devOptions, i)).join(',') : ''
|
|
|
+ return row.deviceIds ? row.deviceIds.split(',').map(i => this.selectDictLabel(this.allDevOptions, i)).join(',') : ''
|
|
|
}
|
|
|
},
|
|
|
};
|