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/req-list.vue |  354 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 214 insertions(+), 140 deletions(-)

diff --git a/eims-ui-mobile/src/pages/repair/req-list.vue b/eims-ui-mobile/src/pages/repair/req-list.vue
index 54209d6..974d2aa 100644
--- a/eims-ui-mobile/src/pages/repair/req-list.vue
+++ b/eims-ui-mobile/src/pages/repair/req-list.vue
@@ -2,151 +2,173 @@
 {
   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" :auto="false" @query="queryList" show-refresher-update-time>
+  <z-paging
+    ref="paging"
+    v-model="dataList"
+    :auto="false"
+    @query="queryList"
+    show-refresher-update-time
+  >
     <template #top>
-      <wd-drop-menu v-if="!isSelectReq">
-        <wd-drop-menu-item
-          v-model="reqTypeId"
-          label-key="dictLabel"
-          value-key="dictValue"
-          :options="reqTypeList"
-          @change="handleReqType"
-        />
-        <wd-drop-menu-item
-          v-model="status"
-          label-key="dictLabel"
-          value-key="dictValue"
-          :options="statusList"
-          @change="handleReqStatu"
-        />
-      </wd-drop-menu>
+      <wd-navbar
+        title="鎶ヤ慨鍒楄〃"
+        left-arrow
+        @click-left="goBack"
+        right-text="鏂板"
+        @click-right="handleClickRight"
+        custom-style="background: #4D80F0;"
+        safeAreaInsetTop
+      ></wd-navbar>
+      <!-- 澧炲姞涓�涓悳绱㈡爮 -->
+      <wd-search v-model="searchValue" @search="handleSearch"></wd-search>
+<!--      <wd-drop-menu v-if="!isSelectReq">-->
+<!--        <wd-drop-menu-item-->
+<!--          v-model="reqTypeId"-->
+<!--          label-key="dictLabel"-->
+<!--          value-key="dictValue"-->
+<!--          :options="reqTypeList"-->
+<!--          @change="handleReqType"-->
+<!--        />-->
+<!--        <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="handleReqStatu"-->
+<!--        />-->
+<!--      </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.code }}</text>
-            </view>
+      <ReqCard
+        v-for="item in dataList"
+        :key="item.id"
+        :item="item"
+        @itemClick="itemClick"
+      ></ReqCard>
+<!--      <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-sm">{{ item.code }}</text>-->
+<!--            </view>-->
 
-            <view>
-              <wd-button size="small" v-if="item.status === '0'" type="info">寰呮帴鍗�</wd-button>
-              <wd-button size="small" v-else-if="item.status === '1'" type="warning">
-                宸叉帴鍗�
-              </wd-button>
-              <wd-button size="small" v-else-if="item.status === '2'" type="primary">
-                缁翠慨涓�
-              </wd-button>
-              <wd-button size="small" v-else-if="item.status === '3'" type="success">
-                宸插畬鎴�
-              </wd-button>
-            </view>
-          </view>
-        </template>
-        <wd-swipe-action>
-          <view class="flex h-[160rpx] items-center" @click.stop="itemClick(item)">
-            <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>
+<!--            <view>-->
+<!--              <wd-button size="small" v-if="item.status === '0'" type="info">寰呮帴鍗�</wd-button>-->
+<!--              <wd-button size="small" v-else-if="item.status === '1'" type="warning">-->
+<!--                宸叉帴鍗�-->
+<!--              </wd-button>-->
+<!--              <wd-button size="small" v-else-if="item.status === '2'" type="primary">-->
+<!--                缁翠慨涓�-->
+<!--              </wd-button>-->
+<!--              <wd-button size="small" v-else-if="item.status === '3'" type="success">-->
+<!--                宸插畬鎴�-->
+<!--              </wd-button>-->
+<!--            </view>-->
+<!--          </view>-->
+<!--        </template>-->
+<!--        <wd-swipe-action>-->
+<!--          <view class="flex h-[160rpx] items-center" @click.stop="itemClick(item)">-->
+<!--            <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 === '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.occTime }}</text>
-                </view>
+<!--                <template v-if="item.reqType === '3'">-->
+<!--                  <text>鍏朵粬绫诲瀷</text>-->
+<!--                </template>-->
+<!--                <view class="text-color-gray mt-1 text-mini">-->
+<!--                  <text>鍙戠敓鏃堕棿: {{ item.occTime }}</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.reqUserName }}</text>
-                </view>
-              </view>
-              <view class="text-color-gray text-xs mt-1">
-                {{ item.location }} {{ item.madeIn }}
-              </view>
-            </view>
-            <view v-if="isSelectReq">
-              <wd-button size="small" icon="edit-outline" @click.stop="handleSelectReq(item)">
-                閫変腑
-              </wd-button>
-            </view>
-          </view>
-          <template #right>
-            <view class="h-full px-3 flex items-center">
-              <wd-button size="small" type="error" @click.stop="handleDelete(item)">鍒犻櫎</wd-button>
-            </view>
-          </template>
-        </wd-swipe-action>
-      </wd-card>
+<!--                <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.reqUserName }}</text>-->
+<!--                </view>-->
+<!--              </view>-->
+<!--              <view class="text-color-gray text-sm mt-1">-->
+<!--                {{ item.location }} {{ item.madeIn }}-->
+<!--              </view>-->
+<!--            </view>-->
+<!--            <view v-if="isSelectReq">-->
+<!--              <wd-button size="small" icon="edit-outline" @click.stop="handleSelectReq(item)">-->
+<!--                鎺ュ崟-->
+<!--              </wd-button>-->
+<!--            </view>-->
+<!--          </view>-->
+<!--          <template #right>-->
+<!--            <view class="h-full px-3 flex items-center">-->
+<!--              <wd-button size="small" type="error" @click.stop="handleDelete(item)">鍒犻櫎</wd-button>-->
+<!--            </view>-->
+<!--          </template>-->
+<!--        </wd-swipe-action>-->
+<!--      </wd-card>-->
     </view>
   </z-paging>
 </template>
 
 <script setup lang="ts">
