Blame view

pages/index/index.vue 23.2 KB
c293da23   刘淇   新园林init
1
  <template>
cf70629b   刘淇   养护计划 照片 自己写样式
2
    <view class="page-container">
12e66ec8   刘淇   新增树
3
4
5
      <!-- 用户信息栏 -->
      <view class="user-info-bar">
        <view class="user-info">
12e66ec8   刘淇   新增树
6
          <view class="user-text">
e2e5221c   刘淇   验证码登录
7
8
            <view class="username">你好{{ userName }}</view>
            <view class="login-desc">蓟城山水全域智能运营管理平台</view>
12e66ec8   刘淇   新增树
9
10
          </view>
        </view>
4f475013   刘淇   k线图
11
        <view class="msg-icon" @click="handleMsgClick" hover-class="msg-icon--hover">
1d3624b0   刘淇   首页。养护任务
12
          <up-icon name="chat" color="#fff" size="24" />
578c1373   刘淇   样式优化
13
          <view class="msg-badge">
53012a16   刘淇   首页 优化
14
            <up-badge type="error" showZero="true" max="999" :value="msgCount"></up-badge>
4f475013   刘淇   k线图
15
          </view>
12e66ec8   刘淇   新增树
16
17
18
        </view>
      </view>
  
4f475013   刘淇   k线图
19
      <view class="content-wrap">
1d3624b0   刘淇   首页。养护任务
20
21
22
23
24
25
26
        <!-- 图表区域 增加平滑动画容器 -->
        <view class="chart-wrap" v-show="showChartArea">
          <!-- 任务完成情况标题 -->
          <view class="module-title">任务完成情况</view>
  
          <!-- 任务完成情况卡片 -->
          <view class="task-chart-card">
ee792d52   刘淇   动态表单
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
           <view class="card-header">
    <view class="unit-tip">数字指标</view>
    <!-- ActionSheet 点击唤起 -->
    <view class="sort-trigger" @click="openActionSheet">
      {{ sortLabel }}
      <up-icon name="arrow-down" size="14" style="margin-left:4rpx;"></up-icon>
    </view>
    <!-- ActionSheet组件 -->
    <up-action-sheet
      :show="showActionSheet"
      :actions="actionSheetOptions"
      @select="handleSheetSelect"
      @close="showActionSheet = false"
    />
    <view class="date-picker-wrap">
      <neo-datetime-pro v-model="dateRange" type="daterange" :clearable="false" placeholder="请选择日期范围"
                      @confirm="handleDateConfirm" :max-date="maxDate" @popup-show="handlePopupShow"
                      @popup-hide="handlePopupHide" />
    </view>
  </view>
  
4f475013   刘淇   k线图
48
  
1d3624b0   刘淇   首页。养护任务
49
            <!-- 双折线K线图 -->
ee792d52   刘淇   动态表单
50
            <!-- <view class="chart-container">
1d3624b0   刘淇   首页。养护任务
51
52
              <uni-charts v-if="!isDatePickerOpen" type="line" :data="klineChartData" :categories="klineCategories"
                :option="klineOption" :width="chartWidth" :height="chartHeight" />
ee792d52   刘淇   动态表单
53
54
55
56
57
58
59
60
61
62
            </view> -->
  
            <up-grid
                  :border="false"
                 col="4"
          >
              <up-grid-item
                      v-for="(baseListItem,baseListIndex) in baseList"
                      :key="baseListIndex"
              >
9441e28e   刘淇   考勤打卡
63
                  <!-- <up-icon
ee792d52   刘淇   动态表单
64
65
66
                          :customStyle="{paddingTop:20+'rpx'}"
                          :name="baseListItem.name"
                          :size="22"
9441e28e   刘淇   考勤打卡
67
68
                  ></up-icon> -->
                   <text class="grid-text" style="font-size: 24px;">{{baseListItem.num}}</text>
ee792d52   刘淇   动态表单
69
70
71
                  <text class="grid-text">{{baseListItem.title}}</text>
              </up-grid-item>
          </up-grid>
12e66ec8   刘淇   新增树
72
73
          </view>
        </view>
12e66ec8   刘淇   新增树
74
  
1d3624b0   刘淇   首页。养护任务
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
        <view class="con-wrap">
          <view class="con-title">养护任务 </view>
  
          <!-- 手写Tab切换:胶囊分段样式 -->
          <view class="custom-tab-wrap">
            <view class="tab-capsule" :class="{ active: currentTabValue === 0 }" @click="handleTabClick(0)">
              待办事项({{ todoTotal }})
            </view>
            <view class="tab-capsule" :class="{ active: currentTabValue === 1 }" @click="handleTabClick(1)">
              已办事项({{ doneTotal }})
            </view>
          </view>
  
  
          <!-- 动态组信息文案 -->
6cc0ab0e   刘淇   养护任务
90
          <!-- <view class="tip-top" style="padding: 8px 0  0 70px;">
1d3624b0   刘淇   首页。养护任务
91
            <text>{{ tipText }}</text>
6cc0ab0e   刘淇   养护任务
92
          </view> -->
