123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <template>
- <div class="app-container">
- <!-- <el-tree :data="curData" :props="defaultProps"></el-tree> -->
- <!-- default-expand-all -->
- <el-tree
- :data="curData"
- node-key="id"
- default-expand-all
- :expand-on-click-node="false">
- <span class="custom-tree-node" slot-scope="{ node, data }">
- <span>{{ node.data.name }} -- {{pTypeObj[node.data.perm_type]}} ----{{node.data.path}} ---- -- {{mhObj[node.data.menu_hidden]}}/{{psObj[node.data.perm_status]}} ----{{node.data.sort}}</span>
- <span>
- <el-button
- type="text"
- size="mini"
- @click="() => editMenu(data)">
- 编辑
- </el-button>
- <el-button
- type="text"
- size="mini"
- @click="() => appendMenu(data)">
- 添加
- </el-button>
- <el-button
- type="text"
- size="mini"
- @click="() => removeMenu(node, data)">
- 删除
- </el-button>
- </span>
- </span>
- </el-tree>
- <popup-edit
- :isShow="isPopupShow"
- :curObj="curObj"
- :curType="curType"
- @close="closePopup"
- />
- </div>
- </template>
- <script>
- import { arrToObj } from '@/utils'
- import SearchForm from './components/searchForm/Dict'
- import PopupEdit from './components/popup/MenuEdit'
- import baseTable from '_m/baseTable.js'
- export default {
- name: 'basePublicDictSys',
- components: {
- SearchForm,
- PopupEdit
- },
- provide () {
- return {
- parentData: this
- }
- },
- mixins: [baseTable],
- created () {},
- data () {
- const pTypeObj = arrToObj(this.$dictData.perm_type)
- const mhObj = arrToObj(this.$dictData.show_hidden)
- const psObj = arrToObj(this.$dictData.perm_status)
- return {
- defaultProps: {
- children: 'children',
- label: 'name'
- },
- curData: [],
- isPopupShow: false,
- curObj: {},
- curType: '',
- pTypeObj,
- mhObj,
- psObj,
- }
- },
- mounted () {
- this.getMenu()
- },
- methods: {
- getMenu () {
- this.$api.base.admpermissionslist().then(res => {
- let curData = res || []
- this.curData = [...this.formatData(curData)]
- })
- },
- formatData (arr, ids) {
- let newArr = []
- const curArr = JSON.parse(JSON.stringify(arr))
- curArr.forEach(item => {
- let obj = {...item}
- if (item.perm_type === '2' || item.perm_type === '1') {}
- obj.label = item.name
- obj.value = item.id
- obj.ids = ids ? [...ids, item.id] : [item.id]
- if (item.children && item.children.length > 0) {
- obj.children = this.formatData(item.children, obj.ids)
- }
- if (obj.children && obj.children.length === 0) delete obj.children
- newArr.push(obj)
- })
- return newArr
- },
- editMenu (row) {
- this.openPopup(row, 'edit')
- },
- appendMenu (row) {
- this.openPopup(row, 'add')
- },
- removeMenu (node, row) {
- const msgHtml = `确定要删除吗?`
- this.$msg(msgHtml, 'confirm', ()=> {
- this.$api.base.admpermissionsdel({
- id: row.id,
- }).then(data => {
- this.$msgs(`删除成功!`)
- this.getMenu()
- })
- }, null, true)
- },
- openPopup (row, type) {
- this.curObj = row
- this.curType = type
- this.isPopupShow = true
- },
- closePopup (obj) {
- this.isPopupShow = false
- if (obj) {
- this.getMenu()
- }
- }
- }
- }
- </script>
|