Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2024-11-21 10:44:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
28dc01e055d1a6f980179d5961789542325231bd
28dc01e0
1 parent
99f9b8b3
✨ feat: 适配cookie保存未完成表单
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
src/components/GenderField/index.vue
src/components/IdentityField/index.vue
src/components/GenderField/index.vue
View file @
28dc01e
...
...
@@ -38,6 +38,7 @@
<script setup>
import { useRoute } from "vue-router";
import { styleColor } from "@/constant.js";
import Cookies from 'js-cookie';
const $route = useRoute();
const props = defineProps({
...
...
@@ -84,6 +85,19 @@ const onChange = (item) => {
// 发送自定义数据结构
props.item.value = { key: props.item.key, value: gender_value.value, type: "gender" };
emit("active", props.item.value);
// 适配cookie保存未完成表单
const currentValue = gender_value.value;
const existingCookie = Cookies.get($route.query.code);
if (existingCookie) {
// 如果Cookie存在,更新它
let obj = JSON.parse(existingCookie);
obj[props.item.key] = currentValue; // 替换掉旧值
Cookies.set($route.query.code, JSON.stringify(obj));
} else {
// 如果Cookie不存在,新增它
Cookies.set($route.query.code, JSON.stringify({ [props.item.key]: currentValue }));
}
}
</script>
...
...
src/components/IdentityField/index.vue
View file @
28dc01e
<!--
* @Date: 2022-09-14 14:44:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-1
0-28 09:55:37
* @LastEditTime: 2024-1
1-21 10:39:09
* @FilePath: /data-table/src/components/IdentityField/index.vue
* @Description: 身份证输入控件
-->
...
...
@@ -42,6 +42,7 @@
:required="item.component_props.required"
:readonly="item.component_props.readonly"
:border="false"
@blur="onBlur(item)"
>
<template #button>
<van-button size="small" type="primary" v-if="IdEditShow" @click="clickEdit()">编辑</van-button>
...
...
@@ -68,6 +69,7 @@ import { storeToRefs, mainStore } from "@/utils/generatePackage";
import { showSuccessToast, showFailToast, showConfirmDialog } from "vant";
// import idCard from "idcard";
import { styleColor } from "@/constant.js";
import Cookies from 'js-cookie';
const $route = useRoute();
const props = defineProps({
...
...
@@ -310,6 +312,22 @@ const getGenderByIdNumber = (idNumber) => {
}
}
}
// 适配cookie保存未完成表单
const onBlur = (item) => {
const currentValue = item.value;
const existingCookie = Cookies.get($route.query.code);
if (existingCookie) {
// 如果Cookie存在,更新它
let obj = JSON.parse(existingCookie);
obj[props.item.key] = currentValue; // 替换掉旧值
Cookies.set($route.query.code, JSON.stringify(obj));
} else {
// 如果Cookie不存在,新增它
Cookies.set($route.query.code, JSON.stringify({ [props.item.key]: currentValue }));
}
}
</script>
<style lang="less" scoped>
...
...
Please
register
or
login
to post a comment