检测计划表格误差体系,检测源跳转

This commit is contained in:
sjl
2024-12-12 11:38:42 +08:00
parent 726f7841e8
commit 8bd5351d29
7 changed files with 117 additions and 149 deletions

View File

@@ -58,11 +58,15 @@ const dictReportState: Dict[] = [
const dictResult: Dict[] = [ const dictResult: Dict[] = [
{ {
id: "0", id: "0",
label: '符合', label: '符合',
}, },
{ {
id: "1", id: "1",
label: '符合', label: '符合',
},
{
id: "2",
label: '/',
}, },
] ]

View File

@@ -2,9 +2,6 @@
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig"> <el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
<div > <div >
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' :disabled="tableIsDisable" label-width="auto" class="form-three"> <el-form :model="formContent" ref='dialogFormRef' :rules='rules' :disabled="tableIsDisable" label-width="auto" class="form-three">
<!-- <el-form-item label="检测源名称" prop="name" >-->
<!-- <el-input v-model='formContent.name' placeholder="检测源类型+设备类型+数字"/>-->
<!-- </el-form-item>-->
<el-form-item label="设备类型" prop="devType" > <el-form-item label="设备类型" prop="devType" >
<el-select v-model='formContent.devType' placeholder="请选择源型号"> <el-select v-model='formContent.devType' placeholder="请选择源型号">
<el-option <el-option
@@ -15,7 +12,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="检测源类型" prop="type"> <el-form-item label="检测源类型" prop="type" >
<el-select v-model='formContent.type' placeholder="请选择检测源类型"> <el-select v-model='formContent.type' placeholder="请选择检测源类型">
<el-option <el-option
v-for="item in dictStore.getDictData('Pq_Source_Type')" v-for="item in dictStore.getDictData('Pq_Source_Type')"
@@ -144,7 +141,6 @@ const save = () => {
// 打开弹窗,可能是新增,也可能是编辑 // 打开弹窗,可能是新增,也可能是编辑
const open = async (sign: string, data: TestSource.ResTestSource, currentMode: string) => { const open = async (sign: string, data: TestSource.ResTestSource, currentMode: string) => {
console.log('打开弹窗', sign, data)
titleType.value = sign titleType.value = sign
dialogVisible.value = true dialogVisible.value = true
mode.value = currentMode mode.value = currentMode

View File

@@ -50,6 +50,7 @@
const proTable = ref<ProTableInstance>() const proTable = ref<ProTableInstance>()
const getTableList = (params: any) => { const getTableList = (params: any) => {
console.log("getTableList",params)
let newParams = JSON.parse(JSON.stringify(params)) let newParams = JSON.parse(JSON.stringify(params))
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
newParams.pattern = patternId newParams.pattern = patternId
@@ -65,7 +66,7 @@
prop: 'name', prop: 'name',
label: '名称', label: '名称',
search: { el: 'input' }, search: { el: 'input' },
minWidth: 180, minWidth: 300,
}, },
{ {
prop: 'devType', prop: 'devType',
@@ -73,7 +74,7 @@
enum: dictStore.getDictData('S_Dev_Type_'+dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.code), enum: dictStore.getDictData('S_Dev_Type_'+dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.code),
fieldNames: { label: 'name', value: 'id' }, fieldNames: { label: 'name', value: 'id' },
search: { el: 'select' }, search: { el: 'select' },
minWidth: 220, minWidth: 250,
}, },
{ {
prop: 'type', prop: 'type',

View File

@@ -1,39 +1,53 @@
<template> <template>
<div class="device-list-container" v-if="isShow"> <div class="device-list-container" v-if="isShow">
<el-dropdown @command="handleCommand"> <el-dropdown>
<el-link link type='primary' class='table-operate'> <el-link link type='primary' class='table-operate'>
<div class='table-operate-text'>更多...</div> <div>更多...</div>
</el-link> </el-link>
<!-- <span class="el-dropdown-link">
更多<el-icon class="el-icon--right"><arrow-down /></el-icon>
</span> -->
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<!-- <el-dropdown-item command="高精度设备-PQV520-2">高精度设备-PQV-520便携式电能质量监测装置-2</el-dropdown-item> <el-dropdown-item v-for="(name, index) in props.sourceNames" :key="index" @click="handleSourceClick(index)">
<el-dropdown-item command="高精度设备-PQV520-3">高精度设备-PQV-520便携式电能质量监测装置-3</el-dropdown-item> <el-link link type="primary">{{ name }}</el-link>
<el-dropdown-item command="高精度设备-PQV520-4">高精度设备-PQV-520便携式电能质量监测装置-4</el-dropdown-item> --> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
/>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
const props = defineProps<{
isShow: boolean;
}>();
const handleCommand = (command: string | number | object) => {
const props = defineProps({
isShow: {
type: Boolean,
},
sourceNames: {
type: Array as () => string[],
},
sourceIds: {
type: Array as () => string[],
} }
});
const emit = defineEmits<{
(e: 'source-clicked', id: string): void;
}>();
const handleSourceClick = (index: number) => {
if (props.sourceIds && props.sourceIds[index]) {
emit('source-clicked', props.sourceIds[index]);
} else {
console.log('sourceIds is undefined or the index is out of bounds');
}
};
</script> </script>
<style scoped> <style scoped>
.example-showcase .el-dropdown-link { .device-list-container {
cursor: pointer;
color: var(--el-button-text-color);
display: flex; display: flex;
justify-content: center;
align-items: center; align-items: center;
margin-left: 10px; /* 调整这个值以达到所需的效果 */
} }
</style> </style>

View File

@@ -166,10 +166,10 @@
const formRuleRef = ref<FormInstance>() const formRuleRef = ref<FormInstance>()
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({ const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
name: [{ required: true, message: '检测计划名称必填!', trigger: 'blur' }], name: [{ required: true, message: '检测计划名称必填!', trigger: 'blur' }],
source_Id: [{ required: true, message: '检测源必选!', trigger: 'blur' }], sourceIds: [{ required: true, message: '检测源必选!', trigger: 'blur' }],
dataSource_Id: [{ required: true, message: '数据源必选!', trigger: 'blur' }], datasourceIds: [{ required: true, message: '数据源必选!', trigger: 'blur' }],
script_Id: [{ required: true, message: '检测脚本必选!', trigger: 'blur' }], scriptId: [{ required: true, message: '检测脚本必选!', trigger: 'blur' }],
error_Sys_Id: [{ required: true, message: '误差体系必选!', trigger: 'blur' }], errorSysId: [{ required: true, message: '误差体系必选!', trigger: 'blur' }],
}); });
// 关闭弹窗 // 关闭弹窗
@@ -243,7 +243,7 @@ const open = async (sign: string,
{ {
const pqDevList_Result = await getUnboundPqDevList(data); const pqDevList_Result = await getUnboundPqDevList(data);
pqDevList.value = pqDevList_Result.data as Device.ResPqDev[]; pqDevList.value = pqDevList_Result.data as Device.ResPqDev[];
}else{ }else{//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
const boundPqDevList_Result = await getBoundPqDevList({ 'planId': data.id }); const boundPqDevList_Result = await getBoundPqDevList({ 'planId': data.id });
const unboundPqDevList_Result = await getUnboundPqDevList(data); const unboundPqDevList_Result = await getUnboundPqDevList(data);
@@ -256,7 +256,10 @@ const open = async (sign: string,
Object.assign(formContent,{ ...data }) Object.assign(formContent,{ ...data })
} }
pqToArray();//将对象转为数组
}
function pqToArray() {
const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : [] const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : []
// 将 pqSource_Result 转换成 { label, value } 数组 // 将 pqSource_Result 转换成 { label, value } 数组
pqSourceArray.value = sourceArray1.map(item => ({ pqSourceArray.value = sourceArray1.map(item => ({
@@ -281,7 +284,6 @@ const open = async (sign: string,
label: item.name, label: item.name,
value: item.id value: item.id
})) }))
} }
const dataSourceType = computed(() => { const dataSourceType = computed(() => {
@@ -302,6 +304,8 @@ defineExpose({ open })
const props = defineProps<{ const props = defineProps<{
refreshTable: (() => Promise<void>) | undefined; refreshTable: (() => Promise<void>) | undefined;
}>() }>()
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -13,7 +13,7 @@
合并 合并
</el-button> </el-button>
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</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 type='danger' :icon='Delete' plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
删除 删除
</el-button> </el-button>
</template> </template>
@@ -29,8 +29,10 @@
<!-- 向计划导入/导出设备对话框 --> <!-- 向计划导入/导出设备对话框 -->
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup'/> <PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup'/>
<!-- 查看误差体系详细信息 --> <!-- 查看误差体系详细信息 -->
<ErrorStandardDialog :refresh-table='proTable?.getTableList' ref="errorStandardPopup"/> <ErrorStandardPopup :refresh-table='proTable?.getTableList' ref="errorStandardPopup"/>
<!-- 查看检测源 -->
<TestSourcePopup :refresh-table='proTable?.getTableList' ref="testSourcePopup"/>
<!-- 查看设备绑定 -->
<DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/> <DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/>
</template> </template>
@@ -52,12 +54,13 @@ import { useDictStore } from '@/stores/modules/dict'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import type { Action } from 'element-plus' import type { Action } from 'element-plus'
import type { ErrorSystem } from '@/api/error/interface' import type { ErrorSystem } from '@/api/error/interface'
import ErrorStandardDialog from '@/views/machine/errorSystem/components/errorStandardPopup.vue' // 导入子组件 import ErrorStandardPopup from '@/views/machine/errorSystem/components/errorStandardPopup.vue' // 导入子组件
import TestSourcePopup from '@/views/machine/testSource/components/testSourcePopup.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 { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
import { useHandleData } from '@/hooks/useHandleData' import { useHandleData } from '@/hooks/useHandleData'
import { dictTestState,dictReportState,dictResult } from '@/api/plan/planData.ts'
import {getTestSourceById} from '@/api/device/testSource/index'
const dictStore = useDictStore() const dictStore = useDictStore()
const openDeviceView = ref() const openDeviceView = ref()
const openSourceView = ref() const openSourceView = ref()
@@ -66,6 +69,7 @@ const sourceTransferVisible = ref(false)
// ProTable 实例 // ProTable 实例
const proTable = ref<ProTableInstance>() const proTable = ref<ProTableInstance>()
const errorStandardPopup = ref() const errorStandardPopup = ref()
const testSourcePopup = ref()
const planPopup = ref() const planPopup = ref()
const devTransferPopup = ref() const devTransferPopup = ref()
const modeStore = useModeStore(); const modeStore = useModeStore();
@@ -89,7 +93,9 @@ const dataSourceType = computed(() => {
default: default:
return 'Datasource_Contrast' return 'Datasource_Contrast'
} }
}) })
// 表格配置项 // 表格配置项
const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
@@ -104,14 +110,27 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
{ {
prop: 'sourceName', prop: 'sourceName',
label: '检测源', label: '检测源',
minWidth: 480, minWidth: 400,
render: scope => { 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 ( return (
<div class='flx-flex-start'> <div class='flx-flex-start'>
<el-link type='primary' link onClick={() => showTestSource(scope.row.sourceName)}> {firstSourceName && (
{scope.row.sourceName} <el-link type='primary' link onClick={() => showTestSource(firstSourceId)}>
{firstSourceName}
</el-link> </el-link>
<moreButtons isShow={isVisible(scope.row)} ></moreButtons> )}
<moreButtons isShow={isVisible(scope.row)}
sourceNames={remainingSourceNames}//长度>1传给更多子组件从第二位开始的名字
sourceIds={remainingSourceIds} //长度>1时传给更多子组件从第二位开始的id
onSource-clicked={showTestSource}
/>
</div> </div>
) )
}, },
@@ -171,7 +190,8 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
prop: 'testState', prop: 'testState',
label: '检测状态', label: '检测状态',
width: 120, width: 120,
search: { el: 'select', props: { filterable: true } }, enum:dictTestState,
search: { el:'select',props: { filterable: true }},
fieldNames: { label: 'label', value: 'id' }, fieldNames: { label: 'label', value: 'id' },
render: scope => { render: scope => {
return ( return (
@@ -183,11 +203,12 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
prop: 'reportState', prop: 'reportState',
label: '检测报告状态', label: '检测报告状态',
width: 120, width: 120,
enum:dictReportState,
search: { el: 'select', props: { filterable: true } }, search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' }, fieldNames: { label: 'label', value: 'id' },
render: scope => { render: scope => {
return ( return (
scope.row.testState === 0 ? '未生成' : scope.row.testState === 1 ? '部分生成' : '全部生成' scope.row.reportState === 0 ? '未生成' : scope.row.reportState === 1 ? '部分生成' : '全部生成'
) )
}, },
}, },
@@ -195,110 +216,21 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
prop: 'result', prop: 'result',
label: '检测结果', label: '检测结果',
width: 120, width: 120,
enum:dictResult,
search: { el: 'select', props: { filterable: true } }, search: { el: 'select', props: { filterable: true } },
fieldNames: { label: 'label', value: 'id' }, fieldNames: { label: 'label', value: 'id' },
render: scope => { render: scope => {
return ( return (
scope.row.testState === 0 ? '不符合' : scope.row.testState === 1 ? '符合' : '/' scope.row.result === 0 ? '不符合' : scope.row.result === 1 ? '符合' : '/'
) )
}, },
}, },
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 }, { prop: 'operation', label: '操作', fixed: 'right', width: 250 },
]) ])
const handleSourceClicked = (id: string) => {
};
// // 表格配置项
// 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() { function openFileDialog() {
if (fileInput.value) { if (fileInput.value) {
@@ -317,8 +249,6 @@ function isVisible(row: Plan.ReqPlan) {
else{ else{
return true return true
} }
} }
@@ -326,7 +256,18 @@ function showData(row: string) {
errorStandardPopup.value?.open(row, row) errorStandardPopup.value?.open(row, row)
} }
function showTestSource(row: string) { 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
};
const result = await getTestSourceById(params);
testSourcePopup.value?.open('view', result.data, modeStore.currentMode);
} }
@@ -400,10 +341,17 @@ const combineClick = () => {
// 打开 drawer(新增、编辑) // 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => { const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => {
planPopup.value?.open(titleType, row,modeStore.currentMode) planPopup.value?.open(titleType, row,modeStore.currentMode)
} }
// 批量删除设备
const batchDelete = async (id: string[]) => {
await useHandleData(deletePlan, id, '删除所选检测计划')
proTable.value?.clearSelection()
proTable.value?.getTableList()
}
// 删除检测计划 // 删除检测计划
const handleDelete = async (params: Plan.ReqPlanParams) => { const handleDelete = async (params: Plan.ReqPlanParams) => {
await useHandleData(deletePlan, [params.id], `删除【${params.name}】检测计划`) await useHandleData(deletePlan, [params.id], `删除【${params.name}】检测计划`)

View File

@@ -1,3 +1,4 @@
<template> <template>
<el-dialog v-model="dialogVisible" title="程序激活" v-bind="dialogSmall"> <el-dialog v-model="dialogVisible" title="程序激活" v-bind="dialogSmall">
<el-form :model="formContent"> <el-form :model="formContent">