@xizs/nuxt-antui 0.0.5 → 0.0.7
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.
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
import { defineComponent, ref } from 'vue'
|
|
1
|
+
import { defineComponent, h, ref } from 'vue'
|
|
2
2
|
import { AForm, AFormItem, AInput, AButton, ATable, ASelect, APagination, ARangePicker, RedoOutlined } from '#components'
|
|
3
3
|
import type { TableColumnType } from 'ant-design-vue'
|
|
4
4
|
import dayjs from 'dayjs'
|
|
5
5
|
|
|
6
6
|
type TableFormItemType = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
label: string,
|
|
8
|
+
key: string,
|
|
9
|
+
is: string,
|
|
10
|
+
bind?: any,
|
|
11
|
+
value?:any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type TablePropsType = {
|
|
15
|
+
form?: TableFormItemType[]
|
|
16
|
+
table: {
|
|
17
|
+
'v-slots'?:any
|
|
18
|
+
enableSelection?: boolean
|
|
19
|
+
columns: TableColumnType[]
|
|
20
|
+
rowKey: (row: any) => any
|
|
21
|
+
data: (params:any) => any
|
|
22
|
+
},
|
|
23
|
+
footerOptions?: {
|
|
24
|
+
show: boolean
|
|
25
|
+
},
|
|
26
|
+
'v-slots'?:any
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type AttributeType = {
|
|
30
|
+
selectItems:any[],
|
|
31
|
+
selectKeys:any[],
|
|
32
|
+
page:number,
|
|
33
|
+
pageSize: number,
|
|
34
|
+
tableData: any[],
|
|
35
|
+
metaTableData:any[],
|
|
36
|
+
form:any
|
|
11
37
|
}
|
|
12
38
|
|
|
13
39
|
let dateRange = defineComponent({
|
|
@@ -45,7 +71,7 @@ let dateRange = defineComponent({
|
|
|
45
71
|
})
|
|
46
72
|
|
|
47
73
|
|
|
48
|
-
const FormItems = {
|
|
74
|
+
const FormItems:Record<string, (form: any, item: TableFormItemType) => any> = {
|
|
49
75
|
input: (form: any, item: TableFormItemType) => {
|
|
50
76
|
let {t:$t} = useI18n()
|
|
51
77
|
return <AInput size="middle" v-model:value={form[item.key]} placeholder={$t(`请输入{label}`,{label:$t(item.label)})}></AInput>
|
|
@@ -60,34 +86,6 @@ const FormItems = {
|
|
|
60
86
|
}
|
|
61
87
|
}
|
|
62
88
|
|
|
63
|
-
export type TablePropsType = {
|
|
64
|
-
form?: TableFormItemType[]
|
|
65
|
-
action?: {
|
|
66
|
-
search?: boolean
|
|
67
|
-
reset?: boolean
|
|
68
|
-
export?: boolean
|
|
69
|
-
opther: () => any
|
|
70
|
-
}
|
|
71
|
-
table: {
|
|
72
|
-
'v-slots'?:any
|
|
73
|
-
enableSelection?: boolean
|
|
74
|
-
columns: TableColumnType[]
|
|
75
|
-
data: () => any[]
|
|
76
|
-
},
|
|
77
|
-
footerOptions?: {
|
|
78
|
-
show: boolean
|
|
79
|
-
},
|
|
80
|
-
'v-slots'?:any
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export type AttributeType = {
|
|
84
|
-
selectItems:any[],
|
|
85
|
-
selectKeys:any[],
|
|
86
|
-
page:number,
|
|
87
|
-
pageSize: number,
|
|
88
|
-
tableData: any[],
|
|
89
|
-
form:any
|
|
90
|
-
}
|
|
91
89
|
|
|
92
90
|
export const FormTableProps = {
|
|
93
91
|
form: {
|
|
@@ -107,15 +105,7 @@ export const FormTableProps = {
|
|
|
107
105
|
export:false,
|
|
108
106
|
})
|
|
109
107
|
},
|
|
110
|
-
|
|
111
|
-
type: Object as () => TablePropsType['action'],
|
|
112
|
-
default: () => ({
|
|
113
|
-
search: true,
|
|
114
|
-
reset: true,
|
|
115
|
-
export: true,
|
|
116
|
-
opther: () => null
|
|
117
|
-
})
|
|
118
|
-
},
|
|
108
|
+
|
|
119
109
|
table: {
|
|
120
110
|
type: Object as () => TablePropsType['table'],
|
|
121
111
|
default: () => ({
|
|
@@ -150,8 +140,9 @@ export default defineComponent({
|
|
|
150
140
|
const {t:$t} = useI18n()
|
|
151
141
|
|
|
152
142
|
//form 初始化
|
|
153
|
-
const form = ref({})
|
|
143
|
+
const form = ref<any>({})
|
|
154
144
|
props.form?.forEach((item) => {
|
|
145
|
+
|
|
155
146
|
form.value[item.key] = item.value
|
|
156
147
|
})
|
|
157
148
|
props.attribute.form = form.value
|
|
@@ -159,7 +150,7 @@ export default defineComponent({
|
|
|
159
150
|
|
|
160
151
|
//table初始化
|
|
161
152
|
props.table.columns?.forEach((item) => {
|
|
162
|
-
item.title = $t(item.title)
|
|
153
|
+
item.title = $t(item.title as string)
|
|
163
154
|
})
|
|
164
155
|
|
|
165
156
|
let pagination =reactive({
|
|
@@ -186,6 +177,7 @@ export default defineComponent({
|
|
|
186
177
|
pagination.total = res.meta.pagination.total
|
|
187
178
|
pagination.pageSize = res.meta.pagination.per_page
|
|
188
179
|
pagination.page = res.meta.pagination.current_page
|
|
180
|
+
props.attribute.metaTableData = JSON.parse(JSON.stringify(res.list))
|
|
189
181
|
props.attribute.tableData = res.list
|
|
190
182
|
return res.list
|
|
191
183
|
},[])
|
|
@@ -204,13 +196,12 @@ export default defineComponent({
|
|
|
204
196
|
return () => (
|
|
205
197
|
<div class="flex flex-col gap-2 h-full ">
|
|
206
198
|
{props.form&&<AForm layout="inline gap-2">
|
|
207
|
-
{props.form?.map((item) => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
)
|
|
199
|
+
{props.form?.map((item: TableFormItemType) => {
|
|
200
|
+
return (
|
|
201
|
+
<AFormItem label={$t(item.label)}>
|
|
202
|
+
{FormItems[item.is]?.(form.value,item)}
|
|
203
|
+
</AFormItem>
|
|
204
|
+
)
|
|
214
205
|
})}
|
|
215
206
|
<div class="flex gap-2">
|
|
216
207
|
{props.formOptions.search && <AButton type="primary" onClick={()=>tableData.load()}>{$t('搜索')}</AButton>}
|
|
@@ -223,7 +214,7 @@ export default defineComponent({
|
|
|
223
214
|
{slots.content?.(tableData.value) ??
|
|
224
215
|
<ATable
|
|
225
216
|
row-selection={props.table.enableSelection?rowSelection:null}
|
|
226
|
-
rowKey={props.table.rowKey??((row
|
|
217
|
+
rowKey={props.table.rowKey??((row)=>row.id)}
|
|
227
218
|
loading={tableData.loading}
|
|
228
219
|
// scroll={{x: true}}
|
|
229
220
|
columns={props.table.columns}
|
|
@@ -235,7 +226,7 @@ export default defineComponent({
|
|
|
235
226
|
{title}
|
|
236
227
|
</div>
|
|
237
228
|
),
|
|
238
|
-
bodyCell:(row)=>{
|
|
229
|
+
bodyCell:(row:any)=>{
|
|
239
230
|
if(row.column?.customRender!=null){
|
|
240
231
|
return row.column.customRender(row)
|
|
241
232
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex items-center p-2 ml-2">
|
|
3
|
+
<a-dropdown >
|
|
4
|
+
<div class=" cursor-pointer">
|
|
5
|
+
<GlobalOutlined class="text-[20px]" />
|
|
6
|
+
</div>
|
|
7
|
+
<template #overlay>
|
|
8
|
+
<a-menu>
|
|
9
|
+
<a-menu-item v-for="locale in locales" @click="setLocale(locale.code)">
|
|
10
|
+
{{ locale.name }}
|
|
11
|
+
</a-menu-item>
|
|
12
|
+
</a-menu>
|
|
13
|
+
</template>
|
|
14
|
+
</a-dropdown>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
const { locales, setLocale } = useI18n()
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<style scoped></style>
|
package/app/composables/modal.ts
CHANGED
|
@@ -132,10 +132,10 @@ export const Confirm = {
|
|
|
132
132
|
// const { t: $t } = useI18n()
|
|
133
133
|
return new Promise((resolve, reject) => {
|
|
134
134
|
Modal.confirm({
|
|
135
|
-
title:
|
|
136
|
-
content:
|
|
137
|
-
okText:
|
|
138
|
-
cancelText:
|
|
135
|
+
title: '确认删除',
|
|
136
|
+
content: '确认删除该条数据吗?',
|
|
137
|
+
okText: '确定',
|
|
138
|
+
cancelText: '取消',
|
|
139
139
|
onOk: () => {
|
|
140
140
|
resolve(true)
|
|
141
141
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xizs/nuxt-antui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "nuxi dev .playground",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"generate": "nuxt generate .playground",
|
|
10
10
|
"preview": "nuxt preview .playground",
|
|
11
11
|
"lint": "eslint .",
|
|
12
|
-
"postinstall": "nuxt prepare
|
|
12
|
+
"postinstall": "nuxt prepare"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@ant-design-vue/nuxt": "1.4.6",
|