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/home/index.vue | 497 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 370 insertions(+), 127 deletions(-) diff --git a/eims-ui-mobile/src/pages/home/index.vue b/eims-ui-mobile/src/pages/home/index.vue index 636a1e2..bcc1faa 100644 --- a/eims-ui-mobile/src/pages/home/index.vue +++ b/eims-ui-mobile/src/pages/home/index.vue @@ -8,163 +8,403 @@ } </route> <template> - <view - class="bg-base overflow-hidden" - :style="{ - marginTop: safeAreaInsets?.top + 'px', - }" + <z-paging + ref="paging" + v-model="dataList" + @query="queryList" + show-refresher-update-time + hide-empty-view > - <view class="bg-white h-[80rpx] px-2 flex items-center justify-between"> - <view class="flex items-center" @click="handleUserInfo"> - <wd-icon name="user" size="40rpx" class="icon-color-base"></wd-icon> - <text class="ml-1 text-color-base">寮犱笁</text> - </view> - - <view class="flex items-center"> - <wd-icon name="notification" size="40rpx" class="icon-color-base mr-3"></wd-icon> - <wd-icon name="tips" size="40rpx" class="icon-color-base mr-3"></wd-icon> - <wd-icon name="app" size="40rpx" class="icon-color-base"></wd-icon> - </view> - </view> - - <view class="bg-white py-2 px-2"> - <wd-img class="w-full h-[260rpx]" src="/static/images/pic4.jpeg" /> - </view> - <view class="bg-noti flex flex-row"> - <wd-notice-bar - text="杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭紝杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭紝杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭�" - prefix="clock" - type="info" - :scrollable="false" - custom-class="flex-1 overflow-hidden" - /> - <wd-button type="text" class="w-[120rpx]">鏌ョ湅</wd-button> - </view> - - <view class="bg-white"> - <wd-card type="rectangle"> - <template #title> - <view class="flex items-center menu-title-box"> - <view class="menu-indicator"></view> - <view class="ml-1 text-xs">鏁版嵁鎬昏</view> - </view> - </template> - <view class="flex flex-row justify-around"> - <view class="flex flex-col justify-center"> - <text class="text-lg text-center">0</text> - <text class="text-color-gray">璁惧鎬绘暟</text> - </view> - <view class="flex flex-col justify-center"> - <text class="text-lg text-center">0</text> - <text class="text-color-gray">鏁呴殰璁惧鏁�</text> - </view> - <view class="flex flex-col justify-center"> - <text class="text-lg text-center">0</text> - <text class="text-color-gray">鏈慨澶嶆晠闅�</text> - </view> + <template #top> + <view class="bg-white h-[80rpx] px-2 flex items-center justify-between"> + <view class="flex items-center" @click="handleUserInfo"> + <wd-icon name="user" size="40rpx" class="icon-color-base"></wd-icon> + <text class="ml-1 text-color-base">{{ realName }}</text> </view> - </wd-card> - </view> - <view class="bg-white mt-2"> - <wd-card type="rectangle"> - <template #title> - <view class="flex items-center menu-title-box"> - <view class="menu-indicator"></view> - <view class="ml-1 text-xs">鏁版嵁鎬昏</view> - </view> - </template> - <wd-grid :column="4"> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot is-dot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - </wd-grid> - </wd-card> - </view> + <view class="flex items-center"> + <wd-icon + name="notification" + size="40rpx" + class="icon-color-base mr-3" + @click="handleInfo" + ></wd-icon> + <wd-icon + name="tips" + size="40rpx" + class="icon-color-base mr-3" + @click="handleInfo" + ></wd-icon> + <wd-icon name="app" size="40rpx" class="icon-color-base" @click="handleInfo"></wd-icon> + </view> + </view> - <view class="bg-white mt-2"> - <wd-card type="rectangle"> - <template #title> - <view class="flex items-center menu-title-box"> - <view class="menu-indicator"></view> - <view class="ml-1 text-xs">鏁版嵁鎬昏</view> + </template> + <view class="bg-base overflow-hidden"> + + <view class="bg-white py-2 px-2"> + <wd-img class="w-full h-[260rpx]" src="/static/images/pic4.jpeg" /> + </view> + <view class="bg-noti flex flex-row"> + <wd-notice-bar + text="杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭紝杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭紝杩欐槸涓�鏉℃秷鎭彁绀轰俊鎭�" + prefix="clock" + type="info" + :scrollable="false" + custom-class="flex-1 overflow-hidden" + /> + <wd-button type="text" class="w-[120rpx]">鏌ョ湅</wd-button> + </view> + + <view class="bg-white"> + <wd-card type="rectangle"> + <template #title> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-sm">鏁版嵁鎬昏</view> + </view> + </template> + <view class="flex flex-row justify-around"> + <view class="flex flex-col justify-center"> + <text class="text-lg text-center">{{ equTotal }}</text> + <text class="text-color-gray">璁惧鎬绘暟</text> + </view> + <view class="flex flex-col justify-center"> + <text class="text-lg text-center">{{ fixtureTotal }}</text> + <text class="text-color-gray">宸ュ叿鎬绘暟</text> + </view> + <view class="flex flex-col justify-center"> + <text class="text-lg text-center">{{ faultTotal }}</text> + <text class="text-color-gray">鏈慨澶嶆晠闅�</text> + </view> </view> - </template> - <wd-grid :column="4"> - <wd-grid-item - use-slot - class="flex justify-center items-center" - v-for="(item, index) in menuList" - :key="item.id" - > - <image class="slot-img text-center" :src="item.url" /> - <text>{{ item.name }}</text> - </wd-grid-item> - </wd-grid> - </wd-card> + </wd-card> + </view> +<!-- <view class="bg-white mt-2">--> +<!-- <wd-card type="rectangle">--> +<!-- <template #title>--> +<!-- <view class="flex items-center menu-title-box">--> +<!-- <view class="menu-indicator"></view>--> +<!-- <view class="ml-1 text-sm">蹇嵎鎿嶄綔</view>--> +<!-- </view>--> +<!-- </template>--> +<!-- <wd-grid :column="4">--> +<!-- <wd-grid-item--> +<!-- use-slot--> +<!-- class="flex justify-center items-center"--> +<!-- v-for="(item, index) in commonMenu"--> +<!-- :key="item.id"--> +<!-- @click.stop="goItemPage(item)"--> +<!-- v-show="!(isLeader() && item.custom)"--> +<!-- >--> +<!-- <image class="slot-img text-center" :src="item.icon" />--> +<!-- <text>{{ item.name }}</text>--> +<!-- </wd-grid-item>--> +<!-- </wd-grid>--> +<!-- </wd-card>--> +<!-- </view>--> + <view class="bg-white mt-2"> + <wd-card type="rectangle"> + <template #title> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-sm">璁惧绠$悊</view> + </view> + </template> + <wd-grid :column="4"> + <wd-grid-item + use-slot + class="flex justify-center items-center" + v-for="(item, index) in inspectMenu" + :key="item.id" + @click.stop="goItemPage(item)" + > + <image class="slot-img text-center" :src="item.icon" /> + <text>{{ item.name }}</text> + </wd-grid-item> + </wd-grid> + </wd-card> + </view> + <view class="bg-white mt-2"> + <wd-card type="rectangle"> + <template #title> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-sm">鍙拌处鐩稿叧</view> + </view> + </template> + <wd-grid :column="4"> + <wd-grid-item + use-slot + class="flex justify-center items-center" + v-for="(item, index) in equMenu" + @click.stop="goItemPage(item)" + > + <image class="slot-img text-center" :src="item.icon" /> + <text>{{ item.name }}</text> + </wd-grid-item> + </wd-grid> + </wd-card> + </view> + + <view class="w-full h-[100rpx]"></view> </view> - </view> + </z-paging> </template> <script lang="ts" setup> -import { TestEnum } from '@/typings' -import PLATFORM from '@/utils/platform' +import { getAllMenusApi } from '@/service/menu' +import { useUserStore } from '@/store' +import { tabbarStore } from '@/components/fg-tabbar/tabbar' +import { getEquList } from '@/service/equ' +import { getRepairResList, getRepairResUnfinished } from "@/service/repair"; +import { getFixtureList } from '@/service/fixture' +import { receiveOrderRepair } from '@/service/mobile' +import { useToast, useMessage } from 'wot-design-uni' +import { ref } from 'vue' +import {isLeader} from "@/utils/RoleUtils"; +const message = useMessage() +const toast = useToast() defineOptions({ name: 'Home', }) +const userStore = useUserStore() + +const equTotal = ref(0) +const faultTotal = ref(0) +const fixtureTotal = ref(0) + +const paging = ref(null) +const dataList = ref([]) + // 鑾峰彇灞忓箷杈圭晫鍒板畨鍏ㄥ尯鍩熻窛绂� const { safeAreaInsets } = uni.getSystemInfoSync() -const author = ref('鑿查附') -const description = ref( - 'unibest 鏄竴涓泦鎴愪簡澶氱宸ュ叿鍜屾妧鏈殑 uniapp 寮�鍙戞ā鏉匡紝鐢� uniapp + Vue3 + Ts + Vite4 + UnoCss + UniUI + VSCode 鏋勫缓锛屾ā鏉垮叿鏈変唬鐮佹彁绀恒�佽嚜鍔ㄦ牸寮忓寲銆佺粺涓�閰嶇疆銆佷唬鐮佺墖娈电瓑鍔熻兘锛屽苟鍐呯疆浜嗚澶氬父鐢ㄧ殑鍩烘湰缁勪欢鍜屽熀鏈姛鑳斤紝璁╀綘缂栧啓 uniapp 鎷ユ湁 best 浣撻獙銆�', -) -// 娴嬭瘯 uni API 鑷姩寮曞叆 + +const getAllMenus = async () => { + const menuList = await getAllMenusApi() +} +function handleInfo() { + uni.showToast({ + title: '鍔熻兘寮�鍙戜腑', + icon: 'none', + }) +} + +const queryList = (pageNum?: number, pageSize?: number) => { + getEquList({ pageNum, pageSize }) + .then((res: any) => { + equTotal.value = res?.total || 0 + // queryRepairResList() + queryUnFinishedRepairResList() + queryFixtureList() + paging.value.complete(true) + }) + .catch((res) => { + paging.value.complete(true) + }) +} + +const goItemPage = (item: any) => { + if (!item?.custom) { + const url = `/${item.path}` + uni.navigateTo({ + url, + }) + } else { + switch (item.name) { + case '鎺ュ崟缁翠慨': + if (isLeader()) { + toast.info('璇风櫥褰曠淮淇伐璐﹀彿鎺ュ崟') + } else { + handleSelectReq() + } + break + } + } +} + onLoad(() => { - console.log(author) - console.log(TestEnum.A) + // getAllMenus() + queryEquList() + queryUnFinishedRepairResList() + queryFixtureList() }) -const menuList = reactive([ +const commonMenu = reactive([ { id: 1, - name: '娴嬭瘯', - url: '/static/menu/menu1.png', + name: '鏁呴殰鎶ヤ慨', + icon: '/static/ico/ico7.png', + path: 'pages/repair/repair-add', }, { id: 2, - name: '娴嬭瘯', - url: '/static/menu/menu1.png', + custom: true, + name: '鎺ュ崟缁翠慨', + icon: '/static/ico/ico8.png', + path: 'pages/repair/repair-add', + }, +]) + +const equMenu = reactive([ + { + id: 1, + name: '璁惧鍒楄〃', + icon: '/static/ico/ico15.png', + path: 'pages/equ/equ-list', + }, + { + id: 2, + name: '宸ュ叿鍒楄〃', + icon: '/static/ico/ico16.png', + path: 'pages/fixture/fixture-list', + }, +]) + +const inspectMenu = reactive([ + /* { + id: 0, + name: '璁惧鐐规', + icon: '/static/menu/menu0.png', + path: 'pages/inspect/insp-add', + }, */ + { + id: 1, + name: '鐐规姹囨��', + icon: '/static/ico/ico17.png', + path: 'pages/inspect/insp-st', + }, + { + id: 2, + name: '淇濆吇姹囨��', + icon: '/static/ico/ico11.png', + path: 'pages/maint/maint-st', + }, + { + id: 3, + name: '鎶ヤ慨鍒楄〃', + icon: '/static/ico/ico18.png', + path: 'pages/repair/req-list', + }, + { + id: 4, + name: '缁翠慨鍒楄〃', + icon: '/static/ico/ico19.png', + path: 'pages/repair/res-list', }, ]) function handleUserInfo() { - console.error('12121') + goToMy() } +function goToMy() { + tabbarStore.setCurIdx(4) + uni.switchTab({ + url: '/pages/my/index', + }) +} +const realName = computed(() => userStore?.userInfo?.realName) + +/** + * 閫夋嫨鎶ヤ慨鍗� + */ +function handleSelectReq() { + uni.navigateTo({ + url: '/pages/repair/req-list', + events: { + // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹� + selectReq: function (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, + } + receiveOrderRepair(resData) + .then((res: any) => { + if (res?.id) { + toast.success(res?.msg || '鎿嶄綔鎴愬姛') + uni.navigateTo({ + url: `/pages/repair/res-detail?id=${res?.id}`, + }) + } else { + toast.error(res?.msg || '鐢熸垚缁翠慨宸ュ崟澶辫触锛岃閲嶈瘯') + } + }) + .catch((res) => { + toast.error(res?.msg || '鐢熸垚缁翠慨宸ュ崟澶辫触锛岃閲嶈瘯') + }) + }, + }, + success: function (res) { + // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹� + res.eventChannel.emit('OnSelectReq', { data: '缁翠慨鍗曢〉闈㈤�夋嫨鎶ヤ慨鍗�' }) + }, + }) +} + +function queryEquList() { + getEquList({ + page: 1, + size: 10, + }) + .then((res: any) => { + equTotal.value = res?.total || 0 + }) + .catch((err) => { + console.log(err) + }) +} + +function queryRepairResList() { + getRepairResList({ + page: 1, + size: 10, + status: '2', + }) + .then((res: any) => { + faultTotal.value = res?.total || 0 + }) + .catch((res) => {}) +} + +function queryUnFinishedRepairResList() { + getRepairResUnfinished('0,1,2') + .then((res: any) => { + console.log("res", res) + faultTotal.value = res || 0 + }) + .catch((res) => {}) +} + +function queryFixtureList() { + getFixtureList({ + page: 1, + size: 10, + }) + .then((res: any) => { + fixtureTotal.value = res?.total || 0 + }) + .catch((res) => {}) +} + +function goToDetail(item) { + uni.navigateTo({ + url: `/pages/repair/res-detail?id=${item.id}`, + }) +} </script> <style lang="scss" scoped> @@ -202,6 +442,9 @@ .slot-img { width: 72rpx; height: 72rpx; - border-radius: 8rpx; + margin-left: 4rpx; +} +:deep(.wd-grid-item__content) { + align-items: center; } </style> -- Gitblit v1.9.3