fix:临时提交

master
blak-kong 2 years ago
parent b426251c83
commit a1d3824adf

@ -5,18 +5,18 @@ import { useState, useEffect } from "react";
import "./index.less";
interface Props {
isCanClick: boolean;
isShowNurse: boolean;
isStopNurse: boolean;
isDisabled: boolean; // 是否禁用开始暂停按钮:模式与连接设备是否一致
onEmitStartNurse: Function; // 每次点击item回调事件和数据给父组件
onEmitSwitchChange: Function;
onEmitEndPlan: Function;
onEmitErrorTips: Function; // 不可点击,提示错误
}
function Index({
isCanClick,
isShowNurse,
isStopNurse,
isDisabled,
onEmitStartNurse,
onEmitSwitchChange,
onEmitEndPlan,
@ -27,7 +27,9 @@ function Index({
};
const onSwitchChange = () => {
onEmitSwitchChange();
if (!isDisabled) {
onEmitSwitchChange();
}
};
const onEndPlan = () => {
@ -43,12 +45,12 @@ function Index({
<View className="footer">
{!isShowNurse && (
<Block>
{isCanClick ? (
<View className="btn" onClick={onStartNurse}>
{isDisabled ? (
<View className="btn btn-disable" onClick={onStartNurse}>
</View>
) : (
<View className="btn btn-disable" onClick={onStartNurse}>
<View className="btn" onClick={onStartNurse}>
</View>
)}
@ -56,7 +58,7 @@ function Index({
)}
{isShowNurse && (
<View className="switch-btn-box">
{isCanClick && (
{!isDisabled && (
<View className="btn-item border-right" onClick={onSwitchChange}>
{isStopNurse ? (
<Block>
@ -79,8 +81,11 @@ function Index({
)}
</View>
)}
{!isCanClick && (
<View className="btn-item border-right" onClick={onErrorTips}>
{isDisabled && (
<View
className="btn-item border-right btn-disable"
onClick={onErrorTips}
>
{isStopNurse ? (
<Block>
<Image

@ -169,7 +169,6 @@ class IotCarePlan extends Component<any, any> {
/** 连接设备 End */
/** 护理过程 */
isCanClick: false, // 是否可以点击开始按钮/启动暂停
isStandStatus: false, // 当前模式是否舱体/支架模式
isShowStepTips: false, // 是否显示介绍步骤弹窗
isConnectionBlutoot: true, // 是否已连接蓝牙
@ -220,6 +219,9 @@ class IotCarePlan extends Component<any, any> {
// 上一次护理记录未生成,是否继续连接设备
isShowReReadRecordConnect: false,
// 按钮是否可运行
isFooterBtnDisabled: false,
};
}
@ -371,6 +373,7 @@ class IotCarePlan extends Component<any, any> {
isConnectionBlutoot: false, // 断开蓝牙
isShowCountdown: false, // 关闭倒计时,防止倒计时还在运行
});
this.footerIsDisabled();
};
GetModeList = async (id) => {
@ -429,21 +432,21 @@ class IotCarePlan extends Component<any, any> {
// 护理检查改变模式,是否提示切换护理模式
// isNotCheck为真时不进行校验直接切换
this.tempModeCurrent = data;
this.footerIsDisabled();
if (!isNotCheck) {
let isReturn = this.modeRuningChange();
if (isReturn) return;
}
let { isStandStatus, isShowNurse } = this.state;
// 舱体模式无法对应的时候,置灰开始按钮
let isCabinMode = data.isCabinMode === 1;
if (isStandStatus === isCabinMode) {
this.setState({ isCanClick: true }); // 是否舱体一致时,可以点击
} else {
this.setState({ isCanClick: false });
}
console.log("isStandStatus", isStandStatus, isCabinMode);
console.log("isStandStatus === isCabinMode", isStandStatus === isCabinMode);
// let isCabinMode = data.isCabinMode === 1;
// if (isStandStatus === isCabinMode) {
// this.setState({ isCanClick: true }); // 是否舱体一致时,可以点击
// } else {
// this.setState({ isCanClick: false });
// }
let currentServiceData = {
startSource: "",
@ -595,22 +598,19 @@ class IotCarePlan extends Component<any, any> {
};
/** 开始护理按钮:点击开始,页面进行到下一步 */
onStartNurse = async () => {
// 开发者工具
// const platform = Taro.getSystemInfoSync().platform;
// if (platform === "devtools") {
// // 仅开发者工具,直接运行
// this.stepNext();
// }
let { isStandStatus, ActiveModeItem } = this.state;
let isCabinMode = ActiveModeItem.isCabinMode === 1;
if (isStandStatus === isCabinMode) {
// 如果检查通过,可运行,则执行下一步
if (!this.footerIsDisabled()) {
this.stepNext();
return;
}
// 如果检查失败,则报错
this.onEmitErrorTips();
};
/** 不可切换光照提示 */
/**
* @name
* @description isCabinMode 0. 1.
*/
onEmitErrorTips = async () => {
let { isStandStatus, ActiveModeItem } = this.state;
if (isStandStatus) {
@ -653,54 +653,76 @@ class IotCarePlan extends Component<any, any> {
/** 蓝牙相关 */
switchBLEMatch = (jsonStatus: any) => {
console.log("蓝牙相关", jsonStatus);
let { ActiveModeItem } = this.state;
switch (jsonStatus.bleCommandType) {
// 如果设备配对链接发送配对码的时候,设备应答小程序配对码是否正确。
case "SendMatchCode":
if (jsonStatus.matchedSuccess) {
console.log("设备配对成功");
this.setState({
facialMaskConnectStatus: true,
facialMaskConnectStatus: 1,
});
}
break;
// 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了
// 设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了
case "BleStatusSync":
console.log("BleStatusSync 附属设备状态主动上报", jsonStatus);
switch (jsonStatus.connectMessage?.deviceName) {
case "WL200":
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
} else {
// 清除时间倒计时定时器
this.setState({
facialMaskConnectStatus: 0, // 蓝牙断开
isFooterBtnDisabled: false, // 蓝牙断开所以不可点击
});
// 断开连接直接暂停
this.judgementWorkStatus(
MODE_WORKING_ENUM.PAUSE,
ActiveModeItem?.modeType
);
// 设备断开时,给定一个断开时间
ActiveModeItem.breakTimeStr = this.state.currentTime;
}
break;
// 附属设备是否连接支架
case "Stand":
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
console.log("舱体支架连接");
this.setState({
isStandStatus: true,
isCanClick: this.state.ActiveModeItem?.isCabinMode === 1,
});
if (!this.state.isStandStatus && this.isRuning) {
// 断开连接直接暂停
this.judgementWorkStatus(
MODE_WORKING_ENUM.PAUSE,
this.state.ActiveModeItem?.modeType
ActiveModeItem?.modeType
);
}
} else {
console.log("舱体支架断开连接");
if (this.state.isStandStatus && this.isRuning) {
// 断开连接直接暂停
this.judgementWorkStatus(
MODE_WORKING_ENUM.PAUSE,
this.state.ActiveModeItem?.modeType
ActiveModeItem?.modeType
);
}
// 设备断开时,给定一个断开时间
ActiveModeItem.breakTimeStr = this.state.currentTime;
this.setState({
isStandStatus: false,
isCanClick: this.state.ActiveModeItem?.isCabinMode !== 1,
isStopNurse: true,
ActiveModeItem,
});
}
break;
default:
console.log("监听到到设备连接状态改变 this.footerIsDisabled()");
this.footerIsDisabled(); // 判断底部运行按钮是否可点击
break;
}
break;
@ -714,9 +736,6 @@ class IotCarePlan extends Component<any, any> {
console.log("支架是否链接", isStandDevice);
this.setState({
isStandStatus: isStandDevice,
isCanClick: isStandDevice
? this.state.ActiveModeItem?.isCabinMode === 1
: this.state.ActiveModeItem?.isCabinMode !== 1,
});
// 连上面罩后, 获取仪器记录, 与缓存信息对比
@ -781,25 +800,34 @@ class IotCarePlan extends Component<any, any> {
"设备主动上报给小程序的指令 一般是工作状态改变",
jsonStatus
);
this.workStatus = jsonStatus.workStatus;
this.setState({
Electricity: jsonStatus.battery,
// fr200Electricity: jsonStatus.battery,
matrixElectricity: jsonStatus.matrixBattery,
workMode: jsonStatus?.workMode,
});
// 判断是否在step == 2(护理中)
if (
this.state.step == 2 &&
jsonStatus.workStatus !== MODE_WORKING_ENUM.END
) {
this.updateDeviceSyncData(
{
totalWorkingMinutes: jsonStatus.totalWorkingMinutes,
totalWorkingSeconds: jsonStatus.totalWorkingSeconds,
},
jsonStatus
);
if (jsonStatus?.workMode === this.state.ActiveModeItem.modeType) {
this.setState({
workMode: jsonStatus?.workMode, // 仅当设备上报模式与小程序一致时,才允许改变小程序变量缓存
});
// 判断是否在step == 2(护理中)
// 仅当设备模式与小程序是否一致,才允许更改设备运行时间
if (
this.state.facialMaskConnectStatus === 1 &&
this.state.step == 2 &&
jsonStatus.workStatus !== MODE_WORKING_ENUM.END
) {
this.updateDeviceSyncData(
{
totalWorkingMinutes: jsonStatus.totalWorkingMinutes,
totalWorkingSeconds: jsonStatus.totalWorkingSeconds,
},
jsonStatus
);
}
}
if (
@ -1122,9 +1150,19 @@ class IotCarePlan extends Component<any, any> {
facialMaskConnectStatus == 1
) {
let totalSeconds = minSecToS(ActiveModeItem.modeTimeStr);
let currentSeconds = minSecToS(currentTime);
// 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算
let currentSeconds = ActiveModeItem?.breakTimeStr
? minSecToS(ActiveModeItem.breakTimeStr)
: minSecToS(currentTime);
let checkTime = totalSeconds - currentSeconds;
this.elapsedTime = checkTime;
// 完成重连同步则删除重连时间字段
if (ActiveModeItem?.breakTimeStr) {
delete ActiveModeItem?.breakTimeStr;
this.setState({ ActiveModeItem });
}
// 判断剩余时间是否大于1
if (currentSeconds >= 1) {
// 小程序显示倒计时
this.setState({
@ -1155,6 +1193,8 @@ class IotCarePlan extends Component<any, any> {
currentServiceData
);
this.updateWL200NursingHistory(currentServiceData);
this.setState({
ModeStepIndex: index,
currentServiceData,
@ -1222,6 +1262,8 @@ class IotCarePlan extends Component<any, any> {
*
*/
onNursingTap() {
// 如果已禁止运行,则停止执行后续逻辑
if (this.state.isFooterBtnDisabled) return;
// 防止多次点击
if (this.state.hadClickStart) return;
this.setState({
@ -1407,7 +1449,8 @@ class IotCarePlan extends Component<any, any> {
let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间
let neededTotalSeconds = jsonStatus.neededTotalSeconds; // 从仪器上获取的使用时间
console.log(
"从仪器上获取的使用时间 neededTotalSeconds",
"从仪器上获取的使用时间 totalSeconds: %d neededTotalSeconds: %d",
totalSeconds,
neededTotalSeconds
);
let nursingTimeStr = currentDevice?.nursingTimeStr;
@ -1478,6 +1521,32 @@ class IotCarePlan extends Component<any, any> {
Taro.setStorageSync("WL200NursingHistory", params);
console.log("保存setWL200NursingHistory");
};
/** 更新WL200护理历史运行时间 */
updateWL200NursingHistory = (data: any = null) => {
this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
if (this.WL200NursingHistory) {
let params: any = this.WL200NursingHistory;
params.currentTime = this.state.currentTime;
// 设置正确封面
if (data) {
params.currentServiceData = data;
} else {
let currentServiceData = {
startSource: "",
stopSource: "",
};
let serviceLength = this.state.ActiveModeItem.serviceData.length;
if (serviceLength > 0) {
currentServiceData = this.state.ActiveModeItem.serviceData[0];
}
params.currentServiceData = currentServiceData;
}
Taro.setStorageSync("WL200NursingHistory", params);
console.log("更新updateWL200NursingHistory");
}
};
/** 删除WL200护理历史 */
rmWL200NursingHistory = (WL200NursingHistory, hard = false) => {
const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
@ -1772,6 +1841,23 @@ class IotCarePlan extends Component<any, any> {
};
/** 初次护理信息弹窗 END */
/**
* @name
* @description
* @returns true
*/
footerIsDisabled = () => {
let { isStandStatus } = this.state;
let isCanClick = isStandStatus
? this.tempModeCurrent?.isCabinMode === 1
: this.tempModeCurrent?.isCabinMode === 0;
let isFooterBtnDisabled = !(isStandStatus === isCanClick);
this.setState({
isFooterBtnDisabled: isFooterBtnDisabled,
});
return isFooterBtnDisabled; // 数据更新有延迟,返回用于判断
};
render() {
let {
name,
@ -1807,6 +1893,7 @@ class IotCarePlan extends Component<any, any> {
isFirstTipShow,
nurseInfo,
isShowReReadRecordSave,
isFooterBtnDisabled,
} = this.state;
return (
@ -2037,7 +2124,7 @@ class IotCarePlan extends Component<any, any> {
</View>
<Footer
isCanClick={isCanClick}
isDisabled={isFooterBtnDisabled}
isShowNurse={isShowNurse}
isStopNurse={isStopNurse}
onEmitStartNurse={this.onStartNurse}

Loading…
Cancel
Save