ADD:添加导出子计划元信息和导入检修计划按钮逻辑
This commit is contained in:
@@ -123,3 +123,13 @@ export const getBoundStandardDevList = (params: Plan.ResPlan) => {
|
||||
export const getBoundStandardDevAllList = (params: Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getBoundStandardDev?planId=${params.id}&all=1`)
|
||||
}
|
||||
|
||||
// 导出子计划
|
||||
export const exportSubPlan = (params: Plan.ResPlan) => {
|
||||
return http.download(`/adPlan/exportSubPlan?planId=${params.id}`)
|
||||
}
|
||||
|
||||
// 导入子检测计划
|
||||
export const importSubPlan = (params: Device.ReqPqDevParams) => {
|
||||
return http.upload(`/adPlan/importSubPlan`, params)
|
||||
}
|
||||
3
frontend/src/components/ImportZip/index.scss
Normal file
3
frontend/src/components/ImportZip/index.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.upload {
|
||||
width: 80%;
|
||||
}
|
||||
89
frontend/src/components/ImportZip/index.vue
Normal file
89
frontend/src/components/ImportZip/index.vue
Normal file
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="`导入${parameter.title}`"
|
||||
:destroy-on-close="true"
|
||||
width="580px"
|
||||
draggable
|
||||
>
|
||||
<el-form class="drawer-multiColumn-form" style="margin-top: 10px" label-width="100px">
|
||||
<el-form-item label="文件上传:">
|
||||
<el-upload
|
||||
action="#"
|
||||
class="upload"
|
||||
drag
|
||||
:http-request="uploadZip"
|
||||
accept=".zip"
|
||||
:show-file-list="false"
|
||||
>
|
||||
<slot name="empty">
|
||||
<el-icon class="el-icon--upload">
|
||||
<upload-filled />
|
||||
</el-icon>
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
</slot>
|
||||
<template #tip>
|
||||
<slot name="tip">
|
||||
<div class="el-upload__tip">请上传 .zip 标准格式文件</div>
|
||||
</slot>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="ImportZip">
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage, UploadRequestOptions } from 'element-plus'
|
||||
|
||||
export interface ZipParameterProps {
|
||||
title: string // 标题
|
||||
patternId?: string // 模式ID
|
||||
importApi?: (params: any) => Promise<any> // 批量导入的Api
|
||||
}
|
||||
// dialog状态
|
||||
const dialogVisible = ref(false)
|
||||
// 父组件传过来的参数
|
||||
const parameter = ref<ZipParameterProps>({
|
||||
title: ''
|
||||
})
|
||||
const emit = defineEmits<{
|
||||
(e: 'result', data: boolean): void
|
||||
}>()
|
||||
// 接收父组件参数
|
||||
const acceptParams = (params: ZipParameterProps) => {
|
||||
parameter.value = { ...parameter.value, ...params }
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
// 文件上传
|
||||
const uploadZip = async (param: UploadRequestOptions) => {
|
||||
let zipFormData = new FormData()
|
||||
zipFormData.append('file', param.file)
|
||||
if (parameter.value.patternId) {
|
||||
zipFormData.append('patternId', parameter.value.patternId)
|
||||
}
|
||||
await parameter.value.importApi!(zipFormData).then(res => handleImportResponse(res))
|
||||
}
|
||||
|
||||
const handleImportResponse = (res: any) => {
|
||||
if (res.code === 'A0000') {
|
||||
ElMessage.success('导入成功')
|
||||
} else {
|
||||
ElMessage.error(res.message)
|
||||
}
|
||||
dialogVisible.value = false
|
||||
emit('result', res.data)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
acceptParams
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@use './index.scss';
|
||||
</style>
|
||||
@@ -26,21 +26,20 @@
|
||||
<ProTable ref="proTable" :columns="columns" :request-api="getTableList" type="selection">
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab('add')" v-if="!isTabPlanFather">
|
||||
<el-button type="primary" icon="CirclePlus" @click="addTab('add')" v-if="!isTabPlanFather">
|
||||
新增子计划
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab('edit')" v-if="isTabPlanFather">
|
||||
<el-button type="primary" icon="Edit" @click="addTab('edit')" v-if="isTabPlanFather">
|
||||
编辑子计划
|
||||
</el-button>
|
||||
<!-- <el-button type="primary" :icon="Upload" >
|
||||
导出检测方案
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Download" >
|
||||
导入检测结果
|
||||
</el-button> -->
|
||||
<el-button type="primary" icon="Download" @click="exportPlan" v-if="isTabPlanFather">
|
||||
导出子计划元信息
|
||||
</el-button>
|
||||
<el-button type="primary" icon="Upload">导入检测结果</el-button>
|
||||
<el-button type="primary" icon="Box" v-if="!isTabPlanFather">数据合并</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
icon="Delete"
|
||||
plain
|
||||
:disabled="!scope.isSelected"
|
||||
v-if="isTabPlanFather"
|
||||
@@ -56,7 +55,7 @@
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
:icon="ScaleToOriginal"
|
||||
icon="ScaleToOriginal"
|
||||
style="margin-left: 10px"
|
||||
v-if="!isTabPlanFather"
|
||||
:disabled="!scope.isSelected"
|
||||
@@ -82,7 +81,7 @@
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
:icon="ScaleToOriginal"
|
||||
icon="ScaleToOriginal"
|
||||
style="margin-left: 10px"
|
||||
v-if="!isTabPlanFather"
|
||||
>
|
||||
@@ -106,7 +105,7 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:icon="Delete"
|
||||
icon="Delete"
|
||||
v-if="!isTabPlanFather"
|
||||
:disabled="scope.row.checkState != 0"
|
||||
@click="handleRemove(scope.row)"
|
||||
@@ -116,7 +115,7 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:icon="Delete"
|
||||
icon="Delete"
|
||||
v-if="isTabPlanFather"
|
||||
@click="subHandleRemove(scope.row)"
|
||||
>
|
||||
@@ -133,17 +132,17 @@
|
||||
<script setup lang="tsx">
|
||||
import { ElMessage, ElMessageBox, TabPaneName } from 'element-plus'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { CirclePlus, Delete, ScaleToOriginal } from '@element-plus/icons-vue'
|
||||
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
|
||||
import { Plan } from '@/api/plan/interface'
|
||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||
import { ColumnProps, ProTableInstance, SearchRenderScope } from '@/components/ProTable/interface'
|
||||
import { deletePlan, getDevListByPlanId, subPlanBindDev } from '@/api/plan/plan'
|
||||
import { deletePlan, exportSubPlan, getDevListByPlanId, subPlanBindDev } from '@/api/plan/plan'
|
||||
import { Device } from '@/api/device/interface/device'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import DevTransfer from '@/views/plan/planList/components/devTransfer.vue'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import router from '@/routers'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const planFormContent = ref<Plan.ReqPlan>()
|
||||
@@ -499,7 +498,7 @@ const handleRemove = async (row: any) => {
|
||||
|
||||
//子计划下移除被检设备
|
||||
const subHandleRemove = async (row: any) => {
|
||||
ElMessageBox.confirm(`确定要移除计划【${row.name}】吗?`, '提示', {
|
||||
ElMessageBox.confirm(`确定要移除被检设备【${row.name}】吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
@@ -554,6 +553,16 @@ const handleClose = () => {
|
||||
router.push('/plan/planList')
|
||||
}
|
||||
|
||||
const exportPlan = async () => {
|
||||
// 从 planFormContent.value?.children 中找到 id 与 item.name 匹配的子计划
|
||||
const subPlanFormContent = planFormContent.value?.children?.find(child => child.id === planId.value)
|
||||
const params = {
|
||||
id: subPlanFormContent.id
|
||||
}
|
||||
ElMessageBox.confirm(`确认导出${subPlanFormContent.name}子计划元信息?`, '温馨提示', { type: 'warning' }).then(() =>
|
||||
useDownload(exportSubPlan, `${subPlanFormContent.name}_子计划元信息`, params, false, '.zip')
|
||||
)
|
||||
}
|
||||
defineExpose({ open, handleTableDataUpdate })
|
||||
|
||||
interface ChildrenPlanProps {
|
||||
@@ -566,10 +575,10 @@ const props = withDefaults(defineProps<ChildrenPlanProps>(), {
|
||||
width: 800,
|
||||
height: 744
|
||||
})
|
||||
|
||||
// const props = defineProps<{
|
||||
// refreshTable: (() => Promise<void>) | undefined;
|
||||
// width: {
|
||||
// type: Number,
|
||||
// default: 800,
|
||||
// },
|
||||
// height: {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user