From d28bb7d7acdc4d27a553e5b6b2458d5e7ec43165 Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期二, 29 四月 2025 14:40:44 +0800 Subject: [PATCH] 完成设备维修工单 --- eims-ui-mobile/src/pages/repair/res-list.vue | 157 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 147 insertions(+), 10 deletions(-) diff --git a/eims-ui-mobile/src/pages/repair/res-list.vue b/eims-ui-mobile/src/pages/repair/res-list.vue index 2f3951c..096aedd 100644 --- a/eims-ui-mobile/src/pages/repair/res-list.vue +++ b/eims-ui-mobile/src/pages/repair/res-list.vue @@ -61,7 +61,7 @@ </view> </view> </template> - <view class="flex h-[240rpx] items-center" @click.stop="itemClick(item)"> + <view class="flex h-[240rpx] items-center"> <image v-if="item.reqType === '1'" class="slot-img text-center" @@ -102,10 +102,10 @@ </view> <view class="text-color-gray mt-1 text-mini"> - <text>寮�濮嬫椂闂�: {{ item.startTime }}</text> + <text>缁翠慨寮�濮�: {{ item.startTime }}</text> </view> <view class="text-color-gray mt-1 text-mini"> - <text>瀹屾垚鏃堕棿: {{ item.endTime }}</text> + <text>缁翠慨缁撴潫: {{ item.endTime }}</text> </view> <view class="text-color-gray mt-1 text-mini"> <text>缁翠慨浜�: {{ item.resUserName }}</text> @@ -113,9 +113,75 @@ </view> </view> <view> - <wd-button v-if="item.status === '1'" size="small" icon="edit-outline">寮�濮嬬淮淇�</wd-button> - <wd-button v-if="item.status === '2'" size="small" icon="edit-outline">缁翠慨涓�</wd-button> - <wd-button v-if="item.status === '3'" size="small" icon="edit-outline">宸插畬鎴�</wd-button> + <!--鎿嶄綔宸ユ垨缁翠慨宸ヨ鑹�--> + <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)" + v-if="item.fbId === null" + > + 鍐欒瘎浠� + </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)" + v-if="item.fbId === null" + > + 鍐欒瘎浠� + </wd-button> + </view> + </template> </view> </view> </wd-card> @@ -126,9 +192,11 @@ <script setup lang="ts"> import { onMounted, getCurrentInstance, ref } from 'vue' import { useToast, useMessage } from 'wot-design-uni' -import { getRepairResList, addRepairRes } from '@/service/repair' +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 { useUserStore } from '@/store' +import { formatDate } from '@/utils/DateUtils' const userStore = useUserStore() const message = useMessage() @@ -181,11 +249,76 @@ * 鏉$洰鐐瑰嚮浜嬩欢 * @param item */ -function itemClick(item: any) {} +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/feedback?id=${item.id}`, + }) +} onNavigationBarButtonTap((e) => { if (e.index === 0) { - handleSelectReq() + if (isLeader()) { + toast.info('璇风櫥褰曠淮淇伐璐﹀彿鎺ュ崟') + } else if (isOperatorOrRepair()) { + handleSelectReq() + } } }) @@ -240,8 +373,12 @@ const sList: any = await getDictInfo(DICT_REPAIR_RES_STATUS) statusList.value.push(...sList) } -onLoad((options) => { +onLoad(() => { initData() + uni.$on('res-list-refresh', reloadData) +}) +onUnload(() => { + uni.$off('res-list-refresh', reloadData) }) </script> -- Gitblit v1.9.3