选择部门组件优化

This commit is contained in:
liuye
2023-05-26 09:43:02 +08:00
parent ebf5c78721
commit 1c24282a3e
2 changed files with 6 additions and 3 deletions

View File

@@ -50,9 +50,11 @@ export default {
...mapState(['user']), ...mapState(['user']),
isSingle: v => !!v.$route.query.single, isSingle: v => !!v.$route.query.single,
nodeKey: v => v.$route.query.nodeKey || "idNumber", nodeKey: v => v.$route.query.nodeKey || "idNumber",
isRequire: v => v.$route.query.isRequire || 1 isRequire: v => v.$route.query.isRequire || 1,
isAuth: v => !!v.$route.query.isAuth, //是否只能选择自己当前部门及以下
}, },
onLoad(query) { onLoad(query) {
console.log(query)
if (query.selected) { if (query.selected) {
this.selected = query.selected?.split(",").map(e => Number(e)) || [] this.selected = query.selected?.split(",").map(e => Number(e)) || []
} }
@@ -60,7 +62,8 @@ export default {
}, },
methods: { methods: {
getList() { getList() {
this.$http.post(`/app/wxcp/wxdepartment/listAll?name=${this.name}`).then(res => { var url = this.isAuth ? `/app/wxcp/wxdepartment/listByUser?name=${this.name}` : `/app/wxcp/wxdepartment/listAll?name=${this.name}`
this.$http.post(url).then(res => {
if (res?.data) { if (res?.data) {
res.data.forEach(e => e.isCheck = this.selected.includes(e[this.nodeKey])) res.data.forEach(e => e.isCheck = this.selected.includes(e[this.nodeKey]))
this.depts = new this.$tree(res.data, {parent: 'parentid'}) this.depts = new this.$tree(res.data, {parent: 'parentid'})

View File

@@ -12,7 +12,7 @@
</div> </div>
</div> </div>
<div class="select-dept"> <div class="select-dept">
<AiPagePicker type="dept" :selected.sync="deptList" single nodeKey="id" @select="getListInit" isRequire="1"> <AiPagePicker type="dept" :selected.sync="deptList" single nodeKey="id" @select="getListInit" isRequire="1" isAuth>
<span class="label">{{deptList[0].name}}</span> <span class="label">{{deptList[0].name}}</span>
<u-icon name="arrow-down" color="#999" size="28" style="margin-left:4px;"/> <u-icon name="arrow-down" color="#999" size="28" style="margin-left:4px;"/>
</AiPagePicker> </AiPagePicker>