gi-component 0.0.7 → 0.0.8
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/dist/gi.css +1 -1
- package/dist/index.d.ts +4 -50
- package/dist/index.es.js +39 -39
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +10 -3
- package/packages/components/button/index.ts +4 -4
- package/packages/components/button/src/button.vue +32 -32
- package/packages/components/button/src/type.ts +2 -2
- package/packages/components/card/index.ts +4 -4
- package/packages/components/card/src/card.vue +21 -21
- package/packages/components/card/src/type.ts +9 -9
- package/packages/components/dialog/index.ts +5 -5
- package/packages/components/dialog/src/dialog.ts +33 -33
- package/packages/components/dialog/src/dialog.vue +34 -32
- package/packages/components/dialog/src/type.ts +13 -13
- package/packages/components/edit-table/index.ts +4 -4
- package/packages/components/edit-table/src/edit-table.vue +47 -47
- package/packages/components/edit-table/src/type.ts +42 -63
- package/packages/components/form/index.ts +4 -4
- package/packages/components/form/src/form.vue +98 -97
- package/packages/components/form/src/type.ts +67 -88
- package/packages/components/grid/index.ts +6 -6
- package/packages/components/grid/src/context.ts +17 -17
- package/packages/components/grid/src/grid-item.vue +40 -40
- package/packages/components/grid/src/grid.vue +38 -38
- package/packages/components/grid/src/hook/use-index.ts +24 -24
- package/packages/components/grid/src/hook/use-responsive-state.ts +26 -26
- package/packages/components/grid/src/hook/use-responsive-value.ts +24 -24
- package/packages/components/grid/src/interface.ts +32 -32
- package/packages/components/grid/src/utils/global-config.ts +3 -3
- package/packages/components/grid/src/utils/index.ts +25 -25
- package/packages/components/grid/src/utils/is.ts +2 -2
- package/packages/components/grid/src/utils/responsive-observe.ts +53 -53
- package/packages/components/input-group/index.ts +4 -4
- package/packages/components/input-group/src/input-group.vue +2 -2
- package/packages/components/input-search/index.ts +4 -4
- package/packages/components/input-search/src/input-search.vue +15 -15
- package/packages/components/input-search/src/type.ts +4 -4
- package/packages/components/page-layout/index.ts +4 -4
- package/packages/components/page-layout/src/page-layout.vue +25 -25
- package/packages/components/page-layout/src/split-button.vue +22 -22
- package/packages/components/page-layout/src/type.ts +9 -9
- package/packages/components/table/index.ts +4 -4
- package/packages/components/table/src/TableColumn.vue +10 -10
- package/packages/components/table/src/table.vue +14 -14
- package/packages/components/table/src/type.ts +7 -7
- package/packages/components/tabs/index.ts +4 -4
- package/packages/components/tabs/src/tabs.vue +20 -20
- package/packages/components/tabs/src/type.ts +9 -9
- package/packages/hooks/index.ts +2 -2
- package/packages/hooks/useBemClass.ts +7 -7
- package/packages/hooks/useTable.ts +6 -7
- package/packages/index.ts +44 -44
- package/packages/styles/index.scss +6 -0
- package/packages/types/tool.ts +4 -4
- package/packages/utils/createSelectDialog.ts +28 -27
- package/packages/utils/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gi-component",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"description": "Vue3中基于Element Plus二次封装基础组件库",
|
|
6
6
|
"author": "lin",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,7 +30,12 @@
|
|
|
30
30
|
"docs:build": "cd docs && pnpm build",
|
|
31
31
|
"docs:preview": "cd docs && pnpm preview",
|
|
32
32
|
"build:lib": "vite build --mode lib",
|
|
33
|
-
"build:docs": "cd docs && pnpm build"
|
|
33
|
+
"build:docs": "cd docs && pnpm build",
|
|
34
|
+
"release:patch": "standard-version --release-as patch",
|
|
35
|
+
"release:minor": "standard-version --release-as minor",
|
|
36
|
+
"release:major": "standard-version --release-as major",
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"lint:fix": "eslint . --fix"
|
|
34
39
|
},
|
|
35
40
|
"peerDependencies": {
|
|
36
41
|
"element-plus": "^2.11.2",
|
|
@@ -39,12 +44,14 @@
|
|
|
39
44
|
"devDependencies": {
|
|
40
45
|
"@antfu/eslint-config": "^5.2.1",
|
|
41
46
|
"@element-plus/icons-vue": "^2.3.1",
|
|
47
|
+
"@types/node": "^24.2.0",
|
|
42
48
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
43
49
|
"@vitejs/plugin-vue-jsx": "^4.2.0",
|
|
44
50
|
"element-plus": "^2.11.2",
|
|
45
51
|
"eslint": "^9.27.0",
|
|
46
52
|
"sass": "^1.89.0",
|
|
47
53
|
"sass-loader": "^16.0.5",
|
|
54
|
+
"standard-version": "^9.5.0",
|
|
48
55
|
"terser": "^5.44.0",
|
|
49
56
|
"typescript": "^5.8.3",
|
|
50
57
|
"unplugin-vue-components": "^28.8.0",
|
|
@@ -53,4 +60,4 @@
|
|
|
53
60
|
"vue": "^3.5.15",
|
|
54
61
|
"vue-tsc": "^2.2.10"
|
|
55
62
|
}
|
|
56
|
-
}
|
|
63
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Button from './src/button.vue'
|
|
1
|
+
import Button from './src/button.vue'
|
|
2
2
|
|
|
3
|
-
export type ButtonInstance = InstanceType<typeof Button
|
|
4
|
-
export * from './src/type'
|
|
5
|
-
export default Button
|
|
3
|
+
export type ButtonInstance = InstanceType<typeof Button>
|
|
4
|
+
export * from './src/type'
|
|
5
|
+
export default Button
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import type { ButtonProps as ElButtonProps } from 'element-plus'
|
|
9
|
-
import type { ButtonProps } from './type.ts'
|
|
8
|
+
import type { ButtonProps as ElButtonProps } from 'element-plus'
|
|
9
|
+
import type { ButtonProps } from './type.ts'
|
|
10
10
|
import {
|
|
11
11
|
Delete,
|
|
12
12
|
Download,
|
|
@@ -15,45 +15,45 @@ import {
|
|
|
15
15
|
Printer,
|
|
16
16
|
Search,
|
|
17
17
|
Upload
|
|
18
|
-
} from '@element-plus/icons-vue'
|
|
19
|
-
import { computed, useAttrs } from 'vue'
|
|
20
|
-
import { useBemClass } from '../../../hooks'
|
|
18
|
+
} from '@element-plus/icons-vue'
|
|
19
|
+
import { computed, useAttrs } from 'vue'
|
|
20
|
+
import { useBemClass } from '../../../hooks'
|
|
21
21
|
|
|
22
22
|
const props = withDefaults(defineProps<ButtonProps>(), {
|
|
23
23
|
type: ''
|
|
24
|
-
})
|
|
24
|
+
})
|
|
25
25
|
|
|
26
26
|
const emit = defineEmits<{
|
|
27
|
-
(e: 'click', event: MouseEvent): void
|
|
28
|
-
}>()
|
|
29
|
-
|
|
30
|
-
const attrs = useAttrs()
|
|
31
|
-
|
|
32
|
-
const { b } = useBemClass()
|
|
33
|
-
|
|
34
|
-
const obj: Record<string, { btnProps: Partial<ButtonProps
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
27
|
+
(e: 'click', event: MouseEvent): void
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const attrs = useAttrs()
|
|
31
|
+
|
|
32
|
+
const { b } = useBemClass()
|
|
33
|
+
|
|
34
|
+
const obj: Record<string, { btnProps: Partial<ButtonProps>, btnText: string }>
|
|
35
|
+
= {
|
|
36
|
+
add: { btnProps: { icon: Plus, type: 'primary' }, btnText: '新增' },
|
|
37
|
+
edit: { btnProps: { icon: Edit, type: 'primary' }, btnText: '编辑' },
|
|
38
|
+
delete: { btnProps: { icon: Delete, type: 'danger' }, btnText: '删除' },
|
|
39
|
+
search: { btnProps: { icon: Search, type: 'primary' }, btnText: '搜索' },
|
|
40
|
+
reset: { btnProps: { type: undefined }, btnText: '重置' },
|
|
41
|
+
upload: { btnProps: { icon: Upload, type: 'primary' }, btnText: '上传' },
|
|
42
|
+
download: {
|
|
43
|
+
btnProps: { icon: Download, type: 'primary' },
|
|
44
|
+
btnText: '下载'
|
|
45
|
+
},
|
|
46
|
+
print: { btnProps: { icon: Printer, type: 'primary' }, btnText: '打印' }
|
|
47
|
+
}
|
|
48
48
|
|
|
49
49
|
const bindProps = computed(() => {
|
|
50
|
-
const btnProps = obj?.[props.type]?.btnProps || { type: props.type }
|
|
51
|
-
return { ...attrs, ...props, ...btnProps } as Omit<ElButtonProps, 'type'
|
|
52
|
-
})
|
|
50
|
+
const btnProps = obj?.[props.type]?.btnProps || { type: props.type }
|
|
51
|
+
return { ...attrs, ...props, ...btnProps } as Omit<ElButtonProps, 'type'>
|
|
52
|
+
})
|
|
53
53
|
|
|
54
54
|
const btnText = computed(() => {
|
|
55
|
-
return obj[props.type].btnText
|
|
56
|
-
})
|
|
55
|
+
return obj[props.type].btnText
|
|
56
|
+
})
|
|
57
57
|
</script>
|
|
58
58
|
|
|
59
59
|
<style lang="scss" scoped></style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ButtonProps as ElButtonProps } from 'element-plus'
|
|
1
|
+
import type { ButtonProps as ElButtonProps } from 'element-plus'
|
|
2
2
|
|
|
3
3
|
export interface ButtonProps extends Partial<Omit<ElButtonProps, 'type'>> {
|
|
4
4
|
type?:
|
|
@@ -11,5 +11,5 @@ export interface ButtonProps extends Partial<Omit<ElButtonProps, 'type'>> {
|
|
|
11
11
|
| 'download'
|
|
12
12
|
| 'print'
|
|
13
13
|
| ''
|
|
14
|
-
| ElButtonProps['type']
|
|
14
|
+
| ElButtonProps['type']
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Card from './src/card.vue'
|
|
1
|
+
import Card from './src/card.vue'
|
|
2
2
|
|
|
3
|
-
export type CardInstance = InstanceType<typeof Card
|
|
4
|
-
export * from './src/type'
|
|
5
|
-
export default Card
|
|
3
|
+
export type CardInstance = InstanceType<typeof Card>
|
|
4
|
+
export * from './src/type'
|
|
5
|
+
export default Card
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
20
|
<script lang="ts" setup>
|
|
21
|
-
import type { CardProps } from './type'
|
|
22
|
-
import { computed, useSlots } from 'vue'
|
|
23
|
-
import { useBemClass } from '../../../hooks'
|
|
21
|
+
import type { CardProps } from './type'
|
|
22
|
+
import { computed, useSlots } from 'vue'
|
|
23
|
+
import { useBemClass } from '../../../hooks'
|
|
24
24
|
|
|
25
25
|
const props = withDefaults(defineProps<CardProps>(), {
|
|
26
26
|
title: '',
|
|
@@ -31,37 +31,37 @@ const props = withDefaults(defineProps<CardProps>(), {
|
|
|
31
31
|
headerStyle: () => ({}),
|
|
32
32
|
bodyStyle: () => ({}),
|
|
33
33
|
inner: false
|
|
34
|
-
})
|
|
34
|
+
})
|
|
35
35
|
|
|
36
36
|
defineSlots<{
|
|
37
|
-
default: () => void
|
|
38
|
-
title: () => void
|
|
39
|
-
extra: () => void
|
|
40
|
-
footer: () => void
|
|
41
|
-
}>()
|
|
37
|
+
default: () => void
|
|
38
|
+
title: () => void
|
|
39
|
+
extra: () => void
|
|
40
|
+
footer: () => void
|
|
41
|
+
}>()
|
|
42
42
|
|
|
43
|
-
const slot = useSlots()
|
|
44
|
-
const { b } = useBemClass()
|
|
43
|
+
const slot = useSlots()
|
|
44
|
+
const { b } = useBemClass()
|
|
45
45
|
|
|
46
46
|
const getCardClass = computed(() => {
|
|
47
|
-
const arr: string[] = [b('card')]
|
|
47
|
+
const arr: string[] = [b('card')]
|
|
48
48
|
if (props.bordered) {
|
|
49
|
-
arr.push(b('card--bordered'))
|
|
49
|
+
arr.push(b('card--bordered'))
|
|
50
50
|
}
|
|
51
51
|
if (props.inner) {
|
|
52
|
-
arr.push(b('card--inner'))
|
|
52
|
+
arr.push(b('card--inner'))
|
|
53
53
|
}
|
|
54
|
-
arr.push(b(`card--${props.size}`))
|
|
55
|
-
return arr.join(' ')
|
|
56
|
-
})
|
|
54
|
+
arr.push(b(`card--${props.size}`))
|
|
55
|
+
return arr.join(' ')
|
|
56
|
+
})
|
|
57
57
|
|
|
58
58
|
const getHeaderClass = computed(() => {
|
|
59
|
-
const arr: string[] = [b('card-header')]
|
|
59
|
+
const arr: string[] = [b('card-header')]
|
|
60
60
|
if (props.headerBordered) {
|
|
61
|
-
arr.push(b('card-header--bordered'))
|
|
61
|
+
arr.push(b('card-header--bordered'))
|
|
62
62
|
}
|
|
63
|
-
return arr.join(' ')
|
|
64
|
-
})
|
|
63
|
+
return arr.join(' ')
|
|
64
|
+
})
|
|
65
65
|
</script>
|
|
66
66
|
|
|
67
67
|
<style lang="scss" scoped>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { CSSProperties } from 'vue'
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export interface CardProps {
|
|
4
|
-
title?: string
|
|
5
|
-
extra?: string
|
|
6
|
-
bordered?: boolean
|
|
7
|
-
size?: 'small' | 'middle'
|
|
8
|
-
headerBordered?: boolean
|
|
9
|
-
headerStyle?: CSSProperties
|
|
10
|
-
bodyStyle?: CSSProperties
|
|
11
|
-
inner?: boolean
|
|
4
|
+
title?: string
|
|
5
|
+
extra?: string
|
|
6
|
+
bordered?: boolean
|
|
7
|
+
size?: 'small' | 'middle'
|
|
8
|
+
headerBordered?: boolean
|
|
9
|
+
headerStyle?: CSSProperties
|
|
10
|
+
bodyStyle?: CSSProperties
|
|
11
|
+
inner?: boolean // 内嵌模式
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Dialog from './src/dialog.vue'
|
|
1
|
+
import Dialog from './src/dialog.vue'
|
|
2
2
|
|
|
3
|
-
export type DialogInstance = InstanceType<typeof Dialog
|
|
4
|
-
export * from './src/dialog'
|
|
5
|
-
export * from './src/type'
|
|
6
|
-
export default Dialog
|
|
3
|
+
export type DialogInstance = InstanceType<typeof Dialog>
|
|
4
|
+
export * from './src/dialog'
|
|
5
|
+
export * from './src/type'
|
|
6
|
+
export default Dialog
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { DialogInstance } from '../index'
|
|
2
|
-
import ElementPlus from 'element-plus'
|
|
3
|
-
import { createApp, h, ref } from 'vue'
|
|
4
|
-
import GiDialog from './dialog.vue'
|
|
1
|
+
import type { DialogInstance } from '../index'
|
|
2
|
+
import ElementPlus from 'element-plus'
|
|
3
|
+
import { createApp, h, ref } from 'vue'
|
|
4
|
+
import GiDialog from './dialog.vue'
|
|
5
5
|
|
|
6
|
-
export type DialogOptions = Partial<DialogInstance['$props']
|
|
6
|
+
export type DialogOptions = Partial<DialogInstance['$props']>
|
|
7
7
|
|
|
8
8
|
export interface DialogReturnObject {
|
|
9
|
-
close: () => void
|
|
10
|
-
update: (newProps?: Record<string, any>) => void
|
|
9
|
+
close: () => void
|
|
10
|
+
update: (newProps?: Record<string, any>) => void
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const DEF_OPTIONS: DialogOptions = {
|
|
@@ -15,73 +15,73 @@ const DEF_OPTIONS: DialogOptions = {
|
|
|
15
15
|
// center: false,
|
|
16
16
|
// footer: true,
|
|
17
17
|
// closeOnClickModal: true
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
export function createDialog() {
|
|
21
21
|
const Dialog = {
|
|
22
22
|
_context: {},
|
|
23
23
|
// 核心创建方法
|
|
24
24
|
create(options: DialogOptions): DialogReturnObject {
|
|
25
|
-
const mergedOptions = { ...DEF_OPTIONS, ...options }
|
|
25
|
+
const mergedOptions = { ...DEF_OPTIONS, ...options }
|
|
26
26
|
// 创建容器
|
|
27
|
-
const container = document.createElement('div')
|
|
28
|
-
document.body.appendChild(container)
|
|
27
|
+
const container = document.createElement('div')
|
|
28
|
+
document.body.appendChild(container)
|
|
29
29
|
|
|
30
30
|
// 状态管理
|
|
31
|
-
const visible = ref(true)
|
|
32
|
-
const dialogOptions = ref(mergedOptions || {})
|
|
31
|
+
const visible = ref(true)
|
|
32
|
+
const dialogOptions = ref(mergedOptions || {})
|
|
33
33
|
|
|
34
34
|
// 创建弹窗应用
|
|
35
35
|
const dialogApp = createApp({
|
|
36
36
|
setup() {
|
|
37
37
|
// 关闭处理
|
|
38
38
|
const closed = () => {
|
|
39
|
-
dialogApp.unmount()
|
|
40
|
-
container.remove()
|
|
41
|
-
}
|
|
39
|
+
dialogApp.unmount()
|
|
40
|
+
container.remove()
|
|
41
|
+
}
|
|
42
42
|
|
|
43
43
|
return () =>
|
|
44
44
|
h(GiDialog, {
|
|
45
45
|
...dialogOptions.value,
|
|
46
|
-
modelValue: visible.value,
|
|
46
|
+
'modelValue': visible.value,
|
|
47
47
|
'onUpdate:modelValue': (val: boolean) => (visible.value = val),
|
|
48
|
-
onClosed: () => closed()
|
|
49
|
-
})
|
|
48
|
+
'onClosed': () => closed()
|
|
49
|
+
})
|
|
50
50
|
}
|
|
51
|
-
})
|
|
51
|
+
})
|
|
52
52
|
|
|
53
|
-
dialogApp.use(ElementPlus)
|
|
53
|
+
dialogApp.use(ElementPlus)
|
|
54
54
|
|
|
55
55
|
// 继承主应用的上下文
|
|
56
|
-
Object.assign(dialogApp._context, Dialog._context)
|
|
56
|
+
Object.assign(dialogApp._context, Dialog._context)
|
|
57
57
|
|
|
58
58
|
// 挂载
|
|
59
|
-
dialogApp.mount(container)
|
|
59
|
+
dialogApp.mount(container)
|
|
60
60
|
|
|
61
61
|
return {
|
|
62
62
|
/** 关闭对话框 */
|
|
63
63
|
close: () => {
|
|
64
|
-
visible.value = false
|
|
64
|
+
visible.value = false
|
|
65
65
|
setTimeout(() => {
|
|
66
|
-
dialogApp.unmount()
|
|
67
|
-
container.remove()
|
|
68
|
-
}, 300)
|
|
66
|
+
dialogApp.unmount()
|
|
67
|
+
container.remove()
|
|
68
|
+
}, 300)
|
|
69
69
|
},
|
|
70
70
|
/** 更新对话框 */
|
|
71
71
|
update: (newProps?: Record<string, any>) => {
|
|
72
|
-
dialogOptions.value = { ...dialogOptions.value, ...newProps }
|
|
72
|
+
dialogOptions.value = { ...dialogOptions.value, ...newProps }
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
},
|
|
76
76
|
|
|
77
77
|
/** 对话框-打开 */
|
|
78
78
|
open(options: DialogOptions) {
|
|
79
|
-
return this.create(options)
|
|
79
|
+
return this.create(options)
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
return Dialog
|
|
83
|
+
return Dialog
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// 默认导出实例
|
|
87
|
-
export const Dialog = createDialog()
|
|
87
|
+
export const Dialog = createDialog()
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
<slot name="footer">
|
|
19
19
|
<template v-if="typeof props.footer === 'boolean'">
|
|
20
20
|
<el-space :size="10">
|
|
21
|
-
<el-button v-bind="props.cancelButtonProps" @click="handleCancel">
|
|
21
|
+
<el-button v-bind="props.cancelButtonProps" @click="handleCancel">
|
|
22
|
+
{{
|
|
22
23
|
props.cancelText
|
|
23
|
-
}}
|
|
24
|
+
}}
|
|
25
|
+
</el-button>
|
|
24
26
|
<el-button
|
|
25
27
|
type="primary"
|
|
26
28
|
v-bind="props.okButtonProps"
|
|
@@ -40,15 +42,15 @@
|
|
|
40
42
|
</template>
|
|
41
43
|
|
|
42
44
|
<script lang="ts" setup>
|
|
43
|
-
import type { VNode } from 'vue'
|
|
44
|
-
import type { DialogProps } from './type'
|
|
45
|
-
import { computed, defineProps, defineSlots, ref } from 'vue'
|
|
46
|
-
import { useBemClass } from '../../../hooks'
|
|
45
|
+
import type { VNode } from 'vue'
|
|
46
|
+
import type { DialogProps } from './type'
|
|
47
|
+
import { computed, defineProps, defineSlots, ref } from 'vue'
|
|
48
|
+
import { useBemClass } from '../../../hooks'
|
|
47
49
|
|
|
48
50
|
const visible = defineModel('modelValue', {
|
|
49
51
|
type: Boolean,
|
|
50
52
|
default: false
|
|
51
|
-
})
|
|
53
|
+
})
|
|
52
54
|
|
|
53
55
|
const props = withDefaults(defineProps<DialogProps>(), {
|
|
54
56
|
closeOnClickModal: true,
|
|
@@ -58,23 +60,23 @@ const props = withDefaults(defineProps<DialogProps>(), {
|
|
|
58
60
|
cancelText: '取消',
|
|
59
61
|
width: 'calc(100% - 20px)',
|
|
60
62
|
alignCenter: true
|
|
61
|
-
})
|
|
63
|
+
})
|
|
62
64
|
|
|
63
65
|
defineSlots<{
|
|
64
|
-
title: () => VNode
|
|
65
|
-
footer: () => VNode
|
|
66
|
-
default: () => VNode
|
|
67
|
-
}>()
|
|
66
|
+
title: () => VNode
|
|
67
|
+
footer: () => VNode
|
|
68
|
+
default: () => VNode
|
|
69
|
+
}>()
|
|
68
70
|
|
|
69
|
-
const { b } = useBemClass()
|
|
71
|
+
const { b } = useBemClass()
|
|
70
72
|
|
|
71
73
|
const getClass = computed(() => {
|
|
72
|
-
const arr: string[] = [b('dialog')]
|
|
74
|
+
const arr: string[] = [b('dialog')]
|
|
73
75
|
if (props.simple) {
|
|
74
|
-
arr.push(b('dialog--simple'))
|
|
76
|
+
arr.push(b('dialog--simple'))
|
|
75
77
|
}
|
|
76
|
-
return arr.join(' ')
|
|
77
|
-
})
|
|
78
|
+
return arr.join(' ')
|
|
79
|
+
})
|
|
78
80
|
|
|
79
81
|
const dialogProps = computed(() => {
|
|
80
82
|
return {
|
|
@@ -89,34 +91,34 @@ const dialogProps = computed(() => {
|
|
|
89
91
|
onBeforeOk: undefined,
|
|
90
92
|
onCancel: undefined,
|
|
91
93
|
simple: undefined
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
+
}
|
|
95
|
+
})
|
|
94
96
|
|
|
95
|
-
const okLoading = ref(false)
|
|
97
|
+
const okLoading = ref(false)
|
|
96
98
|
|
|
97
99
|
const handleCancel = () => {
|
|
98
|
-
props.onCancel?.()
|
|
99
|
-
visible.value = false
|
|
100
|
-
}
|
|
100
|
+
props.onCancel?.()
|
|
101
|
+
visible.value = false
|
|
102
|
+
}
|
|
101
103
|
|
|
102
104
|
const handleOk = async () => {
|
|
103
105
|
if (props.onBeforeOk) {
|
|
104
106
|
try {
|
|
105
|
-
okLoading.value = true
|
|
106
|
-
const flag = await props.onBeforeOk()
|
|
107
|
-
okLoading.value = false
|
|
107
|
+
okLoading.value = true
|
|
108
|
+
const flag = await props.onBeforeOk()
|
|
109
|
+
okLoading.value = false
|
|
108
110
|
if (flag) {
|
|
109
|
-
visible.value = false
|
|
111
|
+
visible.value = false
|
|
110
112
|
}
|
|
111
113
|
} catch (error) {
|
|
112
|
-
console.error('error', error)
|
|
113
|
-
okLoading.value = false
|
|
114
|
+
console.error('error', error)
|
|
115
|
+
okLoading.value = false
|
|
114
116
|
}
|
|
115
117
|
} else {
|
|
116
|
-
props.onOk?.()
|
|
117
|
-
visible.value = false
|
|
118
|
+
props.onOk?.()
|
|
119
|
+
visible.value = false
|
|
118
120
|
}
|
|
119
|
-
}
|
|
121
|
+
}
|
|
120
122
|
</script>
|
|
121
123
|
|
|
122
124
|
<style lang="scss" scoped></style>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { ButtonProps, DialogProps as ElDialogProps } from 'element-plus'
|
|
2
|
-
import type { CSSProperties, VNode } from 'vue'
|
|
1
|
+
import type { ButtonProps, DialogProps as ElDialogProps } from 'element-plus'
|
|
2
|
+
import type { CSSProperties, VNode } from 'vue'
|
|
3
3
|
|
|
4
4
|
export interface DialogProps extends Partial<ElDialogProps> {
|
|
5
|
-
content?: string | (() => VNode)
|
|
6
|
-
footer?: boolean | (() => VNode)
|
|
7
|
-
okText?: string
|
|
8
|
-
cancelText?: string
|
|
9
|
-
okButtonProps?: Partial<ButtonProps
|
|
10
|
-
cancelButtonProps?: Partial<ButtonProps
|
|
11
|
-
style?: CSSProperties
|
|
12
|
-
simple?: boolean
|
|
13
|
-
onOk?: () => void
|
|
14
|
-
onBeforeOk?: () => Promise<boolean
|
|
15
|
-
onCancel?: () => void
|
|
5
|
+
content?: string | (() => VNode)
|
|
6
|
+
footer?: boolean | (() => VNode)
|
|
7
|
+
okText?: string
|
|
8
|
+
cancelText?: string
|
|
9
|
+
okButtonProps?: Partial<ButtonProps>
|
|
10
|
+
cancelButtonProps?: Partial<ButtonProps>
|
|
11
|
+
style?: CSSProperties
|
|
12
|
+
simple?: boolean // 简单模式
|
|
13
|
+
onOk?: () => void
|
|
14
|
+
onBeforeOk?: () => Promise<boolean>
|
|
15
|
+
onCancel?: () => void
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import EditTable from './src/edit-table.vue'
|
|
1
|
+
import EditTable from './src/edit-table.vue'
|
|
2
2
|
|
|
3
|
-
export type EditTableInstance = InstanceType<typeof EditTable
|
|
4
|
-
export * from './src/type'
|
|
5
|
-
export default EditTable
|
|
3
|
+
export type EditTableInstance = InstanceType<typeof EditTable>
|
|
4
|
+
export * from './src/type'
|
|
5
|
+
export default EditTable
|