Commit 84c796aa by 王刘锁

设备

parent 5e902f7f
...@@ -58,4 +58,48 @@ export default class EquipmentAccount { ...@@ -58,4 +58,48 @@ export default class EquipmentAccount {
responseType: "blob", responseType: "blob",
}); });
} }
queryDictValue (id) {
return request({
url: `/taskEquipmentTopic/queryTopicValue`,
method: 'get',
params: {dictValueId: id},
loading: false
})
}
saveDictValue (inputForm) {
return request({
url: `/taskEquipmentTopic/saveTopicValue`,
method: 'post',
data: inputForm
})
}
getDictValue (dictTypeId) {
return request({
url: '/taskEquipmentTopic/getTopicValue',
method: 'get',
params: {
'equipmentNo': dictTypeId
}
})
}
deleteDictValue (ids) {
return request({
url: '/taskEquipmentTopic/deleteTopicValue',
method: 'delete',
params: {ids: ids}
})
}
// 获取任务下拉列表
getTaskList(equipmentNo) {
return request({
url: `/taskEquipmentTopic/getTaskList`,
method: 'get',
params: { 'equipmentNo': equipmentNo}
});
}
} }
<template>
<el-dialog
:title="!inputForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
append-to-body
v-dialogDrag
:visible.sync="visible">
<el-form size="small" :model="inputForm" :rules="dataRule" v-loading="loading" ref="inputForm"
@keyup.enter.native="doSubmit()"
label-width="80px" @submit.native.prevent>
<el-form-item label="任务" prop="topicType">
<el-select v-model="inputForm.taskName" placeholder="任务">
<el-option v-for="item in taskOptions" :key="item.value" :label="item.lable" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="主题类型" prop="topicType">
<el-select v-model="inputForm.topicType" placeholder="请选择主题类型">
<el-option v-for="item in typeOptions" :key="item.value" :label="item.lable" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label=" 主题名称
" prop="label">
<el-input v-model="inputForm.topicName" placeholder="主题名称"></el-input>
</el-form-item>
<el-form-item label="消息值" prop="value">
<el-input v-model="inputForm.mesageValue" placeholder="消息值"></el-input>
</el-form-item>
<el-form-item label="排序号" prop="sort">
<el-input-number :step="1" v-model="inputForm.sort" placeholder="排序号"></el-input-number>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="visible = false" icon="el-icon-circle-close">关闭</el-button>
<el-button size="small" type="primary" @click="doSubmit()" icon="el-icon-circle-check"
v-noMoreClick>确定</el-button>
</span>
</el-dialog>
</template>
<script>
import EquipmentAccount from '@/api/equipmentAdmin/EquipmentAccount'
export default {
data() {
return {
taskOptions:[],
typeOptions: [{lable: '发布', value: '1'}, {lable: '订阅', value: '2'}],
visible: false,
loading: false,
inputForm: {
id: '',
topicName: '',
mesageValue: '',
topicType: '',
taskName:'',
sort: 1
},
dataRule: {
topicName: [
{required: true, message: '主题名不能为空', trigger: 'blur'}
],
taskName: [
{required: true, message: '任务不能为空', trigger: 'blur'}
]
}
}
},
EquipmentAccount: null,
created() {
this.EquipmentAccount = new EquipmentAccount()
},
methods: {
init(method, obj) {
this.inputForm.id = obj.dictValueId
this.inputForm.equipmentNo = obj.dictTypeId
this.EquipmentAccount.getTaskList(this.inputForm.equipmentNo).then(({data}) => {
this.taskOptions = data
})
this.visible = true
this.$nextTick(() => {
this.$refs['inputForm'].resetFields()
if (method === 'edit' || method === 'view') { // 修改或者查看
this.EquipmentAccount.queryDictValue(this.inputForm.id).then(({data}) => {
this.inputForm = this.recover(this.inputForm, data)
this.inputForm.id = obj.dictValueId
})
}
})
},
// 表单提交
doSubmit() {
if (!this.groupId) {
this.groupWrong = '请选择分组'
}
this.$refs['inputForm'].validate((valid) => {
if (valid) {
this.loading = true
this.EquipmentAccount.saveDictValue(this.inputForm).then(({data}) => {
this.loading = false
this.$message.success(data)
this.visible = false
this.$emit('refreshDataList')
}).catch(() => {
this.loading = false
})
}
})
}
}
}
</script>
<template>
<div style="padding:10px; height: calc(100% - 80px);">
<vxe-toolbar :refresh="{query: refreshList}" custom>
<template #buttons>
<el-button type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
<el-button type="danger" size="small" icon="el-icon-delete" @click="del()"
:disabled="$refs.dictValueTable && $refs.dictValueTable.getCheckboxRecords().length === 0" plain>删除
</el-button>
</template>
</vxe-toolbar>
<vxe-table border="inner" auto-resize resizable height="auto" :scroll-y="{ enabled: false }" :loading="loading"
size="small" ref="dictValueTable" show-header-overflow show-overflow highlight-hover-row :menu-config="{}"
:print-config="{}" :import-config="{}" :export-config="{}" :sort-config="{remote:true}" :data="dataList"
:checkbox-config="{}">
<vxe-column type="seq" width="40"></vxe-column>
<vxe-column type="checkbox" width="40px"></vxe-column>
<vxe-column field="label" title="任务名称">
<template slot-scope="scope">
<el-link type="primary" :underline="false" @click="edit(scope.row.id)">
{{scope.row.taskName}}</el-link>
</template>
</vxe-column>
<vxe-column field="topicType" title="主题类型" align="center" width="80px">
<template slot-scope="scope">
<span v-if="scope.row.topicType === '1'" style="color: #249601;">发布</span>
<span v-else-if="scope.row.topicType === '2'" style="color: #FF0000;">订阅</span>
</template>
</vxe-column>
<vxe-column title="主题名称" field="topicName"></vxe-column>
<vxe-column title="消息值" field="messageValue"></vxe-column>
<vxe-column title="排序" field="sort"></vxe-column>
<vxe-column title="操作" width="100px" fixed="right" align="center">
<template slot-scope="scope">
<el-button v-if="hasPermission('sys:dict:edit')" type="text" size="small" @click="edit(scope.row.id)">
修改
</el-button>
<el-divider direction="vertical"></el-divider>
<el-button v-if="hasPermission('sys:dict:del')" type="text" size="small" @click="del(scope.row.id)">
删除
</el-button>
</template>
</vxe-column>
</vxe-table>
<!-- 弹窗, 新增 / 修改 -->
<topic-form ref="topicForm" @refreshDataList="refreshList"></topic-form>
</div>
</template>
<script>
import TopicForm from './TopicForm'
import EquipmentAccount from '@/api/equipmentAdmin/EquipmentAccount'
export default {
data () {
return {
dataList: [],
dictTypeId: '',
loading: false
}
},
props: ['dictTypeTitle'],
components: {
TopicForm
},
EquipmentAccount: null,
created () {
this.EquipmentAccount = new EquipmentAccount()
},
methods: {
// 获取数据列表
refreshList (dictTypeId) {
this.loading = true
if (dictTypeId) {
this.dictTypeId = dictTypeId
}
this.EquipmentAccount.getDictValue(this.dictTypeId).then(({ data }) => {
this.dataList = data
this.loading = false
})
},
// 新增
add () {
this.dictVisible = true
this.$nextTick(() => {
this.$refs.topicForm.init('add', { dictValueId: '', dictTypeId: this.dictTypeId })
})
},
// 修改
edit (id) {
this.dictVisible = true
this.$nextTick(() => {
this.$refs.topicForm.init('edit', { dictValueId: id, dictTypeId: this.dictTypeId })
})
},
// 删除
del (id) {
let ids = id || this.$refs.dictValueTable.getCheckboxRecords().map(item => {
return item.id
}).join(',')
this.$confirm(`确定删除所选项吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.EquipmentAccount.deleteDictValue(ids).then(({ data }) => {
this.$message.success(data)
this.refreshList()
this.$dictUtils.refreshDictList()
})
})
},
closeRight () {
this.$emit('closeRight')
}
}
}
</script>
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="点位:" prop="pointId" :rules="[{ message: '请选择地图类型', trigger: 'change' },]"> <el-form-item label="等待点位:" prop="pointId" :rules="[{ message: '请选择等待点位', trigger: 'change' },]">
<el-select v-model="formData.pointId" filterable placeholder="点位"> <el-select v-model="formData.pointId" filterable placeholder="等待点位">
<el-option v-for="item in formData.pointOptions" :key="item.id" :label="item.name" :value="item.id"> <el-option v-for="item in formData.pointOptions" :key="item.id" :label="item.name" :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
<vxe-column field="sort" title="排序" align="center" width="50px"></vxe-column> <vxe-column field="sort" title="排序" align="center" width="50px"></vxe-column>
<vxe-column field="createDate" title="创建时间" align="center" width="180px"></vxe-column> <vxe-column field="createDate" title="创建时间" align="center" width="180px"></vxe-column>
<vxe-column field="updateDate" title="更新时间" align="center" width="180px"></vxe-column> <vxe-column field="updateDate" title="更新时间" align="center" width="180px"></vxe-column>
<vxe-column title="操作" width="180px" align="center" fixed="right"> <vxe-column title="操作" width="250px" align="center" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="hasPermission('equipmentAccount:view')" type="text" size="mini" <el-button v-if="hasPermission('equipmentAccount:view')" type="text" size="mini"
@click="accountDetails(scope.row)">详情 @click="accountDetails(scope.row)">详情
...@@ -102,6 +102,8 @@ ...@@ -102,6 +102,8 @@
<el-button v-if="hasPermission('equipmentAccount:del')" type="text" size="mini" <el-button v-if="hasPermission('equipmentAccount:del')" type="text" size="mini"
@click="accountDelete(scope.row)">删除 @click="accountDelete(scope.row)">删除
</el-button> </el-button>
<el-divider direction="vertical"></el-divider>
<el-button v-if="hasPermission('equipmentAccount:edit') && scope.row.equipmentType === '4'" type="text" size="small" @click="showRight(scope.row)">管理主题</el-button>
</template> </template>
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>
...@@ -114,22 +116,34 @@ ...@@ -114,22 +116,34 @@
</div> </div>
<equipmentAccountAdd v-if="dialogConfig.open" ref="equipmentAccountAdd" :dialogConfig="dialogConfig"> <equipmentAccountAdd v-if="dialogConfig.open" ref="equipmentAccountAdd" :dialogConfig="dialogConfig">
</equipmentAccountAdd> </equipmentAccountAdd>
<el-drawer
size = "700px"
:title="`任务主题列表,所属设备: ${this.dictTypeTitle}`"
:visible.sync="rightVisible"
direction="rtl">
<topic-list :dict-type-title="dictTypeTitle" ref="topicList" @closeRight="closeRight"></topic-list>
</el-drawer>
</div> </div>
</template> </template>
<script> <script>
import equipmentAccountAdd from './add.vue' import equipmentAccountAdd from './add.vue'
import EquipmentAccount from '@/api/equipmentAdmin/EquipmentAccount' import EquipmentAccount from '@/api/equipmentAdmin/EquipmentAccount'
import TopicList from './TopicList'
export default { export default {
EquipmentAccount: null, EquipmentAccount: null,
name: '', name: '',
components: { components: {
equipmentAccountAdd equipmentAccountAdd,
TopicList
}, },
props: {}, props: {},
data () { data () {
return { return {
dictTypeTitle: '',
rightVisible: false,
searchForm: { searchForm: {
equipmentType: '', equipmentType: '',
equipmentNo: '', equipmentNo: '',
...@@ -163,6 +177,16 @@ export default { ...@@ -163,6 +177,16 @@ export default {
watch: {}, watch: {},
computed: {}, computed: {},
methods: { methods: {
closeRight () {
this.rightVisible = false
},
showRight (row) {
this.rightVisible = true
this.$nextTick(() => {
this.$refs.topicList.refreshList(row.equipmentNo)
this.dictTypeTitle = row.name
})
},
// 获取列表 // 获取列表
async getEquipmentPage () { async getEquipmentPage () {
this.loading = true this.loading = true
......
...@@ -112,12 +112,12 @@ export default { ...@@ -112,12 +112,12 @@ export default {
takeName: [ takeName: [
{ required: true, message: '请输入任务名称', trigger: 'blur' }, { required: true, message: '请输入任务名称', trigger: 'blur' },
], ],
deviceGroup: [ // deviceGroup: [
{ required: true, message: '请输入设备分组', trigger: 'blur' }, // { required: true, message: '请输入设备分组', trigger: 'blur' },
], // ],
mapName: [ // mapName: [
{ required: true, message: '请输入地图名称', trigger: 'blur' }, // { required: true, message: '请输入地图名称', trigger: 'blur' },
], // ],
variableStatus: [ variableStatus: [
{ required: true, message: '请选择是/否包含任务变量', trigger: 'blur' }, { required: true, message: '请选择是/否包含任务变量', trigger: 'blur' },
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment