批量导入被检设备
This commit is contained in:
@@ -31,33 +31,33 @@ export const deletePqDev = (params: string[]) => {
|
|||||||
|
|
||||||
// //导入被检设备(比对)
|
// //导入被检设备(比对)
|
||||||
// export const importPqDev=(params: Device.ReqPqDevParams)=>{
|
// export const importPqDev=(params: Device.ReqPqDevParams)=>{
|
||||||
// return http.upload(`/pqDev/import`, params)
|
// return http.upload(`/pqDev/import`, params)
|
||||||
// }
|
// }
|
||||||
// //导入比对式被检设备
|
// //导入比对式被检设备
|
||||||
// export const importContrastPqDev=(params: Device.ReqPqDevParams)=>{
|
// export const importContrastPqDev=(params: Device.ReqPqDevParams)=>{
|
||||||
// return http.upload(`/pqDev/importContrast`, params)
|
// return http.upload(`/pqDev/importContrast`, params)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//导出灿能二楼设备
|
//导出灿能二楼设备
|
||||||
export const exportCNDev=(params: Device.ReqPqDevParams)=>{
|
export const exportCNDev = (params: Device.ReqPqDevParams) => {
|
||||||
return http.download(`/pqDev/exportCNDev`, params)
|
return http.download(`/pqDev/exportCNDev`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载灿能二楼设备导入文件模板
|
// 下载灿能二楼设备导入文件模板
|
||||||
export const downloadCNDevTemplate = () => {
|
export const downloadCNDevTemplate = () => {
|
||||||
return http.download(`/pqDev/downloadCNDevTemplate`)
|
return http.download(`/pqDev/downloadCNDevTemplate`)
|
||||||
}
|
}
|
||||||
|
|
||||||
//导入灿能二楼设备
|
//导入灿能二楼设备
|
||||||
export const importCNDev=(params: Device.ReqPqDevParams)=>{
|
export const importCNDev = (params: Device.ReqPqDevParams) => {
|
||||||
return http.upload(`/pqDev/importCNDev`, params)
|
return http.uploadExcel(`/pqDev/importCNDev`, params)
|
||||||
}
|
}
|
||||||
//根据设备类型决定(电源、icd、模板、通道数、额定电压、额定电流);
|
//根据设备类型决定(电源、icd、模板、通道数、额定电压、额定电流);
|
||||||
export const getPqDev = () => {
|
export const getPqDev = () => {
|
||||||
return http.post(`/devType/list`)
|
return http.post(`/devType/list`)
|
||||||
}
|
}
|
||||||
|
|
||||||
//被检设备归档
|
//被检设备归档
|
||||||
export const documentedPqDev=(ids:string[])=>{
|
export const documentedPqDev = (ids: string[]) => {
|
||||||
return http.post(`/pqDev/documented`, ids)
|
return http.post(`/pqDev/documented`, ids)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class RequestHttp {
|
|||||||
config.loading ?? (config.loading = true)
|
config.loading ?? (config.loading = true)
|
||||||
config.loading && showFullScreenLoading()
|
config.loading && showFullScreenLoading()
|
||||||
if (config.headers && typeof config.headers.set === 'function') {
|
if (config.headers && typeof config.headers.set === 'function') {
|
||||||
config.headers.set('Authorization', 'Bearer '+userStore.token)
|
config.headers.set('Authorization', 'Bearer ' + userStore.token)
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
@@ -63,7 +63,7 @@ class RequestHttp {
|
|||||||
// 登陆失效
|
// 登陆失效
|
||||||
if (data.code == ResultEnum.OVERDUE) {
|
if (data.code == ResultEnum.OVERDUE) {
|
||||||
userStore.setToken('')
|
userStore.setToken('')
|
||||||
userStore.setUserInfo({name: ''})
|
userStore.setUserInfo({ name: '' })
|
||||||
router.replace(LOGIN_URL)
|
router.replace(LOGIN_URL)
|
||||||
ElMessage.error(data.message)
|
ElMessage.error(data.message)
|
||||||
return Promise.reject(data)
|
return Promise.reject(data)
|
||||||
@@ -115,9 +115,24 @@ class RequestHttp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
upload(url: string, params?: object, _object = {}): Promise<BlobPart> {
|
upload(url: string, params?: object, _object = {}): Promise<BlobPart> {
|
||||||
return this.service.post(url, params, { ..._object, headers: { 'Content-Type': 'multipart/form-data' } })
|
return this.service.post(url, params, {
|
||||||
|
..._object,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 针对excel的上传,默认返回的是blob类型,Excel没问题时返回json特殊处理
|
||||||
|
*/
|
||||||
|
uploadExcel(url: string, params?: object, _object = {}): Promise<BlobPart> {
|
||||||
|
return this.service.post(url, params, {
|
||||||
|
..._object,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
responseType: 'blob',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new RequestHttp(config)
|
export default new RequestHttp(config)
|
||||||
|
|||||||
@@ -1,49 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="dialogVisible" :title="`批量添加${parameter.title}`" :destroy-on-close="true" width="580px" draggable>
|
<el-dialog v-model='dialogVisible' :title='`批量添加${parameter.title}`' :destroy-on-close='true' width='580px'
|
||||||
<el-form class="drawer-multiColumn-form" label-width="100px">
|
draggable>
|
||||||
<el-form-item label="模板下载 :">
|
<el-form class='drawer-multiColumn-form' label-width='100px'>
|
||||||
<el-button type="primary" :icon="Download" @click="downloadTemp"> 点击下载 </el-button>
|
<el-form-item label='模板下载 :'>
|
||||||
|
<el-button type='primary' :icon='Download' @click='downloadTemp'> 点击下载</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="文件上传 :">
|
<el-form-item label='文件上传 :'>
|
||||||
<el-upload
|
<el-upload
|
||||||
action="#"
|
action='#'
|
||||||
class="upload"
|
class='upload'
|
||||||
:drag="true"
|
:drag='true'
|
||||||
:limit="excelLimit"
|
:limit='excelLimit'
|
||||||
:multiple="true"
|
:multiple='true'
|
||||||
:show-file-list="true"
|
:show-file-list='true'
|
||||||
:http-request="uploadExcel"
|
:http-request='uploadExcel'
|
||||||
:before-upload="beforeExcelUpload"
|
:before-upload='beforeExcelUpload'
|
||||||
:on-exceed="handleExceed"
|
:on-exceed='handleExceed'
|
||||||
:on-success="excelUploadSuccess"
|
|
||||||
:on-error="excelUploadError"
|
|
||||||
:accept="parameter.fileType!.join(',')"
|
:accept="parameter.fileType!.join(',')"
|
||||||
>
|
>
|
||||||
<slot name="empty">
|
<slot name='empty'>
|
||||||
<el-icon class="el-icon--upload">
|
<el-icon class='el-icon--upload'>
|
||||||
<upload-filled />
|
<upload-filled />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<div class='el-upload__text'>将文件拖到此处,或<em>点击上传</em></div>
|
||||||
</slot>
|
</slot>
|
||||||
<template #tip>
|
<template #tip>
|
||||||
<slot name="tip">
|
<slot name='tip'>
|
||||||
<div class="el-upload__tip">请上传 .xls , .xlsx 标准格式文件,文件最大为 {{ parameter.fileSize }}M</div>
|
<div class='el-upload__tip'>请上传 .xls , .xlsx 标准格式文件,文件最大为 {{ parameter.fileSize }}M</div>
|
||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="parameter.showCover" label="数据覆盖 :">
|
<el-form-item v-if='parameter.showCover' label='数据覆盖 :'>
|
||||||
<el-switch v-model="isCover" />
|
<el-switch v-model='isCover' />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="ImportExcel">
|
<script setup lang='ts' name='ImportExcel'>
|
||||||
import { ref } from "vue";
|
import { ref } from 'vue'
|
||||||
import { useDownload } from "@/hooks/useDownload";
|
import { useDownload } from '@/hooks/useDownload'
|
||||||
import { Download } from "@element-plus/icons-vue";
|
import { Download } from '@element-plus/icons-vue'
|
||||||
import { ElNotification, UploadRequestOptions, UploadRawFile, ElMessage } from "element-plus";
|
import { ElNotification, UploadRequestOptions, UploadRawFile, ElMessage } from 'element-plus'
|
||||||
|
|
||||||
export interface ExcelParameterProps {
|
export interface ExcelParameterProps {
|
||||||
title: string; // 标题
|
title: string; // 标题
|
||||||
@@ -57,78 +56,73 @@ export interface ExcelParameterProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 是否覆盖数据
|
// 是否覆盖数据
|
||||||
const isCover = ref(false);
|
const isCover = ref(false)
|
||||||
// 最大文件上传数
|
// 最大文件上传数
|
||||||
const excelLimit = ref(1);
|
const excelLimit = ref(1)
|
||||||
// dialog状态
|
// dialog状态
|
||||||
const dialogVisible = ref(false);
|
const dialogVisible = ref(false)
|
||||||
// 父组件传过来的参数
|
// 父组件传过来的参数
|
||||||
const parameter = ref<ExcelParameterProps>({
|
const parameter = ref<ExcelParameterProps>({
|
||||||
title: "",
|
title: '',
|
||||||
fileSize: 5,
|
fileSize: 5,
|
||||||
fileType: ["application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]
|
fileType: ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||||
});
|
})
|
||||||
|
|
||||||
// 接收父组件参数
|
// 接收父组件参数
|
||||||
const acceptParams = (params: ExcelParameterProps) => {
|
const acceptParams = (params: ExcelParameterProps) => {
|
||||||
parameter.value = { ...parameter.value, ...params };
|
parameter.value = { ...parameter.value, ...params }
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true
|
||||||
};
|
}
|
||||||
|
|
||||||
// Excel 导入模板下载
|
// Excel 导入模板下载
|
||||||
const downloadTemp = () => {
|
const downloadTemp = () => {
|
||||||
if (!parameter.value.tempApi) return;
|
if (!parameter.value.tempApi) return
|
||||||
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`,{},false);
|
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`, {}, false)
|
||||||
};
|
}
|
||||||
|
|
||||||
// 文件上传
|
// 文件上传
|
||||||
const uploadExcel = async (param: UploadRequestOptions) => {
|
const uploadExcel = async (param: UploadRequestOptions) => {
|
||||||
let excelFormData = new FormData();
|
let excelFormData = new FormData()
|
||||||
excelFormData.append("file", param.file);
|
excelFormData.append('file', param.file)
|
||||||
if(parameter.value.patternId){
|
if (parameter.value.patternId) {
|
||||||
excelFormData.append("patternId",parameter.value.patternId)
|
excelFormData.append('patternId', parameter.value.patternId)
|
||||||
}
|
}
|
||||||
isCover.value && excelFormData.append("isCover", isCover.value as unknown as Blob);
|
isCover.value && excelFormData.append('isCover', isCover.value as unknown as Blob)
|
||||||
//await parameter.value.importApi!(excelFormData);
|
//await parameter.value.importApi!(excelFormData);
|
||||||
await parameter.value.importApi!(excelFormData)
|
await parameter.value.importApi!(excelFormData)
|
||||||
.then(res => handleImportResponse( res))
|
.then(res => handleImportResponse(res))
|
||||||
parameter.value.getTableList && parameter.value.getTableList();
|
parameter.value.getTableList && parameter.value.getTableList()
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function handleImportResponse(res: any) {
|
||||||
|
if (res.type === 'application/json') {
|
||||||
async function handleImportResponse( res: any) {
|
const fileReader = new FileReader()
|
||||||
//console.log('res1', res.type);
|
fileReader.onloadend = () => {
|
||||||
if (res.type === 'application/json') {
|
try {
|
||||||
//console.log('res2', res);
|
const jsonData = JSON.parse(fileReader.result)
|
||||||
const fileReader = new FileReader()
|
if (jsonData.code === 'A0000') {
|
||||||
fileReader.onloadend = () => {
|
ElMessage.success('导入成功')
|
||||||
try {
|
} else {
|
||||||
const jsonData = JSON.parse(fileReader.result)
|
ElMessage.error(jsonData.message)
|
||||||
// console.log('123',jsonData)
|
|
||||||
if (jsonData.code === 'A0000') {
|
|
||||||
ElMessage.success('导入成功')
|
|
||||||
} else {
|
|
||||||
//ElMessage.error('导入失败,请查看下载附件!')
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fileReader.readAsText(res)
|
} catch (err) {
|
||||||
} else {
|
console.log(err)
|
||||||
//ElMessage.error('导入失败,请查看下载附件!')
|
}
|
||||||
// let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
|
|
||||||
// const url = window.URL.createObjectURL(blob)
|
|
||||||
// const link = document.createElement('a')
|
|
||||||
// link.href = url
|
|
||||||
// link.download = '终端入网检测失败列表'
|
|
||||||
// document.body.appendChild(link)
|
|
||||||
// link.click()
|
|
||||||
// link.remove()
|
|
||||||
}
|
}
|
||||||
|
fileReader.readAsText(res)
|
||||||
|
} else {
|
||||||
|
ElMessage.error('导入失败,请查看下载附件!')
|
||||||
|
let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = '终端入网检测失败列表'
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
link.remove()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,56 +130,56 @@ async function handleImportResponse( res: any) {
|
|||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* */
|
* */
|
||||||
const beforeExcelUpload = (file: UploadRawFile) => {
|
const beforeExcelUpload = (file: UploadRawFile) => {
|
||||||
const isExcel = parameter.value.fileType!.includes(file.type as File.ExcelMimeType);
|
const isExcel = parameter.value.fileType!.includes(file.type as File.ExcelMimeType)
|
||||||
const fileSize = file.size / 1024 / 1024 < parameter.value.fileSize!;
|
const fileSize = file.size / 1024 / 1024 < parameter.value.fileSize!
|
||||||
if (!isExcel)
|
if (!isExcel)
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: "温馨提示",
|
title: '温馨提示',
|
||||||
message: "上传文件只能是 xls / xlsx 格式!",
|
message: '上传文件只能是 xls / xlsx 格式!',
|
||||||
type: "warning"
|
type: 'warning',
|
||||||
});
|
})
|
||||||
if (!fileSize)
|
if (!fileSize)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: "温馨提示",
|
title: '温馨提示',
|
||||||
message: `上传文件大小不能超过 ${parameter.value.fileSize}MB!`,
|
message: `上传文件大小不能超过 ${parameter.value.fileSize}MB!`,
|
||||||
type: "warning"
|
type: 'warning',
|
||||||
});
|
})
|
||||||
}, 0);
|
}, 0)
|
||||||
return isExcel && fileSize;
|
return isExcel && fileSize
|
||||||
};
|
}
|
||||||
|
|
||||||
// 文件数超出提示
|
// 文件数超出提示
|
||||||
const handleExceed = () => {
|
const handleExceed = () => {
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: "温馨提示",
|
title: '温馨提示',
|
||||||
message: "最多只能上传一个文件!",
|
message: '最多只能上传一个文件!',
|
||||||
type: "warning"
|
type: 'warning',
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
// 上传错误提示
|
// 上传错误提示
|
||||||
const excelUploadError = () => {
|
// const excelUploadError = () => {
|
||||||
ElNotification({
|
// ElNotification({
|
||||||
title: "温馨提示",
|
// title: '温馨提示',
|
||||||
message: `批量添加${parameter.value.title}失败,请您重新上传!`,
|
// message: `批量添加${parameter.value.title}失败,请您重新上传!`,
|
||||||
type: "error"
|
// type: 'error',
|
||||||
});
|
// })
|
||||||
};
|
// }
|
||||||
|
|
||||||
// 上传成功提示
|
// 上传成功提示
|
||||||
const excelUploadSuccess = () => {
|
// const excelUploadSuccess = () => {
|
||||||
ElNotification({
|
// ElNotification({
|
||||||
title: "温馨提示",
|
// title: '温馨提示',
|
||||||
message: `批量添加${parameter.value.title}成功!`,
|
// message: `批量添加${parameter.value.title}成功!`,
|
||||||
type: "success"
|
// type: 'success',
|
||||||
});
|
// })
|
||||||
};
|
// }
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
acceptParams
|
acceptParams,
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang='scss' scoped>
|
||||||
@import "./index.scss";
|
@import "./index.scss";
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -10,8 +10,12 @@
|
|||||||
<template #tableHeader='scope'>
|
<template #tableHeader='scope'>
|
||||||
<el-button v-auth.device="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
<el-button v-auth.device="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||||
<el-button v-auth.device="'export'" type='primary' :icon='Upload' plain @click='downloadFile()'>导出</el-button>
|
<el-button v-auth.device="'export'" type='primary' :icon='Upload' plain @click='downloadFile()'>导出</el-button>
|
||||||
<el-button v-auth.device="'import'" type='primary' :icon='Download' plain @click="importFile('')" v-if='modeStore.currentMode != "比对式"'>导入</el-button>
|
<el-button v-auth.device="'import'" type='primary' :icon='Download' plain @click="importFile('')"
|
||||||
<el-button v-auth.device="'import'" type='primary' :icon='Download' plain @click="importFile('比对式')" v-if='modeStore.currentMode === "比对式"'>导入</el-button>
|
v-if='modeStore.currentMode != "比对式"'>导入
|
||||||
|
</el-button>
|
||||||
|
<el-button v-auth.device="'import'" type='primary' :icon='Download' plain @click="importFile('比对式')"
|
||||||
|
v-if='modeStore.currentMode === "比对式"'>导入
|
||||||
|
</el-button>
|
||||||
<el-button v-auth.device="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
<el-button v-auth.device="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||||
@click='batchDelete(scope.selectedListIds)'>
|
@click='batchDelete(scope.selectedListIds)'>
|
||||||
删除
|
删除
|
||||||
@@ -19,8 +23,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<!-- 表格操作 -->
|
<!-- 表格操作 -->
|
||||||
<template #operation='scope'>
|
<template #operation='scope'>
|
||||||
<el-button v-auth.device="'edit'" type='primary' link :icon='EditPen' :model-value="false" @click="openDialog('edit', scope.row)">编辑</el-button>
|
<el-button v-auth.device="'edit'" type='primary' link :icon='EditPen' :model-value='false'
|
||||||
<el-button v-auth.device="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
@click="openDialog('edit', scope.row)">编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button v-auth.device="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</ProTable>
|
</ProTable>
|
||||||
@@ -40,28 +47,36 @@ import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/i
|
|||||||
import DevicePopup from '@/views/machine/device/components/devicePopup.vue'
|
import DevicePopup from '@/views/machine/device/components/devicePopup.vue'
|
||||||
import { CirclePlus, Delete, EditPen, Download, Upload } from '@element-plus/icons-vue'
|
import { CirclePlus, Delete, EditPen, Download, Upload } from '@element-plus/icons-vue'
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import {getPqDevList, deletePqDev, getPqDev, exportCNDev, downloadCNDevTemplate, importCNDev} from '@/api/device/device/index.ts'
|
import {
|
||||||
|
getPqDevList,
|
||||||
|
deletePqDev,
|
||||||
|
getPqDev,
|
||||||
|
exportCNDev,
|
||||||
|
downloadCNDevTemplate,
|
||||||
|
importCNDev,
|
||||||
|
} from '@/api/device/device/index.ts'
|
||||||
import { ElMessageBox } from 'element-plus'
|
import { ElMessageBox } from 'element-plus'
|
||||||
import { computed, onBeforeMount, onMounted, reactive, ref } from 'vue'
|
import { onBeforeMount, reactive, ref } from 'vue'
|
||||||
import { useModeStore , useAppSceneStore} from '@/stores/modules/mode';
|
import { useModeStore, useAppSceneStore } from '@/stores/modules/mode'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'device'
|
name: 'device',
|
||||||
})
|
})
|
||||||
const modeStore = useModeStore();
|
const modeStore = useModeStore()
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
const appSceneStore = useAppSceneStore()
|
const appSceneStore = useAppSceneStore()
|
||||||
// ProTable 实例
|
// ProTable 实例
|
||||||
const proTable = ref<ProTableInstance>()
|
const proTable = ref<ProTableInstance>()
|
||||||
const devicePopup = ref()
|
const devicePopup = ref()
|
||||||
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
|
const boundPqDevList = ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||||
// 存储设备类型选项
|
// 存储设备类型选项
|
||||||
const devTypeOptions = ref<Device.ResDev[]>([])
|
const devTypeOptions = ref<Device.ResDev[]>([])
|
||||||
|
|
||||||
const getTableList = async (params: any) => {
|
const getTableList = async (params: any) => {
|
||||||
let newParams = JSON.parse(JSON.stringify(params))
|
let newParams = JSON.parse(JSON.stringify(params))
|
||||||
newParams.searchEndTime = endDate.value
|
newParams.searchEndTime = endDate.value
|
||||||
newParams.searchBeginTime = startDate.value
|
newParams.searchBeginTime = startDate.value
|
||||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||||
newParams.pattern = patternId
|
newParams.pattern = patternId
|
||||||
return getPqDevList(newParams)
|
return getPqDevList(newParams)
|
||||||
}
|
}
|
||||||
@@ -87,7 +102,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
render: (scope) => {
|
render: (scope) => {
|
||||||
// 查找设备类型名称
|
// 查找设备类型名称
|
||||||
const name = devTypeOptions.value.find(option => option.id === scope.row.devType);
|
const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
||||||
return <span>{name?.name}</span>
|
return <span>{name?.name}</span>
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -97,18 +112,18 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
isShow: appSceneStore.currentScene === '0',
|
isShow: appSceneStore.currentScene === '0',
|
||||||
...(appSceneStore.currentScene === '0' ? {
|
...(appSceneStore.currentScene === '0' ? {
|
||||||
search: {
|
search: {
|
||||||
render: () => {
|
render: () => {
|
||||||
return (
|
return (
|
||||||
<div class='flx-flex-start'>
|
<div class='flx-flex-start'>
|
||||||
<TimeControl
|
<TimeControl
|
||||||
default={'月'}
|
default={'月'}
|
||||||
onUpdate-dates={handleDateChange}
|
onUpdate-dates={handleDateChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
} : {}),
|
} : {}),
|
||||||
// search: {
|
// search: {
|
||||||
// span: 2,
|
// span: 2,
|
||||||
@@ -166,47 +181,46 @@ const handleDateChange = (startDateTemp: string, endDateTemp: string) => {
|
|||||||
}
|
}
|
||||||
// 打开 drawer(新增、编辑)
|
// 打开 drawer(新增、编辑)
|
||||||
const openDialog = (titleType: string, row: Partial<Device.ResPqDev> = {}) => {
|
const openDialog = (titleType: string, row: Partial<Device.ResPqDev> = {}) => {
|
||||||
devicePopup.value?.open(titleType, row,modeStore.currentMode,appSceneStore.currentScene,devTypeOptions.value)
|
devicePopup.value?.open(titleType, row, modeStore.currentMode, appSceneStore.currentScene, devTypeOptions.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 批量删除设备
|
// 批量删除设备
|
||||||
const batchDelete = async (id: string[]) => {
|
const batchDelete = async (id: string[]) => {
|
||||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
|
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
|
||||||
await useHandleData(deletePqDev, {'ids':id,'pattern': patternId} , '删除所选设备')
|
await useHandleData(deletePqDev, { 'ids': id, 'pattern': patternId }, '删除所选设备')
|
||||||
proTable.value?.clearSelection()
|
proTable.value?.clearSelection()
|
||||||
proTable.value?.getTableList()
|
proTable.value?.getTableList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除设备
|
// 删除设备
|
||||||
const handleDelete = async (params: Device.ResPqDev) => {
|
const handleDelete = async (params: Device.ResPqDev) => {
|
||||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||||
await useHandleData(deletePqDev, {'ids': [params.id] ,'pattern': patternId}, `删除【${params.name}】设备`)
|
await useHandleData(deletePqDev, { 'ids': [params.id], 'pattern': patternId }, `删除【${params.name}】设备`)
|
||||||
proTable.value?.getTableList()
|
proTable.value?.getTableList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出设备
|
// 导出设备
|
||||||
const downloadFile = async () => {
|
const downloadFile = async () => {
|
||||||
// 获取当前的搜索参数
|
// 获取当前的搜索参数
|
||||||
const searchParam = proTable.value?.searchParam || {};
|
const searchParam = proTable.value?.searchParam || {}
|
||||||
|
|
||||||
// 将开始时间和结束时间添加到搜索参数中
|
// 将开始时间和结束时间添加到搜索参数中
|
||||||
searchParam.searchBeginTime = startDate.value;
|
searchParam.searchBeginTime = startDate.value
|
||||||
searchParam.searchEndTime = endDate.value;
|
searchParam.searchEndTime = endDate.value
|
||||||
|
|
||||||
ElMessageBox.confirm('确认导出被检设备?', '温馨提示', { type: 'warning' }).then(() =>{
|
ElMessageBox.confirm('确认导出被检设备?', '温馨提示', { type: 'warning' }).then(() => {
|
||||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||||
useDownload(exportCNDev,'被检设备导出数据', {...proTable.value?.searchParam,pattern:patternId}, false,'.xlsx')
|
useDownload(exportCNDev, '被检设备导出数据', { ...proTable.value?.searchParam, pattern: patternId }, false, '.xlsx')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//导入设备
|
//导入设备
|
||||||
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||||
|
|
||||||
const importFile = async (pattern:string) => {
|
const importFile = async (pattern: string) => {
|
||||||
|
|
||||||
if(pattern === '比对式'){
|
if (pattern === '比对式') {
|
||||||
// const params = {
|
// const params = {
|
||||||
// title: '被检设备',
|
// title: '被检设备',
|
||||||
// showCover: false,
|
// showCover: false,
|
||||||
@@ -215,34 +229,32 @@ const importFile = async (pattern:string) => {
|
|||||||
// getTableList: proTable.value?.getTableList,
|
// getTableList: proTable.value?.getTableList,
|
||||||
// }
|
// }
|
||||||
// deviceImportExcel.value?.acceptParams(params)
|
// deviceImportExcel.value?.acceptParams(params)
|
||||||
}else{
|
} else {
|
||||||
const params = {
|
const params = {
|
||||||
title: '被检设备',
|
title: '被检设备',
|
||||||
showCover: false,
|
showCover: false,
|
||||||
patternId: dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id,
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id,
|
||||||
tempApi: downloadCNDevTemplate,
|
tempApi: downloadCNDevTemplate,
|
||||||
importApi: importCNDev,
|
importApi: importCNDev,
|
||||||
// importApi: modeStore.currentMode === "比对式"? importContrastPqDev: importCNDev,
|
// importApi: modeStore.currentMode === "比对式"? importContrastPqDev: importCNDev,
|
||||||
getTableList: proTable.value?.getTableList,
|
getTableList: proTable.value?.getTableList,
|
||||||
}
|
}
|
||||||
deviceImportExcel.value?.acceptParams(params)
|
deviceImportExcel.value?.acceptParams(params)
|
||||||
|
|
||||||
console.log(params)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
const response = await getPqDev()
|
const response = await getPqDev()
|
||||||
devTypeOptions.value = (response.data as Device.ResDev[]).map(item => ({
|
devTypeOptions.value = (response.data as Device.ResDev[]).map(item => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
icd: item.icd,
|
icd: item.icd,
|
||||||
power: item.power,
|
power: item.power,
|
||||||
devVolt: item.devVolt,
|
devVolt: item.devVolt,
|
||||||
devCurr: item.devCurr,
|
devCurr: item.devCurr,
|
||||||
devChns: item.devChns
|
devChns: item.devChns,
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Reference in New Issue
Block a user