hookehuyr

feat: 添加对iframe项目标识的支持并处理表单提交消息

<!--
* @Date: 2022-07-18 10:22:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-07-03 17:44:43
* @LastEditTime: 2025-09-25 14:31:46
* @FilePath: /data-table/src/views/index.vue
* @Description: 首页
-->
......@@ -281,6 +281,8 @@ const data_id = $route.query.data_id ? $route.query.data_id : null;
const x_field_1 = $route.query.x_field_1 ? $route.query.x_field_1 : null;
// 周期ID标识
const x_cycle = $route.query.x_cycle ? $route.query.x_cycle : null;
// iframe项目标识 - 现在是美乐爱觉使用
const x_project = $route.query.x_project ? $route.query.x_project : null;
// iframe传值openid
const iframe_openid = getUrlParams(location.href) ? getUrlParams(location.href).openid : '';
// 强制后台检查标识
......@@ -1076,6 +1078,30 @@ const successHandle = () => { // 表单成功提交后续操作
getChildVal();
return false;
}
// iframe 项目标识 - 现在是美乐爱觉使用
if (x_project === 'behalo') {
// 向父页面发送消息
const messageData = {
id: successInfo.value?.id,
type: 'formSubmit',
timestamp: Date.now(),
};
try {
// 发送消息到父页面
if (window.parent && window.parent !== window) {
window.parent.postMessage(messageData, '*');
console.log('已向父页面发送消息:', messageData);
}
} catch (error) {
console.error('发送消息到父页面失败:', error);
}
// 提交成功,直接返回
return false;
}
// 如果类型为跳转网页
if (successInfo.value.commit_action === 'url') {
window.location.href = successInfo.value.commit_url;
......