增加检测计划功能
This commit is contained in:
@@ -7,26 +7,27 @@
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' :icon='Download' >导入</el-button>
|
||||
<el-button type='primary' :icon='CirclePlus' >合并</el-button>
|
||||
<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>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openAddDialog">新增</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'>导出</el-button>
|
||||
<!-- <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' >删除</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="showDeviceOpen(scope.row)">设备</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="showtestSourceOpen(scope.row)">检测源</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="showDeviceOpen(scope.row)">所属设备</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="showtestSourceOpen(scope.row)">所属检测源</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<!-- 新增/编辑误差体系对话框 -->
|
||||
<PlanDialog
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<planPopup
|
||||
:visible="dialogFormVisible"
|
||||
:formData="dialogForm"
|
||||
:dialogTitle="dialogTitle"
|
||||
@@ -35,31 +36,44 @@
|
||||
/>
|
||||
|
||||
</div>
|
||||
<open :width='viewWidth' :height='viewHeight' ref='openView' />
|
||||
<DeviceOpen :width='viewWidth' :height='viewHeight' ref='openDeviceView' />
|
||||
<SourceOpen :width='viewWidth' :height='viewHeight' ref='openSourceView' />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name='useProTable'>
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps } from '@/components/ProTable/interface'
|
||||
import TimeControl from '@/components/TimeControl/index.vue'
|
||||
import type { ProTableInstance,ColumnProps } from '@/components/ProTable/interface'
|
||||
import { CirclePlus, Delete,EditPen,View,Upload,Download,List} from '@element-plus/icons-vue'
|
||||
import planDataList from '@/api/plan/planData'
|
||||
import {dictPattern,dictTestState,dictReportState,dictResult,testPlanDataList,testSoureDataList,testScriptDataList,testErrSystDataList,planData} from '@/api/plan/planData'
|
||||
import { reactive,ref } from 'vue'
|
||||
import type { Plan } from '@/api/plan/interface'
|
||||
import PlanDialog from "@/views/plan/planList/components/PlanDialog.vue"; // 导入子组件
|
||||
import Open from '@/views/plan/planList/components/PlanOpen.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 { useViewSize } from '@/hooks/useViewSize'
|
||||
import { useRouter } from "vue-router";
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { Action } from 'element-plus'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
// 定义包含和排除的单位
|
||||
const includedUnits = ['日', '周', '月', '自定义']; // 可以根据需要包含的单位
|
||||
const excludedUnits = ['季度','年']; // 要排除的单位
|
||||
const defaultUnits = '日'; // 默认的单位
|
||||
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
|
||||
const openView = ref()
|
||||
const planData = planDataList
|
||||
const openDeviceView = ref()
|
||||
const openSourceView = ref()
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
// const planData = planData
|
||||
const dialogFormVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const isReadOnly = ref(false)
|
||||
const router = useRouter();
|
||||
const dialogForm = ref<Plan.PlanList>({
|
||||
id: '',
|
||||
const dialogForm = ref<Plan.PlanBO>({
|
||||
id: '' ,
|
||||
name: '',
|
||||
pattern:'',
|
||||
father_Plan_Id:'',
|
||||
@@ -68,7 +82,6 @@ const dialogForm = ref<Plan.PlanList>({
|
||||
error_Sys_Id:'',
|
||||
test_State: '',
|
||||
report_State: '',
|
||||
state:0,
|
||||
result:'',
|
||||
|
||||
|
||||
@@ -76,7 +89,7 @@ const dialogForm = ref<Plan.PlanList>({
|
||||
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<Plan.PlanList>[]>([
|
||||
const columns = reactive<ColumnProps<Plan.PlanBO>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{
|
||||
prop: 'name',
|
||||
@@ -87,16 +100,22 @@ const columns = reactive<ColumnProps<Plan.PlanList>[]>([
|
||||
prop: 'dataSource_Id',
|
||||
label: '数据源名称',
|
||||
width: 200,
|
||||
enum: testSoureDataList,
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
},
|
||||
{
|
||||
prop: 'script_Id',
|
||||
label: '检测脚本',
|
||||
width: 300,
|
||||
enum: testScriptDataList,
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
},
|
||||
{
|
||||
prop: 'error_Sys_Id',
|
||||
label: '误差体系',
|
||||
width: 200,
|
||||
enum: testErrSystDataList,
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
},
|
||||
{
|
||||
prop: 'test_State',
|
||||
@@ -130,8 +149,77 @@ const columns = reactive<ColumnProps<Plan.PlanList>[]>([
|
||||
{ prop: 'operation', label: '操作', fixed: 'right' ,width: 500, },
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
const fileInput = ref<HTMLInputElement | null>(null); // 声明 fileInput
|
||||
function openFileDialog() {
|
||||
if (fileInput.value) {
|
||||
fileInput.value.click();
|
||||
}
|
||||
}
|
||||
|
||||
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(
|
||||
'请输入合并后的计划名称',
|
||||
'检测计划合并',
|
||||
{
|
||||
confirmButtonText: 'OK',
|
||||
cancelButtonText: 'Cancel',
|
||||
}
|
||||
)
|
||||
.then(({ value }) => {
|
||||
console.log(`合并后的计划名为:`,value)
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
})
|
||||
}
|
||||
|
||||
// 打开编辑对话框
|
||||
const openEditDialog = (planSystem: Plan.PlanList) => {
|
||||
const openEditDialog = (planSystem: Plan.PlanBO) => {
|
||||
dialogForm.value = {...planSystem};
|
||||
dialogTitle.value = '编辑检测计划';
|
||||
isReadOnly.value = false;
|
||||
@@ -150,7 +238,6 @@ const openAddDialog = () => {
|
||||
error_Sys_Id:'',
|
||||
test_State: '',
|
||||
report_State: '',
|
||||
state:0,
|
||||
result:'',
|
||||
};
|
||||
dialogTitle.value = '新增检测计划';
|
||||
@@ -158,21 +245,22 @@ const openAddDialog = () => {
|
||||
dialogFormVisible.value = true; // 打开对话框
|
||||
};
|
||||
|
||||
const handleRowClick = (planSystem: Plan.PlanList) =>{
|
||||
const handleRowClick = (planSystem: Plan.PlanBO) =>{
|
||||
dialogForm.value = {...planSystem};
|
||||
dialogTitle.value = '查看检测计划';
|
||||
isReadOnly.value = true;
|
||||
dialogFormVisible.value = true; // 打开对话框
|
||||
}
|
||||
|
||||
const showDeviceOpen = (planSystem: Plan.PlanList) => {
|
||||
openView.value.open('设备列表')
|
||||
const showDeviceOpen = (planSystem: Plan.PlanBO) => {
|
||||
openDeviceView.value.open('计划设备列表')
|
||||
}
|
||||
|
||||
const showtestSourceOpen=(planSystem: Plan.PlanList)=>{
|
||||
router.push({
|
||||
path: "/machine/testSource",
|
||||
});
|
||||
const showtestSourceOpen=(planSystem: Plan.PlanBO)=>{
|
||||
openSourceView.value.open('计划检测源列表')
|
||||
// router.push({
|
||||
// path: "/machine/testSource",
|
||||
// });
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user