YNUtdPlatform/pages/realName/index/pages/project.vue

559 lines
16 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: 90%">
<uni-easyinput
suffixIcon="search"
v-model="queryParams.params.proName"
placeholder="请输入工程信息"
@iconClick="getListData"
></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">
<scroll-view class="data-container" scroll-y="true">
<view class="scroll-item" v-for="(item, index) in companyInfoList" :key="index">
<view class="item-1">
<view>{{ index + 1 }}</view>
<view>{{ item.proName }}</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-2">
<view>{{ item.subComName }}</view>
<view>{{ item.voltageLevel }}</view>
<view>{{ item.proType }}</view>
<view>{{ item.proStatus }}</view>
</view>
<view class="item-3">
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goSubListPage(item)"
>
<view>分包</view>
<view style="color: #3f9dfd; font-weight: bold">{{ item.subNum }}</view>
</view>
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goTeamListPage(item)"
>
<view>班组</view>
<view style="color: #3f9dfd; font-weight: bold">{{ item.teamNum }}</view>
</view>
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goAttPersonListPage(item)"
>
<view>考勤人数</view>
<view style="color: #3f9dfd; font-weight: bold">{{ item.attPersonNum }}</view>
</view>
</view>
<view class="item-3">
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goAllPersonListPage(item)"
>
<view>在场</view>
<view style="color: #3f9dfd; font-weight: bold">{{ item.einPersonNum }}</view>
</view>
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goWorkPersonListPage(item)"
>
<view>固定</view>
<view style="color: #3f9dfd; font-weight: bold">{{ item.formalPersonNum }}</view>
</view>
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goTempPersonListPage(item)"
>
<view>临时</view>
<view style="color: #3f9dfd; font-weight: bold">{{ item.temporaryPersonNum }}</view>
</view>
</view>
<view class="item-3">
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goLightPersonListPage(item, 2)"
>
<view>绿灯</view>
<view style="color: #3fb779; font-weight: bold">{{ item.greenPersonNum }}</view>
</view>
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goLightPersonListPage(item, 1)"
>
<view>黄灯</view>
<view style="color: #e89c2d; font-weight: bold">{{ item.yellowPersonNum }}</view>
</view>
<view
style="width: 25%; margin: 0 20rpx; display: flex; align-items: center; justify-content: space-between"
@tap="goLightPersonListPage(item, 0)"
>
<view>红灯</view>
<view style="color: #e8717f; font-weight: bold">{{ item.redPersonNum }}</view>
</view>
</view>
</view>
</scroll-view>
</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 proStatusList"
:key="index"
:class="{ active: index === activeIndex2 }"
@tap="onSelectStatus(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 levelList"
:key="index"
:class="{ active: index === activeIndex3 }"
@tap="onSelectLevel(index, item.id)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<h2>工程类型</h2>
<view>
<scroll-view class="company-container" scroll-y="true" style="padding-bottom: 120rpx">
<view class="company-items">
<view
v-for="(item, index) in proTypeList"
:key="index"
:class="{ active: index === activeIndex4 }"
@tap="onSelectType(index, item.name)"
>
{{ 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,
recordsTotal: 0,
token: uni.getStorageSync('tjToken'),
// 查询参数
queryParams: {
offset: '0',
limit: '999999',
params: {
userId: uni.getStorageSync('realNameUser').userId + '',
proName: '',
subComId: '',
proStatus: '',
voltageLevel: '',
proType: ''
}
},
companyList: [{ name: '全部', id: '' }],
proStatusList: [{ name: '全部', id: '' }],
levelList: [{ name: '全部', id: '' }],
proTypeList: [{ name: '全部', id: '' }],
companyInfoList: []
}
},
// mounted() {
// },
onLoad(option) {
this.getHomePageSelectData().then(() => {
if (option.voltageLevel) {
// 获取电压等级
const voltageLevel = JSON.parse(option.voltageLevel)
const { currentIndex, name } = voltageLevel
this.activeIndex3 = currentIndex + 1
this.queryParams.params.voltageLevel = this.levelList[currentIndex + 1].id
this.getListData()
} else if (option.proType) {
// 获取工程类型
const proType = JSON.parse(option.proType)
const { currentIndex, name } = proType
this.activeIndex4 = currentIndex + 1
this.queryParams.params.proType = this.proTypeList[currentIndex + 1].id
this.getListData()
} else if (option.survey) {
// 获取工程概况
const survey = JSON.parse(option.survey)
const { currentIndex, name } = survey
this.activeIndex2 = currentIndex
this.queryParams.params.proStatus = this.proStatusList[currentIndex+ 1].id
this.getListData()
} else if(option.proStatus&&option.proStatus==0){//在建
this.activeIndex2=1
this.queryParams.params.proStatus = "0"
this.getListData()
}else{
this.getListData()
}
})
},
methods: {
/* 获取作业计划列表 */
async getListData() {
console.log('this.queryParams参数', this.queryParams)
uni.request({
url: config.realBmwUrl + '/homeSubPage/getAppBuildPro',
method: 'POST',
data: JSON.stringify(this.queryParams),
header: {
'Content-Type': 'application/json'
// token: this.token
},
success: res => {
console.log('res****', res)
this.recordsTotal = res.data.recordsTotal
this.companyInfoList = res.data.data
},
fail: err => {}
})
},
/* 获取公司数据 */
async getHomePageSelectData() {
const res = await getHomePageSelectApi()
console.log('resresres', res)
this.companyList = this.companyList.concat(res.subList)
this.proTypeList = this.proTypeList.concat(res.proType)
this.proStatusList = this.proStatusList.concat(res.proStatusList)
this.levelList = this.levelList.concat(res.levelList)
},
leftClick() {
uni.navigateTo({ url: `/pages/realName/index/index` })
},
onSearchFilter() {
// 打开底部弹框
this.$refs.popup.open()
},
/* 选择公司 */
onSelectCompany(index, id) {
this.activeIndex = index
if (index === 0) {
this.queryParams.params.subComId = ''
} else {
this.queryParams.params.subComId = id
}
},
onSelectStatus(index, name) {
this.activeIndex2 = index
if (index === 0) {
this.queryParams.params.proStatus = ''
} else {
this.queryParams.params.proStatus = name
}
},
onSelectLevel(index, name) {
this.activeIndex3 = index
if (index === 0) {
this.queryParams.params.voltageLevel = ''
} else {
this.queryParams.params.voltageLevel = name
}
},
onSelectType(index, name) {
this.activeIndex4 = index
if (index === 0) {
this.queryParams.params.proType = ''
} else {
this.queryParams.params.proType = name
}
},
/* 重置 */
onReset() {
this.activeIndex = 0
this.queryParams.params.subComId = ''
this.activeIndex2 = 0
this.queryParams.params.proStatus = ''
this.activeIndex3 = 0
this.queryParams.params.voltageLevel = ''
this.activeIndex4 = 0
this.queryParams.params.proType = ''
this.onQuery()
},
/* 查询 */
onQuery() {
this.getListData().then(() => {
this.$refs.popup.close()
})
},
/* 点击跳转分包 */
goSubListPage(row) {
uni.navigateTo({ url: `/pages/realName/index/pages/subList?proId=${row.proId}` })
},
/* 点击跳转班组 */
goTeamListPage(row) {
uni.navigateTo({ url: `/pages/realName/index/pages/teamList?proId=${row.proId}` })
},
/* 点击跳转人员-已考勤 */
goAttPersonListPage(row) {
uni.navigateTo({ url: `/pages/realName/index/pages/personList?proId=${row.proId}&isAtt=0` })
},
/* 点击跳转人员-在场(全部) */
goAllPersonListPage(row) {
uni.navigateTo({ url: `/pages/realName/index/pages/personList?proId=${row.proId}` })
},
/* 点击跳转人员-固定 */
goWorkPersonListPage(row) {
uni.navigateTo({ url: `/pages/realName/index/pages/personList?proId=${row.proId}&workerType=1` })
},
/* 点击跳转人员-临时 */
goTempPersonListPage(row) {
uni.navigateTo({ url: `/pages/realName/index/pages/personList?proId=${row.proId}&workerType=0` })
},
/* 点击跳转人员-灯 */
goLightPersonListPage(row, type) {
//绿2 黄1 红0
uni.navigateTo({ url: `/pages/realName/index/pages/personList?proId=${row.proId}&lightStatus=${type}` })
},
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.proId,
type: 1
}
uni.request({
url: `${config.loginBaseUrl}${
row.isCollect == 0 ? '/app/offLine/insertCollect' : '/app/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 {
padding: 14rpx 0;
background-color: #fff;
margin: 20rpx auto;
}
.item-1,
.item-2,
.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-2,
.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;
padding-bottom: 120rpx;
.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>