Skip to content

Commit d1e5ecf

Browse files
committed
style: 优化 GiForm 表单使用代码
1 parent 25da301 commit d1e5ecf

File tree

14 files changed

+45
-59
lines changed

14 files changed

+45
-59
lines changed

src/components/GiForm/src/GiForm.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ const getComponentBindProps = (item: ColumnItem) => {
143143
// 组件默认配置映射表
144144
const ConfigMap = new Map<ColumnItem['type'], Partial<ColumnItem['props'] & { placeholder: string }>>([
145145
['input', { allowClear: true, placeholder: `请输入${item.label}`, maxLength: 255, showWordLimit: true }],
146+
['input-password', { placeholder: `请输入${item.label}` }],
146147
['input-number', { placeholder: `请输入${item.label}` }],
147148
['textarea', { allowClear: false, placeholder: `请输入${item.label}`, maxLength: 200, showWordLimit: true, autoSize: { minRows: 3, maxRows: 5 } }],
148149
['input-tag', { allowClear: true, placeholder: `请输入${item.label}` }],

src/components/GiForm/src/type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { VNode } from 'vue'
33

44
export type ColumnItemType =
55
| 'input'
6+
| 'input-password'
67
| 'input-number'
78
| 'input-tag'
89
| 'textarea'
@@ -29,6 +30,7 @@ export type ColumnItemType =
2930

3031
export type ComponentProps =
3132
& A.InputInstance['$props']
33+
& A.InputPasswordInstance['$props']
3234
& A.InputNumberInstance['$props']
3335
& A.InputTagInstance['$props']
3436
& A.TextareaInstance['$props']

src/views/code/generator/GenConfigDrawer.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,10 @@ const formColumns: ColumnItem[] = reactive([
149149
label: '作者名称',
150150
field: 'author',
151151
type: 'input',
152+
required: true,
152153
props: {
153154
maxLength: 100,
154-
showWordLimit: true,
155155
},
156-
rules: [{ required: true, message: '请输入作者名称' }],
157156
},
158157
{
159158
label: '业务名称',
@@ -162,7 +161,6 @@ const formColumns: ColumnItem[] = reactive([
162161
props: {
163162
placeholder: '自定义业务名称,例如:用户',
164163
maxLength: 50,
165-
showWordLimit: true,
166164
},
167165
rules: [{ required: true, message: '请输入业务名称' }],
168166
},
@@ -184,7 +182,6 @@ const formColumns: ColumnItem[] = reactive([
184182
props: {
185183
placeholder: '项目模块包名,例如:top.continew.admin.system',
186184
maxLength: 60,
187-
showWordLimit: true,
188185
},
189186
rules: [{ required: true, message: '请输入模块包名' }],
190187
},
@@ -195,7 +192,6 @@ const formColumns: ColumnItem[] = reactive([
195192
props: {
196193
placeholder: '数据库表前缀,例如:sys_',
197194
maxLength: 20,
198-
showWordLimit: true,
199195
},
200196
},
201197
{

src/views/open/app/AppAddModal.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ const columns: ColumnItem[] = reactive([
4242
field: 'name',
4343
type: 'input',
4444
span: 24,
45-
rules: [{ required: true, message: '请输入名称' }],
45+
required: true,
46+
props: {
47+
maxLength: 100,
48+
},
4649
},
4750
{
4851
label: '失效时间',
@@ -59,10 +62,6 @@ const columns: ColumnItem[] = reactive([
5962
field: 'description',
6063
type: 'textarea',
6164
span: 24,
62-
props: {
63-
maxLength: 200,
64-
autoSize: { minRows: 3, maxRows: 5 },
65-
},
6665
},
6766
{
6867
label: '状态',

src/views/setting/components/VerifyModel.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ const columns: ColumnItem[] = reactive([
5959
field: 'phone',
6060
type: 'input',
6161
span: 24,
62+
props: {
63+
showWordLimit: false,
64+
},
6265
rules: [
6366
{ required: true, message: '请输入手机号' },
6467
{ match: Regexp.Phone, message: '请输入正确的手机号' },

src/views/system/client/ClientAddModal.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,20 @@ const columns: ColumnItem[] = reactive([
5353
label: '终端 Key',
5454
field: 'clientKey',
5555
type: 'input',
56-
rules: [{ required: true, message: '请输入终端 Key' }],
5756
span: 24,
58-
disabled: () => {
59-
return isUpdate.value
57+
required: true,
58+
props: {
59+
maxLength: 32,
6060
},
61+
disabled: () => isUpdate.value,
6162
},
6263
{
6364
label: '终端秘钥',
6465
field: 'clientSecret',
6566
type: 'input',
66-
rules: [{ required: true, message: '请输入终端秘钥' }],
6767
span: 24,
68-
disabled: () => {
69-
return isUpdate.value
70-
},
68+
required: true,
69+
disabled: () => isUpdate.value,
7170
slots: {
7271
append: () => (
7372
<a-button onClick={handleGenerate}>
@@ -83,12 +82,12 @@ const columns: ColumnItem[] = reactive([
8382
label: '认证类型',
8483
field: 'authType',
8584
type: 'select',
85+
required: true,
8686
props: {
8787
options: auth_type_enum,
8888
multiple: true,
8989
maxTagCount: 2,
9090
},
91-
rules: [{ required: true, message: '请选择认证类型' }],
9291
},
9392
{
9493
label: '终端类型',
@@ -97,7 +96,6 @@ const columns: ColumnItem[] = reactive([
9796
props: {
9897
options: client_type,
9998
},
100-
rules: [{ required: true, message: '请选择终端类型' }],
10199
},
102100
{
103101
label: () => (
@@ -141,11 +139,11 @@ const columns: ColumnItem[] = reactive([
141139
label: '状态',
142140
field: 'status',
143141
type: 'radio-group',
142+
required: true,
144143
props: {
145144
type: 'button',
146145
options: DisEnableStatusList,
147146
},
148-
rules: [{ required: true, message: '请选择状态' }],
149147
},
150148
])
151149

src/views/system/dept/DeptAddModal.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ const columns: ColumnItem[] = reactive([
103103
field: 'description',
104104
type: 'textarea',
105105
span: 24,
106-
props: {
107-
maxLength: 200,
108-
autoSize: { minRows: 3, maxRows: 5 },
109-
},
110106
},
111107
{
112108
label: '状态',

src/views/system/dict/DictItemAddModal.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ const columns: ColumnItem[] = reactive([
5353
field: 'label',
5454
type: 'input',
5555
span: 24,
56-
rules: [{ required: true, message: '请输入标签' }],
56+
required: true,
57+
props: {
58+
maxLength: 30,
59+
},
5760
},
5861
{
5962
label: '',
6063
field: 'value',
6164
type: 'input',
6265
span: 24,
63-
rules: [{ required: true, message: '请输入值' }],
66+
required: true,
67+
props: {
68+
maxLength: 30,
69+
},
6470
},
6571
{
6672
label: '标签颜色',
@@ -83,10 +89,6 @@ const columns: ColumnItem[] = reactive([
8389
field: 'description',
8490
type: 'textarea',
8591
span: 24,
86-
props: {
87-
maxLength: 200,
88-
autoSize: { minRows: 3, maxRows: 5 },
89-
},
9092
},
9193
{
9294
label: '状态',

src/views/system/dict/tree/DictAddModal.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,27 @@ const columns: ColumnItem[] = reactive([
4040
field: 'name',
4141
type: 'input',
4242
span: 24,
43-
rules: [{ required: true, message: '请输入名称',
44-
}],
43+
required: true,
44+
props: {
45+
maxLength: 30,
46+
},
4547
},
4648
{
4749
label: '编码',
4850
field: 'code',
4951
type: 'input',
5052
span: 24,
51-
rules: [{ required: true, message: '请输入编码' }],
53+
required: true,
54+
props: {
55+
maxLength: 30,
56+
},
5257
disabled: () => isUpdate.value,
5358
},
5459
{
5560
label: '描述',
5661
field: 'description',
5762
type: 'textarea',
5863
span: 24,
59-
props: {
60-
maxLength: 200,
61-
autoSize: { minRows: 3, maxRows: 5 },
62-
},
6364
},
6465
])
6566

src/views/system/role/RoleAddDrawer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<fieldset>
1313
<legend>基础信息</legend>
1414
<a-form-item label="名称" field="name">
15-
<a-input v-model.trim="form.name" placeholder="请输入名称" />
15+
<a-input v-model.trim="form.name" placeholder="请输入名称" max-length="30" show-word-limit />
1616
</a-form-item>
1717
<a-form-item label="编码" field="code">
18-
<a-input v-model.trim="form.code" placeholder="请输入编码" :disabled="isUpdate" />
18+
<a-input v-model.trim="form.code" placeholder="请输入编码" max-length="30" show-word-limit :disabled="isUpdate" />
1919
</a-form-item>
2020
<a-form-item label="排序" field="sort">
2121
<a-input-number v-model="form.sort" placeholder="请输入排序" :min="1" mode="button" />

0 commit comments

Comments
 (0)