@xizs/nuxt-antui 0.0.1 → 0.0.3
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/app/components/global/Form.tsx +29 -7
- package/app/components/global/FormTable.tsx +22 -9
- package/app/components/layout/Base.vue +1 -1
- package/app/composables/drawer.ts +23 -9
- package/app/composables/form.ts +77 -1
- package/app/composables/modal.ts +57 -34
- package/app/composables/table.ts +14 -43
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AForm, AFormItem, AInput, ASelect,AInputNumber, LineOutlined, ASwitch, ATextarea } from "#components"
|
|
1
|
+
import { AForm, AFormItem, AInput, ASelect,AInputNumber, LineOutlined, ASwitch, ATextarea, ARadio, ARadioGroup, AButton } from "#components"
|
|
2
2
|
|
|
3
3
|
export type FormItemType = {
|
|
4
4
|
label:string,
|
|
@@ -16,10 +16,14 @@ export type FormPropsType = {
|
|
|
16
16
|
showSubmit?:boolean
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const FormComs
|
|
19
|
+
const FormComs = {
|
|
20
20
|
input:(form:any,item:FormItemType)=>{
|
|
21
21
|
return <AInput v-model:value={form[item.key]}></AInput>
|
|
22
22
|
},
|
|
23
|
+
button:(form:any,item:FormItemType)=>{
|
|
24
|
+
console.log(item.bind)
|
|
25
|
+
return <AButton {...item.bind}>{ item.bind.content}</AButton>
|
|
26
|
+
},
|
|
23
27
|
textarea:(form:any,item:FormItemType)=>{
|
|
24
28
|
return <ATextarea v-model:value={form[item.key]}></ATextarea>
|
|
25
29
|
},
|
|
@@ -41,6 +45,12 @@ const FormComs = {
|
|
|
41
45
|
},
|
|
42
46
|
switch:(form:any,item:FormItemType)=>{
|
|
43
47
|
return <ASwitch v-model:checked={form[item.key]} {...item.bind}></ASwitch>
|
|
48
|
+
},
|
|
49
|
+
radio: (form: any, item: FormItemType) => {
|
|
50
|
+
return <ARadioGroup v-model:value={form[item.key]} {...item.bind}></ARadioGroup>
|
|
51
|
+
},
|
|
52
|
+
uploadImg: (form: any, item: FormItemType) => {
|
|
53
|
+
return <UploadImg v-model:value={form[item.key]} {...item.bind}></UploadImg>
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
56
|
|
|
@@ -62,13 +72,18 @@ export default defineComponent({
|
|
|
62
72
|
type:Boolean,
|
|
63
73
|
default:true
|
|
64
74
|
},
|
|
75
|
+
defaultFormData: {
|
|
76
|
+
type: Object,
|
|
77
|
+
default: () => ({})
|
|
78
|
+
}
|
|
65
79
|
},
|
|
66
80
|
setup(props,{expose}){
|
|
67
81
|
|
|
68
82
|
let thisRef = ref(null)
|
|
69
|
-
let formData = ref(
|
|
83
|
+
let formData = ref(props.defaultFormData)
|
|
70
84
|
let rules = ref({})
|
|
71
|
-
props.form.forEach(item=>{
|
|
85
|
+
ADParse(props.form,formData.value).forEach(item=>{
|
|
86
|
+
if(item.key==null) return
|
|
72
87
|
if(Array.isArray(item.key)){
|
|
73
88
|
item.key.forEach(key=>{
|
|
74
89
|
formData.value[key] = item.value??''
|
|
@@ -112,9 +127,16 @@ export default defineComponent({
|
|
|
112
127
|
return ()=><AForm ref={thisRef} model={formData.value} rules={rules.value} label-col={{ span: 6 }} wrapper-col={{ span: 16 }}>
|
|
113
128
|
{/* {JSON.stringify(formData.value)} */}
|
|
114
129
|
{
|
|
115
|
-
props.form.map(item=>{
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
ADParse(props.form, formData.value).map(item => {
|
|
131
|
+
if (item.label == null) {
|
|
132
|
+
return typeof item.is === 'function'? item.is(formData.value) :
|
|
133
|
+
FormComs[item.is](formData.value,item)
|
|
134
|
+
}
|
|
135
|
+
return <AFormItem label={item.label} key={item.key} name={item.key} {...item.bind} class={{'hidden':item.show===false}}>
|
|
136
|
+
{
|
|
137
|
+
typeof item.is === 'function'? item.is(formData.value) :
|
|
138
|
+
FormComs[item.is](formData.value,item)
|
|
139
|
+
}
|
|
118
140
|
</AFormItem>
|
|
119
141
|
})
|
|
120
142
|
}
|
|
@@ -46,10 +46,10 @@ let dateRange = defineComponent({
|
|
|
46
46
|
|
|
47
47
|
const FormItems = {
|
|
48
48
|
input:(form:any,item:TableFormItemType)=>{
|
|
49
|
-
return <AInput size="middle" v-model:value={form[item.key]} placeholder={
|
|
49
|
+
return <AInput size="middle" v-model:value={form[item.key]} placeholder={`请输入 ${item.label}`}></AInput>
|
|
50
50
|
},
|
|
51
51
|
select:(form:any,item:TableFormItemType)=>{
|
|
52
|
-
return <ASelect allowClear class="min-w-[150px]" v-model:value={form[item.key]} options={item.bind
|
|
52
|
+
return <ASelect allowClear class="min-w-[150px]" v-model:value={form[item.key]} options={item.bind?.options} placeholder={`please select ${item.label}`}></ASelect>
|
|
53
53
|
},
|
|
54
54
|
dateRange:(form:any,item:TableFormItemType)=>{
|
|
55
55
|
|
|
@@ -58,7 +58,7 @@ const FormItems = {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export type TablePropsType = {
|
|
61
|
-
form
|
|
61
|
+
form?: TableFormItemType[]
|
|
62
62
|
action?: {
|
|
63
63
|
search?: boolean
|
|
64
64
|
reset?: boolean
|
|
@@ -70,6 +70,9 @@ export type TablePropsType = {
|
|
|
70
70
|
enableSelection?: boolean
|
|
71
71
|
columns: TableColumnType[]
|
|
72
72
|
data: () => any[]
|
|
73
|
+
},
|
|
74
|
+
footerOptions?: {
|
|
75
|
+
show: boolean
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
@@ -83,7 +86,7 @@ export type AttributeType = {
|
|
|
83
86
|
export const FormTableProps = {
|
|
84
87
|
form: {
|
|
85
88
|
type: Array as () => TableFormItemType[],
|
|
86
|
-
required:
|
|
89
|
+
required: false
|
|
87
90
|
},
|
|
88
91
|
formOptions:{
|
|
89
92
|
type:Object as () => {
|
|
@@ -116,13 +119,21 @@ export const FormTableProps = {
|
|
|
116
119
|
rowKey:(row:any)=>any
|
|
117
120
|
})
|
|
118
121
|
},
|
|
122
|
+
footerOptions: {
|
|
123
|
+
type: Object as () => {
|
|
124
|
+
show: boolean,
|
|
125
|
+
},
|
|
126
|
+
default: () => ({
|
|
127
|
+
show: true,
|
|
128
|
+
})
|
|
129
|
+
},
|
|
119
130
|
attribute:{
|
|
120
131
|
type:Object as ()=> AttributeType
|
|
121
132
|
},
|
|
122
133
|
control:{
|
|
123
134
|
type:Object,
|
|
124
135
|
required:true
|
|
125
|
-
}
|
|
136
|
+
},
|
|
126
137
|
}
|
|
127
138
|
|
|
128
139
|
export default defineComponent({
|
|
@@ -131,9 +142,10 @@ export default defineComponent({
|
|
|
131
142
|
setup(props) {
|
|
132
143
|
|
|
133
144
|
const form = ref({})
|
|
134
|
-
props.form
|
|
145
|
+
props.form?.forEach((item) => {
|
|
135
146
|
form.value[item.key] = item.value?? ''
|
|
136
147
|
})
|
|
148
|
+
const metaForm = JSON.parse(JSON.stringify(form.value))
|
|
137
149
|
let pagination =reactive({
|
|
138
150
|
page:1,
|
|
139
151
|
pageSize:20,
|
|
@@ -160,6 +172,7 @@ export default defineComponent({
|
|
|
160
172
|
pagination.pageSize = res.meta.pagination.per_page
|
|
161
173
|
pagination.page = res.meta.pagination.current_page
|
|
162
174
|
console.log(res)
|
|
175
|
+
props.attribute.tableData = res.list
|
|
163
176
|
return res.list
|
|
164
177
|
},[])
|
|
165
178
|
|
|
@@ -190,7 +203,7 @@ export default defineComponent({
|
|
|
190
203
|
})}
|
|
191
204
|
<div class="flex gap-2">
|
|
192
205
|
{props.formOptions.search && <AButton type="primary" onClick={()=>tableData.load()}>搜索</AButton>}
|
|
193
|
-
|
|
206
|
+
{props.formOptions.reset && <AButton onClick={() => patch(metaForm,form.value)}>重置</AButton>}
|
|
194
207
|
{props.formOptions.export && <AButton type="primary">导出</AButton>}
|
|
195
208
|
</div>
|
|
196
209
|
</AForm>}
|
|
@@ -238,7 +251,7 @@ export default defineComponent({
|
|
|
238
251
|
dataSource={tableData.value}
|
|
239
252
|
/>
|
|
240
253
|
</div>
|
|
241
|
-
|
|
254
|
+
{props.footerOptions.show && <div class="mt-3 flex items-center justify-between">
|
|
242
255
|
<div>
|
|
243
256
|
{ props.table.enableSelection && (`选中项: ${props.attribute.selectKeys.length}`)}
|
|
244
257
|
</div>
|
|
@@ -263,7 +276,7 @@ export default defineComponent({
|
|
|
263
276
|
<AButton icon={h(RedoOutlined)} loading={tableData.loading} onClick={tableData.load} />
|
|
264
277
|
</div>
|
|
265
278
|
|
|
266
|
-
</div>
|
|
279
|
+
</div>}
|
|
267
280
|
|
|
268
281
|
</div>
|
|
269
282
|
)
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
<div class=" flex items-center">
|
|
31
31
|
<div >
|
|
32
32
|
<a-dropdown >
|
|
33
|
-
<div class="h-[30px] leading-[30px]">{{ useAdmin().value?.username }}</div>
|
|
33
|
+
<div class="h-[30px] leading-[30px]">{{ useAdmin().value?.username ?? 'Admin'}}</div>
|
|
34
34
|
<template #overlay>
|
|
35
35
|
<a-menu>
|
|
36
36
|
<a-menu-item @click="()=>singOut()">
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import { createVNode, render } from "vue"
|
|
2
2
|
|
|
3
|
-
export const Drawer = (el)=>{
|
|
3
|
+
export const Drawer = (el) => {
|
|
4
|
+
let container = document.createDocumentFragment()
|
|
5
|
+
let control = { close: () => { } }
|
|
4
6
|
|
|
5
7
|
let com = defineComponent({
|
|
6
|
-
setup(){
|
|
7
|
-
let open=ref(true)
|
|
8
|
+
setup() {
|
|
9
|
+
let open = ref(true)
|
|
8
10
|
console.log('aaaaaa')
|
|
9
|
-
|
|
11
|
+
control.close = () => {
|
|
12
|
+
open.value = false
|
|
13
|
+
}
|
|
14
|
+
return () => h(el, {
|
|
10
15
|
open: open.value, // 等价于 v-model:open
|
|
11
16
|
'onUpdate:open': (val: boolean) => {
|
|
12
17
|
open.value = val
|
|
13
|
-
console.log(val,open.value)
|
|
14
|
-
|
|
18
|
+
console.log(val, open.value)
|
|
19
|
+
if (!val) {
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
render(null, container) // 卸载组件
|
|
22
|
+
if (container.parentNode) {
|
|
23
|
+
container.parentNode.removeChild(container) // 移除 DOM
|
|
24
|
+
}
|
|
25
|
+
}, 1000);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
15
28
|
})
|
|
16
29
|
}
|
|
17
30
|
})
|
|
18
31
|
|
|
19
32
|
|
|
20
|
-
let container = document.createDocumentFragment()
|
|
21
33
|
const vnode = h(com)
|
|
22
34
|
vnode.appContext = useNuxtApp().vueApp._context
|
|
23
|
-
render(vnode,container)
|
|
35
|
+
render(vnode, container)
|
|
24
36
|
document.body.appendChild(container)
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
return control
|
|
39
|
+
}
|
|
40
|
+
|
package/app/composables/form.ts
CHANGED
|
@@ -1 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
// import type { FormItemType } from "../components/global/Form";
|
|
2
|
+
// import { AForm, AFormItem, AInput, ASelect, AInputNumber, LineOutlined, ASwitch, ATextarea, ARadio } from "#components"
|
|
3
|
+
|
|
4
|
+
// export const FormComs = {
|
|
5
|
+
// input: (form: any, item: FormItemType) =>
|
|
6
|
+
// h(AInput, {
|
|
7
|
+
// value: form[item.key as string],
|
|
8
|
+
// 'onUpdate:value': (val: any) => (form[item.key as string] = val)
|
|
9
|
+
// }),
|
|
10
|
+
|
|
11
|
+
// textarea: (form: any, item: FormItemType) =>
|
|
12
|
+
// h(ATextarea, {
|
|
13
|
+
// value: form[item.key as string],
|
|
14
|
+
// 'onUpdate:value': (val: any) => (form[item.key as string] = val)
|
|
15
|
+
// }),
|
|
16
|
+
|
|
17
|
+
// inputNumber: (form: any, item: FormItemType) =>
|
|
18
|
+
// h(AInputNumber, {
|
|
19
|
+
// ...item.bind,
|
|
20
|
+
// value: form[item.key as string],
|
|
21
|
+
// 'onUpdate:value': (val: any) => (form[item.key as string] = val)
|
|
22
|
+
// }),
|
|
23
|
+
|
|
24
|
+
// inputNumberRange: (form: any, item: FormItemType) =>
|
|
25
|
+
// h(
|
|
26
|
+
// 'div',
|
|
27
|
+
// { class: 'flex items-center gap-2' },
|
|
28
|
+
// [
|
|
29
|
+
// h(AInputNumber, {
|
|
30
|
+
// class: 'flex-1',
|
|
31
|
+
// ...item.bind[0],
|
|
32
|
+
// value: form[item.key[0] as string],
|
|
33
|
+
// 'onUpdate:value': (val: any) => (form[item.key[0] as string] = val)
|
|
34
|
+
// }),
|
|
35
|
+
// h(LineOutlined),
|
|
36
|
+
// h(AInputNumber, {
|
|
37
|
+
// class: 'flex-1',
|
|
38
|
+
// ...item.bind[1],
|
|
39
|
+
// value: form[item.key[1] as string],
|
|
40
|
+
// 'onUpdate:value': (val: any) => (form[item.key[1] as string] = val)
|
|
41
|
+
// })
|
|
42
|
+
// ]
|
|
43
|
+
// ),
|
|
44
|
+
|
|
45
|
+
// select: (form: any, item: FormItemType) =>
|
|
46
|
+
// h(ASelect, {
|
|
47
|
+
// value: form[item.key as string],
|
|
48
|
+
// options: item.bind.options,
|
|
49
|
+
// 'onUpdate:value': (val: any) => (form[item.key as string] = val)
|
|
50
|
+
// }),
|
|
51
|
+
|
|
52
|
+
// countrySelect: (form: any, item: FormItemType) =>
|
|
53
|
+
// h(ASelect, {
|
|
54
|
+
// value: form[item.key as string],
|
|
55
|
+
// options: Const.CountrySelectList(),
|
|
56
|
+
// 'onUpdate:value': (val: any) => (form[item.key as string] = val)
|
|
57
|
+
// }),
|
|
58
|
+
|
|
59
|
+
// switch: (form: any, item: FormItemType) =>
|
|
60
|
+
// h(ASwitch, {
|
|
61
|
+
// ...item.bind,
|
|
62
|
+
// checked: form[item.key as string],
|
|
63
|
+
// 'onUpdate:checked': (val: any) => (form[item.key as string] = val)
|
|
64
|
+
// }),
|
|
65
|
+
|
|
66
|
+
// radio: (form: any, item: FormItemType) =>
|
|
67
|
+
// h(ARadio, {
|
|
68
|
+
// ...item.bind,
|
|
69
|
+
// checked: form[item.key as string],
|
|
70
|
+
// 'onUpdate:checked': (val: any) => (form[item.key as string] = val)
|
|
71
|
+
// }),
|
|
72
|
+
|
|
73
|
+
// // upload: (form: any, item: FormItemType) =>
|
|
74
|
+
// // h(UploadImg, {
|
|
75
|
+
// // ...item.bind
|
|
76
|
+
// // })
|
|
77
|
+
// }
|
package/app/composables/modal.ts
CHANGED
|
@@ -2,36 +2,36 @@ import { createVNode, render } from "vue"
|
|
|
2
2
|
import Form from "../components/global/Form"
|
|
3
3
|
import { AModal } from "#components"
|
|
4
4
|
|
|
5
|
-
export const NormalModal = (el)=>{
|
|
6
|
-
let control = {close:()=>{}}
|
|
5
|
+
export const NormalModal = (el) => {
|
|
6
|
+
let control = { close: () => { } }
|
|
7
7
|
let container = document.createDocumentFragment()
|
|
8
8
|
|
|
9
9
|
let com = defineComponent({
|
|
10
|
-
setup(){
|
|
11
|
-
let open=ref(true)
|
|
12
|
-
control.close = ()=>{
|
|
10
|
+
setup() {
|
|
11
|
+
let open = ref(true)
|
|
12
|
+
control.close = () => {
|
|
13
13
|
open.value = false
|
|
14
14
|
}
|
|
15
|
-
return ()=> h(el,{
|
|
15
|
+
return () => h(el, {
|
|
16
16
|
open: open.value, // 等价于 v-model:open
|
|
17
17
|
'onUpdate:open': (val: boolean) => {
|
|
18
18
|
open.value = val
|
|
19
|
-
if(!val){
|
|
19
|
+
if (!val) {
|
|
20
20
|
setTimeout(() => {
|
|
21
21
|
render(null, container) // 卸载组件
|
|
22
22
|
if (container.parentNode) {
|
|
23
|
-
|
|
23
|
+
container.parentNode.removeChild(container) // 移除 DOM
|
|
24
24
|
}
|
|
25
25
|
}, 1000);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
27
|
+
},
|
|
28
28
|
})
|
|
29
29
|
}
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
const vnode = h(com)
|
|
33
33
|
vnode.appContext = useNuxtApp().vueApp._context
|
|
34
|
-
render(vnode,container)
|
|
34
|
+
render(vnode, container)
|
|
35
35
|
document.body.appendChild(container)
|
|
36
36
|
|
|
37
37
|
return control
|
|
@@ -41,19 +41,19 @@ export const NormalModal = (el)=>{
|
|
|
41
41
|
// export Modal.Normal = NormalModal
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
type FormModalParamsType= {
|
|
45
|
-
title:string,
|
|
46
|
-
form:{
|
|
47
|
-
label:string,
|
|
48
|
-
key:string,
|
|
49
|
-
is:string
|
|
44
|
+
type FormModalParamsType = {
|
|
45
|
+
title: string,
|
|
46
|
+
form: {
|
|
47
|
+
label: string,
|
|
48
|
+
key: string,
|
|
49
|
+
is: string
|
|
50
50
|
}[],
|
|
51
|
-
submit:()=>void
|
|
51
|
+
submit: () => void
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export const FormModal = (params:FormModalParamsType)=>{
|
|
54
|
+
export const FormModal = (params: FormModalParamsType) => {
|
|
55
55
|
|
|
56
|
-
let submit:()=>void
|
|
56
|
+
let submit: () => void
|
|
57
57
|
|
|
58
58
|
// let control = NormalModal(h(AModal,{
|
|
59
59
|
// title: params.title,
|
|
@@ -72,7 +72,7 @@ export const FormModal = (params:FormModalParamsType)=>{
|
|
|
72
72
|
// submit = formRef.value.submit
|
|
73
73
|
// loading = formRef.value.loading
|
|
74
74
|
// })
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
// return ()=>h(Form,{
|
|
77
77
|
// ref: formRef,
|
|
78
78
|
// form: params.form,
|
|
@@ -83,37 +83,39 @@ export const FormModal = (params:FormModalParamsType)=>{
|
|
|
83
83
|
// }))))
|
|
84
84
|
|
|
85
85
|
let control = NormalModal(h(defineComponent({
|
|
86
|
-
setup(){
|
|
86
|
+
setup() {
|
|
87
87
|
let formRef = ref(null)
|
|
88
|
-
let loading =ref(false)
|
|
89
|
-
|
|
90
|
-
onMounted(()=>{
|
|
91
|
-
submit =
|
|
88
|
+
let loading = ref(false)
|
|
89
|
+
|
|
90
|
+
onMounted(() => {
|
|
91
|
+
submit = async () => {
|
|
92
92
|
loading.value = true
|
|
93
|
-
try{
|
|
93
|
+
try {
|
|
94
94
|
await formRef.value.submit()
|
|
95
|
-
}finally{
|
|
95
|
+
} finally {
|
|
96
96
|
|
|
97
97
|
loading.value = false
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
// loading = formRef.value.loading
|
|
101
101
|
})
|
|
102
|
-
|
|
103
|
-
return ()=>h(AModal,{
|
|
102
|
+
|
|
103
|
+
return () => h(AModal, {
|
|
104
104
|
title: params.title,
|
|
105
|
+
width: params.width,
|
|
105
106
|
okText: '提交',
|
|
106
107
|
cancelText: '取消',
|
|
107
108
|
confirmLoading: loading.value,
|
|
108
|
-
onOk: async ()=>{
|
|
109
|
+
onOk: async () => {
|
|
109
110
|
await submit()
|
|
110
111
|
control.close()
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
},h(Form,{
|
|
113
|
+
|
|
114
|
+
}, h(Form, {
|
|
114
115
|
ref: formRef,
|
|
115
116
|
form: params.form,
|
|
116
|
-
|
|
117
|
+
defaultFormData: params.defaultFormData,
|
|
118
|
+
submit: params.submit,
|
|
117
119
|
showSubmit: false
|
|
118
120
|
}))
|
|
119
121
|
}
|
|
@@ -123,4 +125,25 @@ export const FormModal = (params:FormModalParamsType)=>{
|
|
|
123
125
|
export const MModal = {
|
|
124
126
|
Normal: NormalModal,
|
|
125
127
|
Form: FormModal
|
|
126
|
-
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const Confirm = {
|
|
131
|
+
delete: () => {
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
Modal.confirm({
|
|
134
|
+
title: '确认删除',
|
|
135
|
+
content: '确认删除该条数据吗?',
|
|
136
|
+
okText: '确定',
|
|
137
|
+
cancelText: '取消',
|
|
138
|
+
onOk: () => {
|
|
139
|
+
resolve(true)
|
|
140
|
+
},
|
|
141
|
+
onCancel: () => {
|
|
142
|
+
reject()
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
package/app/composables/table.ts
CHANGED
|
@@ -1,63 +1,34 @@
|
|
|
1
|
-
import { ACard, ADropdown, AMenu, EllipsisOutlined } from "#components";
|
|
1
|
+
import { ABadge, ACard, ADropdown, AMenu, ATag, EllipsisOutlined } from "#components";
|
|
2
2
|
import type { TablePropsType } from "../components/global/FormTable";
|
|
3
|
-
import
|
|
3
|
+
import FormTableCom from "../components/global/FormTable";
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
export const FormTable = (props:TablePropsType)=>{
|
|
6
|
+
export const FormTable = (props: TablePropsType) => {
|
|
7
7
|
|
|
8
8
|
const attribute = reactive({
|
|
9
|
-
selectItems:[],
|
|
10
|
-
selectKeys:[],
|
|
11
|
-
page:1,
|
|
12
|
-
pageSize:10
|
|
9
|
+
selectItems: [],
|
|
10
|
+
selectKeys: [],
|
|
11
|
+
page: 1,
|
|
12
|
+
pageSize: 10
|
|
13
13
|
})
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
const control = {
|
|
16
|
-
refresh:()=>{}
|
|
16
|
+
refresh: () => { }
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
|
-
com:h(FormTableCom,{...props,attribute,control}),
|
|
20
|
+
com: h(FormTableCom, { ...props, attribute, control }),
|
|
21
21
|
attribute,
|
|
22
22
|
control
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const TablePage = (props:TablePropsType)=>{
|
|
27
|
-
let TableParams =
|
|
26
|
+
export const TablePage = (props: TablePropsType) => {
|
|
27
|
+
let TableParams = FormTable(props)
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
30
|
...TableParams,
|
|
31
|
-
com: h(ACard,{class:"absolute top-0 left-0 right-0 bottom-0 h-full",bodyStyle:"height:100%"},TableParams.com)
|
|
32
|
-
|
|
31
|
+
com: h(ACard, { class: "absolute top-0 left-0 right-0 bottom-0 h-full", bodyStyle: "height:100%" }, TableParams.com)
|
|
32
|
+
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
export const TableCell = {
|
|
37
|
-
Dropdown:(params:{label:string,icon:string,onClick:()=>void}[])=>{
|
|
38
|
-
// return h(EllipsisOutlined,{class:"mr-2"},{default:()=>{
|
|
39
|
-
// return h()
|
|
40
|
-
// }})
|
|
41
|
-
|
|
42
|
-
return h('div',{style:{'min-width':'50px'}},h(ADropdown,{},{
|
|
43
|
-
default:()=>{
|
|
44
|
-
return h(EllipsisOutlined,{class:"mr-2"})
|
|
45
|
-
},
|
|
46
|
-
overlay:()=>{
|
|
47
|
-
return h(AMenu,{items:params.map(item=>{
|
|
48
|
-
return {
|
|
49
|
-
label:item.label,
|
|
50
|
-
icon:()=>item.icon,
|
|
51
|
-
onClick:item.onClick
|
|
52
|
-
}
|
|
53
|
-
})})
|
|
54
|
-
}
|
|
55
|
-
}))
|
|
56
|
-
},
|
|
57
|
-
Tenant:(params:{name:string,id:string})=>{
|
|
58
|
-
return h('div',{class:"flex flex-col"},[
|
|
59
|
-
h('span',{class:"mr-2"},params.name),
|
|
60
|
-
h('span',{class:"mr-2 whitespace-nowrap"},`ID: ${params.id}`)
|
|
61
|
-
])
|
|
62
|
-
},
|
|
63
|
-
}
|