From 453f63fd6cd6466222304df619e62b3a5667ca68 Mon Sep 17 00:00:00 2001
From: zhuguifei <zhuguifei@zhuguifeideiMac.local>
Date: 星期二, 05 八月 2025 13:56:47 +0800
Subject: [PATCH] 修复0730测试问题
---
eims-ui-mobile/src/pages/maint/maint-st.vue | 246 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 215 insertions(+), 31 deletions(-)
diff --git a/eims-ui-mobile/src/pages/maint/maint-st.vue b/eims-ui-mobile/src/pages/maint/maint-st.vue
index f7ce57c..85851df 100644
--- a/eims-ui-mobile/src/pages/maint/maint-st.vue
+++ b/eims-ui-mobile/src/pages/maint/maint-st.vue
@@ -11,13 +11,25 @@
<template>
<z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time>
<template #top>
- <wd-drop-menu>
- <wd-drop-menu-item v-model="equName" :options="equList" @change="handleEquName" />
- <wd-drop-menu-item v-model="status" :options="statusList" @change="handleStatus" />
- </wd-drop-menu>
+ <!-- 澧炲姞涓�涓悳绱㈡爮 -->
+ <wd-search v-model="searchValue" @search="handleSearch">
+ <template #right-icon>
+ <wd-icon name="scan" size="34rpx"></wd-icon>
+ </template>
+ </wd-search>
+ <wd-tabs v-model="activeTab" @change="handleTabChange">
+ <wd-tab title="寰呬繚鍏�"></wd-tab>
+ <wd-tab title="寰呯‘璁�"></wd-tab>
+ <wd-tab title="宸插畬鎴�"></wd-tab>
+ </wd-tabs>
</template>
<view class="bg-base">
- <wd-card type="rectangle" v-for="(item, index) in dataList" :key="item.id">
+ <wd-card
+ type="rectangle"
+ v-for="(item, index) in dataList"
+ :key="item.id"
+ :class="[getCardColorClass(item.planTime)]"
+ >
<template #title>
<view class="flex justify-between">
<view class="flex items-center menu-title-box">
@@ -35,24 +47,36 @@
</view>
</view>
</template>
- <view class="flex h-[140rpx]" items-center>
+ <view class="flex" items-center>
<image class="slot-img text-center" src="/static/images/camera.png" />
<view class="flex-1">
- <view class="text-color-gray text-xs mt-1 flex">
- <text class="mr-3">宸ュ崟鎬绘暟: {{ item.orderCount }}</text>
+ <view class="text-color-gray text-sm mt-1 flex">
+ <text class="mr-3">鎬绘暟: {{ item.orderCount }}</text>
|
+ <template v-if="activeTab === 0">
+ <text class="mx-3">寰呬繚鍏�: {{ item.dbyCount }}</text>
+ |
+ </template>
+ <template v-else>
+ <text class="mx-3">寰呴獙璇�: {{ item.dyzCount }}</text>
+ |
+ </template>
<text class="mx-3">宸插畬鎴�: {{ item.wcCount }}</text>
</view>
- <view class="text-color-gray text-xs mt-2 flex">
- <text class="mr-3">寰呬繚鍏�: {{ item.dbyCount }}</text>
- |
- <text class="mx-3">淇濆吇涓�: {{ item.byCount }}</text>
- |
- <text class="ml-3">寰呴獙璇�: {{ item.dyzCount }}</text>
- </view>
- <view class="text-color-gray text-xs mt-2 flex">
+<!-- <view class="text-color-gray text-sm mt-2 flex">-->
+<!-- <text class="mr-3">寰呬繚鍏�: {{ item.dbyCount }}</text>-->
+<!-- |-->
+<!--<!– <text class="mx-3">淇濆吇涓�: {{ item.byCount }}</text>–>-->
+<!--<!– |–>-->
+<!--<!– <text class="ml-3">寰呴獙璇�: {{ item.dyzCount }}</text>–>-->
+<!-- </view>-->
+ <view class="text-color-gray text-sm mt-2 flex">
<text>鐘舵�侊細</text>
- <template v-if="item.status=== '1'">
+ <template v-if="item.status === '1'">
+ <wd-icon class="icon-color-warning" name="check-outline" size="34rpx"></wd-icon>
+ <text class="ml-1">寰呯‘璁�</text>
+ </template>
+ <template v-else-if="item.status === '2'">
<wd-icon class="icon-color-success" name="check-outline" size="34rpx"></wd-icon>
<text class="ml-1">宸插畬鎴�</text>
</template>
@@ -61,30 +85,101 @@
<text class="ml-1">杩涜涓�</text>
</template>
</view>
- <view class="text-color-gray text-xs mt-2 flex">
- 鍒涘缓鏃堕棿: {{item.createTime}}
- </view>
+ <view class="text-color-gray text-sm mt-2 flex">鍒涘缓鏃堕棿: {{ item.createTime }}</view>
</view>
<wd-button size="small" icon="edit-outline" @click.stop="itemClick(item)">鏄庣粏</wd-button>
</view>
</wd-card>
</view>
+
+ <wd-fab
+ v-if="status === '1' && isLeader()"
+ :draggable="true"
+ type="success"
+ position="left-bottom"
+ :expandable="false"
+ inactiveIcon="check"
+ @click="handleBatchComplete"
+ direction="top"
+ />
</z-paging>
</template>
<script setup lang="ts">
-import { ref } from 'vue'
+import { ref, computed } from 'vue'
import { getMaintStList } from '@/service/maint'
+import dayjs from 'dayjs'
+import { updateMaintSt } from '@/service/maint'
+import { useUserStore } from "@/store";
+import { isLeader } from '@/utils/RoleUtils'
+import { useToast } from 'wot-design-uni'
+
+const searchValue = ref<string>('')
+/**
+ * 鍏朵粬椤甸潰浼犺繃鏉ョ殑鏁版嵁
+ * assetNo: 璧勪骇缂栧彿
+ * from: 鏄惁鏄壂鐮佽繘鏉ョ殑锛屽鏋滄槸鎵爜杩涙潵锛屽彧鑳芥煡璇㈠浐瀹氳澶囩殑鏁版嵁
+ */
+interface PageParams {
+ assetNo?: string
+ from?: string
+}
interface QueryParams {
pageNum: number
pageSize: number
+ assetNo?: string
equName?: string
status?: string
+ params?: NonNullable<unknown>
}
-const status = ref<string>('-1')
+// 璁$畻宸ュ崟鍗$墖鐨勮儗鏅鑹茬被
+function getCardColorClass(planTime) {
+ if (!planTime) return ''
+
+ const now = dayjs()
+ const planDate = dayjs(planTime)
+
+ // 鑾峰彇璁″垝鏃ユ湡鎵�鍦ㄦ湀浠界殑鏈�鍚庝竴澶�
+ const planMonthEnd = planDate.endOf('month')
+
+ // 璁$畻褰撳墠鏃ユ湡涓庤鍒掓湀鏈堝簳鐨勫樊鍊硷紙澶╂暟锛�
+ const diffDays = planMonthEnd.diff(now, 'day')
+
+ if (diffDays < 0) {
+ // 宸茬粡杩囦簡璁″垝鏈堢殑鏈堝簳锛岀孩鑹茶儗鏅�
+ return 'card-overdue'
+ } else if (diffDays <= 3) {
+ // 璺濈璁″垝鏈堟湀搴�3澶╀互鍐咃紝绾㈣壊鑳屾櫙
+ return 'card-overdue'
+ } else if (diffDays <= 10) {
+ // 璺濈璁″垝鏈堟湀搴�10澶╀互鍐咃紝榛勮壊鑳屾櫙
+ return 'card-urgent'
+ } else {
+ // 姝e父鐘舵�侊紝鑳屾櫙棰滆壊涓嶅彉
+ return ''
+ }
+}
+
+// 椤甸潰鍙傛暟锛屼笂涓〉闈紶閫掕繃鏉ョ殑鍙傛暟
+const option = reactive<PageParams>({
+ assetNo: '',
+ from: '',
+})
+
+// 鏍囩椤电浉鍏�
+const activeTab = ref(0) // 榛樿閫変腑绗竴涓爣绛鹃〉锛堝緟淇濆吇锛�
+
+// 鍘熸湁鐘舵��
+const status = ref<string>('0') // 榛樿涓哄緟淇濆吇鐘舵��
const equName = ref<string>('-1')
+const filterDate = ref<string>('0')
+
+const filterDateList = ref<Record<string, any>[]>([
+ { label: '鎵�鏈夋暟鎹�', value: '0' },
+ { label: '褰撴湀鏁版嵁', value: '1' },
+])
const statusList = ref<Record<string, any>[]>([
{ label: '鎵�鏈夌姸鎬�', value: '-1' },
@@ -94,9 +189,31 @@
{ label: '宸插畬鎴�', value: '3' },
])
const equList = ref<Record<string, any>[]>([{ label: '鎵�鏈夎澶�', value: '-1' }])
+
+// 鏍囩椤靛垏鎹㈠鐞嗗嚱鏁�
+function handleTabChange({ index }) {
+ // 鏍规嵁鏍囩椤电储寮曡缃搴旂殑鐘舵�佸��
+ if (index === 0) {
+ // 寰呬繚鍏�
+ status.value = '0'
+ } else if (index === 1) {
+ // 寰呯‘璁�
+ status.value = '1'
+ } else if (index === 2) {
+ // 宸插畬鎴�
+ status.value = '2'
+ }
+ // 閲嶆柊鍔犺浇鏁版嵁
+ reloadData()
+}
+
+// 鍘熸湁鍑芥暟
function handleStatus({ value }) {}
function handleEquName({ value }) {
console.log(value)
+}
+function handleFilterDate({ value }) {
+ reloadData()
}
const paging = ref(null)
@@ -105,20 +222,36 @@
const queryList = (pageNum?: number, pageSize?: number) => {
// 杩欓噷鐨刾ageNo鍜宲ageSize浼氳嚜鍔ㄨ绠楀ソ锛岀洿鎺ヤ紶缁欐湇鍔″櫒鍗冲彲
// 杩欓噷鐨勮姹傚彧鏄紨绀猴紝璇锋浛鎹㈡垚鑷繁鐨勯」鐩殑缃戠粶璇锋眰锛屽苟鍦ㄧ綉缁滆姹傚洖璋冧腑閫氳繃paging.value.complete(璇锋眰鍥炴潵鐨勬暟缁�)灏嗚姹傜粨鏋滀紶缁檢-paging
- const params: QueryParams = {
+ const queryParams: QueryParams = {
pageNum,
pageSize,
equName: equName.value,
status: status.value,
+ params: {},
}
- if (equName.value === '-1') {
- delete params.equName
- }
- if (status.value === '-1') {
- delete params.status
+ if (filterDate.value === '1') {
+ // 鑾峰彇褰撳墠鏃ユ湡
+ const now = dayjs()
+ queryParams.params = {
+ beginPlanTime: now.startOf('month').format('YYYY-MM-DD 00:00:00'),
+ endPlanTime: now.endOf('month').format('YYYY-MM-DD 23:59:59'),
+ }
+ } else {
+ queryParams.params = {}
}
- getMaintStList(params)
+ if (equName.value === '-1') {
+ delete queryParams.equName
+ }
+ if (status.value === '-1') {
+ delete queryParams.status
+ }
+ // 濡傛灉鏄粠鎵爜椤甸潰杩囨潵锛屽彧鑳芥煡璇㈠浐瀹氳澶囩殑鏁版嵁
+ if (option?.from === 'scan') {
+ queryParams.assetNo = option.assetNo
+ }
+ queryParams.params.searchValue = searchValue.value
+ getMaintStList(queryParams)
.then((res: any) => {
// 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡
paging.value.completeByTotal(res.rows, res.total)
@@ -137,10 +270,53 @@
})
}
+function handleSearch () {
+ console.log('handleSearch')
+ paging.value.reload()
+}
+
function reloadData() {
paging.value.reload()
}
-onLoad(() => {
+
+const userStore = useUserStore()
+const toast = useToast()
+
+async function handleBatchComplete() {
+ console.log('handleBatchComplete', dataList.value.length)
+ if (!isLeader()) {
+ toast.info('鏃犳潈闄愭搷浣�')
+ return
+ }
+ // 濡傛灉寰呯‘璁ゅ伐鍗曞垪琛ㄤ负绌猴紝鍒欐彁绀虹敤鎴锋棤寰呯‘璁ゅ伐鍗�
+ if (dataList.value.length < 1) {
+ toast.info('鏃犲緟纭宸ュ崟')
+ return
+ }
+ const now = new Date()
+ const verifyTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`
+
+ // 鍋囪 dataList 鏄綋鍓嶅緟纭鐨勫伐鍗曞垪琛�
+ const promises = dataList.value.map(item => {
+ return updateMaintSt({
+ id: item.id,
+ status: '2',
+ verifyUser: userStore?.userInfo?.userId,
+ verifyTime
+ })
+ })
+
+ try {
+ await Promise.all(promises)
+ toast.success('涓�閿‘璁ゅ畬鎴�')
+ reloadData() // 鍒锋柊鍒楄〃
+ } catch (e) {
+ toast.error('閮ㄥ垎宸ュ崟纭澶辫触锛岃閲嶈瘯')
+ }
+}
+
+onLoad((options) => {
+ Object.assign(option, options)
uni.$on('maint-st-refresh', reloadData)
})
onUnload(() => {
@@ -162,7 +338,7 @@
height: 40rpx;
}
.text-mini {
- font-size: 22rpx;
+ font-size: 24rpx;
}
.menu-indicator {
@@ -177,4 +353,12 @@
:deep(.wd-card__title-content) {
padding: 24rpx 0 !important;
}
+
+/* 宸ュ崟鍗$墖鑳屾櫙棰滆壊 */
+.card-urgent {
+ background-color: rgba(255, 204, 0, 0.1); /* 榛勮壊鑳屾櫙 */
+}
+.card-overdue {
+ background-color: rgba(255, 0, 0, 0.1); /* 绾㈣壊鑳屾櫙 */
+}
</style>
--
Gitblit v1.9.3