误差体系

This commit is contained in:
sjl
2024-11-26 15:41:20 +08:00
parent a1d3485ba7
commit 3c56eb2ba0
12 changed files with 548 additions and 621 deletions

View File

@@ -3,148 +3,93 @@
<ProTable
ref='proTable'
:columns='columns'
:data='errorData'
type='selection'
@selection-change="handleSelectionChange"
:request-api='getPqErrSysList'
>
<!-- 表格 header 按钮 -->
<template #tableHeader>
<el-button type='primary' :icon='CirclePlus' @click="openAddDialog">新增</el-button>
<el-button type='danger' :icon='Delete' plain :disabled='!multipleSelection.length'
>
批量删除
</el-button>
<template #tableHeader='scope'>
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
<el-button v-auth.device="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
@click='batchDelete(scope.selectedListIds)'>
批量删除
</el-button>
</template>
<!-- 表格操作 -->
<template #operation='scope'>
<el-button type='primary' link :icon='View' @click="handleRowClick(scope.row)">查看</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='View'>查看</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>
</template>
</ProTable>
<!-- 新增/编辑误差体系对话框 -->
<ErrorSystemDialog
:visible="dialogFormVisible"
:formData="dialogForm"
:dialogTitle="dialogTitle"
@update:visible="dialogFormVisible = $event"
/>
<!-- 查看误差体系详细信息 -->
<ErrorStandardDialog
:visible="detail_dialogFormVisible"
:formData="detail_dialogForm"
:dialogTitle="detail_dialogTitle"
@update:visible="detail_dialogFormVisible = $event"
/>
</div>
<ErrorSystemPopup :refresh-table='proTable?.getTableList' ref='errorSystemPopup' />
<ErrorStandardPopup :refresh-table='proTable?.getTableList' ref='errorStandardPopup' />
</template>
<script setup lang="ts" name='useProTable'>
import ProTable from '@/components/ProTable/index.vue'
import type { ColumnProps } from '@/components/ProTable/interface'
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
import { CirclePlus, Delete,EditPen,View} from '@element-plus/icons-vue'
import errorDataList from '@/api/device/error/errorData'
import { reactive,ref } from 'vue'
import { useHandleData } from '@/hooks/useHandleData'
import ErrorSystemPopup from '@/views/machine/errorSystem/components/errorSystemPopup.vue'
import ErrorStandardPopup from '@/views/machine/errorSystem/components/errorStandardPopup.vue'
import type { ErrorSystem } from '@/api/device/interface/error'
import ErrorSystemDialog from "@/views/machine/errorSystem/components/ErrorSystemDialog.vue"; // 导入子组件
import ErrorStandardDialog from "@/views/machine/errorSystem/components/ErrorStandardDialog.vue"; // 导入子组件
import { useDictStore } from '@/stores/modules/dict'
import { getPqErrSysList, deletePqErrSys} from '@/api/device/error/index'
const dictStore = useDictStore()
let multipleSelection = ref<string[]>([])
const errorData = errorDataList.errordata
const dialogFormVisible = ref(false)
const dialogTitle = ref('新增误差体系')
const dialogForm = ref<ErrorSystem.ErrorSystemList>({
id: '',
name: '',
standard_Name:'',
standard_Time:'',
dev_Level:'',
enable:1,
state:1,
});
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: '',//最大误差
});
// ProTable 实例
const proTable = ref<ProTableInstance>()
const errorSystemPopup = ref()
const errorStandardPopup = ref()
// 表格配置项
const columns = ref<ColumnProps<ErrorSystem.ErrorSystemList>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{
prop: 'id',
label: '序号',
width: 70,
},
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'name',
label: '误差体系名称',
},
{
prop: 'standard_Name',
prop: 'standardName',
label: '参照标准名称',
},
{
prop: 'standard_Time',
prop: 'standardTime',
label: '标准实施年份',
width: 200,
search: { el: 'input' },
},
{
prop: 'dev_Level',
prop: 'devLevel',
label: '适用设备等级',
width: 120,
enum: dictStore.getDictData('errorLevel'),
enum: dictStore.getDictData('Dev_Level'),
search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'code' },
fieldNames: { label: 'name', value: 'id' },
},
{ prop: 'operation', label: '操作', fixed: 'right' ,width: 250,},
])
// 打开编辑对话框
const openEditDialog = (errorSystem: ErrorSystem.ErrorSystemList) => {
errorSystem.standard_Time ='2024'
dialogForm.value = {...errorSystem};
dialogTitle.value = '编辑误差体系';
dialogFormVisible.value = true; // 打开对话框
};
const openAddDialog = () => {
dialogForm.value = {
id: '',
name: '',
standard_Name:'',
standard_Time:'',
dev_Level:'',
state:0,
};
dialogTitle.value = '新增误差体系';
dialogFormVisible.value = true; // 打开对话框
};
//选中
// 处理选择变化
const handleSelectionChange = (selection:ErrorSystem.ErrorSystemList[]) => {
multipleSelection.value = selection.map(row => row.id); // 更新选中的行
};
const handleRowClick = (errorSystem: ErrorSystem.ErrorSystemList) =>{
detail_dialogTitle.value = errorSystem.name;
detail_dialogFormVisible.value = true; // 显示对话框
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<ErrorSystem.ErrorSystemList> = {}) => {
errorSystemPopup.value?.open(titleType, row)
}
// 批量删除设备
const batchDelete = async (id: string[]) => {
await useHandleData(deletePqErrSys, id, '删除所选误差体系')
proTable.value?.clearSelection()
proTable.value?.getTableList()
}
// 删除设备
const handleDelete = async (params: ErrorSystem.ErrorSystemList) => {
await useHandleData(deletePqErrSys, [params.id], `删除【${params.name}】误差体系`)
proTable.value?.getTableList()
}
</script>
<style scoped>