cosey 0.2.22 → 0.2.23
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/components/table/table.vue.d.ts +2 -2
- package/components/table/table.vue.js +31 -2
- package/locale/lang/ar.d.ts +1 -0
- package/locale/lang/ar.js +2 -1
- package/locale/lang/en.d.ts +1 -0
- package/locale/lang/en.js +2 -1
- package/locale/lang/zh-cn.d.ts +1 -0
- package/locale/lang/zh-cn.js +2 -1
- package/package.json +1 -1
- package/utils/excel/index.d.ts +5 -0
- package/utils/excel/index.js +1 -1
- package/utils/index.js +2 -2
- package/utils/vue.d.ts +4 -0
- package/utils/vue.js +14 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PaginationProps } from 'element-plus';
|
|
1
|
+
import { type PaginationProps, type TableColumnCtx } from 'element-plus';
|
|
2
2
|
import { type TableSlots, type TableExpose, type ToolbarConfig } from './table';
|
|
3
3
|
import { type TableColumnProps } from './table-column/table-column';
|
|
4
4
|
type __VLS_Slots = TableSlots;
|
|
@@ -153,7 +153,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
153
153
|
scrollTo: (options: number | ScrollToOptions, yCoord?: number) => void;
|
|
154
154
|
setScrollTop: (top?: number) => void;
|
|
155
155
|
setScrollLeft: (left?: number) => void;
|
|
156
|
-
columns:
|
|
156
|
+
columns: TableColumnCtx<any>[];
|
|
157
157
|
updateKeyChildren: (key: string, data: any[]) => void;
|
|
158
158
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
159
159
|
api: {
|
|
@@ -12,11 +12,12 @@ import { filterEmptyFormValue } from './utils.js';
|
|
|
12
12
|
import stdin_default$1 from './style/index.js';
|
|
13
13
|
import { useComponentConfig, useConfig } from '../config-provider/config-provider.js';
|
|
14
14
|
import { isNullish, isObject, isFunction } from '../../utils/is.js';
|
|
15
|
+
import { flatColumns } from '../../utils/excel/index.js';
|
|
16
|
+
import { getVNodeText, createMergedExpose } from '../../utils/vue.js';
|
|
15
17
|
import { useFetch } from '../../hooks/useFetch.js';
|
|
16
18
|
import { useFullPage } from '../../hooks/useFullPage.js';
|
|
17
19
|
import { useLocale } from '../../hooks/useLocale.js';
|
|
18
20
|
import { addPxUnit } from '../../utils/css.js';
|
|
19
|
-
import { createMergedExpose } from '../../utils/vue.js';
|
|
20
21
|
import { walkTree } from '../../utils/tree.js';
|
|
21
22
|
|
|
22
23
|
const _hoisted_1 = {
|
|
@@ -115,6 +116,34 @@ var stdin_default = /* @__PURE__ */defineComponent({
|
|
|
115
116
|
setRenderedColumns();
|
|
116
117
|
};
|
|
117
118
|
const tableData = ref(props.data || []);
|
|
119
|
+
const tableDataWithSummary = computed(() => {
|
|
120
|
+
const columns = flatColumns(props.columns);
|
|
121
|
+
const data = [...tableData.value];
|
|
122
|
+
if (props.summaryMethod) {
|
|
123
|
+
const sum = props.summaryMethod({
|
|
124
|
+
columns,
|
|
125
|
+
data: tableData.value
|
|
126
|
+
});
|
|
127
|
+
data.push(columns.reduce((row, column, index) => {
|
|
128
|
+
row[column.prop] = getVNodeText(sum[index]);
|
|
129
|
+
return row;
|
|
130
|
+
}, {}));
|
|
131
|
+
} else if (props.showSummary) {
|
|
132
|
+
const sum = columns.map(column => {
|
|
133
|
+
const data2 = tableData.value.map(row => +row[column.prop]);
|
|
134
|
+
if (data2.some(num => isNaN(num))) {
|
|
135
|
+
return "";
|
|
136
|
+
}
|
|
137
|
+
return String(data2.reduce((sum2, num) => sum2 + num, 0));
|
|
138
|
+
});
|
|
139
|
+
sum[0] = props.sumText || t("co.table.total");
|
|
140
|
+
data.push(columns.reduce((row, column, index) => {
|
|
141
|
+
row[column.prop] = sum[index];
|
|
142
|
+
return row;
|
|
143
|
+
}, {}));
|
|
144
|
+
}
|
|
145
|
+
return data;
|
|
146
|
+
});
|
|
118
147
|
const getFetchParams = () => {
|
|
119
148
|
const params = {
|
|
120
149
|
...orderParams,
|
|
@@ -341,7 +370,7 @@ var stdin_default = /* @__PURE__ */defineComponent({
|
|
|
341
370
|
title: unref(t)("co.table.exportData"),
|
|
342
371
|
config: mergedToolbarConfig.value.export,
|
|
343
372
|
columns: exportColumns.value,
|
|
344
|
-
data:
|
|
373
|
+
data: tableDataWithSummary.value
|
|
345
374
|
}, null, 8, ["modelValue", "title", "config", "columns", "data"])])) : createCommentVNode("v-if", true), mergedToolbarConfig.value.fullScreen ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(_component_el_tooltip, {
|
|
346
375
|
content: unref(isFullPage) ? unref(t)("co.table.exitFullScreen") : unref(t)("co.table.fullScreen"),
|
|
347
376
|
placement: "top",
|
package/locale/lang/ar.d.ts
CHANGED
package/locale/lang/ar.js
CHANGED
|
@@ -66,7 +66,8 @@ var stdin_default = {
|
|
|
66
66
|
selectField: "\u0627\u062E\u062A\u064A\u0627\u0631 \u0627\u0644\u062D\u0642\u0644",
|
|
67
67
|
paramConfig: "\u0636\u0628\u0637 \u0627\u0644\u0645\u0639\u0627\u064A\u064A\u0631",
|
|
68
68
|
header: "\u0631\u0623\u0633 \u0627\u0644\u062C\u062F\u0648\u0644",
|
|
69
|
-
groupHeader: "\u0631\u0623\u0633 \u0627\u0644\u0645\u062C\u0645\u0648\u0639\u0629"
|
|
69
|
+
groupHeader: "\u0631\u0623\u0633 \u0627\u0644\u0645\u062C\u0645\u0648\u0639\u0629",
|
|
70
|
+
total: "\u0627\u0644\u0645\u062C\u0645\u0648\u0639"
|
|
70
71
|
},
|
|
71
72
|
toggle: {
|
|
72
73
|
unfold: "\u0625\u0638\u0647\u0627\u0631",
|
package/locale/lang/en.d.ts
CHANGED
package/locale/lang/en.js
CHANGED
package/locale/lang/zh-cn.d.ts
CHANGED
package/locale/lang/zh-cn.js
CHANGED
|
@@ -66,7 +66,8 @@ var stdin_default = {
|
|
|
66
66
|
selectField: "\u9009\u62E9\u5B57\u6BB5",
|
|
67
67
|
paramConfig: "\u53C2\u6570\u914D\u7F6E",
|
|
68
68
|
header: "\u8868\u5934",
|
|
69
|
-
groupHeader: "\u5206\u7EC4\u8868\u5934"
|
|
69
|
+
groupHeader: "\u5206\u7EC4\u8868\u5934",
|
|
70
|
+
total: "\u5408\u8BA1"
|
|
70
71
|
},
|
|
71
72
|
toggle: {
|
|
72
73
|
unfold: "\u5C55\u5F00",
|
package/package.json
CHANGED
package/utils/excel/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { bookFormats } from './bookFormats';
|
|
2
2
|
import type { ExportBookType, ExportExcelScheme } from './type';
|
|
3
|
+
import { type TableColumnProps } from '../../components/table/table-column/table-column';
|
|
4
|
+
/**
|
|
5
|
+
* 只取最底层的列组成表头
|
|
6
|
+
*/
|
|
7
|
+
export declare function flatColumns(columns: TableColumnProps[]): TableColumnProps[];
|
|
3
8
|
/**
|
|
4
9
|
* 根据数据和配置,导出 excel 文件
|
|
5
10
|
*/
|
package/utils/excel/index.js
CHANGED
package/utils/index.js
CHANGED
|
@@ -4,14 +4,14 @@ export { getControlKey } from './browser.js';
|
|
|
4
4
|
export { getLabelByValue, getTreeLabelByValue } from './collection.js';
|
|
5
5
|
export { addPxUnit, cssObjectToString, getContextBoxWidth, getDir, getStyle, setStyle } from './css.js';
|
|
6
6
|
export { DATE_FORMAT, DATE_TIME_FORMAT, MONTH_FORMAT, TIME_FORMAT, YEAR_FORMAT, formatAsBasicDateTime, formatAsDate, formatAsDateTime, getDayjs } from './date.js';
|
|
7
|
-
export { exportExcel } from './excel/index.js';
|
|
7
|
+
export { exportExcel, flatColumns } from './excel/index.js';
|
|
8
8
|
export { chooseFiles, getFileType, readAsArrayBuffer, readAsDataURL } from './file.js';
|
|
9
9
|
export { isBoolean, isEmpty, isFunction, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isString, isUndefined } from './is.js';
|
|
10
10
|
export { minmax } from './number.js';
|
|
11
11
|
export { deepAssign, initObject, omitObject, omitUndefined, uniformAssign } from './object.js';
|
|
12
12
|
export { getBasename, getExtname } from './path.js';
|
|
13
13
|
export { uniqid, uuid } from './string.js';
|
|
14
|
-
export { Scope, addNullablePlaceholder, createMergedExpose, defineTemplate } from './vue.js';
|
|
14
|
+
export { Scope, addNullablePlaceholder, createMergedExpose, defineTemplate, getVNodeText } from './vue.js';
|
|
15
15
|
export { note, noteOnce, resetWarned, warning, warningOnce } from './warning.js';
|
|
16
16
|
export { findCSSNode, insertCSS, removeCSS, updateCSS, updateCSSByStyle } from './dynamicCSS.js';
|
|
17
17
|
export { sleep } from './sleep.js';
|
package/utils/vue.d.ts
CHANGED
|
@@ -21,3 +21,7 @@ export declare function createMergedExpose<T = any>(keys: string[], ...exposeLis
|
|
|
21
21
|
* 如果值为空时展示占位符,否则显示值
|
|
22
22
|
*/
|
|
23
23
|
export declare function addNullablePlaceholder<T = unknown>(value: T, converter?: (value: NonNullable<T>) => any): string;
|
|
24
|
+
/**
|
|
25
|
+
* 获取 VNode 中的文本
|
|
26
|
+
*/
|
|
27
|
+
export declare function getVNodeText(vnode: unknown): string;
|
package/utils/vue.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, createVNode } from 'vue';
|
|
2
|
+
import { isObject } from './is.js';
|
|
2
3
|
|
|
3
4
|
function defineTemplate(callback) {
|
|
4
5
|
return {
|
|
@@ -37,5 +38,17 @@ function addNullablePlaceholder(value, converter) {
|
|
|
37
38
|
}
|
|
38
39
|
return converter ? converter(value) : value;
|
|
39
40
|
}
|
|
41
|
+
function getVNodeText(vnode) {
|
|
42
|
+
if (typeof vnode === "string" || typeof vnode === "number") {
|
|
43
|
+
return String(vnode);
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(vnode)) {
|
|
46
|
+
return vnode.map(getVNodeText).join("");
|
|
47
|
+
}
|
|
48
|
+
if (isObject(vnode) && vnode.children) {
|
|
49
|
+
return getVNodeText(vnode.children);
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
40
53
|
|
|
41
|
-
export { Scope, addNullablePlaceholder, createMergedExpose, defineTemplate };
|
|
54
|
+
export { Scope, addNullablePlaceholder, createMergedExpose, defineTemplate, getVNodeText };
|