|
|
|
|
@ -44,7 +44,7 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.DvRepair.requireDate')" prop="requireDate" required>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.DvRepair.requireDate')" prop="requireDate">
|
|
|
|
|
<el-date-picker
|
|
|
|
|
v-model="formData.requireDate"
|
|
|
|
|
type="date"
|
|
|
|
|
@ -146,17 +146,22 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.DvRepair.device')" prop="deviceId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.deviceId"
|
|
|
|
|
filterable
|
|
|
|
|
<el-input
|
|
|
|
|
:model-value="selectedDeviceText"
|
|
|
|
|
readonly
|
|
|
|
|
clearable
|
|
|
|
|
:loading="deviceLoading"
|
|
|
|
|
:disabled="isBaseInfoReadonly"
|
|
|
|
|
:placeholder="t('EquipmentManagement.DvRepair.placeholderDevice')"
|
|
|
|
|
class="!w-full"
|
|
|
|
|
:disabled="isBaseInfoReadonly"
|
|
|
|
|
@clear="clearDeviceSelection"
|
|
|
|
|
>
|
|
|
|
|
<el-option v-for="opt in deviceOptions" :key="String(opt.value)" :label="opt.label" :value="opt.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<template #append>
|
|
|
|
|
<el-button @click="openDeviceDialog" :disabled="isBaseInfoReadonly">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.select') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="showComponentSelect" :span="8">
|
|
|
|
|
@ -389,11 +394,107 @@
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Dialog
|
|
|
|
|
:title="t('EquipmentManagement.DvRepair.device') + t('common.select')"
|
|
|
|
|
v-model="deviceDialogVisible"
|
|
|
|
|
:appendToBody="true"
|
|
|
|
|
width="1080px"
|
|
|
|
|
>
|
|
|
|
|
<el-form
|
|
|
|
|
ref="deviceDialogQueryFormRef"
|
|
|
|
|
:model="deviceDialogQueryParams"
|
|
|
|
|
:inline="true"
|
|
|
|
|
class="-mb-15px"
|
|
|
|
|
>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.deviceCode')" prop="deviceCode">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="deviceDialogQueryParams.deviceCode"
|
|
|
|
|
:placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceCode')"
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-220px"
|
|
|
|
|
@keyup.enter="handleDeviceDialogQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.deviceName')" prop="deviceName">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="deviceDialogQueryParams.deviceName"
|
|
|
|
|
:placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceName')"
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-220px"
|
|
|
|
|
@keyup.enter="handleDeviceDialogQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="handleDeviceDialogQuery">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.query') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button @click="resetDeviceDialogQuery">
|
|
|
|
|
<Icon icon="ep:refresh" class="mr-5px" />
|
|
|
|
|
{{ t('common.reset') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
v-loading="deviceDialogLoading"
|
|
|
|
|
:data="deviceDialogList"
|
|
|
|
|
:stripe="true"
|
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
|
row-key="id"
|
|
|
|
|
max-height="420"
|
|
|
|
|
@row-click="handleDeviceDialogRowClick"
|
|
|
|
|
@row-dblclick="confirmDeviceSelection"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column width="55" align="center">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-radio
|
|
|
|
|
:model-value="deviceDialogSelectedId"
|
|
|
|
|
:value="String(row.id)"
|
|
|
|
|
@click.stop
|
|
|
|
|
@change="handleDeviceDialogRadioChange(row)"
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
</el-radio>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceCode')" prop="deviceCode" min-width="150" />
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceName')" prop="deviceName" min-width="150" />
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceType')" prop="deviceTypeName" min-width="120">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
{{ getDeviceTypeName(row.deviceTypeName ?? row.deviceType) }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceStatus')" prop="deviceStatus" width="100">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<dict-tag type="mes_tz_status" :value="row.deviceStatus ?? ''" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceBrand')" prop="deviceBrand" min-width="120" />
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.sn')" prop="sn" min-width="140" />
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end mt-15px">
|
|
|
|
|
<Pagination
|
|
|
|
|
:total="deviceDialogTotal"
|
|
|
|
|
v-model:page="deviceDialogQueryParams.pageNo"
|
|
|
|
|
v-model:limit="deviceDialogQueryParams.pageSize"
|
|
|
|
|
@pagination="getDeviceDialogList"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button type="primary" @click="confirmDeviceSelection">{{ t('common.ok') }}</el-button>
|
|
|
|
|
<el-button @click="deviceDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { DvRepairApi, DvRepairVO } from '@/api/mes/dvrepair'
|
|
|
|
|
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
|
|
|
|
|
import { DeviceTypeApi, DeviceTypeTreeVO } from '@/api/mes/devicetype'
|
|
|
|
|
import { RepairItemsApi } from '@/api/mes/repairItems'
|
|
|
|
|
import { getSimpleUserList, UserVO } from '@/api/system/user'
|
|
|
|
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
|
|
|
|
@ -438,7 +539,7 @@ const createDefaultFormData = (): DvRepairFormData => ({
|
|
|
|
|
machineryBrand: undefined,
|
|
|
|
|
machinerySpec: undefined,
|
|
|
|
|
machineryTypeId: 1,
|
|
|
|
|
requireDate: undefined,
|
|
|
|
|
requireDate: Date.now(),
|
|
|
|
|
finishDate: undefined,
|
|
|
|
|
confirmDate: undefined,
|
|
|
|
|
repairResult: '',
|
|
|
|
|
@ -456,7 +557,7 @@ const createDefaultFormData = (): DvRepairFormData => ({
|
|
|
|
|
acceptedBy: undefined,
|
|
|
|
|
confirmBy: undefined,
|
|
|
|
|
faultLevel: undefined,
|
|
|
|
|
isShutdown: undefined,
|
|
|
|
|
isShutdown: false,
|
|
|
|
|
status: undefined,
|
|
|
|
|
remark: undefined,
|
|
|
|
|
isCode: true
|
|
|
|
|
@ -504,10 +605,31 @@ const statusLabel = computed(() => {
|
|
|
|
|
|
|
|
|
|
const showComponentSelect = computed(() => formData.value.machineryTypeId === 2)
|
|
|
|
|
|
|
|
|
|
const selectedDeviceText = computed(() => {
|
|
|
|
|
const deviceId = formData.value.deviceId
|
|
|
|
|
if (typeof deviceId !== 'number') return ''
|
|
|
|
|
const option = deviceOptions.value.find((item) => item.value === deviceId)
|
|
|
|
|
return option?.label || `ID:${deviceId}`
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const deviceLoading = ref(false)
|
|
|
|
|
const deviceOptions = ref<{ label: string; value: number; raw?: DeviceLedgerVO }[]>([])
|
|
|
|
|
const deviceOptionsLoaded = ref(false)
|
|
|
|
|
|
|
|
|
|
const deviceDialogVisible = ref(false)
|
|
|
|
|
const deviceDialogLoading = ref(false)
|
|
|
|
|
const deviceDialogList = ref<DeviceLedgerVO[]>([])
|
|
|
|
|
const deviceDialogTotal = ref(0)
|
|
|
|
|
const deviceDialogSelectedId = ref('')
|
|
|
|
|
const deviceDialogSelectedRow = ref<DeviceLedgerVO>()
|
|
|
|
|
const deviceDialogQueryFormRef = ref()
|
|
|
|
|
const deviceDialogQueryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
deviceCode: undefined as string | undefined,
|
|
|
|
|
deviceName: undefined as string | undefined
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const componentLoading = ref(false)
|
|
|
|
|
const componentOptions = ref<{ label: string; value: number }[]>([])
|
|
|
|
|
|
|
|
|
|
@ -605,6 +727,108 @@ const ensureDeviceOptionsLoaded = async () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const deviceTypeNameMap = ref<Record<number, string>>({})
|
|
|
|
|
|
|
|
|
|
const buildDeviceTypeNameMap = (nodes: DeviceTypeTreeVO[]) => {
|
|
|
|
|
const map: Record<number, string> = {}
|
|
|
|
|
const walk = (list: DeviceTypeTreeVO[]) => {
|
|
|
|
|
list.forEach((node) => {
|
|
|
|
|
if (typeof node?.id === 'number') {
|
|
|
|
|
map[node.id] = node.name ?? ''
|
|
|
|
|
}
|
|
|
|
|
if (Array.isArray(node?.children)) walk(node.children)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
walk(nodes)
|
|
|
|
|
deviceTypeNameMap.value = map
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getDeviceTypeName = (value: any) => {
|
|
|
|
|
const id = typeof value === 'number' ? value : Number(value)
|
|
|
|
|
if (!Number.isNaN(id) && deviceTypeNameMap.value[id]) return deviceTypeNameMap.value[id]
|
|
|
|
|
return value ?? '-'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---- 设备弹框方法 ----
|
|
|
|
|
const getDeviceDialogList = async () => {
|
|
|
|
|
deviceDialogLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const data = await DeviceLedgerApi.getDeviceLedgerPage(deviceDialogQueryParams)
|
|
|
|
|
const list = Array.isArray(data) ? data : data?.list ?? data?.data?.list ?? []
|
|
|
|
|
deviceDialogList.value = list as DeviceLedgerVO[]
|
|
|
|
|
deviceDialogTotal.value = Array.isArray(data) ? data.length : data?.total ?? data?.data?.total ?? list.length
|
|
|
|
|
} finally {
|
|
|
|
|
deviceDialogLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const openDeviceDialog = async () => {
|
|
|
|
|
deviceDialogVisible.value = true
|
|
|
|
|
deviceDialogSelectedId.value = formData.value.deviceId !== undefined && formData.value.deviceId !== null
|
|
|
|
|
? String(formData.value.deviceId)
|
|
|
|
|
: ''
|
|
|
|
|
deviceDialogSelectedRow.value = undefined
|
|
|
|
|
deviceDialogQueryParams.pageNo = 1
|
|
|
|
|
deviceDialogQueryParams.deviceCode = undefined
|
|
|
|
|
deviceDialogQueryParams.deviceName = undefined
|
|
|
|
|
if (!Object.keys(deviceTypeNameMap.value).length) {
|
|
|
|
|
try {
|
|
|
|
|
const treeData = await DeviceTypeApi.getDeviceTypeTree({})
|
|
|
|
|
buildDeviceTypeNameMap(treeData ?? [])
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
}
|
|
|
|
|
await getDeviceDialogList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDeviceDialogQuery = () => {
|
|
|
|
|
deviceDialogQueryParams.pageNo = 1
|
|
|
|
|
getDeviceDialogList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resetDeviceDialogQuery = () => {
|
|
|
|
|
deviceDialogQueryFormRef.value?.resetFields?.()
|
|
|
|
|
handleDeviceDialogQuery()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDeviceDialogRowClick = (row: DeviceLedgerVO) => {
|
|
|
|
|
deviceDialogSelectedId.value = String(row.id)
|
|
|
|
|
deviceDialogSelectedRow.value = row
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDeviceDialogRadioChange = (row: DeviceLedgerVO) => {
|
|
|
|
|
deviceDialogSelectedRow.value = row
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const confirmDeviceSelection = (row?: DeviceLedgerVO) => {
|
|
|
|
|
const selected = row?.id !== undefined && row?.id !== null
|
|
|
|
|
? row
|
|
|
|
|
: deviceDialogSelectedRow.value ||
|
|
|
|
|
deviceDialogList.value.find((item) => String(item.id) === deviceDialogSelectedId.value)
|
|
|
|
|
|
|
|
|
|
if (!selected?.id) {
|
|
|
|
|
message.warning(t('EquipmentManagement.DvRepair.validatorMachineryIdRequired'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const id = Number(selected.id)
|
|
|
|
|
const label = `${selected.deviceCode ?? ''} ${selected.deviceName ?? ''}`.trim()
|
|
|
|
|
deviceOptions.value = upsertDeviceOption(deviceOptions.value, { label, value: id, raw: selected })
|
|
|
|
|
formData.value.deviceId = id
|
|
|
|
|
deviceDialogVisible.value = false
|
|
|
|
|
formRef.value?.clearValidate?.('deviceId')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const clearDeviceSelection = () => {
|
|
|
|
|
formData.value.deviceId = undefined
|
|
|
|
|
formData.value.machineryCode = undefined
|
|
|
|
|
formData.value.machineryName = undefined
|
|
|
|
|
formData.value.machinerySpec = undefined
|
|
|
|
|
formData.value.machineryBrand = undefined
|
|
|
|
|
componentOptions.value = []
|
|
|
|
|
setLineRows([])
|
|
|
|
|
formRef.value?.clearValidate?.('deviceId')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => formData.value.machineryTypeId,
|
|
|
|
|
() => {
|
|
|
|
|
@ -722,14 +946,9 @@ const formRules = reactive({
|
|
|
|
|
],
|
|
|
|
|
requireDate: [
|
|
|
|
|
{
|
|
|
|
|
validator: (_: any, value: any, callback: any) => {
|
|
|
|
|
if (!value) {
|
|
|
|
|
callback(new Error(t('EquipmentManagement.DvRepair.validatorRequireDateRequired')))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
callback()
|
|
|
|
|
},
|
|
|
|
|
trigger: 'change'
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('EquipmentManagement.DvRepair.validatorRequireDateRequired'),
|
|
|
|
|
trigger: ['blur', 'change']
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
faultLevel: [
|
|
|
|
|
|