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/equ/equ-list.vue | 131 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 105 insertions(+), 26 deletions(-) diff --git a/eims-ui-mobile/src/pages/equ/equ-list.vue b/eims-ui-mobile/src/pages/equ/equ-list.vue index 4a72014..920c368 100644 --- a/eims-ui-mobile/src/pages/equ/equ-list.vue +++ b/eims-ui-mobile/src/pages/equ/equ-list.vue @@ -1,17 +1,36 @@ <route lang="json5" type="page"> { layout: 'default', - style: { - navigationBarTitleText: '璁惧鍒楄〃', - }, + needLogin: true, + style: { navigationBarTitleText: '璁惧鍒楄〃', navigationStyle: 'custom' }, } </route> <template> - <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time> + <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time> <template #top> + <wd-navbar + title="璁惧鍒楄〃" + left-arrow + @click-left="goBack" + custom-style="background: #4D80F0;" + safeAreaInsetTop + ></wd-navbar> + <wd-search v-model="searchValue" placeholder="璇疯緭鍏ュ叧閿瓧" @search="handleSearch" /> <wd-drop-menu> - <wd-drop-menu-item v-model="equTypeId" :options="typeList" @change="handleEquType" /> - <wd-drop-menu-item v-model="status" :options="statusList" @change="handleEquStatu" /> + <wd-drop-menu-item + v-model="equTypeId" + label-key="dictLabel" + value-key="dictValue" + :options="typeList" + @change="handleEquType" + /> + <wd-drop-menu-item + v-model="status" + label-key="dictLabel" + value-key="dictValue" + :options="statusList" + @change="handleEquStatu" + /> </wd-drop-menu> </template> @@ -21,25 +40,36 @@ <view class="flex justify-between items-baseline"> <view class="flex items-center menu-title-box"> <view class="menu-indicator"></view> - <text class="ml-1 text-xs">{{ item.assetNo }}</text> + <text class="ml-1 text-sm">{{ item.assetNo }}</text> + <wd-tag v-if="item.status === '0'" class="ml-2" bg-color="cyan">璇曠敤</wd-tag> + <wd-tag v-else-if="item.status === '1'" class="ml-2" type="success">浣跨敤</wd-tag> + <wd-tag v-else-if="item.status === '2'" class="ml-2" type="danger">鍋滅敤</wd-tag> + <wd-tag v-else-if="item.status === '3'" class="ml-2" bg-color="pink">鎶ュ簾</wd-tag> + <wd-tag v-else-if="item.status === '4'" class="ml-2" type="warning">闂茬疆</wd-tag> + <wd-tag v-else-if="item.status === '5'" class="ml-2">鏂板</wd-tag> </view> - <view> + <view @click.stop="handleInfo"> <text class="icon-color-base">璇︽儏</text> <wd-icon name="arrow-right" custom-class="icon-color-base"></wd-icon> </view> </view> </template> - <view class="flex h-[80rpx]" @click.stop="itemClick(item)"> + <view class="flex h-[90rpx] items-center" @click.stop="itemClick(item)"> <image class="slot-img text-center" src="/static/images/camera.png" /> - <view> + <view class="flex-1"> <view class="text-color-base"> {{ item.equName }} <text class="text-color-gray ml-2 text-mini">{{ item.modelNo }}</text> </view> - <view class="text-color-gray text-xs mt-1"> + <view class="text-color-gray text-sm mt-1"> {{ item.location }} | {{ item.madeIn }} </view> + </view> + <view v-if="isSelectEqu"> + <wd-button size="small" icon="edit-outline" @click.stop="handleSelectEqu(item)"> + 閫変腑 + </wd-button> </view> </view> </wd-card> @@ -49,22 +79,24 @@ <script setup lang="ts"> import { onMounted, getCurrentInstance, ref } from 'vue' - import { getEquList } from '@/service/equ' +import { DICT_SYS_EQU_STATUS, getDictInfo } from '@/service/dict' // 璁惧绫诲瀷 -const equTypeId = ref<number>(0) +const equTypeId = ref<number>(-1) // 璁惧鐘舵�� -const status = ref<number>(0) - +const status = ref<number>(-1) +const searchValue = ref<string>('') const isSelectEqu = ref(false) -const typeList = ref<Record<string, any>[]>([{ label: '鎵�鏈夎澶�', value: 0 }]) -const statusList = ref<Record<string, any>[]>([{ label: '鎵�鏈夌姸鎬�', value: 0 }]) +const typeList = ref<Record<string, any>[]>([{ dictLabel: '璁惧绫诲瀷', dictValue: -1 }]) +const statusList = ref<Record<string, any>[]>([{ dictLabel: '鎵�鏈夌姸鎬�', dictValue: -1 }]) function handleEquType({ value }) { + reloadData() console.log(value) } function handleEquStatu({ value }) { + reloadData() console.log(value) } @@ -72,13 +104,25 @@ const dataList = ref([]) const queryList = (pageNum?: number, pageSize?: number) => { - // 杩欓噷鐨刾ageNo鍜宲ageSize浼氳嚜鍔ㄨ绠楀ソ锛岀洿鎺ヤ紶缁欐湇鍔″櫒鍗冲彲 - // 杩欓噷鐨勮姹傚彧鏄紨绀猴紝璇锋浛鎹㈡垚鑷繁鐨勯」鐩殑缃戠粶璇锋眰锛屽苟鍦ㄧ綉缁滆姹傚洖璋冧腑閫氳繃paging.value.complete(璇锋眰鍥炴潵鐨勬暟缁�)灏嗚姹傜粨鏋滀紶缁檢-paging - getEquList({ pageNum, pageSize }) + const parmams = { + pageNum, + pageSize, + equTypeId: equTypeId.value, + status: status.value, + params: { + searchValue: searchValue.value, + }, + } + if (equTypeId.value === -1) { + delete parmams.equTypeId + } + if (status.value === -1) { + delete parmams.status + } + getEquList(parmams) .then((res: any) => { // 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡 - console.log(res) - paging.value.complete(res.rows) + paging.value.completeByTotal(res.rows, res.total) }) .catch((res) => { // 濡傛灉璇锋眰澶辫触鍐檖aging.value.complete(false)锛屼細鑷姩灞曠ず閿欒椤甸潰 @@ -88,15 +132,35 @@ }) } +const goBack = () => { + uni.navigateBack() +} + /** * 璁惧鏉$洰鐐瑰嚮浜嬩欢 * @param item */ -function itemClick(item: any) { +function itemClick(item: any) {} +function handleInfo() { + uni.showToast({ + title: '鍔熻兘寮�鍙戜腑', + icon: 'none', + }) +} +/** + * 鍏跺畠椤甸潰閫夋嫨璁惧 + * @param item + */ +function handleSelectEqu(item: any) { if (isSelectEqu.value) { emitSelectEqu(item) uni.navigateBack() } +} + +function handleSearch() { + console.log('handleSearch') + paging.value.reload() } /** @@ -109,16 +173,28 @@ }) } - const eventChannel = ref<any>() onMounted(() => { const instance: any = getCurrentInstance().proxy const event = instance.getOpenerEventChannel() eventChannel.value = event - event.on('handleSelectEqu', function (data) { + event.on('OnSelectEqu', function (data) { isSelectEqu.value = true - console.log('handleSelectEqu', data) + console.log('OnSelectEqu', data) }) +}) + +function reloadData() { + paging.value.reload() +} + +async function initData() { + const sList: any = await getDictInfo(DICT_SYS_EQU_STATUS) + statusList.value.push(...sList) +} + +onLoad(() => { + initData() }) </script> @@ -146,4 +222,7 @@ :deep(.wd-card__footer) { padding: 10rpx !important; } +:deep(.wd-card__title-content) { + padding: 16rpx !important; +} </style> -- Gitblit v1.9.3