icd映射文件
This commit is contained in:
@@ -20,12 +20,12 @@ export const getICDAllList = (params: ICD.ResICD) => {
|
|||||||
|
|
||||||
//添加ICD
|
//添加ICD
|
||||||
export const addICD = (params: ICD.ResICD) => {
|
export const addICD = (params: ICD.ResICD) => {
|
||||||
return http.post(`/icd/add`, params)
|
return http.upload(`/icd/add`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
//编辑ICD
|
//编辑ICD
|
||||||
export const updateICD = (params: ICD.ResICD) => {
|
export const updateICD = (params: ICD.ResICD) => {
|
||||||
return http.post(`/icd/update`, params)
|
return http.upload(`/icd/update`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除ICD
|
//删除ICD
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export namespace ICD {
|
|||||||
updateTime?: string| null; //更新时间
|
updateTime?: string| null; //更新时间
|
||||||
angle: number; // 是否支持电压相角、电流相角指标
|
angle: number; // 是否支持电压相角、电流相角指标
|
||||||
usePhaseIndex: number; // 角型接线时是否使用相别的指标来进行检测
|
usePhaseIndex: number; // 角型接线时是否使用相别的指标来进行检测
|
||||||
|
mappingFile: string | null;//映射文件
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -278,7 +278,6 @@ const open = async (
|
|||||||
pairs.value = pair
|
pairs.value = pair
|
||||||
showSteps.value = true
|
showSteps.value = true
|
||||||
initOperate()
|
initOperate()
|
||||||
dialogTitle.value = title
|
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
|
|
||||||
// 等待组件渲染完成
|
// 等待组件渲染完成
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ const planIdKey = ref<string>('')
|
|||||||
const deviceMonitor = ref<Map<string, any[]>>();
|
const deviceMonitor = ref<Map<string, any[]>>();
|
||||||
const planIsOnlyWave = ref(false)
|
const planIsOnlyWave = ref(false)
|
||||||
const open = async (
|
const open = async (
|
||||||
|
title: string,
|
||||||
device: Device.ResPqDev[],
|
device: Device.ResPqDev[],
|
||||||
standardDev: StandardDevice.ResPqStandardDevice[],
|
standardDev: StandardDevice.ResPqStandardDevice[],
|
||||||
fatherPlanId: string,
|
fatherPlanId: string,
|
||||||
@@ -223,6 +223,7 @@ const open = async (
|
|||||||
checkType: string,
|
checkType: string,
|
||||||
isOnlyWave:boolean
|
isOnlyWave:boolean
|
||||||
) => {
|
) => {
|
||||||
|
dialogTitle.value = title
|
||||||
planIsOnlyWave.value = isOnlyWave
|
planIsOnlyWave.value = isOnlyWave
|
||||||
CompareTestVisible.value = false
|
CompareTestVisible.value = false
|
||||||
devIdList.value = device
|
devIdList.value = device
|
||||||
|
|||||||
@@ -845,8 +845,9 @@ const handleTest2 = async (val: string) => {
|
|||||||
|
|
||||||
// 检查数组长度是否为1且唯一元素是'wave_data'
|
// 检查数组长度是否为1且唯一元素是'wave_data'
|
||||||
const isOnlyWave = targetPlan.datasourceIds.length === 1 && targetPlan.datasourceIds[0] === 'wave_data'
|
const isOnlyWave = targetPlan.datasourceIds.length === 1 && targetPlan.datasourceIds[0] === 'wave_data'
|
||||||
|
dialogTitle.value = val
|
||||||
deviceConnectionPopupRef.value?.open(
|
deviceConnectionPopupRef.value?.open(
|
||||||
|
dialogTitle.value,
|
||||||
filteredChannelsSelection,
|
filteredChannelsSelection,
|
||||||
pqStandardDevList.value,
|
pqStandardDevList.value,
|
||||||
props.id,
|
props.id,
|
||||||
|
|||||||
@@ -14,6 +14,23 @@
|
|||||||
show-word-limit
|
show-word-limit
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="映射文件" prop="mappingFile">
|
||||||
|
<el-upload
|
||||||
|
action="#"
|
||||||
|
:limit="1"
|
||||||
|
:on-change='MappingHandleChange'
|
||||||
|
:auto-upload="false"
|
||||||
|
:file-list="mappingFileList"
|
||||||
|
:on-exceed="MappingHandleExceed"
|
||||||
|
:on-remove="MappingHandleRemove"
|
||||||
|
style="width: 100% !important;"
|
||||||
|
accept=".txt"
|
||||||
|
class="upload-container"
|
||||||
|
>
|
||||||
|
<el-button type="primary">选择文件</el-button>
|
||||||
|
</el-upload>
|
||||||
|
仅支持上传大小不超过1MB的.txt文件
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="是否支持电压相角、电流相角指标" prop="angle" label-width="auto">
|
<el-form-item label="是否支持电压相角、电流相角指标" prop="angle" label-width="auto">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="formContent.angle"
|
v-model="formContent.angle"
|
||||||
@@ -46,7 +63,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ElMessage, type FormInstance, type FormItemRule } from 'element-plus'
|
import { ElMessage, UploadFile, type FormInstance, type FormItemRule } from 'element-plus'
|
||||||
import { computed, ref, Ref } from 'vue'
|
import { computed, ref, Ref } from 'vue'
|
||||||
import { type ICD } from '@/api/device/interface/icd'
|
import { type ICD } from '@/api/device/interface/icd'
|
||||||
import { dialogSmall } from '@/utils/elementBind'
|
import { dialogSmall } from '@/utils/elementBind'
|
||||||
@@ -56,6 +73,17 @@ import { addICD, updateICD } from '@/api/device/icd'
|
|||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
// 定义弹出组件元信息
|
// 定义弹出组件元信息
|
||||||
const dialogFormRef = ref()
|
const dialogFormRef = ref()
|
||||||
|
const mappingFileName = ref('')
|
||||||
|
const mappingFileUrl = ref('')
|
||||||
|
let excelFormData = new FormData()
|
||||||
|
|
||||||
|
|
||||||
|
const mappingFileList = computed(() => {
|
||||||
|
if (mappingFileName.value && mappingFileUrl.value) {
|
||||||
|
return [{name: mappingFileName.value, url: mappingFileUrl.value}];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
function useMetaInfo() {
|
function useMetaInfo() {
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const titleType = ref('add')
|
const titleType = ref('add')
|
||||||
@@ -65,7 +93,8 @@ function useMetaInfo() {
|
|||||||
path: '',
|
path: '',
|
||||||
state: 1,
|
state: 1,
|
||||||
angle: 0,
|
angle: 0,
|
||||||
usePhaseIndex: 0
|
usePhaseIndex: 0,
|
||||||
|
mappingFile: ''
|
||||||
})
|
})
|
||||||
return { dialogVisible, titleType, formContent }
|
return { dialogVisible, titleType, formContent }
|
||||||
}
|
}
|
||||||
@@ -80,7 +109,8 @@ const resetFormContent = () => {
|
|||||||
path: '',
|
path: '',
|
||||||
state: 1,
|
state: 1,
|
||||||
angle: 0,
|
angle: 0,
|
||||||
usePhaseIndex: 0
|
usePhaseIndex: 0,
|
||||||
|
mappingFile: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,11 +123,13 @@ const formRuleRef = ref<FormInstance>()
|
|||||||
//定义校验规则
|
//定义校验规则
|
||||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||||
name: [{ required: true, message: 'icd名称必填!', trigger: 'blur' }],
|
name: [{ required: true, message: 'icd名称必填!', trigger: 'blur' }],
|
||||||
path: [{ required: true, message: 'icd存储地址必填!', trigger: 'blur' }]
|
path: [{ required: true, message: 'icd存储地址必填!', trigger: 'blur' }],
|
||||||
|
mappingFile: [{required: true, message: '请上传映射文件', trigger: 'change'}],
|
||||||
})
|
})
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
const close = () => {
|
const close = () => {
|
||||||
|
excelFormData = new FormData()
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
// 清空dialogForm中的值
|
// 清空dialogForm中的值
|
||||||
resetFormContent()
|
resetFormContent()
|
||||||
@@ -110,10 +142,27 @@ const save = () => {
|
|||||||
try {
|
try {
|
||||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
// 清空 excelFormData
|
||||||
|
excelFormData.delete('name')
|
||||||
|
excelFormData.delete('path')
|
||||||
|
excelFormData.delete('angle')
|
||||||
|
excelFormData.delete('usePhaseIndex')
|
||||||
|
|
||||||
|
excelFormData.append('name', formContent.value.name)
|
||||||
|
excelFormData.append('path', formContent.value.path)
|
||||||
|
excelFormData.append('angle', formContent.value.angle)
|
||||||
|
excelFormData.append('usePhaseIndex', formContent.value.usePhaseIndex)
|
||||||
|
|
||||||
|
let baseFileFlag = handleFileLimit(excelFormData.get('mappingFile') as File)
|
||||||
|
if (!baseFileFlag) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (formContent.value.id) {
|
if (formContent.value.id) {
|
||||||
await updateICD(formContent.value)
|
excelFormData.append('id', formContent.value.id)
|
||||||
|
await updateICD(excelFormData)
|
||||||
} else {
|
} else {
|
||||||
await addICD(formContent.value)
|
await addICD(excelFormData)
|
||||||
}
|
}
|
||||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||||
close()
|
close()
|
||||||
@@ -135,9 +184,64 @@ const open = async (sign: string, data: ICD.ResICD) => {
|
|||||||
|
|
||||||
if (data.id) {
|
if (data.id) {
|
||||||
formContent.value = { ...data }
|
formContent.value = { ...data }
|
||||||
} else {
|
formContent.value.id = data.id
|
||||||
resetFormContent()
|
// 文件信息回显
|
||||||
|
if (data.mappingFile) {
|
||||||
|
mappingFileName.value = data.mappingFile.name
|
||||||
|
mappingFileUrl.value = data.mappingFile.url
|
||||||
|
// 模拟文件列表显示
|
||||||
|
formContent.value.mappingFile = data.mappingFile.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mappingFileName.value = ''
|
||||||
|
mappingFileUrl.value = ''
|
||||||
|
resetFormContent()
|
||||||
|
// 清空 excelFormData
|
||||||
|
excelFormData = new FormData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const MappingHandleChange = async (param: UploadFile) => {
|
||||||
|
mappingFileName.value = param.name;
|
||||||
|
mappingFileUrl.value = URL.createObjectURL(param.raw as Blob);
|
||||||
|
excelFormData.append('mappingFile', param.raw as Blob, param.name);
|
||||||
|
|
||||||
|
formContent.value.mappingFile = param.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
const MappingHandleRemove = () => {
|
||||||
|
excelFormData.delete('mappingFile');
|
||||||
|
formContent.value.mappingFile = ''
|
||||||
|
};
|
||||||
|
|
||||||
|
const MappingHandleExceed = (files: File[]) => {
|
||||||
|
// 移除旧文件
|
||||||
|
excelFormData.delete('mappingFile');
|
||||||
|
// 添加新文件
|
||||||
|
if (files.length > 0) {
|
||||||
|
const newFile = files[0] as unknown as UploadFile;
|
||||||
|
mappingFileName.value = newFile.name;
|
||||||
|
excelFormData.append('mappingFile', newFile as Blob, newFile.name);
|
||||||
|
|
||||||
|
formContent.value.mappingFile = newFile.name
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileSizeLimit = 1 * 1024 * 1024; // 1MB
|
||||||
|
|
||||||
|
const handleFileLimit = (file: File) => {
|
||||||
|
if (file) {
|
||||||
|
if (file.size > fileSizeLimit) {
|
||||||
|
ElMessage.error({message: `文件大小不能超过${fileSizeLimit / 1024 / 1024}MB`});
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对外映射
|
// 对外映射
|
||||||
|
|||||||
@@ -69,6 +69,14 @@
|
|||||||
label: '存储地址',
|
label: '存储地址',
|
||||||
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
prop: 'mappingFile',
|
||||||
|
label: '映射文件路径',
|
||||||
|
minWidth: 150,
|
||||||
|
render: scope => {
|
||||||
|
return scope.row.mappingFile.url
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prop: 'createTime',
|
prop: 'createTime',
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ const BaseHandleExceed = (files: File[]) => {
|
|||||||
baseFileName.value = newFile.name;
|
baseFileName.value = newFile.name;
|
||||||
excelFormData.append('baseFile', newFile as Blob, newFile.name);
|
excelFormData.append('baseFile', newFile as Blob, newFile.name);
|
||||||
|
|
||||||
formContent.value.detailFile = newFile.name
|
formContent.value.baseFile = newFile.name
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user