Commit 0db615a6 authored by 高如斌's avatar 高如斌

访客场景字段临时特殊处理

parent 9073d710
......@@ -654,8 +654,33 @@ const processSSELine = async (
case "form":
if (data && data.coms) {
// 正常情况:
// formJson.value = data;
formJson.value = data;
// 演示场景特殊处理:
// 提取被过滤掉的字段
const hiddenFields = data.coms
.filter((com: any) => {
const title = com.props?.title;
return title === "接访员工手机号" || title === "接访员工姓名";
})
.map((com: any) => ({
title: com.props?.title || "",
name: com.props?.name || "",
}));
// 保存隐藏字段到 store
formStore.setHiddenFields(hiddenFields);
// 过滤掉不需要的字段
const filteredData = {
...data,
coms: data.coms.filter((com: any) => {
const title = com.props?.title;
return title !== "接访员工手机号" && title !== "接访员工姓名";
}),
};
formJson.value = filteredData;
}
break;
}
......
......@@ -26,6 +26,14 @@ const templateRef = ref();
const submit = () => {
templateRef.value?.ctx.validate(1, (isValid: boolean, formData: any) => {
if (isValid) {
// 临时处理:追加隐藏字段到表单数据
const hiddenFields = formStore.hiddenFields;
hiddenFields.forEach((field) => {
if (field.name) {
formData[field.name] = "none";
}
});
console.log("表单验证通过,提交数据:", formData);
// 调用 store 的 submitForm 方法,触发回调
formStore.submitForm(formData);
......
......@@ -69,6 +69,9 @@ export const useFormStore = defineStore("form", {
// 表单提交回调函数
onSubmitCallback: null as ((data: any) => void) | null,
// 过滤掉的隐藏字段
hiddenFields: [] as Array<{ title: string; name: string }>,
}),
actions: {
......@@ -87,6 +90,21 @@ export const useFormStore = defineStore("form", {
this.formJson = getInitFormJson();
},
/**
* 设置隐藏字段
* @param fields 隐藏字段数组
*/
setHiddenFields(fields: Array<{ title: string; name: string }>) {
this.hiddenFields = fields;
},
/**
* 清空隐藏字段
*/
clearHiddenFields() {
this.hiddenFields = [];
},
/**
* 设置表单提交回调函数
* @param callback 回调函数
......@@ -149,6 +167,7 @@ export const useFormStore = defineStore("form", {
closeForm() {
this.showForm = false;
this.clearFormJson();
this.clearHiddenFields();
},
},
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment