hookehuyr

测试首页cookie问题操作

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