1d3624b0   刘淇   首页。养护任务
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  
          <!-- 顶部进度提示栏 -->
          <view v-if="showTipHeader" class="tip-header">
            <up-icon name="checkmark-circle" color="#00b42a" size="20"></up-icon>
            <text style="color: #1677ff;">今日组内:您已经完成{{ finishNum }}项,小组均值{{ avgNum }}项</text>
          </view>
  
  
          <scroll-view 
            class="task-list-container" 
            scroll-y 
            @scroll="onListScroll" 
            @scrolltoupper="handleTouchTop"
            enhanced
          >
            <view v-if="taskList.length === 0" class="empty-box">
              <up-empty />
            </view>
            <view class="task-item" v-for="(item, index) in taskList" :key="`${item.taskName}_${index}`"
              hover-class="task-item--hover" @click="handleTaskClick(item)">
cf70629b   刘淇   养护计划 照片 自己写样式
113
              <view class="task-item__content">
1d3624b0   刘淇   首页。养护任务
114
115
116
                <view class="name-fixed-wrap">
                  <view class="task-item__name ">
                    事项{{ index + 1 }} 
cf70629b   刘淇   养护计划 照片 自己写样式
117
                  </view>
1d3624b0   刘淇   首页。养护任务
118
119
                  <view class="task-name-text">
                    {{ item.taskName || '无' }}
cf70629b   刘淇   养护计划 照片 自己写样式
120
121
                  </view>
                </view>
1d3624b0   刘淇   首页。养护任务
122
123
124
125
126
127
128
129
130
  
                <view v-if="currentTabValue === 0" class="task-item__footer" style="padding-left:  60px;">
                  <image class="loc-icon" src="https://img.jichengshanshui.com.cn:28207/appimg/定位icon@3x.png" mode="aspectFit"></image>
                  <template v-if="isWalkTextMode">
                    <text>距离当前{{ item.distance }}m ·约{{ item.estimatedWalkingMinutes }}分钟步行</text>
                  </template>
                  <template v-else>
                    <text>{{ item.distance }}m ·</text>
                    <up-icon name="star-fill" color="#ffd21d" size="20"></up-icon>
6cc0ab0e   刘淇   养护任务
131
                    <text>历史完成率{{ item.historyCompletionRate }}%</text>
1d3624b0   刘淇   首页。养护任务
132
133
                  </template>
                </view>
4f475013   刘淇   k线图
134
              </view>
4f475013   刘淇   k线图
135
            </view>
1d3624b0   刘淇   首页。养护任务
136
137
          </scroll-view>
        </view>
12e66ec8   刘淇   新增树
138
      </view>
12e66ec8   刘淇   新增树
139
    </view>
c293da23   刘淇   新园林init
140
141
  </template>
  
cf70629b   刘淇   养护计划 照片 自己写样式
142
  <script setup lang="ts">
9441e28e   刘淇   考勤打卡
143
144
  import { ref, computed, nextTick, watch } from 'vue';
  import { onShow, onUnload } from '@dcloudio/uni-app';
1d3624b0   刘淇   首页。养护任务
145
  import { useUserStore } from '@/pinia/user';
9441e28e   刘淇   考勤打卡
146
  // import { timeFormat } from '@/uni_modules/uview-plus/libs/function/date';
4f475013   刘淇   k线图
147
  import uniCharts from '@/components/uni-charts/uni-charts.vue';
1d3624b0   刘淇   首页。养护任务
148
149
150
151
  import { getUnreadCount } from "@/api/user";
  import {
    getTaskCompletionSummary,
    taskDetailsWithDistance,
9441e28e   刘淇   考勤打卡
152
153
154
    taskDetailsWithSmartSort,
    getCurrentOrg,
    orgTaskIndicator
1d3624b0   刘淇   首页。养护任务
155
  } from "@/api/index/index";
1d3624b0   刘淇   首页。养护任务
156
  const userStore = useUserStore();
9441e28e   刘淇   考勤打卡
157
  const deptId = computed(() => String(userStore.userInfo?.deptId ?? ''));
1d3624b0   刘淇   首页。养护任务
158
  
6cc0ab0e   刘淇   养护任务
159
  // ====================== 分组配置(多部门归属同一组) ======================
1d3624b0   刘淇   首页。养护任务
160
  type GroupItem = {
9441e28e   刘淇   考勤打卡
161
    deptIds: string[];
1d3624b0   刘淇   首页。养护任务
162
    label: string;
9441e28e   刘淇   考勤打卡
163
164
    showTipHeader: boolean;
    useWalkText: boolean;
1d3624b0   刘淇   首页。养护任务
165
  };
1d3624b0   刘淇   首页。养护任务
166
  const groupConfig: GroupItem[] = [
6cc0ab0e   刘淇   养护任务
167
168
    {
      deptIds: ['361', '363', '279', '277', '270'],
9441e28e   刘淇   考勤打卡
169
      label: '[组2 A1B2 纯效率·有提醒]',
6cc0ab0e   刘淇   养护任务
170
171
172
      showTipHeader: true,
      useWalkText: true
    },
6cc0ab0e   刘淇   养护任务
173
174
    {
      deptIds: ['252', '273', '274', '337', '359', '360'],
9441e28e   刘淇   考勤打卡
175
      label: '[组3 A2B1 个性化·无提醒]',
6cc0ab0e   刘淇   养护任务
176
177
178
      showTipHeader: false,
      useWalkText: false
    },
6cc0ab0e   刘淇   养护任务
179
180
    {
      deptIds: ['281', '272', '271', '338', '280'],
9441e28e   刘淇   考勤打卡
181
      label: '[组4 A2B2 个性化·有提醒]',
6cc0ab0e   刘淇   养护任务
182
183
184
      showTipHeader: true,
      useWalkText: false
    },
1d3624b0   刘淇   首页。养护任务
185
  ];
