模式列表复制问题

master
blak-kong 2 years ago
parent 44c672c97f
commit b61a5c4507

@ -183,7 +183,9 @@ class IotCarePlanFR200 extends Component<any, any> {
modeType: "",
openSourceData: [],
}, // 当前选中模式
SwitchActiveModeItem: {}, // 切换选中模式
SwitchActiveModeItem: {
modeType: "",
}, // 切换选中模式
ModeID: "mode_", // 模式KEY
activeModeID: "", // 当前选中模式ID:用于高亮
@ -429,10 +431,10 @@ class IotCarePlanFR200 extends Component<any, any> {
title: obj.name,
});
await this.GetModeList(obj.id);
await this.GetModeList(obj?.id);
// 如果不存在设备模式值,则判断为首次进入,弹窗提示
let isFirstTipShow = getStorageSync("first_instrument_" + obj.id);
let isFirstTipShow = getStorageSync("first_instrument_" + obj?.id);
if (!isFirstTipShow) {
this.firstNurseInfo();
}
@ -508,19 +510,25 @@ class IotCarePlanFR200 extends Component<any, any> {
});
if (this.state.activeModeID != "") {
let res1 = res.data.data.find((e) => e.id == this.state.activeModeID);
let res1 = res.data.data.find(
(e) => e?.id == this.state.activeModeID
);
if (res1) {
setTimeout(() => {
this.modeCurrentFun(res1);
}, 100);
}
} else {
setTimeout(() => {
this.modeCurrentFun(res.data.data[0]);
}, 100);
}
let res1 = res.data.data.find((e) => e.id == this.state.activeModeID);
let res1 = res.data.data.find((e) => e?.id == this.state.activeModeID);
if (res1) {
setTimeout(() => {
this.modeCurrentFun(res1);
}, 100);
}
} else {
this.setState({ ModeList: [] });
}
@ -581,20 +589,20 @@ class IotCarePlanFR200 extends Component<any, any> {
// 根据模式,动态设置底部按钮样式
let currentWorkModeType = 1;
if (data.modeType === "moistureTest") {
if (data?.modeType === "moistureTest") {
currentWorkModeType = 3;
} else if (
data.modeType === "maskPenetration" ||
data.modeType === "essence" ||
data.modeType === "led"
data?.modeType === "maskPenetration" ||
data?.modeType === "essence" ||
data?.modeType === "led"
) {
currentWorkModeType = 2;
}
this.setState({
ActiveModeItem: data,
activeModeID: data.id,
ModeID: "mode_" + data.id,
activeModeID: data?.id,
ModeID: "mode_" + data?.id,
waterStepIndex: 0, // 水分测试步骤
EssenceStepIndex: 0, // 精华促渗步骤
MaskModeStepIndex: 0, // 面膜促渗步骤
@ -613,7 +621,7 @@ class IotCarePlanFR200 extends Component<any, any> {
// FR200 水分测试和促渗不可自动运行,需手动点击开始测试,手动启动检测
// 其他模式可以自动运行
let notStartArr = ["moistureTest", "maskPenetration", "essence"];
if (!notStartArr.includes(data.modeType)) {
if (!notStartArr.includes(data?.modeType)) {
setTimeout(() => {
this.onNursingTap("switch");
}, 800);
@ -673,8 +681,8 @@ class IotCarePlanFR200 extends Component<any, any> {
switchModeCurrentFun = async (data) => {
this.setState({
SwitchActiveModeItem: data,
activeModeID: data.id,
ModeID: "mode_" + data.id,
activeModeID: data?.id,
ModeID: "mode_" + data?.id,
});
};
// 打开模式切换弹窗
@ -723,7 +731,7 @@ class IotCarePlanFR200 extends Component<any, any> {
setTimeout(() => {
this.onNursingTap();
// // 倒计时弹窗: 倒计时完成后,自动开始,并判断弹窗
// let downNum = CountDownTime[this.state.ActiveModeItem.modeType] || 3;
// let downNum = CountDownTime[this.state.ActiveModeItem?.modeType] || 3;
// this.showCountdownFun(downNum, () => {});
}, 500);
@ -741,9 +749,9 @@ class IotCarePlanFR200 extends Component<any, any> {
let params: any = {};
params = {
instrumentId: currentDevice.id,
instrumentId: currentDevice?.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeId: ActiveModeItem?.id,
modeName: ActiveModeItem.modeName,
nursingTime: s_to_hms(this.elapsedTime),
nursingData: JSON.stringify({
@ -770,8 +778,8 @@ class IotCarePlanFR200 extends Component<any, any> {
this.moistureTest(
params.nursingData,
formattedDate,
ActiveModeItem.id,
currentDevice.id
ActiveModeItem?.id,
currentDevice?.id
);
}, 2000);
};
@ -885,7 +893,7 @@ class IotCarePlanFR200 extends Component<any, any> {
let { isStopNurse, ActiveModeItem } = this.state;
console.log("切换光照,", ActiveModeItem);
if (ActiveModeItem.modeType === "led") {
if (ActiveModeItem?.modeType === "led") {
this.onSwitchChangeLED();
return;
}
@ -940,7 +948,7 @@ class IotCarePlanFR200 extends Component<any, any> {
*/
openStepTips = () => {
let isFirstEntryModeNot = getStorageSync(
"isFirstEntryMode_" + this.state.currentDevice.id
"isFirstEntryMode_" + this.state.currentDevice?.id
);
// 1.如果没有持久化不再提示,每次进入都会弹窗提示
if (!isFirstEntryModeNot) {
@ -952,7 +960,7 @@ class IotCarePlanFR200 extends Component<any, any> {
};
closeStepTips = (data) => {
if (data.isLocal) {
setStorageSync("isFirstEntryMode_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗
setStorageSync("isFirstEntryMode_" + this.state.currentDevice?.id, true); // 关闭首次进入弹窗
}
this.setState({ isShowStepTips: false });
};
@ -1068,7 +1076,7 @@ class IotCarePlanFR200 extends Component<any, any> {
let nowModeItem;
if (nWorkMode) {
nowModeItem = ModeList.find((item) => {
return item.modeType === nWorkMode;
return item?.modeType === nWorkMode;
});
}
opts.workStatus = nWorkStatus;
@ -1208,9 +1216,9 @@ class IotCarePlanFR200 extends Component<any, any> {
});
// 根据不同的模式,切换步骤到下一步
if (ActiveModeItem.modeType === "essence") {
if (ActiveModeItem?.modeType === "essence") {
this.essencePenetrationNext();
} else if (ActiveModeItem.modeType === "maskPenetration") {
} else if (ActiveModeItem?.modeType === "maskPenetration") {
this.maskPenetrationNext();
}
} else {
@ -1371,7 +1379,7 @@ class IotCarePlanFR200 extends Component<any, any> {
const { ActiveModeItem, currentGear } = this.state;
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workMode: ActiveModeItem?.modeType, // 使用模式
workStatus: "working",
gear: currentGear,
};
@ -1420,7 +1428,7 @@ class IotCarePlanFR200 extends Component<any, any> {
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workMode: ActiveModeItem?.modeType, // 使用模式
workStatus: "working",
gear: gear,
};
@ -1445,7 +1453,7 @@ class IotCarePlanFR200 extends Component<any, any> {
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workMode: ActiveModeItem?.modeType, // 使用模式
workStatus: "working",
gear: currentGear,
};
@ -1492,13 +1500,13 @@ class IotCarePlanFR200 extends Component<any, any> {
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workMode: ActiveModeItem?.modeType, // 使用模式
workStatus: newWorkStatus,
};
// 水分测试需要特殊处理
// 水分测试准备 水分测试工作 水分测试启动
if (ActiveModeItem.modeType === "moistureTest") {
if (ActiveModeItem?.modeType === "moistureTest") {
let that = this;
sendParams.testStatus = "standby"; // 切换为准备
@ -1516,8 +1524,8 @@ class IotCarePlanFR200 extends Component<any, any> {
// 面膜促渗和精华促渗
if (
ActiveModeItem.modeType === "maskPenetration" ||
ActiveModeItem.modeType === "essence"
ActiveModeItem?.modeType === "maskPenetration" ||
ActiveModeItem?.modeType === "essence"
) {
sendParams.gear = this.state.currentGear; // 点击开始再开始
}
@ -1695,7 +1703,7 @@ class IotCarePlanFR200 extends Component<any, any> {
// 仪器缓存模式,判断是否存在于现有模式中
let recordModeItem = ModeList.find((item) => {
return item.id == FR200NursingHistory.modeId;
return item?.id == FR200NursingHistory.modeId;
});
if (!FR200NursingHistory || !recordModeItem) {
console.log("仪器有数据, 但是缓存没有数据, 忽略");
@ -1716,7 +1724,7 @@ class IotCarePlanFR200 extends Component<any, any> {
!workStatus
) {
// 判断id是否一致, 一致的话则生成护理报表
if (jsonStatus.id == FR200NursingHistory.id) {
if (jsonStatus?.id == FR200NursingHistory?.id) {
console.log("id一致, 设备没有运行/已完成/待机");
let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间
@ -1737,9 +1745,9 @@ class IotCarePlanFR200 extends Component<any, any> {
: s_to_hms(this.elapsedTime);
let params = {
instrumentId: currentDevice.id,
instrumentId: currentDevice?.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeId: ActiveModeItem?.id,
modeName: ActiveModeItem.modeName,
nursingTime: timeValue,
};
@ -1750,9 +1758,9 @@ class IotCarePlanFR200 extends Component<any, any> {
} else {
// ID不一致同步异常统一提交一分钟
let params = {
instrumentId: currentDevice.id,
instrumentId: currentDevice?.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeId: ActiveModeItem?.id,
modeName: ActiveModeItem.modeName,
nursingTime: "00:01:00",
};
@ -1765,7 +1773,7 @@ class IotCarePlanFR200 extends Component<any, any> {
console.log("id一致, 设备运行中或暂停");
// 5.判断设备状态-运行中
// 同步时间
if (jsonStatus.id == FR200NursingHistory.id) {
if (jsonStatus?.id == FR200NursingHistory?.id) {
if (FR200NursingHistory.currentTime) {
this.isRuning = true;
this.resetTimer();
@ -1793,8 +1801,8 @@ class IotCarePlanFR200 extends Component<any, any> {
videoTime: this.FR200NursingHistory.videoTime,
tempModeCurrent: ActiveModeItem,
ActiveModeItem: ActiveModeItem,
activeModeID: ActiveModeItem.id,
ModeID: "mode_" + ActiveModeItem.id,
activeModeID: ActiveModeItem?.id,
ModeID: "mode_" + ActiveModeItem?.id,
currentTime: this.FR200NursingHistory.currentTime,
});
}
@ -1805,9 +1813,9 @@ class IotCarePlanFR200 extends Component<any, any> {
const params = {
createDate: dayjs().format("YYYY-MM-DD"),
workMode: jsonStatus.workMode,
instrumentId: currentDevice.id,
instrumentId: currentDevice?.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeId: ActiveModeItem?.id,
modeName: ActiveModeItem.modeName,
id: dayjs().format("YYYY-MM-DD HH:mm:ss"),
neededTotalSeconds: jsonStatus.neededTotalSeconds,
@ -1837,7 +1845,7 @@ class IotCarePlanFR200 extends Component<any, any> {
params.dataArray.push(jsonStatus);
params.jsonStatus = jsonStatus;
params.workMode = jsonStatus?.workMode;
params.modeId = this.state.ActiveModeItem.id;
params.modeId = this.state.ActiveModeItem?.id;
params.modeName = this.state.ActiveModeItem.modeName;
console.log(jsonStatus, 555555555555);
@ -1845,7 +1853,7 @@ class IotCarePlanFR200 extends Component<any, any> {
} else {
params.jsonStatus = jsonStatus;
params.workMode = jsonStatus?.workMode;
params.modeId = data.id;
params.modeId = data?.id;
params.modeName = data.modeName;
}
@ -1995,9 +2003,9 @@ class IotCarePlanFR200 extends Component<any, any> {
params = data;
} else {
params = {
instrumentId: currentDevice.id,
instrumentId: currentDevice?.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeId: ActiveModeItem?.id,
modeName: ActiveModeItem.modeName,
nursingTime: s_to_hms(this.elapsedTime),
};
@ -2012,7 +2020,7 @@ class IotCarePlanFR200 extends Component<any, any> {
console.log("PostNursingLogClock", res2);
if (res2.data.code === 200) {
let params = {
instrumentId: currentDevice.id,
instrumentId: currentDevice?.id,
};
// 上传护理完成的仪器ID
let res = await InstrumentInfo.apiClock.addClockInstrument(params);
@ -2030,9 +2038,9 @@ class IotCarePlanFR200 extends Component<any, any> {
this.goFaceReport(
res1,
ActiveModeItem.id,
ActiveModeItem?.id,
res2.data.data,
currentDevice.id
currentDevice?.id
); // 跳转
}, 2000);
}
@ -2223,13 +2231,13 @@ class IotCarePlanFR200 extends Component<any, any> {
firstNurseInfo = async () => {
let { currentDevice } = this.state;
let res = await InstrumentInfo.firstNurseInfo({
instrumentId: currentDevice.id,
instrumentId: currentDevice?.id,
});
console.log(res, "接口");
if (res.data.code === 200) {
let isFirstTipShow = getStorageSync(
"first_instrument_" + currentDevice.id
"first_instrument_" + currentDevice?.id
);
console.log(isFirstTipShow, "查看返回值");
@ -2239,7 +2247,7 @@ class IotCarePlanFR200 extends Component<any, any> {
this.setState({ nurseInfo: res.data.data, isFirstTipShow: true });
}
setStorageSync("first_instrument_" + currentDevice.id, true);
setStorageSync("first_instrument_" + currentDevice?.id, true);
} else {
this.setState({ nurseInfo: res.data.data });
}
@ -2249,7 +2257,7 @@ class IotCarePlanFR200 extends Component<any, any> {
this.setState({ isFirstTipShow: true });
};
onTipShowClose = async () => {
setStorageSync("first_instrument_" + this.state.currentDevice.id, true);
setStorageSync("first_instrument_" + this.state.currentDevice?.id, true);
this.setState({ isFirstTipShow: false });
};
/** 初次护理信息弹窗 END */
@ -2576,8 +2584,8 @@ class IotCarePlanFR200 extends Component<any, any> {
></EchartsFullScean>
</View>
{(ActiveModeItem.modeType === "maskPenetration" ||
ActiveModeItem.modeType === "essence") && (
{(ActiveModeItem?.modeType === "maskPenetration" ||
ActiveModeItem?.modeType === "essence") && (
<Gears
onEmitMinus={this.handleMinus}
onEmitAdd={this.handleAdd}
@ -2585,7 +2593,7 @@ class IotCarePlanFR200 extends Component<any, any> {
></Gears>
)}
{ActiveModeItem.modeType === "moistureTest" && (
{ActiveModeItem?.modeType === "moistureTest" && (
<WaterTest
isRuningTest={isRuningTest}
stepList={waterStepList}

Loading…
Cancel
Save