detection-business/pages/index/countEmployees.vue

388 lines
8.5 KiB
Vue
Raw Normal View History

2025-02-21 15:03:52 +08:00
<template>
2025-04-30 15:05:20 +08:00
<view class="">
<headersVue :titles="titles">
<u-icon name="arrow-left" color="#fff" size="18"></u-icon>
</headersVue>
<view class="content">
2025-07-11 10:17:36 +08:00
<view>
<u-subsection :list="dateRangeList" keyName="label" :current="selected"
@change="slectRange"></u-subsection>
</view>
2025-06-16 17:17:24 +08:00
<view style="margin-top: 20rpx">
<uni-datetime-picker v-model="queryParams.datetimeRange" type="daterange" rangeSeparator="至"
@change="getStaffCount" />
</view>
2025-04-30 15:05:20 +08:00
<!-- 顶部选择区域 -->
2025-05-07 16:06:58 +08:00
<!-- <view class="top_">
2025-04-30 15:05:20 +08:00
<view class="select-container" @click="showDropdown">
<view class="select-text">
{{ queryStr != null ? queryStr : '请选择工作内容' }}
</view>
<u-icon style="margin-left: 10rpx;" name="arrow-down" size="18" color="#8D90A6"></u-icon>
</view>
<u-icon v-if="queryStr" name="close-circle" color="#8D90A6" size="18" @click="clearSelection"></u-icon>
2025-05-07 16:06:58 +08:00
</view> -->
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
<!-- 列表区域 -->
<view class="list_">
<view class="list_title">
<view class="list_ds">
2025-07-11 10:17:36 +08:00
<view style="margin-right: 50px">排名</view>
2025-04-30 15:05:20 +08:00
<view>员工</view>
</view>
<view>服务台次</view>
</view>
<view class="list_box" v-for="(item, index) in List" :key="index">
2025-05-13 13:16:32 +08:00
<view class="list_box_top" @click="goDetail(item)">
2025-07-11 10:17:36 +08:00
<view class="pm_" v-if="index != 0 && index != 2 && index != 1">{{
index + 1
}}</view>
2025-04-30 15:05:20 +08:00
<view class="pm_ one" v-if="index == 0">{{ index + 1 }}</view>
<view class="pm_ two" v-if="index == 1">{{ index + 1 }}</view>
<view class="pm_ three" v-if="index == 2">{{ index + 1 }}</view>
<view class="list_ds">
<view class="tx_">
<image v-if="item.avatar" style="border-radius: 50%"
:src="baseImageUrl + '/' + item.avatar" mode=""></image>
<image src="/static/imgs/touxiang.png" v-else mode=""></image>
</view>
<view>
<view>{{ item.nickname }}</view>
<view class="num_hui">{{ item.mobile }}</view>
</view>
</view>
<view>{{ item.totalCount }}</view>
</view>
<scroll-view class="scroll-wrap" scroll-x>
<view class="scroll-item" v-for="data in item.children" :key="data.projectName">
<view class="scroll-label">{{ data.projectName }}</view>
<view class="scroll-value">{{ data.count }}</view>
</view>
</scroll-view>
</view>
</view>
</view>
<!-- 选择器 -->
<u-picker :show="isShowScreen" :columns="[columns]" @cancel="handleCancel" keyName="projectName"
@confirm="submitScreen"></u-picker>
</view>
2025-02-21 15:03:52 +08:00
</template>
<script>
2025-07-11 10:17:36 +08:00
import headersVue from "../../components/header/headers.vue";
2025-04-30 15:05:20 +08:00
import request from "@/utils/request";
import config from "config";
2025-07-11 10:17:36 +08:00
import {
getDateRange
} from "@/utils/utils";
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
export default {
data() {
return {
titles: "员工统计",
List: [],
selectList: [],
useSelectList: [],
show: false,
2025-07-11 10:17:36 +08:00
status: "loading",
2025-04-30 15:05:20 +08:00
baseImageUrl: config.baseImageUrl,
isShowScreen: false,
columns: [],
queryParams: {},
queryStr: null,
2025-07-11 10:17:36 +08:00
selected: "day",
dateRangeList: [{
label: "本日",
value: "day",
},
{
label: "本月",
value: "month",
},
],
2025-04-30 15:05:20 +08:00
};
},
components: {
headersVue,
},
onLoad() {
2025-06-16 17:17:24 +08:00
const now = new Date();
2025-07-11 10:17:36 +08:00
this.setCurrentMonthRange();
2025-06-06 10:46:40 +08:00
2025-06-16 17:17:24 +08:00
this.getStaffCount();
2025-04-30 15:05:20 +08:00
this.getInspectionProject();
},
methods: {
// 获取员工统计
getStaffCount() {
request({
2025-07-11 10:17:36 +08:00
url: "/partnerOwn/partner/getStaffCount",
method: "post",
2025-04-30 15:05:20 +08:00
data: this.queryParams,
}).then((res) => {
this.$nextTick(() => {
this.List = res.data;
});
});
2025-06-16 17:17:24 +08:00
}, // 补零1 → 01
pad(n) {
2025-07-11 10:17:36 +08:00
return n.toString().padStart(2, "0");
2025-06-16 17:17:24 +08:00
},
// Date → "YYYY-MM-DD"
formatDate(d) {
2025-07-11 10:17:36 +08:00
// 添加类型检查,确保 d 是 Date 对象
if (!(d instanceof Date)) {
console.error("formatDate() 期望接收 Date 对象,但收到:", d);
d = new Date(d); // 尝试转换为 Date 对象
if (isNaN(d.getTime())) {
// 检查是否有效日期
d = new Date(); // 如果转换失败,使用当前日期
}
}
return `${d.getFullYear()}-${this.pad(d.getMonth() + 1)}-${this.pad(
d.getDate()
)}`;
2025-06-16 17:17:24 +08:00
},
2025-07-11 10:17:36 +08:00
2025-06-16 17:17:24 +08:00
// 设置本月起止日期:月初到今天
setCurrentMonthRange() {
2025-07-11 10:17:36 +08:00
// 直接使用 Date 对象
2025-06-16 17:17:24 +08:00
const now = new Date();
2025-07-11 10:17:36 +08:00
// 创建月初的 Date 对象
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
2025-06-16 17:17:24 +08:00
this.queryParams.datetimeRange = [
2025-07-11 15:56:41 +08:00
this.formatDate(now), // 月初
2025-07-11 10:17:36 +08:00
this.formatDate(now), // 今天
2025-06-16 17:17:24 +08:00
];
2025-04-30 15:05:20 +08:00
},
2025-07-11 10:17:36 +08:00
// 辅助函数:补零
pad(num) {
return num.toString().padStart(2, "0");
},
2025-04-30 15:05:20 +08:00
// 获取工作内容列表
getInspectionProject() {
request({
2025-07-11 10:17:36 +08:00
url: "/inspection/dl-inspection-project/page",
method: "get",
2025-04-30 15:05:20 +08:00
params: {
pageNo: 1,
pageSize: 10000,
},
}).then((res) => {
this.columns = res.data.records;
});
},
2025-07-11 10:17:36 +08:00
slectRange(e) {
this.selected = e;
console.log(e, this.selected);
const {
value
} = this.dateRangeList[e];
console.log(value);
// this.queryParams.datetimeRange = [
// this.formatDate(firstDay),
// this.formatDate(now)
// ];
this.queryParams.datetimeRange = getDateRange(value);
this.getStaffCount();
},
2025-05-13 13:16:32 +08:00
goDetail(data) {
uni.navigateTo({
2025-07-11 10:17:36 +08:00
url: `/pages/index/staffProjectList/staffProjectList?userId=${data.userId}`,
});
2025-05-13 13:16:32 +08:00
},
2025-04-30 15:05:20 +08:00
// 显示下拉框
showDropdown() {
this.isShowScreen = true;
},
// 处理选择器确认事件
submitScreen(e) {
this.isShowScreen = false;
this.queryParams.id = e.value[0].id;
this.queryStr = e.value[0].projectName;
this.getStaffCount();
},
// 处理选择器取消事件
handleCancel() {
this.isShowScreen = false;
},
// 清除选择
clearSelection() {
this.queryParams.id = null;
this.queryStr = null;
this.getStaffCount();
},
},
};
2025-02-21 15:03:52 +08:00
</script>
<style scoped lang="scss">
2025-04-30 15:05:20 +08:00
.content {
background: #f7f8fc;
width: 100%;
padding-top: 200rpx;
}
.top_ {
width: 100%;
height: 104rpx;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0 30rpx;
border-bottom: 1rpx solid #f5f5f5;
.select-container {
display: flex;
align-items: center;
flex: 1; // 让这个区域撑满可用空间
}
.select-text {
font-size: 28rpx;
color: #101a3e;
}
}
.list_ {
width: 100%;
box-sizing: border-box;
padding: 30rpx;
}
.list_title {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #101a3e;
box-sizing: border-box;
padding: 0 30rpx;
margin-bottom: 20rpx;
}
.list_ds {
display: flex;
align-items: center;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.list_box {
width: 100%;
background: #ffffff;
border-radius: 8rpx;
margin-bottom: 30rpx;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.list_box_top {
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 30rpx 50rpx;
border-bottom: 2rpx solid #f5f5f5;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.list_box_bottom {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx 50rpx;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.tx_ {
width: 90rpx;
height: 90rpx;
margin-right: 5px;
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
image {
width: 100%;
height: 100%;
}
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.num_hui {
font-size: 24rpx;
color: #8d90a6;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.text_ {
font-size: 28rpx;
color: #8d90a6;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.num_ {
font-size: 28rpx;
color: #101a3e;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.pm_ {
width: 40rpx;
height: 40rpx;
background: #327dfb;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 28rpx;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.one {
background: url(../../static/imgs/oneStaff.png);
width: 55rpx;
/* height: 156px; */
background-repeat: no-repeat;
background-size: cover;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.two {
background: url(../../static/imgs/twoStaff.png);
width: 55rpx;
/* height: 156px; */
background-repeat: no-repeat;
background-size: cover;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.three {
background: url(../../static/imgs/threeStaff.png);
width: 55rpx;
background-repeat: no-repeat;
background-size: cover;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.scroll-wrap {
display: flex;
flex-direction: row;
white-space: nowrap;
overflow-x: auto;
padding: 16rpx;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.scroll-item {
flex-shrink: 0;
display: inline-block;
border-radius: 12rpx;
padding: 12rpx 20rpx;
margin-right: 20rpx;
min-width: 180rpx;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.scroll-label {
font-size: 26rpx;
font-weight: 500;
color: #555;
}
2025-02-26 18:08:08 +08:00
2025-04-30 15:05:20 +08:00
.scroll-value {
font-size: 28rpx;
color: #000;
margin-top: 6rpx;
}
</style>