6cc0ab0e   刘淇   养护任务
186
187
  const defaultGroup: GroupItem = {
    deptIds: [],
9441e28e   刘淇   考勤打卡
188
    label: '[组1 A1B1 纯效率·无提醒]',
6cc0ab0e   刘淇   养护任务
189
190
191
    showTipHeader: false,
    useWalkText: true
  };
1d3624b0   刘淇   首页。养护任务
192
  const currentGroup = computed(() => {
6cc0ab0e   刘淇   养护任务
193
    const targetDept = deptId.value;
9441e28e   刘淇   考勤打卡
194
195
196
    for (const g of groupConfig) {
      if (g.deptIds.includes(targetDept)) {
        return g;
6cc0ab0e   刘淇   养护任务
197
198
      }
    }
6cc0ab0e   刘淇   养护任务
199
    return defaultGroup;
1d3624b0   刘淇   首页。养护任务
200
  });
1d3624b0   刘淇   首页。养护任务
201
202
203
204
205
  const tipText = computed(() => currentGroup.value.label);
  const showTipHeader = computed(() => currentGroup.value.showTipHeader);
  const isWalkTextMode = computed(() => currentGroup.value.useWalkText);
  const useDistanceApi = computed(() => currentGroup.value.useWalkText);
  // =========================================================================
c293da23   刘淇   新园林init
206
  
1d3624b0   刘淇   首页。养护任务
207
208
  const finishNum = ref(0);
  const avgNum = ref(0);
cf70629b   刘淇   养护计划 照片 自己写样式
209
  const msgCount = ref(0);
1d3624b0   刘淇   首页。养护任务
210
  const currentTabValue = ref(0);
1d3624b0   刘淇   首页。养护任务
211
  const dateRange = ref<string[]>([]);
5b5a4862   刘淇   按钮放大
212
  const yesterday = new Date();
1d3624b0   刘淇   首页。养护任务
213
  yesterday.setDate(yesterday.getDate() - 1);
9441e28e   刘淇   考勤打卡
214
  const maxDate = ref(timeFormat(yesterday, 'YYYY-MM-DD'));
1d3624b0   刘淇   首页。养护任务
215
  const minDate = '2026-01-06';
5b5a4862   刘淇   按钮放大
216
  const isDatePickerOpen = ref(false);
5b5a4862   刘淇   按钮放大
217
218
219
  const handlePopupShow = () => {
    isDatePickerOpen.value = true;
  };
5b5a4862   刘淇   按钮放大
220
221
222
  const handlePopupHide = () => {
    isDatePickerOpen.value = false;
  };
cf70629b   刘淇   养护计划 照片 自己写样式
223
  
1d3624b0   刘淇   首页。养护任务
224
225
226
227
228
229
230
  const todoTotal = ref(0);
  const doneTotal = ref(0);
  const todoFullList = ref<any[]>([]);
  const doneFullList = ref<any[]>([]);
  const taskList = computed(() => {
    return currentTabValue.value === 0 ? todoFullList.value : doneFullList.value;
  });
1d3624b0   刘淇   首页。养护任务
231
232
  const chooseOptions = computed(() => [
    { title: `待办事项(${todoTotal.value})`, id: 'todo' },
9441e28e   刘淇   考勤打卡
233
    { title: `已办事项(${doneTotal.value})`, id: 'done' },
1d3624b0   刘淇   首页。养护任务
234
  ]);
c293da23   刘淇   新园林init
235
  
1d3624b0   刘淇   首页。养护任务
236
237
  const currentLon = ref<string>('');
  const currentLat = ref<string>('');
4f475013   刘淇   k线图
238
239
  const chartWidth = ref(0);
  const chartHeight = ref(300);
1d3624b0   刘淇   首页。养护任务
240
  const klineCategories = ref<string[]>([]);
4f475013   刘淇   k线图
241
  const klineChartData = ref([
12e66ec8   刘淇   新增树
242
    {
4570c70a   刘淇   消息中心
243
      name: '已完成任务数',
1d3624b0   刘淇   首页。养护任务
244
      data: [] as number[],
4f475013   刘淇   k线图
245
      color: '#25AF69'
12e66ec8   刘淇   新增树
246
247
    },
    {
6bce1057   刘淇   ai 大区经理
248
      name: '总任务数',
1d3624b0   刘淇   首页。养护任务
249
      data: [] as number[],
4f475013   刘淇   k线图
250
251
252
      color: '#B34C17'
    }
  ]);
4f475013   刘淇   k线图
253
254
255
  const klineOption = ref({
    grid: {
      top: '25%',
53012a16   刘淇   首页 优化
256
      left: '12%',
9441e28e   刘淇   考勤打卡
257
      right: '12%',
53012a16   刘淇   首页 优化
258
      bottom: '16%'
12e66ec8   刘淇   新增树
259
    },
4f475013   刘淇   k线图
260
    xAxis: {
1d3624b0   刘淇   首页。养护任务
261
      axisLabel: { fontSize: 12, color: '#666' }
12e66ec8   刘淇   新增树
262
    },
4f475013   刘淇   k线图
263
264
    yAxis: {
      min: 0,
1d3624b0   刘淇   首页。养护任务
265
266
      splitLine: { lineStyle: { color: '#f5f5f7' } },
      axisLabel: { fontSize: 12, color: '#666' }
12e66ec8   刘淇   新增树
267
    },
4f475013   刘淇   k线图
268
269
    tooltip: {
      trigger: 'axis',
1d3624b0   刘淇   首页。养护任务
270
      formatter: (params: any[]) => {
4570c70a   刘淇   消息中心
271
        return `${params[0].name}<br/>
9441e28e   刘淇   考勤打卡
272
273
  ${params[0].seriesName}: ${params[0].value}<br/>
  ${params[1].seriesName}: ${params[1].value}`;
4f475013   刘淇   k线图
274
275
276
277
278
      }
    },
    legend: {
      show: true,
      top: '5%',
1d3624b0   刘淇   首页。养护任务
279
      textStyle: { fontSize: 12 }
12e66ec8   刘淇   新增树
280
    }
4f475013   刘淇   k线图
281
282
  });
  
