<route lang="json5" type="page">
|
{
|
layout: 'default',
|
needLogin: true,
|
style: {
|
navigationBarTitleText: '维修明细',
|
'app-plus': {
|
titleNView: {
|
buttons: [
|
{
|
text: '提交',
|
fontSize: '14px',
|
color: '#FFFFFF',
|
},
|
{
|
text: '保存',
|
fontSize: '14px',
|
color: '#FFFFFF',
|
},
|
],
|
},
|
},
|
},
|
}
|
</route>
|
<template>
|
<view class="bg-base container" safeAreaInsetTopBottom>
|
<wd-form ref="form" :model="repairRes" :rules="rules">
|
<wd-cell-group custom-class="group" title="报修信息" border>
|
<wd-cell title="故障类型" title-width="200rpx" is-link>
|
<text>{{ reqType?.dictLabel }}</text>
|
</wd-cell>
|
|
<wd-textarea
|
label="报修描述"
|
label-width="200rpx"
|
type="textarea"
|
v-model="repairRes.reqDesc"
|
auto-height
|
readonly
|
/>
|
</wd-cell-group>
|
|
<wd-cell-group
|
v-if="repairRes?.reqType === '1'"
|
custom-class="mt-2"
|
title="设备信息"
|
use-slot
|
border
|
>
|
<wd-cell title="设备名称" title-width="200rpx" is-link>
|
<text>{{ repairRes?.equName }}</text>
|
</wd-cell>
|
<wd-cell title="资产编号" title-width="200rpx" is-link>
|
<text>{{ repairRes?.assetNo }}</text>
|
</wd-cell>
|
</wd-cell-group>
|
|
<wd-cell-group
|
v-if="repairRes?.reqType === '2'"
|
custom-class="mt-2"
|
title="工具信息"
|
use-slot
|
border
|
>
|
<wd-cell title="工具名称" title-width="200rpx" is-link>
|
<text>{{ repairRes?.fixtureName }}</text>
|
</wd-cell>
|
<wd-cell title="资产编号" title-width="200rpx" is-link>
|
<text>{{ repairRes?.assetNo }}</text>
|
</wd-cell>
|
</wd-cell-group>
|
|
<wd-cell-group custom-class="mt-2" title="维修信息" use-slot border>
|
<wd-cell title="故障类别" title-width="200rpx" prop="faultType">
|
<wd-radio-group v-model="repairRes.faultType" inline shape="dot"> >
|
<wd-radio v-for="item in faultList" :value="item.dictValue">{{item.dictLabel}}</wd-radio>
|
</wd-radio-group>
|
</wd-cell>
|
<wd-textarea
|
label="原因分析"
|
label-width="200rpx"
|
type="textarea"
|
v-model="repairRes.resReason"
|
auto-height
|
:maxlength="200"
|
show-word-limit
|
placeholder="请输入原因分析"
|
clearable
|
/>
|
|
<wd-textarea
|
label="处理措施"
|
label-width="200rpx"
|
type="textarea"
|
v-model="repairRes.resHandle"
|
auto-height
|
:maxlength="200"
|
show-word-limit
|
placeholder="请输入处理措施"
|
clearable
|
/>
|
|
<wd-textarea
|
label="预防措施"
|
label-width="200rpx"
|
type="textarea"
|
v-model="repairRes.resPrevent"
|
auto-height
|
:maxlength="200"
|
show-word-limit
|
placeholder="请输入预防措施"
|
clearable
|
/>
|
|
<wd-textarea
|
label="备注"
|
label-width="200rpx"
|
type="textarea"
|
v-model="repairRes.remark"
|
auto-height
|
:maxlength="200"
|
show-word-limit
|
placeholder="请输入备注"
|
clearable
|
/>
|
</wd-cell-group>
|
<wd-cell-group custom-class="mt-2" title="备件信息" use-slot border>
|
<!-- 备件信息录入区域 -->
|
<view v-if="repairRes.spareParts && repairRes.spareParts.length > 0" class="mt-2">
|
<view
|
v-for="(part, partIndex) in repairRes.spareParts"
|
:key="partIndex"
|
class="flex justify-between mt-1"
|
>
|
<wd-input
|
v-model="part.name"
|
label="名称:"
|
label-width="100rpx"
|
placeholder="备件名称"
|
|
|
/>
|
<wd-input
|
v-model="part.quantity"
|
label="数量:"
|
label-width="100rpx"
|
placeholder="数量" type="number" :maxlength="5" />
|
</view>
|
</view>
|
<!-- 维修说明区域 -->
|
<view class="mt-2 flex justify-end">
|
<wd-button type="info" style="margin: 20px" @click.stop="addSparePart()">
|
添加备件
|
</wd-button>
|
</view>
|
<view class="h-[2px] w-full bg-base"></view>
|
</wd-cell-group>
|
</wd-form>
|
<view class="h-[5px] w-full bg-base"></view>
|
<view class=" flex justify-around py-4">
|
<wd-button block @click="saveOrder">保存</wd-button>
|
<wd-button type="success" block @click="submitOrder">提交</wd-button>
|
</view>
|
</view>
|
|
<!-- 备件选择弹出层 -->
|
<wd-popup v-model="showSparePopup" position="bottom" height="33.33vh">
|
<view class="flex justify-between p-2 bg-white">
|
<wd-button type="text" @click="closeSparePopup">取消</wd-button>
|
<wd-button type="text" @click="addOtherSparePart">其他</wd-button>
|
|
</view>
|
<wd-input
|
v-model="searchKeyword"
|
placeholder="请输入备件名称或型号"
|
clearable
|
@input="filterSpareParts"
|
/>
|
<view class="p-2">
|
<view
|
v-for="(part, index) in sparePartsList"
|
:key="index"
|
class="flex justify-between items-center p-2 border-b"
|
@click="selectFilteredSparePart(part)"
|
>
|
<text>{{ part.name }} ({{ part.code }})</text>
|
<text>剩余: {{ part.actualStock }}</text>
|
</view>
|
</view>
|
</wd-popup>
|
</template>
|
|
<script setup lang="ts">
|
import { getRepairRes, updateRepairRes } from '@/service/repair'
|
import { RepairResVO } from '@/service/repair.d'
|
import { FormRules } from 'wot-design-uni/components/wd-form/types'
|
import { useToast, useMessage } from 'wot-design-uni'
|
import { isEquAdmin, isLeader, isLineOrRepair, isRepair } from "@/utils/RoleUtils";
|
import { DICT_REPAIR_FAULT_TYPE, DICT_REPAIR_REQ_TYPE, getDictInfo } from "@/service/dict";
|
import { formatDate } from '@/utils/DateUtils'
|
const toast = useToast()
|
const message = useMessage()
|
const showSparePopup = ref(false)
|
import { getSpareList } from '@/service/spare'
|
import { ref } from "vue";
|
const fileList = ref<[]>()
|
const selectedPartIndex = ref(-1)
|
const sparePartsList = ref([])
|
const searchKeyword = ref('')
|
// 报修单类型
|
const reqTypeList = ref<any>([])
|
// 故障类别
|
const faultList = ref<any>([])
|
const repairRes = reactive<RepairResVO>({
|
id: '',
|
resCode: '',
|
reqType: '',
|
reqDesc: '',
|
equName: '',
|
assetNo: '',
|
fixtureName: '',
|
resReason: '',
|
status: '',
|
resHandle: '',
|
resPrevent: '',
|
remark: '',
|
})
|
|
const rules: FormRules = {
|
startTime: [
|
{
|
required: true,
|
message: '请选择保养开始时间',
|
},
|
],
|
}
|
|
function filterSpareParts() {
|
if (!searchKeyword.value) {
|
loadSpareParts()
|
} else {
|
loadSpareParts(searchKeyword.value)
|
}
|
}
|
// 备件选择相关逻辑
|
function addSparePart() {
|
// if (!item.spareParts) {
|
// item.spareParts = []
|
// }
|
repairRes.spareParts.value = []
|
|
selectSparePart()
|
}
|
|
function selectSparePart(item: any) {
|
showSparePopup.value = true
|
|
loadSpareParts()
|
}
|
|
function loadSpareParts(value?: string) {
|
getSpareList({ name: value, pageNum: 1, pageSize: 10 }).then((res: any) => {
|
sparePartsList.value = res.rows
|
|
})
|
}
|
|
function selectFilteredSparePart(part: any) {
|
repairRes.spareParts.value.push({
|
id: part.id,
|
name: part.name,
|
quantity: '',
|
})
|
closeSparePopup()
|
}
|
function addOtherSparePart() {
|
repairRes.spareParts.value.push({
|
id: '',
|
name: '',
|
quantity: '',
|
})
|
closeSparePopup();
|
}
|
|
function closeSparePopup() {
|
showSparePopup.value = false
|
selectedPartIndex.value = -1
|
searchKeyword.value = ''
|
}
|
|
function handleFileChange({ fileList }) {}
|
|
function initRepairRes(id: any) {
|
getRepairRes(id)
|
.then((res: any) => {
|
Object.assign(repairRes, res)
|
})
|
.catch((res) => {})
|
}
|
|
async function initData(options: any) {
|
initRepairRes(options.id)
|
const reqList = await getDictInfo(DICT_REPAIR_REQ_TYPE)
|
reqTypeList.value = reqList
|
const fList = await getDictInfo(DICT_REPAIR_FAULT_TYPE)
|
faultList.value = fList
|
}
|
|
function hanldeUpdateRepairRes(data: any, resolve: any) {
|
updateRepairRes(data)
|
.then((res: any) => {
|
resolve(true)
|
toastSucces()
|
uni.$emit('list-refresh')
|
uni.navigateBack()
|
})
|
.catch((res) => {
|
console.error(res)
|
})
|
}
|
function toastSucces() {
|
toast.success('操作成功')
|
}
|
|
function handleClickRight(data: any) {
|
message
|
.confirm({
|
msg: '确定' + (data.status === '3' ? '提交' : '保存') + '?',
|
title: '提示',
|
beforeConfirm: ({ resolve }) => {
|
hanldeUpdateRepairRes(data, resolve)
|
},
|
})
|
.then(() => {})
|
.catch((error) => {
|
console.log(error)
|
})
|
}
|
|
function submitOrder() {
|
const data = Object.assign({}, repairRes)
|
// 提交修改状态为完成
|
data.status = '3'
|
// 设置维修完成时间
|
data.endTime = formatDate(new Date())
|
handleClickRight(data)
|
}
|
|
function saveOrder() {
|
const data = Object.assign({}, repairRes)
|
// 仅保存不修改状态为完成
|
data.status = '2'
|
// 仅保存不设置完成时间
|
data.endTime = ''
|
handleClickRight(data)
|
}
|
|
onNavigationBarButtonTap((e) => {
|
if (e.index === 0) {
|
// 管理员角色
|
if (isRepair() || isEquAdmin()) {
|
switch (repairRes.status) {
|
// 已接单
|
case '1':
|
break
|
// 维修中
|
case '2':
|
{
|
const data = Object.assign({}, repairRes)
|
// 提交修改状态为完成
|
data.status = '3'
|
// 设置维修完成时间
|
data.endTime = formatDate(new Date())
|
handleClickRight(data)
|
}
|
break
|
// 已完成
|
case '3':
|
toast.warning('当前维修工单完成状态,不可操作')
|
break
|
}
|
}
|
} else if (e.index === 1) {
|
if (isRepair() || isEquAdmin()) {
|
switch (repairRes.status) {
|
// 已接单
|
case '1':
|
break
|
// 维修中
|
case '2':
|
{
|
const data = Object.assign({}, repairRes)
|
data.status = '2'
|
// 仅保存不修改状态
|
handleClickRight(data)
|
}
|
break
|
// 已完成
|
case '3':
|
toast.warning('当前维修工单完成状态,不可操作')
|
break
|
}
|
}
|
}
|
})
|
|
const reqType = computed(() =>
|
reqTypeList.value.find((item) => item.dictValue === repairRes.reqType),
|
)
|
|
onMounted(() => {})
|
onLoad((options) => {
|
initData(options)
|
})
|
</script>
|
|
<style scoped lang="scss">
|
.container {
|
}
|
</style>
|