Showing
1 changed file
with
32 additions
and
3 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-14 14:44:30 | 2 | * @Date: 2022-09-14 14:44:30 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-08-22 09:59:32 | 4 | + * @LastEditTime: 2024-08-23 13:39:19 |
| 5 | * @FilePath: /data-table/src/components/IdentityField/index.vue | 5 | * @FilePath: /data-table/src/components/IdentityField/index.vue |
| 6 | * @Description: 身份证输入控件 | 6 | * @Description: 身份证输入控件 |
| 7 | --> | 7 | --> |
| ... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
| 28 | :border="false" | 28 | :border="false" |
| 29 | > | 29 | > |
| 30 | </van-field> --> | 30 | </van-field> --> |
| 31 | - <div v-if="item.component_props.readonly" style="padding: 0.5rem 1rem; font-size: 0.9rem;"> | 31 | + <div v-if="item.component_props.readonly && data_type !== 'encrypt_mode'" style="padding: 0.5rem 1rem; font-size: 0.9rem;"> |
| 32 | {{ item.value }} | 32 | {{ item.value }} |
| 33 | </div> | 33 | </div> |
| 34 | <van-field | 34 | <van-field |
| ... | @@ -43,6 +43,9 @@ | ... | @@ -43,6 +43,9 @@ |
| 43 | :readonly="item.component_props.readonly" | 43 | :readonly="item.component_props.readonly" |
| 44 | :border="false" | 44 | :border="false" |
| 45 | > | 45 | > |
| 46 | + <template #button> | ||
| 47 | + <van-button size="small" type="primary" v-if="data_type === 'encrypt_mode'" @click="clickEdit()">编辑</van-button> | ||
| 48 | + </template> | ||
| 46 | </van-field> | 49 | </van-field> |
| 47 | <!-- <div v-if="gender" class="gender"><span>性别:</span>{{ gender }}</div> --> | 50 | <!-- <div v-if="gender" class="gender"><span>性别:</span>{{ gender }}</div> --> |
| 48 | <van-number-keyboard | 51 | <van-number-keyboard |
| ... | @@ -62,8 +65,9 @@ | ... | @@ -62,8 +65,9 @@ |
| 62 | import { useRoute } from "vue-router"; | 65 | import { useRoute } from "vue-router"; |
| 63 | import $ from "jquery"; | 66 | import $ from "jquery"; |
| 64 | import { storeToRefs, mainStore } from "@/utils/generatePackage"; | 67 | import { storeToRefs, mainStore } from "@/utils/generatePackage"; |
| 65 | -import { showSuccessToast, showFailToast } from "vant"; | 68 | +import { showSuccessToast, showFailToast, showConfirmDialog } from "vant"; |
| 66 | // import idCard from "idcard"; | 69 | // import idCard from "idcard"; |
| 70 | +import { styleColor } from "@/constant.js"; | ||
| 67 | 71 | ||
| 68 | const $route = useRoute(); | 72 | const $route = useRoute(); |
| 69 | const props = defineProps({ | 73 | const props = defineProps({ |
| ... | @@ -100,13 +104,38 @@ watch( | ... | @@ -100,13 +104,38 @@ watch( |
| 100 | } | 104 | } |
| 101 | ); | 105 | ); |
| 102 | 106 | ||
| 107 | +const data_type = ref(''); | ||
| 108 | +const clickEdit = () => { | ||
| 109 | + showConfirmDialog({ | ||
| 110 | + title: '温馨提示', | ||
| 111 | + message: | ||
| 112 | + '身份证号将重置后重新输入,是否确认?', | ||
| 113 | + confirmButtonColor: styleColor.baseColor | ||
| 114 | + }) | ||
| 115 | + .then(() => { | ||
| 116 | + // 重置输入显示 | ||
| 117 | + props.item.value = ''; | ||
| 118 | + props.item.component_props.readonly = false; | ||
| 119 | + data_type.value = ''; | ||
| 120 | + }) | ||
| 121 | + .catch(() => { | ||
| 122 | + // on cancel | ||
| 123 | + }); | ||
| 124 | +} | ||
| 125 | + | ||
| 103 | // 监听默认值变化 | 126 | // 监听默认值变化 |
| 104 | watch( | 127 | watch( |
| 105 | () => props.item.component_props.default, | 128 | () => props.item.component_props.default, |
| 106 | (v) => { | 129 | (v) => { |
| 107 | if (v) { | 130 | if (v) { |
| 108 | props.item.value = v; | 131 | props.item.value = v; |
| 132 | + if (v.indexOf('*') !== -1) { // 默认值是加密模式 | ||
| 133 | + props.item.component_props.readonly = true; | ||
| 134 | + data_type.value = 'encrypt_mode'; | ||
| 135 | + } | ||
| 109 | } | 136 | } |
| 137 | + }, { | ||
| 138 | + immediate: true, | ||
| 110 | } | 139 | } |
| 111 | ); | 140 | ); |
| 112 | 141 | ... | ... |
-
Please register or login to post a comment