| | |
| | | <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> |
| | |
| | | </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"> |
| | |
| | | </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> |
| | |
| | | <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> |
| | |
| | | </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" |
| | |
| | | |
| | | <!--管理员角色--> |
| | | <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> |
| | | |
| | |
| | | </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 |
| | |
| | | equName: '', |
| | | assetNo: '', |
| | | planTime: '', |
| | | createTime: '', |
| | | orderCount: null, |
| | | wcCount: null, |
| | | dbyCount: null, |
| | |
| | | pageSize, |
| | | maintCode: maintCode.value, |
| | | } |
| | | |
| | | getMaintStOrderList(params) |
| | | .then((res: any) => { |
| | | // 请勿在网络请求回调中给dataList赋值!!只需要调用complete就可以了 |
| | |
| | | // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理 |
| | | // 在底层的网络请求抛出异常时,写uni.$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 || '请求失败') |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 开始保养 |
| | | * @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) |
| | | }, |
| | | }) |
| | |
| | | * @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 |
| | |
| | | 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> |
| | | |