From 60384e8241fa855b5780260633ee9b9f8904847a Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期五, 20 六月 2025 14:24:19 +0800
Subject: [PATCH] feat(eims-ui-mobile): 为多个页面添加搜索功能 - 在 equ-list、insp-st、maint-st、req-list 和 res-list 页面中添加设备名称和资产编号的模糊搜索

---
 eims-ui-mobile/src/pages/repair/res-list.vue |  528 ++++++++++++++++++++++++----------------------------------
 1 files changed, 216 insertions(+), 312 deletions(-)

diff --git a/eims-ui-mobile/src/pages/repair/res-list.vue b/eims-ui-mobile/src/pages/repair/res-list.vue
index 02b2570..3ca5864 100644
--- a/eims-ui-mobile/src/pages/repair/res-list.vue
+++ b/eims-ui-mobile/src/pages/repair/res-list.vue
@@ -2,187 +2,51 @@
 {
   layout: 'default',
   needLogin: true,
-  style: {
-    navigationBarTitleText: '璁惧缁翠慨',
-    'app-plus': {
-      titleNView: {
-        buttons: [
-          {
-            text: '鎺ュ崟',
-            fontSize: '14px',
-            color: '#FFFFFF',
-          },
-          {
-            text: '',
-            fontSize: '24px',
-            color: '#FFFFFF',
-          },
-        ],
-      },
-    },
-  },
+  style: { navigationBarTitleText: '璁惧缁翠慨', navigationStyle: 'custom' },
 }
 </route>
 <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="resTypeId"
-          label-key="dictLabel"
-          value-key="dictValue"
-          :options="resTypeList"
-          @change="handleResType"
-        />
-        <wd-drop-menu-item
-          v-model="status"
-          label-key="dictLabel"
-          value-key="dictValue"
-          :options="statusList"
-          @change="handleResStatu"
-        />
-      </wd-drop-menu>
+      <wd-navbar
+        title="璁惧缁翠慨"
+        left-arrow
+        @click-left="goBack"
+        custom-style="background: #4D80F0;"
+        safeAreaInsetTop
+      >
+<!--        <template #right>-->
+<!--          <text v-if="isLineOrRepair()" class="text-white">鎺ュ崟</text>-->
+<!--        </template>-->
+      </wd-navbar>
+      <!-- 澧炲姞涓�涓悳绱㈡爮 -->
+      <wd-search v-model="searchValue" @search="handleSearch">
+      </wd-search>
+<!--      <wd-drop-menu>-->
+<!--        <wd-drop-menu-item-->
+<!--          v-model="resTypeId"-->
+<!--          label-key="dictLabel"-->
+<!--          value-key="dictValue"-->
+<!--          :options="resTypeList"-->
+<!--          @change="handleResType"-->
+<!--        />-->
+<!--        <wd-drop-menu-item-->
+<!--          v-model="filterDate"-->
+<!--          :options="filterDateList"-->
+<!--          @change="handleFilterDate"-->
+<!--        />-->
+<!--        <wd-drop-menu-item-->
+<!--          v-model="status"-->
+<!--          label-key="dictLabel"-->
+<!--          value-key="dictValue"-->
+<!--          :options="statusList"-->
+<!--          @change="handleResStatu"-->
+<!--        />-->
+<!--      </wd-drop-menu>-->
     </template>
 
     <view class="bg-base">
