Files
2024-10-31 14:34:57 +08:00

281 lines
6.4 KiB
Vue

<template>
<section class="chooseUser">
<div class="select-content">
<div class="area-flex">
<p class="title">地区</p>
<AiAreaPicker v-model="areaList" multiple class="value" extra>
<span class="label" v-if="areaList.length">已选择</span>
<span v-else style="color:#999;">请选择</span>
<u-icon name="arrow-right" color="#999" size="24" style="margin-left:8px;"/>
</AiAreaPicker>
</div>
<div class="area-flex">
<p class="title">部门/人员</p>
<AiPagePicker type="custom" :selected.sync="deptUserList" nodeKey="id" :ops="{url:'./selectDeptUser',label:'name'}" valueObj>
<!-- <div class="item active" v-for="item in deptUserList" :key="item.id">{{ item.name }}</div>
<AiMore v-if="deptUserList.length==0" class="right"/> -->
<span class="label" v-if="deptUserList.length">已选择</span>
<span v-else style="color:#999;">请选择</span>
<u-icon name="arrow-right" color="#999" size="24" style="margin-left:8px;"/>
</AiPagePicker>
</div>
<div class="type-content">
<div class="type-list" v-for="(item, index) in tagList" :key="index">
<p>{{ item.name }}</p>
<div class="list">
<div class="item" :class="items.isCheck ? 'active' : ''" v-for="(items, indexs) in item.tagList" :key="indexs" @click="typeClick(index, indexs)">
{{ items.name }}
</div>
</div>
</div>
</div>
</div>
<div class="bg-144"></div>
<div class="footer">
<div class="confirm" @click="confirm">确定</div>
</div>
</section>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: "chooseUser",
appName: "条件选择",
data() {
return {
value: '',
areaId: '',
areaName: '',
areaList: [],
tagList: [],
tagIdList: [],
userList: [],
deptList: [],
}
},
computed: {
...mapState(['user']),
deptUserList: {
set(v) {
this.userList = v.filter(e => e.kind == 'user')
this.deptList = v.filter(e => e.kind == 'dept')
},
get() {
let {userList, deptList} = this
return [userList, deptList].flat()
}
}
},
methods: {
getTagList() {
this.$http.post("/app/wxcp/wxcorptag/listAll?size=100").then(res => {
if (res?.code == 0) {
res.data.records.map((item) => {
item.tagList.map((items) => {
items.isCheck = this.tagIdList.includes(items.id);
})
})
this.tagList = res.data.records
}
})
},
typeClick(index, indexs) {
this.tagList[index].tagList[indexs].isCheck = !this.tagList[index].tagList[indexs].isCheck
},
confirm() {
// if(!this.areaList.length) {
// return this.$u.toast('请选择地区')
// }
this.tagIdList = []
this.tagList.map((item) => {
item.tagList.map((items) => {
if (items.isCheck) {
this.tagIdList.push(items.id)
}
})
})
// if(!this.tagIdList.length) {
// return this.$u.toast('请选择标签')
// }
var userIdList = [], deptIdList = []
this.userList.map((item) => {
userIdList.push(item.id)
})
this.deptList.map((item) => {
deptIdList.push(item.id)
})
uni.$emit('selectTag', {
areaIdList: this.areaList,
tagIdList: this.tagIdList,
userList: userIdList,
deptList: deptIdList
})
uni.navigateBack({})
},
},
onShow() {
document.title = '人员选择'
},
onLoad(option) {
console.log(option)
this.areaId = this.user.areaId
this.areaName = this.user.areaName
if (option.areaList) {
this.areaList = option.areaList.split(',')
}
if (option.tagIdList) {
this.tagIdList = option.tagIdList.split(',')
}
if (option.userList) {
var list = option.userList.split(',')
list.map(item => {
var info = {
id: item
}
this.userList.push(info)
})
}
if (option.deptList) {
var list = option.deptList.split(',')
list.map(item => {
var info = {
id: item
}
this.deptList.push(info)
})
}
this.getTagList()
},
}
</script>
<style lang="scss" scoped>
.chooseUser {
.select-content {
.area-flex {
display: flex;
justify-content: space-between;
padding: 32px;
line-height: 44px;
margin-bottom: 16px;
background-color: #fff;
.title {
width: 150px;
margin-bottom: 0;
}
.value {
width: calc(100% - 150px);
text-align: right;
}
}
.area-content {
padding: 16px 32px 32px;
border-bottom: 1px solid #ddd;
.area-item {
display: inline-block;
margin-right: 16px;
.u-icon {
margin-left: 4px;
}
}
}
.title {
line-height: 44px;
margin-bottom: 16px;
font-size: 32px;
color: #666;
.tips {
font-size: 34px;
color: #f46;
vertical-align: middle;
}
}
.local-icon {
width: 32px;
height: 32px;
margin-right: 4px;
}
.type-list {
padding-left: 16px;
margin-bottom: 16px;
padding: 34px 32px 32px;
background-color: #fff;
p {
line-height: 44px;
margin-bottom: 24px;
font-size: 30px;
color: #666;
}
.list {
overflow: hidden;
.item {
padding: 12px 32px;
float: left;
font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC;
color: #333;
line-height: 40px;
background-color: #F3F4F7;
border-radius: 4px;
margin: 0 16px 16px 0;
}
.active {
background-color: #3192F4;
color: #fff;
}
}
}
}
.bg-144 {
height: 144px;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 112px;
line-height: 112px;
background: #fff;
display: flex;
font-size: 36px;
font-family: PingFangSC-Regular, PingFang SC;
.confirm {
color: #fff;
background: #1365dd;
}
div {
flex: 1;
text-align: center;
color: #333;
}
}
::v-deep .u-icon__label {
font-size: 28px !important;
}
.right {
float: right;
}
}
</style>