@vue-ui-kit/ant 1.1.0 → 1.1.2
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/dist/cjs/index.js +1 -1
- package/dist/declarations/antProxy.d.ts +13 -0
- package/dist/es/index.js +686 -646
- package/dist/packages/components/PFormGroup.vue.d.ts +1 -0
- package/dist/packages/store/renderStore.d.ts +3 -0
- package/package.json +1 -1
- package/src/declarations/antProxy.ts +20 -6
- package/src/packages/components/PForm.vue +83 -82
- package/src/packages/components/PFormGroup.vue +70 -57
- package/src/packages/components/PGrid.vue +361 -360
- package/src/packages/store/renderStore.tsx +109 -88
|
@@ -1,277 +1,277 @@
|
|
|
1
1
|
<script generic="D = Recordable, F = Recordable" lang="ts" name="PGrid" setup>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
import { ColumnProps, PFormItemProps, PGridProps, ResponsePathConfig } from '#/antProxy'
|
|
3
|
+
import { computed, useAttrs, ref, Ref, reactive, onMounted, watch, toRefs } from 'vue'
|
|
4
|
+
import { debounce, get, isArray, isFunction, isString, merge, omit, toNumber } from 'lodash-es'
|
|
5
|
+
import { eachTree } from '@/utils/treeHelper'
|
|
6
|
+
import { message as $message } from 'ant-design-vue'
|
|
7
|
+
import RenderAntItem from '@/components/RenderAntItem'
|
|
8
|
+
import RenderTitleSlots from '@/components/RenderTitleSlots'
|
|
9
|
+
import RenderDefaultSlots from '@/components/RenderDefaultSlots'
|
|
10
|
+
import { v4 as uuid_v4 } from 'uuid'
|
|
11
|
+
import { valued } from '@/utils/is'
|
|
12
|
+
import RenderItemSlots from '@/components/RenderItemSlots'
|
|
13
|
+
import { cleanCol, defaultItemResponsive, defaultLabelCol } from '@/utils/core'
|
|
14
|
+
import Icon from '@/renders/Icon'
|
|
15
|
+
import { $confirm } from '@/hooks/useMessage'
|
|
16
|
+
import {
|
|
17
|
+
Table as ATable,
|
|
18
|
+
Button as AButton,
|
|
19
|
+
Form as AForm,
|
|
20
|
+
FormItem as AFormItem,
|
|
21
|
+
Row as ARow,
|
|
22
|
+
Col as ACol,
|
|
23
|
+
Spin as ASpin,
|
|
24
|
+
} from 'ant-design-vue'
|
|
25
|
+
import { TablePaginationConfig } from 'ant-design-vue/es/table/interface'
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
27
|
+
const props = defineProps<PGridProps<D, F>>()
|
|
28
|
+
const {
|
|
29
|
+
formConfig,
|
|
30
|
+
pageConfig,
|
|
31
|
+
columns,
|
|
32
|
+
toolbarConfig,
|
|
33
|
+
proxyConfig,
|
|
34
|
+
tableConfig,
|
|
35
|
+
selectConfig,
|
|
36
|
+
scrollMode,
|
|
37
|
+
} = toRefs(props)
|
|
38
|
+
const loading = reactive({
|
|
39
|
+
table: false,
|
|
40
|
+
form: false,
|
|
41
|
+
})
|
|
42
|
+
const submitOnReset = true
|
|
43
|
+
const boxEl = ref<HTMLDivElement>()
|
|
44
|
+
const renderHeight = ref(500)
|
|
45
|
+
const selectedRowKeys = ref<string[] | number[]>([])
|
|
46
|
+
const innerToolbarHandler = (code: string) => {
|
|
47
|
+
const { ajax } = proxyConfig.value!
|
|
48
|
+
switch (code) {
|
|
49
|
+
case 'multiDelete':
|
|
50
|
+
if (ajax.multiDelete) {
|
|
51
|
+
if (selectedRowKeys.value.length > 0) {
|
|
52
|
+
$confirm({
|
|
53
|
+
title: '警告',
|
|
54
|
+
content: '确认删除选中的数据吗?',
|
|
55
|
+
}).then(() => {
|
|
56
|
+
loading.table = true
|
|
57
|
+
ajax.multiDelete!(selectedRowKeys.value)
|
|
58
58
|
.then(() => {
|
|
59
|
-
$message.success('删除成功')
|
|
60
|
-
resetPage()
|
|
59
|
+
$message.success('删除成功')
|
|
60
|
+
resetPage()
|
|
61
61
|
})
|
|
62
62
|
.catch(() => {
|
|
63
|
-
$message.error('删除失败')
|
|
63
|
+
$message.error('删除失败')
|
|
64
64
|
})
|
|
65
65
|
.finally(() => {
|
|
66
|
-
loading.table = false
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const slotTitleColumns = computed(() => {
|
|
77
|
-
const cols: ColumnProps<D>[] = [];
|
|
78
|
-
eachTree(columns.value, (col) => {
|
|
79
|
-
if (col.slots && col.slots.title) {
|
|
80
|
-
if (!col.field) {
|
|
81
|
-
col.field = '__holder__' + cols.length;
|
|
66
|
+
loading.table = false
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
} else {
|
|
70
|
+
$message.warn('请选择要删除的数据')
|
|
82
71
|
}
|
|
83
|
-
cols.push(col);
|
|
84
72
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
const refreshTable = () => {
|
|
96
|
-
renderTableKey.value = uuid_v4();
|
|
97
|
-
};
|
|
98
|
-
const debounceRefreshForm = debounce(refreshForm, 100);
|
|
99
|
-
const debounceRefreshTable = debounce(refreshTable, 100);
|
|
100
|
-
const slotDefaultColumns = computed(() => {
|
|
101
|
-
const cols: ColumnProps<D>[] = [];
|
|
102
|
-
eachTree(columns.value, (col) => {
|
|
103
|
-
if ((col.slots && col.slots.default) || col.formatter || col.cellRender) {
|
|
104
|
-
if (!col.field) {
|
|
105
|
-
col.field = '__holder__' + cols.length;
|
|
106
|
-
}
|
|
107
|
-
cols.push(col);
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const slotTitleColumns = computed(() => {
|
|
77
|
+
const cols: ColumnProps<D>[] = []
|
|
78
|
+
eachTree(columns.value, (col) => {
|
|
79
|
+
if (col.slots && col.slots.title) {
|
|
80
|
+
if (!col.field) {
|
|
81
|
+
col.field = '__holder__' + cols.length
|
|
108
82
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
'toolbarToolClick',
|
|
133
|
-
'pick',
|
|
134
|
-
]);
|
|
135
|
-
const toolBtnClick = (code: string) => {
|
|
136
|
-
emit('toolbarButtonClick', {
|
|
137
|
-
data: tableData.value,
|
|
138
|
-
code,
|
|
139
|
-
selectedKeys: selectedRowKeys.value,
|
|
140
|
-
});
|
|
141
|
-
innerToolbarHandler(code);
|
|
142
|
-
};
|
|
143
|
-
const toolToolClick = (code: string) => {
|
|
144
|
-
emit('toolbarToolClick', { data: tableData.value, code, selectedKeys: selectedRowKeys.value });
|
|
145
|
-
innerToolbarHandler(code);
|
|
146
|
-
};
|
|
147
|
-
const queryFormData = ref<Partial<F>>({}) as Ref<Partial<F>>;
|
|
148
|
-
const pickRow = ({ row, field }: { row: D; field: string }) => {
|
|
149
|
-
emit('pick', { row, field });
|
|
150
|
-
};
|
|
151
|
-
const resetQueryFormData = (lazy?: boolean) => {
|
|
152
|
-
if (formConfig.value && formConfig.value.items.length > 0) {
|
|
153
|
-
if (formConfig.value.customReset) {
|
|
154
|
-
formConfig.value.customReset();
|
|
155
|
-
} else {
|
|
156
|
-
const obj: Partial<F> = {};
|
|
157
|
-
eachTree(formConfig.value.items, (item) => {
|
|
158
|
-
if (item.field && item.itemRender) {
|
|
159
|
-
if (valued(item.itemRender.defaultValue)) {
|
|
160
|
-
obj[item.field] = item.itemRender.defaultValue;
|
|
161
|
-
} else {
|
|
162
|
-
obj[item.field] = undefined;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
queryFormData.value = obj;
|
|
83
|
+
cols.push(col)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
return cols
|
|
87
|
+
})
|
|
88
|
+
const formEl = ref()
|
|
89
|
+
const tableEl = ref()
|
|
90
|
+
const renderFormKey = ref(uuid_v4())
|
|
91
|
+
const renderTableKey = ref(uuid_v4())
|
|
92
|
+
const refreshForm = () => {
|
|
93
|
+
renderFormKey.value = uuid_v4()
|
|
94
|
+
}
|
|
95
|
+
const refreshTable = () => {
|
|
96
|
+
renderTableKey.value = uuid_v4()
|
|
97
|
+
}
|
|
98
|
+
const debounceRefreshForm = debounce(refreshForm, 100)
|
|
99
|
+
const debounceRefreshTable = debounce(refreshTable, 100)
|
|
100
|
+
const slotDefaultColumns = computed(() => {
|
|
101
|
+
const cols: ColumnProps<D>[] = []
|
|
102
|
+
eachTree(columns.value, (col) => {
|
|
103
|
+
if ((col.slots && col.slots.default) || col.formatter || col.cellRender) {
|
|
104
|
+
if (!col.field) {
|
|
105
|
+
col.field = '__holder__' + cols.length
|
|
167
106
|
}
|
|
168
|
-
|
|
107
|
+
cols.push(col)
|
|
169
108
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
109
|
+
})
|
|
110
|
+
return cols
|
|
111
|
+
})
|
|
112
|
+
const pagination = reactive<IPage>({
|
|
113
|
+
page: 1,
|
|
114
|
+
size: pageConfig.value?.pageSize ?? 10,
|
|
115
|
+
})
|
|
116
|
+
const dataSeed = ref(0)
|
|
117
|
+
const totalCount = ref(0)
|
|
118
|
+
const tableData = ref<D[]>([]) as Ref<D[]>
|
|
119
|
+
const mode = computed<'list' | 'pagination' | 'bad'>(() =>
|
|
120
|
+
proxyConfig.value && proxyConfig.value.ajax
|
|
121
|
+
? pageConfig.value
|
|
122
|
+
? 'pagination'
|
|
123
|
+
: 'list'
|
|
124
|
+
: 'bad',
|
|
125
|
+
)
|
|
126
|
+
const attrs = useAttrs()
|
|
127
|
+
const emit = defineEmits([
|
|
128
|
+
'query',
|
|
129
|
+
'reset',
|
|
130
|
+
'update:tableData',
|
|
131
|
+
'toolbarButtonClick',
|
|
132
|
+
'toolbarToolClick',
|
|
133
|
+
'pick',
|
|
134
|
+
])
|
|
135
|
+
const toolBtnClick = (code: string) => {
|
|
136
|
+
emit('toolbarButtonClick', {
|
|
137
|
+
data: tableData.value,
|
|
138
|
+
code,
|
|
139
|
+
selectedKeys: selectedRowKeys.value,
|
|
140
|
+
})
|
|
141
|
+
innerToolbarHandler(code)
|
|
142
|
+
}
|
|
143
|
+
const toolToolClick = (code: string) => {
|
|
144
|
+
emit('toolbarToolClick', { data: tableData.value, code, selectedKeys: selectedRowKeys.value })
|
|
145
|
+
innerToolbarHandler(code)
|
|
146
|
+
}
|
|
147
|
+
const queryFormData = ref<Partial<F>>({}) as Ref<Partial<F>>
|
|
148
|
+
const pickRow = ({ row, field }: { row: D; field: string }) => {
|
|
149
|
+
emit('pick', { row, field })
|
|
150
|
+
}
|
|
151
|
+
const resetQueryFormData = (lazy?: boolean) => {
|
|
152
|
+
if (formConfig.value && formConfig.value.items.length > 0) {
|
|
153
|
+
if (formConfig.value.customReset) {
|
|
154
|
+
formConfig.value.customReset()
|
|
155
|
+
} else {
|
|
156
|
+
const obj: Partial<F> = {}
|
|
157
|
+
eachTree(formConfig.value.items, (item) => {
|
|
158
|
+
if (item.field && item.itemRender) {
|
|
159
|
+
if (valued(item.itemRender.defaultValue)) {
|
|
160
|
+
obj[item.field] = item.itemRender.defaultValue
|
|
161
|
+
} else {
|
|
162
|
+
obj[item.field] = undefined
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
queryFormData.value = obj
|
|
174
167
|
}
|
|
175
|
-
|
|
176
|
-
|
|
168
|
+
refreshForm()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
pagination.page = 1
|
|
172
|
+
if (!lazy) {
|
|
173
|
+
debounceFetchData()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const handleResponse = (response: Recordable, pathConfig?: ResponsePathConfig<D>) =>
|
|
177
177
|
pathConfig
|
|
178
|
-
|
|
178
|
+
? {
|
|
179
179
|
list: isString(pathConfig.list)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
? get(response, pathConfig.list)
|
|
181
|
+
: isFunction(pathConfig.list)
|
|
182
|
+
? pathConfig.list(response)
|
|
183
|
+
: undefined,
|
|
184
184
|
total: isString(pathConfig.total)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
? get(response, pathConfig.total)
|
|
186
|
+
: isFunction(pathConfig.total)
|
|
187
|
+
? pathConfig.total(response)
|
|
188
|
+
: undefined,
|
|
189
189
|
result: isString(pathConfig.result)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
? get(response, pathConfig.result)
|
|
191
|
+
: isFunction(pathConfig.result)
|
|
192
|
+
? pathConfig.result(response)
|
|
193
|
+
: undefined,
|
|
194
194
|
message: isString(pathConfig.message)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
? get(response, pathConfig.message)
|
|
196
|
+
: isFunction(pathConfig.message)
|
|
197
|
+
? pathConfig.message(response)
|
|
198
|
+
: undefined,
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
: {
|
|
201
201
|
list: response,
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
202
|
+
}
|
|
203
|
+
const enoughSpacing = ref(true)
|
|
204
|
+
const reload = () => {
|
|
205
|
+
return resetQueryFormData()
|
|
206
|
+
}
|
|
207
|
+
const resetPage = () => {
|
|
208
|
+
pagination.page = 1
|
|
209
|
+
selectedRowKeys.value = []
|
|
210
|
+
return fetchData()
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @description
|
|
214
|
+
* @param p
|
|
215
|
+
* @param _filters todo filters
|
|
216
|
+
* @param _sorter todo sorter
|
|
217
|
+
*/
|
|
218
|
+
const handleTableChange = (p: TablePaginationConfig, _filters, _sorter) => {
|
|
219
|
+
pagination.page = p.current!
|
|
220
|
+
pagination.size = p.pageSize!
|
|
221
|
+
return fetchData()
|
|
222
|
+
}
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
const fetchData = () =>
|
|
225
225
|
new Promise<D[]>((resolve) => {
|
|
226
226
|
if (mode.value !== 'bad') {
|
|
227
|
-
loading.form = true
|
|
228
|
-
loading.table = true
|
|
229
|
-
const { ajax } = proxyConfig.value
|
|
227
|
+
loading.form = true
|
|
228
|
+
loading.table = true
|
|
229
|
+
const { ajax } = proxyConfig.value!
|
|
230
230
|
ajax
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
231
|
+
.query({
|
|
232
|
+
form: queryFormData.value,
|
|
233
|
+
page: pagination,
|
|
234
|
+
})
|
|
235
|
+
.then((response) => {
|
|
236
|
+
const { list, total, result, message } = handleResponse(
|
|
237
|
+
response,
|
|
238
|
+
proxyConfig.value!.response,
|
|
239
|
+
)
|
|
240
|
+
if (list) {
|
|
241
|
+
tableData.value = list as D[]
|
|
242
|
+
dataSeed.value++
|
|
243
|
+
} else if (result) {
|
|
244
|
+
tableData.value = result as D[]
|
|
245
|
+
totalCount.value = total ?? result.length
|
|
246
|
+
dataSeed.value++
|
|
247
|
+
} else {
|
|
248
|
+
tableData.value = []
|
|
249
|
+
dataSeed.value++
|
|
250
|
+
if (message) {
|
|
251
|
+
$message.warn(message)
|
|
252
|
+
}
|
|
252
253
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
});
|
|
254
|
+
resolve(tableData.value as D[])
|
|
255
|
+
})
|
|
256
|
+
.catch((e) => {
|
|
257
|
+
console.error('fetchData error', e)
|
|
258
|
+
resolve([] as D[])
|
|
259
|
+
})
|
|
260
|
+
.finally(() => {
|
|
261
|
+
loading.form = false
|
|
262
|
+
loading.table = false
|
|
263
|
+
})
|
|
264
264
|
}
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
265
|
+
})
|
|
266
|
+
const debounceFetchData = debounce(fetchData, 160)
|
|
267
|
+
const passQuery = (params: Partial<F>) => {
|
|
268
|
+
Object.assign(queryFormData.value, params)
|
|
269
|
+
pagination.page = 1
|
|
270
|
+
return debounceFetchData()
|
|
271
|
+
}
|
|
272
|
+
const pg = computed(() =>
|
|
273
273
|
mode.value === 'pagination'
|
|
274
|
-
|
|
274
|
+
? {
|
|
275
275
|
current: pagination.page,
|
|
276
276
|
total: totalCount.value,
|
|
277
277
|
pageSize: pagination.size,
|
|
@@ -279,119 +279,120 @@
|
|
|
279
279
|
showSizeChanger: true,
|
|
280
280
|
showTotal: (total: number) => `共${total}条数据`,
|
|
281
281
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
282
|
+
: false,
|
|
283
|
+
)
|
|
284
|
+
const defaultTableConfig = {
|
|
285
|
+
size: 'small',
|
|
286
|
+
sticky: true,
|
|
287
|
+
transformCellText: ({ text }) => {
|
|
288
|
+
return isArray(text) && text.length === 0 ? '-' : text
|
|
289
|
+
},
|
|
290
|
+
}
|
|
291
|
+
const tc = computed(() =>
|
|
292
292
|
merge(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
293
|
+
{},
|
|
294
|
+
defaultTableConfig,
|
|
295
|
+
tableConfig?.value ?? {},
|
|
296
|
+
selectConfig.value
|
|
297
|
+
? {
|
|
298
|
+
rowSelection: {
|
|
299
|
+
type: selectConfig.value.multiple ? 'checkbox' : 'radio',
|
|
300
|
+
preserveSelectedRowKeys: true,
|
|
301
|
+
selectedRowKeys: selectedRowKeys.value,
|
|
302
|
+
onChange: (selectedKeys: string[] | number[]) => {
|
|
303
|
+
selectedRowKeys.value = selectedKeys
|
|
304
|
+
},
|
|
304
305
|
},
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
: {},
|
|
306
|
+
}
|
|
307
|
+
: {},
|
|
308
308
|
),
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
309
|
+
)
|
|
310
|
+
/*omit({labelCol:defaultLabelCol,...formConfig},['items'])*/
|
|
311
|
+
const fc = computed(() => omit({ labelCol: defaultLabelCol, ...formConfig.value }, ['items']))
|
|
312
|
+
const handleFormSubmit = () => {
|
|
313
|
+
resetPage()
|
|
314
|
+
}
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
watch(
|
|
317
317
|
() => formConfig.value,
|
|
318
318
|
() => {
|
|
319
|
-
debounceRefreshForm()
|
|
319
|
+
debounceRefreshForm()
|
|
320
320
|
},
|
|
321
321
|
{ deep: true },
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
)
|
|
323
|
+
watch(
|
|
324
324
|
() => [columns.value, proxyConfig.value, toolbarConfig.value],
|
|
325
325
|
() => {
|
|
326
|
-
debounceRefreshTable()
|
|
326
|
+
debounceRefreshTable()
|
|
327
327
|
},
|
|
328
328
|
{ deep: true },
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
329
|
+
)
|
|
330
|
+
defineExpose({
|
|
331
|
+
commitProxy: {
|
|
332
|
+
query: debounceFetchData,
|
|
333
|
+
reload,
|
|
334
|
+
reloadPage: resetPage,
|
|
335
|
+
passQuery,
|
|
336
|
+
},
|
|
337
|
+
$table: computed(() => tableEl.value),
|
|
338
|
+
selectedRowKeys: computed(() => selectedRowKeys.value),
|
|
339
|
+
$form: computed(() => formEl.value),
|
|
340
|
+
})
|
|
341
|
+
onMounted(() => {
|
|
342
|
+
/*判断本组件所在容器DOM*/
|
|
343
|
+
const pNode = boxEl.value?.parentElement
|
|
344
|
+
const ph = pNode ? window.getComputedStyle(pNode).height : '0px'
|
|
345
|
+
renderHeight.value = props.renderY ?? toNumber(ph.replace('px', '')) - (props.fitHeight ?? 170) - (!!props.toolbarConfig ? 30 : 0) - (Math.ceil((props.formConfig?.items?.length ?? 0) / 4) * 35)
|
|
346
|
+
enoughSpacing.value = toNumber(ph.replace('px', '')) > 600
|
|
347
|
+
resetQueryFormData(props.manualFetch)
|
|
348
|
+
})
|
|
349
349
|
</script>
|
|
350
350
|
<template>
|
|
351
351
|
<div ref="boxEl" class="h-full p-wrapper flex flex-col gap-8px overflow-y-auto" v-bind="attrs">
|
|
352
352
|
<div v-if="mode === 'bad'">请检查配置</div>
|
|
353
353
|
<template v-else>
|
|
354
354
|
<div
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
v-if="formConfig?.items?.some((s: PFormItemProps<F>) => s.field && s.itemRender)"
|
|
356
|
+
class="p-pane p-form-wrapper"
|
|
357
357
|
>
|
|
358
358
|
<a-spin :spinning="loading.form">
|
|
359
359
|
<a-form
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
360
|
+
:key="renderFormKey"
|
|
361
|
+
ref="formEl"
|
|
362
|
+
:model="queryFormData"
|
|
363
|
+
v-bind="fc"
|
|
364
|
+
@submit="handleFormSubmit"
|
|
365
365
|
>
|
|
366
366
|
<a-row :gutter="[6, 12]">
|
|
367
367
|
<a-col
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
368
|
+
v-for="(item, idx) in formConfig!.items"
|
|
369
|
+
:key="'_col_' + idx"
|
|
370
|
+
v-bind="item.col ?? (item.span ? { span: item.span } : defaultItemResponsive)"
|
|
371
371
|
>
|
|
372
372
|
<a-form-item
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
373
|
+
:key="'_item_' + idx"
|
|
374
|
+
:class="`p-content-align-${item.align ?? 'left'}`"
|
|
375
|
+
:label="item.title"
|
|
376
|
+
:name="item.field"
|
|
377
|
+
v-bind="omit(item, ['field', 'title', 'span', 'col', 'itemRender'])"
|
|
378
378
|
>
|
|
379
379
|
<render-item-slots
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
380
|
+
v-if="item.slots?.default"
|
|
381
|
+
:key="'_sl_'+(item.field??'_')+'_'+idx"
|
|
382
|
+
:form-data="queryFormData"
|
|
383
|
+
:item="item"
|
|
384
|
+
:pass-trigger="() => {}"
|
|
384
385
|
/>
|
|
385
386
|
<render-ant-item
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
v-else-if="item.itemRender?.name"
|
|
388
|
+
:key="'_re_'+(item.field??'_')+'_'+idx"
|
|
389
|
+
:default-handler="{
|
|
389
390
|
reset: () => {
|
|
390
391
|
resetQueryFormData(!submitOnReset);
|
|
391
392
|
},
|
|
392
393
|
}"
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
:item-render="item.itemRender"
|
|
395
|
+
:render-form-params="{ data: queryFormData, field: item.field }"
|
|
395
396
|
/>
|
|
396
397
|
<span v-else></span>
|
|
397
398
|
</a-form-item>
|
|
@@ -401,19 +402,19 @@
|
|
|
401
402
|
</a-spin>
|
|
402
403
|
</div>
|
|
403
404
|
<div
|
|
404
|
-
|
|
405
|
-
|
|
405
|
+
v-if="toolbarConfig"
|
|
406
|
+
class="p-toolbar-wrapper flex items-center w-full justify-between p-theme-bg pt-8px px-16px"
|
|
406
407
|
>
|
|
407
408
|
<div class="flex items-center flex-1 gap-4px">
|
|
408
409
|
<template v-if="toolbarConfig.buttons && toolbarConfig.buttons.length > 0">
|
|
409
410
|
<a-button
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
411
|
+
v-for="(btn, idx) in toolbarConfig.buttons"
|
|
412
|
+
:key="idx"
|
|
413
|
+
:type="btn.type"
|
|
414
|
+
size="small"
|
|
415
|
+
@click="toolBtnClick(btn.code)"
|
|
415
416
|
>
|
|
416
|
-
<Icon v-if="btn.icon" :icon="btn.icon"
|
|
417
|
+
<Icon v-if="btn.icon" :icon="btn.icon"/>
|
|
417
418
|
{{ btn.content }}
|
|
418
419
|
</a-button>
|
|
419
420
|
</template>
|
|
@@ -421,49 +422,49 @@
|
|
|
421
422
|
<span class="flex items-center gap-4px">
|
|
422
423
|
<template v-if="toolbarConfig.tools && toolbarConfig.tools.length > 0">
|
|
423
424
|
<a-button
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
425
|
+
v-for="(tool, idx) in toolbarConfig.tools"
|
|
426
|
+
:key="idx"
|
|
427
|
+
:type="tool.type"
|
|
428
|
+
size="small"
|
|
429
|
+
@click="toolToolClick(tool.code)"
|
|
429
430
|
>
|
|
430
|
-
<Icon :icon="tool.icon"
|
|
431
|
+
<Icon :icon="tool.icon"/>
|
|
431
432
|
</a-button>
|
|
432
433
|
</template>
|
|
433
434
|
</span>
|
|
434
435
|
</div>
|
|
435
436
|
<div :class="`p-pane flex-1 ${enoughSpacing ? 'h-0' : ''} p-${scrollMode ?? 'inner'}-scroll`">
|
|
436
437
|
<a-table
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
438
|
+
:key="renderTableKey + '_table'"
|
|
439
|
+
:row-key="rowKey ?? 'id'"
|
|
440
|
+
ref="tableEl"
|
|
441
|
+
:columns="columns.map((c) => cleanCol(c as Recordable))"
|
|
442
|
+
:data-source="tableData"
|
|
443
|
+
:loading="loading.table"
|
|
444
|
+
:pagination="pg"
|
|
445
|
+
v-bind="tc"
|
|
446
|
+
:scroll="{
|
|
446
447
|
x: 'max-content',
|
|
447
448
|
y: renderHeight,
|
|
448
449
|
}"
|
|
449
|
-
|
|
450
|
+
@change="handleTableChange"
|
|
450
451
|
>
|
|
451
452
|
<template v-if="slotTitleColumns.length > 0" #headerCell="{ column }">
|
|
452
453
|
<render-title-slots
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
v-if="slotTitleColumns.some((s) => column.key && s.field === column.key)"
|
|
455
|
+
:key="renderTableKey + '_title_' + dataSeed + '_slot_' + column.key"
|
|
456
|
+
:column="slotTitleColumns.find((f) => column.key && f.field === column.key)!"
|
|
456
457
|
/>
|
|
457
458
|
</template>
|
|
458
459
|
<template v-if="slotDefaultColumns.length > 0" #bodyCell="{ column, record, index }">
|
|
459
460
|
<render-default-slots
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
461
|
+
v-if="slotDefaultColumns.some((s) => column.key && s.field === column.key)"
|
|
462
|
+
:key="renderTableKey + '_cell_' + dataSeed + '_slot_' + column.key"
|
|
463
|
+
:column="slotDefaultColumns.find((f) => column.key && f.field === column.key)!"
|
|
464
|
+
:default-handler="{ pick: pickRow }"
|
|
465
|
+
:row="record"
|
|
466
|
+
:row-index="index"
|
|
467
|
+
:table-data="tableData as Recordable[]"
|
|
467
468
|
/>
|
|
468
469
|
</template>
|
|
469
470
|
</a-table>
|