@xizs/nuxt-antui 0.0.7 → 0.0.9

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.
@@ -12,18 +12,23 @@ type TableFormItemType = {
12
12
  }
13
13
 
14
14
  export type TablePropsType = {
15
- form?: TableFormItemType[]
16
- table: {
15
+ form?: TableFormItemType[],
16
+ formOptions: {
17
+ search: boolean,
18
+ reset: boolean,
19
+ export: boolean,
20
+ },
21
+ table: {
22
+ 'v-slots'?:any
23
+ enableSelection?: boolean
24
+ columns: TableColumnType[]
25
+ rowKey: (row: any) => any
26
+ data: (params:any) => any
27
+ },
28
+ footerOptions?: {
29
+ show: boolean
30
+ },
17
31
  '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
32
  }
28
33
 
29
34
  export type AttributeType = {
@@ -51,13 +56,18 @@ let dateRange = defineComponent({
51
56
  let {t:$t} = useI18n()
52
57
 
53
58
  let value = watchRef(ref([]),(nv,ov)=>{
54
- if(nv?.length>0){
55
- props.form[props.item.key[0] as string] = nv[0].format('YYYY-MM-DD 00:00:00')
56
- props.form[props.item.key[1] as string] = nv[1].format('YYYY-MM-DD 23:59:59')
57
- }else{
58
- props.form[props.item.key[0] as string] = ''
59
- props.form[props.item.key[1] as string] = ''
60
- }
59
+ if(nv?.length>0){
60
+ props.form[props.item.key[0] as string] = nv[0].format('YYYY-MM-DD 00:00:00')
61
+ props.form[props.item.key[1] as string] = nv[1].format('YYYY-MM-DD 23:59:59')
62
+ }else{
63
+ props.form[props.item.key[0] as string] = ''
64
+ props.form[props.item.key[1] as string] = ''
65
+ }
66
+ })
67
+ watch([() => props.form[props.item.key[0] as string],()=>props.form[props.item.key[1] as string]], (nv) => {
68
+ console.log(nv)
69
+ value.value[0]=nv[0]
70
+ value.value[1]=nv[1]
61
71
  })
62
72
  const rangePresets = ref([
63
73
  { label: $t('今天'), value: [dayjs(), dayjs()] },
@@ -80,8 +90,16 @@ const FormItems:Record<string, (form: any, item: TableFormItemType) => any> = {
80
90
  let {t:$t} = useI18n()
81
91
  return <ASelect allowClear class="min-w-[150px]" v-model:value={form[item.key]} options={item.bind?.options} placeholder={$t(`请选择{label}`,{label:$t(item.label)})}></ASelect>
82
92
  },
93
+ selectTenant: (form: any, item: TableFormItemType) => {
94
+ let { t: $t } = useI18n()
95
+ watch(Const.TenantSelectList(), (nv) => {
96
+ console.log(nv)
97
+ }, {
98
+ once: true
99
+ })
100
+ return <ASelect allowClear class="min-w-[150px]" v-model:value={form[item.key]} options={Const.TenantSelectList().value} placeholder={$t(`请选择{label}`,{label:$t(item.label)})}></ASelect>
101
+ },
83
102
  dateRange:(form:any,item:TableFormItemType)=>{
84
-
85
103
  return h(dateRange,{form,item})
86
104
  }
87
105
  }
@@ -93,12 +111,7 @@ export const FormTableProps = {
93
111
  required: false
94
112
  },
95
113
  formOptions:{
96
- type:Object as () => {
97
- search:boolean,
98
- reset:boolean,
99
- export:boolean,
100
- opther?:()=>any
101
- },
114
+ type:Object as ()=> TablePropsType['formOptions'],
102
115
  default:()=>({
103
116
  search:true,
104
117
  reset:true,
@@ -143,7 +156,14 @@ export default defineComponent({
143
156
  const form = ref<any>({})
144
157
  props.form?.forEach((item) => {
145
158
 
146
- form.value[item.key] = item.value
159
+ if (Array.isArray(item.key)) {
160
+ item.key.forEach((key,index) => {
161
+ form.value[key] = item.value?.[index]??''
162
+ })
163
+
164
+ } else {
165
+ form.value[item.key] = item.value??''
166
+ }
147
167
  })
148
168
  props.attribute.form = form.value
149
169
  const metaForm = JSON.parse(JSON.stringify(form.value))
@@ -195,6 +215,7 @@ export default defineComponent({
195
215
 
196
216
  return () => (
197
217
  <div class="flex flex-col gap-2 h-full ">
218
+ {/* {JSON.stringify(form.value)} */}
198
219
  {props.form&&<AForm layout="inline gap-2">
199
220
  {props.form?.map((item: TableFormItemType) => {
200
221
  return (
@@ -205,7 +226,7 @@ export default defineComponent({
205
226
  })}
206
227
  <div class="flex gap-2">
207
228
  {props.formOptions.search && <AButton type="primary" onClick={()=>tableData.load()}>{$t('搜索')}</AButton>}
208
- {props.formOptions.reset && <AButton onClick={() => patch(metaForm,form.value)}>{$t('重置')}</AButton>}
229
+ {props.formOptions.reset && <AButton onClick={() => patch(metaForm,form.value,true)}>{$t('重置')}</AButton>}
209
230
  {props.formOptions.export && <AButton type="primary">{$t('导出')}</AButton>}
210
231
  </div>
211
232
  </AForm>}
@@ -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.7",
4
+ "version": "0.0.9",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",