<template>
|
<view class="bg-base">
|
<view v-if="exist">
|
<wd-cell>
|
<template #title>
|
<text class="text-color-gray">设备图片</text>
|
</template>
|
</wd-cell>
|
<view class="h-[1px] bg-base"></view>
|
<image class="equ-img" src="/static/images/cgq.png" />
|
|
<wd-cell class="mt-2">
|
<template #title>
|
<text class="text-color-gray">设备信息</text>
|
</template>
|
</wd-cell>
|
<wd-card type="rectangle">
|
<template #title>
|
<view class="flex justify-between items-baseline">
|
<view class="flex items-center menu-title-box">
|
<view class="menu-indicator"></view>
|
<text class="ml-1 text-sm">{{ model.assetNo }}</text>
|
<wd-tag v-if="model.status === '0'" class="ml-2" bg-color="cyan">试用</wd-tag>
|
<wd-tag v-else-if="model.status === '1'" class="ml-2" type="success">使用</wd-tag>
|
<wd-tag v-else-if="model.status === '2'" class="ml-2" type="danger">停用</wd-tag>
|
<wd-tag v-else-if="model.status === '3'" class="ml-2" bg-color="pink">报废</wd-tag>
|
<wd-tag v-else-if="model.status === '4'" class="ml-2" type="warning">闲置</wd-tag>
|
<wd-tag v-else class="ml-2">新增</wd-tag>
|
</view>
|
|
<view @click="handleInfo">
|
<text class="icon-color-base">状态变更</text>
|
<wd-icon name="arrow-right" custom-class="icon-color-base"></wd-icon>
|
</view>
|
</view>
|
</template>
|
<view class="flex h-[90rpx] items-center">
|
<image class="slot-img text-center" src="/static/images/camera.png" />
|
<view class="flex-1">
|
<view class="text-color-base">
|
{{ model.equName }}
|
<text class="text-color-gray ml-2 text-mini">{{ model.modelNo }}</text>
|
</view>
|
<view class="text-color-gray text-sm mt-1">
|
{{ model.location }} | {{ model.madeIn }}
|
</view>
|
</view>
|
</view>
|
</wd-card>
|
|
<view class="mt-2">
|
<wd-cell class="mt-2">
|
<template #title>
|
<text class="text-color-gray">操作</text>
|
</template>
|
</wd-cell>
|
<view class="h-[1px] bg-base"></view>
|
<view class="bg-white flex justify-around py-4">
|
<wd-button icon="edit-outline" @click.stop="handleInsp">点检</wd-button>
|
<wd-button icon="laptop" v-if="isRepair() || isLeader()" @click.stop="handMaint">
|
保养
|
</wd-button>
|
<wd-button icon="laptop" @click.stop="handleRequest">报修</wd-button>
|
<!-- <wd-button icon="tools" @click.stop="showActions">维修</wd-button>-->
|
</view>
|
</view>
|
<view class="h-[10px] bg-base"></view>
|
<wd-tabs v-model="tab">
|
|
<wd-tab title="报修单">
|
<view class="h-[10px] bg-base"></view>
|
<!-- 维修请求区域 -->
|
<view class="mt-2" v-if="reqList.length > 0">
|
|
|
<view class="bg-base">
|
<req-card
|
v-for="item in reqList"
|
:key="item.id"
|
:item="item"
|
@click="handleReqClick"
|
/>
|
</view>
|
</view>
|
</wd-tab>
|
<wd-tab title="维修单">
|
<view class="h-[10px] bg-base"></view>
|
<!-- 维修单区域 -->
|
<view class="mt-2" v-if="resList.length > 0">
|
|
|
<view class="bg-base">
|
<res-card v-for="item in resList" :key="item.id" :item="item" />
|
</view>
|
</view>
|
</wd-tab>
|
</wd-tabs>
|
|
<wd-action-sheet
|
v-model="show"
|
:actions="actions"
|
@close="close"
|
@select="select"
|
cancel-text="取消"
|
/>
|
|
<wd-popup v-model="showStatusDialog" position="center" round :close-on-click-modal="false">
|
<view class="popup-container">
|
<view class="popup-title">设备状态变更</view>
|
<view class="flex flex-wrap justify-between mb-4">
|
<view
|
v-for="item in statusOptions"
|
:key="item.value"
|
:class="['status-option', selectedStatus === item.value ? 'active' : '']"
|
@click="selectStatus(item.value)"
|
>
|
{{ item.label }}
|
</view>
|
</view>
|
<wd-textarea
|
v-model="changeReason"
|
placeholder="请输入变更原因"
|
:maxlength="100"
|
show-word-limit
|
required
|
/>
|
<view class="popup-actions">
|
<wd-button block @click="handleStatusChangeCancel">取消</wd-button>
|
<wd-button type="primary" block class="ml-2" @click="handleStatusChangeConfirm">确定</wd-button>
|
</view>
|
</view>
|
</wd-popup>
|
</view>
|
<view v-else>
|
<wd-status-tip image="search" tip="当前搜索无结果" />
|
<view class="w-full flex justify-center">{{ scanResult }}</view>
|
</view>
|
</view>
|
</template>
|
<script setup lang="ts">
|
import dayjs from 'dayjs'
|
import type { EquVO } from '@/service/equ.d'
|
import type { RepairReqVO, RepairResVO } from '@/service/repair.d'
|
import { useToast, useMessage } from 'wot-design-uni'
|
import { getEquByAssetNo } from '@/service/equ'
|
import { getInspStByStId } from '@/service/inspect'
|
import { isLeader, isRepair } from '@/utils/RoleUtils'
|
import { getRepairReqList, getRepairResList } from '@/service/repair'
|
import ReqCard from '@/components/repair/req-card.vue'
|
import ResCard from '@/components/repair/res-card.vue'
|
import { useUserStore } from '@/store'
|
import { addEquStatu } from '@/service/equ_status'
|
import type { EimsEquStatuBo } from '@/service/equ_status.d'
|
const tab = ref<number>(0)
|
const message = useMessage()
|
const toast = useToast()
|
const model = reactive<EquVO>({})
|
const userStore = useUserStore()
|
const scanResult = ref<string>('')
|
const show = ref<boolean>(false)
|
const exist = ref<boolean>(false)
|
const reqList = ref<RepairReqVO[]>([])
|
const resList = ref<RepairResVO[]>([])
|
const actions = ref([
|
{
|
name: '新增报修',
|
},
|
{
|
name: '去维修',
|
},
|
])
|
const showStatusDialog = ref(false)
|
const selectedStatus = ref<string>('')
|
const changeReason = ref<string>('')
|
const statusOptions = [
|
{ label: '试用', value: '0' },
|
{ label: '使用', value: '1' },
|
{ label: '停用', value: '2' },
|
{ label: '报废', value: '3' },
|
{ label: '闲置', value: '4' },
|
{ label: '新增', value: '5' },
|
]
|
|
function initData(assetNo: any) {
|
getEquByAssetNo(assetNo)
|
.then((res: any) => {
|
console.error(res)
|
if (res?.equId) {
|
exist.value = true
|
Object.assign(model, res)
|
// 加载维修请求和维修单数据
|
loadRepairData()
|
} else {
|
toast.error('未查询到该资产编号相关数据!')
|
}
|
})
|
.catch((res) => {
|
console.error(res)
|
toast.error(res?.data?.msg || '请求失败')
|
})
|
}
|
|
// 加载维修请求和维修单数据
|
function loadRepairData() {
|
// 加载未接单的维修请求
|
getRepairReqList({
|
equId: model.equId,
|
status: '0',
|
}).then((res: any) => {
|
if (res?.rows) {
|
reqList.value = res.rows
|
}
|
})
|
|
// 加载未完成的维修单
|
const params = {
|
equId: model.equId,
|
params: {
|
status: '0,1,2',
|
},
|
}
|
// 如果是维修工则加载本要接单的维修单
|
if (isRepair()) {
|
params.resUser = userStore?.userInfo?.userId
|
params.params.status = '0,1,2'
|
}
|
getRepairResList(params).then((res: any) => {
|
if (res?.rows) {
|
resList.value = res.rows
|
}
|
})
|
}
|
|
function handleInfo() {
|
if (!model?.equId) {
|
uni.showToast({ title: '未查询到设备,请联系管理员!', icon: 'none' })
|
return
|
}
|
console.log("model::",model)
|
selectedStatus.value = model.status || '5'
|
changeReason.value = ''
|
showStatusDialog.value = true
|
}
|
|
function handleInsp() {
|
// 拼接出st_id (由日期+设备id组成)
|
const today = dayjs().format('YYYYMMDD')
|
const stId = `${today}_${model.equId}`
|
|
getInspStByStId(stId).then((res: any) => {
|
if (res?.id) {
|
uni.navigateTo({
|
url: `/pages/inspect/insp-record?id=${res?.id}&viewMode=Day`,
|
})
|
} else {
|
uni.showToast({
|
title: '设备今天没有点检记录,请联系管理员!',
|
icon: 'none',
|
})
|
}
|
})
|
}
|
function handMaint() {
|
if (!model?.assetNo) {
|
uni.showToast({
|
title: '未查询到设备,请联系管理员!',
|
icon: 'none',
|
})
|
return false
|
}
|
uni.navigateTo({
|
url: `/pages/maint/maint-st?assetNo=${model?.assetNo}&from=scan`,
|
})
|
}
|
|
function handleRequest() {
|
if (!model?.assetNo) {
|
uni.showToast({
|
title: '未查询到设备,请联系管理员!',
|
icon: 'none',
|
})
|
return false
|
}
|
uni.navigateTo({
|
url: `/pages/repair/repair-add?equId=${model?.equId}&equName=${model?.equName}&from=scan`,
|
})
|
}
|
|
function showActions() {
|
show.value = true
|
}
|
|
function close() {
|
show.value = false
|
}
|
|
function select({ item, index }) {
|
console.error(model?.equId)
|
console.error(!model?.equId)
|
if (!model?.equId) {
|
uni.showToast({
|
title: '未查询到设备,请联系管理员!',
|
icon: 'none',
|
})
|
return false
|
}
|
switch (index) {
|
case 0:
|
uni.navigateTo({
|
url: `/pages/repair/repair-add?equId=${model?.equId}&equName=${model?.equName}&from=scan`,
|
})
|
break
|
case 1:
|
uni.navigateTo({
|
url: `/pages/repair/res-list?assetNo=${model?.assetNo}&from=scan`,
|
})
|
break
|
}
|
}
|
|
// 处理维修请求点击事件
|
function handleReqClick(item) {
|
uni.navigateTo({
|
url: `/pages/repair/req-detail?id=${item.id}`,
|
})
|
}
|
|
defineExpose({ handleReqClick })
|
|
function selectStatus(val: string) {
|
selectedStatus.value = val
|
}
|
|
function handleStatusChangeCancel() {
|
showStatusDialog.value = false
|
}
|
|
async function handleStatusChangeConfirm() {
|
if (!selectedStatus.value) {
|
uni.showToast({ title: '请选择设备状态', icon: 'none' })
|
return
|
}
|
if (!changeReason.value.trim()) {
|
uni.showToast({ title: '请填写变更原因', icon: 'none' })
|
return
|
}
|
const params: EimsEquStatuBo = {
|
equId: model.equId,
|
beforeChange: model.status,
|
afterChange: selectedStatus.value,
|
changeDesc: changeReason.value,
|
orderStatus: '0',
|
}
|
try {
|
await addEquStatu(params)
|
uni.showToast({ title: '提交成功,待管理员确认', icon: 'success' })
|
showStatusDialog.value = false
|
// 可选:刷新设备信息
|
initData(model.assetNo)
|
} catch (e) {
|
uni.showToast({ title: '提交失败', icon: 'none' })
|
}
|
}
|
|
onLoad((options) => {
|
uni.$on('list-refresh', loadRepairData)
|
scanResult.value = options?.result
|
initData(options?.result)
|
})
|
onUnload(() => {
|
uni.$off('list-refresh', loadRepairData)
|
})
|
</script>
|
|
<style scoped lang="scss">
|
.equ-img {
|
width: 100%;
|
height: 300rpx;
|
}
|
.slot-img {
|
width: 72rpx;
|
height: 72rpx;
|
margin-right: 24rpx;
|
}
|
.text-mini {
|
font-size: 22rpx;
|
}
|
|
.menu-indicator {
|
width: 6rpx;
|
height: 22rpx;
|
border-radius: 10rpx;
|
background-color: $uni-color-primary;
|
}
|
:deep(.wd-card__footer) {
|
padding: 10rpx !important;
|
}
|
:deep(.wd-card__title-content) {
|
padding: 16rpx 0 !important;
|
}
|
.status-option {
|
display: inline-block;
|
padding: 10rpx 24rpx;
|
margin: 8rpx 8rpx 8rpx 0;
|
border-radius: 8rpx;
|
border: 1px solid #eee;
|
background: #f7f7f7;
|
color: #666;
|
cursor: pointer;
|
}
|
.status-option.active {
|
background: $uni-color-primary;
|
color: #fff;
|
border-color: $uni-color-primary;
|
}
|
.popup-container {
|
width: 600rpx;
|
background: #fff;
|
border-radius: 16rpx;
|
padding: 32rpx 24rpx 24rpx 24rpx;
|
}
|
.popup-title {
|
font-size: 32rpx;
|
font-weight: bold;
|
text-align: center;
|
margin-bottom: 24rpx;
|
}
|
.popup-actions {
|
display: flex;
|
margin-top: 24rpx;
|
gap: 16rpx;
|
justify-content: space-around;
|
}
|
</style>
|