From b09c7e7aefd41a62326ea56460092aa0db54c083 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 21 四月 2026 17:30:52 +0800
Subject: [PATCH] 现场监管模块
---
package_supervision/pages/subtask/index.js | 111 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 87 insertions(+), 24 deletions(-)
diff --git a/package_supervision/pages/subtask/index.js b/package_supervision/pages/subtask/index.js
index 28cc91a..730ebe0 100644
--- a/package_supervision/pages/subtask/index.js
+++ b/package_supervision/pages/subtask/index.js
@@ -1,19 +1,30 @@
import taskApi from '../../api/taskApi';
import dayjs from 'dayjs';
+import { useSubTaskItem } from './subtaskitem-proxy.js';
+
+const app = getApp();
Page({
+ behaviors: [useSubTaskItem],
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
- minDate: new Date(2026, 0, 1).getTime(),
+ // 鏃ュ巻鏄剧ず鏃ユ湡鑼冨洿
+ minDate: new Date(2026, 2, 1).getTime(),
maxDate: new Date(2026, 3, 30).getTime(),
- thisDate: new Date().getTime(),
+ // 閫変腑鐨勬棩鏈�
+ thisDate: new Date().getTime(),
+ // 涓婃閫変腑鐨勬棩鏈�
+ lastDate: new Date().getTime(),
+
+ // 褰撴湀鎬讳换鍔¢�夐」鍙婇�変腑鐨勪换鍔�
toptask: {
options: [],
value: '',
},
+ // 閫変腑鎬讳换鍔′笅瀵瑰簲鐨勬棩浠诲姟
daytasks: [],
},
@@ -22,6 +33,26 @@
*/
onLoad(options) {
this.fetchToptask();
+ // 椤甸潰鍔犺浇瀹屾垚鍚庯紝璁惧畾鏃ュ巻鐨勬牸寮忓寲鏃ユ湡鍑芥暟
+ const _formatCalendarDay = this._formatCalendarDay;
+ this.setData({
+ formatCalendarDay: _formatCalendarDay,
+ });
+
+ // 璁剧疆鏃ュ巻璧锋鏃堕棿
+ this.setData({
+ minDate: dayjs().startOf('month').add(-1, 'month').toDate().getTime(),
+ maxDate: dayjs().endOf('month').toDate().getTime(),
+ });
+ },
+
+ /**
+ * 鐩戝惉椤甸潰婊氬姩
+ */
+ onPageScroll(e) {
+ this.setData({
+ scrollTop: e.scrollTop,
+ });
},
/**
@@ -44,12 +75,23 @@
* 鍒囨崲鏈堜唤鎴栧勾浠戒簨浠跺鐞嗗嚱鏁�
*/
handelMonthChange(e) {
- console.log('handelMonthChange', e);
+ // 閫変腑鏃ユ湡鍚屾鍒囨崲涓�涓湀
const { year, month } = e.detail;
let thisDay = dayjs(this.data.thisDate);
thisDay = thisDay.year(year);
thisDay = thisDay.month(month - 1);
- this.setData({ thisDate: thisDay.toDate().getTime() });
+
+ // 濡傛灉鍒囨崲鍚庣殑鏈堜唤涓哄綋鍓嶆棩鍘嗚寖鍥寸殑璧峰鏈堜唤锛屽垯淇敼璧峰鏈堜唤鍑忓皯涓�涓湀锛岀‘淇濈敤鎴峰彲缁х画鏌ョ湅鍘嗗彶鏈堜唤
+ const _minDate = dayjs(this.data.minDate);
+ if (thisDay.month() == _minDate.month()) {
+ this.setData({
+ minDate: _minDate.add(-1, 'month').toDate().getTime(),
+ });
+ }
+
+ this.setData({
+ thisDate: thisDay.toDate().getTime(),
+ });
this.fetchToptask();
},
@@ -60,21 +102,18 @@
* type TDateType = 'selected' | 'disabled' | 'start' | 'start-end' |'centre' | 'end' | ''
*/
_formatCalendarDay(day) {
- console.log('_formatCalendarDay', day);
+ if (!this) return;
const { date } = day;
- const year = date.getFullYear();
- const month = date.getMonth() + 1;
- const curDate = date.getDate();
-
const { daytasks } = this.data;
// 鏌ユ壘褰撳ぉ鏄惁鏈夋棩浠诲姟
const fdt = daytasks.find(d => {
- return dayjs(d.date).isSame(dayjs(date), 'day');
+ return dayjs(d.date).isSame(dayjs(date), 'day') && d.totalTaskNum > 0;
});
if (fdt) {
day.suffix = `${fdt.completeTaskNum}/${fdt.totalTaskNum}`;
+ day.className = 'has-task';
}
return day;
},
@@ -83,8 +122,14 @@
* 鐐瑰嚮鏃ユ湡浜嬩欢澶勭悊鍑芥暟
*/
handleSelectDay(e) {
+ console.log('app', app);
const date = new Date(e.detail.value);
- console.log('handleSelectDay', date);
+ const { thisDate } = this.data;
+ this.setData({
+ lastDate: thisDate,
+ thisDate: date.getTime(),
+ });
+ this.fetchSubtaskByDayTask();
},
/**
@@ -96,16 +141,24 @@
const starttime = thisDay.startOf('month').format('YYYY-MM-DD HH:mm:ss');
const endtime = thisDay.endOf('month').format('YYYY-MM-DD HH:mm:ss');
taskApi.fetchTopTasks({ starttime, endtime }).then(res => {
- const options = res.data.map(r => {
- return {
- label: r.name,
- value: r.tguid,
- };
- });
+ const options =
+ res.data.length > 0
+ ? res.data.map(r => {
+ return {
+ label: r.name,
+ value: r.tguid,
+ };
+ })
+ : [
+ {
+ label: '鏈湀鏃犵洃绠′换鍔�',
+ value: null,
+ },
+ ];
this.setData({
toptask: {
- options,
- value: options.length > 0 ? options[0].value : '',
+ options: options,
+ value: options[0].value,
},
});
this.fetchDayTasks();
@@ -120,12 +173,22 @@
taskApi
.fetchDayTasks(this.data.toptask.value)
.then(res => {
- this.setData({ daytasks: res });
- setTimeout(() => {
- const _formatCalendarDay = this._formatCalendarDay;
- this.setData({ formatCalendarDay: _formatCalendarDay });
- }, 1000);
+ if (res) {
+ this.setData({ daytasks: res });
+ this.selectThisDay();
+ }
})
.finally(() => this.setData({ pageLoading: false }));
},
+
+ // 鐢ㄤ簬瑙﹀彂鏃ュ巻鐨勬棩鏈熸牸寮忓寲鍑芥暟锛屾樉绀烘瘡鏃ヤ换鍔″畬鎴愭儏鍐�
+ selectThisDay() {
+ setTimeout(() => {
+ const { thisDate } = this.data;
+ this.setData({
+ thisDate,
+ });
+ this.fetchSubtaskByDayTask();
+ }, 200);
+ },
});
--
Gitblit v1.9.3