9441e28e   刘淇   考勤打卡
283
284
285
286
287
288
289
290
291
292
293
294
295
296
  const baseList = ref<Array<{ num: string; title: string }>>([]);
  const orgOptions = ref<any[]>([]);
  const value1 = ref<number | string>('');
  const showActionSheet = ref(false);
  
  watch(orgOptions, async (list) => {
    if (list.length && !value1.value) {
      value1.value = list[0].value;
      // 拿到默认组织后,拉指标
      if (dateRange.value.length === 2) {
        await fetchOrgIndicator(Number(value1.value), dateRange.value[0], dateRange.value[1]);
      }
    }
  }, { immediate: true });
ee792d52   刘淇   动态表单
297
  
9441e28e   刘淇   考勤打卡
298
299
  const actionSheetOptions = computed(() => {
    return orgOptions.value.map(opt => ({
ee792d52   刘淇   动态表单
300
301
      name: opt.label,
      value: opt.value
9441e28e   刘淇   考勤打卡
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
    }));
  });
  const sortLabel = computed(() => {
    const cur = orgOptions.value.find(i => i.value === value1.value);
    return cur?.label ?? "";
  });
  const openActionSheet = () => {
    showActionSheet.value = true;
  };
  // ActionSheet选中组织:刷新指标
  const handleSheetSelect = async (item: { name: string; value: number }) => {
    value1.value = item.value;
    showActionSheet.value = false;
    console.log('选中组织:', item.value);
    if (dateRange.value.length === 2) {
      await fetchOrgIndicator(item.value, dateRange.value[0], dateRange.value[1]);
    }
  };
4f475013   刘淇   k线图
320
  
9441e28e   刘淇   考勤打卡
321
  const userName = computed(() => userStore.userInfo?.nickname || '用户');
1d3624b0   刘淇   首页。养护任务
322
  const rpx2px = (rpx: number) => {
cf70629b   刘淇   养护计划 照片 自己写样式
323
    const systemInfo = uni.getSystemInfoSync();
1d3624b0   刘淇   首页。养护任务
324
325
326
    return Math.floor(systemInfo.screenWidth / 750 * rpx);
  };
  
9441e28e   刘淇   考勤打卡
327
  // ========== 滚动逻辑 ==========
1d3624b0   刘淇   首页。养护任务
328
  const showChartArea = ref(true);
1d3624b0   刘淇   首页。养护任务
329
  const scrollHideThreshold = rpx2px(80);
1d3624b0   刘淇   首页。养护任务
330
331
  const safeShowThreshold = rpx2px(130);
  let scrollTimer: number | null = null;
1d3624b0   刘淇   首页。养护任务
332
333
  const handleTouchTop = () => {
    showChartArea.value = true;
4f475013   刘淇   k线图
334
  };
1d3624b0   刘淇   首页。养护任务
335
336
  const onListScroll = (e: any) => {
    const scrollTop = e.detail.scrollTop;
1d3624b0   刘淇   首页。养护任务
337
    if (scrollTimer) clearTimeout(scrollTimer);
1d3624b0   刘淇   首页。养护任务
338
339
340
341
342
    if (scrollTop <= safeShowThreshold) {
      showChartArea.value = true;
    } else if (scrollTop > scrollHideThreshold) {
      showChartArea.value = false;
    }
1d3624b0   刘淇   首页。养护任务
343
344
345
346
347
348
    scrollTimer = setTimeout(() => {
      if (scrollTop <= safeShowThreshold) {
        showChartArea.value = true;
      }
    }, 100);
  };
1d3624b0   刘淇   首页。养护任务
349
350
351
  const handleTabClick = (tabIndex: number) => {
    if (currentTabValue.value === tabIndex) return;
    currentTabValue.value = tabIndex;
1d3624b0   刘淇   首页。养护任务
352
353
354
    showChartArea.value = true;
  };
  
9441e28e   刘淇   考勤打卡
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
  // ========== 公共函数:请求 orgTaskIndicator 指标接口 ==========
  const fetchOrgIndicator = async (orgId: number, beginDate: string, endDate: string) => {
    try {
      // 日期字符串转毫秒时间戳
      const beginTime = new Date(beginDate).getTime();
      const endTime = new Date(endDate).getTime();
      const res = await orgTaskIndicator({
        orgId,
        beginTime,
        endTime
      });
      console.log('orgTaskIndicator 返回:', res);
      baseList.value = [
        {
          num: String(res.totalCnt ?? 0),
          title: '应办任务数'
1d3624b0   刘淇   首页。养护任务
371
        },
9441e28e   刘淇   考勤打卡
372
373
374
375
376
377
378
379
380
381
382
        {
          num: String(res.doneCnt ?? 0),
          title: '已办任务数'
        },
        {
          num: String(res.pendingCnt ?? 0),
          title: '待办任务数'
        },
        {
          num: String(res.overdueCnt ?? 0),
          title: '超时未完成'
1d3624b0   刘淇   首页。养护任务
383
        }
9441e28e   刘淇   考勤打卡
384
385
386
387
388
      ];
    } catch (err) {
      console.error('orgTaskIndicator 请求失败:', err);
    }
  };
