Showing
4 changed files
with
84 additions
and
3 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 14:31:20 | 2 | * @Date: 2022-08-29 14:31:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-08-19 15:22:34 | 4 | + * @LastEditTime: 2024-11-20 16:57:46 |
| 5 | * @FilePath: /data-table/src/components/NameField/index.vue | 5 | * @FilePath: /data-table/src/components/NameField/index.vue |
| 6 | * @Description: 姓名输入框 | 6 | * @Description: 姓名输入框 |
| 7 | --> | 7 | --> |
| ... | @@ -33,6 +33,8 @@ | ... | @@ -33,6 +33,8 @@ |
| 33 | 33 | ||
| 34 | <script setup> | 34 | <script setup> |
| 35 | import { useRoute } from "vue-router"; | 35 | import { useRoute } from "vue-router"; |
| 36 | +import Cookies from 'js-cookie'; | ||
| 37 | + | ||
| 36 | const $route = useRoute(); | 38 | const $route = useRoute(); |
| 37 | const props = defineProps({ | 39 | const props = defineProps({ |
| 38 | item: Object, | 40 | item: Object, |
| ... | @@ -66,6 +68,25 @@ watch( | ... | @@ -66,6 +68,25 @@ watch( |
| 66 | } | 68 | } |
| 67 | } | 69 | } |
| 68 | ); | 70 | ); |
| 71 | + | ||
| 72 | +// 适配cookie保存未完成表单 | ||
| 73 | +watch( | ||
| 74 | + () => props.item.value, | ||
| 75 | + (v) => { | ||
| 76 | + const currentValue = v; | ||
| 77 | + const existingCookie = Cookies.get($route.query.code); | ||
| 78 | + | ||
| 79 | + if (existingCookie) { | ||
| 80 | + // 如果Cookie存在,更新它 | ||
| 81 | + let obj = JSON.parse(existingCookie); | ||
| 82 | + obj[props.item.key] = currentValue; // 替换掉旧值 | ||
| 83 | + Cookies.set($route.query.code, JSON.stringify(obj)); | ||
| 84 | + } else { | ||
| 85 | + // 如果Cookie不存在,新增它 | ||
| 86 | + Cookies.set($route.query.code, JSON.stringify({ [props.item.key]: currentValue })); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + ); | ||
| 69 | </script> | 90 | </script> |
| 70 | 91 | ||
| 71 | <style lang="less" scoped> | 92 | <style lang="less" scoped> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-30 11:34:19 | 2 | * @Date: 2022-08-30 11:34:19 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-08-22 09:55:29 | 4 | + * @LastEditTime: 2024-11-20 17:43:24 |
| 5 | * @FilePath: /data-table/src/components/RadioField/index.vue | 5 | * @FilePath: /data-table/src/components/RadioField/index.vue |
| 6 | * @Description: 单项选择控件 | 6 | * @Description: 单项选择控件 |
| 7 | --> | 7 | --> |
| ... | @@ -64,6 +64,7 @@ | ... | @@ -64,6 +64,7 @@ |
| 64 | import { styleColor } from "@/constant.js"; | 64 | import { styleColor } from "@/constant.js"; |
| 65 | import $ from "jquery"; | 65 | import $ from "jquery"; |
| 66 | import { useRoute } from "vue-router"; | 66 | import { useRoute } from "vue-router"; |
| 67 | +import Cookies from 'js-cookie'; | ||
| 67 | 68 | ||
| 68 | const $route = useRoute(); | 69 | const $route = useRoute(); |
| 69 | 70 | ||
| ... | @@ -173,6 +174,25 @@ const showUrl = (rule) => { | ... | @@ -173,6 +174,25 @@ const showUrl = (rule) => { |
| 173 | location.href = rule.desc_url | 174 | location.href = rule.desc_url |
| 174 | } | 175 | } |
| 175 | const rule_content = ref(""); | 176 | const rule_content = ref(""); |
| 177 | + | ||
| 178 | +// 适配cookie保存未完成表单 | ||
| 179 | +watch( | ||
| 180 | + () => props.item.value, | ||
| 181 | + (v) => { | ||
| 182 | + const currentValue = v.affix ? v.affix : v.value; | ||
| 183 | + const existingCookie = Cookies.get($route.query.code); | ||
| 184 | + | ||
| 185 | + if (existingCookie) { | ||
| 186 | + // 如果Cookie存在,更新它 | ||
| 187 | + let obj = JSON.parse(existingCookie); | ||
| 188 | + obj[props.item.key] = currentValue; // 替换掉旧值 | ||
| 189 | + Cookies.set($route.query.code, JSON.stringify(obj)); | ||
| 190 | + } else { | ||
| 191 | + // 如果Cookie不存在,新增它 | ||
| 192 | + Cookies.set($route.query.code, JSON.stringify({ [props.item.key]: currentValue })); | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + ); | ||
| 176 | </script> | 196 | </script> |
| 177 | 197 | ||
| 178 | <style lang="less" scoped> | 198 | <style lang="less" scoped> | ... | ... |
| ... | @@ -30,6 +30,7 @@ import { useRoute } from "vue-router"; | ... | @@ -30,6 +30,7 @@ import { useRoute } from "vue-router"; |
| 30 | import { showSuccessToast, showFailToast } from 'vant'; | 30 | import { showSuccessToast, showFailToast } from 'vant'; |
| 31 | // 初始化WX环境 | 31 | // 初始化WX环境 |
| 32 | import wx from 'weixin-js-sdk' | 32 | import wx from 'weixin-js-sdk' |
| 33 | +import Cookies from 'js-cookie'; | ||
| 33 | 34 | ||
| 34 | const $route = useRoute(); | 35 | const $route = useRoute(); |
| 35 | const props = defineProps({ | 36 | const props = defineProps({ |
| ... | @@ -65,6 +66,25 @@ watch( | ... | @@ -65,6 +66,25 @@ watch( |
| 65 | } | 66 | } |
| 66 | ); | 67 | ); |
| 67 | 68 | ||
| 69 | +// 适配cookie保存未完成表单 | ||
| 70 | +watch( | ||
| 71 | + () => props.item.value, | ||
| 72 | + (v) => { | ||
| 73 | + const currentValue = v; | ||
| 74 | + const existingCookie = Cookies.get($route.query.code); | ||
| 75 | + | ||
| 76 | + if (existingCookie) { | ||
| 77 | + // 如果Cookie存在,更新它 | ||
| 78 | + let obj = JSON.parse(existingCookie); | ||
| 79 | + obj[props.item.key] = currentValue; // 替换掉旧值 | ||
| 80 | + Cookies.set($route.query.code, JSON.stringify(obj)); | ||
| 81 | + } else { | ||
| 82 | + // 如果Cookie不存在,新增它 | ||
| 83 | + Cookies.set($route.query.code, JSON.stringify({ [props.item.key]: currentValue })); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + ); | ||
| 87 | + | ||
| 68 | // 默认识别类型 | 88 | // 默认识别类型 |
| 69 | const scan_type_code = ref('ALL_CODE'); | 89 | const scan_type_code = ref('ALL_CODE'); |
| 70 | // 微信二维码扫描功能判断 | 90 | // 微信二维码扫描功能判断 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 14:31:20 | 2 | * @Date: 2022-08-29 14:31:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-09-14 13:40:21 | 4 | + * @LastEditTime: 2024-11-20 17:02:26 |
| 5 | * @FilePath: /data-table/src/components/TextareaField/index.vue | 5 | * @FilePath: /data-table/src/components/TextareaField/index.vue |
| 6 | * @Description: 多行文本输入框 | 6 | * @Description: 多行文本输入框 |
| 7 | --> | 7 | --> |
| ... | @@ -37,6 +37,7 @@ | ... | @@ -37,6 +37,7 @@ |
| 37 | 37 | ||
| 38 | <script setup> | 38 | <script setup> |
| 39 | import { useRoute } from "vue-router"; | 39 | import { useRoute } from "vue-router"; |
| 40 | +import Cookies from 'js-cookie'; | ||
| 40 | 41 | ||
| 41 | const props = defineProps({ | 42 | const props = defineProps({ |
| 42 | item: Object, | 43 | item: Object, |
| ... | @@ -58,6 +59,25 @@ onMounted(() => { | ... | @@ -58,6 +59,25 @@ onMounted(() => { |
| 58 | // 只读模式下默认值替换换行符 | 59 | // 只读模式下默认值替换换行符 |
| 59 | props.item.value = props.item.component_props.readonly ? props.item.component_props.default?.replace(/\n/g, "<br>") : props.item.component_props.default; | 60 | props.item.value = props.item.component_props.readonly ? props.item.component_props.default?.replace(/\n/g, "<br>") : props.item.component_props.default; |
| 60 | }) | 61 | }) |
| 62 | + | ||
| 63 | +// 适配cookie保存未完成表单 | ||
| 64 | +watch( | ||
| 65 | + () => props.item.value, | ||
| 66 | + (v) => { | ||
| 67 | + const currentValue = v; | ||
| 68 | + const existingCookie = Cookies.get($route.query.code); | ||
| 69 | + | ||
| 70 | + if (existingCookie) { | ||
| 71 | + // 如果Cookie存在,更新它 | ||
| 72 | + let obj = JSON.parse(existingCookie); | ||
| 73 | + obj[props.item.key] = currentValue; // 替换掉旧值 | ||
| 74 | + Cookies.set($route.query.code, JSON.stringify(obj)); | ||
| 75 | + } else { | ||
| 76 | + // 如果Cookie不存在,新增它 | ||
| 77 | + Cookies.set($route.query.code, JSON.stringify({ [props.item.key]: currentValue })); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + ); | ||
| 61 | </script> | 81 | </script> |
| 62 | 82 | ||
| 63 | <style lang="less" scoped> | 83 | <style lang="less" scoped> | ... | ... |
-
Please register or login to post a comment