From 5320e0fc3520de4bbd9d08e5cadbbe10f87f74c5 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Mon, 25 Mar 2024 15:07:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=A1=E8=AE=B0=E5=BD=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/instrumentClickinUpload/index.tsx | 45 ++- src/recoding/pages/recording/recording.tsx | 327 +++++++++--------- 2 files changed, 215 insertions(+), 157 deletions(-) diff --git a/src/instrument/pages/instrumentClickinUpload/index.tsx b/src/instrument/pages/instrumentClickinUpload/index.tsx index bc6b85c..71c777c 100644 --- a/src/instrument/pages/instrumentClickinUpload/index.tsx +++ b/src/instrument/pages/instrumentClickinUpload/index.tsx @@ -191,10 +191,15 @@ export default class InstrumentClickInUpload extends Component { let { punchInInfo, instrumentDetail } = this.state; let obj = punchInInfo; if (obj.clockImageList.length === 0) { - msg("至少上传一张图片"); + msg("至少上传一张图片!"); + return; + } + if (!obj.clockContent) { + msg("请输入打卡心得!"); return; } + // 批量上传图片 let promiseTasks: any = []; let imgList: any[] = []; obj.clockImageList.map((imgUrl: string) => { @@ -226,6 +231,11 @@ export default class InstrumentClickInUpload extends Component { } } + Taro.showLoading({ + title: "请求中...", + mask: true, + }); + let clockParmas = { clockImageList: imgList, clockContent: obj.clockContent, @@ -238,8 +248,13 @@ export default class InstrumentClickInUpload extends Component { params ); console.log(instrumentRes, "添加仪器成功"); - + // 上传护理记录 + await this.PostNursingLogClock(); + // 上传打卡记录 let res = await InstrumentInfo.apiClock.postInsertClockLog(clockParmas); + + Taro.hideLoading(); + // 打卡完成 if (res.data.code === 200) { msg("打卡成功"); setTimeout(() => { @@ -250,6 +265,32 @@ export default class InstrumentClickInUpload extends Component { } }; + /** 提交护理记录 */ + PostNursingLogClock = async (data: any = null) => { + let { instrumentDetail, currentInfo } = this.state; + + let params = { + instrumentId: instrumentDetail.id, + instrumentName: instrumentDetail.name, + modeId: currentInfo.id, + modeName: currentInfo.modeName, + nursingTime: "00:01:00", + }; + + let res: any = await InstrumentInfo.apiNursingLog.addLog(params); + console.log("PostNursingLogClock", res); + + if (res.data.code === 200) { + let params = { + instrumentId: instrumentDetail.id, + }; + // 上传护理完成的仪器ID + let res = await InstrumentInfo.apiClock.addClockInstrument(params); + console.log(res, "护理完成"); + } + }; + /*** 护理记录 END ***/ + onPlayTap = async () => { let { videoContext } = this.state; videoContext.play(); diff --git a/src/recoding/pages/recording/recording.tsx b/src/recoding/pages/recording/recording.tsx index f3c6f1a..628459d 100644 --- a/src/recoding/pages/recording/recording.tsx +++ b/src/recoding/pages/recording/recording.tsx @@ -61,14 +61,14 @@ export default class Recording extends Component { clockImageList: [], clockContent: "", }, - navigationBarHeight: '', - statusBarHeight: '' + navigationBarHeight: "", + statusBarHeight: "", }; } - componentDidMount() { } + componentDidMount() {} - componentWillUnmount() { } + componentWillUnmount() {} // 格式化时间 getTime(time) { const hour = time.slice(0, 2); @@ -270,15 +270,13 @@ export default class Recording extends Component { this.getClockStatistics(); this.DayTime(); this.setStatusBar(); - } - componentDidShow() { } + componentDidShow() {} - componentDidHide() { } + componentDidHide() {} - async initData() { - } + async initData() {} // 选择年份 onChangeYear(event) { this.setState({ year: event.detail.value }); @@ -294,12 +292,12 @@ export default class Recording extends Component { }; // 跳转到护理报告 toReport(id, recordId, item) { - this.state.bindingInstrumentList.map(instrument => { + this.state.bindingInstrumentList.map((instrument) => { if (instrument.id == id) { setStorageSync("instrument_detail", instrument); } - }) - console.log(item, '查看'); + }); + console.log(item, "查看"); if ([1, 2, 3, 4, 5].includes(item.jumpType)) { this.One(item); @@ -316,22 +314,23 @@ export default class Recording extends Component { } // 打开第一种类型 One = async (item) => { - let ids = Number(item.id) + let ids = Number(item.id); // 获取echarts数据 这个是获取接口更新echarts页面 let res2 = await InstrumentInfo.apiNursingLog.getStatiCDE(ids); - let nursingData = JSON.parse(res2.data.data.nursingData) + let nursingData = JSON.parse(res2.data.data.nursingData); let obj = { modeName: res2.data.data.modeName, - data: nursingData - } + data: nursingData, + }; let report = false; go( "/recoding/pages/face_report_one/face_report_one?id=" + - item.id + - "&report=" + - report + "&obj=" + - JSON.stringify(obj) + item.id + + "&report=" + + report + + "&obj=" + + JSON.stringify(obj) ); }; // 打开第二种类型 @@ -340,64 +339,74 @@ export default class Recording extends Component { let report = false; go( "/recoding/pages/face_report/face_report?id=" + - item.id + - "&recordId=" + item.instrumentId + - "&report=" + - report + item.id + + "&recordId=" + + item.instrumentId + + "&report=" + + report ); }; // 打开第三种类型 three = async (item) => { - this.moistureTest(item) + this.moistureTest(item); }; async moistureTest(allData) { let data = { queryDate: allData.createTime, - instrumentId: allData.instrumentId - } + instrumentId: allData.instrumentId, + }; let res = await InstrumentInfo.fr200.moistureTest(data); - console.log(res,'查看返回数据'); - - let echartsData = res.data.rows + console.log(res, "查看返回数据"); + + let echartsData = res.data.rows; for (let i = 0; i < echartsData.length; i++) { for (let j = i + 1; j < echartsData.length; j++) { - if (echartsData[i].createTime.split(' ')[0] == echartsData[j].createTime.split(' ')[0]) { - let result = Date.parse(echartsData[i].createTime) - Date.parse(echartsData[j].createTime) + if ( + echartsData[i].createTime.split(" ")[0] == + echartsData[j].createTime.split(" ")[0] + ) { + let result = + Date.parse(echartsData[i].createTime) - + Date.parse(echartsData[j].createTime); if (result < 0) { - echartsData.splice(i, 1) + echartsData.splice(i, 1); } else { - echartsData.splice(j, 1) + echartsData.splice(j, 1); } } } } - let gears: any = [] - let eDate: any = [] - console.log(echartsData,'echartsDataechartsData'); - - echartsData.map(item => { - - const result = item.createTime.split(' ')[0].substring(5); - eDate.push(result) - item.nursingData = JSON.parse(item.nursingData) - let level: any = 0 - item.nursingData?.GearData?.map(gear => { - level = level + gear.forehead - }) - level = Math.floor(level / 3) - gears.push(level) - }) + let gears: any = []; + let eDate: any = []; + console.log(echartsData, "echartsDataechartsData"); + + echartsData.map((item) => { + const result = item.createTime.split(" ")[0].substring(5); + eDate.push(result); + item.nursingData = JSON.parse(item.nursingData); + let level: any = 0; + item.nursingData?.GearData?.map((gear) => { + level = level + gear.forehead; + }); + level = Math.floor(level / 3); + gears.push(level); + }); echartsData = { - gears, eDate - } - setStorageSync('moistureEachtsData', JSON.stringify(echartsData)) - - go(`/recoding/pages/moisture_test_report/moisture_test_report?data=${allData.nursingData}&date=${allData.createTime}&modeId=${allData.modeId}&id=${allData.instrumentId}&echartsData=${JSON.stringify(echartsData)}`); + gears, + eDate, + }; + setStorageSync("moistureEachtsData", JSON.stringify(echartsData)); + go( + `/recoding/pages/moisture_test_report/moisture_test_report?data=${ + allData.nursingData + }&date=${allData.createTime}&modeId=${allData.modeId}&id=${ + allData.instrumentId + }&echartsData=${JSON.stringify(echartsData)}` + ); } - // 打开其他类型 AllDevice = async (item) => { console.log("打开其他类型", item); @@ -476,7 +485,6 @@ export default class Recording extends Component { } setStatusBar() { - Taro.getSystemInfoAsync({ success: (res) => { const statusBarHeight = res.statusBarHeight || 0; @@ -511,17 +519,20 @@ export default class Recording extends Component { show, punchInInfo, navigationBarHeight, - statusBarHeight + statusBarHeight, } = this.state; const statusBarHeightRpx = statusBarHeight * 2; const navigationBarHeightRpx = navigationBarHeight * 2; - const height = statusBarHeightRpx + navigationBarHeightRpx + const height = statusBarHeightRpx + navigationBarHeightRpx; return ( - - + { {current === 0 && ( - { onClick={this.onChangeProduct.bind(this, item.id)} > - {item.name} + {item.name} ))} @@ -576,17 +591,17 @@ export default class Recording extends Component { {current === 0 && recordList.length === 0 && ( - + - 暂无数据 + 暂无数据 )} {current === 0 && ( - + {/* @@ -613,12 +628,12 @@ export default class Recording extends Component { */} - + {recordList.map((item: any, index: any) => ( - - - - {item.createTime} + + + + {item.createTime} { {item.instrumentType === 2 && ( { > 回看报告 )} - + - - {item.instrumentName} - - 模式:{item.modeName} - - 护理时间:{item.nursingTime} + + {item.instrumentName} + + 模式:{item.modeName} + + {item.instrumentType === 2 && ( + 护理时间:{item.nursingTime} + )} @@ -667,7 +684,7 @@ export default class Recording extends Component { )} {current === 1 && ( - + {/* { > 暂无数据 */} - - - - 年度打卡统计 + + + + 年度打卡统计 - + {year}年 - + {monthTime.map((item) => ( - + {item.time > 0 && ( - {item.time}天 + {item.time}天 )} - {item.month} + {item.month} ))} - - + + {clockStatistics.map((item) => ( - - - + + + {item.year}年{item.month}月 { item.month )} > - + {" "} {!item.isMore ? "展开更多" : "收起更多"} @@ -738,51 +755,51 @@ export default class Recording extends Component { ? "rotate(180deg)" : "rotate(0deg)", }} - className='more_icon' + className="more_icon" src={require("@/img/arrow-down.png")} - mode='widthFix' + mode="widthFix" > - - - - {item.clockNum} - 本月打卡天数 + + + + {item.clockNum} + 本月打卡天数 - - + + {(item.percentage * 100).toFixed(2)}% - 超越花至用户 + 超越花至用户 - + {item.isMore && item.detail && ( {item.detail.map((obj) => ( - - - + + + {obj.updateTime} - + {obj.clockImg.map((img) => ( ))} - + {/* 小紫弹智能射频仪、花至抗老射频仪PRO{" "} */} {obj.instrumentName === null ? "" : obj.instrumentName} - + {obj.clockContent} @@ -797,8 +814,8 @@ export default class Recording extends Component { )} {!clockShow && ViewAddInstrument === "true" && ( - - + + 前往打卡 {/* @@ -808,64 +825,64 @@ export default class Recording extends Component { )} this.setState({ show: false })}> - + - 今日打卡 - + 今日打卡 + 本月您已打卡 - {clockStatistics[0]?.clockNum}{" "} + {clockStatistics[0]?.clockNum}{" "} 天,超越 - + {(clockStatistics[0]?.percentage * 100).toFixed(1)}% 花至用户 - + {punchInInfo.clockImageList.map((item, index) => ( - - + + ))} {punchInInfo.clockImageList.length < 3 && ( )} - - + + - + {"(" + (punchInInfo.clockContent.length || 0) + "/120)"} - - + + 确认提交