-      <wd-card type="rectangle" v-for="(item, index) in dataList" :key="item.id">
-        <template #title>
-          <view class="flex justify-between items-center">
-            <view class="flex items-center menu-title-box">
-              <view class="menu-indicator"></view>
-              <text class="ml-1 text-xs">{{ item.resCode }}</text>
-              <text class="text-color-gray ml-2 text-mini">鎺ュ崟:{{ item.createTime }}</text>
-            </view>
-
-            <view>
-              <wd-tag size="small" v-if="item.status === '1'" type="warning">宸叉帴鍗�</wd-tag>
-              <wd-tag size="small" v-else-if="item.status === '2'" type="primary">缁翠慨涓�</wd-tag>
-              <wd-tag size="small" v-else-if="item.status === '3'" type="success">宸插畬鎴�</wd-tag>
-            </view>
-          </view>
-        </template>
-        <view class="flex h-[240rpx] items-center">
-          <image
-            v-if="item.reqType === '1'"
-            class="slot-img text-center"
-            src="/static/ico/ico-huiyi.png"
-          />
-          <image
-            v-else-if="item.reqType === '2'"
-            class="slot-img text-center"
-            src="/static/ico/ico-setting.png"
-          />
-          <image
-            v-else-if="item.reqType === '3'"
-            class="slot-img text-center"
-            src="/static/ico/ico-faxian.png"
-          />
-          <view class="flex-1 mt-1">
-            <view class="text-color-base">
-              <template v-if="item.reqType === '1'">
-                <text>璁惧绫诲瀷</text>
-                <text class="mx-2">|</text>
-                <text>{{ item.equName }}</text>
-              </template>
-
-              <template v-if="item.reqType === '2'">
-                <text>宸ュ叿绫诲瀷</text>
-                <text class="mx-2">|</text>
-                <text>{{ item.fixtureName }}</text>
-              </template>
-
-              <template v-if="item.reqType === '3'">
-                <text>鍏朵粬绫诲瀷</text>
-              </template>
-              <view class="text-color-gray mt-1 text-mini">
-                <text>鎶ヤ慨浜�: {{ item.reqUserName }}</text>
-              </view>
-              <view class="text-color-gray mt-1 text-mini">
-                <text>鎶ヤ慨鏃堕棿: {{ item.reqTime }}</text>
-              </view>
-
-              <view class="text-color-gray mt-1 text-mini">
-                <text>缁翠慨寮�濮�: {{ item.startTime }}</text>
-              </view>
-              <view class="text-color-gray mt-1 text-mini">
-                <text>缁翠慨缁撴潫: {{ item.endTime }}</text>
-              </view>
-              <view class="text-color-gray mt-1 text-mini">
-                <text>缁翠慨浜�: {{ item.resUserName }}</text>
-              </view>
-            </view>
-          </view>
-          <view>
-            <!--鎿嶄綔宸ユ垨缁翠慨宸ヨ鑹�-->
-            <template v-if="isOperatorOrRepair()">
-              <wd-button
-                v-if="item.status === '1'"
-                size="small"
-                icon="edit-outline"
-                @click.stop="handleStartRepair(item)"
-              >
-                寮�濮嬬淮淇�
-              </wd-button>
-              <wd-button
-                v-else-if="item.status === '2'"
-                size="small"
-                icon="edit-outline"
-                @click.stop="itemClick(item)"
-              >
-                缁翠慨涓�
-              </wd-button>
-              <view class="h-full flex flex-col" v-else-if="item.status === '3'">
-                <wd-button size="small" icon="warn-bold" @click.stop="itemClick(item)">
-                  璇︽儏
-                </wd-button>
-                <wd-button
-                  class="mt-4"
-                  size="small"
-                  icon="edit-outline"
-                  @click.stop="goToFeedBack(item)"
-                >
-                  鏌ョ湅璇勪环
-                </wd-button>
-              </view>
-            </template>
-
-            <!--绠$悊鍛樿鑹�-->
-            <template v-else-if="isLeader()">
-              <wd-button
-                v-if="item.status === '1'"
-                size="small"
-                icon="warn-bold"
-                disabled
-                @click.stop="itemClick(item)"
-              >
-                寰呯淮淇�
-              </wd-button>
-              <wd-button
-                v-else-if="item.status === '2'"
-                size="small"
-                icon="warn-bold"
-                disabled
-                @click.stop="itemClick(item)"
-              >
-                缁翠慨涓�
-              </wd-button>
-              <view class="h-full flex flex-col" v-else-if="item.status === '3'">
-                <wd-button size="small" icon="warn-bold" @click.stop="itemClick(item)">
-                  璇︽儏
-                </wd-button>
-                <wd-button
-                  class="mt-4"
-                  size="small"
-                  icon="edit-outline"
-                  @click.stop="goToFeedBack(item)"
-                >
-                  {{ item.fbId == null ? '鍐欒瘎浠�' : '鏌ョ湅璇勪环' }}
-                </wd-button>
-              </view>
-            </template>
-          </view>
-        </view>
-      </wd-card>
+      <res-card v-for="item in dataList" :key="item.id" :item="item" />
     </view>
   </z-paging>
 </template>
