@sdata/web-vue 3.14.0 → 3.15.0
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/sd.css +26 -3
- package/dist/sd.min.css +1 -1
- package/es/_components/resize-trigger.vue_vue_type_script_setup_true_lang.js +6 -3
- package/es/_components/select-view/select-view.js +3 -1
- package/es/alert/alert.vue_vue_type_script_setup_true_lang.js +5 -2
- package/es/anchor/anchor.vue_vue_type_script_setup_true_lang.js +5 -2
- package/es/back-top/back-top.vue_vue_type_script_setup_true_lang.js +5 -2
- package/es/basic-crud-table/basic-crud-modal.js +5 -0
- package/es/basic-crud-table/basic-crud-modal.vue.d.ts +264 -0
- package/es/basic-crud-table/basic-crud-modal.vue_vue_type_script_setup_true_lang.js +139 -0
- package/es/basic-crud-table/basic-crud-table.js +5 -0
- package/es/basic-crud-table/basic-crud-table.vue.d.ts +935 -0
- package/es/basic-crud-table/basic-crud-table.vue_vue_type_script_setup_true_lang.js +510 -0
- package/es/basic-crud-table/index.d.ts +2722 -0
- package/es/basic-crud-table/index.js +9 -0
- package/es/basic-crud-table/style/css.js +2 -0
- package/es/basic-crud-table/style/index.css +42 -0
- package/es/basic-crud-table/style/index.d.ts +2 -0
- package/es/basic-crud-table/style/index.js +2 -0
- package/es/basic-crud-table/style/index.scss +33 -0
- package/es/basic-crud-table/style/token.scss +8 -0
- package/es/basic-crud-table/types.d.ts +69 -0
- package/es/breadcrumb/breadcrumb-item.js +4 -2
- package/es/breadcrumb/breadcrumb.js +3 -1
- package/es/calendar/components/event.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/calendar/components/headings-bar.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/carousel/carousel-arrow.vue_vue_type_script_setup_true_lang.js +9 -5
- package/es/carousel/carousel-indicator.vue_vue_type_script_setup_true_lang.js +4 -2
- package/es/carousel/carousel-item.vue_vue_type_script_setup_true_lang.js +4 -2
- package/es/carousel/carousel.js +3 -1
- package/es/cascader/cascader-option.js +1 -1
- package/es/cascader/cascader.vue_vue_type_script_setup_true_lang.js +2 -2
- package/es/color-picker/panel.js +5 -3
- package/es/components.d.ts +1 -0
- package/es/copy/copy.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/date-picker/hooks/use-provide-datepicker-transform.js +1 -1
- package/es/date-picker/panels/header.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/date-picker/picker.vue_vue_type_script_setup_true_lang.js +3 -3
- package/es/date-picker/range-picker.vue_vue_type_script_setup_true_lang.js +2 -2
- package/es/drawer/drawer.vue_vue_type_script_setup_true_lang.js +4 -3
- package/es/dropdown/dropdown-button.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/dropdown/dropdown-panel.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/dropdown/dropdown-submenu.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/file-previewer/file-previewer.vue_vue_type_script_setup_true_lang.js +13 -9
- package/es/form/form-item.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/form/index.js +1 -1
- package/es/grid/grid-col.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/grid/grid-item.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/grid/grid-row.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/grid/grid.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/image/image.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/image/preview-arrow.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/image/preview.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/index.css +26 -3
- package/es/index.d.ts +2 -0
- package/es/index.js +55 -54
- package/es/index.scss +1 -0
- package/es/input/input.js +3 -1
- package/es/input-number/input-number.js +8 -6
- package/es/json-form/style/index.css +0 -3
- package/es/json-form/style/index.scss +4 -3
- package/es/json-form/utils.js +4 -4
- package/es/layout/sider.vue_vue_type_script_setup_true_lang.js +9 -7
- package/es/link/link.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/list/list.js +1 -1
- package/es/locale/interface.d.ts +39 -0
- package/es/locale/lang/ar-eg.js +38 -0
- package/es/locale/lang/de-de.js +38 -0
- package/es/locale/lang/en-us.js +38 -0
- package/es/locale/lang/es-es.js +38 -0
- package/es/locale/lang/fr-fr.js +38 -0
- package/es/locale/lang/id-id.js +38 -0
- package/es/locale/lang/it-it.js +38 -0
- package/es/locale/lang/ja-jp.js +38 -0
- package/es/locale/lang/km-kh.js +38 -0
- package/es/locale/lang/ko-kr.js +38 -0
- package/es/locale/lang/ms-my.js +38 -0
- package/es/locale/lang/nl-nl.js +38 -0
- package/es/locale/lang/pt-pt.js +38 -0
- package/es/locale/lang/ru-ru.js +38 -0
- package/es/locale/lang/th-th.js +38 -0
- package/es/locale/lang/vi-vn.js +38 -0
- package/es/locale/lang/zh-cn.js +38 -0
- package/es/locale/lang/zh-tw.js +38 -0
- package/es/menu/item.d.ts +1 -1
- package/es/modal/modal.vue_vue_type_script_setup_true_lang.js +4 -3
- package/es/overflow-list/overflow-list.js +1 -1
- package/es/page-header/page-header.vue_vue_type_script_setup_true_lang.js +8 -2
- package/es/pagination/page-item-ellipsis.vue_vue_type_script_setup_true_lang.js +5 -2
- package/es/pagination/page-item-step.vue_vue_type_script_setup_true_lang.js +5 -3
- package/es/pagination/pagination.js +1 -1
- package/es/popconfirm/popconfirm.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/qr-code/qr-code.vue_vue_type_script_setup_true_lang.js +4 -2
- package/es/rate/rate.js +3 -1
- package/es/sd-vue.js +54 -52
- package/es/secret/secret.vue_vue_type_script_setup_true_lang.js +3 -1
- package/es/select/select.js +2 -2
- package/es/statistic/statistic.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/steps/steps.vue_vue_type_script_setup_true_lang.js +6 -3
- package/es/table/index.d.ts +4 -4
- package/es/table/table-operation-td.js +3 -3
- package/es/table/table-operation-th.js +1 -1
- package/es/table/table-th.d.ts +1 -1
- package/es/table/table-th.js +3 -3
- package/es/table/table.d.ts +1 -1
- package/es/table/table.js +2 -2
- package/es/tabs/tabs-button.js +1 -1
- package/es/tag/tag.vue_vue_type_script_setup_true_lang.js +8 -2
- package/es/tag-group/tag-group.vue_vue_type_script_setup_true_lang.js +2 -2
- package/es/textarea/textarea.vue_vue_type_script_setup_true_lang.js +5 -2
- package/es/time-picker/time-picker.vue_vue_type_script_setup_true_lang.js +2 -2
- package/es/toolbar/index.d.ts +3 -3
- package/es/toolbar/toolbar.vue.d.ts +2 -2
- package/es/toolbar/toolbar.vue_vue_type_script_setup_true_lang.js +5 -5
- package/es/transfer/transfer-list-item.js +3 -1
- package/es/transfer/transfer.vue_vue_type_script_setup_true_lang.js +7 -5
- package/es/tree/base-node.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/tree/node-switcher.vue_vue_type_script_lang.js +1 -1
- package/es/typography/edit-content.vue_vue_type_script_setup_true_lang.js +8 -2
- package/es/upload/upload-list-item.js +1 -1
- package/es/upload/upload-picture-item.js +5 -3
- package/es/verification-code/verification-code.js +4 -2
- package/json/vetur-tags.json +3 -0
- package/json/web-types.json +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { getPrefixCls } from "../_utils/global-config.js";
|
|
3
|
+
import { isPromise } from "../_utils/is.js";
|
|
4
|
+
import { _asyncToGenerator } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/asyncToGenerator.js";
|
|
5
|
+
import Button from "../button/index.js";
|
|
6
|
+
import Spin from "../spin/index.js";
|
|
7
|
+
import Link from "../link/index.js";
|
|
8
|
+
import Popconfirm from "../popconfirm/index.js";
|
|
9
|
+
import Space from "../space/index.js";
|
|
10
|
+
import Table from "../table/index.js";
|
|
11
|
+
import Toolbar from "../toolbar/index.js";
|
|
12
|
+
import basic_crud_modal_default from "./basic-crud-modal.js";
|
|
13
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, onMounted, openBlock, ref, renderList, renderSlot, shallowRef, toDisplayString, unref, useModel, useSlots, withCtx } from "vue";
|
|
14
|
+
import { isFunction, isNil, isString, omitBy } from "es-toolkit";
|
|
15
|
+
//#region components/basic-crud-table/basic-crud-table.vue?vue&type=script&setup=true&lang.ts
|
|
16
|
+
var _hoisted_1 = ["aria-busy"];
|
|
17
|
+
var basic_crud_table_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, {
|
|
18
|
+
name: "BasicCrudTable",
|
|
19
|
+
inheritAttrs: false
|
|
20
|
+
}), {}, {
|
|
21
|
+
__name: "basic-crud-table",
|
|
22
|
+
props: /*@__PURE__*/ mergeModels({
|
|
23
|
+
title: {},
|
|
24
|
+
columns: {},
|
|
25
|
+
tableProps: { default: () => ({}) },
|
|
26
|
+
toolbarProps: { default: () => ({}) },
|
|
27
|
+
modalProps: { default: () => ({}) },
|
|
28
|
+
modalFormProps: { default: () => ({ schemas: [] }) },
|
|
29
|
+
showCreate: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
32
|
+
},
|
|
33
|
+
openCreateModal: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
showEdit: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true
|
|
40
|
+
},
|
|
41
|
+
showDelete: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: true
|
|
44
|
+
},
|
|
45
|
+
showToolbar: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: true
|
|
48
|
+
},
|
|
49
|
+
showHeader: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: true
|
|
52
|
+
},
|
|
53
|
+
showTitle: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: true
|
|
56
|
+
},
|
|
57
|
+
showActionColumn: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: true
|
|
60
|
+
},
|
|
61
|
+
fetchExcludeEmptyValues: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
fetchTableOnMounted: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true
|
|
68
|
+
},
|
|
69
|
+
actionWidth: { default: 120 },
|
|
70
|
+
fetchTableApi: { type: Function },
|
|
71
|
+
tableDataTransformer: { type: Function },
|
|
72
|
+
createApi: { type: Function },
|
|
73
|
+
updateApi: { type: Function },
|
|
74
|
+
detailApi: { type: Function },
|
|
75
|
+
valueTransformer: { type: Function },
|
|
76
|
+
beforeModalSubmit: { type: Function },
|
|
77
|
+
deleteContent: { type: [String, Function] },
|
|
78
|
+
deleteApi: { type: Function },
|
|
79
|
+
beforeDelete: { type: Function },
|
|
80
|
+
deleteNameKey: {}
|
|
81
|
+
}, {
|
|
82
|
+
"loading": _objectSpread2({ type: Boolean }, { default: false }),
|
|
83
|
+
"loadingModifiers": {},
|
|
84
|
+
"toolbarModel": { default: () => ({}) },
|
|
85
|
+
"toolbarModelModifiers": {},
|
|
86
|
+
"tableData": { default: () => [] },
|
|
87
|
+
"tableDataModifiers": {},
|
|
88
|
+
"modalModel": { default: () => ({}) },
|
|
89
|
+
"modalModelModifiers": {},
|
|
90
|
+
"modalVisible": _objectSpread2({ type: Boolean }, { default: false }),
|
|
91
|
+
"modalVisibleModifiers": {}
|
|
92
|
+
}),
|
|
93
|
+
emits: /*@__PURE__*/ mergeModels([
|
|
94
|
+
"create",
|
|
95
|
+
"edit",
|
|
96
|
+
"delete",
|
|
97
|
+
"reset",
|
|
98
|
+
"search",
|
|
99
|
+
"tableFetched",
|
|
100
|
+
"modalSuccess",
|
|
101
|
+
"modalClose",
|
|
102
|
+
"error"
|
|
103
|
+
], [
|
|
104
|
+
"update:loading",
|
|
105
|
+
"update:toolbarModel",
|
|
106
|
+
"update:tableData",
|
|
107
|
+
"update:modalModel",
|
|
108
|
+
"update:modalVisible"
|
|
109
|
+
]),
|
|
110
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
111
|
+
const emit = __emit;
|
|
112
|
+
const loading = useModel(__props, "loading");
|
|
113
|
+
const toolbarModel = useModel(__props, "toolbarModel");
|
|
114
|
+
const tableData = useModel(__props, "tableData");
|
|
115
|
+
const modalModel = useModel(__props, "modalModel");
|
|
116
|
+
const modalVisible = useModel(__props, "modalVisible");
|
|
117
|
+
const slots = useSlots();
|
|
118
|
+
const toolbarRef = shallowRef();
|
|
119
|
+
const modalRef = shallowRef();
|
|
120
|
+
const current = shallowRef(resolvePaginationNumber("current", "defaultCurrent", 1));
|
|
121
|
+
const pageSize = shallowRef(resolvePaginationNumber("pageSize", "defaultPageSize", 10));
|
|
122
|
+
const total = shallowRef(0);
|
|
123
|
+
const sorter = shallowRef({});
|
|
124
|
+
const fetchData = shallowRef();
|
|
125
|
+
const prefixCls = getPrefixCls("basic-crud-table");
|
|
126
|
+
const cls = computed(() => [prefixCls, { [`${prefixCls}-loading`]: loading.value }]);
|
|
127
|
+
const toolbarSlotNames = computed(() => getForwardedSlotNames("toolbar__", [
|
|
128
|
+
"default",
|
|
129
|
+
"action_prepend",
|
|
130
|
+
"action_append"
|
|
131
|
+
]));
|
|
132
|
+
const tableSlotNames = computed(() => getForwardedSlotNames("table__", ["action_prepend", "action_append"]));
|
|
133
|
+
const modalSlotNames = computed(() => getForwardedSlotNames("modal__"));
|
|
134
|
+
const resolvedColumns = computed(() => __props.showActionColumn ? [...__props.columns, {
|
|
135
|
+
title: "操作",
|
|
136
|
+
dataIndex: "__basic_crud_action__",
|
|
137
|
+
slotName: "basic-crud-action",
|
|
138
|
+
width: __props.actionWidth,
|
|
139
|
+
fixed: "right"
|
|
140
|
+
}] : __props.columns);
|
|
141
|
+
const resolvedPagination = computed(() => __props.tableProps.pagination === false ? false : _objectSpread2(_objectSpread2({}, typeof __props.tableProps.pagination === "object" ? __props.tableProps.pagination : {}), {}, {
|
|
142
|
+
current: current.value,
|
|
143
|
+
pageSize: pageSize.value,
|
|
144
|
+
total: total.value
|
|
145
|
+
}));
|
|
146
|
+
const params = computed(() => _objectSpread2(_objectSpread2({
|
|
147
|
+
current: current.value,
|
|
148
|
+
pageSize: pageSize.value
|
|
149
|
+
}, sorter.value), toolbarModel.value));
|
|
150
|
+
onMounted(() => {
|
|
151
|
+
if (__props.fetchTableOnMounted) handleFetchData();
|
|
152
|
+
});
|
|
153
|
+
function getForwardedSlotNames(prefix, excluded = []) {
|
|
154
|
+
return Object.keys(slots).filter((name) => name.startsWith(prefix)).map((name) => name.slice(prefix.length)).filter((name) => !excluded.includes(name));
|
|
155
|
+
}
|
|
156
|
+
function resolvePaginationNumber(controlled, initial, fallback) {
|
|
157
|
+
var _ref, _pagination$controlle;
|
|
158
|
+
const pagination = __props.tableProps.pagination;
|
|
159
|
+
return typeof pagination === "object" ? Number((_ref = (_pagination$controlle = pagination[controlled]) !== null && _pagination$controlle !== void 0 ? _pagination$controlle : pagination[initial]) !== null && _ref !== void 0 ? _ref : fallback) : fallback;
|
|
160
|
+
}
|
|
161
|
+
function isObjectResult(value) {
|
|
162
|
+
return !!value && typeof value === "object" && Array.isArray(value.data);
|
|
163
|
+
}
|
|
164
|
+
function handleFetchData() {
|
|
165
|
+
return _handleFetchData.apply(this, arguments);
|
|
166
|
+
}
|
|
167
|
+
function _handleFetchData() {
|
|
168
|
+
_handleFetchData = _asyncToGenerator(function* (fetchParams = params.value) {
|
|
169
|
+
if (isNil(__props.fetchTableApi)) return;
|
|
170
|
+
loading.value = true;
|
|
171
|
+
try {
|
|
172
|
+
const requestParams = __props.fetchExcludeEmptyValues ? omitBy(fetchParams, (value) => value === "" || value === null || value === void 0) : fetchParams;
|
|
173
|
+
const response = yield __props.fetchTableApi(requestParams);
|
|
174
|
+
fetchData.value = response;
|
|
175
|
+
const result = isFunction(__props.tableDataTransformer) ? yield __props.tableDataTransformer(response) : response;
|
|
176
|
+
if (Array.isArray(result)) {
|
|
177
|
+
tableData.value = result;
|
|
178
|
+
total.value = result.length;
|
|
179
|
+
} else if (isObjectResult(result)) {
|
|
180
|
+
var _ref2, _result$total;
|
|
181
|
+
tableData.value = result.data;
|
|
182
|
+
total.value = (_ref2 = (_result$total = result.total) !== null && _result$total !== void 0 ? _result$total : result.count) !== null && _ref2 !== void 0 ? _ref2 : result.data.length;
|
|
183
|
+
} else return;
|
|
184
|
+
emit("tableFetched", tableData.value, result);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
emit("error", error);
|
|
187
|
+
} finally {
|
|
188
|
+
loading.value = false;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return _handleFetchData.apply(this, arguments);
|
|
192
|
+
}
|
|
193
|
+
function handleSearch() {
|
|
194
|
+
return _handleSearch.apply(this, arguments);
|
|
195
|
+
}
|
|
196
|
+
function _handleSearch() {
|
|
197
|
+
_handleSearch = _asyncToGenerator(function* () {
|
|
198
|
+
current.value = 1;
|
|
199
|
+
yield handleFetchData();
|
|
200
|
+
emit("search", toolbarModel.value);
|
|
201
|
+
});
|
|
202
|
+
return _handleSearch.apply(this, arguments);
|
|
203
|
+
}
|
|
204
|
+
function handleReset() {
|
|
205
|
+
return _handleReset.apply(this, arguments);
|
|
206
|
+
}
|
|
207
|
+
function _handleReset() {
|
|
208
|
+
_handleReset = _asyncToGenerator(function* () {
|
|
209
|
+
current.value = 1;
|
|
210
|
+
sorter.value = {};
|
|
211
|
+
yield nextTick();
|
|
212
|
+
yield handleFetchData();
|
|
213
|
+
emit("reset");
|
|
214
|
+
});
|
|
215
|
+
return _handleReset.apply(this, arguments);
|
|
216
|
+
}
|
|
217
|
+
/** 仅重置工具栏筛选项,不触发列表请求。 */
|
|
218
|
+
function resetToolbar() {
|
|
219
|
+
var _toolbarRef$value;
|
|
220
|
+
(_toolbarRef$value = toolbarRef.value) === null || _toolbarRef$value === void 0 || _toolbarRef$value.reset(false);
|
|
221
|
+
}
|
|
222
|
+
/** 重置工具栏筛选、分页与排序,并重新请求列表。 */
|
|
223
|
+
function reset() {
|
|
224
|
+
return _reset.apply(this, arguments);
|
|
225
|
+
}
|
|
226
|
+
function _reset() {
|
|
227
|
+
_reset = _asyncToGenerator(function* () {
|
|
228
|
+
resetToolbar();
|
|
229
|
+
yield handleReset();
|
|
230
|
+
});
|
|
231
|
+
return _reset.apply(this, arguments);
|
|
232
|
+
}
|
|
233
|
+
function handleCreate() {
|
|
234
|
+
var _modalRef$value;
|
|
235
|
+
if (__props.openCreateModal) (_modalRef$value = modalRef.value) === null || _modalRef$value === void 0 || _modalRef$value.open();
|
|
236
|
+
emit("create");
|
|
237
|
+
}
|
|
238
|
+
function handleEdit(_x, _x2) {
|
|
239
|
+
return _handleEdit.apply(this, arguments);
|
|
240
|
+
}
|
|
241
|
+
function _handleEdit() {
|
|
242
|
+
_handleEdit = _asyncToGenerator(function* (row, context) {
|
|
243
|
+
var _modalRef$value2;
|
|
244
|
+
yield (_modalRef$value2 = modalRef.value) === null || _modalRef$value2 === void 0 ? void 0 : _modalRef$value2.open(row);
|
|
245
|
+
emit("edit", row, context);
|
|
246
|
+
});
|
|
247
|
+
return _handleEdit.apply(this, arguments);
|
|
248
|
+
}
|
|
249
|
+
const deleteConfirmContent = ref("确定要删除此条记录吗?");
|
|
250
|
+
const pendingDeleteRow = shallowRef();
|
|
251
|
+
function resolveDeleteContent(row) {
|
|
252
|
+
if (isString(__props.deleteContent)) return __props.deleteContent;
|
|
253
|
+
if (isFunction(__props.deleteContent)) return __props.deleteContent(row);
|
|
254
|
+
const name = __props.deleteNameKey ? row[__props.deleteNameKey] : void 0;
|
|
255
|
+
return name ? `确定删除【${String(name)}】吗?` : "确定要删除此条记录吗?";
|
|
256
|
+
}
|
|
257
|
+
function handleDeletePopupChange(visible, row) {
|
|
258
|
+
if (!visible) return;
|
|
259
|
+
pendingDeleteRow.value = row;
|
|
260
|
+
const resolved = resolveDeleteContent(row);
|
|
261
|
+
if (isPromise(resolved)) resolved.then((content) => {
|
|
262
|
+
if (pendingDeleteRow.value === row) deleteConfirmContent.value = content;
|
|
263
|
+
});
|
|
264
|
+
else deleteConfirmContent.value = resolved;
|
|
265
|
+
}
|
|
266
|
+
function executeDelete(_x3, _x4) {
|
|
267
|
+
return _executeDelete.apply(this, arguments);
|
|
268
|
+
}
|
|
269
|
+
function _executeDelete() {
|
|
270
|
+
_executeDelete = _asyncToGenerator(function* (row, context) {
|
|
271
|
+
if (__props.beforeDelete && (yield __props.beforeDelete(row)) === false) return false;
|
|
272
|
+
emit("delete", row, context);
|
|
273
|
+
try {
|
|
274
|
+
if (__props.deleteApi) yield __props.deleteApi(row);
|
|
275
|
+
yield handleFetchData();
|
|
276
|
+
return true;
|
|
277
|
+
} catch (error) {
|
|
278
|
+
emit("error", error);
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
return _executeDelete.apply(this, arguments);
|
|
283
|
+
}
|
|
284
|
+
function handleDeleteConfirm() {
|
|
285
|
+
const row = pendingDeleteRow.value;
|
|
286
|
+
if (!row) return Promise.resolve(false);
|
|
287
|
+
return executeDelete(row);
|
|
288
|
+
}
|
|
289
|
+
function handleModalSuccess(_x5, _x6) {
|
|
290
|
+
return _handleModalSuccess.apply(this, arguments);
|
|
291
|
+
}
|
|
292
|
+
function _handleModalSuccess() {
|
|
293
|
+
_handleModalSuccess = _asyncToGenerator(function* (result, context) {
|
|
294
|
+
yield handleFetchData();
|
|
295
|
+
emit("modalSuccess", result, context);
|
|
296
|
+
});
|
|
297
|
+
return _handleModalSuccess.apply(this, arguments);
|
|
298
|
+
}
|
|
299
|
+
function handlePageChange(_x7) {
|
|
300
|
+
return _handlePageChange.apply(this, arguments);
|
|
301
|
+
}
|
|
302
|
+
function _handlePageChange() {
|
|
303
|
+
_handlePageChange = _asyncToGenerator(function* (value) {
|
|
304
|
+
current.value = value;
|
|
305
|
+
yield handleFetchData();
|
|
306
|
+
});
|
|
307
|
+
return _handlePageChange.apply(this, arguments);
|
|
308
|
+
}
|
|
309
|
+
function handlePageSizeChange(_x8) {
|
|
310
|
+
return _handlePageSizeChange.apply(this, arguments);
|
|
311
|
+
}
|
|
312
|
+
function _handlePageSizeChange() {
|
|
313
|
+
_handlePageSizeChange = _asyncToGenerator(function* (value) {
|
|
314
|
+
pageSize.value = value;
|
|
315
|
+
current.value = 1;
|
|
316
|
+
yield handleFetchData();
|
|
317
|
+
});
|
|
318
|
+
return _handlePageSizeChange.apply(this, arguments);
|
|
319
|
+
}
|
|
320
|
+
function handleTableChange(_x9, _x10) {
|
|
321
|
+
return _handleTableChange.apply(this, arguments);
|
|
322
|
+
}
|
|
323
|
+
function _handleTableChange() {
|
|
324
|
+
_handleTableChange = _asyncToGenerator(function* (_data, extra) {
|
|
325
|
+
var _extra$sorter;
|
|
326
|
+
if (extra.type !== "sorter") return;
|
|
327
|
+
sorter.value = ((_extra$sorter = extra.sorter) === null || _extra$sorter === void 0 ? void 0 : _extra$sorter.field) && extra.sorter.direction ? { sort_by: extra.sorter.direction === "descend" ? `-${extra.sorter.field}` : extra.sorter.field } : {};
|
|
328
|
+
current.value = 1;
|
|
329
|
+
yield handleFetchData();
|
|
330
|
+
});
|
|
331
|
+
return _handleTableChange.apply(this, arguments);
|
|
332
|
+
}
|
|
333
|
+
__expose({
|
|
334
|
+
fetchTableData: handleFetchData,
|
|
335
|
+
search: handleSearch,
|
|
336
|
+
/** 重置工具栏筛选 + 分页/排序并刷新(全量重置)。 */
|
|
337
|
+
reset,
|
|
338
|
+
/** 仅重置工具栏筛选项,不刷新。 */
|
|
339
|
+
resetToolbar,
|
|
340
|
+
/** 仅重置分页/排序并刷新,不动工具栏。 */
|
|
341
|
+
resetTable: handleReset,
|
|
342
|
+
create: handleCreate,
|
|
343
|
+
edit: handleEdit,
|
|
344
|
+
delete: executeDelete,
|
|
345
|
+
tableData: computed(() => tableData.value),
|
|
346
|
+
fetchData: computed(() => fetchData.value),
|
|
347
|
+
isCreate: computed(() => {
|
|
348
|
+
var _modalRef$value3;
|
|
349
|
+
return ((_modalRef$value3 = modalRef.value) === null || _modalRef$value3 === void 0 ? void 0 : _modalRef$value3.type) === "create";
|
|
350
|
+
}),
|
|
351
|
+
modalRef
|
|
352
|
+
});
|
|
353
|
+
return (_ctx, _cache) => {
|
|
354
|
+
return openBlock(), createElementBlock("section", {
|
|
355
|
+
class: normalizeClass(cls.value),
|
|
356
|
+
"aria-busy": loading.value
|
|
357
|
+
}, [
|
|
358
|
+
__props.showHeader ? (openBlock(), createElementBlock("header", {
|
|
359
|
+
key: 0,
|
|
360
|
+
class: normalizeClass(`${unref(prefixCls)}-header`)
|
|
361
|
+
}, [
|
|
362
|
+
renderSlot(_ctx.$slots, "header__title", { title: __props.title }, () => [__props.showTitle && __props.title ? (openBlock(), createElementBlock("h3", {
|
|
363
|
+
key: 0,
|
|
364
|
+
class: normalizeClass(`${unref(prefixCls)}-title`)
|
|
365
|
+
}, toDisplayString(__props.title), 3)) : createCommentVNode("", true)]),
|
|
366
|
+
renderSlot(_ctx.$slots, "header__extra"),
|
|
367
|
+
!__props.showToolbar && __props.showCreate ? (openBlock(), createElementBlock("div", {
|
|
368
|
+
key: 0,
|
|
369
|
+
class: normalizeClass(`${unref(prefixCls)}-header-actions`)
|
|
370
|
+
}, [createVNode(unref(Button), {
|
|
371
|
+
type: "primary",
|
|
372
|
+
onClick: handleCreate
|
|
373
|
+
}, {
|
|
374
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("新建", -1)])]),
|
|
375
|
+
_: 1
|
|
376
|
+
})], 2)) : createCommentVNode("", true),
|
|
377
|
+
__props.showToolbar ? (openBlock(), createBlock(unref(Toolbar), mergeProps({
|
|
378
|
+
key: 1,
|
|
379
|
+
ref_key: "toolbarRef",
|
|
380
|
+
ref: toolbarRef,
|
|
381
|
+
modelValue: toolbarModel.value,
|
|
382
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => toolbarModel.value = $event)
|
|
383
|
+
}, __props.toolbarProps, {
|
|
384
|
+
loading: loading.value,
|
|
385
|
+
onSearch: handleSearch,
|
|
386
|
+
onReset: handleReset
|
|
387
|
+
}), createSlots({
|
|
388
|
+
"action-append": withCtx(() => [renderSlot(_ctx.$slots, "toolbar__action_append"), __props.showCreate ? (openBlock(), createBlock(unref(Button), {
|
|
389
|
+
key: 0,
|
|
390
|
+
type: "primary",
|
|
391
|
+
onClick: handleCreate
|
|
392
|
+
}, {
|
|
393
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("新建", -1)])]),
|
|
394
|
+
_: 1
|
|
395
|
+
})) : createCommentVNode("", true)]),
|
|
396
|
+
_: 2
|
|
397
|
+
}, [
|
|
398
|
+
_ctx.$slots.toolbar__default ? {
|
|
399
|
+
name: "default",
|
|
400
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "toolbar__default")]),
|
|
401
|
+
key: "0"
|
|
402
|
+
} : void 0,
|
|
403
|
+
_ctx.$slots.toolbar__action_prepend ? {
|
|
404
|
+
name: "action-prepend",
|
|
405
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "toolbar__action_prepend")]),
|
|
406
|
+
key: "1"
|
|
407
|
+
} : void 0,
|
|
408
|
+
renderList(toolbarSlotNames.value, (name) => {
|
|
409
|
+
return {
|
|
410
|
+
name,
|
|
411
|
+
fn: withCtx((data) => [renderSlot(_ctx.$slots, `toolbar__${name}`, normalizeProps(guardReactiveProps(data)))])
|
|
412
|
+
};
|
|
413
|
+
})
|
|
414
|
+
]), 1040, ["modelValue", "loading"])) : createCommentVNode("", true)
|
|
415
|
+
], 2)) : createCommentVNode("", true),
|
|
416
|
+
createVNode(unref(Spin), {
|
|
417
|
+
loading: loading.value,
|
|
418
|
+
class: normalizeClass(`${unref(prefixCls)}-body`)
|
|
419
|
+
}, {
|
|
420
|
+
default: withCtx(() => [createVNode(unref(Table), mergeProps(__props.tableProps, {
|
|
421
|
+
columns: resolvedColumns.value,
|
|
422
|
+
data: tableData.value,
|
|
423
|
+
pagination: resolvedPagination.value,
|
|
424
|
+
onPageChange: handlePageChange,
|
|
425
|
+
onPageSizeChange: handlePageSizeChange,
|
|
426
|
+
onChange: handleTableChange
|
|
427
|
+
}), createSlots({
|
|
428
|
+
"basic-crud-action": withCtx((data) => [createVNode(unref(Space), null, {
|
|
429
|
+
default: withCtx(() => [
|
|
430
|
+
renderSlot(_ctx.$slots, "table__action_prepend", normalizeProps(guardReactiveProps(data))),
|
|
431
|
+
__props.showEdit ? (openBlock(), createBlock(unref(Link), {
|
|
432
|
+
key: 0,
|
|
433
|
+
ellipsis: false,
|
|
434
|
+
onClick: ($event) => handleEdit(data.record, data)
|
|
435
|
+
}, {
|
|
436
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode(" 编辑 ", -1)])]),
|
|
437
|
+
_: 1
|
|
438
|
+
}, 8, ["onClick"])) : createCommentVNode("", true),
|
|
439
|
+
__props.showDelete ? (openBlock(), createBlock(unref(Popconfirm), {
|
|
440
|
+
key: 1,
|
|
441
|
+
content: deleteConfirmContent.value,
|
|
442
|
+
type: "warning",
|
|
443
|
+
"on-before-ok": handleDeleteConfirm,
|
|
444
|
+
onPopupVisibleChange: (visible) => handleDeletePopupChange(visible, data.record)
|
|
445
|
+
}, {
|
|
446
|
+
default: withCtx(() => [createVNode(unref(Link), {
|
|
447
|
+
ellipsis: false,
|
|
448
|
+
status: "danger"
|
|
449
|
+
}, {
|
|
450
|
+
default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("删除", -1)])]),
|
|
451
|
+
_: 1
|
|
452
|
+
})]),
|
|
453
|
+
_: 1
|
|
454
|
+
}, 8, ["content", "onPopupVisibleChange"])) : createCommentVNode("", true),
|
|
455
|
+
renderSlot(_ctx.$slots, "table__action_append", normalizeProps(guardReactiveProps(data)))
|
|
456
|
+
]),
|
|
457
|
+
_: 2
|
|
458
|
+
}, 1024)]),
|
|
459
|
+
_: 2
|
|
460
|
+
}, [renderList(tableSlotNames.value, (name) => {
|
|
461
|
+
return {
|
|
462
|
+
name,
|
|
463
|
+
fn: withCtx((data) => [renderSlot(_ctx.$slots, `table__${name}`, normalizeProps(guardReactiveProps(data)))])
|
|
464
|
+
};
|
|
465
|
+
})]), 1040, [
|
|
466
|
+
"columns",
|
|
467
|
+
"data",
|
|
468
|
+
"pagination"
|
|
469
|
+
])]),
|
|
470
|
+
_: 3
|
|
471
|
+
}, 8, ["loading", "class"]),
|
|
472
|
+
createVNode(basic_crud_modal_default, {
|
|
473
|
+
ref_key: "modalRef",
|
|
474
|
+
ref: modalRef,
|
|
475
|
+
visible: modalVisible.value,
|
|
476
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => modalVisible.value = $event),
|
|
477
|
+
model: modalModel.value,
|
|
478
|
+
"onUpdate:model": _cache[2] || (_cache[2] = ($event) => modalModel.value = $event),
|
|
479
|
+
"modal-props": __props.modalProps,
|
|
480
|
+
"modal-form-props": __props.modalFormProps,
|
|
481
|
+
"create-api": __props.createApi,
|
|
482
|
+
"update-api": __props.updateApi,
|
|
483
|
+
"detail-api": __props.detailApi,
|
|
484
|
+
"value-transformer": __props.valueTransformer,
|
|
485
|
+
"before-submit": __props.beforeModalSubmit,
|
|
486
|
+
onSuccess: handleModalSuccess,
|
|
487
|
+
onClose: _cache[3] || (_cache[3] = ($event) => emit("modalClose")),
|
|
488
|
+
onError: _cache[4] || (_cache[4] = ($event) => emit("error", $event))
|
|
489
|
+
}, createSlots({ _: 2 }, [renderList(modalSlotNames.value, (name) => {
|
|
490
|
+
return {
|
|
491
|
+
name,
|
|
492
|
+
fn: withCtx((data) => [renderSlot(_ctx.$slots, `modal__${name}`, normalizeProps(guardReactiveProps(data)))])
|
|
493
|
+
};
|
|
494
|
+
})]), 1032, [
|
|
495
|
+
"visible",
|
|
496
|
+
"model",
|
|
497
|
+
"modal-props",
|
|
498
|
+
"modal-form-props",
|
|
499
|
+
"create-api",
|
|
500
|
+
"update-api",
|
|
501
|
+
"detail-api",
|
|
502
|
+
"value-transformer",
|
|
503
|
+
"before-submit"
|
|
504
|
+
])
|
|
505
|
+
], 10, _hoisted_1);
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}));
|
|
509
|
+
//#endregion
|
|
510
|
+
export { basic_crud_table_vue_vue_type_script_setup_true_lang_default as default };
|