|
|
@@ -754,6 +754,7 @@ function postQualityInspection(url, data, success, failure) {
|
|
|
function bindQualityInspectionFlow() {
|
|
|
const $flow = $('.quality-inspection-flow');
|
|
|
const $radios = $('[name="quality-need-rectification"]');
|
|
|
+ const isWap = window.location.pathname.indexOf('/wap/') === 0;
|
|
|
let needRectification = qualityInspectionNeedDraft();
|
|
|
showQualityInspectionNeed(needRectification);
|
|
|
let pending = null;
|
|
|
@@ -765,6 +766,7 @@ function bindQualityInspectionFlow() {
|
|
|
postQualityInspection(preUrl + '/save', data, function () {
|
|
|
busy = false;
|
|
|
$button.prop('disabled', false);
|
|
|
+ if (!isWap && data.type === 'start-inspection') qualityInspectionNeedDraft(null);
|
|
|
if (reload) {
|
|
|
if (!inspection.readOnly && ['flow-add-audit', 'flow-del-audit'].includes(data.type)) qualityInspectionNeedDraft(needRectification);
|
|
|
window.location.reload();
|
|
|
@@ -828,6 +830,7 @@ function bindQualityInspectionFlow() {
|
|
|
return;
|
|
|
}
|
|
|
needRectification = value;
|
|
|
+ if (!isWap) qualityInspectionNeedDraft(needRectification);
|
|
|
showQualityInspectionNeed(needRectification);
|
|
|
});
|
|
|
$('.flow-save-rectification').on('click', function () {
|
|
|
@@ -892,21 +895,29 @@ function bindQualityInspectionFlow() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-// 仅在添加、移除审批人引起的刷新之间暂存选择,读取后即清除。
|
|
|
+// 电脑版按用户、巡检单和轮次保留草稿选择;手机端沿用一次性暂存。
|
|
|
function qualityInspectionNeedDraft(value) {
|
|
|
const current = inspection.need_rectification === 0 ? 0 : 1;
|
|
|
const key = 'quality-inspection-need:' + cur_uid + ':' + inspection.id + ':' + inspection.times + ':' + inspection.stage_round;
|
|
|
+ const isWap = window.location.pathname.indexOf('/wap/') === 0;
|
|
|
try {
|
|
|
+ if (!isWap && (value === null || inspection.readOnly)) {
|
|
|
+ removeLocalCache(key);
|
|
|
+ return current;
|
|
|
+ }
|
|
|
if (value !== undefined) {
|
|
|
- sessionStorage.setItem(key, JSON.stringify({ value, savedValue: current }));
|
|
|
+ const saved = JSON.stringify({ value, savedValue: current });
|
|
|
+ if (isWap) sessionStorage.setItem(key, saved);
|
|
|
+ else setLocalCache(key, saved);
|
|
|
} else {
|
|
|
- const saved = sessionStorage.getItem(key);
|
|
|
- sessionStorage.removeItem(key);
|
|
|
+ const saved = isWap ? sessionStorage.getItem(key) : getLocalCache(key);
|
|
|
+ if (isWap) sessionStorage.removeItem(key);
|
|
|
const draft = saved ? JSON.parse(saved) : null;
|
|
|
if (!inspection.readOnly && draft && draft.savedValue === current && [0, 1].includes(draft.value)) return draft.value;
|
|
|
+ if (!isWap && saved) removeLocalCache(key);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.warn('无法暂存是否整改选项', error);
|
|
|
+ console.warn('无法保存或读取是否整改选项', error);
|
|
|
}
|
|
|
return current;
|
|
|
}
|