YNUtdPlatform/pages/realName/index/pages/personList.vue

798 lines
25 KiB
Vue

<template>
<view class="page">
<u-navbar
class="u-navbar"
title="人员信息"
placeholder
@leftClick="leftClick"
leftIconColor="#fff"
rightIcon="list"
@rightClick="goIndex"
bgColor="#00337A"
:titleStyle="{ color: '#FFF', fontSize: '32rpx' }"
>
<view class="u-nav-slot" slot="right">
<text style="color: #fff">首页</text>
</view>
</u-navbar>
<view class="header-fixed">
<view class="search-content">
<view style="width: 25%">
<uni-data-select v-model="selectType" :localdata="range" :clear="false"></uni-data-select>
</view>
<view style="width: 70%">
<uni-easyinput
suffixIcon="search"
v-model="keyWord"
placeholder="请输入名称"
@iconClick="searchList"
></uni-easyinput>
</view>
<view class="search-icon" @tap="onSearchFilter"></view>
</view>
<view style="margin-top: 20rpx; color: #3f9dfd; letter-spacing: 2rpx">已查询{{ recordsTotal }}条数据</view>
</view>
<view style="padding: 0 20rpx">
<u-list class="data-container" @scrolltolower="scrolltolower" height="74vh">
<view
v-if="companyInfoList.length == 0"
style="
width: 96%;
height: 60vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
"
>
<image src="../../../../static/realName/noData.png" style="width: 100rpx; height: 120rpx" mode=""></image>
<view>暂无数据</view>
</view>
<u-list-item v-for="(item, index) in companyInfoList" v-if="companyInfoList.length > 0" :key="index">
<view class="scroll-item">
<view class="item-1">
<view>{{ index + 1 }}</view>
<view>
<text>{{ item.name }}-</text>
<text v-if="item.sex == '1.0'">男</text>
<text v-if="item.sex == '0.0'">女</text>
<text>-{{ item.age }}</text>
(
<text v-if="item.workerType == 0">临时用工</text>
<text v-if="item.workerType == 1">固定用工</text>
<text v-if="item.workerType == 2">分包管理人员</text>
)
<text v-if="item.isAtt != null" style="color: #06e7a3; margin-left: 80rpx; font-weight: 600">
已考勤
</text>
<text v-if="item.isAtt == null" style="color: #ff2f2f; margin-left: 80rpx; font-weight: 600">
未考勤
</text>
</view>
<uni-icons
:type="item.isCollect == 1 ? 'star-filled' : 'star'"
size="20"
@click="onCollection($event, item)"
:style="{ color: item.isCollect == 1 ? '#f9971e' : '' }"
style="position: absolute; right: 1%"
></uni-icons>
</view>
<view class="item-3" @click="onViewWorkDetails(item)">
<view style="width: 40%; margin: 0 20rpx; display: flex; align-items: center">
<view style="width: 100rpx">工种</view>
<view style="font-weight: bold; margin-left: 40rpx">{{ item.postName }}</view>
</view>
<view style="width: 45%; margin: 0 20rpx; display: flex; align-items: center">
<view style="width: 100rpx">联系方式</view>
<view style="color: #3f9dfd; font-weight: bold; margin-left: 40rpx">{{ item.phone }}</view>
</view>
</view>
<view class="item-3" @click="onViewWorkDetails(item)">
<view style="width: 40%; margin: 0 20rpx; display: flex; align-items: center">
<view style="width: 150rpx">是否为作业打卡</view>
<view style="font-weight: bold; margin-left: 40rpx">
<text style="color: #06e7a3" v-if="item.isPlanWorker == 1">是</text>
<text style="color: #ff2f2f" v-if="item.isPlanWorker == 0">否</text>
</view>
</view>
<view style="width: 45%; margin: 0 20rpx; display: flex; align-items: center">
<view style="width: 120rpx">红绿灯状态</view>
<view style="font-weight: bold; margin-left: 40rpx">
<text style="color: #06e7a3" v-if="item.lightStatus == 2">绿灯</text>
<text style="color: yellow" v-if="item.lightStatus == 1">黄灯</text>
<text style="color: #ff2f2f" v-if="item.lightStatus == 0">红灯</text>
</view>
</view>
</view>
<view
style="width: 100%; font-size: 24rpx; padding: 20rpx 0; border-bottom: 1px solid #eee"
@click="onViewWorkDetails(item)"
>
<view
style="width: 95%%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
>
<view style="width: 100rpx">所在班组</view>
<view style="width: 83%">
{{ item.teamName }}
</view>
</view>
</view>
<view
style="width: 100%; font-size: 24rpx; padding: 20rpx 0; border-bottom: 1px solid #eee"
@click="onViewWorkDetails(item)"
>
<view
style="width: 95%%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
>
<view style="width: 100rpx">所在分包</view>
<view style="width: 83%">
{{ item.subName }}
</view>
</view>
</view>
<view
style="width: 100%; font-size: 24rpx; padding: 20rpx 0; border-bottom: 1px solid #eee"
@click="onViewWorkDetails(item)"
>
<view
style="width: 95%%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
>
<view style="width: 100rpx">所在工程</view>
<view style="width: 83%">
{{ item.proName }}
</view>
</view>
</view>
</view>
</u-list-item>
</u-list>
</view>
<!-- 底部弹框 -->
<uni-popup ref="popup" type="bottom" background-color="#fff">
<view class="bottom-content">
<h1>条件筛选</h1>
<h2>分公司</h2>
<view>
<scroll-view class="company-container" scroll-y="true">
<view class="company-items">
<view
v-for="(item, index) in companyList"
:key="index"
:class="{ active: index === activeIndex }"
@tap="onSelectCompany(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<h2>红绿灯状态</h2>
<view>
<scroll-view class="company-container" scroll-y="true">
<view class="company-items">
<view
v-for="(item, index) in lightList"
:key="index"
:class="{ active: index === activeIndex2 }"
@tap="onSelectLight(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<h2>用工类型</h2>
<view>
<scroll-view class="company-container" scroll-y="true">
<view class="company-items">
<view
v-for="(item, index) in workTypeList"
:key="index"
:class="{ active: index === activeIndex3 }"
@tap="onSelectWorkType(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<h2>年龄分布</h2>
<view>
<scroll-view class="company-container" scroll-y="true">
<view class="company-items">
<view
v-for="(item, index) in ageTypeList"
:key="index"
:class="{ active: index === activeIndex4 }"
@tap="onSelectAgeType(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<h2>性别</h2>
<view>
<scroll-view class="company-container" scroll-y="true">
<view class="company-items">
<view
v-for="(item, index) in sexTypeList"
:key="index"
:class="{ active: index === activeIndex5 }"
@tap="onSelectSexType(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<h2>考勤状态</h2>
<view>
<scroll-view class="company-container" scroll-y="true">
<view class="company-items">
<view
v-for="(item, index) in attTypeList"
:key="index"
:class="{ active: index === activeIndex6 }"
@tap="onSelectAttType(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<h2>作业打卡</h2>
<view>
<scroll-view class="company-container" scroll-y="true" style="padding-bottom: 150rpx">
<view class="company-items">
<view
v-for="(item, index) in dayAttTypeList"
:key="index"
:class="{ active: index === activeIndex7 }"
@tap="onSelectDayAttType(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<view class="bottom-btn">
<button style="background-color: #fff; color: #00337a" @tap="onReset">重置</button>
<button style="background-color: #00337a; color: #fff" @tap="onQuery">查询</button>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import { getHomePageSelectApi } from '../../../../api/phaseTwo/homePage'
import config from '@/config'
export default {
data() {
return {
activeIndex: 0,
activeIndex2: 0,
activeIndex3: 0,
activeIndex4: 0,
activeIndex5: 0,
activeIndex6: 0,
activeIndex7: 0,
recordsTotal: 0,
token: uni.getStorageSync('tjToken'),
selectType: 0,
keyWord: '',
range: [
{ value: 0, text: '姓名' },
{ value: 1, text: '分包' },
{ value: 2, text: '班组' },
{ value: 3, text: '工种' }
],
// 查询参数
queryParams: {
page: 0,
offset: 0,
limit: 10,
params: {
userId: uni.getStorageSync('realNameUser').userId + '',
workerName: '', //人员姓名
subName: '', //分包名称
teamName: '', //班组名称
postName: '', //岗位名称
proId: '', //工程编号
subId: '', //分包编号
teamId: '', //班组编号
lightStatus: '', //灯状态
workerType: '', //人员类型
sex: '', //性别
isAtt: '', //是否考勤
subComId: '', //分公司编号
isPlanWorker: '', //是否作业打卡
startAge: '', //开始年龄
endAge: '' //结束年龄
}
},
isLoading: false,
companyList: [{ name: '全部', id: '' }],
lightList: [
{ name: '全部', id: '-1' },
{ name: '绿灯', id: '2' },
{ name: '黄灯', id: '1' },
{ name: '红灯', id: '0' }
],
workTypeList: [
{ name: '全部', id: '-1' },
{ name: '固定用工', id: '1,2' },
{ name: '临时用工', id: '0' }
],
ageTypeList: [
{ name: '全部', id: '-1' },
{ name: '<20', id: '0' },
{ name: '20-30', id: '1' },
{ name: '30-40', id: '2' },
{ name: '40-50', id: '3' },
{ name: '50-60', id: '4' }
],
sexTypeList: [
{ name: '全部', id: '-1' },
{ name: '男', id: '1' },
{ name: '女', id: '0' }
],
attTypeList: [
{ name: '全部', id: '-1' },
{ name: '已考勤', id: '0' },
{ name: '未考勤', id: '1' }
],
dayAttTypeList: [
{ name: '全部', id: '-1' },
{ name: '日计划打卡', id: '1' },
{ name: '非日计划打卡', id: '0' }
],
companyInfoList: []
}
},
mounted() {
this.getHomePageSelectData()
},
onLoad(option) {
console.log(option)
this.queryParams.params.proId = option.proId || ''
this.queryParams.params.subId = option.subId || ''
this.queryParams.params.teamId = option.teamId || ''
if (option.isAtt && option.isAtt == 0 && option.isPlanWorker && option.isPlanWorker == 1) {
//日计划打卡
this.activeIndex6 = 1
this.activeIndex7 = 1
this.queryParams.params.isAtt = '0'
this.queryParams.params.isPlanWorker = '1'
this.getListData()
} else if (option.isAtt && option.isAtt == 0) {
//已考勤
this.activeIndex6 = 1
this.queryParams.params.isAtt = '0'
this.getListData()
} else if (option.workerType && option.workerType == 1) {
//固定人员
this.activeIndex3 = 1
this.queryParams.params.workerType = '1,2'
this.getListData()
} else if (option.workerType && option.workerType == 0) {
//临时人员
this.activeIndex3 = 2
this.queryParams.params.workerType = '0'
this.getListData()
} else if (option.sex && option.sex == 1) {
//男
this.activeIndex5 = 1
this.queryParams.params.sex = '1'
this.getListData()
} else if (option.sex && option.sex == 0) {
//女
this.activeIndex5 = 2
this.queryParams.params.sex = '0'
this.getListData()
} else if (option.lightStatus && option.lightStatus == 2) {
//绿灯
this.activeIndex2 = 1
this.queryParams.params.lightStatus = '2'
this.getListData()
} else if (option.lightStatus && option.lightStatus == 1) {
//黄灯
this.activeIndex2 = 2
this.queryParams.params.lightStatus = '1'
this.getListData()
} else if (option.lightStatus && option.lightStatus == 0) {
//红灯
this.activeIndex2 = 3
this.queryParams.params.lightStatus = '0'
this.getListData()
} else if (option.isAtt && option.isAtt == 0 && option.workerType && option.workerType == 1) {
//已考勤-固定人员
this.activeIndex6 = 1
this.queryParams.params.isAtt = '0'
this.activeIndex3 = 1
this.queryParams.params.workerType = '1,2'
this.getListData()
} else if (option.isAtt && option.isAtt == 0 && option.workerType && option.workerType == 0) {
//已考勤-临时人员
this.activeIndex6 = 1
this.queryParams.params.isAtt = '0'
this.activeIndex3 = 2
this.queryParams.params.workerType = '0'
this.getListData()
} else if (option.selectType && option.postName) {
//已考勤-临时人员
this.selectType = Number(option.selectType)
this.keyWord = option.postName || ''
this.getListData()
} else if (option.ageType && option.ageType != '') {
//年龄
if (option.ageType == 0) {
this.activeIndex4 = 1
this.queryParams.params.startAge = '0'
this.queryParams.params.endAge = '20'
} else if (option.ageType == 1) {
this.activeIndex4 = 2
this.queryParams.params.startAge = '20'
this.queryParams.params.endAge = '30'
} else if (option.ageType == 2) {
this.activeIndex4 = 3
this.queryParams.params.startAge = '30'
this.queryParams.params.endAge = '40'
} else if (option.ageType == 3) {
this.activeIndex4 = 4
this.queryParams.params.startAge = '40'
this.queryParams.params.endAge = '50'
} else if (option.ageType == 4) {
this.activeIndex4 = 5
this.queryParams.params.startAge = '50'
this.queryParams.params.endAge = '60'
}
this.getListData()
} else {
this.getListData()
}
},
methods: {
scrolltolower() {
//判断 如果页码*页容量大于等于总条数,提示该页数据加载完毕
if (this.queryParams.limit >= this.recordsTotal) {
uni.$u.toast('数据加载完毕')
return
}
this.queryParams.page++
//页码+1,调用获取数据的方法获取第二页数据
if (this.queryParams.page == 0) {
this.queryParams.offset = 0
this.queryParams.limit = 10
} else {
this.queryParams.limit = this.queryParams.page * 10
}
//此处调用自己获取数据列表的方法
this.getListData()
},
searchList() {
this.queryParams.page = 0
this.queryParams.limit = 10
this.companyInfoList = []
this.getListData()
},
/* 获取列表 */
async getListData() {
if (this.selectType == 0) {
this.queryParams.params.workerName = this.keyWord
} else if (this.selectType == 1) {
this.queryParams.params.subName = this.keyWord
} else if (this.selectType == 2) {
this.queryParams.params.teamName = this.keyWord
} else if (this.selectType == 3) {
this.queryParams.params.postName = this.keyWord
}
this.queryParams.offset = this.queryParams.offset + ''
this.queryParams.limit = this.queryParams.limit + ''
console.log(this.queryParams)
this.isLoading = true
uni.request({
url: config.realBmwUrl + '/homeSubPage/getAppWorkerMsg',
method: 'POST',
data: JSON.stringify(this.queryParams),
header: {
'Content-Type': 'application/json'
// token: this.token
},
success: res => {
console.log('res****', res)
if (res.data.data?.length > 0) {
// if (this.queryParams.offset == 0) {
this.companyInfoList = res.data.data
// } else {
// this.companyInfoList = [...this.companyInfoList, ...res.data.data]
// }
this.recordsTotal = res.data.recordsTotal
}
this.isLoading = false
},
fail: err => {
this.isLoading = false
}
})
},
/* 获取公司数据 */
async getHomePageSelectData() {
const res = await getHomePageSelectApi()
this.companyList = this.companyList.concat(res.subList)
},
leftClick() {
// uni.navigateTo({ url: `/pages/realName/index/index` })
uni.navigateBack()
},
onSearchFilter() {
// 打开底部弹框
this.$refs.popup.open()
},
/* 选择公司 */
onSelectCompany(index, Id) {
this.activeIndex = index
if (index === 0) {
this.queryParams.params.subComId = ''
} else {
this.queryParams.params.subComId = Id
}
},
onSelectLight(index, Id) {
this.activeIndex2 = index
this.queryParams.params.lightStatus = Id
},
onSelectWorkType(index, Id) {
this.activeIndex3 = index
this.queryParams.params.workerType = Id
},
onSelectAgeType(index, Id) {
this.activeIndex4 = index
if (Id == -1) {
this.queryParams.params.startAge = '0'
this.queryParams.params.endAge = '99'
} else if (Id == 0) {
this.queryParams.params.startAge = '0'
this.queryParams.params.endAge = '20'
} else if (Id == 1) {
this.queryParams.params.startAge = '20'
this.queryParams.params.endAge = '30'
} else if (Id == 2) {
this.queryParams.params.startAge = '30'
this.queryParams.params.endAge = '40'
} else if (Id == 3) {
this.queryParams.params.startAge = '40'
this.queryParams.params.endAge = '50'
} else if (Id == 3) {
this.queryParams.params.startAge = '50'
this.queryParams.params.endAge = '60'
}
},
onSelectSexType(index, Id) {
this.activeIndex5 = index
this.queryParams.params.sex = Id
},
onSelectAttType(index, Id) {
this.activeIndex6 = index
this.queryParams.params.isAtt = Id
},
onSelectDayAttType(index, Id) {
this.activeIndex7 = index
this.queryParams.params.isPlanWorker = Id
},
/* 重置 */
onReset() {
this.activeIndex = 0
this.queryParams.params.subComId = ''
this.activeIndex2 = 0
this.queryParams.params.lightStatus = ''
this.activeIndex3 = 0
this.queryParams.params.workerType = ''
this.activeIndex4 = 0
this.queryParams.params.ageType = ''
this.queryParams.params.startAge = '0'
this.queryParams.params.endAge = '99'
this.activeIndex5 = 0
this.queryParams.params.sex = ''
this.activeIndex6 = 0
this.queryParams.params.isAtt = ''
this.activeIndex7 = 0
this.queryParams.params.isPlanWorker = ''
this.onQuery()
},
/* 查询 */
onQuery() {
this.queryParams.page = 0
this.queryParams.limit = 10
this.companyInfoList = []
this.getListData().then(() => {
this.$refs.popup.close()
})
},
/* 点击跳转详情 */
onViewWorkDetails(row) {
console.log(row)
uni.navigateTo({ url: `/pages/realName/index/pages/personDetail?idNumber=${row.idNumber}` })
},
goIndex() {
uni.navigateTo({ url: `/pages/realName/index/index` })
},
/* 收藏与取消收藏 */
onCollection(e, row) {
console.log(row)
const params = {
id: row.collectId,
userId: uni.getStorageSync('realNameUser').userId,
foreignId: row.idNumber,
type: 4
}
uni.request({
url: `${config.realAppUrl}${row.isCollect == 0 ? '/offLine/insertCollect' : '/offLine/deleteCollect'}`,
method: 'POST',
data: JSON.stringify(params),
header: {
'Content-Type': 'application/json',
token: this.token
},
success: res => {
if (res.data.code === 200) {
uni.showToast({ icon: 'none', title: ` ${row.isCollect == 0 ? '收藏成功' : '已取消收藏'}` })
this.getListData()
}
},
fail: err => {}
})
}
}
}
</script>
<style lang="scss" scoped>
.page {
width: 100vw;
height: 100vh;
background-color: #efefef;
box-sizing: border-box;
}
.header-fixed {
width: 94%;
margin: 20rpx auto;
background-color: #fff;
border-radius: 10rpx;
padding: 20rpx;
.search-content {
display: flex;
align-items: center;
.search-icon {
width: 48rpx;
height: 40rpx;
margin-right: 60rpx;
margin-left: 30rpx;
background: url('../../../../static/realName/screen.png') no-repeat;
background-size: 100% 100%;
}
}
}
.data-container {
width: 100%;
height: 75vh;
.scroll-item {
width: 100%;
height: auto;
background-color: #fff;
border-radius: 10rpx;
margin: 20rpx 0;
}
.item-1,
.item-3 {
width: 96%;
margin: 0 auto;
padding: 20rpx 0;
border-bottom: 1px solid #eee;
display: flex;
align-items: center;
position: relative;
}
.item-1 view:first-child {
width: 80rpx;
height: 56rpx;
margin-right: 16rpx;
text-align: center;
line-height: 56rpx;
background: url('../../../../static/realName/serial.png') no-repeat;
background-size: 100% 100%;
color: #fff;
font-weight: bold;
font-size: 28rpx;
}
.item-3 {
font-size: 24rpx;
justify-content: space-around;
}
}
.bottom-content {
height: 60vh;
overflow-y: auto;
h1,
h2 {
padding: 15rpx 0;
font-size: 32rpx;
}
h1 {
margin-top: 10rpx;
border-bottom: 1px solid #ccc;
text-align: center;
}
h2 {
padding-left: 16rpx;
// border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
.company-container {
width: 96%;
height: auto;
padding: 40rpx 20rpx;
.company-items {
width: 100%;
padding: 0 16rpx;
display: flex;
flex-wrap: wrap;
view {
width: 48%;
height: 48rpx;
margin-top: 10rpx;
line-height: 48rpx;
border-radius: 10rpx;
text-align: center;
background-color: #eee;
color: #656565;
}
.active {
background-color: #3f9dfd;
color: #fff;
}
}
.company-items view:nth-child(2n + 1) {
margin-right: 10rpx;
}
}
.bottom-btn {
width: 100%;
position: fixed;
display: flex;
bottom: 20rpx;
z-index: 9;
button {
flex: 1;
height: 80rpx;
margin: 0 20rpx;
line-height: 80rpx;
font-weight: normal;
border-radius: 20rpx;
border: 1rpx solid #00337a;
}
}
}
</style>