<route lang="json5" type="page">
|
{
|
layout: 'default',
|
needLogin: true,
|
style: { navigationBarTitleText: '工单明细', navigationStyle: 'custom' },
|
}
|
</route>
|
<template>
|
<view class="bg-base container" safeAreaInsetTopBottom>
|
<wd-navbar
|
title="保养工单"
|
left-arrow
|
@click-left="goBack"
|
right-text="提交"
|
@click-right="handleClickRight"
|
custom-style="background: #4D80F0;"
|
safeAreaInsetTop
|
>
|
<template #right>
|
<text v-if="isOperatorOrRepair()" class="text-white">提交</text>
|
<text v-else-if="isLeader()" class="text-white">验证</text>
|
</template>
|
</wd-navbar>
|
<wd-form ref="form" :model="order" :rules="rules">
|
<wd-cell-group custom-class="group" title="设备信息" border>
|
<wd-cell title="设备名称" title-width="200rpx" is-link>
|
<text>{{ order?.equName }}</text>
|
</wd-cell>
|
<wd-cell title="资产编号" title-width="200rpx" is-link>
|
<text>{{ order?.assetNo }}</text>
|
</wd-cell>
|
</wd-cell-group>
|
|
<wd-cell-group custom-class="mt-2" title="保养信息" border>
|
<wd-cell title="保养单号" title-width="200rpx" is-link>
|
<text>{{ order?.maintCode }}</text>
|
</wd-cell>
|
<wd-cell title="保养项" title-width="200rpx" is-link>
|
<text>{{ order?.maintName }}</text>
|
</wd-cell>
|
<wd-cell title="计划保养日期" title-width="200rpx" is-link>
|
<text>{{ order?.planTime }}</text>
|
</wd-cell>
|
<wd-cell title="保养开始时间" title-width="200rpx" is-link>
|
<text>{{ order?.startTime }}</text>
|
</wd-cell>
|
<wd-cell title="保养完成时间" title-width="200rpx" is-link>
|
<text>{{ order?.endTime }}</text>
|
</wd-cell>
|
|
<wd-textarea
|
label="工作描述"
|
label-width="200rpx"
|
type="textarea"
|
v-model="order.maintDesc"
|
auto-height
|
:maxlength="200"
|
show-word-limit
|
placeholder="请输入工作描述"
|
clearable
|
/>
|
<wd-cell title="保养图片" title-width="200rpx" prop="fileList">
|
<wd-upload
|
:auto-upload="false"
|
:file-list="fileList"
|
@change="handleFileChange"
|
></wd-upload>
|
</wd-cell>
|
<wd-textarea
|
label="备注"
|
label-width="200rpx"
|
type="textarea"
|
v-model="order.remark"
|
auto-height
|
:maxlength="200"
|
show-word-limit
|
placeholder="请输入备注"
|
clearable
|
/>
|
</wd-cell-group>
|
<view class="h-[2px] w-full bg-base"></view>
|
<!--是否显示管理员验证按钮 (工单状态为2-待验证 且登录人role-leader管理员角色)-->
|
<wd-cell
|
title="验证通过(管理员)"
|
title-width="200px"
|
v-if="order.status === '2' && isLeader()"
|
>
|
<view style="text-align: right">
|
<wd-switch v-model="isVerify" />
|
</view>
|
</wd-cell>
|
|
<!--是否显示操作工保养完成 (工单状态为1-保养中 且登录人role-操作工角色)-->
|
<wd-cell
|
title="保养完成(操作工)"
|
title-width="200px"
|
v-if="order.status === '1' && isOperatorOrRepair()"
|
>
|
<view style="text-align: right">
|
<wd-switch v-model="isFinish" />
|
</view>
|
</wd-cell>
|
</wd-form>
|
<view class="h-[100rpx]"></view>
|
</view>
|
</template>
|
|
<script setup lang="ts">
|
import { getMaintOrder, updateMaintOrder } from '@/service/maint'
|
import { reactive, onMounted } from 'vue'
|
import { FormRules } from 'wot-design-uni/components/wd-form/types'
|
import { useToast, useMessage } from 'wot-design-uni'
|
import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils'
|
const toast = useToast()
|
const message = useMessage()
|
|
const fileList = ref<[]>()
|
|
// 管理员验是否通过
|
const isVerify = ref(false)
|
// 操作工保养是完成
|
const isFinish = ref(false)
|
|
interface MaintOrder {
|
id: string
|
equName: string
|
assetNo: string
|
status: string
|
maintCode: string
|
maintName: string
|
planTime: string
|
startTime: string
|
endTime?: string
|
maintDesc: string
|
remark: string
|
}
|
|
const order = reactive<MaintOrder>({
|
id: '',
|
equName: '',
|
assetNo: '',
|
status: '',
|
maintCode: '',
|
maintName: '',
|
planTime: '',
|
startTime: '',
|
endTime: '',
|
maintDesc: '',
|
remark: '',
|
})
|
|
const rules: FormRules = {
|
startTime: [
|
{
|
required: true,
|
message: '请选择保养开始时间',
|
},
|
],
|
endTime: [
|
{
|
required: true,
|
message: '请选择保养结束时间',
|
},
|
],
|
maintDesc: [
|
{
|
required: true,
|
message: '请输入工作描述',
|
},
|
],
|
}
|
|
function handleFileChange({ fileList }) {}
|
|
function initMaintOrder(id: any) {
|
getMaintOrder(id)
|
.then((res: any) => {
|
Object.assign(order, res)
|
})
|
.catch((res) => {})
|
}
|
|
function updateOrder(data: any, resolve: any) {
|
updateMaintOrder(data)
|
.then((res: any) => {
|
resolve(true)
|
toastSucces()
|
uni.$emit('maint-order-refresh')
|
})
|
.catch((res) => {
|
console.error(res)
|
})
|
}
|
function toastSucces() {
|
toast.success('操作成功')
|
}
|
|
function handleSubmit(data: any) {
|
message
|
.confirm({
|
msg: '确定提交?',
|
title: '提示',
|
beforeConfirm: ({ resolve }) => {
|
updateOrder(data, resolve)
|
},
|
})
|
.then(() => {})
|
.catch((error) => {
|
console.log(error)
|
})
|
}
|
|
const goBack = () => {
|
uni.navigateBack()
|
}
|
function handleClickRight() {
|
// 管理员角色 且待验证状态
|
if (isLeader()) {
|
switch (order.status) {
|
case '0':
|
case '1':
|
toast.warning('当前工单等待操作工保养状态,不可操作')
|
break
|
case '2':
|
// 勾选验证,可提交
|
if (isVerify.value) {
|
// 修改工单状态为已完成
|
const data: any = Object.assign({}, { id: order.id, status: order.status })
|
data.status = '3'
|
handleSubmit(data)
|
} else {
|
toast.warning('请选择是否验证通过')
|
}
|
break
|
case '3':
|
toast.warning('当前工单完成状态,不可操作')
|
break
|
}
|
} else if (isOperatorOrRepair()) {
|
switch (order.status) {
|
case '0':
|
break
|
case '1':
|
{
|
const data = Object.assign({}, order)
|
// 勾选工单完成,改变状态
|
if (isFinish.value) {
|
// 修改工单状态为待验证
|
data.status = '2'
|
}
|
handleSubmit(data)
|
}
|
break
|
case '2':
|
toast.warning('当前工单等待管理验证状态,不可操作')
|
break
|
case '3':
|
toast.warning('当前工单完成状态,不可操作')
|
break
|
}
|
}
|
}
|
|
onMounted(() => {})
|
onLoad((options) => {
|
initMaintOrder(options.id)
|
})
|
</script>
|
|
<style scoped lang="scss">
|
.container {
|
height: 100vh;
|
}
|
</style>
|