gi-component 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +60 -60
- package/packages/components/edit-table/src/edit-table.vue +36 -30
- package/packages/components/form/src/form.vue +423 -426
- package/packages/components/form/src/type.ts +84 -84
- package/packages/hooks/index.ts +0 -1
- package/packages/index.ts +5 -5
- package/packages/styles/index.scss +6 -0
- package/packages/utils/createSelectDialog.ts +23 -16
- package/packages/hooks/useTable.ts +0 -100
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gi-component",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "Vue3中基于Element Plus二次封装基础组件库",
|
|
6
|
-
"author": "lin",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/lin-97/gi-component.git"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"element-plus",
|
|
14
|
-
"vitepress",
|
|
15
|
-
"vue3",
|
|
16
|
-
"gi-component",
|
|
17
|
-
"二次封装组件",
|
|
18
|
-
"封装组件"
|
|
19
|
-
],
|
|
20
|
-
"main": "dist/index.umd.js",
|
|
21
|
-
"module": "dist/index.es.js",
|
|
22
|
-
"types": "dist/index.d.ts",
|
|
23
|
-
"files": [
|
|
24
|
-
"dist",
|
|
25
|
-
"packages"
|
|
26
|
-
],
|
|
27
|
-
"scripts": {
|
|
28
|
-
"dev": "vite --host",
|
|
29
|
-
"docs:dev": "cd docs && pnpm dev",
|
|
30
|
-
"docs:build": "cd docs && pnpm build",
|
|
31
|
-
"docs:preview": "cd docs && pnpm preview",
|
|
32
|
-
"build:lib": "vite build",
|
|
33
|
-
"build:docs": "cd docs && pnpm build",
|
|
34
|
-
"lint": "eslint .",
|
|
35
|
-
"lint:fix": "eslint . --fix"
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"element-plus": "^2.11.0",
|
|
39
|
-
"vue": "^3.4.0"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@antfu/eslint-config": "^
|
|
43
|
-
"@element-plus/icons-vue": "^2.3.1",
|
|
44
|
-
"@types/node": "^24.2.0",
|
|
45
|
-
"@vitejs/plugin-vue": "^5.2.4",
|
|
46
|
-
"@vitejs/plugin-vue-jsx": "^4.2.0",
|
|
47
|
-
"element-plus": "^2.11.2",
|
|
48
|
-
"eslint": "^9.
|
|
49
|
-
"sass": "^1.89.0",
|
|
50
|
-
"sass-loader": "^16.0.5",
|
|
51
|
-
"terser": "^5.44.0",
|
|
52
|
-
"typescript": "^5.8.3",
|
|
53
|
-
"unplugin-vue-components": "^28.8.0",
|
|
54
|
-
"vite": "6.3.5",
|
|
55
|
-
"vite-plugin-dts": "^4.5.4",
|
|
56
|
-
"vue": "^3.5.15",
|
|
57
|
-
"vue-tsc": "^2.2.10",
|
|
58
|
-
"xe-utils": "^3.7.9"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gi-component",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.28",
|
|
5
|
+
"description": "Vue3中基于Element Plus二次封装基础组件库",
|
|
6
|
+
"author": "lin",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/lin-97/gi-component.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"element-plus",
|
|
14
|
+
"vitepress",
|
|
15
|
+
"vue3",
|
|
16
|
+
"gi-component",
|
|
17
|
+
"二次封装组件",
|
|
18
|
+
"封装组件"
|
|
19
|
+
],
|
|
20
|
+
"main": "dist/index.umd.js",
|
|
21
|
+
"module": "dist/index.es.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"packages"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"dev": "vite --host",
|
|
29
|
+
"docs:dev": "cd docs && pnpm dev",
|
|
30
|
+
"docs:build": "cd docs && pnpm build",
|
|
31
|
+
"docs:preview": "cd docs && pnpm preview",
|
|
32
|
+
"build:lib": "vite build",
|
|
33
|
+
"build:docs": "cd docs && pnpm build",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"lint:fix": "eslint . --fix"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"element-plus": "^2.11.0",
|
|
39
|
+
"vue": "^3.4.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@antfu/eslint-config": "^7.2.0",
|
|
43
|
+
"@element-plus/icons-vue": "^2.3.1",
|
|
44
|
+
"@types/node": "^24.2.0",
|
|
45
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
46
|
+
"@vitejs/plugin-vue-jsx": "^4.2.0",
|
|
47
|
+
"element-plus": "^2.11.2",
|
|
48
|
+
"eslint": "^9.39.2",
|
|
49
|
+
"sass": "^1.89.0",
|
|
50
|
+
"sass-loader": "^16.0.5",
|
|
51
|
+
"terser": "^5.44.0",
|
|
52
|
+
"typescript": "^5.8.3",
|
|
53
|
+
"unplugin-vue-components": "^28.8.0",
|
|
54
|
+
"vite": "6.3.5",
|
|
55
|
+
"vite-plugin-dts": "^4.5.4",
|
|
56
|
+
"vue": "^3.5.15",
|
|
57
|
+
"vue-tsc": "^2.2.10",
|
|
58
|
+
"xe-utils": "^3.7.9"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
<template v-if="column.slotName">
|
|
11
11
|
<slot :name="column.slotName" v-bind="scope"></slot>
|
|
12
12
|
</template>
|
|
13
|
-
<template v-else-if="!column.type">
|
|
13
|
+
<template v-else-if="!column.type">
|
|
14
|
+
{{ scope.row[column.prop] }}
|
|
15
|
+
</template>
|
|
14
16
|
<component :is="COMP_MAP[column.type] || column.type" v-else v-bind="getComponentBindProps(column)"
|
|
15
|
-
v-model="scope.row[column.prop]" class="w-full" :disabled="isDisabled(scope)"
|
|
16
|
-
</component>
|
|
17
|
+
v-model="scope.row[column.prop]" class="w-full" :disabled="isDisabled(scope)" />
|
|
17
18
|
</ElFormItem>
|
|
18
19
|
</template>
|
|
19
20
|
</ElTableColumn>
|
|
@@ -109,36 +110,38 @@ const STATIC_PROPS = new Map([
|
|
|
109
110
|
['title', {}]
|
|
110
111
|
])
|
|
111
112
|
|
|
113
|
+
/** 占位符文本映射 */
|
|
114
|
+
const PLACEHOLDER_MAP = new Map<EditTableColumnItemType, (label?: string) => string | undefined>([
|
|
115
|
+
['input', (label) => `请输入${label}`],
|
|
116
|
+
['input-number', (label) => `请输入${label}`],
|
|
117
|
+
['input-tag', (label) => `请输入${label}`],
|
|
118
|
+
['textarea', (label) => `请填写${label}`],
|
|
119
|
+
['select', (label) => `请选择${label}`],
|
|
120
|
+
['select-v2', (label) => `请选择${label}`],
|
|
121
|
+
['tree-select', (label) => `请选择${label}`],
|
|
122
|
+
['cascader', (label) => `请选择${label}`],
|
|
123
|
+
['time-select', (label) => `请选择${label}`],
|
|
124
|
+
['input-search', (label) => `请选择${label}`],
|
|
125
|
+
['date-picker', () => '请选择日期'],
|
|
126
|
+
['time-picker', () => '请选择时间']
|
|
127
|
+
])
|
|
128
|
+
|
|
112
129
|
/** 获取占位文本 */
|
|
113
|
-
const getPlaceholder = (item: EditTableColumnItem) => {
|
|
130
|
+
const getPlaceholder = (item: EditTableColumnItem): string | undefined => {
|
|
114
131
|
if (!item.type) return undefined
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
if (['textarea'].includes(item.type)) {
|
|
119
|
-
return `请填写${item.label}`
|
|
120
|
-
}
|
|
121
|
-
if (
|
|
122
|
-
['select', 'select-v2', 'tree-select', 'cascader', 'time-select', 'input-search'].includes(
|
|
123
|
-
item.type
|
|
124
|
-
)
|
|
125
|
-
) {
|
|
126
|
-
return `请选择${item.label}`
|
|
127
|
-
}
|
|
128
|
-
if (['date-picker'].includes(item.type)) {
|
|
129
|
-
return `请选择日期`
|
|
130
|
-
}
|
|
131
|
-
if (['time-picker'].includes(item.type)) {
|
|
132
|
-
return `请选择时间`
|
|
133
|
-
}
|
|
134
|
-
return undefined
|
|
132
|
+
const placeholderFn = PLACEHOLDER_MAP.get(item.type)
|
|
133
|
+
return placeholderFn ? placeholderFn(item.label) : undefined
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
|
|
136
|
+
/** 组件的默认props配置 */
|
|
138
137
|
function getComponentBindProps(item: EditTableColumnItem) {
|
|
139
138
|
// 获取默认配置
|
|
140
|
-
const defaultProps: any = STATIC_PROPS.get(item.type || '') || {}
|
|
141
|
-
|
|
139
|
+
const defaultProps: Record<string, any> = { ...(STATIC_PROPS.get(item.type || '') || {}) }
|
|
140
|
+
const placeholder = getPlaceholder(item)
|
|
141
|
+
if (placeholder) {
|
|
142
|
+
defaultProps.placeholder = placeholder
|
|
143
|
+
}
|
|
144
|
+
// 日期选择器格式化
|
|
142
145
|
if (item.type === 'date-picker') {
|
|
143
146
|
defaultProps.valueFormat = item?.componentProps?.type === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'
|
|
144
147
|
}
|
|
@@ -148,10 +151,11 @@ function getComponentBindProps(item: EditTableColumnItem) {
|
|
|
148
151
|
|
|
149
152
|
/** 表单项校验规则 */
|
|
150
153
|
function getFormItemRules(item: EditTableColumnItem) {
|
|
154
|
+
const rules = Array.isArray(item.rules) ? item.rules : []
|
|
151
155
|
if (item.required) {
|
|
152
156
|
return [
|
|
153
157
|
{ required: true, message: `${item.label}为必填项` },
|
|
154
|
-
...
|
|
158
|
+
...rules
|
|
155
159
|
]
|
|
156
160
|
}
|
|
157
161
|
return item.rules
|
|
@@ -164,8 +168,10 @@ function getLabelClassName(item: EditTableColumnItem) {
|
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
/** 判断是否禁用 */
|
|
167
|
-
const isDisabled = (
|
|
168
|
-
if (typeof props?.cellDisabled === 'function')
|
|
171
|
+
const isDisabled = (scope: any): boolean => {
|
|
172
|
+
if (typeof props?.cellDisabled === 'function') {
|
|
173
|
+
return props.cellDisabled(scope)
|
|
174
|
+
}
|
|
169
175
|
return false
|
|
170
176
|
}
|
|
171
177
|
|