From 2cf0e718f7c4b4bbc6346ee19acb734c47de2669 Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 18 Aug 2023 14:41:52 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=AE=8C=E6=88=90=E8=B4=A8=E9=87=8F-?= =?UTF-8?q?=E6=9C=80=E8=BF=9124=E5=B0=8F=E6=97=B6=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/dynamicData.js | 4 --- src/utils/dynamicProps.js | 25 ++++++++++++-- .../monitoring/qualityRecentHours/index.vue | 34 +++++++++++-------- 3 files changed, 41 insertions(+), 22 deletions(-) delete mode 100644 src/utils/dynamicData.js diff --git a/src/utils/dynamicData.js b/src/utils/dynamicData.js deleted file mode 100644 index 3d57ce4c..00000000 --- a/src/utils/dynamicData.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 用于调整服务器返回的动态数据 - */ -export default function handleDynamicData() {} diff --git a/src/utils/dynamicProps.js b/src/utils/dynamicProps.js index c1a5f275..b0a9e643 100644 --- a/src/utils/dynamicProps.js +++ b/src/utils/dynamicProps.js @@ -1,9 +1,9 @@ /** * 用于动态表结构的 tableProps 生成 - * @param {*} nameData - * @returns + * @param {*} nameData + * @returns */ -export default function handleNameData(nameData) { +export function handleNameData(nameData) { const props = step1(nameData.filter((item) => item.tree == 1)); step2( props, @@ -42,3 +42,22 @@ function step2(firstTierProps, tree2) { function notRepeat(propArray, name) { return propArray.every((item) => item.label !== name); } + +/** + * 用于调整服务器返回的动态数据 + * @param {*} dynamicData + * @returns + */ +export function handleDynamicData(dynamicData) { + return dynamicData.map((dd) => { + const initData = { + inspectionContent: dd.inspectionDetContent, + }; + dd.data.forEach((column) => { + column.children.forEach((ch) => { + initData[`${column.dynamicName}-${ch.dynamicName}`] = ch.dynamicValue; + }); + }); + return initData; + }); +} diff --git a/src/views/quality/monitoring/qualityRecentHours/index.vue b/src/views/quality/monitoring/qualityRecentHours/index.vue index 435ade7a..84b38a39 100644 --- a/src/views/quality/monitoring/qualityRecentHours/index.vue +++ b/src/views/quality/monitoring/qualityRecentHours/index.vue @@ -11,7 +11,10 @@ :formConfigs="[{ label: '近24小时检测记录', type: 'title' }]" ref="search-bar" /> + + import response from './response.json'; -import handleNameData from '@/utils/dynamicProps'; -import handleDynamicData from '@/utils/dynamicData'; +import { handleNameData, handleDynamicData } from '@/utils/dynamicProps'; // import hljs from 'highlight.js/lib/highlight'; // import json from 'highlight.js/lib/languages/json'; // import 'highlight.js/styles/github-gist.css'; @@ -36,24 +38,21 @@ export default { props: {}, data() { return { + initing: false, queryParams: { pageNo: 1, pageSize: 10, }, // jsondemo: '', list: [ - { - inspectionContent: '检测内容1', - '2023-03-18T00:00:00-产线1': '产线1-asdf', - '2023-03-18T01:00:00-产线2': '产线2-kldf', - '2023-03-18T02:00:00-产线1': '产线1-vasdkj', - }, + // { + // inspectionContent: '检测内容1', + // '2023-03-18T00:00:00-产线1': '产线1-asdf', + // '2023-03-18T01:00:00-产线2': '产线2-kldf', + // '2023-03-18T02:00:00-产线1': '产线1-vasdkj', + // }, ], tableProps: [ - { - type: 'index', - label: '序号' - }, { prop: 'inspectionContent', label: '检测内容', @@ -86,11 +85,16 @@ export default { data: { data: dyanmicData, nameData }, } = response; + this.initing = true; const dynamicProps = handleNameData(nameData); - this.tableProps.push(...dynamicProps) - const [dataList, length] = handleDynamicData(dyanmicData); + this.tableProps.push(...dynamicProps); + const dataList = handleDynamicData(dyanmicData); this.list = dataList; - this.queryParams.pageSize = length; + this.queryParams.pageSize = dataList.length; + + setTimeout(() => { + this.initing = false; + }, 1000); }, handleEmitFun(payload) {