From af205347e67a4baf49a27d29f5c7a650c55e659f Mon Sep 17 00:00:00 2001 From: qsj <731458905@qq.com> Date: Fri, 22 Mar 2024 10:39:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E7=9C=8B=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/moduleIOT/pages/iotCarePlan/FR200.tsx | 5 +- .../components/Echart_face/index.tsx | 161 +++++++++++++++++- .../pages/face_report/face_report.tsx | 27 +-- .../pages/face_report_one/face_report_one.tsx | 18 +- src/recoding/pages/recording/recording.tsx | 11 +- src/utils/Interface.js | 22 +++ 6 files changed, 217 insertions(+), 27 deletions(-) diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.tsx b/src/moduleIOT/pages/iotCarePlan/FR200.tsx index ffa1282..e99ade6 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.tsx +++ b/src/moduleIOT/pages/iotCarePlan/FR200.tsx @@ -2020,9 +2020,12 @@ class IotCarePlanFR200 extends Component { } else if ("moistureTest" === nursingData.workMode) { console.log("水分测试"); } else { + let report = true; go( "/recoding/pages/face_report/face_report?id=" + - this.state.currentDevice.id + this.state.currentDevice.id+ + "&report=" + + report ); } }; diff --git a/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx b/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx index 189ff3a..7a5fb0f 100644 --- a/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx +++ b/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx @@ -4,7 +4,10 @@ import { Block, View, Image, Text, Input } from "@tarojs/components"; import { Popup, Progress, Slider } from "@antmjs/vantui"; import { useRef } from "react"; import Echarts, { EChartOption, EchartsHandle } from "taro-react-echarts"; -import echarts from "@/utils/echarts.min.js"; +// import echarts from "@/utils/echarts.min.js"; +import * as echarts from "echarts"; + +import React, { useState, useEffect,useMemo } from 'react'; import "./index.less"; @@ -15,7 +18,11 @@ interface Props { function Index({ EchartsData }:Props) { + + let type =0 + // console.log(EchartsData,'EchartsDataEchartsData'); + switch(EchartsData.modeName) { case '基础班脸部': type=37 @@ -35,7 +42,15 @@ function Index({ default: } + // const chartRef = useRef(null); + // console.log(chartRef,'chartRefchartRef'); + + // let chartInstance = echarts.init(chartRef.current); const echartsRef = useRef(null); + // const echartsRef = useRef< null>(null); + // let echartsRef:any = React.createRef();; + // console.log(chartRef,'echartsRefechartsRef',chartInstance); + function generateColorArray(startColor, endColor, steps) { var startRGB = hexToRgb(startColor); var endRGB = hexToRgb(endColor); @@ -73,18 +88,16 @@ function Index({ const colors = generateColorArray(startColor, endColor, steps); -const xList = [...new Array(type).fill(0).map((item, key) => key)]; +// const xList = [...new Array(type).fill(0).map((item, key) => key)]; let seriesData:any =[] seriesData = EchartsData?.data?.groupedAa -// const xList = [...new Array(37).fill(0).map((item, key) => key)]; +const xList = [...new Array(37).fill(0).map((item, key) => key)]; // const seriesData = [ // ...xList.map((item) => { // return Math.random() * 80; // }), // ]; - - - const option: EChartOption ={ +let [option, setOption] = useState({ grid: { // 让图表占满容器 top: "10rpx", @@ -165,8 +178,140 @@ seriesData = EchartsData?.data?.groupedAa }, }, ], - }; - let arr = [2, 3, 4, 5, 6, 7] + }) + useEffect(() =>{ + setOption({...option, + + series:[ + + { + barCategoryGap: '0%', + data: [11,22,33,44,55,55], + type: "bar", + // barWidth: 15, + gapWidth: "0%", + itemStyle: { + normal: { + color: function (params) { + var value = params.data; + return new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { + offset: 0, + color: colors[parseInt(value)], // 红色 + }, + { + offset: 1, + color: colors[0], // 黄色 + }, + ]);; + }, + }, + }, + }, + ]}) + console.log(option,'optionoption',xList); + + },[EchartsData]) + // 基于 EchartsData 生成 ECharts 配置 +// const option: EChartOption ={ +// grid: { +// // 让图表占满容器 +// top: "10rpx", +// left: "45rpx", +// right: "28rpx", +// bottom: "17rpx", +// }, +// xAxis: { +// type: "category", +// data: [...xList], +// axisLabel: { +// interval: 5, +// formatter: function (value, index) { +// return value * 10 + 's'; +// }, +// textStyle: { +// color: '#999999', // 文字颜色 +// fontSize: 8 // 文字大小 +// }, +// }, +// axisTick: { +// // alignWithLabel: true, +// show: false, +// interval: 9, +// }, +// // axisLine: { +// // show: false, +// // }, +// }, +// yAxis: [ +// { +// min: 0, +// max: 80, +// splitNumber: 10, +// axisLabel: { +// formatter: function (value, index) { +// const num = value / 10 + 1 +// return num === 9 ? '' : num + '级'; +// }, +// textStyle: { +// color: '#999999', // 文字颜色 +// fontSize: 8 // 文字大小 +// }, +// }, +// type: "value", +// splitLine: { +// lineStyle: { +// color: ["#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#fff"], +// type: 'dashed' +// }, +// } +// }, +// ], +// series: [ + +// { +// barCategoryGap: '0%', +// data: seriesData, +// type: "bar", +// // barWidth: 15, +// gapWidth: "0%", +// itemStyle: { +// normal: { +// color: function (params) { +// var value = params.data; +// return new echarts.graphic.LinearGradient(0, 0, 0, 1, [ +// { +// offset: 0, +// color: colors[parseInt(value)], // 红色 +// }, +// { +// offset: 1, +// color: colors[0], // 黄色 +// }, +// ]);; +// }, +// }, +// }, +// }, +// ], +// }; +// const chartOptions = useMemo(() => { + +// console.log(option,'optionoptionoption'); + +// return option; +// }, [EchartsData]); + + + +// // 使用 useMemo 来记住创建的 ECharts 实例 +// const chartRef = useMemo(() => { + + +// return option; +// }, []); // 空数组意味着 chartRef 仅在组件挂载时创建一次 + + return ( { } } - async getRecord(id, recordId) { - console.log("id, recordId", id, recordId); + async getRecord(id, instrumentId) { + console.log("id, instrumentId", id, instrumentId); let data = {}; if (id != null) { - data["instrumentId"] = id; + data["instrumentId"] = instrumentId; } + // 获取当前 + let res1 = await InstrumentInfo.apiNursingLog.getRecordNow(id); + // 获取历史记录列表 let res = await InstrumentInfo.apiNursingLog.getRecord(data); + + res1.data.data.nursingTime = this.getTime(res1.data.data.nursingTime); + res1.data.data.createTime = getdates(res1.data.data.createTime).replace(/-/g, "."); + + this.setState({ recordData: res1.data.data }); + if (res.data.code === 200) { - if (recordId) { + if (instrumentId) { res.data.rows.map((item) => { item.nursingTime = this.getTime(item.nursingTime); item.createTime = getdates(item.createTime).replace(/-/g, "."); - - if (item.id == recordId) { - this.setState({ recordData: item }); - } }); - } else { - this.setState({ recordData: res.data.rows[0] }); } this.setState({ - recordList: res.data.rows.filter((item) => item.id != recordId), + recordList: res.data.rows.filter((item) => item.id != instrumentId), }); } } @@ -313,7 +316,7 @@ export default class Index extends Component { - {recordData.createTime} + {recordData?.createTime} { if (id != null) { data["instrumentId"] = id; } - let res = await InstrumentInfo.apiNursingLog.getStatistics(data); - + let res = await InstrumentInfo.apiNursingLog.getStatisticsFace(data); + let res2 = await InstrumentInfo.apiNursingLog.getStatiCDE(id); + let nursingData=JSON.parse(res2.data.data.nursingData) + let obj ={ + modeName:res2.data.data.modeName, + data:nursingData + } + this.init({ + obj:JSON.stringify(obj) + }) if (res.data.code === 200) { this.setState({ statistics: res.data.data }); } @@ -275,12 +283,15 @@ export default class Index extends Component { reportShow: Bool }) } - this.init(options) + // this.init(options) this.getRouteId(); // this.getClockStatistics() } init(options){ + let obj =JSON.parse(options.obj) +console.log(obj,'obj111111111111111'); + let recordData =this.state.recordData let modeImage =this.state.modeImage @@ -309,7 +320,6 @@ export default class Index extends Component { } this.setState({recordData,modeImage,EchartsData:{...obj}}) - console.log(obj,'查看'); } diff --git a/src/recoding/pages/recording/recording.tsx b/src/recoding/pages/recording/recording.tsx index 2a3587d..c55b2ba 100644 --- a/src/recoding/pages/recording/recording.tsx +++ b/src/recoding/pages/recording/recording.tsx @@ -327,13 +327,20 @@ export default class Recording extends Component { "/recoding/pages/face_report_one/face_report_one?id=" + item.id + "&report=" + - report+ "&obj=" + - JSON.stringify(obj) + report ); }; // 打开第二种类型 two = async (item) => { console.log("打开第二种类型", item); + let report = false; + go( + "/recoding/pages/face_report/face_report?id=" + + item.id + + "&recordId=" + item.instrumentId+ + "&report=" + + report + ); }; // 打开第三种类型 three = async (item) => { diff --git a/src/utils/Interface.js b/src/utils/Interface.js index 185b282..8e89ec0 100644 --- a/src/utils/Interface.js +++ b/src/utils/Interface.js @@ -406,6 +406,13 @@ export const InstrumentInfo = { url: "/nursingLog/record" + paramsToUrlQueryString(data), method: "get", }); + }, + /**查询用户护理记录(当前)*/ + getRecordNow: (data) => { + return Ajax({ + url: `/nursingLog/${data}` , + method: "get", + }); }, /**查询用户护理记录的当月统计信息*/ getStatistics: (data) => { @@ -414,6 +421,21 @@ export const InstrumentInfo = { method: "get", }); }, + /*脸部能量时间*/ + getStatisticsFace: (data) => { + return Ajax({ + url: "/nursingLog/fr200/statistics" + paramsToUrlQueryString(data), + method: "get", + }); + }, + /**获取脸部能量图数据*/ + getStatiCDE: (data) => { + + return Ajax({ + url: `/nursingLog/${data}`, + method: "get", + }); + }, }, }; //localhost:9204/instrument/getInstrumentInfoBySerial