diff --git a/src/api/eqpt/measurementPlan/task.ts b/src/api/eqpt/measurementPlan/task.ts index aaed504..f92dc89 100644 --- a/src/api/eqpt/measurementPlan/task.ts +++ b/src/api/eqpt/measurementPlan/task.ts @@ -145,3 +145,13 @@ }, }) } +// 任务单中设备按设备类型分类 +export function getTaskTogether(id: string) { + return request({ + url: '/business/order/statisticsByDevice', + method: 'post', + data: { + id, + }, + }) +} diff --git a/src/api/eqpt/measurementPlan/task.ts b/src/api/eqpt/measurementPlan/task.ts index aaed504..f92dc89 100644 --- a/src/api/eqpt/measurementPlan/task.ts +++ b/src/api/eqpt/measurementPlan/task.ts @@ -145,3 +145,13 @@ }, }) } +// 任务单中设备按设备类型分类 +export function getTaskTogether(id: string) { + return request({ + url: '/business/order/statisticsByDevice', + method: 'post', + data: { + id, + }, + }) +} diff --git a/src/views/tested/MeasurementPlan/early/components/table.vue b/src/views/tested/MeasurementPlan/early/components/table.vue index 64140a2..e6b80f8 100644 --- a/src/views/tested/MeasurementPlan/early/components/table.vue +++ b/src/views/tested/MeasurementPlan/early/components/table.vue @@ -8,6 +8,8 @@ import scanEquipmentDialog from '@/components/scanEquipmentDialog/index.vue' import QRcodeDeviceDialog from '@/components/QRcodeDeviceDialog/index.vue' import { getPreTaskContent } from '@/api/eqpt/measurementPlan/task' +import { uniqueMultiArray } from '@/utils/Array' + const $props = defineProps({ data: { type: Array, @@ -267,6 +269,7 @@ watch(() => $props.data, (newVal) => { if (newVal) { list.value = newVal + fetchTogetherData() } }, { deep: true, @@ -379,6 +382,72 @@ } }) } +// --------------------------------------------表格操作-------------------------------------------- +// 表格标识 +const tableFlag = ref('normal')// normal普通表格 together聚合表格 +// 切换表格 +const changeTable = () => { + if (tableFlag.value === 'normal') { + tableFlag.value = 'together' + } + else { + tableFlag.value = 'normal' + } +} + +const togetherColumns = ref([ + { + text: '', + value: '', + align: 'center', + width: '38', + }, + { + text: '设备名称', + value: 'equipmentName', + align: 'center', + }, + { + text: '总计', + value: 'deviceNum', + align: 'center', + }, +]) +const togetherList = ref([]) +const expandList = ref([]) +function fetchTogetherData() { + togetherList.value = [] + const equipmentNames = uniqueMultiArray(list.value, 'equipmentName') + equipmentNames.forEach((element: any) => { + togetherList.value.push({ + equipmentName: element.equipmentName, + deviceNum: list.value.filter((citem: any) => citem.equipmentName === element.equipmentName).length, + }) + }) +} + +const getRowKeys = (row: any) => { // 获取当前行id + return row.equipmentName // 这里看这一行中需要根据哪个属性值是id +} +// 控制展开行 +const expands = ref([]) +const expandChange = (row: any, expandedRows: any) => { + if (expandedRows.length) { + expands.value = [] + if (row) { + expands.value.push(row.equipmentName) + } + } + else { + expands.value = [] + } +} +watch(() => expands.value, (newVal) => { + expandList.value = list.value.filter((item: any) => item.equipmentName === newVal[0]) +}, +{ + deep: true, +}) @@ -457,4 +565,14 @@ .el-select { width: 100%; } + +.nortable-header { + ::v-deep(.el-table__body-wrapper) { + display: none; + } +} + +::v-deep(.el-table__expanded-cell) { + padding: 0; +} diff --git a/src/api/eqpt/measurementPlan/task.ts b/src/api/eqpt/measurementPlan/task.ts index aaed504..f92dc89 100644 --- a/src/api/eqpt/measurementPlan/task.ts +++ b/src/api/eqpt/measurementPlan/task.ts @@ -145,3 +145,13 @@ }, }) } +// 任务单中设备按设备类型分类 +export function getTaskTogether(id: string) { + return request({ + url: '/business/order/statisticsByDevice', + method: 'post', + data: { + id, + }, + }) +} diff --git a/src/views/tested/MeasurementPlan/early/components/table.vue b/src/views/tested/MeasurementPlan/early/components/table.vue index 64140a2..e6b80f8 100644 --- a/src/views/tested/MeasurementPlan/early/components/table.vue +++ b/src/views/tested/MeasurementPlan/early/components/table.vue @@ -8,6 +8,8 @@ import scanEquipmentDialog from '@/components/scanEquipmentDialog/index.vue' import QRcodeDeviceDialog from '@/components/QRcodeDeviceDialog/index.vue' import { getPreTaskContent } from '@/api/eqpt/measurementPlan/task' +import { uniqueMultiArray } from '@/utils/Array' + const $props = defineProps({ data: { type: Array, @@ -267,6 +269,7 @@ watch(() => $props.data, (newVal) => { if (newVal) { list.value = newVal + fetchTogetherData() } }, { deep: true, @@ -379,6 +382,72 @@ } }) } +// --------------------------------------------表格操作-------------------------------------------- +// 表格标识 +const tableFlag = ref('normal')// normal普通表格 together聚合表格 +// 切换表格 +const changeTable = () => { + if (tableFlag.value === 'normal') { + tableFlag.value = 'together' + } + else { + tableFlag.value = 'normal' + } +} + +const togetherColumns = ref([ + { + text: '', + value: '', + align: 'center', + width: '38', + }, + { + text: '设备名称', + value: 'equipmentName', + align: 'center', + }, + { + text: '总计', + value: 'deviceNum', + align: 'center', + }, +]) +const togetherList = ref([]) +const expandList = ref([]) +function fetchTogetherData() { + togetherList.value = [] + const equipmentNames = uniqueMultiArray(list.value, 'equipmentName') + equipmentNames.forEach((element: any) => { + togetherList.value.push({ + equipmentName: element.equipmentName, + deviceNum: list.value.filter((citem: any) => citem.equipmentName === element.equipmentName).length, + }) + }) +} + +const getRowKeys = (row: any) => { // 获取当前行id + return row.equipmentName // 这里看这一行中需要根据哪个属性值是id +} +// 控制展开行 +const expands = ref([]) +const expandChange = (row: any, expandedRows: any) => { + if (expandedRows.length) { + expands.value = [] + if (row) { + expands.value.push(row.equipmentName) + } + } + else { + expands.value = [] + } +} +watch(() => expands.value, (newVal) => { + expandList.value = list.value.filter((item: any) => item.equipmentName === newVal[0]) +}, +{ + deep: true, +}) @@ -457,4 +565,14 @@ .el-select { width: 100%; } + +.nortable-header { + ::v-deep(.el-table__body-wrapper) { + display: none; + } +} + +::v-deep(.el-table__expanded-cell) { + padding: 0; +} diff --git a/src/views/tested/MeasurementPlan/task/components/tableList.vue b/src/views/tested/MeasurementPlan/task/components/tableList.vue index 2fe218b..eaaec42 100644 --- a/src/views/tested/MeasurementPlan/task/components/tableList.vue +++ b/src/views/tested/MeasurementPlan/task/components/tableList.vue @@ -10,7 +10,7 @@ import { getInfoDetail } from '@/api/eqpt/device/info' import scanEquipmentDialog from '@/components/scanEquipmentDialog/index.vue' import QRcodeDeviceDialog from '@/components/QRcodeDeviceDialog/index.vue' -import { getPreTaskContent } from '@/api/eqpt/measurementPlan/task' +import { getPreTaskContent, getTaskTogether } from '@/api/eqpt/measurementPlan/task' const $props = defineProps({ data: { type: Array, @@ -499,6 +499,71 @@ } }) } + +// --------------------------------------------表格操作-------------------------------------------- +// 表格标识 +const tableFlag = ref('normal')// normal普通表格 together聚合表格 +// 切换表格 +const changeTable = () => { + if (tableFlag.value === 'normal') { + tableFlag.value = 'together' + } + else { + tableFlag.value = 'normal' + } +} + +const togetherColumns = ref([ + { + text: '', + value: '', + align: 'center', + width: '38', + }, + { + text: '设备名称', + value: 'sampleName', + align: 'center', + }, + { + text: '总计', + value: 'deviceNum', + align: 'center', + }, +]) +const togetherList = ref([]) +const expandList = ref([]) +const fetchTogetherData = () => { + if (!$route.path.includes('detail')) { return } + const id = JSON.parse($route.query.row as string).id + getTaskTogether(id).then((res) => { + togetherList.value = res.data + }) +} +fetchTogetherData() + +const getRowKeys = (row: any) => { // 获取当前行id + return row.sampleName // 这里看这一行中需要根据哪个属性值是id +} +// 控制展开行 +const expands = ref([]) +const expandChange = (row: any, expandedRows: any) => { + if (expandedRows.length) { + expands.value = [] + if (row) { + expands.value.push(row.sampleName) + } + } + else { + expands.value = [] + } +} +watch(() => expands.value, (newVal) => { + expandList.value = list.value.filter((item: any) => item.sampleName === newVal[0]) +}, +{ + deep: true, +}) @@ -636,4 +779,14 @@ text-decoration: underline; } } + +.nortable-header { + ::v-deep(.el-table__body-wrapper) { + display: none; + } +} + +::v-deep(.el-table__expanded-cell) { + padding: 0; +}