|
|
@ -34,6 +34,11 @@ |
|
|
|
<el-col class="curd-in-out" style="height: calc(100vh - 190px)" :xs="10" :sm="8" :md="5" :lg="6" :xl="4"> |
|
|
|
|
|
|
|
<crudOperation :permission="permission"> |
|
|
|
<template v-slot:left> |
|
|
|
<el-button v-permission="permission.add" size="mini" icon="el-icon-plus" :disabled="crud.selections[0] && crud.selections[0].id && crud.selections[0].id !== defaultExpandedKeys" @click="crud.toAdd"> |
|
|
|
新增 |
|
|
|
</el-button> |
|
|
|
</template> |
|
|
|
<template v-slot:right> |
|
|
|
<el-button v-permission="permission.del" icon="el-icon-delete" size="mini" :loading="crud.delAllLoading" :disabled="crud.selections.length === 0" @click="toDelete(crud.selections)">删除</el-button> |
|
|
|
</template> |
|
|
@ -43,7 +48,7 @@ |
|
|
|
<span class="right-top-line" /> |
|
|
|
<span class="left-bottom-line" /> |
|
|
|
<div class="tree-scroll"> |
|
|
|
<el-tree ref="tree" v-loading="crud.loading" :data="crud.data" :props="defaultProps" node-key="id" :expand-on-click-node="false" highlight-current @node-click="handleNodeClick" /> |
|
|
|
<el-tree ref="tree" v-loading="crud.loading" :data="crud.data" :props="defaultProps" node-key="id" :default-expanded-keys="defaultExpandedKeys" highlight-current @node-click="handleNodeClick" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-col> |
|
|
@ -51,7 +56,7 @@ |
|
|
|
<el-col class="container-right" :xs="14" :sm="16" :md="19" :lg="18" :xl="20"> |
|
|
|
<span class="right-top-line" /> |
|
|
|
<span class="left-bottom-line" /> |
|
|
|
<deviceDetail ref="deviceDetail" :permission="permission" :active-add-btn="activeAddBtn" @treeRefresh="updateKeyChildren" /> |
|
|
|
<deviceDetail ref="deviceDetail" :permission="permission" :active-add-btn="activeRightBtn" /> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</div> |
|
|
@ -60,54 +65,53 @@ |
|
|
|
<script> |
|
|
|
import deviceDetail from './deviceDetail' |
|
|
|
import crudDevice from '@/api/storeManage/deviceManage/deviceDetail' |
|
|
|
import CRUD, { presenter, header, form } from '@crud/crud' |
|
|
|
import CRUD, { presenter, form } from '@crud/crud' |
|
|
|
import crudOperation from '@crud/CRUD.operation' |
|
|
|
import Vue from 'vue' |
|
|
|
|
|
|
|
const defaultForm = { id: null, dicName: null, dicCode: null, dicExplain: null, dicType: true } |
|
|
|
const defaultForm = { id: null, name: null, sort: null } |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'Dict', |
|
|
|
name: 'Device', |
|
|
|
components: { crudOperation, deviceDetail }, |
|
|
|
cruds() { |
|
|
|
return [ |
|
|
|
CRUD({ |
|
|
|
title: '区域', url: 'api/dictrionary/menu', |
|
|
|
title: '区域', url: 'api/storeroom/tree', |
|
|
|
crudMethod: { ...crudDevice }, |
|
|
|
optShow: { |
|
|
|
add: true, |
|
|
|
add: false, |
|
|
|
edit: true, |
|
|
|
del: false, |
|
|
|
download: false, |
|
|
|
group: false |
|
|
|
}, |
|
|
|
sort: ['dicSequence,asc'] |
|
|
|
sort: ['sort,asc'] |
|
|
|
}) |
|
|
|
] |
|
|
|
}, |
|
|
|
mixins: [presenter(), header(), form(defaultForm)], |
|
|
|
mixins: [presenter(), form(defaultForm)], |
|
|
|
data() { |
|
|
|
return { |
|
|
|
rules: { |
|
|
|
dicName: [ |
|
|
|
{ required: true, message: '请输入字典名称', trigger: 'blur' } |
|
|
|
], |
|
|
|
dicCode: [ |
|
|
|
{ required: true, message: '请输入字典代码', trigger: 'blur' } |
|
|
|
{ required: true, message: '请输入区域名称', trigger: 'blur' } |
|
|
|
] |
|
|
|
}, |
|
|
|
permission: { |
|
|
|
add: ['admin', 'dict:add'], |
|
|
|
edit: ['admin', 'dict:edit'], |
|
|
|
del: ['admin', 'dict:del'] |
|
|
|
add: ['admin', 'deviceManage:add'], |
|
|
|
edit: ['admin', 'deviceManage:edit'], |
|
|
|
del: ['admin', 'deviceManage:del'] |
|
|
|
}, |
|
|
|
defaultProps: { |
|
|
|
children: 'childMenus', |
|
|
|
label: 'dicName' |
|
|
|
children: 'children', |
|
|
|
label: 'name' |
|
|
|
}, |
|
|
|
activeAddBtn: false, |
|
|
|
activeRightBtn: false, |
|
|
|
deleteVisible: false, |
|
|
|
deleteData: {}, |
|
|
|
allowDelete: false // 是否允许删除当前区域 |
|
|
|
allowDelete: false, // 是否允许删除当前区域 |
|
|
|
defaultExpandedKeys: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
@ -118,37 +122,25 @@ export default { |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
// 选中字典后,设置字典详情数据 |
|
|
|
[CRUD.HOOK.afterRefresh]() { |
|
|
|
Vue.set(this.defaultExpandedKeys, 0, this.crud.data[0].id) |
|
|
|
this.$refs.tree.setCurrentKey(this.crud.data[0].id) |
|
|
|
this.crud.selections = [this.crud.data[0]] |
|
|
|
}, |
|
|
|
// 选中区域后,显示设备详情数据 |
|
|
|
handleNodeClick(val) { |
|
|
|
if (val) { |
|
|
|
if (val.dicType === 'true') { |
|
|
|
this.crud.selectionChangeHandler([val]) |
|
|
|
} else { |
|
|
|
this.crud.selectionChangeHandler([]) |
|
|
|
} |
|
|
|
this.crud.selectionChangeHandler([val]) |
|
|
|
this.$refs.deviceDetail.query.id = val.id |
|
|
|
this.$refs.deviceDetail.dicPid = val.id |
|
|
|
this.$refs.deviceDetail.crud.toQuery() |
|
|
|
this.activeAddBtn = true |
|
|
|
this.activeRightBtn = true |
|
|
|
} |
|
|
|
}, |
|
|
|
// 编辑前将字典明细临时清空,避免日志入库数据过长 |
|
|
|
// 编辑前将区域临时清空,避免日志入库数据过长 |
|
|
|
[CRUD.HOOK.beforeToEdit](crud, form) { |
|
|
|
// 将角色的菜单清空,避免日志入库数据过长 |
|
|
|
form.deviceDetails = null |
|
|
|
}, |
|
|
|
updateKeyChildren(data) { |
|
|
|
const oldDatas = this.$refs.tree.getCurrentNode().childMenus |
|
|
|
if (oldDatas) { |
|
|
|
for (let i = 0; i < data.length; i++) { |
|
|
|
const oldData = oldDatas.find((d) => { return d.id === data[i].id }) |
|
|
|
if (oldData) { |
|
|
|
data[i].childMenus = oldData.childMenus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.$refs.tree.updateKeyChildren(this.$refs.tree.getCurrentKey(), data) |
|
|
|
}, |
|
|
|
toDelete(data) { |
|
|
|
this.deleteData = data |
|
|
|
this.deleteVisible = true |
|
|
|