diff --git a/appStore/userConfig/views.py b/appStore/userConfig/views.py index 97b4fa35bbdbfd0c637afb8c4440b219db57b3dc..b183989c6adf1eb6288a3985d88caa1840247e5e 100644 --- a/appStore/userConfig/views.py +++ b/appStore/userConfig/views.py @@ -10,7 +10,6 @@ from appStore.userConfig.serializers import UserConfigSerializer from appStore.utils.common import json_response from appStore.utils.customer_view import CusModelViewSet # Create your views here. - class UserConfigViewSet(CusModelViewSet): """ 用户配置数据管理 diff --git a/templates/front-project/src/components/RightTable.vue b/templates/front-project/src/components/RightTable.vue deleted file mode 100644 index dff7c61353524350c45256364701f33fb53b4a92..0000000000000000000000000000000000000000 --- a/templates/front-project/src/components/RightTable.vue +++ /dev/null @@ -1,246 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/templates/front-project/src/components/TableHeader.vue b/templates/front-project/src/components/TableHeader.vue deleted file mode 100644 index a9c28048cfa859e7cdc51f4f30dbefba75e035a6..0000000000000000000000000000000000000000 --- a/templates/front-project/src/components/TableHeader.vue +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/templates/front-project/src/utils/utils.js b/templates/front-project/src/utils/utils.js index 6fe997f32c66bac8b546c63bf1e2996fde2d05ef..c62d0be20e60030d115d6c8159ec5a5580668427 100644 --- a/templates/front-project/src/utils/utils.js +++ b/templates/front-project/src/utils/utils.js @@ -5,46 +5,129 @@ * Author: wqz * Date: Wed May 22 14:08:49 2024 +0800 */ -export default { - data() { - return { - currentPage: 1, //当前页数 - pageSize: 10, // 每页显示条数 - total: 0, // 总条数 - itemKey: 0, //更新数据后生成随机数从而刷新页面数据 - }; - }, +import {ElMessage} from 'element-plus'; +import {down_message} from "@/api/api"; - methods: { - //分页 - handleSizeChange(val) { - this.pageSize = val; - this.currentPage = 1; - }, - //分页 - handleCurrentChange(val) { - this.currentPage = val; - }, - //处理展示的数据 - handleDataLoaded(value) { - this.showAllData = value; - // 在这里处理子组件的数据 +export default { + data() { + return { + currentPage: 1, //当前页数 + pageSize: 10, // 每页显示条数 + total: 0, // 总条数 + itemKey: 0, //更新数据后生成随机数从而刷新页面数据 + }; }, - //选择框只能单选 - handleSelection(val) { - this.testData = val[0]; - if (val.length > 1) { - this.$refs.testTable.clearSelection(); - this.$refs.testTable.toggleRowSelection(val.pop()); - } + computed: { + //分页展示当前页面 + showData() { + return this.allDatas.slice( + (this.currentPage - 1) * this.pageSize, + this.currentPage * this.pageSize + ); + }, + //数据详情页面的展示全部数据和展示平均数据 + displayTableData() { + if (this.showAllData) { + return this.tableDatas; + } else { + let count = 1; + const modifiedTableData = JSON.parse(JSON.stringify(this.tableDatas)); // 深拷贝原始数据 + modifiedTableData.forEach(row => { + Object.entries(row).forEach(([key, value]) => { + if (typeof value === 'string' && key.startsWith('column') && value.startsWith('平均值')) { + row[key] = value + this.dataName.charAt(0).toUpperCase() + this.dataName.slice(1) + "#" + `${count}`; // 将"平均值"替换为"this.dataName#" + count++; + } + }); + }); + return modifiedTableData; + } + } }, - //数据页面时点击后跳转至对应数据详情页面 - handleRowClick(row) { - const List1 = [row.stream, row.lmbench, row.unixbench, row.fio, row.iozone, row.jvm2008, row.cpu2006, row.cpu2017] - const List2 = ['stream', 'lmbench', 'unixbench', 'fio', 'iozone', 'jvm2008', 'cpu2006', 'cpu2017'] - const firstNonZeroIndex = List1.findIndex(num => num !== 0); - this.selectedType = List2[firstNonZeroIndex] - this.$router.push({name: this.selectedType, "params": {baseId: row.env_id, comparsionIds: ''}}); + methods: { + //分页 + handleSizeChange(val) { + this.pageSize = val; + this.currentPage = 1; + }, + //分页 + handleCurrentChange(val) { + this.currentPage = val; + }, + //下载日志 + downLog(row) { + down_message({result_log_name: row.result_log_name}).then((response) => { + const url = window.URL.createObjectURL(new Blob([response.data])) + const link = document.createElement('a') + link.href = url + link.setAttribute('download', 'log.tar') + document.body.appendChild(link) + link.click() + }).catch(error => { + if (error.code === "ERR_BAD_REQUEST") { + ElMessage({message: "下载失败没有找到对应日志", type: 'warning'}) + } + console.log(error) + }).finally(() => { + // excelDisabled 将被设置为 true,然后立即被设置为 false,禁用的时间非常短,不足以被用户察觉到。 + this.excelDisabled = false; + }); + }, + //处理展示的数据 + handleDataLoaded(value) { + this.showAllData = value; + // 在这里处理子组件的数据 + }, + //对比数据的样式和颜色 + getCellClassName(row, key) { + let value = row[key]; + if (typeof value === 'string' && value.endsWith('%')) { + // 去除百分比符号 "%" + value = value.replace('%', ''); + // 将百分比转换为小数 + value = parseFloat(value); + if (value >= 5) { + return 'green-cell'; + } else if (value < -5) { + return 'red-cell'; + } + } + return ''; + }, + // 单元格合并 当前行row、当前列column、当前行号rowIndex、当前列号columnIndex + objectSpanMethod({rowIndex, columnIndex}) { + //columnIndex 表示需要合并的列,多列时用 || 隔开 + if (columnIndex === 0) { + const _row = this.filterData(this.tableDatas, columnIndex).one[rowIndex]; + const _col = _row > 0 ? 1 : 0; // 为0是不执行合并。 为1是从当前单元格开始,执行合并1列 + return { + rowspan: _row, + colspan: _col, + } + } + }, + filterData(arr, colIndex) { + let spanOneArr = []; + let concatOne = 0; + arr.forEach((item, index) => { + if (index === 0) { + spanOneArr.push(1); + } else { + //first second 分别表示表格数据第一列和第二列对应的参数字段,根据实际参数修改 + if (colIndex === 0) { + if (item.column1 === arr[index - 1].column1) { + spanOneArr[concatOne] += 1; + spanOneArr.push(0); + } else { + spanOneArr.push(1); + concatOne = index; + } + } + } + }); + return { + one: spanOneArr, + }; + }, }, - }, }; \ No newline at end of file