模式列表复制问题

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

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

Loading…
Cancel
Save