@xizs/nuxt-antui 0.0.6 → 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.
@@ -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
- label: string
8
- key: string
9
- is: string
10
- bind?: any
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,35 +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
- metaTableData:any[],
90
- form:any
91
- }
92
89
 
93
90
  export const FormTableProps = {
94
91
  form: {
@@ -108,15 +105,7 @@ export const FormTableProps = {
108
105
  export:false,
109
106
  })
110
107
  },
111
- action: {
112
- type: Object as () => TablePropsType['action'],
113
- default: () => ({
114
- search: true,
115
- reset: true,
116
- export: true,
117
- opther: () => null
118
- })
119
- },
108
+
120
109
  table: {
121
110
  type: Object as () => TablePropsType['table'],
122
111
  default: () => ({
@@ -151,8 +140,9 @@ export default defineComponent({
151
140
  const {t:$t} = useI18n()
152
141
 
153
142
  //form 初始化
154
- const form = ref({})
143
+ const form = ref<any>({})
155
144
  props.form?.forEach((item) => {
145
+
156
146
  form.value[item.key] = item.value
157
147
  })
158
148
  props.attribute.form = form.value
@@ -160,7 +150,7 @@ export default defineComponent({
160
150
 
161
151
  //table初始化
162
152
  props.table.columns?.forEach((item) => {
163
- item.title = $t(item.title)
153
+ item.title = $t(item.title as string)
164
154
  })
165
155
 
166
156
  let pagination =reactive({
@@ -206,13 +196,12 @@ export default defineComponent({
206
196
  return () => (
207
197
  <div class="flex flex-col gap-2 h-full ">
208
198
  {props.form&&<AForm layout="inline gap-2">
209
- {props.form?.map((item) => {
210
- form[item.key] = item.value?? ''
211
- return (
212
- <AFormItem label={$t(item.label)}>
213
- {FormItems[item.is](form.value,item)}
214
- </AFormItem>
215
- )
199
+ {props.form?.map((item: TableFormItemType) => {
200
+ return (
201
+ <AFormItem label={$t(item.label)}>
202
+ {FormItems[item.is]?.(form.value,item)}
203
+ </AFormItem>
204
+ )
216
205
  })}
217
206
  <div class="flex gap-2">
218
207
  {props.formOptions.search && <AButton type="primary" onClick={()=>tableData.load()}>{$t('搜索')}</AButton>}
@@ -225,7 +214,7 @@ export default defineComponent({
225
214
  {slots.content?.(tableData.value) ??
226
215
  <ATable
227
216
  row-selection={props.table.enableSelection?rowSelection:null}
228
- rowKey={props.table.rowKey??((row,key)=>key)}
217
+ rowKey={props.table.rowKey??((row)=>row.id)}
229
218
  loading={tableData.loading}
230
219
  // scroll={{x: true}}
231
220
  columns={props.table.columns}
@@ -237,7 +226,7 @@ export default defineComponent({
237
226
  {title}
238
227
  </div>
239
228
  ),
240
- bodyCell:(row)=>{
229
+ bodyCell:(row:any)=>{
241
230
  if(row.column?.customRender!=null){
242
231
  return row.column.customRender(row)
243
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>
@@ -0,0 +1,5 @@
1
+ import zhCN from 'ant-design-vue/es/locale/zh_CN';
2
+
3
+ export const useAntLocale = () => useState(() => {
4
+ return zhCN
5
+ })
@@ -1,6 +1,8 @@
1
1
  import { createVNode, render } from "vue"
2
2
  import Form from "../components/global/Form"
3
- import { AModal } from "#components"
3
+ import { AConfigProvider, AModal } from "#components"
4
+
5
+ import zhCN from 'ant-design-vue/es/locale/zh_CN';
4
6
 
5
7
  export const NormalModal = (el) => {
6
8
  let control = { close: () => { } }
@@ -12,27 +14,29 @@ export const NormalModal = (el) => {
12
14
  control.close = () => {
13
15
  open.value = false
14
16
  }
15
- return () => h(el, {
16
- open: open.value, // 等价于 v-model:open
17
- 'onUpdate:open': (val: boolean) => {
18
- open.value = val
19
- if (!val) {
20
- setTimeout(() => {
21
- render(null, container) // 卸载组件
22
- if (container.parentNode) {
23
- container.parentNode.removeChild(container) // 移除 DOM
24
- }
25
- }, 1000);
26
- }
27
- },
28
- })
17
+ return () => h(AConfigProvider, { locale: useAntLocale().value }, [
18
+ h(el, {
19
+ open: open.value, // 等价于 v-model:open
20
+ 'onUpdate:open': (val: boolean) => {
21
+ open.value = val
22
+ if (!val) {
23
+ setTimeout(() => {
24
+ render(null, container) // 卸载组件
25
+ if (container.parentNode) {
26
+ container.parentNode.removeChild(container) // 移除 DOM
27
+ }
28
+ }, 1000);
29
+ }
30
+ },
31
+ })
32
+ ])
29
33
  }
30
34
  })
31
35
 
32
36
  const vnode = h(com)
33
37
  vnode.appContext = useNuxtApp().vueApp._context
34
38
  render(vnode, container)
35
- document.body.appendChild(container)
39
+ // document.getElementById('aaaa')!.appendChild(container)
36
40
 
37
41
  return control
38
42
 
@@ -55,32 +59,6 @@ export const FormModal = (params: FormModalParamsType) => {
55
59
 
56
60
  let submit: () => void
57
61
 
58
- // let control = NormalModal(h(AModal,{
59
- // title: params.title,
60
- // okText: '提交'+loading?.value,
61
- // cancelText: '取消',
62
- // onOk: async ()=>{
63
- // await submit()
64
- // control.close()
65
- // }
66
-
67
- // },h(defineComponent({
68
- // setup(){
69
- // let formRef = ref(null)
70
-
71
- // onMounted(()=>{
72
- // submit = formRef.value.submit
73
- // loading = formRef.value.loading
74
- // })
75
-
76
- // return ()=>h(Form,{
77
- // ref: formRef,
78
- // form: params.form,
79
- // submit:params.submit,
80
- // showSubmit: false
81
- // })
82
- // }
83
- // }))))
84
62
 
85
63
  let control = NormalModal(h(defineComponent({
86
64
  setup() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xizs/nuxt-antui",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
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 .playground"
12
+ "postinstall": "nuxt prepare"
13
13
  },
14
14
  "dependencies": {
15
15
  "@ant-design-vue/nuxt": "1.4.6",