114 lines
2.8 KiB
Vue
Raw Normal View History

<template>
<view class="people-list-box">
<headers :themeType="true" :showBack="true" class="fixedHeaderBox">
<view class="headerName" >
选择人员
</view>
</headers>
<view class="people-list" :style="{ 'padding-top': statusBarHeight + 44 + 'px' }">
<view class="people-item" v-for="(item,index) in peopleList" :key="index" @click="checkPeople($event,item)">
{{item.workerName}}
<view v-if="item.isCheck" class="success">
<icon type="success_no_circle" size="16" color="#67C23A"/>
</view>
</view>
</view>
</view>
</template>
<script>
import headers from "../../../components/headers/headers.vue"
export default{
components:{headers},
data(){
return{
peopleList: [],
checkList: [],
statusBarHeight: 0
}
},
components:{
headers
},
onShow(){
this.statusBarHeight=uni.getStorageSync('systemInfo').statusBarHeight;
this.projectSn = JSON.parse(uni.getStorageSync('userInfo')).sn;
if(uni.getStorageSync('attendee')){
this.checkList = JSON.parse(uni.getStorageSync('attendee'))
}
console.log(this.checkList)
this.selctPeopleList();
},
methods:{
selctPeopleList(){
let that = this
this.sendRequest({
url: "xmgl/systemUser/getProjectChilderSystemUserList",
data: {projectSn: this.projectSn},
method: "POST",
success(res){
that.peopleList = res.result;
for(let j=0;j<that.peopleList.length; j++){
that.peopleList[j].isCheck = false
// console.log(1)
if(that.checkList.length > 0){
for(let i = 0;i<that.checkList.length; i++){
// console.log(2)
if(that.checkList[i].userId == that.peopleList[j].userId){
that.peopleList[j].isCheck = true
}
}
}
}
console.log(that.peopleList, that.checkList)
}
})
},
checkPeople(e,val){
val.isCheck = !val.isCheck
this.$forceUpdate()
// console.log(this.peopleList)
if(val.isCheck){
if(this.checkList.length > 0){
for(let i = 0; i<this.checkList.length; i++){
if(this.checkList[i].userId == val.userId ){
return;
}
}
this.checkList.push(val)
} else {
this.checkList.push(val)
}
} else {
for(let i = 0; i<this.checkList.length; i++){
if(this.checkList[i].userId == val.userId ){
this.checkList.splice(i, 1)
}
}
}
uni.setStorageSync('attendee',JSON.stringify(this.checkList))
// console.log(this.checkList)
}
}
}
</script>
<style lang="less" scoped>
.people-list-box{
box-sizing: border-box;
.people-item{
padding-left: 40rpx;
padding-right: 40rpx;
width: 100%;
box-sizing: border-box;
height: 100rpx;
line-height: 100rpx;
border-bottom: 1px solid #eee;
display: flex;
justify-content: space-between;
align-items: center;
}
}
</style>