Files
dvcp_v2_wxcp_app/src/project/saas/AppCooperationPropaganda/selectUser.vue

240 lines
5.1 KiB
Vue
Raw Normal View History

2022-07-20 17:00:46 +08:00
<template>
<section class="selectUser">
<div class="header-middle">
2022-07-25 18:02:40 +08:00
<div class="userCards" v-for="e in userList" :key="e.userId">
2022-07-20 17:00:46 +08:00
<div class="imges">
2022-07-26 10:32:07 +08:00
<div class="imgselect" :class="{ 'checked': e.isChecked }" @click.stop="itemCheck(e)" />
2022-07-26 11:05:58 +08:00
<img src="./images/tx@2x.png" alt="" class="avatras"/>
2022-07-20 17:00:46 +08:00
</div>
<div class="rights fill">
<div class="applicationNames">
2022-07-25 18:02:40 +08:00
<AiOpenData type="userName" :openid="e.userId"/>
2022-07-20 17:00:46 +08:00
</div>
</div>
</div>
2022-07-25 09:11:26 +08:00
<AiEmpty description="暂无数据" v-if="!userList"/>
2022-07-20 17:00:46 +08:00
</div>
<div class="subBtn" @click="submit">
<div>确定选择</div>
</div>
</section>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: "selectUser",
appName: "选择创建人",
data() {
return {
selected: [],
userList: [],
2022-08-02 11:17:34 +08:00
current: 1,
2022-07-20 17:00:46 +08:00
}
},
computed: {
...mapState(['user']),
hasData() {
return this.userList?.length > 0
}
},
onLoad() {
this.selected = uni.getStorageSync('userSelect') || []
2022-08-02 13:51:37 +08:00
this.getCreateUserList()
2022-07-20 17:00:46 +08:00
},
methods: {
2022-08-02 14:16:45 +08:00
isSelected(userId) {
return this.selected.userId===userId
2022-07-20 17:00:46 +08:00
},
2022-08-02 13:51:37 +08:00
getCreateUserList() {
2022-07-20 17:00:46 +08:00
this.userList = []
2022-08-02 14:16:45 +08:00
this.$http.post(`app/appmasssendingtask/createUserlist`, {}).then(res => {
2022-07-20 17:00:46 +08:00
if (res?.data) {
2022-08-02 13:51:37 +08:00
// let userArr = res.data.records.map(e => ({userId: e.createUserId, isChecked: this.isSelected(e.createUserId)}))
this.userList = res.data.map(e => ({userId: e, isChecked: this.isSelected(e)}))
// userArr.forEach(item=> {
// if(!this.userList.find(o=> o.userId === item.userId)) {
// this.userList.push(item)
// }
// })
2022-07-20 17:00:46 +08:00
}
})
},
itemCheck(row) {
2022-07-21 09:33:17 +08:00
this.userList.forEach(e => e.isChecked = false)
2022-07-26 11:05:58 +08:00
const index = this.userList.findIndex(o => {
2022-07-26 10:32:07 +08:00
return row.userId===o.userId
})
2022-07-26 11:05:58 +08:00
this.userList[index].isChecked = true
2022-07-26 10:32:07 +08:00
this.selected = this.userList[index]
2022-07-20 17:00:46 +08:00
},
submit() {
2022-07-26 10:32:07 +08:00
if(!this.selected.userId) {
2022-07-20 17:00:46 +08:00
return this.$u.toast('请选择创建人')
}
2022-07-26 11:05:58 +08:00
uni.$emit("pagePicker:custom", [this.selected])
2022-07-20 17:00:46 +08:00
uni.setStorageSync('userSelect', this.selected)
uni.navigateBack()
},
}
}
</script>
<style lang="scss" scoped>
.selectUser {
height: 100%;
background: #fff;
.header-top {
background: #fff;
padding: 20px 32px;
}
.header-middle {
padding-bottom: 140px;
.hint {
padding: 28px 20px 28px 32px;
line-height: 56px;
box-shadow: 0 1px 0 0 #e4e5e6;
font-size: 30px;
font-weight: 500;
word-break: break-all;
}
.empty-div {
height: 16px;
background: #f5f5f5;
}
.imges {
display: flex;
align-items: center;
.imgselect {
width: 48px;
height: 48px;
vertical-align: middle;
background-image: url("./images/xz.png");
background-position: center;
background-size: 100% 100%;
&.checked {
background-image: url("./images/xzh.png");
}
}
.avatras {
width: 74px;
height: 74px;
border-radius: 8px;
margin-left: 36px;
}
}
.cards {
display: flex;
align-items: center;
height: 120px;
line-height: 120px;
padding: 0 0 0 32px;
img {
width: 74px;
height: 74px;
border-radius: 8px;
}
.rightes {
width: calc(100% - 160px);
display: flex;
align-items: center;
margin-left: 32px;
border-bottom: 1px solid #e4e5e6;
.applicationNames {
flex: 1;
min-width: 0;
font-size: 36px;
font-weight: 500;
color: #333333;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.imgs {
flex-shrink: 0;
width: 40px;
height: 40px;
margin-right: 20px;
}
}
}
.userCards {
display: flex;
align-items: center;
height: 120px;
line-height: 120px;
padding: 0 0 0 32px;
.rights {
display: flex;
justify-content: space-between;
align-items: center;
margin-left: 32px;
border-bottom: 1px solid #e4e5e6;
padding-right: 40px;
height: inherit;
.applicationNames {
font-size: 36px;
font-weight: 500;
color: #333333;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.idNumbers {
color: #666;
}
}
}
}
.subBtn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 118px;
background: #f4f8fb;
div {
width: 192px;
height: 80px;
line-height: 80px;
text-align: center;
background: #1365dd;
border-radius: 4px;
font-size: 32px;
color: #fff;
margin: 20px 34px 0 0;
float: right;
}
}
.color-3F8DF5 {
color: #3F8DF5;
}
.mar-h4 {
margin: 0 4px;
}
}
</style>