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
2023-04-06 10:11:10 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
49631fe6c1c521c745e1c20784f9178b838f31c6
49631fe6
1 parent
2e21190c
✨ feat(身份证控件): 新增编辑按钮可以进行文字直接输入
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
components.d.ts
src/components/IdentityField/index.vue
components.d.ts
View file @
49631fe
...
...
@@ -45,7 +45,6 @@ declare module '@vue/runtime-core' {
RouterView
:
typeof
import
(
'vue-router'
)[
'RouterView'
]
RuleField
:
typeof
import
(
'./src/components/RuleField/index.vue'
)[
'default'
]
SignField
:
typeof
import
(
'./src/components/SignField/index.vue'
)[
'default'
]
'SignField copy'
:
typeof
import
(
'./src/components/SignField copy/index.vue'
)[
'default'
]
TableField
:
typeof
import
(
'./src/components/TableField/index.vue'
)[
'default'
]
Test
:
typeof
import
(
'./src/components/VideoField/test.vue'
)[
'default'
]
TextareaField
:
typeof
import
(
'./src/components/TextareaField/index.vue'
)[
'default'
]
...
...
src/components/IdentityField/index.vue
View file @
49631fe
<!--
* @Date: 2022-09-14 14:44:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-0
2-01 15:07:15
* @LastEditTime: 2023-0
4-06 10:08:41
* @FilePath: /data-table/src/components/IdentityField/index.vue
* @Description: 身份证输入控件
-->
...
...
@@ -13,6 +13,7 @@
</div>
<!-- <div v-if="item.component_props.readonly" style="padding: 0.5rem 1rem;">{{ item.value }}</div> -->
<van-field
ref="fieldRef"
v-model="item.value"
:id="item.name"
:name="item.name"
...
...
@@ -20,7 +21,8 @@
:rules="rules"
:required="item.component_props.required"
:disabled="item.component_props.readonly"
readonly
:readonly="!edit_mode"
right-icon="edit" @click-right-icon="clickRightIcon"
@touchstart.stop="openKeyboard($event)"
:border="false"
>
...
...
@@ -44,6 +46,7 @@ import $ from "jquery";
import { storeToRefs, mainStore } from "@/utils/generatePackage";
import { showSuccessToast, showFailToast } from "vant";
const props = defineProps({
item: Object,
});
...
...
@@ -71,8 +74,16 @@ watch(
}
);
const readonly = props.item.component_props.readonly;
const fieldRef = ref(null);
const edit_mode = ref(false);
const clickRightIcon = () => { // 编辑模式
edit_mode.value = true;
nextTick(() => {
fieldRef.value?.focus();
})
}
const openKeyboard = (e) => {
if (readonly
) return false; // 如果为只读
,不能设置
if (readonly
|| e.target.className.indexOf('edit') > 0 || edit_mode.value) return false; // 如果为只读或者编辑模式
,不能设置
// // 键盘上移动
// const target_to_view_height = window.innerHeight - e.target.getBoundingClientRect().y; // 元素到适口高度
// const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度
...
...
Please
register
or
login
to post a comment