This commit is contained in:
2026-09-20 18:12:51 +08:00
parent 4af9afda61
commit 7078de6385
3 changed files with 106 additions and 45 deletions
@@ -1,11 +1,12 @@
<template>
<div ref="page" class="customer-archive-public-view">
<customer-archive />
<customer-archive ref="archive" />
</div>
</template>
<script>
import CustomerArchive from './customer-archive.vue';
import { postPublicProcessMessage } from '@/api/vehicle/customer-archive';
export default {
name: 'CustomerArchivePublicView',
@@ -14,7 +15,9 @@ export default {
},
created() {
this.handleIframeHeight = () => this.sendIframeHeight();
this.handleProcessMessage = event => this.onProcessMessage(event);
document.addEventListener('DOMContentLoaded', this.handleIframeHeight, false);
window.addEventListener('message', this.handleProcessMessage);
},
mounted() {
document.documentElement.classList.add('mk-iframe-page');
@@ -36,6 +39,7 @@ export default {
beforeUnmount() {
document.removeEventListener('DOMContentLoaded', this.handleIframeHeight, false);
window.removeEventListener('load', this.handleIframeHeight);
window.removeEventListener('message', this.handleProcessMessage);
(this.mkHeightTimers || []).forEach(timer => clearTimeout(timer));
if (this.mkHeightObserver) {
this.mkHeightObserver.disconnect();
@@ -55,6 +59,82 @@ export default {
window.parent.postMessage({ height: height }, '*');
});
},
onProcessMessage(event) {
const data = event && event.data;
if (!data || typeof data !== 'object') return;
if (data.height && !data.status && !data.type) return;
if (data.type === 'formValues' || data.type === 'afterSubmit') return;
console.log('客商公开页收到流程消息:', data);
const formValues = data.formValues;
if (data.status === 'submit') {
this.submitData(formValues);
} else if (data.status === 'save') {
this.saveData(formValues);
}
if (data.type === 'getFormValues') {
window.parent.postMessage({ type: 'formValues', formData: this.buildFormData() }, '*');
}
},
submitData(lbpmFormValues) {
const formData = this.buildFormData();
this.postFormData('submit', lbpmFormValues, formData);
if (!lbpmFormValues) return;
const parameters = Object.assign({}, lbpmFormValues, {
loginName: this.getLoginName(lbpmFormValues),
formInstanceId: this.getFormId(),
subject: formData.subject,
});
window.parent.postMessage(
{
type: 'afterSubmit',
success: true,
parameters,
},
'*'
);
},
saveData(lbpmFormValues) {
this.postFormData('save', lbpmFormValues, this.buildFormData());
},
postFormData(status, formValues, formData) {
const payload = {
status,
formValues: formValues || {},
formData,
};
console.log('客商公开页提交流程数据:', payload);
postPublicProcessMessage(payload).catch(error => {
console.error('客商公开页提交流程数据失败:', error);
});
},
buildFormData() {
const archive = this.getArchiveForm();
return {
...archive,
subject: archive.fullName || archive.shortName || '',
formInstanceId: this.getFormId(),
};
},
getArchiveForm() {
const archive = this.$refs.archive && this.$refs.archive.archiveForm;
if (!archive) return {};
try {
return JSON.parse(JSON.stringify(archive));
} catch (error) {
return { ...archive };
}
},
getFormId() {
return this.$route.query.id || this.getArchiveForm().id || '';
},
getLoginName(formValues = {}) {
return (
formValues.loginName ||
this.$route.query.loginName ||
this.$route.query.submitIdentity ||
''
);
},
},
};
</script>
+14 -44
View File
@@ -2001,7 +2001,6 @@ export default {
return;
}
this.openArchive({ id }, true);
this.bindMkParentHeight();
return;
}
this.initDeptTree();
@@ -2012,10 +2011,6 @@ export default {
const readonly = this.$route.query.view === '1' || this.$route.query.view === 'true';
this.openArchive(this.$route.query.id ? { id: this.$route.query.id } : null, readonly);
}
this.bindMkParentHeight();
},
mounted() {
this.notifyMkParentHeight();
},
computed: {
...mapGetters(['permission', 'userInfo']),
@@ -2036,12 +2031,6 @@ export default {
isPublicViewPage() {
return this.$route.path === '/vehicle/customer-archive/public-view';
},
isMkEmbed() {
const isMk = this.$route.query.isMk;
return (
this.isPublicViewPage || isMk === '1' || isMk === 1 || isMk === 'true'
);
},
archiveContainer() {
return 'div';
},
@@ -2220,28 +2209,6 @@ export default {
hasPermission(code) {
return this.isAdmin || this.validData(this.permission[code], false);
},
bindMkParentHeight() {
if (!this.isMkEmbed) return;
document.addEventListener(
'DOMContentLoaded',
function () {
var tbody = document.body;
var height = tbody.clientHeight;
// 如需动态改变表单高度,可以直接发送此postMessage
window.parent.postMessage({ height: height }, '*');
},
false
);
},
notifyMkParentHeight() {
if (!this.isMkEmbed) return;
this.$nextTick(() => {
var tbody = document.body;
var height = tbody.clientHeight;
// 如需动态改变表单高度,可以直接发送此postMessage
window.parent.postMessage({ height: height }, '*');
});
},
mergeSelectOptions(target, values) {
const list = Array.isArray(values) ? values : values ? [values] : [];
list.forEach(value => {
@@ -3983,6 +3950,8 @@ export default {
},
closeArchive() {
if (this.isPublicViewPage) return;
this.archiveBox = false;
this.$router.$avueRouter?.closeTag?.();
this.$router.push('/vehicle/customer-archive');
},
openArchive(row, readonly = false) {
@@ -4009,7 +3978,6 @@ export default {
this.selectedQualificationFiles = [];
if (this.isPublicViewPage) this.ensurePublicViewOptions(this.archiveForm);
this.archiveBox = true;
this.notifyMkParentHeight();
this.loadChangeRecords();
})
.catch(() => {
@@ -4025,7 +3993,6 @@ export default {
this.ocrQualificationUploadFiles = [];
this.selectedQualificationFiles = [];
this.archiveBox = true;
this.notifyMkParentHeight();
},
resetArchive() {
this.readonly = false;
@@ -4185,16 +4152,20 @@ export default {
archive.fullName ||
this.archiveForm.fullName ||
'';
this.submitMkApprovalFlow(id, fullName)
.then(() => submitApproval(id))
.then(() => {
this.closeArchive();
this.onLoad(this.page);
this.$message({ type: 'success', message: '提交成功!' });
});
this.submitCustomerApproval(id, fullName).then(() => {
this.closeArchive();
this.onLoad(this.page);
this.$message({ type: 'success', message: '提交成功!' });
});
});
});
},
/**
* 列表 / 新增 / 编辑提交共用:提交 MK 审核流并更新客商审批状态
*/
submitCustomerApproval(id, fullName = '') {
return this.submitMkApprovalFlow(id, fullName).then(() => submitApproval(id));
},
/**
* 提交 MK 审核流:templateCode 取业务字典 mk_template 中「提交审核流」的键值
* 提交人手机号由后端从用户表读取真实值(前端接口会脱敏)
@@ -4811,8 +4782,7 @@ export default {
cancelButtonText: '取消',
type: 'warning',
})
.then(() => this.submitMkApprovalFlow(row.id, archive.fullName || row.fullName))
.then(() => submitApproval(row.id))
.then(() => this.submitCustomerApproval(row.id, archive.fullName || row.fullName))
.then(() => {
this.onLoad(this.page);
this.$message({ type: 'success', message: '提交成功!' });