5b5a4862   刘淇   按钮放大
389
  
9441e28e   刘淇   考勤打卡
390
391
392
393
394
395
396
  // ========== 初始化日期范围(近7天) ==========
  const initRecent7Days = () => {
    const now = new Date();
    const end = new Date(now);
    end.setDate(end.getDate() - 1);
    const start = new Date(end);
    start.setDate(start.getDate() - 6);
cf70629b   刘淇   养护计划 照片 自己写样式
397
    dateRange.value = [
9441e28e   刘淇   考勤打卡
398
399
      timeFormat(start, 'YYYY-MM-DD'),
      timeFormat(end, 'YYYY-MM-DD')
cf70629b   刘淇   养护计划 照片 自己写样式
400
    ];
1d3624b0   刘淇   首页。养护任务
401
    initChartData(dateRange.value[0], dateRange.value[1]);
4f475013   刘淇   k线图
402
403
  };
  
cf70629b   刘淇   养护计划 照片 自己写样式
404
405
406
407
408
  const getUnread = async () => {
    try {
      const res = await getUnreadCount();
      msgCount.value = res || 0;
    } catch (error) {
9441e28e   刘淇   考勤打卡
409
410
411
412
413
414
415
416
417
418
419
420
      console.error('获取未读消息失败:', error);
    }
  };
  
  // getOrg:只拉组织下拉选项,不处理指标
  const getOrg = async () => {
    try {
      const res = await getCurrentOrg();
      console.log('getCurrentOrg组织下拉:', res);
      orgOptions.value = res.options || [];
    } catch (error) {
      console.error('获取组织下拉失败:', error);
cf70629b   刘淇   养护计划 照片 自己写样式
421
422
    }
  };
4570c70a   刘淇   消息中心
423
  
1d3624b0   刘淇   首页。养护任务
424
  const initChartData = async (beginTime: string, endTime: string) => {
cf70629b   刘淇   养护计划 照片 自己写样式
425
    try {
1d3624b0   刘淇   首页。养护任务
426
      const postData = { beginTime, endTime };
cf70629b   刘淇   养护计划 照片 自己写样式
427
      const res = await getTaskCompletionSummary(postData);
1d3624b0   刘淇   首页。养护任务
428
429
      klineCategories.value = res.map((item: any) => item.currentDate);
      klineChartData.value[0].data = res.map((item: any) => item.completedNum);
9441e28e   刘淇   考勤打卡
430
      klineChartData.value[1].data = res.map((item: any) => item.countPendingNum);
cf70629b   刘淇   养护计划 照片 自己写样式
431
    } catch (error) {
9441e28e   刘淇   考勤打卡
432
      console.error('图表数据请求失败:', error);
cf70629b   刘淇   养护计划 照片 自己写样式
433
434
    }
  };
4f475013   刘淇   k线图
435
  
1d3624b0   刘淇   首页。养护任务
436
  const loadDistanceApiTask = async (lon: string, lat: string) => {
cf70629b   刘淇   养护计划 照片 自己写样式
437
    try {
1d3624b0   刘淇   首页。养护任务
438
439
      const paramsTodo = { queryType: 1, currentLon: lon, currentLat: lat };
      const paramsDone = { queryType: 2, currentLon: lon, currentLat: lat };
cf70629b   刘淇   养护计划 照片 自己写样式
440
      const [todoRes, doneRes] = await Promise.all([
1d3624b0   刘淇   首页。养护任务
441
442
        taskDetailsWithDistance(paramsTodo),
        taskDetailsWithDistance(paramsDone)
cf70629b   刘淇   养护计划 照片 自己写样式
443
      ]);
1d3624b0   刘淇   首页。养护任务
444
445
446
447
448
449
450
451
452
      todoFullList.value = todoRes?.sortedTasks || [];
      doneFullList.value = doneRes?.sortedTasks || [];
      todoTotal.value = Number(todoRes?.totalPendingTasks) || 0;
      doneTotal.value = Number(doneRes?.totalPendingTasks) || 0;
      finishNum.value = todoRes?.teamProgress?.userCompletedCount ?? 0;
      avgNum.value = doneRes?.teamProgress?.teamAverage ?? 0;
      await nextTick();
    } catch (err) {
      uni.showToast({ title: '加载任务失败', icon: 'none' });
9441e28e   刘淇   考勤打卡
453
      console.error('loadDistanceApiTask error', err);
1d3624b0   刘淇   首页。养护任务
454
455
456
457
      todoFullList.value = [];
      doneFullList.value = [];
      todoTotal.value = 0;
      doneTotal.value = 0;
cf70629b   刘淇   养护计划 照片 自己写样式
458
    }
4f475013   刘淇   k线图
459
  };
