检测计划

This commit is contained in:
sjl
2024-12-11 19:39:09 +08:00
parent 393ad5fa0b
commit 5dbd6eb8be
15 changed files with 634 additions and 550 deletions

View File

@@ -3,7 +3,7 @@
<ProTable
ref='proTable'
:columns='columns'
:data='planData'
:request-api='getTableList'
>
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
@@ -12,99 +12,40 @@
<el-button type='primary' :icon='ScaleToOriginal' :disabled='!(scope.selectedList.length > 1)' @click='combineClick'>
合并
</el-button>
<el-button type='primary' :icon='CirclePlus' @click='openAddDialog'>新增</el-button>
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'>
删除
</el-button>
<input type='file' style='display: none' ref='fileInput' @change='handleFiles'>
</template>
<!-- 表格操作 -->
<template #operation='scope'>
<!-- <el-button type='primary' link :icon='View' @click="handleRowClick(scope.row)">查看</el-button> -->
<!-- <el-button type='primary' link :icon='Upload' @click='exportClick'>导出</el-button> -->
<el-button type='primary' link :icon='EditPen' @click='openEditDialog(scope.row)'>编辑</el-button>
<el-button type='primary' link :icon='Delete' @click='openEditDialog(scope.row)'>删除</el-button>
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit',scope.row)">编辑</el-button>
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
<el-button type='primary' link :icon='List' @click='showDeviceOpen(scope.row)'>设备绑定</el-button>
<!-- <div class='cn-render-buttons'>
<el-dropdown trigger='click'>
<el-button link type='primary' class='table-operate'>
<div class='table-operate-text'>更多</div>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item :style="{color: 'var(--el-color-danger)'}" :icon='Delete'>
删除
</el-dropdown-item>
<el-dropdown-item :icon='List' @click='showDeviceOpen(scope.row)'>
设备绑定
</el-dropdown-item>
<el-dropdown-item :icon='Tools' @click='showtestSourceOpen(scope.row)'>
检测源绑定
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div> -->
</template>
</ProTable>
<!-- 向计划导入/导出设备对话框 -->
<planPopup
:visible="dialogFormVisible"
:formData="dialogForm"
:dialogTitle="dialogTitle"
:is-read-only="isReadOnly"
@update:visible="dialogFormVisible = $event"
/>
<!-- 查看误差体系详细信息 -->
<ErrorStandardDialog
:visible='detail_dialogFormVisible'
:formData='detail_dialogForm'
:dialogTitle='detail_dialogTitle'
@update:visible='detail_dialogFormVisible = $event'
ref="errorStandardPopup"
/>
<!-- <TestSourcePopup :refresh-table='proTable?.getTableList' ref='testSourcePopup' /> -->
</div>
<devTransfer
:dialogVisible=devTransferVisible
@update:visible='devTransferVisible = $event'
/>
<sourceTransfer
:dialogVisible=sourceTransferVisible
@update:visible='sourceTransferVisible = $event'
/>
<DeviceOpen :width='viewWidth' :height='viewHeight' ref='openDeviceView' />
<SourceOpen :width='viewWidth' :height='viewHeight' ref='openSourceView' />
<!-- 向计划导入/导出设备对话框 -->
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup'/>
<!-- 查看误差体系详细信息 -->
<ErrorStandardDialog :refresh-table='proTable?.getTableList' ref="errorStandardPopup"/>
<DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/>
</template>
<script setup lang='tsx' name='useProTable'>
import ProTable from '@/components/ProTable/index.vue'
import TimeControl from '@/components/TimeControl/index.vue'
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import { ScaleToOriginal, CirclePlus, Delete, EditPen, View, Upload, Download, List, Tools } from '@element-plus/icons-vue'
import {
dictPattern,
dictTestState,
dictReportState,
dictResult,
testPlanDataList,
testSoureDataList,
testScriptDataList,
testErrSystDataList,
planData,
testFatherPlanList,
} from '@/api/plan/planData'
import { reactive, ref } from 'vue'
import {getPlanList,deletePlan } from '@/api/plan/plan.ts'
import { computed, onMounted, reactive, ref } from 'vue'
import type { Plan } from '@/api/plan/interface'
import planPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
import DeviceOpen from '@/views/plan/planList/components/devPopup.vue'
import SourceOpen from '@/views/plan/planList/components/sourcePopup.vue'
import moreButtons from './components/moreButtons.vue'
import devTransfer from './components/devTransfer.vue'
import sourceTransfer from './components/sourceTransfer.vue'
import DevTransfer from './components/devTransfer.vue'
import { useViewSize } from '@/hooks/useViewSize'
import { useRouter } from 'vue-router'
import { useDictStore } from '@/stores/modules/dict'
@@ -113,60 +54,45 @@ import type { Action } from 'element-plus'
import type { ErrorSystem } from '@/api/error/interface'
import ErrorStandardDialog from '@/views/machine/errorSystem/components/errorStandardPopup.vue' // 导入子组件
import TestSourcePopup from '@/views/machine/testSource/components/testSourcePopup.vue' // 导入子组件
import { type TestSource } from '@/api/device/interface/testSource'
import { type TestSource } from '@/api/device/interface/testSource'
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
import { useHandleData } from '@/hooks/useHandleData'
const dictStore = useDictStore()
// 定义包含和排除的单位
const includedUnits = ['日', '周', '月', '自定义'] // 可以根据需要包含的单位
const excludedUnits = ['季度', '年'] // 要排除的单位
const defaultUnits = '日' // 默认的单位
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
const openDeviceView = ref()
const openSourceView = ref()
const devTransferVisible = ref(false)
const sourceTransferVisible = ref(false)
// ProTable 实例
const proTable = ref<ProTableInstance>()
// const planData = planData
const dialogFormVisible = ref(false)
const dialogTitle = ref('')
const isReadOnly = ref(false)
const router = useRouter()
const errorStandardPopup = ref()
const planPopup = ref()
const devTransferPopup = ref()
const modeStore = useModeStore();
const fileInput = ref<HTMLInputElement | null>(null) // 声明 fileInput
const dialogForm = ref<Plan.PlanBO>({
id: '',
name: '',
pattern: '',
father_Plan_Id: '',
dataSource_Id: '',
script_Id: '',
error_Sys_Id: '',
test_State: '',
report_State: '',
result: '',
const getTableList = async(params: any) => {
let newParams = JSON.parse(JSON.stringify(params))
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
newParams.pattern = patternId
return getPlanList(newParams)
}
})
const detail_dialogFormVisible = ref(false)
const detail_dialogTitle = ref('Q/GDW 10650.2-2021 误差体系')
const detail_dialogForm = ref<ErrorSystem.Error_detail>({
measured: '',//被测量
deviceLevel: '',//检测装置级别
measurementType: '',
condition: '',//测量条件
maxErrorValue: '',//最大误差
})
// <el-button
// v-for="(button, index) in scope.row.testSourceList"
// :key="index"
// @click="handleClick(button)"
// >
// {{ button.text }}
// </el-button>
const dataSourceType = computed(() => {
switch (modeStore.currentMode) {
case '模拟式':
return 'Datasource_Simulate'
case '数字式':
return 'Datasource_Digital'
default:
return 'Datasource_Contrast'
}
})
// 表格配置项
const columns = reactive<ColumnProps<Plan.PlanAndSourceBO>[]>([
const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
@@ -176,96 +102,204 @@ const columns = reactive<ColumnProps<Plan.PlanAndSourceBO>[]>([
search: { el: 'input' },
},
{
prop: 'testSourceName',
prop: 'sourceName',
label: '检测源',
width: 375,
minWidth: 480,
render: scope => {
return (
<div class='flx-flex-start'>
<el-button type='primary' link onClick={() => showTestSource(scope.row.testSourceName)}>
{scope.row.testSourceName}
</el-button>
<el-link type='primary' link onClick={() => showTestSource(scope.row.sourceName)}>
{scope.row.sourceName}
</el-link>
<moreButtons isShow={isVisible(scope.row)} ></moreButtons>
</div>
)
},
},
{
prop: 'script_Id',
prop: 'scriptId',
label: '检测脚本',
width: 360,
enum: testScriptDataList,
fieldNames: { label: 'label', value: 'id' },
render: scope => {
return (
<el-button type='primary' link onClick={() => showTestScript(scope.row.script_Id)}>
{getScriptName(scope.row.script_Id)}
</el-button>
<el-link type='primary' link onClick={() => showTestScript(scope.row.scriptId)}>
{scope.row.scriptName}
</el-link>
)
},
},
{
prop: 'error_Sys_Id',
prop: 'errorSysId',
label: '误差体系',
width: 200,
enum: testErrSystDataList,
fieldNames: { label: 'label', value: 'id' },
render: scope => {
const errSysName = getErrSysName(scope.row.error_Sys_Id)
return (
<el-button type='primary' link onClick={() => showData(errSysName || '')}>
{errSysName}
</el-button>
<el-link type='primary' link onClick={() => showData(scope.row.errorSysId || '')}>
{scope.row.errorSysName}
</el-link>
)
},
},
{
prop: 'dataSource_Ids',
prop: 'datasourceIds',
label: '数据源',
width: 120,
// enum: testSoureDataList,
// fieldNames: { label: 'label', value: 'id' },
enum: dictStore.getDictData(dataSourceType.value),
fieldNames: { label: 'name', value: 'value' },
minWidth: 250,
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.value === code)
return dictItem ? dictItem.name : '/' // 如果找到匹配的项,返回对应的 name
})
return names.join(', ') // 用逗号连接所有的 name
}
// 查找单个 code 对应的 name
const dictItem = dictStore.getDictData(dataSourceType.value).find(item => item.value === codeArray[0])
return dictItem ? dictItem.name : '/' // 如果找到匹配的项,返回对应的 name
},
},
{
prop: 'test_State',
prop: 'testState',
label: '检测状态',
width: 120,
enum: dictTestState,
// enum: dictStore.getDictData('planTestState'),
search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' },
render: scope => {
return (
scope.row.testState === 0 ? '未检' : scope.row.testState === 1 ? '检测中' : '检测完成'
)
},
},
{
prop: 'report_State',
prop: 'reportState',
label: '检测报告状态',
width: 120,
enum: dictReportState,
// enum: dictStore.getDictData('planReportState'),
search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' },
render: scope => {
return (
scope.row.testState === 0 ? '未生成' : scope.row.testState === 1 ? '部分生成' : '全部生成'
)
},
},
{
prop: 'result',
label: '检测结果',
width: 120,
enum: dictResult,
// enum: dictStore.getDictData('planResult'),
search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' },
render: scope => {
return (
scope.row.testState === 0 ? '不符合' : scope.row.testState === 1 ? '符合' : '/'
)
},
},
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 },
])
function getScriptName(id: string) {
return testScriptDataList.find(item => item.id == id)?.label
}
function getErrSysName(id: string) {
return testErrSystDataList.find(item => item.id == id)?.label
}
const fileInput = ref<HTMLInputElement | null>(null) // 声明 fileInput
// // 表格配置项
// const columns = reactive<ColumnProps<Plan.PlanAndSourceBO>[]>([
// { type: 'selection', fixed: 'left', width: 70 },
// { type: 'index', fixed: 'left', width: 70, label: '序号' },
// {
// prop: 'name',
// label: '名称',
// width: 220,
// search: { el: 'input' },
// },
// {
// prop: 'testSourceName',
// label: '检测源',
// width: 375,
// render: scope => {
// return (
// <div class='flx-flex-start'>
// <el-link type='primary' link onClick={() => showTestSource(scope.row.testSourceName)}>
// {scope.row.testSourceName}
// </el-link>
// <moreButtons isShow={isVisible(scope.row)} ></moreButtons>
// </div>
// )
// },
// },
// {
// prop: 'script_Id',
// label: '检测脚本',
// width: 360,
// enum: testScriptDataList,
// fieldNames: { label: 'label', value: 'id' },
// render: scope => {
// return (
// <el-link type='primary' link onClick={() => showTestScript(scope.row.script_Id)}>
// {getScriptName(scope.row.script_Id)}
// </el-link>
// )
// },
// },
// {
// prop: 'error_Sys_Id',
// label: '误差体系',
// width: 200,
// enum: testErrSystDataList,
// fieldNames: { label: 'label', value: 'id' },
// render: scope => {
// const errSysName = getErrSysName(scope.row.error_Sys_Id)
// return (
// <el-link type='primary' link onClick={() => showData(errSysName || '')}>
// {errSysName}
// </el-link>
// )
// },
// },
// {
// prop: 'dataSource_Ids',
// label: '数据源',
// width: 120,
// // enum: testSoureDataList,
// // fieldNames: { label: 'label', value: 'id' },
// },
// {
// prop: 'test_State',
// label: '检测状态',
// width: 120,
// enum: dictTestState,
// // enum: dictStore.getDictData('planTestState'),
// search: { el: 'select', props: { filterable: true } },
// fieldNames: { label: 'label', value: 'id' },
// },
// {
// prop: 'report_State',
// label: '检测报告状态',
// width: 120,
// enum: dictReportState,
// // enum: dictStore.getDictData('planReportState'),
// search: { el: 'select', props: { filterable: true } },
// fieldNames: { label: 'label', value: 'id' },
// },
// {
// prop: 'result',
// label: '检测结果',
// width: 120,
// enum: dictResult,
// // enum: dictStore.getDictData('planResult'),
// search: { el: 'select', props: { filterable: true } },
// fieldNames: { label: 'label', value: 'id' },
// },
// { prop: 'operation', label: '操作', fixed: 'right', width: 250 },
// ])
function openFileDialog() {
if (fileInput.value) {
fileInput.value.click()
@@ -273,36 +307,34 @@ function openFileDialog() {
}
function isVisible(row: Plan.PlanAndSourceBO) {
//console.log(row)
if(!row.hasOwnProperty('testSourceList') || !Array.isArray(row.testSourceList))
function isVisible(row: Plan.ReqPlan) {
if(!row.hasOwnProperty('sourceName') || !Array.isArray(row.sourceName)){
return false
else if(row.testSourceList.length <= 1)
}
else if(row.sourceName.length <= 1){
return false
else
}
else{
return true
}
}
const errorStandardPopup = ref()
function showData(row: string) {
errorStandardPopup.value?.open(row, row)
// router.push({
// path: "/machine/device",
// query: { id: row }
// });
}
const testSourcePopup = ref()
function showTestSource(row: string) {
//testSourcePopup.value?.open('view', row,'模拟式')
}
function showTestScript(row: string) {
}
function handleFiles(event: Event) {
const target = event.target as HTMLInputElement
const files = target.files
@@ -363,52 +395,25 @@ const combineClick = () => {
})
}
// 打开编辑对话框
const openEditDialog = (planSystem: Plan.PlanBO) => {
dialogForm.value = { ...planSystem }
dialogTitle.value = '编辑检测计划'
isReadOnly.value = false
dialogFormVisible.value = true // 打开对话框
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => {
planPopup.value?.open(titleType, row,modeStore.currentMode)
}
const openAddDialog = () => {
dialogForm.value = {
id: '',
name: '',
pattern: '',
father_Plan_Id: '',
dataSource_Id: '',
script_Id: '',
error_Sys_Id: '',
test_State: '',
report_State: '',
result: '',
}
dialogTitle.value = '新增检测计划'
isReadOnly.value = false
dialogFormVisible.value = true // 打开对话框
// 删除检测计划
const handleDelete = async (params: Plan.ReqPlanParams) => {
await useHandleData(deletePlan, [params.id], `删除【${params.name}】检测计划`)
proTable.value?.getTableList()
}
const handleRowClick = (planSystem: Plan.PlanBO) => {
dialogForm.value = { ...planSystem }
dialogTitle.value = '查看检测计划'
isReadOnly.value = true
dialogFormVisible.value = true // 打开对话框
const showDeviceOpen = (row: Partial<Plan.ReqPlan> = {}) => {
devTransferPopup.value.open(row)
}
const showDeviceOpen = (planSystem: Plan.PlanBO) => {
devTransferVisible.value = true
//openDeviceView.value.open('计划设备列表')
}
const showtestSourceOpen = (planSystem: Plan.PlanBO) => {
sourceTransferVisible.value = true
// openSourceView.value.open('计划检测源列表')
// router.push({
// path: "/machine/testSource",
// });
}
</script>
<style scoped>