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 13:36:13 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
822e97b59ee0a04bd31243f0358a091309edf84d
822e97b5
1 parent
f8be6f2c
🐞 fix: 修复地址数据保存时的情况不一样,取数据时可能出现问题的处理
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
src/components/AreaPickerField/index.vue
src/components/AreaPickerField/index.vue
View file @
822e97b
<!--
* @Date: 2022-08-30 14:32:11
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-11-21 13:
14:21
* @LastEditTime: 2024-11-21 13:
34:36
* @FilePath: /data-table/src/components/AreaPickerField/index.vue
* @Description: 省市区选择控件
-->
...
...
@@ -84,6 +84,15 @@ const validatorMessage = (val, rule) => {
};
const rules = [{ validator, message: validatorMessage }];
const isJSON = (value) => {
try {
JSON.parse(value);
return true;
} catch (e) {
return false;
}
}
// 子组件通信,适配规则触发
const onActive = (val) => {
// 适配cookie保存未完成表单
...
...
@@ -94,11 +103,22 @@ const onActive = (val) => {
// 如果Cookie存在,更新它
let obj = JSON.parse(existingCookie);
if (val.city_code) { // 修改了
let temp = JSON.parse(obj[props.item.key]);
let temp = null;
if (isJSON(obj[props.item.key])) {
temp = JSON.parse(obj[props.item.key]);
temp.city_code = val.city_code;
temp.province = val.province;
temp.city = val.city;
temp.district = val.district;
} else {
temp = {
city_code: val.city_code,
province: val.province,
city: val.city,
district: val.district,
street: val.street,
};
}
obj[props.item.key] = JSON.stringify(temp); // 替换掉旧值
} else { // 只修改了地址
let temp = JSON.parse(obj[props.item.key]);
...
...
Please
register
or
login
to post a comment