1d3624b0   刘淇   首页。养护任务
460
  const loadSmartSortTask = async (lon: string, lat: string) => {
cf70629b   刘淇   养护计划 照片 自己写样式
461
    try {
1d3624b0   刘淇   首页。养护任务
462
      const [todoRes, doneRes] = await Promise.all([
9441e28e   刘淇   考勤打卡
463
464
        taskDetailsWithSmartSort({ queryType: 1, currentLon: lon, currentLat: lat }),
        taskDetailsWithSmartSort({ queryType: 2, currentLon: lon, currentLat: lat })
1d3624b0   刘淇   首页。养护任务
465
466
467
468
469
470
471
472
473
474
      ]);
      todoFullList.value = todoRes?.sortedTasks || [];
      doneFullList.value = doneRes?.sortedTasks || [];
      todoTotal.value = Number(todoRes?.totalPendingTasks) || 0;
      doneTotal.value = Number(doneRes?.totalPendingTasks) || 0;
      finishNum.value = todoRes?.teamProgress?.userCompletedCount ?? 0;
      avgNum.value = doneRes?.teamProgress?.teamAverage ?? 0;
      await nextTick();
    } catch (err) {
      uni.showToast({ title: '加载任务失败', icon: 'none' });
9441e28e   刘淇   考勤打卡
475
      console.error('loadSmartSortTask error', err);
1d3624b0   刘淇   首页。养护任务
476
477
478
479
      todoFullList.value = [];
      doneFullList.value = [];
      todoTotal.value = 0;
      doneTotal.value = 0;
cf70629b   刘淇   养护计划 照片 自己写样式
480
481
    }
  };
1d3624b0   刘淇   首页。养护任务
482
483
484
485
486
487
488
489
490
491
  const loadAllTaskByDept = async () => {
    const loc = await getCurrentLocation();
    currentLon.value = loc.lon;
    currentLat.value = loc.lat;
    if (useDistanceApi.value) {
      await loadDistanceApiTask(loc.lon, loc.lat);
    } else {
      await loadSmartSortTask(loc.lon, loc.lat);
    }
  };
cf70629b   刘淇   养护计划 照片 自己写样式
492
  
9441e28e   刘淇   考勤打卡
493
494
  // 日期确认回调:更新图表 + 重新请求指标orgTaskIndicator
  const handleDateConfirm = async (e: string[]) => {
cf70629b   刘淇   养护计划 照片 自己写样式
495
    dateRange.value = e;
9441e28e   刘淇   考勤打卡
496
497
498
499
    await initChartData(e[0], e[1]);
    if (value1.value) {
      await fetchOrgIndicator(Number(value1.value), e[0], e[1]);
    }
4f475013   刘淇   k线图
500
  };
12e66ec8   刘淇   新增树
501
  
9441e28e   刘淇   考勤打卡
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
  const getCurrentLocation = (): Promise<{ lon: string; lat: string }> => {
    return new Promise((resolve, reject) => {
      uni.getSetting({
        success: (settingRes) => {
          if (!settingRes.authSetting['scope.userLocation']) {
            uni.authorize({
              scope: 'scope.userLocation',
              success: () => {
                uni.getLocation({
                  type: 'gcj02',
                  success: (loc) => {
                    resolve({
                      lon: loc.longitude.toFixed(6),
                      lat: loc.latitude.toFixed(6)
                    });
                  },
                  fail: (err) => {
                    uni.showToast({ title: '获取位置失败,请开启定位', icon: 'none' });
                    reject('定位失败');
                  }
                });
              },
              fail: () => {
                uni.showModal({
                  title: '需要定位权限',
                  content: '允许定位才能查看任务距离',
                  confirmText: '去设置',
                  success: (modalRes) => {
                    if (modalRes.confirm) {
                      uni.openSetting();
                    }
                  }
                });
                reject('拒绝定位');
              }
            });
          } else {
            uni.getLocation({
              type: 'gcj02',
              success: (loc) => {
                resolve({
                  lon: loc.longitude.toFixed(6),
                  lat: loc.latitude.toFixed(6)
                });
              },
              fail: (err) => {
                uni.showToast({ title: '获取位置失败,请开启定位', icon: 'none' });
                reject('定位失败');
              }
            });
          }
        },
        fail: (err) => {
          reject('获取权限设置失败');
        }
      });
    });
4f475013   刘淇   k线图
559
560
  };
  
9441e28e   刘淇   考勤打卡
561
562
563
  const handleMsgClick = () => {
    uni.navigateTo({ url: '/pages-sub/msg/msg' });
  };
1d3624b0   刘淇   首页。养护任务
564
565
566
  const handleTaskClick = (item: any) => {
    if (item.taskType == "maintain") {
      if (currentTabValue.value === 0) {
9441e28e   刘淇   考勤打卡
567
568
569
570
571
572
573
        uni.navigateTo({
          url: `/pages-sub/daily/maintain-add?planNo=${item.planNo || ''}&planTypeId=${item.planTypeId ?? ''}&businessLine=${item.busiLine ?? ''}`
        });
      } else {
        uni.navigateTo({
          url: `/pages-sub/daily/maintain-detail?planNo=${item.planNo || ''}`
        });
1d3624b0   刘淇   首页。养护任务
574
      }
cf70629b   刘淇   养护计划 照片 自己写样式
575
    }
1d3624b0   刘淇   首页。养护任务
576
577
    if (item.taskType == "inspection") {
      if (currentTabValue.value === 0) {
9441e28e   刘淇   考勤打卡
578
579
580
581
582
583
584
        uni.navigateTo({
          url: `/pages-sub/daily/inspect-add?planNo=${item.planNo}&batchNo=${item.batchNo}`
        });
      } else {
        uni.navigateTo({
          url: `/pages-sub/daily/inspect-detail?planNo=${item.planNo || ''}`
        });
1d3624b0   刘淇   首页。养护任务
585
586
587
      }
    }
  };
