hookehuyr

✨ feat: 新增姓名控件,新增性别控件

...@@ -12,16 +12,19 @@ declare module '@vue/runtime-core' { ...@@ -12,16 +12,19 @@ declare module '@vue/runtime-core' {
12 CalendarField: typeof import('./src/components/CalendarField/index.vue')['default'] 12 CalendarField: typeof import('./src/components/CalendarField/index.vue')['default']
13 CheckboxField: typeof import('./src/components/CheckboxField/index.vue')['default'] 13 CheckboxField: typeof import('./src/components/CheckboxField/index.vue')['default']
14 ContactField: typeof import('./src/components/ContactField/index.vue')['default'] 14 ContactField: typeof import('./src/components/ContactField/index.vue')['default']
15 + copy: typeof import('./src/components/RadioField copy/index.vue')['default']
15 DatePickerField: typeof import('./src/components/DatePickerField/index.vue')['default'] 16 DatePickerField: typeof import('./src/components/DatePickerField/index.vue')['default']
16 DateTimePickerField: typeof import('./src/components/DateTimePickerField/index.vue')['default'] 17 DateTimePickerField: typeof import('./src/components/DateTimePickerField/index.vue')['default']
17 DesField: typeof import('./src/components/DesField/index.vue')['default'] 18 DesField: typeof import('./src/components/DesField/index.vue')['default']
18 DividerField: typeof import('./src/components/DividerField/index.vue')['default'] 19 DividerField: typeof import('./src/components/DividerField/index.vue')['default']
19 EmailField: typeof import('./src/components/EmailField/index.vue')['default'] 20 EmailField: typeof import('./src/components/EmailField/index.vue')['default']
20 FileUploaderField: typeof import('./src/components/FileUploaderField/index.vue')['default'] 21 FileUploaderField: typeof import('./src/components/FileUploaderField/index.vue')['default']
22 + GenderField: typeof import('./src/components/GenderField/index.vue')['default']
21 IdentityField: typeof import('./src/components/IdentityField/index.vue')['default'] 23 IdentityField: typeof import('./src/components/IdentityField/index.vue')['default']
22 ImageUploaderField: typeof import('./src/components/ImageUploaderField/index.vue')['default'] 24 ImageUploaderField: typeof import('./src/components/ImageUploaderField/index.vue')['default']
23 MarqueeField: typeof import('./src/components/MarqueeField/index.vue')['default'] 25 MarqueeField: typeof import('./src/components/MarqueeField/index.vue')['default']
24 MultiRuleField: typeof import('./src/components/MultiRuleField/index.vue')['default'] 26 MultiRuleField: typeof import('./src/components/MultiRuleField/index.vue')['default']
27 + NameField: typeof import('./src/components/NameField/index.vue')['default']
25 NoteField: typeof import('./src/components/NoteField/index.vue')['default'] 28 NoteField: typeof import('./src/components/NoteField/index.vue')['default']
26 NumberField: typeof import('./src/components/NumberField/index.vue')['default'] 29 NumberField: typeof import('./src/components/NumberField/index.vue')['default']
27 PhoneField: typeof import('./src/components/PhoneField/index.vue')['default'] 30 PhoneField: typeof import('./src/components/PhoneField/index.vue')['default']
......
1 +<!--
2 + * @Date: 2022-08-30 11:34:19
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2023-02-01 11:06:05
5 + * @FilePath: /data-table/src/components/GenderField/index.vue
6 + * @Description: 性别选择控件
7 +-->
8 +<template>
9 + <div v-if="HideShow" class="radio-field-page">
10 + <div class="label">
11 + {{ item.component_props.label
12 + }}<span v-if="item.component_props.required">&nbsp;*</span>
13 + </div>
14 + <div v-if="item.component_props.note" class="note" v-html="item.component_props.note" />
15 + <van-field :name="item.name" :rules="item.rules">
16 + <template #input>
17 + <van-radio-group v-model="item.value" direction="horizontal">
18 + <van-radio name="男">男</van-radio>
19 + <van-radio name="女">女</van-radio>
20 + </van-radio-group>
21 + </template>
22 + </van-field>
23 + </div>
24 +</template>
25 +
26 +<script setup>
27 +import { styleColor } from "@/constant.js";
28 +
29 +const props = defineProps({
30 + item: Object,
31 +});
32 +
33 +// TAG: 自定义主题颜色
34 +const themeVars = {
35 + radioColor: styleColor.baseColor,
36 +};
37 +// 隐藏显示
38 +const HideShow = computed(() => {
39 + return !props.item.component_props.disabled
40 +})
41 +
42 +onMounted(() => {
43 +})
44 +</script>
45 +
46 +<style lang="less" scoped>
47 +.radio-field-page {
48 + .label {
49 + padding: 1rem 1rem 0 1rem;
50 + font-size: 0.9rem;
51 + font-weight: bold;
52 + span {
53 + color: red;
54 + }
55 + }
56 + .note {
57 + font-size: 0.9rem;
58 + margin-left: 1rem;
59 + color: gray;
60 + padding-bottom: 0.5rem;
61 + white-space: pre;
62 + }
63 +}
64 +
65 +:deep(.van-radio) {
66 + border: 1px solid #eaeaea;
67 + border-radius: 0.25rem;
68 + padding: 0.25rem 0.5rem;
69 + // width: 100vw;
70 +}
71 +</style>
1 +<!--
2 + * @Date: 2022-08-29 14:31:20
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2023-02-01 10:53:53
5 + * @FilePath: /data-table/src/components/NameField/index.vue
6 + * @Description: 姓名输入框
7 +-->
8 +<template>
9 + <div v-if="HideShow" class="text-field-page">
10 + <div class="label">
11 + {{ item.component_props.label
12 + }}<span v-if="item.component_props.required">&nbsp;*</span>
13 + </div>
14 + <van-field
15 + v-model="item.value"
16 + :name="item.name"
17 + :type="item.type"
18 + :placeholder="item.component_props.placeholder ? item.component_props.placeholder : '请输入'"
19 + :rules="item.rules"
20 + :required="item.required"
21 + :readonly="item.component_props.readonly"
22 + :disabled="item.component_props.disabled"
23 + :input-align="item.component_props.align"
24 + />
25 + </div>
26 +</template>
27 +
28 +<script setup>
29 +const props = defineProps({
30 + item: Object,
31 +});
32 +// 隐藏显示
33 +const HideShow = computed(() => {
34 + return !props.item.component_props.disabled
35 +})
36 +</script>
37 +
38 +<style lang="less" scoped>
39 +.text-field-page {
40 + .label {
41 + padding: 1rem 1rem 0 1rem;
42 + font-size: 0.9rem;
43 + font-weight: bold;
44 + span {
45 + color: red;
46 + }
47 + }
48 +}
49 +
50 +:deep(.van-field__body) {
51 + border: 1px solid #eaeaea;
52 + border-radius: 0.25rem;
53 + padding: 0.25rem 0.5rem;
54 +}
55 +</style>
...@@ -27,6 +27,8 @@ import RuleField from '@/components/RuleField/index.vue' ...@@ -27,6 +27,8 @@ import RuleField from '@/components/RuleField/index.vue'
27 import MultiRuleField from '@/components/MultiRuleField/index.vue' 27 import MultiRuleField from '@/components/MultiRuleField/index.vue'
28 import ButtonField from '@/components/ButtonField/index.vue' 28 import ButtonField from '@/components/ButtonField/index.vue'
29 import NoteField from '@/components/NoteField/index.vue'; 29 import NoteField from '@/components/NoteField/index.vue';
30 +import NameField from '@/components/NameField/index.vue';
31 +import GenderField from '@/components/GenderField/index.vue';
30 32
31 /** 33 /**
32 * 生成自定义组件类型 34 * 生成自定义组件类型
...@@ -54,6 +56,8 @@ import NoteField from '@/components/NoteField/index.vue'; ...@@ -54,6 +56,8 @@ import NoteField from '@/components/NoteField/index.vue';
54 * @type rule 活动规则控件 RuleField 56 * @type rule 活动规则控件 RuleField
55 * @type multi_rule 活动规则控件 MultiRuleField 57 * @type multi_rule 活动规则控件 MultiRuleField
56 * @type note 富文本控件 NoteField 58 * @type note 富文本控件 NoteField
59 + * @type name 姓名控件 NameField
60 + * @type gender 性别控件 GenderField
57 */ 61 */
58 export function createComponentType(data) { 62 export function createComponentType(data) {
59 // 判断类型和使用组件 63 // 判断类型和使用组件
...@@ -166,5 +170,13 @@ export function createComponentType(data) { ...@@ -166,5 +170,13 @@ export function createComponentType(data) {
166 item.name = item.key; 170 item.name = item.key;
167 item.component = NoteField; 171 item.component = NoteField;
168 } 172 }
173 + if (item.component_props.tag === 'name') {
174 + item.name = item.key;
175 + item.component = NameField;
176 + }
177 + if (item.component_props.tag === 'gender') {
178 + item.name = item.key;
179 + item.component = GenderField;
180 + }
169 }) 181 })
170 } 182 }
......