增加替换接口的参数

This commit is contained in:
aixianling
2023-06-27 09:49:10 +08:00
parent cc1026765f
commit 8e0265232b

View File

@@ -83,7 +83,9 @@
<el-scrollbar class="AiWechatSelecter-list"> <el-scrollbar class="AiWechatSelecter-list">
<div class="user-wrapper"> <div class="user-wrapper">
<el-checkbox-group v-model="userIds" @change="onCheckboxChange"> <el-checkbox-group v-model="userIds" @change="onCheckboxChange">
<el-checkbox v-for="item in list" :label="item[props.id]" :key="item[props.id]" @change="e => onboxChange(item[props.id], e)">{{ item.name }}</el-checkbox> <el-checkbox v-for="item in list" :label="item[props.id]" :key="item[props.id]"
@change="e => onboxChange(item[props.id], e)">{{ item.name }}
</el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</div> </div>
<AiEmpty v-if="!list.length"></AiEmpty> <AiEmpty v-if="!list.length"></AiEmpty>
@@ -99,7 +101,9 @@
@size-change="getList" @size-change="getList"
@current-change="getList"> @current-change="getList">
<div class="paginationPre" v-if="isMultiple"> <div class="paginationPre" v-if="isMultiple">
<el-checkbox :disabled="!list.length" :indeterminate="isIndeterminate" @change="onAllChange" v-model="isCheckAll">全选</el-checkbox> <el-checkbox :disabled="!list.length" :indeterminate="isIndeterminate" @change="onAllChange"
v-model="isCheckAll">全选
</el-checkbox>
</div> </div>
</el-pagination> </el-pagination>
</el-scrollbar> </el-scrollbar>
@@ -171,7 +175,8 @@
id: 'id' id: 'id'
} }
} }
} },
actions: {default: () => ({})}
}, },
data() { data() {
@@ -216,13 +221,7 @@
const arr = this.chooseUser.filter(v => { const arr = this.chooseUser.filter(v => {
return this.list.map(v => v.id).includes(v.id) return this.list.map(v => v.id).includes(v.id)
}) })
this.isCheckAll = !!(arr.length === this.list.length && this.list.length);
if (arr.length === this.list.length && this.list.length) {
this.isCheckAll = true
} else {
this.isCheckAll = false
}
return arr.length !== 0 && arr.length < this.list.length return arr.length !== 0 && arr.length < this.list.length
}, },
@@ -230,7 +229,6 @@
if (!this.value) { if (!this.value) {
return [] return []
} }
this.chooseUser = JSON.parse(JSON.stringify(this.value.map(item => { this.chooseUser = JSON.parse(JSON.stringify(this.value.map(item => {
return { return {
...item, ...item,
@@ -242,7 +240,12 @@
}))) })))
return this.value.map(v => v[this.props.id]) return this.value.map(v => v[this.props.id])
} },
action: v => ({
tree: "/app/wxcp/wxdepartment/listAll",
users: `/app/wxcp/wxuser/list`,
...v.actions
})
}, },
watch: { watch: {
@@ -393,20 +396,14 @@
}, },
arrDeduplication(arr) { arrDeduplication(arr) {
var hash = {} const hash = {};
arr = arr.reduce(function (item, next) { arr = arr.reduce(function (item, next) {
hash[next.id] ? '' : hash[next.id] = true && item.push(next) hash[next.id] = hash[next.id] || item.push(next)
return item return item
}, []) }, [])
return arr return arr
}, },
onCheckChange (e, isChoosed, isSunChoosed) {
this.$nextTick(() => {
})
},
removeUser(index, item) { removeUser(index, item) {
this.chooseUser.splice(index, 1) this.chooseUser.splice(index, 1)
this.userIds.splice(this.userIds.findIndex(v => v === item.id), 1) this.userIds.splice(this.userIds.findIndex(v => v === item.id), 1)
@@ -438,7 +435,7 @@
getList() { getList() {
this.loading = true this.loading = true
this.instance.post(`/app/wxcp/wxuser/list`, null, { this.instance.post(this.action.users, null, {
params: { params: {
...this.search, ...this.search,
departmentId: this.search.departmentId, departmentId: this.search.departmentId,
@@ -472,21 +469,14 @@
}, },
getTree() { getTree() {
this.instance.post(`/app/wxcp/wxdepartment/listAll?unitName=${this.unitName}`).then(res => { this.instance.post(this.action.tree, null, {
if (res.code === 0) { params: {unitName: this.unitName}
let parent = res.data.map(v => { }).then(res => {
v.label = v.name if (res?.data) {
v.children = [] this.unitList = this.$arr2tree(res.data)
const defaultRoot = this.unitList.at(0)?.id
return v this.defaultExpanded = [defaultRoot].filter(Boolean) || []
}).filter(e => !e.parentid)[0] this.search.departmentId = defaultRoot
if (!this.defaultExpanded.length) {
this.defaultExpanded = [parent.id]
}
this.search.departmentId = parent.id
this.addChild(parent, res.data)
this.unitList = [parent]
} }
}) })
}, },
@@ -636,6 +626,7 @@
margin-bottom: 0; margin-bottom: 0;
} }
} }
img { img {
width: 27px; width: 27px;
height: 27px; height: 27px;
@@ -779,6 +770,7 @@
justify-content: flex-end; justify-content: flex-end;
background: #fcfcfc; background: #fcfcfc;
padding: 10px 10px; padding: 10px 10px;
.paginationPre { .paginationPre {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -839,6 +831,7 @@
.tags-wrapper { .tags-wrapper {
padding: 0 8px; padding: 0 8px;
} }
.el-tag { .el-tag {
margin: 0 8px 8px 0px; margin: 0 8px 8px 0px;
color: #222222; color: #222222;