|
@@ -754,6 +754,7 @@ function postQualityInspection(url, data, success, failure) {
|
|
|
function bindQualityInspectionFlow() {
|
|
function bindQualityInspectionFlow() {
|
|
|
const $flow = $('.quality-inspection-flow');
|
|
const $flow = $('.quality-inspection-flow');
|
|
|
const $radios = $('[name="quality-need-rectification"]');
|
|
const $radios = $('[name="quality-need-rectification"]');
|
|
|
|
|
+ const isWap = window.location.pathname.indexOf('/wap/') === 0;
|
|
|
let needRectification = qualityInspectionNeedDraft();
|
|
let needRectification = qualityInspectionNeedDraft();
|
|
|
showQualityInspectionNeed(needRectification);
|
|
showQualityInspectionNeed(needRectification);
|
|
|
let pending = null;
|
|
let pending = null;
|
|
@@ -765,6 +766,7 @@ function bindQualityInspectionFlow() {
|
|
|
postQualityInspection(preUrl + '/save', data, function () {
|
|
postQualityInspection(preUrl + '/save', data, function () {
|
|
|
busy = false;
|
|
busy = false;
|
|
|
$button.prop('disabled', false);
|
|
$button.prop('disabled', false);
|
|
|
|
|
+ if (!isWap && data.type === 'start-inspection') qualityInspectionNeedDraft(null);
|
|
|
if (reload) {
|
|
if (reload) {
|
|
|
if (!inspection.readOnly && ['flow-add-audit', 'flow-del-audit'].includes(data.type)) qualityInspectionNeedDraft(needRectification);
|
|
if (!inspection.readOnly && ['flow-add-audit', 'flow-del-audit'].includes(data.type)) qualityInspectionNeedDraft(needRectification);
|
|
|
window.location.reload();
|
|
window.location.reload();
|
|
@@ -828,6 +830,7 @@ function bindQualityInspectionFlow() {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
needRectification = value;
|
|
needRectification = value;
|
|
|
|
|
+ if (!isWap) qualityInspectionNeedDraft(needRectification);
|
|
|
showQualityInspectionNeed(needRectification);
|
|
showQualityInspectionNeed(needRectification);
|
|
|
});
|
|
});
|
|
|
$('.flow-save-rectification').on('click', function () {
|
|
$('.flow-save-rectification').on('click', function () {
|
|
@@ -858,40 +861,63 @@ function bindQualityInspectionFlow() {
|
|
|
} else if (type === 'flow-check') {
|
|
} else if (type === 'flow-check') {
|
|
|
message = pending.checkType === 3 ? '确认本次审批通过?' : pending.checkType === 4 ? '确认关闭本次巡检?' : inspection.flow_stage === 3 ? '确认退回重新整改?所有整改人将同时开始新一轮整改。' : pending.checkType === 5 ? '确认退回上报人重新上报?' : '确认退回上一个上报审批节点?';
|
|
message = pending.checkType === 3 ? '确认本次审批通过?' : pending.checkType === 4 ? '确认关闭本次巡检?' : inspection.flow_stage === 3 ? '确认退回重新整改?所有整改人将同时开始新一轮整改。' : pending.checkType === 5 ? '确认退回上报人重新上报?' : '确认退回上一个上报审批节点?';
|
|
|
}
|
|
}
|
|
|
|
|
+ const isReturn = type === 'flow-return';
|
|
|
$('#quality-flow-title').text($(this).text());
|
|
$('#quality-flow-title').text($(this).text());
|
|
|
- $('#quality-flow-message').text(message);
|
|
|
|
|
|
|
+ $('#quality-flow-message').text(message).toggle(!isReturn);
|
|
|
|
|
+ $('#quality-flow-return-group').toggleClass('d-none', !isReturn);
|
|
|
|
|
+ $('[name="quality-flow-return-type"]').prop('checked', false);
|
|
|
$('#quality-flow-opinion').val('').css('height', '');
|
|
$('#quality-flow-opinion').val('').css('height', '');
|
|
|
- $('#quality-flow-opinion-group').toggle(type === 'flow-check');
|
|
|
|
|
|
|
+ $('#quality-flow-opinion-group').toggle(type === 'flow-check' || isReturn).find('label').text(isReturn ? '退回意见' : '处理意见');
|
|
|
|
|
+ $('#quality-flow-cancel').text(isReturn ? '关闭' : '取消');
|
|
|
|
|
+ $('#quality-flow-submit').text(isReturn ? '确认退回' : '确认').toggleClass('btn-warning', isReturn).toggleClass('btn-primary', !isReturn);
|
|
|
$('#quality-flow-confirm').modal('show');
|
|
$('#quality-flow-confirm').modal('show');
|
|
|
});
|
|
});
|
|
|
$('#quality-flow-submit').on('click', function () {
|
|
$('#quality-flow-submit').on('click', function () {
|
|
|
if (!pending || busy) return;
|
|
if (!pending || busy) return;
|
|
|
- if (pending.type === 'flow-check') {
|
|
|
|
|
- pending.opinion = $('#quality-flow-opinion').val().trim();
|
|
|
|
|
- if (pending.checkType !== 3 && !pending.opinion) {
|
|
|
|
|
- toastr.error('请填写退回或关闭原因');
|
|
|
|
|
|
|
+ const data = Object.assign({}, pending);
|
|
|
|
|
+ if (data.type === 'flow-return') {
|
|
|
|
|
+ const checkType = Number($('[name="quality-flow-return-type"]:checked').val());
|
|
|
|
|
+ if (![5, 6].includes(checkType) || (checkType === 6 && !inspection.flowCanReturnPrevious)) {
|
|
|
|
|
+ toastr.error('请选择退回位置');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ data.type = 'flow-check';
|
|
|
|
|
+ data.checkType = checkType;
|
|
|
}
|
|
}
|
|
|
- request(pending, $(this), true);
|
|
|
|
|
|
|
+ if (data.type === 'flow-check') {
|
|
|
|
|
+ data.opinion = $('#quality-flow-opinion').val().trim();
|
|
|
|
|
+ if (data.checkType !== 3 && !data.opinion) {
|
|
|
|
|
+ toastr.error(pending.type === 'flow-return' ? '请填写退回意见' : '请填写退回或关闭原因');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ request(data, $(this), true);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 仅在添加、移除审批人引起的刷新之间暂存选择,读取后即清除。
|
|
|
|
|
|
|
+// 电脑版按用户、巡检单和轮次保留草稿选择;手机端沿用一次性暂存。
|
|
|
function qualityInspectionNeedDraft(value) {
|
|
function qualityInspectionNeedDraft(value) {
|
|
|
const current = inspection.need_rectification === 0 ? 0 : 1;
|
|
const current = inspection.need_rectification === 0 ? 0 : 1;
|
|
|
const key = 'quality-inspection-need:' + cur_uid + ':' + inspection.id + ':' + inspection.times + ':' + inspection.stage_round;
|
|
const key = 'quality-inspection-need:' + cur_uid + ':' + inspection.id + ':' + inspection.times + ':' + inspection.stage_round;
|
|
|
|
|
+ const isWap = window.location.pathname.indexOf('/wap/') === 0;
|
|
|
try {
|
|
try {
|
|
|
|
|
+ if (!isWap && (value === null || inspection.readOnly)) {
|
|
|
|
|
+ removeLocalCache(key);
|
|
|
|
|
+ return current;
|
|
|
|
|
+ }
|
|
|
if (value !== undefined) {
|
|
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 {
|
|
} 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;
|
|
const draft = saved ? JSON.parse(saved) : null;
|
|
|
if (!inspection.readOnly && draft && draft.savedValue === current && [0, 1].includes(draft.value)) return draft.value;
|
|
if (!inspection.readOnly && draft && draft.savedValue === current && [0, 1].includes(draft.value)) return draft.value;
|
|
|
|
|
+ if (!isWap && saved) removeLocalCache(key);
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.warn('无法暂存是否整改选项', error);
|
|
|
|
|
|
|
+ console.warn('无法保存或读取是否整改选项', error);
|
|
|
}
|
|
}
|
|
|
return current;
|
|
return current;
|
|
|
}
|
|
}
|
|
@@ -900,4 +926,5 @@ function showQualityInspectionNeed(value) {
|
|
|
$('[name="quality-need-rectification"]').filter('[value="' + value + '"]').prop('checked', true);
|
|
$('[name="quality-need-rectification"]').filter('[value="' + value + '"]').prop('checked', true);
|
|
|
$('.quality-inspection-flow [data-flow-stage="2"], .quality-inspection-flow [data-flow-stage="3"]').toggleClass('d-none', value === 0);
|
|
$('.quality-inspection-flow [data-flow-stage="2"], .quality-inspection-flow [data-flow-stage="3"]').toggleClass('d-none', value === 0);
|
|
|
$('.quality-inspection-flow .flow-no-rectification').toggleClass('d-none', value !== 0);
|
|
$('.quality-inspection-flow .flow-no-rectification').toggleClass('d-none', value !== 0);
|
|
|
|
|
+ $('.quality-inspection-need-pending').removeClass('quality-inspection-need-pending');
|
|
|
}
|
|
}
|