@xizs/nuxt-antui 0.0.4 → 0.0.6
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.
|
@@ -50,9 +50,6 @@ export const FormComs:{
|
|
|
50
50
|
return <ARadioGroup v-model:value={form[item.key as string]} {...item.bind}></ARadioGroup>
|
|
51
51
|
},
|
|
52
52
|
|
|
53
|
-
// uploadImg: (form: any, item: FormItemType) => {
|
|
54
|
-
// return <UploadImg v-model:value={form[item.key as string]} {...item.bind}></UploadImg>
|
|
55
|
-
// }
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
export default defineComponent({
|
|
@@ -78,7 +75,9 @@ export default defineComponent({
|
|
|
78
75
|
default: () => ({})
|
|
79
76
|
}
|
|
80
77
|
},
|
|
81
|
-
setup(props,{expose}){
|
|
78
|
+
setup(props, { expose }) {
|
|
79
|
+
|
|
80
|
+
const {t:$t} = useI18n()
|
|
82
81
|
|
|
83
82
|
let thisRef = ref(null)
|
|
84
83
|
let formData = ref(props.defaultFormData)
|
|
@@ -125,7 +124,7 @@ export default defineComponent({
|
|
|
125
124
|
|
|
126
125
|
|
|
127
126
|
|
|
128
|
-
return ()=><AForm ref={thisRef} model={formData.value} rules={rules.value} label-col={{ span:
|
|
127
|
+
return ()=><AForm ref={thisRef} model={formData.value} rules={rules.value} label-col={{ span: 8 }} wrapper-col={{ span: 16 }}>
|
|
129
128
|
{/* {JSON.stringify(formData.value)} */}
|
|
130
129
|
{
|
|
131
130
|
ADParse(props.form, formData.value).map(item => {
|
|
@@ -133,7 +132,12 @@ export default defineComponent({
|
|
|
133
132
|
return typeof item.is === 'function'? item.is(formData.value) :
|
|
134
133
|
FormComs[item.is](formData.value,item)
|
|
135
134
|
}
|
|
136
|
-
return <AFormItem
|
|
135
|
+
return <AFormItem
|
|
136
|
+
key={item.key} name={item.key} {...item.bind} class={{ 'hidden': item.show === false }}
|
|
137
|
+
v-slots={{
|
|
138
|
+
label:()=><span class="whitespace-break-spaces">{$t(item.label)}</span>
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
137
141
|
{
|
|
138
142
|
typeof item.is === 'function'? item.is(formData.value) :
|
|
139
143
|
FormComs[item.is](formData.value,item)
|
|
@@ -26,11 +26,11 @@ let dateRange = defineComponent({
|
|
|
26
26
|
|
|
27
27
|
let value = watchRef(ref([]),(nv,ov)=>{
|
|
28
28
|
if(nv?.length>0){
|
|
29
|
-
props.form[props.item.key[0]] = nv[0].format('YYYY-MM-DD 00:00:00')
|
|
30
|
-
props.form[props.item.key[1]] = nv[1].format('YYYY-MM-DD 23:59:59')
|
|
29
|
+
props.form[props.item.key[0] as string] = nv[0].format('YYYY-MM-DD 00:00:00')
|
|
30
|
+
props.form[props.item.key[1] as string] = nv[1].format('YYYY-MM-DD 23:59:59')
|
|
31
31
|
}else{
|
|
32
|
-
props.form[props.item.key[0]] = ''
|
|
33
|
-
props.form[props.item.key[1]] = ''
|
|
32
|
+
props.form[props.item.key[0] as string] = ''
|
|
33
|
+
props.form[props.item.key[1] as string] = ''
|
|
34
34
|
}
|
|
35
35
|
})
|
|
36
36
|
const rangePresets = ref([
|
|
@@ -76,7 +76,8 @@ export type TablePropsType = {
|
|
|
76
76
|
},
|
|
77
77
|
footerOptions?: {
|
|
78
78
|
show: boolean
|
|
79
|
-
}
|
|
79
|
+
},
|
|
80
|
+
'v-slots'?:any
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export type AttributeType = {
|
|
@@ -85,6 +86,8 @@ export type AttributeType = {
|
|
|
85
86
|
page:number,
|
|
86
87
|
pageSize: number,
|
|
87
88
|
tableData: any[],
|
|
89
|
+
metaTableData:any[],
|
|
90
|
+
form:any
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
export const FormTableProps = {
|
|
@@ -120,7 +123,7 @@ export const FormTableProps = {
|
|
|
120
123
|
enableSelection: false,
|
|
121
124
|
columns: [],
|
|
122
125
|
data: () => [],
|
|
123
|
-
rowKey:(row:any)=>
|
|
126
|
+
rowKey:(row:any)=>{}
|
|
124
127
|
})
|
|
125
128
|
},
|
|
126
129
|
footerOptions: {
|
|
@@ -132,10 +135,11 @@ export const FormTableProps = {
|
|
|
132
135
|
})
|
|
133
136
|
},
|
|
134
137
|
attribute:{
|
|
135
|
-
|
|
138
|
+
type: Object as () => AttributeType,
|
|
139
|
+
default:()=>{}
|
|
136
140
|
},
|
|
137
141
|
control:{
|
|
138
|
-
type:Object,
|
|
142
|
+
type:Object as () => any,
|
|
139
143
|
required:true
|
|
140
144
|
},
|
|
141
145
|
}
|
|
@@ -146,6 +150,7 @@ export default defineComponent({
|
|
|
146
150
|
setup(props,{slots}) {
|
|
147
151
|
const {t:$t} = useI18n()
|
|
148
152
|
|
|
153
|
+
//form 初始化
|
|
149
154
|
const form = ref({})
|
|
150
155
|
props.form?.forEach((item) => {
|
|
151
156
|
form.value[item.key] = item.value
|
|
@@ -153,6 +158,11 @@ export default defineComponent({
|
|
|
153
158
|
props.attribute.form = form.value
|
|
154
159
|
const metaForm = JSON.parse(JSON.stringify(form.value))
|
|
155
160
|
|
|
161
|
+
//table初始化
|
|
162
|
+
props.table.columns?.forEach((item) => {
|
|
163
|
+
item.title = $t(item.title)
|
|
164
|
+
})
|
|
165
|
+
|
|
156
166
|
let pagination =reactive({
|
|
157
167
|
page:1,
|
|
158
168
|
pageSize:20,
|
|
@@ -161,7 +171,7 @@ export default defineComponent({
|
|
|
161
171
|
|
|
162
172
|
|
|
163
173
|
const tableData = asyncReactive<any[]>(async ()=>{
|
|
164
|
-
let res = await props.table.data({...form.value,...pagination})
|
|
174
|
+
let res:any = await props.table.data({...form.value,...pagination})
|
|
165
175
|
if(Array.isArray(res)){
|
|
166
176
|
res = {
|
|
167
177
|
list:res,
|
|
@@ -177,6 +187,7 @@ export default defineComponent({
|
|
|
177
187
|
pagination.total = res.meta.pagination.total
|
|
178
188
|
pagination.pageSize = res.meta.pagination.per_page
|
|
179
189
|
pagination.page = res.meta.pagination.current_page
|
|
190
|
+
props.attribute.metaTableData = JSON.parse(JSON.stringify(res.list))
|
|
180
191
|
props.attribute.tableData = res.list
|
|
181
192
|
return res.list
|
|
182
193
|
},[])
|
|
@@ -184,7 +195,7 @@ export default defineComponent({
|
|
|
184
195
|
|
|
185
196
|
const rowSelection = {
|
|
186
197
|
selectedRowKeys: props.attribute?.selectKeys,
|
|
187
|
-
onChange: (keys,rows)=>{
|
|
198
|
+
onChange: (keys:any,rows:any)=>{
|
|
188
199
|
props.attribute!.selectKeys.splice(0,props.attribute!.selectKeys.length,...keys)
|
|
189
200
|
props.attribute!.selectItems.splice(0,props.attribute!.selectItems.length,...rows)
|
|
190
201
|
}
|
|
@@ -216,10 +227,10 @@ export default defineComponent({
|
|
|
216
227
|
row-selection={props.table.enableSelection?rowSelection:null}
|
|
217
228
|
rowKey={props.table.rowKey??((row,key)=>key)}
|
|
218
229
|
loading={tableData.loading}
|
|
219
|
-
scroll={{x: true}}
|
|
230
|
+
// scroll={{x: true}}
|
|
220
231
|
columns={props.table.columns}
|
|
221
232
|
pagination={false}
|
|
222
|
-
sticky={tableData.value.length>0}
|
|
233
|
+
// sticky={tableData.value.length>0}
|
|
223
234
|
v-slots={{
|
|
224
235
|
headerCell: ({ title,column }: any) => (
|
|
225
236
|
<div style={{'white-space': 'nowrap'}}>
|
|
@@ -256,7 +267,7 @@ export default defineComponent({
|
|
|
256
267
|
pageSizeOptions={['20','50','100']}
|
|
257
268
|
onShowSizeChange={(current, size) => {
|
|
258
269
|
pagination.pageSize = size
|
|
259
|
-
pagination.page =
|
|
270
|
+
pagination.page = 1
|
|
260
271
|
tableData.load()
|
|
261
272
|
}}
|
|
262
273
|
/>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
<div class=" flex items-center">
|
|
28
28
|
<div >
|
|
29
29
|
<a-dropdown >
|
|
30
|
-
<div class="h-[30px] leading-[30px]">{{ useAdmin().value?.username ?? 'Admin'}}</div>
|
|
30
|
+
<div class="h-[30px] leading-[30px] cursor-pointer">{{ useAdmin().value?.username ?? 'Admin'}}</div>
|
|
31
31
|
<template #overlay>
|
|
32
32
|
<a-menu>
|
|
33
33
|
<a-menu-item @click="()=>singOut()">
|
package/app/composables/modal.ts
CHANGED
|
@@ -84,6 +84,7 @@ export const FormModal = (params: FormModalParamsType) => {
|
|
|
84
84
|
|
|
85
85
|
let control = NormalModal(h(defineComponent({
|
|
86
86
|
setup() {
|
|
87
|
+
const { t: $t } = useI18n()
|
|
87
88
|
let formRef = ref(null)
|
|
88
89
|
let loading = ref(false)
|
|
89
90
|
|
|
@@ -101,16 +102,15 @@ export const FormModal = (params: FormModalParamsType) => {
|
|
|
101
102
|
})
|
|
102
103
|
|
|
103
104
|
return () => h(AModal, {
|
|
104
|
-
title: params.title,
|
|
105
|
+
title: $t(params.title),
|
|
105
106
|
width: params.width,
|
|
106
|
-
okText: '提交',
|
|
107
|
-
cancelText: '取消',
|
|
107
|
+
okText: $t('提交'),
|
|
108
|
+
cancelText: $t('取消'),
|
|
108
109
|
confirmLoading: loading.value,
|
|
109
110
|
onOk: async () => {
|
|
110
111
|
await submit()
|
|
111
112
|
control.close()
|
|
112
113
|
}
|
|
113
|
-
|
|
114
114
|
}, h(Form, {
|
|
115
115
|
ref: formRef,
|
|
116
116
|
form: params.form,
|
|
@@ -129,13 +129,13 @@ export const MModal = {
|
|
|
129
129
|
|
|
130
130
|
export const Confirm = {
|
|
131
131
|
delete: () => {
|
|
132
|
-
const { t: $t } = useI18n()
|
|
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/app/composables/table.ts
CHANGED
|
@@ -9,7 +9,9 @@ export const FormTable = (props: TablePropsType) => {
|
|
|
9
9
|
selectItems: [],
|
|
10
10
|
selectKeys: [],
|
|
11
11
|
page: 1,
|
|
12
|
-
pageSize: 10
|
|
12
|
+
pageSize: 10,
|
|
13
|
+
tableData: [],
|
|
14
|
+
form: {}
|
|
13
15
|
})
|
|
14
16
|
|
|
15
17
|
const control = {
|
|
@@ -28,7 +30,7 @@ export const TablePage = (props: TablePropsType) => {
|
|
|
28
30
|
|
|
29
31
|
return {
|
|
30
32
|
...TableParams,
|
|
31
|
-
com: h(ACard, { class: "absolute top-0 left-0 right-0 bottom-0 h-full", bodyStyle:
|
|
33
|
+
com: h(ACard, { class: "absolute top-0 left-0 right-0 bottom-0 h-full", bodyStyle: { height: '100%' } }, TableParams.com)
|
|
32
34
|
|
|
33
35
|
}
|
|
34
36
|
}
|
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.6",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "nuxi dev .playground",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@ant-design-vue/nuxt": "1.4.6",
|
|
16
16
|
"@nuxtjs/i18n": "9.5.4",
|
|
17
17
|
"@tailwindcss/vite": "^4.1.3",
|
|
18
|
-
"@xizs/nuxt-base": "
|
|
18
|
+
"@xizs/nuxt-base": "0.0.4",
|
|
19
19
|
"ant-design-vue": ">=4",
|
|
20
20
|
"nuxt": "^3.16.2",
|
|
21
21
|
"tailwindcss": "^4.0.14",
|