|
|
|
|
@ -141,6 +141,32 @@
|
|
|
|
|
<el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="关键件" prop="componentIds">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.componentIds"
|
|
|
|
|
multiple
|
|
|
|
|
filterable
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请选择关键件"
|
|
|
|
|
class="!w-full"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in criticalComponentOptions"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:value="item.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="资料" prop="fileUrl">
|
|
|
|
|
<UploadFile :is-show-tip="false" v-model="formData.fileUrl" :limit="1" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
@ -152,6 +178,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
|
|
|
|
|
import { CriticalComponentApi } from '@/api/mes/criticalComponent'
|
|
|
|
|
import { DeviceTypeApi, DeviceTypeTreeVO } from '@/api/mes/devicetype'
|
|
|
|
|
import { getSimpleUserList, UserVO } from '@/api/system/user'
|
|
|
|
|
import { formatDate } from '@/utils/formatTime'
|
|
|
|
|
@ -209,6 +236,8 @@ const initFormData = () => ({
|
|
|
|
|
productionDate: undefined,
|
|
|
|
|
factoryEntryDate: undefined,
|
|
|
|
|
remark: undefined,
|
|
|
|
|
componentIds: [] as number[],
|
|
|
|
|
fileUrl: undefined,
|
|
|
|
|
sort: undefined
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@ -227,14 +256,22 @@ const formRef = ref() // 表单 Ref
|
|
|
|
|
const treeSelectProps = { label: 'name', children: 'children' }
|
|
|
|
|
const deviceTypeTree = ref<DeviceTypeTreeVO[]>([])
|
|
|
|
|
const users = ref<UserVO[]>([])
|
|
|
|
|
const criticalComponentOptions = ref<{ label: string; value: number }[]>([])
|
|
|
|
|
|
|
|
|
|
const ensureOptionsLoaded = async () => {
|
|
|
|
|
const [deviceTypeRes, userRes] = await Promise.all([
|
|
|
|
|
const [deviceTypeRes, userRes, criticalRes] = await Promise.all([
|
|
|
|
|
DeviceTypeApi.getDeviceTypeTree({ pageNo: 1, pageSize: 10 }),
|
|
|
|
|
getSimpleUserList()
|
|
|
|
|
getSimpleUserList(),
|
|
|
|
|
CriticalComponentApi.getCriticalComponentPage({})
|
|
|
|
|
])
|
|
|
|
|
deviceTypeTree.value = deviceTypeRes
|
|
|
|
|
users.value = userRes ?? []
|
|
|
|
|
criticalComponentOptions.value = (criticalRes?.list ?? []).map((item: any) => {
|
|
|
|
|
const code = item.code ? String(item.code) : ''
|
|
|
|
|
const name = item.name ? String(item.name) : ''
|
|
|
|
|
const label = code && name ? `${code}-${name}` : name || code || String(item.id)
|
|
|
|
|
return { label, value: Number(item.id) }
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 打开弹窗 */
|
|
|
|
|
@ -258,7 +295,8 @@ const open = async (type: string, id?: number, defaultDeviceTypeId?: number) =>
|
|
|
|
|
...(detail as any),
|
|
|
|
|
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
|
|
|
|
|
productionDate: normalizeYmd((detail as any)?.productionDate),
|
|
|
|
|
factoryEntryDate: normalizeYmd((detail as any)?.factoryEntryDate)
|
|
|
|
|
factoryEntryDate: normalizeYmd((detail as any)?.factoryEntryDate),
|
|
|
|
|
componentIds: parseIdsValue((detail as any)?.componentId)
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
formLoading.value = false
|
|
|
|
|
@ -279,9 +317,11 @@ const submitForm = async () => {
|
|
|
|
|
...(formData.value as any),
|
|
|
|
|
productionDate: normalizeYmd(formData.value.productionDate),
|
|
|
|
|
factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate),
|
|
|
|
|
deviceManager: formData.value.deviceManagerIds?.length ? formData.value.deviceManagerIds.join(',') : undefined
|
|
|
|
|
deviceManager: formData.value.deviceManagerIds?.length ? formData.value.deviceManagerIds.join(',') : undefined,
|
|
|
|
|
componentId: formData.value.componentIds?.length ? formData.value.componentIds.join(',') : undefined
|
|
|
|
|
} as unknown as DeviceLedgerVO
|
|
|
|
|
delete (data as any).deviceManagerIds
|
|
|
|
|
delete (data as any).componentIds
|
|
|
|
|
if (formType.value === 'create') {
|
|
|
|
|
await DeviceLedgerApi.createDeviceLedger(data)
|
|
|
|
|
message.success(t('common.createSuccess'))
|
|
|
|
|
|