Files
pqs-9100_client/frontend/src/views/plan/planList/index.vue

377 lines
12 KiB
Vue
Raw Normal View History

2024-08-26 20:05:04 +08:00
<template>
2024-10-29 11:17:04 +08:00
<div class='table-box' ref='popupBaseView'>
<ProTable
ref='proTable'
:columns='columns'
:data='planData'
>
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
2024-11-07 13:22:51 +08:00
<el-button type='primary' :icon='Download' @click="importClick">导入</el-button>
<el-button type='primary' :icon='CirclePlus' :disabled='!(scope.selectedList.length > 1)' @click="combineClick">合并</el-button>
2024-10-29 11:17:04 +08:00
<el-button type='primary' :icon='CirclePlus' @click="openAddDialog">新增</el-button>
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'>
批量删除
</el-button>
2024-11-07 13:22:51 +08:00
<input type="file" style="display: none" ref="fileInput" @change="handleFiles">
2024-10-29 11:17:04 +08:00
</template>
2024-08-26 20:05:04 +08:00
<!-- 表格操作 -->
2024-10-29 11:17:04 +08:00
<template #operation='scope'>
2024-11-07 13:22:51 +08:00
<!-- <el-button type='primary' link :icon='View' @click="handleRowClick(scope.row)">查看</el-button> -->
<el-button type='primary' link :icon='Upload' @click="exportClick">导出</el-button>
2024-10-29 11:17:04 +08:00
<el-button type='primary' link :icon='EditPen' @click="openEditDialog(scope.row)">编辑</el-button>
<el-button type='primary' link :icon='Delete' >删除</el-button>
<el-button type='primary' link :icon='List' @click="showDeviceOpen(scope.row)">设备绑定</el-button>
<el-button type='primary' link :icon='Tools' @click="showtestSourceOpen(scope.row)">检测源绑定</el-button>
2024-10-29 11:17:04 +08:00
</template>
</ProTable>
2024-08-26 20:05:04 +08:00
<temp></temp>
2024-11-07 13:22:51 +08:00
<!-- 向计划导入/导出设备对话框 -->
<planPopup
2024-10-29 11:17:04 +08:00
:visible="dialogFormVisible"
:formData="dialogForm"
:dialogTitle="dialogTitle"
:is-read-only="isReadOnly"
@update:visible="dialogFormVisible = $event"
/>
2024-08-27 16:06:16 +08:00
<!-- 查看误差体系详细信息 -->
<ErrorStandardDialog
:visible="detail_dialogFormVisible"
:formData="detail_dialogForm"
:dialogTitle="detail_dialogTitle"
@update:visible="detail_dialogFormVisible = $event"
/>
2024-10-29 11:17:04 +08:00
</div>
2024-11-08 13:09:06 +08:00
<devTransfer
:dialogVisible=devTransferVisible
@update:visible='devTransferVisible = $event'
/>
<sourceTransfer
:dialogVisible=sourceTransferVisible
@update:visible='sourceTransferVisible = $event'
/>
2024-11-07 13:22:51 +08:00
<DeviceOpen :width='viewWidth' :height='viewHeight' ref='openDeviceView' />
<SourceOpen :width='viewWidth' :height='viewHeight' ref='openSourceView' />
2024-10-29 11:17:04 +08:00
</template>
2024-08-26 20:05:04 +08:00
<script setup lang="tsx" name='useProTable'>
2024-10-29 11:17:04 +08:00
import ProTable from '@/components/ProTable/index.vue'
2024-11-07 13:22:51 +08:00
import TimeControl from '@/components/TimeControl/index.vue'
import type { ProTableInstance,ColumnProps } from '@/components/ProTable/interface'
import { 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'
2024-10-29 11:17:04 +08:00
import { reactive,ref } from 'vue'
import type { Plan } from '@/api/plan/interface'
2024-11-07 13:22:51 +08:00
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 temp from './components/temp.vue'
2024-11-08 13:09:06 +08:00
import devTransfer from './components/devTransfer.vue'
import sourceTransfer from './components/sourceTransfer.vue'
2024-10-29 11:17:04 +08:00
import { useViewSize } from '@/hooks/useViewSize'
2024-10-30 15:19:47 +08:00
import { useRouter } from "vue-router";
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'
import type { Action } from 'element-plus'
import type { ErrorSystem } from '@/api/error/interface'
import ErrorStandardDialog from "@/views/machine/errorSystem/components/ErrorStandardDialog.vue"; // 导入子组件
2024-11-07 13:22:51 +08:00
2024-10-30 19:07:41 +08:00
const dictStore = useDictStore()
2024-11-07 13:22:51 +08:00
// 定义包含和排除的单位
const includedUnits = ['日', '周', '月', '自定义']; // 可以根据需要包含的单位
const excludedUnits = ['季度','年']; // 要排除的单位
const defaultUnits = '日'; // 默认的单位
2024-10-29 11:17:04 +08:00
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
2024-11-07 13:22:51 +08:00
const openDeviceView = ref()
const openSourceView = ref()
2024-11-08 13:09:06 +08:00
const devTransferVisible = ref(false)
const sourceTransferVisible = ref(false)
2024-11-07 13:22:51 +08:00
// ProTable 实例
const proTable = ref<ProTableInstance>()
// const planData = planData
2024-10-29 11:17:04 +08:00
const dialogFormVisible = ref(false)
const dialogTitle = ref('')
const isReadOnly = ref(false)
2024-10-30 15:19:47 +08:00
const router = useRouter();
2024-11-07 13:22:51 +08:00
const dialogForm = ref<Plan.PlanBO>({
id: '' ,
2024-10-29 11:17:04 +08:00
name: '',
pattern:'',
father_Plan_Id:'',
dataSource_Id:'',
script_Id:'',
error_Sys_Id:'',
test_State: '',
report_State: '',
result:'',
});
2024-08-26 20:05:04 +08:00
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: '',//最大误差
});
2024-08-28 15:39:08 +08:00
2024-08-26 20:05:04 +08:00
// 表格配置项
const columns = reactive<ColumnProps<Plan.PlanAndSourceBO>[]>([
2024-10-29 11:17:04 +08:00
{ type: 'selection', fixed: 'left', width: 70 },
2024-11-08 13:09:06 +08:00
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
2024-10-29 11:17:04 +08:00
{
prop: 'name',
label: '检测计划名称',
width: 200,
2024-11-08 13:09:06 +08:00
search: { el: 'input' },
2024-10-29 11:17:04 +08:00
},
{
2024-11-08 13:09:06 +08:00
prop: 'testSourceName',
label: '检测源名称',
2024-10-29 11:17:04 +08:00
width: 200,
render: scope => {
return (
// <el-button
// v-for="(button, index) in scope.row.testSourceList"
// :key="index"
// @click="handleClick(button)"
// >
// {{ button.text }}
// </el-button>
<div class='flx-flex-start'>
<el-button type = "primary" link onClick = {() => showData(scope.row.testSourceName)}>
{scope.row.testSourceName}
</el-button>
<temp></temp>
</div>
);
 }
2024-10-29 11:17:04 +08:00
},
{
prop: 'script_Id',
label: '检测脚本',
width: 300,
2024-11-07 13:22:51 +08:00
enum: testScriptDataList,
fieldNames: { label: 'label', value: 'id' },
render: scope => {
return (
<el-button type = "primary" link onClick = {() => showData(scope.row.script_Id)}>
{getScriptName(scope.row.script_Id)}
</el-button>
);
 }
2024-10-29 11:17:04 +08:00
},
{
prop: 'error_Sys_Id',
label: '误差体系',
width: 200,
2024-11-07 13:22:51 +08:00
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>
);
 }
2024-10-29 11:17:04 +08:00
},
2024-11-08 13:09:06 +08:00
{
prop: 'dataSource_Id',
label: '数据源名称',
width: 200,
enum: testSoureDataList,
fieldNames: { label: 'label', value: 'id' },
},
2024-10-29 11:17:04 +08:00
{
prop: 'test_State',
label: '检测状态',
width: 100,
enum: dictTestState,
// enum: dictStore.getDictData('planTestState'),
2024-10-30 19:07:41 +08:00
search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' },
2024-10-29 11:17:04 +08:00
},
{
prop: 'report_State',
label: '检测报告状态',
width: 150,
enum: dictReportState,
// enum: dictStore.getDictData('planReportState'),
2024-10-30 19:07:41 +08:00
search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' },
2024-10-29 11:17:04 +08:00
},
{
prop: 'result',
label: '检测结果',
width: 100,
enum: dictResult,
// enum: dictStore.getDictData('planResult'),
2024-10-30 19:07:41 +08:00
search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' },
2024-10-29 11:17:04 +08:00
},
{
prop: 'father_Plan_Id',
label: '父节点',
width: 200,
enum: testFatherPlanList,
fieldNames: { label: 'label', value: 'id' },
2024-10-29 11:17:04 +08:00
},
2024-11-08 09:21:18 +08:00
// {
// prop: 'create_Time',
// label: '记录时间',
// minWidth: 180,
// search: {
// span: 2,
// render: () => {
// return (
// <div class='flx-flex-start'>
// </div>
// )
// },
// },
// },
{ prop: 'operation', label: '操作', fixed: 'right' ,width: 450, },
2024-10-29 11:17:04 +08:00
])
2024-08-26 20:05:04 +08:00
function getScriptName(id:string){
return testScriptDataList.find(item=>item.id==id)?.label
}
function getErrSysName(id:string){
return testErrSystDataList.find(item=>item.id==id)?.label
}
2024-11-07 13:22:51 +08:00
const fileInput = ref<HTMLInputElement | null>(null); // 声明 fileInput
function openFileDialog() {
if (fileInput.value) {
fileInput.value.click();
}
}
function showData(row: string) {
detail_dialogTitle.value = row;
detail_dialogFormVisible.value = true; // 显示对话框
// router.push({
// path: "/machine/device",
// query: { id: row }
// });
}
2024-11-07 13:22:51 +08:00
function handleFiles(event: Event) {
const target = event.target as HTMLInputElement;
const files = target.files;
if (files && files.length > 0) {
// 处理文件
console.log(files);
ElMessageBox.confirm(
'导入的数据与当前数据有冲突,请选择以哪个数据为主进行覆盖',
'数据冲突',
{
distinguishCancelAndClose: true,
confirmButtonText: '以导入数据为主覆盖',
cancelButtonText: '以当前数据为主覆盖',
type: 'warning',
}
)
.then(() => {
ElMessage({
type: 'info',
message: '以导入数据为主完成数据覆盖',
})
})
.catch((action: Action) => {
ElMessage({
type: 'info',
message:
action === 'cancel'
? '以当前数据为主完成数据覆盖'
: '取消本次导入操作',
})
})
}
}
// 点击导入按钮
const importClick = () => {
openFileDialog()
}
// 点击导出按钮
const exportClick = () => {
openFileDialog()
}
// 点击合并按钮
const combineClick = () => {
ElMessageBox.prompt(
'请输入合并后的计划名称',
'检测计划合并',
{
2024-11-08 09:30:41 +08:00
confirmButtonText: '确定',
cancelButtonText: '取消',
2024-11-07 13:22:51 +08:00
}
)
.then(({ value }) => {
console.log(`合并后的计划名为:`,value)
proTable.value?.clearSelection()
proTable.value?.getTableList()
})
}
2024-10-29 11:17:04 +08:00
// 打开编辑对话框
2024-11-07 13:22:51 +08:00
const openEditDialog = (planSystem: Plan.PlanBO) => {
2024-10-29 11:17:04 +08:00
dialogForm.value = {...planSystem};
dialogTitle.value = '编辑检测计划';
isReadOnly.value = false;
dialogFormVisible.value = true; // 打开对话框
2024-08-26 20:05:04 +08:00
};
2024-10-29 11:17:04 +08:00
const openAddDialog = () => {
2024-10-30 15:19:47 +08:00
2024-10-29 11:17:04 +08:00
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; // 打开对话框
2024-08-26 20:05:04 +08:00
};
2024-11-07 13:22:51 +08:00
const handleRowClick = (planSystem: Plan.PlanBO) =>{
2024-10-29 11:17:04 +08:00
dialogForm.value = {...planSystem};
dialogTitle.value = '查看检测计划';
isReadOnly.value = true;
dialogFormVisible.value = true; // 打开对话框
2024-08-27 14:01:26 +08:00
}
2024-11-07 13:22:51 +08:00
const showDeviceOpen = (planSystem: Plan.PlanBO) => {
2024-11-08 13:09:06 +08:00
devTransferVisible.value = true;
//openDeviceView.value.open('计划设备列表')
2024-08-26 20:05:04 +08:00
}
2024-10-30 15:19:47 +08:00
2024-11-07 13:22:51 +08:00
const showtestSourceOpen=(planSystem: Plan.PlanBO)=>{
sourceTransferVisible.value = true;
// openSourceView.value.open('计划检测源列表')
2024-11-07 13:22:51 +08:00
// router.push({
// path: "/machine/testSource",
// });
2024-10-30 15:19:47 +08:00
}
2024-10-29 11:17:04 +08:00
</script>
2024-08-26 20:05:04 +08:00
2024-10-29 11:17:04 +08:00
<style scoped>
</style>