|
@@ -1,6 +1,7 @@
|
|
<script setup>
|
|
<script setup>
|
|
-import { dayjs } from 'element-plus';
|
|
|
|
-import { getContinuousAssayList, getDeviceList } from '@/api/report/lab';
|
|
|
|
|
|
+import { h } from 'vue';
|
|
|
|
+import { dayjs } from 'element-plus';
|
|
|
|
+import { getContinuousAssayListNew, getDeviceList } from '@/api/report/lab';
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
|
@@ -8,19 +9,21 @@ const queryParams = ref({
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
deviceNo: '',
|
|
deviceNo: '',
|
|
- activeRadioName: 'week'
|
|
|
|
|
|
+ activeRadioName: 'daterange'
|
|
});
|
|
});
|
|
|
|
|
|
const tableLoading = ref(false);
|
|
const tableLoading = ref(false);
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
|
|
|
|
-const datePickerValue = ref(new Date());
|
|
|
|
|
|
+const datePickerValue = ref([]);
|
|
const tempDataValue = ref({timeBegin: dayjs(new Date()).startOf('week').format('YYYY') + '年'});
|
|
const tempDataValue = ref({timeBegin: dayjs(new Date()).startOf('week').format('YYYY') + '年'});
|
|
|
|
|
|
const tableData = ref([]);
|
|
const tableData = ref([]);
|
|
const columns = ref([]);
|
|
const columns = ref([]);
|
|
const options = ref([]);
|
|
const options = ref([]);
|
|
|
|
|
|
|
|
+const dateBeforeSevenDays = computed(() => new Date(dayjs().subtract(7, 'day').format('YYYY-MM-DD')))
|
|
|
|
+
|
|
const format = computed(() => {
|
|
const format = computed(() => {
|
|
return queryParams.value.activeRadioName === 'week' ? tempDataValue.value.timeBegin + ' 第 ww 周' : 'YYYY-MM'
|
|
return queryParams.value.activeRadioName === 'week' ? tempDataValue.value.timeBegin + ' 第 ww 周' : 'YYYY-MM'
|
|
})
|
|
})
|
|
@@ -42,65 +45,121 @@ const onRadioChange = () => {
|
|
|
|
|
|
const getStartTimeAndEndTime = () => {
|
|
const getStartTimeAndEndTime = () => {
|
|
const { activeRadioName } = queryParams.value;
|
|
const { activeRadioName } = queryParams.value;
|
|
- const timeBegin = dayjs(datePickerValue.value).startOf(activeRadioName).format('YYYY-MM-DD');
|
|
|
|
- const timeEnd = dayjs(datePickerValue.value).endOf(activeRadioName).format('YYYY-MM-DD');
|
|
|
|
-
|
|
|
|
|
|
+ const time = datePickerValue.value;
|
|
|
|
+ let timeBegin = '';
|
|
|
|
+ let timeEnd = '';
|
|
|
|
+
|
|
|
|
+ if ( activeRadioName === 'daterange' ) {
|
|
|
|
+ if (time.length) {
|
|
|
|
+ const [ startTime, endTime ] = time;
|
|
|
|
+ timeBegin = dayjs(startTime).format('YYYY-MM-DD')
|
|
|
|
+ timeEnd = dayjs(endTime).format('YYYY-MM-DD')
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ timeBegin = dayjs(time).startOf('month').format('YYYY-MM-DD');
|
|
|
|
+ timeEnd = dayjs(time).endOf('month').format('YYYY-MM-DD');
|
|
|
|
+ }
|
|
|
|
+
|
|
return {
|
|
return {
|
|
timeBegin,
|
|
timeBegin,
|
|
timeEnd
|
|
timeEnd
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const formatter = (row, column) => {
|
|
|
|
+ const { title, ratesDeviationNumber }= row;
|
|
|
|
+ const { no } = column;
|
|
|
|
+
|
|
|
|
+ if ( title === '合格率偏差' && no != 0 && no != columns.value.length - 1 ) {
|
|
|
|
+ const val = row[column.property];
|
|
|
|
+
|
|
|
|
+ if (!ratesDeviationNumber && ratesDeviationNumber != 0) return '';
|
|
|
|
+
|
|
|
|
+ return h('span', {
|
|
|
|
+ style: { color: ratesDeviationNumber != 0 ? 'red' : '#606266' },
|
|
|
|
+ }, row[column.property])
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return row[column.property]
|
|
|
|
+}
|
|
|
|
+
|
|
const initPageData = async() => {
|
|
const initPageData = async() => {
|
|
tableLoading.value = true;
|
|
tableLoading.value = true;
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
|
+
|
|
const dateResult = getStartTimeAndEndTime();
|
|
const dateResult = getStartTimeAndEndTime();
|
|
- const { data } = await getContinuousAssayList({...dateResult, deviceNo: queryParams.value.deviceNo});
|
|
|
|
|
|
+ const { data } = await getContinuousAssayListNew({...dateResult, deviceNo: queryParams.value.deviceNo});
|
|
|
|
|
|
const whiteTableList = [
|
|
const whiteTableList = [
|
|
- // { title: '检测指标', key: 'assayName' },
|
|
|
|
{ title: '实际检测数量', key: 'assayCounts' },
|
|
{ title: '实际检测数量', key: 'assayCounts' },
|
|
- { title: '最小值', key: 'minVal' },
|
|
|
|
- { title: '最大值', key: 'maxVal' },
|
|
|
|
- { title: '合格率(%)', key: 'passedRates' },
|
|
|
|
- { title: '标线(%)', key: 'bx' },
|
|
|
|
- { title: '合格率偏差', key: 'ratesDeviation' }
|
|
|
|
|
|
+ { title: '质控样检测数量', key: 'zkCounts' },
|
|
|
|
+ { title: '质控样合格率(%)', key: 'passedRates' },
|
|
|
|
+ { title: '合格率偏差', key: 'ratesDeviation' },
|
|
]
|
|
]
|
|
-
|
|
|
|
- const tempBodyObject = {};
|
|
|
|
|
|
+
|
|
|
|
+ let assayTotal = 0;
|
|
|
|
+ let zkTotal = 0;
|
|
|
|
+
|
|
const middleData = Object.entries(data).map(([key, value]) => {
|
|
const middleData = Object.entries(data).map(([key, value]) => {
|
|
- const children = Object.entries(value).map(([k, v]) => {
|
|
|
|
- const [child] = v;
|
|
|
|
- tempBodyObject[key + '-' + k] = child;
|
|
|
|
- return {
|
|
|
|
- label: k,
|
|
|
|
- prop: key + '-' + k,
|
|
|
|
- width: 160
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
|
|
+ assayTotal += value['assayCounts']
|
|
|
|
+ zkTotal += value['zkCounts']
|
|
return {
|
|
return {
|
|
- label: key === 'total' ? '' : key,
|
|
|
|
- children
|
|
|
|
|
|
+ label: key,
|
|
|
|
+ prop: key,
|
|
|
|
+ minWidth: 160
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- if ( middleData.length ) {
|
|
|
|
- columns.value = [{ label: '检测点位', fixed: "left", children: [{ label: '检测指标', prop: 'title', width: 150 }]}].concat(middleData);
|
|
|
|
- tableData.value = whiteTableList.map(item => {
|
|
|
|
- const { key } = item;
|
|
|
|
- Object.entries(tempBodyObject).map(([k, v]) => {
|
|
|
|
- item = {
|
|
|
|
- ...item,
|
|
|
|
- [k]: v[key]
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- return item;
|
|
|
|
|
|
+ const tableResultData = whiteTableList.map(item => {
|
|
|
|
+ const { key } = item;
|
|
|
|
+
|
|
|
|
+ Object.entries(data).forEach(([k, v]) => {
|
|
|
|
+ let total = '';
|
|
|
|
+
|
|
|
|
+ if ( key === 'assayCounts' ) total = assayTotal;
|
|
|
|
+
|
|
|
|
+ if ( key === 'zkCounts' ) total = zkTotal;
|
|
|
|
+
|
|
|
|
+ item = {
|
|
|
|
+ total: total === '' ? '' : total,
|
|
|
|
+ ...item,
|
|
|
|
+ ratesDeviationNumber: v['ratesDeviationNumber'],
|
|
|
|
+ [k]: v[key]
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
+ return item;
|
|
|
|
+ })
|
|
|
|
+ console.log(tableResultData)
|
|
|
|
+ if ( middleData.length ) {
|
|
|
|
+ columns.value = [
|
|
|
|
+ { label: '检测指标', width: 200, prop: 'title' },
|
|
|
|
+ ...middleData,
|
|
|
|
+ { label: '合计', width: 200, prop: 'total' }
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ tableData.value = tableResultData;
|
|
} else {
|
|
} else {
|
|
columns.value = [];
|
|
columns.value = [];
|
|
- tableData.value = []
|
|
|
|
|
|
+ tableData.value = [];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // if ( middleData.length ) {
|
|
|
|
+ // columns.value = [{ label: '检测点位', fixed: "left", children: [{ label: '检测指标', prop: 'title', width: 150 }]}].concat(middleData);
|
|
|
|
+ // tableData.value = whiteTableList.map(item => {
|
|
|
|
+ // const { key } = item;
|
|
|
|
+ // Object.entries(tempBodyObject).map(([k, v]) => {
|
|
|
|
+ // item = {
|
|
|
|
+ // ...item,
|
|
|
|
+ // [k]: v[key]
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // return item;
|
|
|
|
+ // });
|
|
|
|
+ // } else {
|
|
|
|
+ // columns.value = [];
|
|
|
|
+ // tableData.value = []
|
|
|
|
+ // }
|
|
tableLoading.value = false;
|
|
tableLoading.value = false;
|
|
loading.value = false;
|
|
loading.value = false;
|
|
}
|
|
}
|
|
@@ -110,33 +169,36 @@ const handlerQuery = () => {
|
|
}
|
|
}
|
|
|
|
|
|
const handlerReset = () => {
|
|
const handlerReset = () => {
|
|
- datePickerValue.value = new Date();
|
|
|
|
- queryParams.value.activeRadioName = 'week';
|
|
|
|
- queryParams.value.deviceNo = ''
|
|
|
|
|
|
+ const [ item ] = options.value;
|
|
|
|
+ datePickerValue.value = [dateBeforeSevenDays.value, new Date()];
|
|
|
|
+ queryParams.value.activeRadioName = 'daterange';
|
|
|
|
+ queryParams.value.deviceNo = item?.deviceNo || '';
|
|
initPageData();
|
|
initPageData();
|
|
}
|
|
}
|
|
|
|
|
|
const handleExport = () => {
|
|
const handleExport = () => {
|
|
const dateResult = getStartTimeAndEndTime();
|
|
const dateResult = getStartTimeAndEndTime();
|
|
- proxy.getDownload("/business/exportContinuousAssayCountByDates", {
|
|
|
|
|
|
+ proxy.getDownload("/business/exportContinuousAssayCountByDatesNew", {
|
|
...dateResult,
|
|
...dateResult,
|
|
deviceNo: queryParams.value.deviceNo
|
|
deviceNo: queryParams.value.deviceNo
|
|
}, `${new Date().getTime()}.xlsx`);
|
|
}, `${new Date().getTime()}.xlsx`);
|
|
}
|
|
}
|
|
|
|
|
|
onMounted(async() => {
|
|
onMounted(async() => {
|
|
- getDeviceList({ type: 2 }).then(({ data }) => {
|
|
|
|
- // const [ item ] = data;
|
|
|
|
- // queryParams.value.deviceNo = item?.deviceNo;
|
|
|
|
|
|
+
|
|
|
|
+ datePickerValue.value = [dateBeforeSevenDays.value, new Date()];
|
|
|
|
+
|
|
|
|
+ await getDeviceList({ type: 2 }).then(({ data }) => {
|
|
|
|
+ const [ item ] = data;
|
|
|
|
+ queryParams.value.deviceNo = item?.deviceNo || '';
|
|
options.value = data
|
|
options.value = data
|
|
});
|
|
});
|
|
|
|
|
|
- initPageData();
|
|
|
|
|
|
+ await initPageData();
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
-
|
|
|
|
<div class="lab-day-viewport space-y-[10px]">
|
|
<div class="lab-day-viewport space-y-[10px]">
|
|
<el-card shadow="never" :body-style="{ border: '0px' }">
|
|
<el-card shadow="never" :body-style="{ border: '0px' }">
|
|
<template #header>
|
|
<template #header>
|
|
@@ -146,28 +208,30 @@ onMounted(async() => {
|
|
</template>
|
|
</template>
|
|
<el-row class="pt-[5px]" justify="space-between" :gutter="20">
|
|
<el-row class="pt-[5px]" justify="space-between" :gutter="20">
|
|
<el-col :span="6">
|
|
<el-col :span="6">
|
|
- <el-form-item label="设备编号">
|
|
|
|
|
|
+ <el-form-item label="设备名称">
|
|
<el-select v-model="queryParams.deviceNo" placeholder="请选择" filterable clearable>
|
|
<el-select v-model="queryParams.deviceNo" placeholder="请选择" filterable clearable>
|
|
<el-option v-for="item in options" :key="item.deviceNo" :label="item.deviceName" :value="item.deviceNo" />
|
|
<el-option v-for="item in options" :key="item.deviceNo" :label="item.deviceName" :value="item.deviceNo" />
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
- <el-col :span="12">
|
|
|
|
|
|
+ <el-col :span="14">
|
|
<div class="flex items-center space-x-[20px]">
|
|
<div class="flex items-center space-x-[20px]">
|
|
<el-form-item label="统计时段">
|
|
<el-form-item label="统计时段">
|
|
<el-radio-group v-model="queryParams.activeRadioName" @change="onRadioChange">
|
|
<el-radio-group v-model="queryParams.activeRadioName" @change="onRadioChange">
|
|
- <el-radio-button label="按周" value="week" />
|
|
|
|
|
|
+ <el-radio-button label="按周" value="daterange" />
|
|
<el-radio-button label="按月" value="month" />
|
|
<el-radio-button label="按月" value="month" />
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item :label="label">
|
|
|
|
|
|
+ <el-form-item>
|
|
<el-date-picker
|
|
<el-date-picker
|
|
v-model="datePickerValue"
|
|
v-model="datePickerValue"
|
|
|
|
+ start-placeholder="开始时间"
|
|
|
|
+ end-placeholder="结束时间"
|
|
|
|
+ placeholder="请选择月份"
|
|
|
|
+ :type="queryParams.activeRadioName"
|
|
:editable="false"
|
|
:editable="false"
|
|
:clearable="false"
|
|
:clearable="false"
|
|
- :type="queryParams.activeRadioName"
|
|
|
|
- :format=format
|
|
|
|
- :placeholder="'请' + label"
|
|
|
|
|
|
+ style="max-width: 280px;"
|
|
@change="onChangeDatePicker"
|
|
@change="onChangeDatePicker"
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -190,14 +254,25 @@ onMounted(async() => {
|
|
plain
|
|
plain
|
|
icon="Download"
|
|
icon="Download"
|
|
@click="handleExport"
|
|
@click="handleExport"
|
|
|
|
+ :loading="loading"
|
|
>导出</el-button>
|
|
>导出</el-button>
|
|
</div>
|
|
</div>
|
|
<el-table :data="tableData" style="width: 100%" v-loading="tableLoading">
|
|
<el-table :data="tableData" style="width: 100%" v-loading="tableLoading">
|
|
- <!-- <el-table-column prop="title" label="检测点位" width="160" fixed="left" header-align="center" /> -->
|
|
|
|
- <el-table-column :label="col.label" :width="col.width || 200" :fixed="col.fixed" align="center" v-for="col, index in columns">
|
|
|
|
- <el-table-column :prop="child.prop" :label="child.label" :width="child.width" v-for="child in col.children"/>
|
|
|
|
|
|
+ <el-table-column
|
|
|
|
+ :prop="col.prop"
|
|
|
|
+ :label="col.label"
|
|
|
|
+ :width="col.width"
|
|
|
|
+ :min-width="col.minWidth || 200"
|
|
|
|
+ :fixed="col.fixed"
|
|
|
|
+ align="center"
|
|
|
|
+ v-for="col, index in columns"
|
|
|
|
+ :formatter="formatter"
|
|
|
|
+ >
|
|
|
|
+ <!-- <template #default="scope">
|
|
|
|
+ {{ scope.row }}
|
|
|
|
+ {{ scope.row[col.prop] }}
|
|
|
|
+ </template> -->
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <!-- <el-table-column prop="totalDeviationRate" label="总质控合格率" width="120" header-align="center" fixed="right" align="center"/> -->
|
|
|
|
</el-table>
|
|
</el-table>
|
|
</el-card>
|
|
</el-card>
|
|
|
|
|