|
|
|
@ -15,8 +15,25 @@
|
|
|
|
</el-col> -->
|
|
|
|
</el-col> -->
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.deviceCode')" prop="deviceCode" required>
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.deviceCode')" prop="deviceCode">
|
|
|
|
<el-input :disabled = "formType == 'update'" v-model="formData.deviceCode" :placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceCode')" />
|
|
|
|
<el-row :gutter="10" style="width: 100%">
|
|
|
|
|
|
|
|
<el-col :xs="24" :sm="18" :md="16" :lg="14" :xl="12">
|
|
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
|
|
v-model="formData.deviceCode"
|
|
|
|
|
|
|
|
:placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceCode')"
|
|
|
|
|
|
|
|
:disabled="Boolean(formData.isCode) || formType === 'update'"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
<el-col :xs="24" :sm="6" :md="4" :lg="3" :xl="2">
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<el-switch
|
|
|
|
|
|
|
|
v-model="formData.isCode"
|
|
|
|
|
|
|
|
:disabled="formType === 'update'"
|
|
|
|
|
|
|
|
@change="handleCodeAutoChange"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
</el-row>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-col :span="12">
|
|
|
|
@ -180,6 +197,36 @@
|
|
|
|
<UploadFile :is-show-tip="false" v-model="formData.fileUrl" :limit="9" />
|
|
|
|
<UploadFile :is-show-tip="false" v-model="formData.fileUrl" :limit="9" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
<el-col v-if="formType === 'update'" :span="24">
|
|
|
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.qrcode')" prop="qrcodeUrl">
|
|
|
|
|
|
|
|
<div class="device-ledger-qrcode-wrap">
|
|
|
|
|
|
|
|
<el-image
|
|
|
|
|
|
|
|
v-if="formData.qrcodeUrl"
|
|
|
|
|
|
|
|
:src="formData.qrcodeUrl"
|
|
|
|
|
|
|
|
:preview-src-list="[formData.qrcodeUrl]"
|
|
|
|
|
|
|
|
preview-teleported
|
|
|
|
|
|
|
|
fit="cover"
|
|
|
|
|
|
|
|
class="device-ledger-qrcode-img"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<template #error>
|
|
|
|
|
|
|
|
<div class="device-ledger-qrcode-error">{{ t('EquipmentManagement.EquipmentLedger.qrcodeLoadError') }}</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</el-image>
|
|
|
|
|
|
|
|
<div v-else class="device-ledger-qrcode-error">{{ t('EquipmentManagement.EquipmentLedger.qrcodeEmpty') }}</div>
|
|
|
|
|
|
|
|
<div class="device-ledger-qrcode-mask">
|
|
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
|
|
circle
|
|
|
|
|
|
|
|
:loading="regenerateCodeLoading"
|
|
|
|
|
|
|
|
:disabled="regenerateCodeLoading"
|
|
|
|
|
|
|
|
@click="handleRegenerateCode"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Icon icon="ep:refresh" />
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
<el-col :span="24">
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.remark')" prop="remark">
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.remark')" prop="remark">
|
|
|
|
<el-input v-model="formData.remark" :placeholder="t('EquipmentManagement.EquipmentLedger.placeholderRemark')" type="textarea" />
|
|
|
|
<el-input v-model="formData.remark" :placeholder="t('EquipmentManagement.EquipmentLedger.placeholderRemark')" type="textarea" />
|
|
|
|
@ -256,6 +303,7 @@ const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
|
|
|
|
|
const regenerateCodeLoading = ref(false)
|
|
|
|
const deviceList = ref<DeviceVO[]>([]) // 列表
|
|
|
|
const deviceList = ref<DeviceVO[]>([]) // 列表
|
|
|
|
|
|
|
|
|
|
|
|
const parseIdsValue = (value: any): number[] => {
|
|
|
|
const parseIdsValue = (value: any): number[] => {
|
|
|
|
@ -352,6 +400,7 @@ const normalizeFileUrlAsJsonArrayString = (value: any): string | undefined => {
|
|
|
|
const initFormData = () => ({
|
|
|
|
const initFormData = () => ({
|
|
|
|
id: undefined,
|
|
|
|
id: undefined,
|
|
|
|
deviceCode: undefined,
|
|
|
|
deviceCode: undefined,
|
|
|
|
|
|
|
|
isCode: true,
|
|
|
|
deviceName: undefined,
|
|
|
|
deviceName: undefined,
|
|
|
|
deviceStatus: undefined,
|
|
|
|
deviceStatus: undefined,
|
|
|
|
deviceBrand: undefined,
|
|
|
|
deviceBrand: undefined,
|
|
|
|
@ -369,6 +418,7 @@ const initFormData = () => ({
|
|
|
|
componentIds: [] as number[],
|
|
|
|
componentIds: [] as number[],
|
|
|
|
beijianIds: [] as number[],
|
|
|
|
beijianIds: [] as number[],
|
|
|
|
fileUrl: undefined,
|
|
|
|
fileUrl: undefined,
|
|
|
|
|
|
|
|
qrcodeUrl: undefined,
|
|
|
|
sort: undefined,
|
|
|
|
sort: undefined,
|
|
|
|
dvId: undefined
|
|
|
|
dvId: undefined
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -376,8 +426,19 @@ const initFormData = () => ({
|
|
|
|
const formData = ref({
|
|
|
|
const formData = ref({
|
|
|
|
...initFormData()
|
|
|
|
...initFormData()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const validateDeviceCode = (_rule, value, callback) => {
|
|
|
|
|
|
|
|
if (Boolean(formData.value.isCode)) {
|
|
|
|
|
|
|
|
callback()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value === undefined || value === null || String(value).trim() === '') {
|
|
|
|
|
|
|
|
callback(new Error(t('EquipmentManagement.EquipmentLedger.validatorDeviceCodeRequired')))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
callback()
|
|
|
|
|
|
|
|
}
|
|
|
|
const formRules = reactive<FormRules>({
|
|
|
|
const formRules = reactive<FormRules>({
|
|
|
|
deviceCode: [{ required: true, message: t('EquipmentManagement.EquipmentLedger.placeholderDeviceCode'), trigger: 'blur' }],
|
|
|
|
deviceCode: [{ validator: validateDeviceCode, trigger: ['blur', 'change'] }],
|
|
|
|
deviceName: [{ required: true, message: t('EquipmentManagement.EquipmentLedger.placeholderDeviceName'), trigger: 'blur' }],
|
|
|
|
deviceName: [{ required: true, message: t('EquipmentManagement.EquipmentLedger.placeholderDeviceName'), trigger: 'blur' }],
|
|
|
|
deviceType: [{ required: true, message: t('EquipmentManagement.EquipmentLedger.placeholderDeviceType'), trigger: 'change' }],
|
|
|
|
deviceType: [{ required: true, message: t('EquipmentManagement.EquipmentLedger.placeholderDeviceType'), trigger: 'change' }],
|
|
|
|
productionDate: [{ required: true, message: t('EquipmentManagement.EquipmentLedger.placeholderProductionDate'), trigger: 'change' }],
|
|
|
|
productionDate: [{ required: true, message: t('EquipmentManagement.EquipmentLedger.placeholderProductionDate'), trigger: 'change' }],
|
|
|
|
@ -446,6 +507,31 @@ const confirmBeijianDialog = () => {
|
|
|
|
beijianDialogVisible.value = false
|
|
|
|
beijianDialogVisible.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleCodeAutoChange = (value: boolean) => {
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
|
|
|
formData.value.deviceCode = undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
formRef.value?.clearValidate('deviceCode')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleRegenerateCode = async () => {
|
|
|
|
|
|
|
|
if (!formData.value.id || !formData.value.deviceCode) return
|
|
|
|
|
|
|
|
regenerateCodeLoading.value = true
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const data = await DeviceLedgerApi.regenerateCode(formData.value.id, formData.value.deviceCode)
|
|
|
|
|
|
|
|
if (data?.qrcodeUrl) {
|
|
|
|
|
|
|
|
formData.value.qrcodeUrl = data.qrcodeUrl
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const detail = await DeviceLedgerApi.getDeviceLedger(formData.value.id)
|
|
|
|
|
|
|
|
formData.value.qrcodeUrl = detail?.qrcodeUrl
|
|
|
|
|
|
|
|
formData.value.deviceCode = detail?.deviceCode ?? formData.value.deviceCode
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
regenerateCodeLoading.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ensureOptionsLoaded = async () => {
|
|
|
|
const ensureOptionsLoaded = async () => {
|
|
|
|
const [deviceTypeRes, userRes, criticalRes, beijianRes] = await Promise.all([
|
|
|
|
const [deviceTypeRes, userRes, criticalRes, beijianRes] = await Promise.all([
|
|
|
|
DeviceTypeApi.getDeviceTypeTree({ pageNo: 1, pageSize: 10 }),
|
|
|
|
DeviceTypeApi.getDeviceTypeTree({ pageNo: 1, pageSize: 10 }),
|
|
|
|
@ -487,12 +573,14 @@ const open = async (type: string, id?: number, defaultDeviceTypeId?: number) =>
|
|
|
|
formData.value = {
|
|
|
|
formData.value = {
|
|
|
|
...initFormData(),
|
|
|
|
...initFormData(),
|
|
|
|
...(detail as any),
|
|
|
|
...(detail as any),
|
|
|
|
|
|
|
|
isCode: (detail as any)?.isCode ?? false,
|
|
|
|
deviceType: normalizeNumberish((detail as any)?.deviceType),
|
|
|
|
deviceType: normalizeNumberish((detail as any)?.deviceType),
|
|
|
|
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
|
|
|
|
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
|
|
|
|
productionDate: normalizeYmd((detail as any)?.productionDate),
|
|
|
|
productionDate: normalizeYmd((detail as any)?.productionDate),
|
|
|
|
factoryEntryDate: normalizeYmd((detail as any)?.factoryEntryDate),
|
|
|
|
factoryEntryDate: normalizeYmd((detail as any)?.factoryEntryDate),
|
|
|
|
componentIds: parseIdsValue((detail as any)?.componentId),
|
|
|
|
componentIds: parseIdsValue((detail as any)?.componentId),
|
|
|
|
beijianIds: parseIdsValue((detail as any)?.beijianId),
|
|
|
|
beijianIds: parseIdsValue((detail as any)?.beijianId),
|
|
|
|
|
|
|
|
qrcodeUrl: (detail as any)?.qrcodeUrl,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
formLoading.value = false
|
|
|
|
formLoading.value = false
|
|
|
|
@ -605,4 +693,47 @@ const resetForm = () => {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.device-ledger-qrcode-wrap {
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
height: 150px;
|
|
|
|
|
|
|
|
width: fit-content;
|
|
|
|
|
|
|
|
min-width: 150px;
|
|
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
border: 1px solid var(--el-border-color-lighter);
|
|
|
|
|
|
|
|
background: var(--el-fill-color-blank);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.device-ledger-qrcode-img {
|
|
|
|
|
|
|
|
height: 150px;
|
|
|
|
|
|
|
|
width: auto;
|
|
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.device-ledger-qrcode-error {
|
|
|
|
|
|
|
|
height: 150px;
|
|
|
|
|
|
|
|
min-width: 150px;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
color: var(--el-text-color-secondary);
|
|
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
|
|
padding: 0 12px;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.device-ledger-qrcode-mask {
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
inset: 0;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
background: rgba(0, 0, 0, 0.35);
|
|
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
|
|
transition: opacity 0.2s ease;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.device-ledger-qrcode-wrap:hover .device-ledger-qrcode-mask {
|
|
|
|
|
|
|
|
opacity: 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|
|