InspectionCleaning/pages/index/index.vue

322 lines
8.0 KiB
Vue
Raw Normal View History

2025-04-07 09:30:11 +08:00
<template>
<view class="content">
2025-04-18 11:55:50 +08:00
<view v-if="false" style="display:flex">
2025-04-14 09:23:50 +08:00
<u-button type="error" @click="testFn">调试录入卡片</u-button>
2025-04-14 09:22:42 +08:00
</view>
2025-04-08 16:34:34 +08:00
<daySelect @dateChange="onDateChange" />
2025-04-09 13:44:35 +08:00
<view v-if="isToday" class="task-info">
2025-04-07 09:30:11 +08:00
<view class="title">今日任务</view>
2025-04-08 16:34:34 +08:00
<!-- 当日计划 点击跳转 -->
2025-04-07 09:30:11 +08:00
<view class="task-list">
2025-04-09 13:44:35 +08:00
<!-- <view class="task-item" >
2025-04-09 09:15:03 +08:00
<view class="name-state">
<view class="name">足球场休息室</view>
<u-tag text="已完成" type="success" border-color="transparent" />
</view>
<view class="time">
<u-tag text="9:00~12:00" type="info" border-color="transparent" />
</view>
2025-04-09 13:44:35 +08:00
</view> -->
<view
class="task-item"
v-for="item in planList"
:key="item.id"
@click="handleTaskClick(item)"
>
2025-04-07 09:30:11 +08:00
<view class="name-state">
2025-04-09 13:44:35 +08:00
<view class="name">{{ item.name }}</view>
<u-tag
v-if="item.isCompleted == 0"
text="待保洁"
type="info"
border-color="transparent"
/>
<u-tag
v-else
text="已完成"
type="success"
border-color="transparent"
/>
2025-04-07 09:30:11 +08:00
</view>
2025-04-08 16:34:34 +08:00
2025-04-07 09:30:11 +08:00
<view class="time">
2025-04-09 13:44:35 +08:00
<u-tag
:text="item.beginTime + '~' + item.endTime"
type="info"
border-color="transparent"
/>
2025-04-07 09:30:11 +08:00
</view>
</view>
</view>
</view>
2025-04-09 13:44:35 +08:00
<view v-if="isToday" class="area-schedule">
2025-04-07 09:30:11 +08:00
<view class="finish">
<view class="point"></view>
<view class="title">已保洁区域</view>
2025-04-09 13:44:35 +08:00
<view class="count-rate">
{{ todayCompletion.completed }}
<view class="total">/{{ todayCompletion.total }}</view>
</view>
2025-04-07 09:30:11 +08:00
<u-line-progress
height="10"
class="schedule-line"
:show-percent="false"
active-color="#2979ff"
2025-04-09 13:44:35 +08:00
:percent="(todayCompletion.completed / todayCompletion.total) * 100"
2025-04-07 09:30:11 +08:00
></u-line-progress>
</view>
<view class="unfinish">
<view class="point"></view>
2025-04-09 13:44:35 +08:00
<view class="title">待保洁区域</view>
<view class="count-rate">
{{ todayCompletion.notCompleted }}
<view class="total">/{{ todayCompletion.total }}</view>
</view>
2025-04-07 09:30:11 +08:00
<u-line-progress
height="10"
class="schedule-line"
:show-percent="false"
active-color="#FC873D"
2025-04-09 13:44:35 +08:00
:percent="
(todayCompletion.notCompleted / todayCompletion.total) * 100
"
2025-04-07 09:30:11 +08:00
></u-line-progress>
</view>
</view>
2025-04-09 13:44:35 +08:00
2025-04-08 16:34:34 +08:00
<!-- 非当日计划 仅展示 -->
2025-04-09 13:44:35 +08:00
<view v-if="!isToday" class="cleaning-plan-box">
<!-- <view class="cleaning-plan">
2025-04-08 16:34:34 +08:00
<view class="title">今日保洁计划名称</view>
<view class="time">
<view class="top">00:00:00</view>
<view class="bottom">23:59:00</view>
</view>
2025-04-09 13:44:35 +08:00
</view> -->
<view class="cleaning-plan" v-for="item in planList" :key="item.id">
<view class="title">{{ item.name }}</view>
2025-04-08 16:34:34 +08:00
<view class="time">
2025-04-09 13:44:35 +08:00
<view class="top">{{ item.beginTime }}</view>
<view class="bottom">{{ item.endTime }}</view>
2025-04-08 16:34:34 +08:00
</view>
2025-04-07 09:30:11 +08:00
</view>
</view>
2025-04-15 10:07:11 +08:00
<u-tabbar :list="vuex_tabbar"></u-tabbar>
2025-04-07 09:30:11 +08:00
</view>
</template>
<script>
2025-04-09 13:44:35 +08:00
import { GetPlanByDate, TodayCompletion } from "@/api/apiList";
2025-04-09 09:15:03 +08:00
import { useRouter } from "@/utils/utils.js";
2025-04-07 09:30:11 +08:00
import daySelect from "@/components/daySelect/index.vue";
export default {
components: {
daySelect,
},
2025-04-08 16:34:34 +08:00
data() {
return {
isToday: true,
currentDate: "",
2025-04-09 13:44:35 +08:00
planList: [],
// 今日完成情况
todayCompletion: {
total: 0,
completed: 0,
notCompleted: 0,
},
2025-04-08 16:34:34 +08:00
};
},
2025-04-09 13:44:35 +08:00
mounted() {
2025-04-14 15:10:19 +08:00
console.log("%c%s", "color:red", "mounted--");
2025-04-09 13:44:35 +08:00
this.getPlanByDate();
},
2025-04-08 16:34:34 +08:00
methods: {
2025-04-14 09:22:42 +08:00
testFn(){
let u = navigator.userAgent;
let isAndroid =
u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android
// let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios
try {
if (isAndroid && AndroidJs) {
console.log("%c%s", "color:red", "安卓--调用方法");
const reqRow = {
name: "input",
data: "",
};
AndroidJs.func(JSON.stringify(reqRow)); // 给安卓传参
} else {
console.log("%c%s", "color:red", "苹果--调用方法");
const reqRow = {
name: "back-iphone",
data: "",
};
window.webkit.messageHandlers.func.postMessage(
JSON.stringify(reqRow)
); // 给ios 传参
}
} catch (e) {
console.log(e, "e-----判断安卓苹果类型出错");
}
},
2025-04-08 16:34:34 +08:00
onDateChange({ date, isToday }) {
this.isToday = isToday;
this.currentDate = date;
2025-04-09 13:44:35 +08:00
this.getPlanByDate();
if (isToday) {
this.getTodayCompletion();
}
2025-04-08 16:34:34 +08:00
},
2025-04-09 13:44:35 +08:00
handleTaskClick(item) {
console.log(item);
2025-04-14 15:10:19 +08:00
2025-04-09 13:44:35 +08:00
uni.navigateTo({
url: `/pages/index/cleanPlan?id=${item.id}`,
});
},
// 根据日期获取计划
async getPlanByDate() {
this.planList = [];
const res = await GetPlanByDate({ Date: this.currentDate });
if (res.succeed) {
this.planList = res.data;
}
},
// 今日完成情况
async getTodayCompletion() {
const res = await TodayCompletion();
if (res.succeed) {
this.todayCompletion = { ...res.data };
this.todayCompletion.total = res.data.completed + res.data.notCompleted;
}
2025-04-09 09:15:03 +08:00
},
2025-04-08 16:34:34 +08:00
},
2025-04-07 09:30:11 +08:00
};
</script>
<style lang="scss" scoped>
.content {
2025-04-09 13:44:35 +08:00
// height: 100vh; // 确保容器有明确高度
2025-04-07 09:30:11 +08:00
overflow: hidden;
2025-04-09 13:44:35 +08:00
padding-bottom: 100rpx;
2025-04-07 09:30:11 +08:00
}
.task-info {
margin: 0 32rpx;
padding: 18rpx;
background: #f5f6fa;
border-radius: 24rpx;
.title {
font-weight: bold;
font-size: 34rpx;
color: #282828;
}
.task-list {
margin-top: 36rpx;
display: flex;
flex-direction: column;
.task-item {
2025-04-09 09:15:03 +08:00
margin-bottom: 20rpx;
2025-04-07 09:30:11 +08:00
padding: 44rpx 30rpx;
background: #ffffff;
border-radius: 16rpx;
.name-state {
display: flex;
justify-content: space-between;
.name {
2025-04-09 13:44:35 +08:00
padding-left: 6rpx;
2025-04-07 09:30:11 +08:00
position: relative;
}
.name::before {
content: "";
position: absolute;
top: 10%;
left: -6%;
display: inline-block;
width: 5rpx;
height: 30rpx;
background: #3d6af0;
}
}
.time {
margin-top: 20rpx;
}
}
}
}
.area-schedule {
margin: 0 32rpx;
margin-top: 26rpx;
display: flex;
justify-content: space-between;
> view {
padding: 22rpx;
width: 48%;
background: #f5f6fa;
border-radius: 10rpx;
.point {
width: 12rpx;
height: 12rpx;
background: #4473fe;
border-radius: 50%;
}
.title {
margin-top: 28rpx;
font-size: 32rpx;
color: #292929;
}
.count-rate {
margin-left: 12rpx;
margin-top: 40rpx;
display: flex;
font-size: 50rpx;
color: #4473fe;
.total {
font-size: 50rpx;
color: #dbdee9;
}
}
.schedule-line {
margin-top: 32rpx;
}
}
.unfinish .point {
background: #fc873d;
}
.unfinish .count-rate {
color: #fc873d;
}
}
2025-04-08 16:34:34 +08:00
.cleaning-plan-box {
.cleaning-plan {
margin: 0 32rpx;
margin-bottom: 36rpx;
padding: 42rpx 52rpx;
display: flex;
justify-content: space-between;
align-items: center;
background: url("@/static/images/plan-bg.png") no-repeat 100% 100%;
background-size: 100% 100%;
.title {
font-weight: 500;
font-size: 36rpx;
color: #334a65;
}
.time {
font-weight: 500;
font-size: 36rpx;
color: #334a65;
}
2025-04-07 09:30:11 +08:00
}
}
</style>