-import { onMounted, getCurrentInstance, ref } from 'vue'
 import { useToast, useMessage } from 'wot-design-uni'
 import { getRepairReqList, delRepairReq } from '@/service/repair'
 import { DICT_REPAIR_REQ_STATUS, DICT_REPAIR_REQ_TYPE, getDictInfo } from '@/service/dict'
+import dayjs from "dayjs";
+import { isEquAdmin, isRepair } from "@/utils/RoleUtils";
+import { useUserStore } from "@/store";
+import ReqCard from "@/components/repair/req-card.vue";
 
+const userStore = useUserStore()
 const message = useMessage()
 const toast = useToast()
 // 鎶ヤ慨鍗曠被鍨�
 const reqTypeId = ref<number>(-1)
 // 鎶ヤ慨鍗曞鐞嗙姸鎬�
 const status = ref<number>(-1)
-
+const searchValue = ref<string>('')
 const isSelectReq = ref(false)
+
+const filterDate = ref<string>('2')
+
+const filterDateList = ref<Record<string, any>[]>([
+  { label: '鎵�鏈夋暟鎹�', value: '0' },
+  { label: '褰撳ぉ鏁版嵁', value: '1' },
+  { label: '褰撴湀鏁版嵁', value: '2' },
+])
 
 const reqTypeList = ref<any>([{ dictLabel: '鎵�鏈夌被鍨�', dictValue: -1 }])
 const statusList = ref<any>([{ dictLabel: '鎵�鏈夌姸鎬�', dictValue: -1 }])
@@ -156,25 +178,56 @@
 function handleReqStatu({ value }) {
   reloadData()
 }
+function handleFilterDate({ value }) {
+  reloadData()
+}
+
+
 
 const paging = ref(null)
 const dataList = ref([])
 
 const queryList = (pageNum?: number, pageSize?: number) => {
-  const parmams = {
+  const queryParams: any = {
     pageNum,
     pageSize,
-    reqType: reqTypeId.value,
-    status: status.value,
+    params: {
+      searchValue: searchValue.value,
+    },
   }
-  if (reqTypeId.value === -1) {
-    delete parmams.reqType
-  }
-  if (status.value === -1) {
-    delete parmams.status
+  // if (reqTypeId.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
+  // }
+
+  // 鏌ヨ鏈畬鎴愮殑鎶ヤ慨鍗�
+  queryParams.params.status = '0,1,2'
+  queryParams.reqUser = userStore?.userInfo?.userId
+  if (isRepair() || isEquAdmin()) {
+    queryParams.params.status = '0'
+    queryParams.reqUser = undefined
   }
 
-  getRepairReqList(parmams)
+  getRepairReqList(queryParams)
     .then((res: any) => {
       paging.value.completeByTotal(res.rows, res.total)
     })
@@ -219,6 +272,11 @@
     })
 }
 
+function handleSearch() {
+  console.log('handleSearch')
+  paging.value.reload()
+}
+
 /**
  * 鏉$洰鐐瑰嚮浜嬩欢
  * @param item
@@ -230,10 +288,19 @@
  * @param item
  */
 function handleSelectReq(item: any) {
-  if (isSelectReq.value) {
-    emitSelectReq(item)
-    uni.navigateBack()
-  }
+  // 寮瑰嚭纭鏄惁鎺ュ崟寮圭獥
+  message.confirm({
+    msg: '纭畾鎺ュ崟锛�',
+    title: '鎻愮ず',
+    beforeConfirm: ({ resolve }) => {
+      resolve(true)
+      // 鎺ュ崟閫昏緫澶勭悊
+      if (isSelectReq.value) {
+        emitSelectReq(item)
+        uni.navigateBack()
+      }
+    },
+  })
 }
 
 /**
@@ -246,13 +313,20 @@
   })
 }
 
-onNavigationBarButtonTap((e) => {
-  if (e.index === 0 && !isSelectReq.value) {
-    uni.navigateTo({
-      url: `/pages/repair/repair-add`,
-    })
-  }
-})
+const goBack = () => {
+  uni.navigateBack()
+}
+function handleClickRight() {
+  // if (e.index === 0 && !isSelectReq.value) {
+  //   uni.navigateTo({
+  //     url: `/pages/repair/repair-add`,
+  //   })
+  // }
+
+  uni.navigateTo({
+    url: `/pages/repair/repair-add`,
+  })
+}
 
 const eventChannel = ref<any>()
 onMounted(() => {
@@ -281,10 +355,10 @@
 
 onLoad(() => {
   initData()
-  uni.$on('req-list-refresh', reloadData)
+  uni.$on('list-refresh', reloadData)
 })
 onUnload(() => {
-  uni.$off('req-list-refresh', reloadData)
+  uni.$off('list-refresh', reloadData)
 })
 </script>
 

--
Gitblit v1.9.3