2024-08-26 20:05:04 +08:00
|
|
|
|
<template>
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<div class="table-box" ref="popupBaseView">
|
|
|
|
|
|
<ProTable
|
|
|
|
|
|
ref="proTable"
|
|
|
|
|
|
:columns="columns"
|
|
|
|
|
|
:data="currentPageData"
|
|
|
|
|
|
:request-api="getTableList"
|
|
|
|
|
|
:pagination="false"
|
|
|
|
|
|
>
|
|
|
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
|
|
|
<template #tableHeader="scope">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-auth.plan="'import'"
|
|
|
|
|
|
:icon="Download"
|
|
|
|
|
|
@click="importClick"
|
|
|
|
|
|
v-if="modeStore.currentMode != '比对式'"
|
|
|
|
|
|
>
|
|
|
|
|
|
导入
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-auth.plan="'export'"
|
|
|
|
|
|
:icon="Upload"
|
|
|
|
|
|
@click="exportClick"
|
|
|
|
|
|
v-if="modeStore.currentMode != '比对式'"
|
|
|
|
|
|
>
|
|
|
|
|
|
导出
|
|
|
|
|
|
</el-button>
|
2025-09-23 10:55:07 +08:00
|
|
|
|
<el-button type="primary" v-auth.plan="'add'" :icon="CirclePlus" @click="openDialog('add')">
|
|
|
|
|
|
新增
|
|
|
|
|
|
</el-button>
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
icon="Upload"
|
|
|
|
|
|
@click="importSubClick"
|
|
|
|
|
|
v-if="modeStore.currentMode === '比对式'"
|
|
|
|
|
|
>
|
|
|
|
|
|
导入检测计划
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-auth.plan="'analysis'"
|
2025-09-25 11:16:57 +08:00
|
|
|
|
icon="DataLine"
|
2025-08-15 16:03:42 +08:00
|
|
|
|
:disabled="!scope.isSelected"
|
2025-10-14 20:54:35 +08:00
|
|
|
|
v-if=" modeStore.currentMode != '比对式'"
|
2025-08-15 16:03:42 +08:00
|
|
|
|
@click="statisticalAnalysisMore(scope.selectedListIds, scope.selectedList)"
|
|
|
|
|
|
>
|
|
|
|
|
|
统计分析
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="danger"
|
|
|
|
|
|
v-auth.plan="'delete'"
|
|
|
|
|
|
:icon="Delete"
|
|
|
|
|
|
plain
|
|
|
|
|
|
:disabled="!scope.isSelected"
|
|
|
|
|
|
@click="batchDelete(scope.selectedListIds)"
|
|
|
|
|
|
>
|
|
|
|
|
|
删除
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 表格操作 -->
|
|
|
|
|
|
<template #operation="scope">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-auth.plan="'edit'"
|
|
|
|
|
|
link
|
2025-08-29 11:34:55 +08:00
|
|
|
|
icon="EditPen"
|
2025-08-15 16:03:42 +08:00
|
|
|
|
@click="openDialog('edit', scope.row)"
|
|
|
|
|
|
>
|
|
|
|
|
|
编辑
|
|
|
|
|
|
</el-button>
|
2025-09-17 16:27:46 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-if="scope.row.testState === 0"
|
|
|
|
|
|
v-auth.plan="'delete'"
|
|
|
|
|
|
link
|
|
|
|
|
|
:icon="Delete"
|
|
|
|
|
|
@click="handleDelete(scope.row)"
|
|
|
|
|
|
>
|
2025-08-15 16:03:42 +08:00
|
|
|
|
删除
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
link
|
2025-09-22 16:16:45 +08:00
|
|
|
|
icon="List"
|
2025-08-15 16:03:42 +08:00
|
|
|
|
@click="openChildrenPlan(scope.row)"
|
2025-09-22 16:16:45 +08:00
|
|
|
|
v-if="modeStore.currentMode == '比对式' && scope.row.fatherPlanId == 0 && scope.row.importFlag == 0"
|
2025-08-15 16:03:42 +08:00
|
|
|
|
>
|
|
|
|
|
|
子计划
|
|
|
|
|
|
</el-button>
|
2025-08-20 08:51:01 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
link
|
2025-08-29 11:34:55 +08:00
|
|
|
|
icon="Cpu"
|
2025-08-20 08:51:01 +08:00
|
|
|
|
@click="openChildrenPlan(scope.row)"
|
2025-08-29 11:34:55 +08:00
|
|
|
|
v-if="modeStore.currentMode == '比对式' && scope.row.importFlag == 1"
|
2025-08-20 08:51:01 +08:00
|
|
|
|
v-auth.plan="'import_subplan'"
|
|
|
|
|
|
>
|
2025-08-29 11:34:55 +08:00
|
|
|
|
被检设备
|
2025-08-20 08:51:01 +08:00
|
|
|
|
</el-button>
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<!-- <el-button type='primary' link :icon='List' @click='showDeviceOpen(scope.row)'>设备绑定</el-button> -->
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-auth.plan="'analysis'"
|
|
|
|
|
|
link
|
2025-09-30 08:42:45 +08:00
|
|
|
|
icon="DataLine"
|
2025-10-14 20:54:35 +08:00
|
|
|
|
v-if="scope.row.testState == '2' && modeStore.currentMode != '比对式'"
|
2025-08-15 16:03:42 +08:00
|
|
|
|
@click="statisticalAnalysis(scope.row)"
|
|
|
|
|
|
>
|
|
|
|
|
|
统计分析
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 在此处新增 footer 插槽 -->
|
|
|
|
|
|
<template #pagination="scope">
|
|
|
|
|
|
<el-pagination
|
|
|
|
|
|
:background="true"
|
|
|
|
|
|
:current-page="currentPage"
|
|
|
|
|
|
:page-size="pageSize"
|
|
|
|
|
|
:page-sizes="[10, 25, 50, 100]"
|
|
|
|
|
|
:total="pageTotal"
|
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</ProTable>
|
|
|
|
|
|
</div>
|
2024-08-27 16:06:16 +08:00
|
|
|
|
|
2024-12-11 19:39:09 +08:00
|
|
|
|
<!-- 向计划导入/导出设备对话框 -->
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<PlanPopup :refresh-table="refreshTable" ref="planPopup" />
|
2024-11-13 15:24:42 +08:00
|
|
|
|
<!-- 查看误差体系详细信息 -->
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<ErrorStandardPopup :refresh-table="proTable?.getTableList" ref="errorStandardPopup" />
|
2024-12-12 11:38:42 +08:00
|
|
|
|
<!-- 查看检测源 -->
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<TestSourcePopup :refresh-table="proTable?.getTableList" ref="testSourcePopup" />
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<ImportExcel ref="planImportExcel" />
|
|
|
|
|
|
<ImportZip ref="planImportZip" @result="importResult" />
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<ChildrenPlan
|
|
|
|
|
|
:refresh-table="refreshTable"
|
2025-09-25 08:49:15 +08:00
|
|
|
|
:current-plan="selectedPlan"
|
2025-08-15 16:03:42 +08:00
|
|
|
|
ref="childrenPlanView"
|
|
|
|
|
|
:width="viewWidth"
|
|
|
|
|
|
:height="viewHeight"
|
|
|
|
|
|
></ChildrenPlan>
|
2024-10-29 11:17:04 +08:00
|
|
|
|
</template>
|
2024-08-26 20:05:04 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<script setup lang="tsx" name="useProTable">
|
2024-10-29 11:17:04 +08:00
|
|
|
|
import ProTable from '@/components/ProTable/index.vue'
|
2025-08-15 16:03:42 +08:00
|
|
|
|
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
2025-09-30 08:42:45 +08:00
|
|
|
|
import { CirclePlus, Delete, Download, Upload } from '@element-plus/icons-vue'
|
2025-08-15 16:03:42 +08:00
|
|
|
|
import {
|
|
|
|
|
|
deletePlan,
|
|
|
|
|
|
downloadTemplate,
|
|
|
|
|
|
exportPlan,
|
|
|
|
|
|
getPlanList,
|
|
|
|
|
|
importPlan,
|
|
|
|
|
|
importSubPlan,
|
|
|
|
|
|
staticsAnalyse
|
2025-09-25 08:49:15 +08:00
|
|
|
|
} from '@/api/plan/plan'
|
2025-07-21 13:47:56 +08:00
|
|
|
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
2024-10-29 11:17:04 +08:00
|
|
|
|
import type { Plan } from '@/api/plan/interface'
|
2024-12-11 19:39:09 +08:00
|
|
|
|
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
|
2025-07-21 13:47:56 +08:00
|
|
|
|
import ChildrenPlan from '@/views/plan/planList/components/childrenPlan.vue'
|
2024-10-29 11:17:04 +08:00
|
|
|
|
import { useViewSize } from '@/hooks/useViewSize'
|
2024-10-30 19:07:41 +08:00
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
2024-11-07 13:22:51 +08:00
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
2024-12-12 11:38:42 +08:00
|
|
|
|
import ErrorStandardPopup from '@/views/machine/errorSystem/components/errorStandardPopup.vue' // 导入子组件
|
2024-12-06 09:11:44 +08:00
|
|
|
|
import TestSourcePopup from '@/views/machine/testSource/components/testSourcePopup.vue' // 导入子组件
|
2024-12-11 19:39:09 +08:00
|
|
|
|
import { type TestSource } from '@/api/device/interface/testSource'
|
2025-08-15 16:03:42 +08:00
|
|
|
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
2024-12-11 19:39:09 +08:00
|
|
|
|
import { useHandleData } from '@/hooks/useHandleData'
|
2025-09-25 08:49:15 +08:00
|
|
|
|
import { dictReportState, dictResult, dictTestState } from '@/api/plan/planData'
|
|
|
|
|
|
import { getTestSourceById } from '@/api/device/testSource'
|
2025-02-18 15:58:38 +08:00
|
|
|
|
import ImportExcel from '@/components/ImportExcel/index.vue'
|
2025-08-15 16:03:42 +08:00
|
|
|
|
import ImportZip from '@/components/ImportZip/index.vue'
|
|
|
|
|
|
import { useDownload } from '@/hooks/useDownload'
|
2025-01-15 09:35:36 +08:00
|
|
|
|
|
2025-01-17 14:57:17 +08:00
|
|
|
|
// defineOptions({
|
|
|
|
|
|
// name: 'planList'
|
|
|
|
|
|
// })
|
2024-10-30 19:07:41 +08:00
|
|
|
|
const dictStore = useDictStore()
|
2025-07-21 13:47:56 +08:00
|
|
|
|
const childrenPlanView = ref()
|
2024-11-07 13:22:51 +08:00
|
|
|
|
// ProTable 实例
|
|
|
|
|
|
const proTable = ref<ProTableInstance>()
|
2024-12-11 19:39:09 +08:00
|
|
|
|
const errorStandardPopup = ref()
|
2024-12-12 11:38:42 +08:00
|
|
|
|
const testSourcePopup = ref()
|
2024-12-11 19:39:09 +08:00
|
|
|
|
const planPopup = ref()
|
2024-12-17 11:12:21 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const modeStore = useModeStore()
|
2025-07-21 13:47:56 +08:00
|
|
|
|
const tableData = ref<any[]>([])
|
2025-02-18 15:58:38 +08:00
|
|
|
|
const planImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const planImportZip = ref<InstanceType<typeof ImportZip> | null>(null)
|
2025-07-21 13:47:56 +08:00
|
|
|
|
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
|
|
|
|
|
|
const pageTotal = ref(0)
|
|
|
|
|
|
const currentPage = ref(1)
|
|
|
|
|
|
const pageSize = ref(10)
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const currentPageData = ref<any[]>([]) //当前页的数据
|
2025-07-21 13:47:56 +08:00
|
|
|
|
const patternId = ref('')
|
2025-09-25 08:49:15 +08:00
|
|
|
|
const selectedPlan = ref()
|
2025-07-22 14:56:58 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
refreshTable()
|
2025-07-21 13:47:56 +08:00
|
|
|
|
})
|
|
|
|
|
|
//假分页后用data刷新
|
|
|
|
|
|
const refreshTable = async () => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
try {
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
patternId.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id
|
|
|
|
|
|
const result = await getPlanList({ patternId: patternId.value })
|
|
|
|
|
|
tableData.value = buildTree(result.data as any[])
|
|
|
|
|
|
pageTotal.value = tableData.value.length
|
|
|
|
|
|
updateCurrentPageData(tableData.value)
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
tableData.value = []
|
|
|
|
|
|
ElMessage.error('获取计划列表失败')
|
|
|
|
|
|
}
|
2024-12-11 19:39:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-21 13:47:56 +08:00
|
|
|
|
// 监听 tableData 变化
|
2025-08-15 16:03:42 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
() => tableData.value,
|
|
|
|
|
|
newVal => {
|
|
|
|
|
|
if (childrenPlanView.value && newVal) {
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
childrenPlanView.value.handleTableDataUpdate?.(newVal)
|
|
|
|
|
|
updateCurrentPageData(newVal)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ deep: true, immediate: true }
|
|
|
|
|
|
)
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
|
|
|
|
|
//模糊查询计划列表
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const getTableList = async (params: any) => {
|
|
|
|
|
|
let newParams = JSON.parse(JSON.stringify(params))
|
2025-07-21 13:47:56 +08:00
|
|
|
|
// 从 newParams 中提取筛选条件
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const name = newParams.name
|
|
|
|
|
|
const reportState = newParams.reportState
|
|
|
|
|
|
const result = newParams.result
|
|
|
|
|
|
const testState = newParams.testState
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
// 对 tableData.value 进行筛选
|
|
|
|
|
|
const filteredData = tableData.value.filter(item => {
|
|
|
|
|
|
let match = true
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
if (name) {
|
|
|
|
|
|
match = item.name?.includes(name)
|
|
|
|
|
|
}
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
if (reportState !== undefined && reportState !== null && reportState !== '') {
|
|
|
|
|
|
match = item.reportState == reportState
|
|
|
|
|
|
}
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
if (result !== undefined && result !== null && result !== '') {
|
|
|
|
|
|
match = item.result == result
|
|
|
|
|
|
}
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
if (testState !== undefined && testState !== null && testState !== '') {
|
|
|
|
|
|
match = item.testState == testState
|
|
|
|
|
|
}
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
return match
|
2025-07-21 13:47:56 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 更新分页总数
|
|
|
|
|
|
pageTotal.value = filteredData.length
|
|
|
|
|
|
|
|
|
|
|
|
// 更新当前页数据
|
|
|
|
|
|
currentPage.value = 1
|
|
|
|
|
|
updateCurrentPageData(filteredData)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function buildTree(flatList: any[]): any[] {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const map = new Map()
|
|
|
|
|
|
const tree: any[] = []
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
// First, create a map of all items by id for fast lookup
|
|
|
|
|
|
flatList.forEach(item => {
|
|
|
|
|
|
map.set(item.id, { ...item, children: [] })
|
|
|
|
|
|
})
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
// Then, assign each item to its parent's children array
|
|
|
|
|
|
flatList.forEach(item => {
|
|
|
|
|
|
if (item.fatherPlanId && map.has(item.fatherPlanId)) {
|
|
|
|
|
|
map.get(item.fatherPlanId).children.push(map.get(item.id))
|
|
|
|
|
|
} else if (item.fatherPlanId === '0') {
|
|
|
|
|
|
// Items with fatherPlanId '0' are root nodes
|
|
|
|
|
|
tree.push(map.get(item.id))
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return tree
|
|
|
|
|
|
}
|
2025-07-22 14:56:58 +08:00
|
|
|
|
|
2025-07-21 13:47:56 +08:00
|
|
|
|
const handleSizeChange = (size: number) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
pageSize.value = size
|
|
|
|
|
|
updateCurrentPageData()
|
2025-07-21 13:47:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleCurrentChange = (page: number) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
currentPage.value = page
|
|
|
|
|
|
updateCurrentPageData()
|
2025-07-21 13:47:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const updateCurrentPageData = (data = tableData.value) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const start = (currentPage.value - 1) * pageSize.value
|
|
|
|
|
|
const end = start + pageSize.value
|
|
|
|
|
|
currentPageData.value = data.slice(start, end)
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-07-21 13:47:56 +08:00
|
|
|
|
}
|
2024-12-11 19:39:09 +08:00
|
|
|
|
|
|
|
|
|
|
const dataSourceType = computed(() => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
// switch (modeStore.currentMode) {
|
|
|
|
|
|
// case '模拟式':
|
|
|
|
|
|
// return 'Datasource_Simulate'
|
|
|
|
|
|
// case '数字式':
|
|
|
|
|
|
// return 'Datasource_Digital'
|
|
|
|
|
|
// default:
|
|
|
|
|
|
// return 'Datasource_Contrast'
|
|
|
|
|
|
// }
|
|
|
|
|
|
return 'Datasource'
|
2024-12-12 11:38:42 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2024-08-26 20:05:04 +08:00
|
|
|
|
// 表格配置项
|
2024-12-11 19:39:09 +08:00
|
|
|
|
const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
2025-08-15 16:03:42 +08:00
|
|
|
|
{ type: 'selection', fixed: 'left', minWidth: 70 },
|
|
|
|
|
|
{ type: 'index', fixed: 'left', minWidth: 70, label: '序号' },
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'name',
|
|
|
|
|
|
label: '名称',
|
|
|
|
|
|
minWidth: 200,
|
|
|
|
|
|
search: { el: 'input' }
|
2024-11-13 15:24:42 +08:00
|
|
|
|
},
|
2025-08-15 16:03:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
prop: 'testState',
|
|
|
|
|
|
label: '检测状态',
|
|
|
|
|
|
minWidth: 100,
|
|
|
|
|
|
enum: dictTestState,
|
|
|
|
|
|
search: { el: 'select', props: { filterable: true } },
|
|
|
|
|
|
fieldNames: { label: 'label', value: 'id' },
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
return scope.row.testState === 0 ? (
|
2025-09-25 11:16:57 +08:00
|
|
|
|
<el-tag type="primary" effect="dark">
|
2025-08-15 16:03:42 +08:00
|
|
|
|
未检
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
) : scope.row.testState === 1 ? (
|
2025-09-25 11:16:57 +08:00
|
|
|
|
<el-tag type="warning" effect="dark">
|
2025-08-15 16:03:42 +08:00
|
|
|
|
检测中
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<el-tag type="success" effect="dark">
|
|
|
|
|
|
检测完成
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2024-11-13 15:24:42 +08:00
|
|
|
|
},
|
2025-08-15 16:03:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
prop: 'progress',
|
|
|
|
|
|
label: '检测进度',
|
|
|
|
|
|
minWidth: 150,
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<el-progress
|
|
|
|
|
|
text-inside={true}
|
|
|
|
|
|
stroke-width={20}
|
2025-09-29 09:47:53 +08:00
|
|
|
|
percentage={Number(((scope.row.progress ?? 0) * 100).toFixed(2))}
|
2025-08-15 16:03:42 +08:00
|
|
|
|
status="success"
|
|
|
|
|
|
/>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2024-11-13 15:24:42 +08:00
|
|
|
|
},
|
2025-08-15 16:03:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
prop: 'reportState',
|
|
|
|
|
|
label: '检测报告状态',
|
|
|
|
|
|
minWidth: 120,
|
|
|
|
|
|
enum: dictReportState,
|
|
|
|
|
|
search: { el: 'select', props: { filterable: true } },
|
|
|
|
|
|
fieldNames: { label: 'label', value: 'id' },
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
return scope.row.reportState === 0 ? '未生成' : scope.row.reportState === 1 ? '部分生成' : '全部生成'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'result',
|
|
|
|
|
|
label: '检测结果',
|
|
|
|
|
|
minWidth: 100,
|
|
|
|
|
|
enum: dictResult,
|
|
|
|
|
|
search: { el: 'select', props: { filterable: true } },
|
|
|
|
|
|
fieldNames: { label: 'label', value: 'id' },
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
return scope.row.result === 0 ? '不符合' : scope.row.result === 1 ? '符合' : '/'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'createTime',
|
|
|
|
|
|
label: '创建时间',
|
|
|
|
|
|
minWidth: 180,
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
if (scope.row.createTime) {
|
|
|
|
|
|
const date = new Date(scope.row.createTime)
|
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
|
const day = String(date.getDate()).padStart(2, '0')
|
|
|
|
|
|
const hours = String(date.getHours()).padStart(2, '0')
|
|
|
|
|
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
|
|
|
|
const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
|
|
|
|
}
|
|
|
|
|
|
return ''
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'sourceName',
|
|
|
|
|
|
label: '检测源',
|
|
|
|
|
|
minWidth: 300,
|
|
|
|
|
|
isShow: modeStore.currentMode != '比对式',
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
const sourceNames = Array.isArray(scope.row.sourceName) ? scope.row.sourceName : []
|
|
|
|
|
|
const sourceIds = Array.isArray(scope.row.sourceIds) ? scope.row.sourceIds : []
|
|
|
|
|
|
const firstSourceName = sourceNames[0]
|
|
|
|
|
|
const firstSourceId = sourceIds[0]
|
|
|
|
|
|
const remainingSourceNames = sourceNames.slice(1)
|
|
|
|
|
|
const remainingSourceIds = sourceIds.slice(1)
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div class="flx-flex-start">
|
|
|
|
|
|
{firstSourceName && (
|
|
|
|
|
|
<el-link type="primary" link onClick={() => showTestSource(firstSourceId)}>
|
|
|
|
|
|
{firstSourceName}
|
|
|
|
|
|
</el-link>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<moreButtons
|
|
|
|
|
|
isShow={isVisible(scope.row)}
|
|
|
|
|
|
sourceNames={remainingSourceNames} //长度>1时,传给更多子组件从第二位开始的名字
|
|
|
|
|
|
sourceIds={remainingSourceIds} //长度>1时,传给更多子组件从第二位开始的id
|
|
|
|
|
|
onSource-clicked={showTestSource}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'scriptId',
|
|
|
|
|
|
label: '检测脚本',
|
|
|
|
|
|
minWidth: 300,
|
|
|
|
|
|
isShow: modeStore.currentMode != '比对式',
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
return <span>{scope.row.scriptName}</span>
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'standardDevNameStr',
|
|
|
|
|
|
label: '标准设备',
|
|
|
|
|
|
minWidth: 250,
|
|
|
|
|
|
isShow: modeStore.currentMode == '比对式',
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
const standardDevNameStr = scope.row.standardDevNameStr
|
|
|
|
|
|
if (!standardDevNameStr) {
|
|
|
|
|
|
return '/'
|
|
|
|
|
|
}
|
|
|
|
|
|
return standardDevNameStr
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'testItemNameStr',
|
2025-09-23 10:55:07 +08:00
|
|
|
|
label: '检测项',
|
2025-08-15 16:03:42 +08:00
|
|
|
|
minWidth: 300,
|
|
|
|
|
|
isShow: modeStore.currentMode == '比对式'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'errorSysId',
|
|
|
|
|
|
label: '误差体系',
|
|
|
|
|
|
minWidth: 300,
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<el-link type="primary" link onClick={() => showData(scope.row)}>
|
|
|
|
|
|
{scope.row.errorSysName}
|
|
|
|
|
|
</el-link>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'origin', //null 表示主计划 1表示子计划
|
|
|
|
|
|
label: '来源',
|
|
|
|
|
|
minWidth: 200,
|
|
|
|
|
|
isShow: modeStore.currentMode == '比对式'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'datasourceIds',
|
|
|
|
|
|
label: '数据源',
|
|
|
|
|
|
enum: dictStore.getDictData(dataSourceType.value),
|
|
|
|
|
|
fieldNames: { label: 'name', value: 'value' },
|
|
|
|
|
|
minWidth: 230,
|
|
|
|
|
|
render: scope => {
|
|
|
|
|
|
const codes = scope.row.datasourceIds // 获取当前行的 datasourceIds 字段
|
|
|
|
|
|
if (!codes) {
|
|
|
|
|
|
return '/'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 确保 codes 是一个字符串
|
|
|
|
|
|
const codeString = Array.isArray(codes) ? codes.join(',') : codes
|
|
|
|
|
|
const codeArray = codeString.split(',')
|
|
|
|
|
|
if (codeArray.length > 1) {
|
|
|
|
|
|
// 查找与每个 code 值匹配的 name,然后拼接成逗号分割的字符串
|
|
|
|
|
|
const names = codeArray.map(code => {
|
|
|
|
|
|
const dictItem = dictStore.getDictData(dataSourceType.value).find(item => item.code === code)
|
|
|
|
|
|
|
|
|
|
|
|
return dictItem ? dictItem.name : '/' // 如果找到匹配的项,返回对应的 name
|
|
|
|
|
|
})
|
|
|
|
|
|
return names.join(', ') // 用逗号连接所有的 name
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查找单个 code 对应的 name
|
|
|
|
|
|
const dictItem = dictStore.getDictData(dataSourceType.value).find(item => item.code === codeArray[0])
|
|
|
|
|
|
return dictItem ? dictItem.name : '/' // 如果找到匹配的项,返回对应的 name
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'dataRule',
|
|
|
|
|
|
label: '数据处理原则',
|
|
|
|
|
|
enum: dictStore.getDictData('Data_Rule'),
|
|
|
|
|
|
fieldNames: { label: 'name', value: 'id' },
|
|
|
|
|
|
minWidth: 120
|
2024-12-11 19:39:09 +08:00
|
|
|
|
},
|
2025-09-08 10:21:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
prop: 'leaderName',
|
|
|
|
|
|
label: '项目负责人',
|
|
|
|
|
|
minWidth: 120,
|
|
|
|
|
|
isShow: modeStore.currentMode == '比对式'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'membersName',
|
|
|
|
|
|
label: '项目成员',
|
|
|
|
|
|
minWidth: 100,
|
|
|
|
|
|
isShow: modeStore.currentMode == '比对式'
|
|
|
|
|
|
},
|
2024-08-26 20:05:04 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 250 }
|
|
|
|
|
|
])
|
2024-11-14 18:40:58 +08:00
|
|
|
|
|
2024-12-11 19:39:09 +08:00
|
|
|
|
function isVisible(row: Plan.ReqPlan) {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
if (!row.hasOwnProperty('sourceName') || !Array.isArray(row.sourceName)) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
} else if (row.sourceName.length <= 1) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return true
|
2024-12-11 19:39:09 +08:00
|
|
|
|
}
|
2024-11-14 18:40:58 +08:00
|
|
|
|
}
|
2024-11-12 20:35:12 +08:00
|
|
|
|
|
2025-03-24 19:56:11 +08:00
|
|
|
|
function showData(row: any) {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
let split = row.errorSysName.split('-')
|
|
|
|
|
|
errorStandardPopup.value?.open(row.errorSysName, { id: row.errorSysId, devLevel: split[split.length - 1] })
|
2024-12-05 20:29:28 +08:00
|
|
|
|
}
|
2024-12-11 19:39:09 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
async function showTestSource(row: string) {
|
|
|
|
|
|
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '' //获取数据字典中对应的id
|
|
|
|
|
|
const params: TestSource.ResTestSource = {
|
|
|
|
|
|
id: row, // 根据实际情况设
|
|
|
|
|
|
pattern: patternId,
|
|
|
|
|
|
type: '',
|
|
|
|
|
|
devType: '',
|
|
|
|
|
|
state: 0
|
|
|
|
|
|
}
|
2024-12-12 11:38:42 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const result = await getTestSourceById(params)
|
|
|
|
|
|
testSourcePopup.value?.open('view', result.data, modeStore.currentMode)
|
2024-12-05 20:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 13:22:51 +08:00
|
|
|
|
// 点击导入按钮
|
|
|
|
|
|
const importClick = () => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
title: '检测计划',
|
|
|
|
|
|
showCover: false,
|
|
|
|
|
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
|
|
|
|
|
tempApi: downloadTemplate,
|
|
|
|
|
|
importApi: importPlan,
|
|
|
|
|
|
getTableList: refreshTable()
|
|
|
|
|
|
}
|
|
|
|
|
|
planImportExcel.value?.acceptParams(params)
|
2024-11-07 13:22:51 +08:00
|
|
|
|
}
|
2025-08-15 16:03:42 +08:00
|
|
|
|
|
2024-11-07 13:22:51 +08:00
|
|
|
|
// 点击导出按钮
|
|
|
|
|
|
const exportClick = () => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
ElMessageBox.confirm('确认导出检测计划?', '温馨提示', { type: 'warning' }).then(() => {
|
|
|
|
|
|
useDownload(
|
|
|
|
|
|
exportPlan,
|
|
|
|
|
|
'检测计划导出数据',
|
|
|
|
|
|
{ ...proTable.value?.searchParam, patternId: patternId },
|
|
|
|
|
|
false,
|
|
|
|
|
|
'.xlsx'
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
2024-11-07 13:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-11 19:39:09 +08:00
|
|
|
|
// 打开 drawer(新增、编辑)
|
|
|
|
|
|
const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
let planType = 0 // 0主计划 1子计划 2修改子计划
|
|
|
|
|
|
|
|
|
|
|
|
if (modeStore.currentMode === '比对式') {
|
|
|
|
|
|
if (titleType === 'add') {
|
|
|
|
|
|
// 新增只能是主计划
|
|
|
|
|
|
planType = 0
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 编辑情况
|
|
|
|
|
|
if (row.children?.length > 0) {
|
|
|
|
|
|
// 有子计划 -> 主计划
|
|
|
|
|
|
planType = 0
|
2025-08-18 16:28:29 +08:00
|
|
|
|
} else if (row.fatherPlanId === '0') {
|
|
|
|
|
|
// 父级ID为"0" -> 主计划
|
2025-08-15 16:03:42 +08:00
|
|
|
|
planType = 0
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 其他 -> 修改子计划
|
|
|
|
|
|
planType = 2
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-07-29 18:35:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
planPopup.value?.open(titleType, row, modeStore.currentMode, planType)
|
2024-08-27 14:01:26 +08:00
|
|
|
|
}
|
2024-10-09 20:03:07 +08:00
|
|
|
|
|
2024-12-12 11:38:42 +08:00
|
|
|
|
// 批量删除设备
|
|
|
|
|
|
const batchDelete = async (id: string[]) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
await useHandleData(deletePlan, { id: id, pattern: patternId.value }, '删除所选检测计划')
|
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
|
await refreshTable()
|
2024-12-12 11:38:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-11 19:39:09 +08:00
|
|
|
|
// 删除检测计划
|
|
|
|
|
|
const handleDelete = async (params: Plan.ReqPlanParams) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
await useHandleData(deletePlan, { id: [params.id], pattern: patternId.value }, `删除【${params.name}】检测计划`)
|
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
|
await refreshTable()
|
2025-07-09 20:12:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-21 13:47:56 +08:00
|
|
|
|
const openChildrenPlan = (row: Partial<Plan.ReqPlan> = {}) => {
|
2025-09-25 08:49:15 +08:00
|
|
|
|
selectedPlan.value = row
|
|
|
|
|
|
childrenPlanView.value.open('子计划管理', row, patternId.value)
|
2024-10-30 15:19:47 +08:00
|
|
|
|
}
|
2024-12-11 19:39:09 +08:00
|
|
|
|
|
2025-02-21 14:57:52 +08:00
|
|
|
|
const statisticalAnalysisMore = async (ids: string[], rows: Plan.ReqPlan[]) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const hasInvalidState = rows.some(row => row.testState != 2)
|
|
|
|
|
|
if (hasInvalidState) {
|
|
|
|
|
|
ElMessage({
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
message: '存在检测状态不为检测完成的计划,无法进行统计分析。'
|
|
|
|
|
|
})
|
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
useDownload(staticsAnalyse, '分析结果', ids, false, '.xlsx')
|
2025-02-17 16:28:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-13 15:40:13 +08:00
|
|
|
|
const statisticalAnalysis = async (row: Partial<Plan.ReqPlan> = {}) => {
|
2025-08-15 16:03:42 +08:00
|
|
|
|
useDownload(staticsAnalyse, '分析结果', [row.id], false, '.xlsx')
|
2025-02-13 15:40:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const importSubClick = () => {
|
|
|
|
|
|
const params = {
|
2025-08-25 11:02:07 +08:00
|
|
|
|
title: '导入检测计划',
|
2025-08-15 16:03:42 +08:00
|
|
|
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
2025-08-27 20:21:55 +08:00
|
|
|
|
importApi: importSubPlan,
|
2025-09-25 08:49:15 +08:00
|
|
|
|
confirmMessage: '本次导入会覆盖已有系统配置数据,是否确认继续?'
|
2025-08-15 16:03:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
planImportZip.value?.acceptParams(params)
|
|
|
|
|
|
}
|
2025-02-13 15:40:13 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
const importResult = async (success: boolean | undefined) => {
|
|
|
|
|
|
if (success) {
|
|
|
|
|
|
await refreshTable()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-10-29 11:17:04 +08:00
|
|
|
|
</script>
|
2024-08-26 20:05:04 +08:00
|
|
|
|
|
2025-08-15 16:03:42 +08:00
|
|
|
|
<style scoped></style>
|