Merge remote-tracking branch 'origin/main'

main
liutao 5 hours ago
commit 4e014658a5

@ -76,6 +76,7 @@
value-key="id"
:placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceType')"
class="!w-full"
@change="() => { formData.typeName = findDeviceTypeName(formData.deviceType) }"
/>
</el-form-item>
</el-col>
@ -910,6 +911,7 @@ const initFormData = () => ({
isScheduled: 0,
ratedCapacity: undefined,
deviceType: undefined as string | undefined,
typeName: undefined as string | undefined,
deviceLine: undefined as string | undefined,
supplier: undefined,
workshop: undefined,
@ -991,6 +993,15 @@ watch(
const treeSelectProps = { label: 'name', children: 'children' }
const deviceTypeTree = ref<DeviceTypeTreeVO[]>([])
const findDeviceTypeName = (id: string | number): string | undefined => {
const stack = [...deviceTypeTree.value]
while (stack.length) {
const node = stack.pop()!
if (String(node.id) === String(id)) return node.name
if (Array.isArray(node.children) && node.children.length) stack.push(...node.children)
}
return undefined
}
const users = ref<UserVO[]>([])
type SelectionOption = { label: string; value: number }
const criticalComponentOptions = ref<SelectionOption[]>([])
@ -1554,6 +1565,7 @@ const submitForm = async () => {
isScheduled: normalizeNumberish((formData.value as any).isScheduled) ?? 0,
ratedCapacity: normalizeNumberish((formData.value as any).ratedCapacity),
deviceType: (formData.value as any).deviceType ?? undefined,
typeName: (formData.value as any).typeName ?? findDeviceTypeName((formData.value as any).deviceType),
deviceLine: (formData.value as any).deviceLine ?? undefined,
productionDate: normalizeYmd(formData.value.productionDate),
outgoingTime: normalizeYmd((formData.value as any).outgoingTime),

@ -74,6 +74,7 @@
t('EquipmentManagement.EquipmentLedger.placeholderDeviceType')
"
class="!w-full"
@change="() => { formData.typeName = findDeviceTypeName(formData.deviceType) }"
/>
</el-form-item>
</el-col>
@ -1186,6 +1187,7 @@ const initFormData = () => ({
isScheduled: 0,
ratedCapacity: undefined,
deviceType: undefined as string | undefined,
typeName: undefined as string | undefined,
deviceLine: undefined as string | undefined,
supplier: undefined,
workshop: undefined,
@ -1284,6 +1286,15 @@ const formRules = reactive<FormRules>({
})
const treeSelectProps = { label: 'name', children: 'children' }
const deviceTypeTree = ref<DeviceTypeTreeVO[]>([])
const findDeviceTypeName = (id: string | number): string | undefined => {
const stack = [...deviceTypeTree.value]
while (stack.length) {
const node = stack.pop()!
if (String(node.id) === String(id)) return node.name
if (Array.isArray(node.children) && node.children.length) stack.push(...node.children)
}
return undefined
}
const users = ref<UserVO[]>([])
type SelectionOption = { label: string; value: number }
const criticalComponentOptions = ref<SelectionOption[]>([])
@ -1676,6 +1687,7 @@ const buildSubmitData = () => {
isScheduled: normalizeNumberish((formData.value as any).isScheduled) ?? 0,
ratedCapacity: normalizeNumberish((formData.value as any).ratedCapacity),
deviceType: (formData.value as any).deviceType ?? undefined,
typeName: (formData.value as any).typeName ?? findDeviceTypeName((formData.value as any).deviceType),
deviceLine: (formData.value as any).deviceLine ?? undefined,
productionDate: normalizeYmd(formData.value.productionDate),
outgoingTime: normalizeYmd((formData.value as any).outgoingTime),

@ -344,14 +344,12 @@
<el-table-column
:label="t('EquipmentManagement.EquipmentLedger.deviceType')"
align="center"
prop="deviceType"
prop="typeName"
min-width="110px"
sortable
>
<template #default="scope">
<el-tag effect="light">
{{ getDeviceTypeName(scope.row.typeName ?? scope.row.deviceType) }}
</el-tag>
<el-tag effect="light">{{ scope.row.typeName || '-' }}</el-tag>
</template>
</el-table-column>
<el-table-column
@ -735,20 +733,8 @@ const typeTreeProps = { label: 'name', children: 'children' }
const treeSelectProps = { label: 'name', children: 'children' }
const typeTreeExpandedKeys = ref<number[]>([])
const deviceTypeTree = ref<DeviceTypeTreeVO[]>([])
const deviceTypeNameMap = ref<Record<string, string>>({})
const ALL_TYPE_NODE_ID = -1
const buildDeviceTypeNameMap = (nodes: DeviceTypeTreeVO[]) => {
const map: Record<string, string> = {}
const stack = [...nodes]
while (stack.length) {
const node = stack.pop()!
if (node.id != null) map[String(node.id)] = node.name
if (Array.isArray(node.children) && node.children.length) stack.push(...node.children)
}
deviceTypeNameMap.value = map
}
const isAllTypeNode = (node: any) => Number(node?.id) === ALL_TYPE_NODE_ID
const buildTypeTreeWithAll = (nodes: DeviceLineTreeVO[]) => {
@ -785,7 +771,6 @@ const getDeviceTypeTree = async () => {
const data = await DeviceTypeApi.getDeviceTypeTree({})
const treeData = JSON.parse(JSON.stringify(data ?? []))
deviceTypeTree.value = treeData
buildDeviceTypeNameMap(treeData)
}
const handleTypeNodeClick = (node: any) => {
@ -972,11 +957,7 @@ const buildTreeQrcodePrintData = () => {
}
}
const getDeviceTypeName = (value: any) => {
const id = String(value ?? '')
if (deviceTypeNameMap.value[id]) return deviceTypeNameMap.value[id]
return value ?? ''
}
const formatScheduleLabel = (value: any) => {
return Number(value) === 1

Loading…
Cancel
Save