From f0610c371668b042d36d7772cb04b49a2afc69ea Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期四, 24 四月 2025 14:51:56 +0800 Subject: [PATCH] 完成移动端保养 --- eims-ui-mobile/src/pages/maint/maint-order.vue | 214 +++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 166 insertions(+), 48 deletions(-) diff --git a/eims-ui-mobile/src/pages/maint/maint-order.vue b/eims-ui-mobile/src/pages/maint/maint-order.vue index bcfcb64..d4fd359 100644 --- a/eims-ui-mobile/src/pages/maint/maint-order.vue +++ b/eims-ui-mobile/src/pages/maint/maint-order.vue @@ -1,26 +1,38 @@ <route lang="json5" type="page"> { + layout: 'default', needLogin: true, style: { navigationBarTitleText: '淇濆吇宸ュ崟', - navigationStyle: 'custom', - navigationBarBackgroundColor: '#4D80F0', + 'app-plus': { + titleNView: { + buttons: [ + { + text: '鎻愪氦', + fontSize: '14px', + color: '#FFFFFF', + }, + { + text: '', + fontSize: '24px', + color: '#FFFFFF', + }, + ], + }, + }, }, } </route> <template> - <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time> + <z-paging + ref="paging" + v-model="dataList" + @query="queryList" + :auto="false" + show-refresher-update-time + > <template #top> - <wd-navbar - title="淇濆吇宸ュ崟" - left-arrow - @click-left="goBack" - right-text="鎻愪氦" - @click-right="handleClickRight" - custom-style="background: #4D80F0;" - safeAreaInsetTop - ></wd-navbar> <wd-cell> <template #title> <text class="text-color-gray">璁惧</text> @@ -41,7 +53,7 @@ </view> </view> </template> - <view class="flex h-[100rpx]" items-center> + <view class="flex h-[140rpx]" items-center> <image class="slot-img text-center" src="/static/images/camera.png" /> <view class="flex-1"> <view class="text-color-gray text-xs mt-1 flex"> @@ -58,7 +70,7 @@ </view> <view class="text-color-gray text-xs mt-2 flex"> <text>鐘舵�侊細</text> - <template v-if="maintSt.orderCount === maintSt.wcCount"> + <template v-if="maintSt.status === '1'"> <wd-icon class="icon-color-success" name="check-outline" size="34rpx"></wd-icon> <text class="ml-1">宸插畬鎴�</text> </template> @@ -66,6 +78,10 @@ <wd-icon class="icon-color-base" name="detection" size="40rpx"></wd-icon> <text class="ml-1">杩涜涓�</text> </template> + </view> + + <view class="text-color-gray text-xs mt-2 flex"> + 鍒涘缓鏃堕棿: {{ maintSt.createTime }} </view> </view> </view> @@ -129,14 +145,24 @@ </view> <!--鎿嶄綔宸ユ垨缁翠慨宸ヨ鑹�--> <template v-if="isOperatorOrRepair()"> - <wd-button - v-if="item.status === '0'" - size="small" - icon="edit-outline" - @click.stop="handleStartMaint(item)" - > - 寮�濮嬩繚鍏� - </wd-button> + <view class="flex flex-col justify-between" v-if="item.status === '0'"> + <wd-button + size="small" + icon="edit-outline" + @click.stop="handleStartMaint(item)" + > + 寮�濮嬩繚鍏� + </wd-button> + + <wd-button + class="mt-3" + size="small" + icon="edit-outline" + @click.stop="handleMaintFinish(item)" + > + 涓�閿繚鍏� + </wd-button> + </view> <wd-button v-if="item.status === '1'" size="small" @@ -167,20 +193,10 @@ <!--绠$悊鍛樿鑹�--> <template v-else-if="isLeader()"> - <wd-button - v-if="item.status === '0'" - size="small" - icon="warn-bold" - disabled - > + <wd-button v-if="item.status === '0'" size="small" icon="warn-bold" disabled> 寰呬繚鍏� </wd-button> - <wd-button - v-if="item.status === '1'" - size="small" - icon="warn-bold" - disabled - > + <wd-button v-if="item.status === '1'" size="small" icon="warn-bold" disabled> 淇濆吇涓� </wd-button> @@ -226,14 +242,17 @@ </template> <script setup lang="ts"> import type { MaintStVO } from '@/service/maint.d' -import { getMaintSt, getMaintStOrderList, updateMaintOrder } from '@/service/maint' +import { getMaintSt, getMaintStOrderList, updateMaintOrder, updateMaintSt } from '@/service/maint' import { ref, reactive } from 'vue' import { useToast, useMessage } from 'wot-design-uni' import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils' +import { formatDate } from '@/utils/DateUtils' const message = useMessage() +const toast = useToast() const paging = ref(null) const dataList = ref([]) +const maintStId = ref('') interface QueryParams { pageNum: number @@ -247,6 +266,7 @@ equName: '', assetNo: '', planTime: '', + createTime: '', orderCount: null, wcCount: null, dbyCount: null, @@ -260,7 +280,6 @@ pageSize, maintCode: maintCode.value, } - getMaintStOrderList(params) .then((res: any) => { // 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡 @@ -271,6 +290,17 @@ // 娉ㄦ剰锛屾瘡娆¢兘闇�瑕佸湪catch涓啓杩欏彞璇濆緢楹荤儲锛寊-paging鎻愪緵浜嗘柟妗堝彲浠ュ叏灞�缁熶竴澶勭悊 // 鍦ㄥ簳灞傜殑缃戠粶璇锋眰鎶涘嚭寮傚父鏃讹紝鍐檜ni.$emit('z-paging-error-emit');鍗冲彲 paging.value.complete(false) + }) +} +function initMaintSt(id: any) { + getMaintSt(id) + .then((res: any) => { + Object.assign(maintSt, res) + paging.value.reload() + }) + .catch((res) => { + console.error(res) + toast.error(res?.data?.msg || '璇锋眰澶辫触') }) } @@ -284,15 +314,44 @@ }) } +/** + * 寮�濮嬩繚鍏� + * @param item + */ function handleStartMaint(item) { + // 纭寮�濮嬩慨鏀圭姸鎬佷负1-淇濆吇涓� + const data = Object.assign({}, item) + data.status = '1' message .confirm({ msg: '纭畾寮�濮嬩繚鍏伙紵', title: '鎻愮ず', beforeConfirm: ({ resolve }) => { - // 纭寮�濮嬩慨鏀圭姸鎬佷负1-淇濆吇涓� - const data = Object.assign({}, item) - data.status = '1' + updateOrder(data, resolve) + }, + }) + .then(() => {}) + .catch((error) => { + console.log(error) + }) +} + + +/** + * 涓�閿繚鍏� + * @param item + */ +function handleMaintFinish(item) { + // 涓�閿繚鍏� + const data = Object.assign({}, item) + data.status = '2' + data.startTime = formatDate(new Date()) + data.endTime = formatDate(new Date()) + message + .confirm({ + msg: '纭畾浣跨敤涓�閿繚鍏伙紵', + title: '鎻愮ず', + beforeConfirm: ({ resolve }) => { updateOrder(data, resolve) }, }) @@ -308,25 +367,85 @@ * @param resolve */ function updateOrder(data: any, resolve: any) { + updateMaintOrder(data) .then((res: any) => { resolve(true) if (res?.code === 200) { reloadData() + // 淇濆吇鐘舵�佹墠闇�瑕佽烦杞� + if(data?.status === '1'){ + goToOrderDetail(data) + } } }) .catch((res) => { console.error(res) }) } -function reloadData() { - paging.value.reload() -} -const goBack = () => { - uni.navigateBack() + +function handleUpdateMaintSt() { + if (maintSt.orderCount !== maintSt.wcCount) { + toast.info('璇峰厛瀹屾垚鎵�鏈変繚鍏婚」锛�') + return false + } + + const data: any = Object.assign( + {}, + { + id: maintSt.id, + orderCount: maintSt.orderCount, + wcCount: maintSt.wcCount, + status: maintSt.status, + specialNote: maintSt.specialNote, + }, + ) + if (data.orderCount === data.wcCount) { + data.status = '1' + } + message + .confirm({ + msg: '纭畾鏇存柊宸ュ崟姹囨�绘暟鎹紵', + title: '鎻愮ず', + beforeConfirm: ({ resolve }) => { + updateMaintSt(data) + .then((res: any) => { + resolve(true) + if (res?.code === 200) { + reloadData() + toastSucces() + } + }) + .catch((res) => { + console.error(res) + }) + }, + }) + .then(() => {}) + .catch((error) => { + console.log(error) + }) } -function handleClickRight() {} +function toastSucces() { + toast.success('鎿嶄綔鎴愬姛') +} + +function reloadData() { + initMaintSt(maintStId.value) +} +onNavigationBarButtonTap((e) => { + if (e.index === 0) { + handleUpdateMaintSt() + } +}) + +onLoad(() => { + uni.$on('maint-order-refresh', reloadData) +}) +onUnload(() => { + uni.$off('maint-order-refresh', reloadData) +}) /** * 鏌ヨ淇濆吇鏄庣粏闇�瑕佺殑code @@ -334,9 +453,8 @@ const maintCode = computed(() => `${maintSt.equId}_${maintSt.planTime}`) onLoad((options) => { - const itemString = decodeURIComponent(options.maintSt) - const item = JSON.parse(itemString) - Object.assign(maintSt, item) + maintStId.value = options.id + reloadData() }) </script> -- Gitblit v1.9.3