@@ -192,13 +56,16 @@
 import { useToast, useMessage } from 'wot-design-uni'
 import { getRepairResList, addRepairRes, updateRepairRes } from '@/service/repair'
 import { DICT_REPAIR_RES_STATUS, DICT_REPAIR_REQ_TYPE, getDictInfo } from '@/service/dict'
-import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils'
+import { isLeader, isLineOrRepair, isRepair } from "@/utils/RoleUtils";
 import { useUserStore } from '@/store'
 import { formatDate } from '@/utils/DateUtils'
+import dayjs from "dayjs";
+import ResCard from "@/components/repair/res-card.vue";
 const userStore = useUserStore()
 
 const message = useMessage()
 const toast = useToast()
+const searchValue = ref<string>('')
 
 /**
  * 鍏朵粬椤甸潰浼犺繃鏉ョ殑鏁版嵁
@@ -222,37 +89,73 @@
 const status = ref<number>(-1)
 
 const isSelectRes = ref(false)
+const filterDate = ref<string>('2')
 
+const filterDateList = ref<Record<string, any>[]>([
+  { label: '鎵�鏈夋暟鎹�', value: '0' },
+  { label: '褰撳ぉ鏁版嵁', value: '1' },
+  { label: '褰撴湀鏁版嵁', value: '2' },
+])
 const resTypeList = ref<any>([{ dictLabel: '鎵�鏈夌被鍨�', dictValue: -1 }])
 const statusList = ref<any>([{ dictLabel: '鎵�鏈夌姸鎬�', dictValue: -1 }])
-function handleResType({ value }) {
-  reloadData()
-}
-function handleResStatu({ value }) {
-  reloadData()
-}
+// function handleResType({ value }) {
+//   reloadData()
+// }
+// function handleResStatu({ value }) {
+//   reloadData()
+// }
+// function handleFilterDate({ value }) {
+//   reloadData()
+// }
 
 const paging = ref(null)
 const dataList = ref([])
 
 const queryList = (pageNum?: number, pageSize?: number) => {
-  const params: any = {
+  const queryParams: any = {
     pageNum,
     pageSize,
-    reqType: resTypeId.value,
-    status: status.value,
+    params: {
+      searchValue: searchValue.value,
+    },
+    // reqType: resTypeId.value,
+    // status: status.value,
   }
-  if (resTypeId.value === -1) {
-    delete params.reqType
-  }
-  if (status.value === -1) {
-    delete params.status
-  }
+  // if (resTypeId.value === -1) {
+  //   delete queryParams.reqType
+  // }
+  // if (status.value === -1) {
+  //   delete queryParams.status
+  // }
+  //
+  // if (filterDate.value === '1') {
+  //   // 鑾峰彇褰撳墠鏃ユ湡
+  //   const now = dayjs()
+  //   queryParams.params = {
+  //     beginReqTime: now.startOf('day').format('YYYY-MM-DD 00:00:00'),
+  //     endReqTime: now.endOf('day').format('YYYY-MM-DD 23:59:59'),
+  //   }
+  // } else if (filterDate.value === '2') {
+  //   const now = dayjs()
+  //   queryParams.params = {
+  //     beginReqTime: now.startOf('month').format('YYYY-MM-DD 00:00:00'),
+  //     endReqTime: now.endOf('month').format('YYYY-MM-DD 23:59:59'),
+  //   }
+  // } else {
+  //   delete queryParams.params
+  // }
   // 濡傛灉鏄粠鎵爜椤甸潰杩囨潵锛屽彧鑳芥煡璇㈠浐瀹氳澶囩殑鏁版嵁
   if (option?.from === 'scan') {
-    params.assetNo = option.assetNo
+    queryParams.assetNo = option.assetNo
   }
-  getRepairResList(params)
+  queryParams.params.status = '0,1,2,3'
+  queryParams.reqUser = userStore?.userInfo?.userId
+  if (isRepair()) {
+    queryParams.params.status = undefined
+    queryParams.resUser = userStore?.userInfo?.userId
+    delete queryParams.reqUser
+  }
+  getRepairResList(queryParams)
     .then((res: any) => {
       paging.value.completeByTotal(res.rows, res.total)
     })
@@ -264,127 +167,128 @@
   paging.value.reload()
 }
 
-/**
- * 鏉$洰鐐瑰嚮浜嬩欢
- * @param item
- */
-function itemClick(item: any) {
-  goToDetail(item)
+// /**
+//  * 鏉$洰鐐瑰嚮浜嬩欢
+//  * @param item
+//  */
+// function itemClick(item: any) {
+//   goToDetail(item)
+// }
+//
+// /**
+//  * 寮�濮嬬淮淇�
+//  * @param item
+//  */
+// function handleStartRepair(item: any) {
+//   // 纭寮�濮嬩慨鏀圭姸鎬佷负2-缁翠慨涓�
+//   const data = Object.assign({}, item)
+//   // 纭寮�濮嬩慨鏀圭姸鎬佷负2-缁翠慨涓�
+//   data.status = '2'
+//   // 璁剧疆寮�濮嬬淮淇椂闂�
+//   data.startTime = formatDate(new Date())
+//   message
+//     .confirm({
+//       msg: '纭畾寮�濮嬬淮淇紵',
+//       title: '鎻愮ず',
+//       beforeConfirm: ({ resolve }) => {
+//         updateRepair(data, resolve)
+//       },
+//     })
+//     .then(() => {})
+//     .catch((error) => {
+//       console.log(error)
+//     })
+// }
+//
+// /**
+//  * 鏇存柊缁翠慨宸ュ崟
+//  * @param data
+//  * @param resolve
+//  */
+// function updateRepair(data: any, resolve: any) {
+//   updateRepairRes(data)
+//     .then((res: any) => {
+//       resolve(true)
+//       if (res?.code === 200) {
+//         reloadData()
+//         // 缁翠慨涓姸鎬佹墠闇�瑕佽烦杞�
+//         if (data?.status === '2') {
+//           goToDetail(data)
+//         }
+//       }
+//     })
+//     .catch((res) => {
+//       console.error(res)
+//     })
+// }
+//
+// function goToDetail(item) {
+//   uni.navigateTo({
+//     url: `/pages/repair/res-detail?id=${item.id}`,
+//   })
+// }
+//
+// function goToFeedBack(item) {
+//   uni.navigateTo({
+//     url: `/pages/repair/repair-fb?id=${item.id}`,
+//   })
+// }
+const goBack = () => {
+  uni.navigateBack()
 }
+// function handleClickRight() {
+//   if (isLineOrRepair()) {
+//     handleSelectReq()
+//   } else {
+//     toast.info('璇风櫥褰曟姤淇伐璐﹀彿鎺ュ崟')
+//   }
+// }
 
-/**
- * 寮�濮嬬淮淇�
- * @param item
- */
-function handleStartRepair(item: any) {
-  // 纭寮�濮嬩慨鏀圭姸鎬佷负2-缁翠慨涓�
-  const data = Object.assign({}, item)
-  // 纭寮�濮嬩慨鏀圭姸鎬佷负2-缁翠慨涓�
-  data.status = '2'
-  // 璁剧疆寮�濮嬬淮淇椂闂�
-  data.startTime = formatDate(new Date())
-  message
-    .confirm({
-      msg: '纭畾寮�濮嬬淮淇紵',
-      title: '鎻愮ず',
-      beforeConfirm: ({ resolve }) => {
-        updateRepair(data, resolve)
-      },
-    })
-    .then(() => {})
-    .catch((error) => {
-      console.log(error)
-    })
-}
-
-/**
- * 鏇存柊缁翠慨宸ュ崟
- * @param data
- * @param resolve
- */
-function updateRepair(data: any, resolve: any) {
-  updateRepairRes(data)
-    .then((res: any) => {
-      resolve(true)
-      if (res?.code === 200) {
-        reloadData()
-        // 缁翠慨涓姸鎬佹墠闇�瑕佽烦杞�
-        if (data?.status === '2') {
-          goToDetail(data)
-        }
-      }
-    })
-    .catch((res) => {
-      console.error(res)
-    })
-}
-
-function goToDetail(item) {
-  uni.navigateTo({
-    url: `/pages/repair/res-detail?id=${item.id}`,
-  })
-}
-
-function goToFeedBack(item) {
-  uni.navigateTo({
-    url: `/pages/repair/repair-fb?id=${item.id}`,
-  })
-}
-
-onNavigationBarButtonTap((e) => {
-  if (e.index === 0) {
-    if (isLeader()) {
-      toast.info('璇风櫥褰曠淮淇伐璐﹀彿鎺ュ崟')
-    } else if (isOperatorOrRepair()) {
-      handleSelectReq()
-    }
-  }
-})
-
-/**
- * 閫夋嫨鎶ヤ慨鍗�
- */
-function handleSelectReq() {
-  uni.navigateTo({
-    url: '/pages/repair/req-list',
-    events: {
-      // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹�
-      selectReq: function (data) {
-        console.error(data)
-        // 閫夋嫨鎶ヤ慨鍗曞悗锛屼慨鏀规姤淇崟鐘舵�佸拰鏂板缁翠慨宸ュ崟
-        const resCode = `WXD${data.data.code.slice(3)}`
-        const deptId = userStore?.userInfo?.deptId
-        const userId = userStore?.userInfo?.userId
-        const resData = {
-          reqId: data.data.id,
-          reqCode: data.data.code,
-          reqUser: data.data.reqUser,
-          reqDept: data.data.reqDept,
-          resCode,
-          status: '1',
-          resUser: userId,
-          resDept: deptId,
-        }
-        addRepairRes(resData)
-          .then((res: any) => {
-            if (res.code === 200) {
-              toast.success(res?.msg || '鎿嶄綔鎴愬姛')
-              reloadData()
-            } else {
-              toast.error(res?.msg || '鐢熸垚缁翠慨宸ュ崟澶辫触锛岃閲嶈瘯')
-            }
-          })
-          .catch((res) => {
-            toast.error(res?.msg || '鐢熸垚缁翠慨宸ュ崟澶辫触锛岃閲嶈瘯')
-          })
-      },
-    },
-    success: function (res) {
-      // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
-      res.eventChannel.emit('OnSelectReq', { data: '缁翠慨鍗曢〉闈㈤�夋嫨鎶ヤ慨鍗�' })
-    },
-  })
-}
+//
+// /**
+//  * 閫夋嫨鎶ヤ慨鍗�
+//  */
+// function handleSelectReq() {
+//   uni.navigateTo({
+//     url: '/pages/repair/req-list',
+//     events: {
+//       // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹�
+//       selectReq: function (data) {
+//         console.error(data)
+//         // 閫夋嫨鎶ヤ慨鍗曞悗锛屼慨鏀规姤淇崟鐘舵�佸拰鏂板缁翠慨宸ュ崟
+//         const resCode = `WXD${data.data.code.slice(3)}`
+//         const deptId = userStore?.userInfo?.deptId
+//         const userId = userStore?.userInfo?.userId
+//         const resData = {
+//           reqId: data.data.id,
+//           reqCode: data.data.code,
+//           reqUser: data.data.reqUser,
+//           reqDept: data.data.reqDept,
+//           resCode,
+//           status: '1',
+//           resUser: userId,
+//           resDept: deptId,
+//         }
+//         addRepairRes(resData)
+//           .then((res: any) => {
+//             if (res.code === 200) {
+//               toast.success(res?.msg || '鎿嶄綔鎴愬姛')
+//               reloadData()
+//             } else {
+//               toast.error(res?.msg || '鐢熸垚缁翠慨宸ュ崟澶辫触锛岃閲嶈瘯')
+//             }
+//           })
+//           .catch((res) => {
+//             toast.error(res?.msg || '鐢熸垚缁翠慨宸ュ崟澶辫触锛岃閲嶈瘯')
+//           })
+//       },
+//     },
+//     success: function (res) {
+//       // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+//       res.eventChannel.emit('OnSelectReq', { data: '缁翠慨鍗曢〉闈㈤�夋嫨鎶ヤ慨鍗�' })
+//     },
+//   })
+// }
 
 async function initData() {
   const rList: any = await getDictInfo(DICT_REPAIR_REQ_TYPE)
@@ -395,10 +299,10 @@
 onLoad((options) => {
   Object.assign(option, options)
   initData()
-  uni.$on('res-list-refresh', reloadData)
+  uni.$on('list-refresh', reloadData)
 })
 onUnload(() => {
-  uni.$off('res-list-refresh', reloadData)
+  uni.$off('list-refresh', reloadData)
 })
 </script>
 

--
Gitblit v1.9.3