hookehuyr

测试首页cookie问题操作

<!--
* @Date: 2022-07-18 10:22:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-10-25 20:45:12
* @LastEditTime: 2024-11-21 10:20:47
* @FilePath: /data-table/src/views/index.vue
* @Description: 首页
-->
......@@ -503,6 +503,22 @@ onMounted(async () => {
createComponentType(formData.value);
// TAG:不同类型提交表单处理
if (page_type === 'add' && model === 'edit') { // 表单为新增状态, 检查是否有未完成的表单信息
const existingCookie = Cookies.get($route.query.code);
if (existingCookie) {
// 如果Cookie存在,更新它
let object = JSON.parse(existingCookie);
console.warn(object);
// 默认值
const objectMap = new Map(Object.entries(object)); // 将 object 转换为 Map,Object.entries() 方法用于返回一个给定对象自身可枚举属性的键值对数组,数组中的每个元素是一个包含键值对的数组,[ ["name", "Alice"], ["age", 30], ["city", "New York"] ]
formData.value.forEach((item) => {
if (objectMap.has(item.key)) {
console.warn(objectMap.get(item.key));
item.component_props.default = objectMap.get(item.key);
}
});
}
}
if (page_type === 'add' && !force_back) { // 表单为新增状态, 非后台打开状态
// 过期时间显示
notice_text.value = `表单报名将在 ${formSetting.value.sjsj_end_time} 后结束`;
......@@ -973,7 +989,7 @@ const onSubmit = async (values) => { // 表单提交回调
console.warn(removeField);
console.warn(postData.value);
}
// if (model === 'edit' || model === 'preview' || page_type === 'info') return false;
if (model === 'edit' || model === 'preview' || page_type === 'info') return false;
// 提交按钮禁用
submitStatus.value = true;
// TAG:不同类型提交表单处理
......