9441e28e   刘淇   考勤打卡
588
589
590
591
592
593
594
595
596
597
598
599
600
601
  
  onShow(async () => {
    showChartArea.value = true;
    chartWidth.value = rpx2px(750 - 60);
    chartHeight.value = rpx2px(300);
    initRecent7Days();
    getUnread();
    await getOrg(); // 拉取组织下拉列表
    await loadAllTaskByDept();
  });
  
  onUnload(() => {
    if (scrollTimer) clearTimeout(scrollTimer);
  });
c293da23   刘淇   新园林init
602
603
  </script>
  
9441e28e   刘淇   考勤打卡
604
605
  
  
12e66ec8   刘淇   新增树
606
  <style scoped lang="scss">
4f475013   刘淇   k线图
607
608
  $primary-color: #1677ff;
  $danger-color: #E53935;
4f475013   刘淇   k线图
609
610
611
612
613
  $text-color: #333;
  $text-color-light: #666;
  $text-color-placeholder: #999;
  $bg-color: #f5f5f7;
  $card-bg: #fff;
cf70629b   刘淇   养护计划 照片 自己写样式
614
615
616
617
618
  $border-radius: 16px;
  $card-radius: 5px;
  $spacing-sm: 5px;
  $spacing-md: 10px;
  $spacing-lg: 15px;
1d3624b0   刘淇   首页。养护任务
619
  $border-color: #e5e5e5;
cf70629b   刘淇   养护计划 照片 自己写样式
620
621
  
  .page-container {
1d3624b0   刘淇   首页。养护任务
622
    height: 100vh;
cf70629b   刘淇   养护计划 照片 自己写样式
623
    background-color: $bg-color;
1d3624b0   刘淇   首页。养护任务
624
625
626
    overflow: hidden;
    display: flex;
    flex-direction: column;
12e66ec8   刘淇   新增树
627
628
  }
  
12e66ec8   刘淇   新增树
629
  .user-info-bar {
1d3624b0   刘淇   首页。养护任务
630
    flex-shrink: 0;
4f475013   刘淇   k线图
631
632
    background: url("https://img.jichengshanshui.com.cn:28207/appimg/bg.jpg") no-repeat;
    background-size: 100% 100%;
24c0bbe7   刘淇   登录账号密码 加密存储
633
    padding: 80px $spacing-lg 135px;
12e66ec8   刘淇   新增树
634
635
636
637
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
12e66ec8   刘淇   新增树
638
  
4f475013   刘淇   k线图
639
    .username {
4570c70a   刘淇   消息中心
640
      font-size: 16px;
cf70629b   刘淇   养护计划 照片 自己写样式
641
      margin-bottom: 4px;
4f475013   刘淇   k线图
642
    }
4f475013   刘淇   k线图
643
    .login-desc {
cf70629b   刘淇   养护计划 照片 自己写样式
644
      font-size: 16px;
12e66ec8   刘淇   新增树
645
    }
12e66ec8   刘淇   新增树
646
647
    .msg-icon {
      position: relative;
cf70629b   刘淇   养护计划 照片 自己写样式
648
      padding: 5px;
578c1373   刘淇   样式优化
649
      top: 10px;
4f475013   刘淇   k线图
650
      border-radius: 50%;
4f475013   刘淇   k线图
651
652
653
      &--hover {
        background-color: rgba(255, 255, 255, 0.2);
      }
12e66ec8   刘淇   新增树
654
655
      .msg-badge {
        position: absolute;
578c1373   刘淇   样式优化
656
657
        top: -2px;
        right: -3px;
12e66ec8   刘淇   新增树
658
659
660
661
      }
    }
  }
  
4f475013   刘淇   k线图
662
  .content-wrap {
1d3624b0   刘淇   首页。养护任务
663
    flex: 1;
cf70629b   刘淇   养护计划 照片 自己写样式
664
    margin-top: -122px;
4f475013   刘淇   k线图
665
666
    border-radius: $border-radius $border-radius 0 0;
    background-color: $bg-color;
4f475013   刘淇   k线图
667
    overflow: hidden;
1d3624b0   刘淇   首页。养护任务
668
669
670
671
672
673
674
675
676
677
678
679
680
681
    display: flex;
    flex-direction: column;
  }
  
  .chart-wrap {
    flex-shrink: 0;
    transition: all 0.35s ease-out;
    opacity: 1;
    overflow: hidden;
  }
  .chart-wrap[hidden] {
    opacity: 0;
    height: 0;
    margin: 0;
4f475013   刘淇   k线图
682
  }
12e66ec8   刘淇   新增树
683
  
4f475013   刘淇   k线图
684
  .module-title {
cf70629b   刘淇   养护计划 照片 自己写样式
685
    padding: $spacing-lg;
578c1373   刘淇   样式优化
686
    font-size: 14px;
4f475013   刘淇   k线图
687
688
    font-weight: 600;
    color: $text-color-light;
1d3624b0   刘淇   首页。养护任务
689
    flex-shrink: 0;
4f475013   刘淇   k线图
690
691
692
693
694
695
696
  }
  
  .task-chart-card {
    background-color: $card-bg;
    border-radius: $card-radius;
    margin: 0 $spacing-lg $spacing-md;
    padding: $spacing-md;
1d3624b0   刘淇   首页。养护任务
697
    flex-shrink: 0;
12e66ec8   刘淇   新增树
698
699
700
    .card-header {
      display: flex;
      justify-content: space-between;
12e66ec8   刘淇   新增树
701
      align-items: center;
cf70629b   刘淇   养护计划 照片 自己写样式
702
      font-size: 12px;
4f475013   刘淇   k线图
703
704
      color: $text-color-placeholder;
      margin-bottom: $spacing-md;
4f475013   刘淇   k线图
705
      .date-picker-wrap {
cf70629b   刘淇   养护计划 照片 自己写样式
706
        border-radius: 3px;
4f475013   刘淇   k线图
707
        transition: background-color 0.2s;
5b5a4862   刘淇   按钮放大
708
709
        position: relative;
        z-index: 999;
4f475013   刘淇   k线图
710
711
712
        &:active {
          background-color: $bg-color;
        }
12e66ec8   刘淇   新增树
713
714
      }
    }
4f475013   刘淇   k线图
715
    .chart-container {
12e66ec8   刘淇   新增树
716
      width: 100%;
cf70629b   刘淇   养护计划 照片 自己写样式
717
      height: 150px;
4f475013   刘淇   k线图
718
719
720
      display: flex;
      align-items: center;
      justify-content: center;
12e66ec8   刘淇   新增树
721
722
    }
  }
1d3624b0   刘淇   首页。养护任务
723
724
725
726
727
728
729
730
731
732
  .con-wrap {
    border-radius: 8px;
    background-color: #fff;
    margin: 0 15px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
12e66ec8   刘淇   新增树
733
  
1d3624b0   刘淇   首页。养护任务
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
  .con-title {
    padding: 10px 15px;
    border-bottom: 1px solid #f0e9e9;
    flex-shrink: 0;
  }
  
  .custom-tab-wrap {
    display: flex;
    align-items: center;
    gap: 20rpx;
    padding: 20rpx 0 20rpx 20rpx;
    background: #fff;
    flex-shrink: 0;
  }
  
  .tab-capsule {
    padding: 10rpx 20rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28rpx;
    color: #999;
    background: #f5f5f5;
    border-radius: 0;
    transition: all 0.2s ease;
    font-weight: 500;
  }
  .tab-capsule.active {
    color: #d4af37;
    background: #fff8dc;
  }
  
  .tip-header {
    display: flex;
    align-items: center;
    gap: 8rpx;
    padding: 12rpx 15rpx;
    background: #e6f7ff;
    font-size: 14px;
    color: #000;
    flex-shrink: 0;
  }
  
  .tip-top {
    padding: 8px 0  0 70px;
    flex-shrink: 0;
12e66ec8   刘淇   新增树
780
781
  }
  
4f475013   刘淇   k线图
782
  .task-list-container {
1d3624b0   刘淇   首页。养护任务
783
784
785
786
787
788
789
790
    width: 100%;
    height: 100%;
    padding-bottom: 300rpx;
    box-sizing: border-box;
  }
  
  .empty-box {
    padding: 60rpx 0;
cf70629b   刘淇   养护计划 照片 自己写样式
791
  }
ee792d52   刘淇   动态表单
792
793
794
795
796
797
798
  .sort-trigger {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: $text-color-placeholder;
  }
  
12e66ec8   刘淇   新增树
799
  
cf70629b   刘淇   养护计划 照片 自己写样式
800
801
802
803
  .task-item {
    padding: $spacing-md;
    transition: background-color 0.2s;
    border-bottom: 1px solid $border-color;
cf70629b   刘淇   养护计划 照片 自己写样式
804
805
806
    &:last-child {
      border-bottom: none;
    }
cf70629b   刘淇   养护计划 照片 自己写样式
807
808
809
    &--hover {
      background-color: $bg-color;
    }
cf70629b   刘淇   养护计划 照片 自己写样式
810
811
812
    &__content {
      width: 100%;
    }
1d3624b0   刘淇   首页。养护任务
813
814
815
816
817
818
    .name-fixed-wrap {
      display: flex;
    }
    .task-item__name {
      width: 60px;
    }
6cc0ab0e   刘淇   养护任务
819
820
821
822
823
824
825
826
827
828
   .task-name-text {
    flex: 1;
    font-size: 14px;
    color: $text-color;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
cf70629b   刘淇   养护计划 照片 自己写样式
829
    &__name {
1d3624b0   刘淇   首页。养护任务
830
      font-size: 15px;
cf70629b   刘淇   养护计划 照片 自己写样式
831
      color: $text-color;
1d3624b0   刘淇   首页。养护任务
832
      display: inline-block;
cf70629b   刘淇   养护计划 照片 自己写样式
833
    }
cf70629b   刘淇   养护计划 照片 自己写样式
834
835
    &__footer {
      display: flex;
1d3624b0   刘淇   首页。养护任务
836
837
838
839
840
      align-items: flex-start;
      gap: 6rpx;
      font-size: 13px;
      color: $text-color-light;
      margin-top: $spacing-sm;
cf70629b   刘淇   养护计划 照片 自己写样式
841
      align-items: center;
cf70629b   刘淇   养护计划 照片 自己写样式
842
843
    }
  }
1d3624b0   刘淇   首页。养护任务
844
845
846
847
  .loc-icon {
    width: 20px;
    height: 20px;
  }
4f475013   刘淇   k线图
848
  
cf70629b   刘淇   养护计划 照片 自己写样式
849
850
  .urgency-tag {
    color: #7D7D7D;
12e66ec8   刘淇   新增树
851
852
  }
  </style>