导航配置

This commit is contained in:
yanran200730
2022-03-18 16:54:02 +08:00
parent b9159b8e15
commit 872d05f47a

View File

@@ -1,5 +1,5 @@
<template> <template>
<ai-list class="list"> <ai-list class="list" v-loading="isLoading">
<ai-title slot="title" title="导航配置" isShowBottomBorder></ai-title> <ai-title slot="title" title="导航配置" isShowBottomBorder></ai-title>
<template slot="content"> <template slot="content">
<ai-card title="首页功能"> <ai-card title="首页功能">
@@ -37,7 +37,7 @@
<i class="el-icon-error icon" @click="removeApp(item.id)" v-if="isRemove && item.type !== '0' && item.picked !== '1'"></i> <i class="el-icon-error icon" @click="removeApp(item.id)" v-if="isRemove && item.type !== '0' && item.picked !== '1'"></i>
<i class="el-icon-circle-plus icon" @click="addApp(item)" v-if="isCanAdd(item)"></i> <i class="el-icon-circle-plus icon" @click="addApp(item)" v-if="isCanAdd(item)"></i>
<h2>{{ item.name }}</h2> <h2>{{ item.name }}</h2>
<div class="item-setting"> <div class="item-setting" v-if="item.type === '0'">
<div class="item-mask"></div> <div class="item-mask"></div>
<div class="item-wrapper__icon" @click.stop="editApp(item)"> <div class="item-wrapper__icon" @click.stop="editApp(item)">
<i class="el-icon-setting"></i> <i class="el-icon-setting"></i>
@@ -100,34 +100,34 @@
<el-form-item label="图标" prop="pictureUrl" style="width: 100%;" :rules="[{ required: true, message: '请上传图标 ', trigger: 'change' }]"> <el-form-item label="图标" prop="pictureUrl" style="width: 100%;" :rules="[{ required: true, message: '请上传图标 ', trigger: 'change' }]">
<ai-uploader v-model="form.pictureUrl" :instance="instance" :limit="1"></ai-uploader> <ai-uploader v-model="form.pictureUrl" :instance="instance" :limit="1"></ai-uploader>
</el-form-item> </el-form-item>
<el-form-item label="权限配置" v-if="form.type === '0'" prop="pictureUrl" style="width: 100%;"> <!-- <el-form-item label="权限配置" v-if="form.type === '0'" prop="pictureUrl" style="width: 100%;">
<el-input disabled :value="girdName" size="small" placeholder="请选择地区"> <el-input disabled :value="girdName" size="small" placeholder="请选择地区">
<template slot="append"> <template slot="append">
<el-button size="small" @click="isShowArea = true">选择地区</el-button> <el-button size="small" @click="isShowArea = true">选择地区</el-button>
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item> -->
</div> </div>
</el-form> </el-form>
<ai-dialog </ai-dialog>
title="选择网格" <ai-dialog
:visible.sync="isShowArea" title="选择权限"
:destroyOnClose="true" :visible.sync="isShowArea"
@close="showGrid = false" :destroyOnClose="true"
@onConfirm="getCheckedTree" @close="isShowArea = false"
width="720px"> @onConfirm="getCheckedTree"
<div class="grid"> width="720px">
<el-tree <el-tree
:data="treeList" :data="treeList"
:props="treeObj.defaultProps" :props="defaultProps"
node-key="id" node-key="id"
ref="tree" check-strictly
show-checkbox ref="tree"
:default-checked-keys="treeObj.checkedKeys" show-checkbox
default-expand-all> :default-checked-keys="defaultChecked"
</el-tree> :default-expanded-keys="defaultExpanded"
</div> default-expand-all>
</ai-dialog> </el-tree>
</ai-dialog> </ai-dialog>
</template> </template>
</ai-list> </ai-list>
@@ -153,11 +153,13 @@
id: '', id: '',
isEdit: false, isEdit: false,
isRemove: false, isRemove: false,
defaultExpanded: [],
isRest: true, isRest: true,
isShowArea: false, isShowArea: false,
isLoading: false,
defaultProps: { defaultProps: {
children: "girdList", children: "children",
label: "girdName", label: "label",
}, },
treeList: [], treeList: [],
form: { form: {
@@ -182,9 +184,9 @@
dictName: '客服', dictName: '客服',
dictValue: '4' dictValue: '4'
}], }],
info: {},
isShowAdd: false, isShowAdd: false,
list: [], list: [],
defaultExpanded: [],
defaultChecked: [] defaultChecked: []
} }
}, },
@@ -193,7 +195,6 @@
this.dict.load('homeConfigMenuType', 'miniConfigCheckType').then(() => { this.dict.load('homeConfigMenuType', 'miniConfigCheckType').then(() => {
this.getList() this.getList()
}) })
this.getTree()
}, },
methods: { methods: {
@@ -211,24 +212,18 @@
}) })
}, },
getTree() { getCheckedTree () {
this.instance.post(`/admin/area/queryAllArea?id=${this.user.info.areaId}`).then(res => { const keys = this.$refs.tree.getCheckedNodes(false, true).map(v => v.id)
this.instance.post(`/app/appminihomeconfig/addOrUpdate`, {
...this.info,
areaIds: keys
}).then(res => {
if (res.code === 0) { if (res.code === 0) {
let parent = res.data.map(v => { this.$message.success('修改成功')
v.label = v.name this.isShowArea = false
v.children = []
return v this.getList()
}).filter(e => !e.parentid)[0]
this.defaultExpanded = [parent.id]
this.defaultChecked = [parent.id]
this.search.areaId = parent.id
this.addChild(parent, res.data)
this.areaTree = [parent]
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(parent.id)
})
} }
}) })
}, },
@@ -248,15 +243,40 @@
}, },
editApp (e) { editApp (e) {
console.log(e) this.info = e
this.form = { this.isLoading = true
...e, this.instance.post(`/app/appminihomeconfig/queryDetailById?id=${e.id}`).then(res => {
pictureUrl: [{ if (res.code === 0) {
url: e.pictureUrl let parent = res.data.areaConfigs.map(v => {
}] v.label = v.name
v.children = []
return v
}).filter(e => !e.parentId)[0]
this.defaultExpanded = res.data.areaConfigs.filter(v => v.checked).map(v => v.id)
this.defaultChecked = res.data.areaConfigs.filter(v => v.checked).map(v => v.id)
this.addChild(parent, res.data.areaConfigs)
this.treeList = [parent]
this.isShowArea = true
}
this.isLoading = false
}).catch(() => {
this.isLoading = false
})
},
addChild(parent, list) {
for (let i = 0; i < list.length; i++) {
if (list[i].parentId === parent.id) {
parent.children.push(list[i])
}
} }
this.isShowAdd = true if (list.length > 0) {
parent['children'].map(v => this.addChild(v, list))
}
}, },
isCanAdd (item) { isCanAdd (item) {