@platox/pivot-table 0.0.34 → 0.0.35
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/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js +72 -81
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.d.ts +1 -5
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js +11 -20
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.d.ts +4 -2
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.d.ts +1 -8
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +11 -20
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.d.ts +1 -7
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js +11 -20
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js +5 -7
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.d.ts +7 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js +10 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.d.ts +22 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js +29 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/Empty.d.ts +5 -0
- package/es/dashboard-workbench/components/module-content/chart-module/Empty.js +30 -0
- package/es/dashboard-workbench/components/module-content/chart-module/Empty.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/index.js +39 -17
- package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/utils.js.map +1 -1
- package/es/dashboard-workbench/components/ui/modal/editor-header.d.ts +12 -0
- package/es/dashboard-workbench/components/ui/modal/editor-header.js +59 -0
- package/es/dashboard-workbench/components/ui/modal/editor-header.js.map +1 -0
- package/es/dashboard-workbench/components/ui/modal/index.module.less.js +9 -0
- package/es/dashboard-workbench/components/ui/modal/index.module.less.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-empty.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-empty.js +139 -0
- package/es/dashboard-workbench/icon/icon-empty.js.map +1 -0
- package/es/dashboard-workbench/index.js +34 -55
- package/es/dashboard-workbench/index.js.map +1 -1
- package/es/dashboard-workbench/lang/en-US.d.ts +1 -0
- package/es/dashboard-workbench/lang/en-US.js +3 -2
- package/es/dashboard-workbench/lang/en-US.js.map +1 -1
- package/es/dashboard-workbench/lang/zh-CN.d.ts +1 -0
- package/es/dashboard-workbench/lang/zh-CN.js +2 -1
- package/es/dashboard-workbench/lang/zh-CN.js.map +1 -1
- package/es/style.css +1 -1
- package/package.json +8 -2
- package/umd/pivot-table.umd.cjs +49 -49
- package/umd/style.css +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/add-module-modal/add-chart-modal/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react'\nimport { Button, Modal, Tabs } from 'antd'\nimport { CloseOutlined } from '@ant-design/icons'\nimport CustomData, { ChartCustomeDataTypes } from './custome-data'\nimport CustomeStyles
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/add-module-modal/add-chart-modal/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react'\nimport { Button, Modal, Tabs } from 'antd'\nimport { CloseOutlined } from '@ant-design/icons'\nimport CustomData, { ChartCustomeDataTypes } from './custome-data'\nimport CustomeStyles from './custome-styles'\nimport { EnumDataApi, ModuleDataApi } from '../../../types'\nimport ChartModule from '../../module-content/chart-module'\nimport { ModuleData } from '../../module-content'\nimport { useTranslation } from 'react-i18next'\nimport EditorHeader from '@platox/pivot-table/dashboard-workbench/components/ui/modal/editor-header'\n\ninterface AddStatisticsModalProps {\n open: boolean\n onClose?: () => void\n onOk?: (data: Partial<ModuleData>) => void\n\n selectModuleData?: ModuleData\n moduleDataApi?: ModuleDataApi\n enumDataApi?: EnumDataApi\n}\n\nconst AddStatisticsModal: React.FC<AddStatisticsModalProps> = ({\n open,\n onClose,\n onOk,\n moduleDataApi,\n selectModuleData,\n enumDataApi,\n}) => {\n const { t } = useTranslation()\n const [customData, setCustomData] = useState<ChartCustomeDataTypes>()\n const [customeStyle, setCustomeStyle] = useState<any>()\n\n useEffect(() => {\n if (selectModuleData) {\n setCustomData(selectModuleData?.customData)\n setCustomeStyle(selectModuleData?.customeStyle)\n }\n }, [selectModuleData])\n\n /* ============================== split =============================== */\n const [title, setTitle] = useState<string>('')\n useEffect(() => {\n if (open) {\n setTitle(!!selectModuleData?.title ? selectModuleData?.title : t('chartText'))\n }\n }, [open])\n\n return (\n <>\n <Modal\n width=\"65%\"\n title={<EditorHeader value={title} onChange={setTitle} />}\n footer={null}\n open={open}\n onCancel={onClose}\n destroyOnClose\n closeIcon={<CloseOutlined />}\n className=\"ow\"\n >\n <div className=\"config-widget-dialog-container\">\n <div className=\"config-widget-dialog-content\">\n <div className=\"config-widget-dialog-preview\">\n <ChartModule\n customData={customData}\n customeStyle={customeStyle}\n moduleDataApi={moduleDataApi}\n />\n </div>\n </div>\n <div className=\"config-widget-dialog-panel\">\n <div className=\"bitable-dashboard edit-panel-container\">\n <Tabs\n defaultActiveKey=\"1\"\n items={[\n {\n key: '1',\n label: t('typeData'),\n children: (\n <CustomData\n enumDataApi={enumDataApi}\n selectModuleData={selectModuleData}\n onAllValuesChange={allVal => {\n setCustomData(allVal)\n }}\n />\n ),\n },\n {\n key: '2',\n label: t('customStyle'),\n children: (\n <CustomeStyles\n customData={customData}\n selectModuleData={selectModuleData}\n onAllValuesChange={allVal => {\n setCustomeStyle(allVal)\n }}\n />\n ),\n },\n ]}\n />\n </div>\n <div className=\"button-container\">\n <Button\n type=\"primary\"\n onClick={() => {\n onOk?.({\n id: selectModuleData?.id,\n type: selectModuleData?.type,\n customData,\n customeStyle,\n title,\n })\n }}\n >\n {t('confirm')}\n </Button>\n </div>\n </div>\n </div>\n </Modal>\n </>\n )\n}\n\nexport default AddStatisticsModal\n"],"names":[],"mappings":";;;;;;;;;AAsBA,MAAM,qBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,EAAE,IAAI,eAAe;AAC7B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAgC;AACpE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAc;AAEtD,YAAU,MAAM;AACd,QAAI,kBAAkB;AACpB,oBAAc,qDAAkB,UAAU;AAC1C,sBAAgB,qDAAkB,YAAY;AAAA,IAAA;AAAA,EAChD,GACC,CAAC,gBAAgB,CAAC;AAGrB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAiB,EAAE;AAC7C,YAAU,MAAM;AACd,QAAI,MAAM;AACC,eAAA,CAAC,EAAC,qDAAkB,SAAQ,qDAAkB,QAAQ,EAAE,WAAW,CAAC;AAAA,IAAA;AAAA,EAC/E,GACC,CAAC,IAAI,CAAC;AAET,SAEI,oBAAA,UAAA,EAAA,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAM;AAAA,MACN,OAAQ,oBAAA,cAAA,EAAa,OAAO,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ACA;AAAA,kBACA;AAAA,gBAAA;AAAA,cAEJ;AAAA,cAEC,YAAE,SAAS;AAAA,YAAA;AAAA,UAAA,EAEhB,CAAA;AAAA,QAAA,EACF,CAAA;AAAA,MAAA,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { StatisticsCustomeDataTypes } from './custome-data';
|
|
3
|
-
import { StatisticsCustomeStylesTypes } from './custome-styles';
|
|
4
2
|
import { ModuleDataApi } from '../../../types';
|
|
5
3
|
import { ModuleData } from '../../module-content';
|
|
6
4
|
interface AddStatisticsModalProps {
|
|
7
5
|
open: boolean;
|
|
8
6
|
onClose?: () => void;
|
|
7
|
+
onOk?: (data: Partial<ModuleData>) => void;
|
|
9
8
|
selectModuleData?: ModuleData;
|
|
10
|
-
onOk?: ({ id, customData, customeStyle, }: {
|
|
11
|
-
id?: ModuleData['id'];
|
|
12
|
-
customData?: StatisticsCustomeDataTypes;
|
|
13
|
-
customeStyle?: StatisticsCustomeStylesTypes;
|
|
14
|
-
}) => void;
|
|
15
9
|
moduleDataApi?: ModuleDataApi;
|
|
16
10
|
enumDataApi?: any;
|
|
17
11
|
}
|
|
@@ -6,6 +6,7 @@ import CustomData from "./custome-data.js";
|
|
|
6
6
|
import CustomeStyles from "./custome-styles.js";
|
|
7
7
|
import StatisticsModule from "../../module-content/statistics-module/index.js";
|
|
8
8
|
import { useTranslation } from "react-i18next";
|
|
9
|
+
import { EditorHeader } from "../../ui/modal/editor-header.js";
|
|
9
10
|
const AddStatisticsModal = ({
|
|
10
11
|
open,
|
|
11
12
|
onClose,
|
|
@@ -17,39 +18,28 @@ const AddStatisticsModal = ({
|
|
|
17
18
|
const { t } = useTranslation();
|
|
18
19
|
const [customData, setCustomData] = useState();
|
|
19
20
|
const [customeStyle, setCustomeStyle] = useState();
|
|
20
|
-
const handleOk = () => {
|
|
21
|
-
onClose == null ? void 0 : onClose();
|
|
22
|
-
};
|
|
23
21
|
useEffect(() => {
|
|
24
22
|
if (selectModuleData) {
|
|
25
23
|
setCustomData(selectModuleData == null ? void 0 : selectModuleData.customData);
|
|
26
24
|
setCustomeStyle(selectModuleData == null ? void 0 : selectModuleData.customeStyle);
|
|
27
25
|
}
|
|
28
26
|
}, [selectModuleData]);
|
|
27
|
+
const [title, setTitle] = useState("");
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (open) {
|
|
30
|
+
setTitle(!!(selectModuleData == null ? void 0 : selectModuleData.title) ? selectModuleData == null ? void 0 : selectModuleData.title : t("statisticsText"));
|
|
31
|
+
}
|
|
32
|
+
}, [open]);
|
|
29
33
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
30
34
|
Modal,
|
|
31
35
|
{
|
|
32
36
|
width: "65%",
|
|
33
|
-
title:
|
|
37
|
+
title: /* @__PURE__ */ jsx(EditorHeader, { value: title, onChange: setTitle }),
|
|
34
38
|
footer: null,
|
|
35
39
|
open,
|
|
36
|
-
onOk: handleOk,
|
|
37
40
|
onCancel: onClose,
|
|
38
41
|
closeIcon: /* @__PURE__ */ jsx(CloseOutlined, {}),
|
|
39
|
-
|
|
40
|
-
content: "ow"
|
|
41
|
-
},
|
|
42
|
-
styles: {
|
|
43
|
-
header: {
|
|
44
|
-
padding: "10px",
|
|
45
|
-
borderBottom: "1px solid #dee0e3",
|
|
46
|
-
marginBottom: "10px"
|
|
47
|
-
},
|
|
48
|
-
body: {
|
|
49
|
-
overflowY: "auto",
|
|
50
|
-
flex: 1
|
|
51
|
-
}
|
|
52
|
-
},
|
|
42
|
+
className: "ow",
|
|
53
43
|
children: /* @__PURE__ */ jsxs("div", { className: "config-widget-dialog-container", children: [
|
|
54
44
|
/* @__PURE__ */ jsx("div", { className: "config-widget-dialog-content", children: /* @__PURE__ */ jsx("div", { className: "config-widget-dialog-preview", children: /* @__PURE__ */ jsx(
|
|
55
45
|
StatisticsModule,
|
|
@@ -103,7 +93,8 @@ const AddStatisticsModal = ({
|
|
|
103
93
|
onOk == null ? void 0 : onOk({
|
|
104
94
|
id: selectModuleData == null ? void 0 : selectModuleData.id,
|
|
105
95
|
customData,
|
|
106
|
-
customeStyle
|
|
96
|
+
customeStyle,
|
|
97
|
+
title
|
|
107
98
|
});
|
|
108
99
|
},
|
|
109
100
|
children: t("confirm")
|
package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useMemo, useState } from 'react'\nimport { Button, Modal, Tabs } from 'antd'\nimport { CloseOutlined } from '@ant-design/icons'\nimport CustomData, { StatisticsCustomeDataTypes } from './custome-data'\nimport CustomeStyles
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useMemo, useState } from 'react'\nimport { Button, Modal, Tabs } from 'antd'\nimport { CloseOutlined } from '@ant-design/icons'\nimport CustomData, { StatisticsCustomeDataTypes } from './custome-data'\nimport CustomeStyles from './custome-styles'\nimport { ModuleDataApi } from '../../../types'\nimport StatisticsModule from '../../module-content/statistics-module'\nimport { ModuleData } from '../../module-content'\nimport { useTranslation } from 'react-i18next'\nimport EditorHeader from '@platox/pivot-table/dashboard-workbench/components/ui/modal/editor-header'\n\ninterface AddStatisticsModalProps {\n open: boolean\n onClose?: () => void\n onOk?: (data: Partial<ModuleData>) => void\n\n selectModuleData?: ModuleData\n moduleDataApi?: ModuleDataApi\n enumDataApi?: any\n}\n\nconst AddStatisticsModal: React.FC<AddStatisticsModalProps> = ({\n open,\n onClose,\n onOk,\n\n moduleDataApi,\n selectModuleData,\n enumDataApi,\n}) => {\n const { t } = useTranslation()\n const [customData, setCustomData] = useState<StatisticsCustomeDataTypes>()\n const [customeStyle, setCustomeStyle] = useState<any>()\n\n useEffect(() => {\n if (selectModuleData) {\n setCustomData(selectModuleData?.customData)\n setCustomeStyle(selectModuleData?.customeStyle)\n }\n }, [selectModuleData])\n\n /* ============================== split =============================== */\n const [title, setTitle] = useState<string>('')\n useEffect(() => {\n if (open) {\n setTitle(!!selectModuleData?.title ? selectModuleData?.title : t('statisticsText'))\n }\n }, [open])\n\n return (\n <>\n <Modal\n width=\"65%\"\n title={<EditorHeader value={title} onChange={setTitle} />}\n footer={null}\n open={open}\n onCancel={onClose}\n closeIcon={<CloseOutlined />}\n className=\"ow\"\n >\n <div className=\"config-widget-dialog-container\">\n <div className=\"config-widget-dialog-content\">\n <div className=\"config-widget-dialog-preview\">\n <StatisticsModule\n customData={customData}\n customeStyle={customeStyle}\n moduleDataApi={moduleDataApi}\n />\n </div>\n </div>\n <div className=\"config-widget-dialog-panel\">\n <div className=\"bitable-dashboard edit-panel-container\">\n <Tabs\n defaultActiveKey=\"1\"\n items={[\n {\n key: '1',\n label: t('typeData'),\n children: (\n <CustomData\n selectModuleData={selectModuleData}\n enumDataApi={enumDataApi}\n onAllValuesChange={allVal => {\n setCustomData(allVal)\n }}\n />\n ),\n },\n {\n key: '2',\n label: t('customStyle'),\n children: (\n <CustomeStyles\n selectModuleData={selectModuleData}\n onAllValuesChange={allVal => {\n setCustomeStyle(allVal)\n }}\n />\n ),\n },\n ]}\n />\n </div>\n <div className=\"button-container\">\n <Button\n type=\"primary\"\n onClick={() => {\n onOk?.({\n id: selectModuleData?.id,\n customData,\n customeStyle,\n title,\n })\n }}\n >\n {t('confirm')}\n </Button>\n </div>\n </div>\n </div>\n </Modal>\n </>\n )\n}\n\nexport default AddStatisticsModal\n"],"names":[],"mappings":";;;;;;;;;AAsBA,MAAM,qBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EAEA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AAA;AAAA,sBACC;AAAA,sBACA;AAAA,sBACA,mBAAmB,CAAU,WAAA;AAC3B,sCAAc,MAAM;AAAA,sBAAA;AAAA,oBACtB;AAAA,kBAAA;AAAA,gBAGN;AAAA,gBACA;AAAA,kBACE,KAAK;AAAA,kBACL,OAAO,EAAE,aAAa;AAAA,kBACtB,UACE;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC;AAAA,sBACA,mBAAmB,CAAU,WAAA;AAC3B,wCAAgB,MAAM;AAAA,sBAAA;AAAA,oBACxB;AAAA,kBAAA;AAAA,gBACF;AAAA,cAEJ;AAAA,YACF;AAAA,UAAA,GAEJ;AAAA,UACA,oBAAC,OAAI,EAAA,WAAU,oBACb,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACN,6CAAA;AAAA,kBACL,IAAI,qDAAkB;AAAA,kBACtB;AAAA,kBACA;AAAA,kBACA;AAAA,gBAAA;AAAA,cAEJ;AAAA,cAEC,YAAE,SAAS;AAAA,YAAA;AAAA,UAAA,EAEhB,CAAA;AAAA,QAAA,EACF,CAAA;AAAA,MAAA,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -10,14 +10,11 @@ import { mapConditionsToPostgrest } from "../utils.js";
|
|
|
10
10
|
import { message, Spin, Modal, Descriptions } from "antd";
|
|
11
11
|
import { getTransformValue } from "../../../utils/index.js";
|
|
12
12
|
import { useMemoizedFn, useSize } from "ahooks";
|
|
13
|
+
import MINIMAL_RAW_EN_LOCALE from "./locales/en.js";
|
|
14
|
+
import l77 from "./locales/zh.js";
|
|
13
15
|
dayjs.extend(isBetween);
|
|
14
|
-
const CalendarModule = ({
|
|
15
|
-
|
|
16
|
-
customData,
|
|
17
|
-
width,
|
|
18
|
-
height
|
|
19
|
-
}) => {
|
|
20
|
-
const { t } = useTranslation();
|
|
16
|
+
const CalendarModule = ({ moduleDataApi, customData }) => {
|
|
17
|
+
const { t, i18n } = useTranslation();
|
|
21
18
|
const { globalData } = useAppContext();
|
|
22
19
|
const [startMonthIntervals, setStartMonthIntervals] = useState(["", ""]);
|
|
23
20
|
const handleDatesSet = (dateInfo) => {
|
|
@@ -162,6 +159,7 @@ const CalendarModule = ({
|
|
|
162
159
|
/* @__PURE__ */ jsx(
|
|
163
160
|
FullCalendar,
|
|
164
161
|
{
|
|
162
|
+
locale: i18n.language === "zh-CN" ? l77 : MINIMAL_RAW_EN_LOCALE,
|
|
165
163
|
ref: calendarRef,
|
|
166
164
|
plugins: [dayGridPlugin],
|
|
167
165
|
headerToolbar: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/calendar-module/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport FullCalendar from '@fullcalendar/react'\nimport dayGridPlugin from '@fullcalendar/daygrid'\nimport dayjs from 'dayjs'\nimport isBetween from 'dayjs/plugin/isBetween'\nimport { EventContentArg, EventSourceInput } from '@fullcalendar/core'\nimport { ModuleDataApi, SourceDataFieldsTypes } from '../../../types'\nimport { CalendarCustomeDataTypes } from '../../add-module-modal/add-calendar-modal/custome-data'\nimport { useAppContext } from '../../../context'\nimport { useTranslation } from 'react-i18next'\nimport { mapConditionsToPostgrest } from '../utils'\nimport { Descriptions, message, Modal, Spin } from 'antd'\nimport { getTransformValue } from '../../../utils'\nimport { useMemoizedFn, useSize } from 'ahooks'\n\ndayjs.extend(isBetween)\n\ninterface CalendarModuleProps {\n customData?: CalendarCustomeDataTypes\n onChange?: (val: unknown) => void\n moduleDataApi?: ModuleDataApi\n width?: number\n height?: number\n rowWidth?: number\n rowHeight?: number\n}\n\nconst CalendarModule: React.FC<CalendarModuleProps> = ({\n moduleDataApi,\n customData,\n width,\n height,\n}) => {\n const { t } = useTranslation()\n const { globalData } = useAppContext()\n\n /* ============================== split =============================== */\n const [startMonthIntervals, setStartMonthIntervals] = useState<[string, string]>(['', ''])\n const handleDatesSet = (dateInfo: any) => {\n const currentDate = dayjs(dateInfo.view.currentStart)\n const firstDay = currentDate.startOf('month').format('YYYY-MM-DD')\n const lastDay = currentDate.endOf('month').format('YYYY-MM-DD')\n setStartMonthIntervals([firstDay, lastDay])\n }\n /* ============================== split =============================== */\n const [isloading, setIsloading] = useState(false)\n const [chartData, setChartData] = useState<any>()\n const fetchChartData = useMemoizedFn(async () => {\n setChartData([])\n if (customData) {\n setIsloading(true)\n let queryString = ''\n const firstDayOfMonth = dayjs().startOf('month').format('YYYY-MM-DD')\n const lastDayOfMonth = dayjs().endOf('month').format('YYYY-MM-DD')\n const conditionData = customData.conditionData\n const FMDay = startMonthIntervals.length > 0 ? startMonthIntervals[0] : firstDayOfMonth\n const LMDay = startMonthIntervals.length > 0 ? startMonthIntervals[1] : lastDayOfMonth\n\n if (conditionData) {\n if (conditionData?.conditionList?.map(item => item.type)?.includes('timestamp')) {\n queryString += `${mapConditionsToPostgrest(conditionData)}`\n } else {\n queryString += `added_on=gt.${FMDay}&added_on=lt.${LMDay}&${mapConditionsToPostgrest(\n conditionData\n )}`\n }\n } else {\n queryString = `added_on=gt.${FMDay}&added_on=lt.${LMDay}`\n }\n\n if (customData?.dataSourceId) {\n moduleDataApi?.({\n id: customData?.dataSourceId,\n query: queryString,\n })\n .then((res: any) => {\n if (!res.success) {\n message.error(res.message)\n return\n }\n setChartData(res.data)\n })\n .finally(() => {\n setIsloading(false)\n })\n }\n }\n })\n useEffect(() => {\n if (customData) {\n fetchChartData()\n }\n }, [customData?.dataSourceId, customData?.conditionData, startMonthIntervals])\n\n /* ============================== split =============================== */\n const fieldOptions = useMemo(() => {\n return globalData?.sourceData?.find(item => item.value === customData?.dataSourceId)?.fields\n }, [globalData, customData])\n\n const events = useMemo(() => {\n const calendarEvents = chartData?.map((item: any) => {\n const title = getTransformValue({\n fieldOptions,\n val: customData?.titleField ? item?.[customData.titleField] : '',\n field: customData?.titleField,\n fieldMap: globalData?.fieldMap,\n })\n return {\n title: title ?? t('unnamedRecord'),\n start:\n customData?.startDateField && item[customData?.startDateField]\n ? dayjs(item[customData?.startDateField])?.toISOString()\n : '',\n end:\n customData?.endDateField && item[customData?.endDateField]\n ? dayjs(item[customData?.endDateField])?.toISOString()\n : undefined,\n allDay: true,\n ...item,\n originalData: item,\n }\n })\n return calendarEvents\n }, [chartData, customData, fieldOptions])\n\n /* ============================== split =============================== */\n const [isModalOpen, setIsModalOpen] = useState(false)\n const [currData, setCurrData] = useState()\n const currTitle = getTransformValue({\n fieldOptions,\n val: customData?.titleField ? currData?.[customData.titleField] : '',\n field: customData?.titleField,\n fieldMap: globalData?.fieldMap,\n })\n\n const handleEventClick = useMemoizedFn((info: any) => {\n const event = info.event\n setIsModalOpen(true)\n\n setCurrData(event.extendedProps?.originalData)\n })\n\n /* ============================== split =============================== */\n const boxRef = useRef<any>()\n const calendarRef = useRef<any>(null)\n const size = useSize(boxRef)\n useEffect(() => {\n setTimeout(() => {\n calendarRef.current?.getApi()?.updateSize()\n }, 16) //不是一个div 会有延迟\n }, [size])\n\n /* ============================== split =============================== */\n\n return (\n <div\n ref={boxRef}\n style={{\n height: '100%',\n width: '100%',\n boxSizing: 'border-box',\n padding: '12px',\n }}\n >\n <div\n className=\"full-calendar-app\"\n style={{\n height: '100%',\n width: '100%',\n overflowY: 'auto',\n position: 'relative',\n }}\n >\n {isloading ? (\n <Spin\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n position: 'absolute',\n background: 'rgba(255,255,255,0.6)',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n zIndex: 1000,\n }}\n spinning={isloading}\n />\n ) : null}\n\n <FullCalendar\n ref={calendarRef} // 设置 FullCalendar 引用\n plugins={[dayGridPlugin]}\n headerToolbar={{\n left: 'title,today,prev,next',\n center: '',\n right: '',\n }}\n initialView=\"dayGridMonth\"\n height=\"auto\" // 自适应高度\n contentHeight=\"auto\" // 自动调整内容高度\n // dayMaxEvents={4} // 如果一天的事件太多则显示更多按钮\n editable={true}\n selectable={true}\n selectMirror={true}\n fixedWeekCount={false}\n datesSet={handleDatesSet}\n timeZone=\"UTC\"\n events={events} // 将筛选后的事件传递给 FullCalendar\n eventContent={(eventInfo: EventContentArg) => {\n return (\n <>\n <i>{eventInfo.event.title}</i>\n </>\n )\n }} // 自定义事件内容渲染\n eventClick={handleEventClick} // 事件点击时调用\n ></FullCalendar>\n <Modal\n title={currTitle ?? t('unnamedRecord')}\n open={isModalOpen}\n onOk={() => {\n setIsModalOpen(false)\n }}\n onCancel={() => {\n setIsModalOpen(false)\n }}\n destroyOnClose\n footer={(_, { OkBtn }) => (\n <>\n <OkBtn />\n </>\n )}\n >\n {(fieldOptions?.length ?? 0) > 0 ? (\n <Descriptions\n className=\"reset-descriptions\"\n layout=\"vertical\"\n column={2}\n items={fieldOptions?.map((field: any, fieldKey) => ({\n key: fieldKey,\n label: field.label,\n children: getTransformValue({\n fieldOptions,\n val: currData?.[field.value],\n field: field.value,\n fieldMap: globalData?.fieldMap,\n }),\n }))}\n />\n ) : null}\n </Modal>\n </div>\n </div>\n )\n}\n\nexport default React.memo(CalendarModule)\n"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,MAAM,OAAO,SAAS;AAYtB,MAAM,iBAAgD,CAAC;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,EAAE,IAAI,eAAe;AACvB,QAAA,EAAE,WAAW,IAAI,cAAc;AAG/B,QAAA,CAAC,qBAAqB,sBAAsB,IAAI,SAA2B,CAAC,IAAI,EAAE,CAAC;AACnF,QAAA,iBAAiB,CAAC,aAAkB;AACxC,UAAM,cAAc,MAAM,SAAS,KAAK,YAAY;AACpD,UAAM,WAAW,YAAY,QAAQ,OAAO,EAAE,OAAO,YAAY;AACjE,UAAM,UAAU,YAAY,MAAM,OAAO,EA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B,UAAU;AAAA,gBACV,UAAS;AAAA,gBACT;AAAA,gBACA,cAAc,CAAC,cAA+B;AAC5C,yDAEI,UAAC,oBAAA,KAAA,EAAG,UAAU,UAAA,MAAM,OAAM,EAC5B,CAAA;AAAA,gBAEJ;AAAA,gBACA,YAAY;AAAA,cAAA;AAAA,YACb;AAAA,YACD;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO,aAAa,EAAE,eAAe;AAAA,gBACrC,MAAM;AAAA,gBACN,MAAM,MAAM;AACV,iCAAe,KAAK;AAAA,gBACtB;AAAA,gBACA,UAAU,MAAM;AACd,iCAAe,KAAK;AAAA,gBACtB;AAAA,gBACA,gBAAc;AAAA,gBACd,QAAQ,CAAC,GAAG,EAAE,MACZ,MAAA,oBAAA,UAAA,EACE,UAAC,oBAAA,OAAA,CAAA,CAAM,EACT,CAAA;AAAA,gBAGA,YAAA,6CAAc,WAAU,KAAK,IAC7B;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAU;AAAA,oBACV,QAAO;AAAA,oBACP,QAAQ;AAAA,oBACR,OAAO,6CAAc,IAAI,CAAC,OAAY,cAAc;AAAA,sBAClD,KAAK;AAAA,sBACL,OAAO,MAAM;AAAA,sBACb,UAAU,kBAAkB;AAAA,wBAC1B;AAAA,wBACA,KAAK,qCAAW,MAAM;AAAA,wBACtB,OAAO,MAAM;AAAA,wBACb,UAAU,yCAAY;AAAA,sBACvB,CAAA;AAAA,oBAAA;AAAA,kBACD;AAAA,gBAAA,IAEF;AAAA,cAAA;AAAA,YAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ;AAEA,MAAA,mBAAe,MAAM,KAAK,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/calendar-module/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport FullCalendar from '@fullcalendar/react'\nimport dayGridPlugin from '@fullcalendar/daygrid'\nimport dayjs from 'dayjs'\nimport isBetween from 'dayjs/plugin/isBetween'\nimport { EventContentArg, EventSourceInput } from '@fullcalendar/core'\nimport { ModuleDataApi, SourceDataFieldsTypes } from '../../../types'\nimport { CalendarCustomeDataTypes } from '../../add-module-modal/add-calendar-modal/custome-data'\nimport { useAppContext } from '../../../context'\nimport { useTranslation } from 'react-i18next'\nimport { mapConditionsToPostgrest } from '../utils'\nimport { Descriptions, message, Modal, Spin } from 'antd'\nimport { getTransformValue } from '../../../utils'\nimport { useMemoizedFn, useSize } from 'ahooks'\nimport en from './locales/en'\nimport zh from './locales/zh'\n// import zh from\n\ndayjs.extend(isBetween)\n\ninterface CalendarModuleProps {\n customData?: CalendarCustomeDataTypes\n onChange?: (val: unknown) => void\n moduleDataApi?: ModuleDataApi\n width?: number\n height?: number\n rowWidth?: number\n rowHeight?: number\n}\n\nconst CalendarModule: React.FC<CalendarModuleProps> = ({ moduleDataApi, customData }) => {\n const { t, i18n } = useTranslation()\n const { globalData } = useAppContext()\n\n /* ============================== split =============================== */\n const [startMonthIntervals, setStartMonthIntervals] = useState<[string, string]>(['', ''])\n const handleDatesSet = (dateInfo: any) => {\n const currentDate = dayjs(dateInfo.view.currentStart)\n const firstDay = currentDate.startOf('month').format('YYYY-MM-DD')\n const lastDay = currentDate.endOf('month').format('YYYY-MM-DD')\n setStartMonthIntervals([firstDay, lastDay])\n }\n /* ============================== split =============================== */\n const [isloading, setIsloading] = useState(false)\n const [chartData, setChartData] = useState<any>()\n const fetchChartData = useMemoizedFn(async () => {\n setChartData([])\n if (customData) {\n setIsloading(true)\n let queryString = ''\n const firstDayOfMonth = dayjs().startOf('month').format('YYYY-MM-DD')\n const lastDayOfMonth = dayjs().endOf('month').format('YYYY-MM-DD')\n const conditionData = customData.conditionData\n const FMDay = startMonthIntervals.length > 0 ? startMonthIntervals[0] : firstDayOfMonth\n const LMDay = startMonthIntervals.length > 0 ? startMonthIntervals[1] : lastDayOfMonth\n\n if (conditionData) {\n if (conditionData?.conditionList?.map(item => item.type)?.includes('timestamp')) {\n queryString += `${mapConditionsToPostgrest(conditionData)}`\n } else {\n queryString += `added_on=gt.${FMDay}&added_on=lt.${LMDay}&${mapConditionsToPostgrest(\n conditionData\n )}`\n }\n } else {\n queryString = `added_on=gt.${FMDay}&added_on=lt.${LMDay}`\n }\n\n if (customData?.dataSourceId) {\n moduleDataApi?.({\n id: customData?.dataSourceId,\n query: queryString,\n })\n .then((res: any) => {\n if (!res.success) {\n message.error(res.message)\n return\n }\n setChartData(res.data)\n })\n .finally(() => {\n setIsloading(false)\n })\n }\n }\n })\n useEffect(() => {\n if (customData) {\n fetchChartData()\n }\n }, [customData?.dataSourceId, customData?.conditionData, startMonthIntervals])\n\n /* ============================== split =============================== */\n const fieldOptions = useMemo(() => {\n return globalData?.sourceData?.find(item => item.value === customData?.dataSourceId)?.fields\n }, [globalData, customData])\n\n const events = useMemo(() => {\n const calendarEvents = chartData?.map((item: any) => {\n const title = getTransformValue({\n fieldOptions,\n val: customData?.titleField ? item?.[customData.titleField] : '',\n field: customData?.titleField,\n fieldMap: globalData?.fieldMap,\n })\n return {\n title: title ?? t('unnamedRecord'),\n start:\n customData?.startDateField && item[customData?.startDateField]\n ? dayjs(item[customData?.startDateField])?.toISOString()\n : '',\n end:\n customData?.endDateField && item[customData?.endDateField]\n ? dayjs(item[customData?.endDateField])?.toISOString()\n : undefined,\n allDay: true,\n ...item,\n originalData: item,\n }\n })\n return calendarEvents\n }, [chartData, customData, fieldOptions])\n\n /* ============================== split =============================== */\n const [isModalOpen, setIsModalOpen] = useState(false)\n const [currData, setCurrData] = useState()\n const currTitle = getTransformValue({\n fieldOptions,\n val: customData?.titleField ? currData?.[customData.titleField] : '',\n field: customData?.titleField,\n fieldMap: globalData?.fieldMap,\n })\n\n const handleEventClick = useMemoizedFn((info: any) => {\n const event = info.event\n setIsModalOpen(true)\n\n setCurrData(event.extendedProps?.originalData)\n })\n\n /* ============================== split =============================== */\n const boxRef = useRef<any>()\n const calendarRef = useRef<any>(null)\n const size = useSize(boxRef)\n useEffect(() => {\n setTimeout(() => {\n calendarRef.current?.getApi()?.updateSize()\n }, 16) //不是一个div 会有延迟\n }, [size])\n\n /* ============================== split =============================== */\n\n return (\n <div\n ref={boxRef}\n style={{\n height: '100%',\n width: '100%',\n boxSizing: 'border-box',\n padding: '12px',\n }}\n >\n <div\n className=\"full-calendar-app\"\n style={{\n height: '100%',\n width: '100%',\n overflowY: 'auto',\n position: 'relative',\n }}\n >\n {isloading ? (\n <Spin\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n position: 'absolute',\n background: 'rgba(255,255,255,0.6)',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n zIndex: 1000,\n }}\n spinning={isloading}\n />\n ) : null}\n\n <FullCalendar\n locale={i18n.language === 'zh-CN' ? zh : en}\n // locale =\n ref={calendarRef} // 设置 FullCalendar 引用\n plugins={[dayGridPlugin]}\n headerToolbar={{\n left: 'title,today,prev,next',\n center: '',\n right: '',\n }}\n initialView=\"dayGridMonth\"\n height=\"auto\" // 自适应高度\n contentHeight=\"auto\" // 自动调整内容高度\n // dayMaxEvents={4} // 如果一天的事件太多则显示更多按钮\n editable={true}\n selectable={true}\n selectMirror={true}\n fixedWeekCount={false}\n datesSet={handleDatesSet}\n timeZone=\"UTC\"\n events={events} // 将筛选后的事件传递给 FullCalendar\n eventContent={(eventInfo: EventContentArg) => {\n return (\n <>\n <i>{eventInfo.event.title}</i>\n </>\n )\n }} // 自定义事件内容渲染\n eventClick={handleEventClick} // 事件点击时调用\n ></FullCalendar>\n <Modal\n title={currTitle ?? t('unnamedRecord')}\n open={isModalOpen}\n onOk={() => {\n setIsModalOpen(false)\n }}\n onCancel={() => {\n setIsModalOpen(false)\n }}\n destroyOnClose\n footer={(_, { OkBtn }) => (\n <>\n <OkBtn />\n </>\n )}\n >\n {(fieldOptions?.length ?? 0) > 0 ? (\n <Descriptions\n className=\"reset-descriptions\"\n layout=\"vertical\"\n column={2}\n items={fieldOptions?.map((field: any, fieldKey) => ({\n key: fieldKey,\n label: field.label,\n children: getTransformValue({\n fieldOptions,\n val: currData?.[field.value],\n field: field.value,\n fieldMap: globalData?.fieldMap,\n }),\n }))}\n />\n ) : null}\n </Modal>\n </div>\n </div>\n )\n}\n\nexport default React.memo(CalendarModule)\n"],"names":["zh","en"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAM,OAAO,SAAS;AAYtB,MAAM,iBAAgD,CAAC,EAAE,eAAe,iBAAiB;AACvF,QAAM,EAAE,GAAG,KAAK,IAAI,eAAe;AAC7B,QAAA,EAAE,WAAW,IAAI,cAAc;AAG/B,QAAA,CAAC,qBAAqB,sBAAsB,IAAI,SAA2B,CAAC,IAAI,EAAE,CAAC;AACnF,QAAA,iBAAiB,CAAC,aAAkB;AACxC,UAAM,cAAc,MAAM,SAAS,KAAK,YAAY;AACpD,UAAM,WAAW,YAAY,QAAQ,OAAO,EAAE,OAAO,YAAY;AACjE,UAAM,UAAU,YAAY,MAAM,OAAO,EAAE,OAAO,YAAY;AACvC,2BAAA,CAAC,UAAU,OAAO,CAAC;AAAA,EAC5C;AAEA,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAc;AAC1C,QAAA,iBAAiB,cAAc,YAAY;;AAC/C,iBAAa,CAAA,CAAE;AACf,QAAI,YAAY;AACd,mBAAa,IAAI;AACjB,UAAI,cAAc;AAClB,YAAM,kBAAkB,QAAQ,QAAQ,OAAO,EAAE,OAAO,YAAY;AACpE,YAAM,iBAAiB,QAAQ,MAAM,OAAO,EAAE,OAAO,YAAY;AACjE,YAAM,gBAAgB,WAAW;AACjC,YAAM,QAAQ,oBAAoB,SAAS,IAAI,oBAAoB,CAAC,IAAI;AACxE,YAAM,QAAQ,oBAAoB,SAAS,IAAI,oBAAoB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oBAAA,UAAA,EACE,UAAC,oBAAA,OAAA,CAAA,CAAM,EACT,CAAA;AAAA,gBAGA,YAAA,6CAAc,WAAU,KAAK,IAC7B;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAU;AAAA,oBACV,QAAO;AAAA,oBACP,QAAQ;AAAA,oBACR,OAAO,6CAAc,IAAI,CAAC,OAAY,cAAc;AAAA,sBAClD,KAAK;AAAA,sBACL,OAAO,MAAM;AAAA,sBACb,UAAU,kBAAkB;AAAA,wBAC1B;AAAA,wBACA,KAAK,qCAAW,MAAM;AAAA,wBACtB,OAAO,MAAM;AAAA,wBACb,UAAU,yCAAY;AAAA,sBACvB,CAAA;AAAA,oBAAA;AAAA,kBACD;AAAA,gBAAA,IAEF;AAAA,cAAA;AAAA,YAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ;AAEA,MAAA,mBAAe,MAAM,KAAK,cAAc;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.js","sources":["../../../../../../packages/dashboard-workbench/components/module-content/calendar-module/locales/en.ts"],"sourcesContent":["const MINIMAL_RAW_EN_LOCALE = {\n code: 'en',\n buttonText: {\n today: 'Today',\n },\n}\nexport default MINIMAL_RAW_EN_LOCALE\n"],"names":[],"mappings":"AAAA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO;AAAA,EAAA;AAEX;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare var l77: {
|
|
2
|
+
code: string;
|
|
3
|
+
week: {
|
|
4
|
+
dow: number;
|
|
5
|
+
doy: number;
|
|
6
|
+
};
|
|
7
|
+
buttonText: {
|
|
8
|
+
prev: string;
|
|
9
|
+
next: string;
|
|
10
|
+
today: string;
|
|
11
|
+
year: string;
|
|
12
|
+
month: string;
|
|
13
|
+
week: string;
|
|
14
|
+
day: string;
|
|
15
|
+
list: string;
|
|
16
|
+
};
|
|
17
|
+
weekText: string;
|
|
18
|
+
allDayText: string;
|
|
19
|
+
moreLinkText(n: string): string;
|
|
20
|
+
noEventsText: string;
|
|
21
|
+
};
|
|
22
|
+
export { l77 as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var l77 = {
|
|
2
|
+
code: "zh-cn",
|
|
3
|
+
week: {
|
|
4
|
+
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
|
|
5
|
+
dow: 1,
|
|
6
|
+
doy: 4
|
|
7
|
+
// The week that contains Jan 4th is the first week of the year.
|
|
8
|
+
},
|
|
9
|
+
buttonText: {
|
|
10
|
+
prev: "上月",
|
|
11
|
+
next: "下月",
|
|
12
|
+
today: "今天",
|
|
13
|
+
year: "年",
|
|
14
|
+
month: "月",
|
|
15
|
+
week: "周",
|
|
16
|
+
day: "日",
|
|
17
|
+
list: "日程"
|
|
18
|
+
},
|
|
19
|
+
weekText: "周",
|
|
20
|
+
allDayText: "全天",
|
|
21
|
+
moreLinkText(n) {
|
|
22
|
+
return "另外 " + n + " 个";
|
|
23
|
+
},
|
|
24
|
+
noEventsText: "没有事件显示"
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
l77 as default
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=zh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zh.js","sources":["../../../../../../packages/dashboard-workbench/components/module-content/calendar-module/locales/zh.ts"],"sourcesContent":["var l77 = {\n code: 'zh-cn',\n week: {\n // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效\n dow: 1,\n doy: 4, // The week that contains Jan 4th is the first week of the year.\n },\n buttonText: {\n prev: '上月',\n next: '下月',\n today: '今天',\n year: '年',\n month: '月',\n week: '周',\n day: '日',\n list: '日程',\n },\n weekText: '周',\n allDayText: '全天',\n moreLinkText(n: string) {\n return '另外 ' + n + ' 个'\n },\n noEventsText: '没有事件显示',\n}\n\nexport { l77 as default }\n"],"names":[],"mappings":"AAAA,IAAI,MAAM;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,IAEJ,KAAK;AAAA,IACL,KAAK;AAAA;AAAA,EACP;AAAA,EACA,YAAY;AAAA,IACV,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,aAAa,GAAW;AACtB,WAAO,QAAQ,IAAI;AAAA,EACrB;AAAA,EACA,cAAc;AAChB;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import IconEmpty from "../../../icon/icon-empty.js";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
const Empty = (props) => {
|
|
5
|
+
const { t } = useTranslation();
|
|
6
|
+
return /* @__PURE__ */ jsxs(
|
|
7
|
+
"div",
|
|
8
|
+
{
|
|
9
|
+
style: {
|
|
10
|
+
color: "#A1A1AA",
|
|
11
|
+
width: "100%",
|
|
12
|
+
height: "100%",
|
|
13
|
+
display: "flex",
|
|
14
|
+
flexDirection: "column",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
justifyContent: "center"
|
|
17
|
+
},
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ jsx(IconEmpty, {}),
|
|
20
|
+
/* @__PURE__ */ jsx("span", { children: t("empty") })
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
Empty.displayName = "Empty";
|
|
26
|
+
export {
|
|
27
|
+
Empty,
|
|
28
|
+
Empty as default
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=Empty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Empty.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/chart-module/Empty.tsx"],"sourcesContent":["import React, { useMemo } from 'react'\nimport styles from './index.scss'\nimport IconEmpty from '@platox/pivot-table/dashboard-workbench/icon/icon-empty'\nimport { useTranslation } from 'react-i18next'\n\nconst componentName = 'Empty'\n\nexport interface EmptyProps {}\nexport const Empty: React.FC<EmptyProps> = props => {\n const { t } = useTranslation()\n return (\n <div\n style={{\n color: '#A1A1AA',\n width: '100%',\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <IconEmpty />\n <span>{t('empty')}</span>\n </div>\n )\n}\n\nEmpty.displayName = 'Empty'\n\nexport default Empty\n"],"names":[],"mappings":";;;AAQO,MAAM,QAA8B,CAAS,UAAA;AAC5C,QAAA,EAAE,EAAE,IAAI,eAAe;AAE3B,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,OAAO;AAAA,QACP,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAClB;AAAA,MAEA,UAAA;AAAA,QAAA,oBAAC,WAAU,EAAA;AAAA,QACV,oBAAA,QAAA,EAAM,UAAE,EAAA,OAAO,EAAE,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACpB;AAEJ;AAEA,MAAM,cAAc;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import React, { useState, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import Chart from "./base-chart/index.js";
|
|
4
4
|
import { useAppContext } from "../../../context.js";
|
|
@@ -8,6 +8,7 @@ import { t } from "i18next";
|
|
|
8
8
|
import { getChartConfig, getSerie, getGrid } from "./utils.js";
|
|
9
9
|
import { getTransformValue } from "../../../utils/index.js";
|
|
10
10
|
import { useMemoizedFn, useSize } from "ahooks";
|
|
11
|
+
import { Empty } from "./Empty.js";
|
|
11
12
|
const ChartModule = ({
|
|
12
13
|
moduleDataApi,
|
|
13
14
|
customData,
|
|
@@ -85,10 +86,18 @@ const ChartModule = ({
|
|
|
85
86
|
const initChartOptions = useMemoizedFn(() => {
|
|
86
87
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
87
88
|
if (customData && chartData && customData.type && chartData.length > 0) {
|
|
89
|
+
const formatter = (data) => {
|
|
90
|
+
if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
|
|
91
|
+
return (data == null ? void 0 : data.value) == 0 ? "" : `${data == null ? void 0 : data.value}`;
|
|
92
|
+
} else {
|
|
93
|
+
return `${data == null ? void 0 : data.value}`;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
88
96
|
const label = {
|
|
89
97
|
show: ((_a = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _a.includes("label")) || ((_b = customeStyle == null ? void 0 : customeStyle.xchartOptions) == null ? void 0 : _b.includes("label")),
|
|
90
98
|
position: "top",
|
|
91
|
-
formatter:
|
|
99
|
+
// formatter: '{c}',
|
|
100
|
+
formatter
|
|
92
101
|
};
|
|
93
102
|
const newXAxisField = (customData == null ? void 0 : customData.xAxis) === "tags" ? "tag" : customData == null ? void 0 : customData.xAxis;
|
|
94
103
|
const newGroupField = (customData == null ? void 0 : customData.groupField) === "tags" ? "tag" : customData == null ? void 0 : customData.groupField;
|
|
@@ -293,7 +302,8 @@ const ChartModule = ({
|
|
|
293
302
|
show: ((_g = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _g.includes("label")) || ((_h = customeStyle == null ? void 0 : customeStyle.xchartOptions) == null ? void 0 : _h.includes("label")),
|
|
294
303
|
rotate: grids.axisLabelRotate,
|
|
295
304
|
// 使标签倾斜,调整为合适的角度
|
|
296
|
-
|
|
305
|
+
interval: "auto",
|
|
306
|
+
// 自动隐藏
|
|
297
307
|
formatter: (value) => {
|
|
298
308
|
return value.length > 15 ? `${value.slice(0, 15)}...` : value;
|
|
299
309
|
},
|
|
@@ -338,7 +348,7 @@ const ChartModule = ({
|
|
|
338
348
|
};
|
|
339
349
|
setChartOptions(options);
|
|
340
350
|
} else {
|
|
341
|
-
setChartOptions(
|
|
351
|
+
setChartOptions(void 0);
|
|
342
352
|
}
|
|
343
353
|
});
|
|
344
354
|
useEffect(() => {
|
|
@@ -363,19 +373,31 @@ const ChartModule = ({
|
|
|
363
373
|
(_a = echartRef == null ? void 0 : echartRef.current) == null ? void 0 : _a.resize();
|
|
364
374
|
}
|
|
365
375
|
}, [size]);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
const isLoading = loading && !chartOptions;
|
|
377
|
+
const isEmpyt = !loading && !chartOptions;
|
|
378
|
+
const isOk = !isLoading && !isEmpyt;
|
|
379
|
+
console.log("asd", {
|
|
380
|
+
isLoading,
|
|
381
|
+
isEmpyt,
|
|
382
|
+
isOk
|
|
383
|
+
});
|
|
384
|
+
return /* @__PURE__ */ jsxs("div", { style: { width: "100%", height: "100%" }, ref: containerRef, children: [
|
|
385
|
+
isLoading && /* @__PURE__ */ jsx(
|
|
386
|
+
Spin,
|
|
387
|
+
{
|
|
388
|
+
style: {
|
|
389
|
+
width: "100%",
|
|
390
|
+
height: "100%",
|
|
391
|
+
display: "flex",
|
|
392
|
+
justifyContent: "center",
|
|
393
|
+
alignItems: "center"
|
|
394
|
+
},
|
|
395
|
+
spinning: loading
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
isEmpyt && /* @__PURE__ */ jsx(Empty, {}),
|
|
399
|
+
isOk && /* @__PURE__ */ jsx(Chart, { echartRef, options: chartOptions })
|
|
400
|
+
] });
|
|
379
401
|
};
|
|
380
402
|
const ChartModule$1 = React.memo(ChartModule);
|
|
381
403
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/chart-module/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { ModuleDataApi, SourceDataFieldsTypes } from '../../../types'\nimport { ChartCustomeDataTypes } from '../../add-module-modal/add-chart-modal/custome-data'\nimport { ChartCustomeStylesTypes } from '../../add-module-modal/add-chart-modal/custome-styles'\nimport BaseChart from './base-chart'\nimport { useAppContext } from '../../../context'\nimport { message, Spin } from 'antd'\nimport { mapConditionsToPostgrest } from '../utils'\nimport { t } from 'i18next'\nimport { getChartConfig, getGrid, getSerie } from './utils'\nimport { getTransformValue } from '../../../utils'\nimport React from 'react'\nimport { useMemoizedFn, useSize } from 'ahooks'\nimport { EChartsOption } from 'echarts'\n\ninterface ChartModuleProps {\n customData?: ChartCustomeDataTypes\n customeStyle?: ChartCustomeStylesTypes\n onChange?: (val: unknown) => void\n moduleDataApi?: ModuleDataApi\n width?: number\n height?: number\n}\n\nconst ChartModule: React.FC<ChartModuleProps> = ({\n moduleDataApi,\n customData,\n customeStyle,\n width = 2,\n height = 2,\n}) => {\n const { globalData } = useAppContext()\n /* ============================== split =============================== */\n const [chartData, setChartData] = useState<any>()\n const [loading, setloading] = useState<any>()\n const fetchChartData = useMemoizedFn(async () => {\n setChartData([])\n if (customData) {\n // 调用方法\n setloading(true)\n let queryString = ''\n const newXAxisField = customData?.xAxis === 'tags' ? 'tag' : customData?.xAxis\n const newGroupField = customData?.groupField === 'tags' ? 'tag' : customData?.groupField\n\n if (!customData.isGroup) {\n if (customData.yAxis === 'recordTotal') {\n queryString += `select=${newXAxisField},id.count()`\n }\n\n if (customData.yAxis === 'fieldValue' && customData?.yAxisField) {\n queryString += `select=${newXAxisField},${customData?.yAxisField}.${customData?.yAxisFieldType}()`\n }\n } else {\n if (customData.yAxis === 'recordTotal') {\n queryString += `select=${newXAxisField},${newGroupField},id.count()`\n }\n if (customData.yAxis === 'fieldValue' && customData?.yAxisField) {\n queryString += `select=${newXAxisField},${newGroupField},${customData?.yAxisField}.${customData?.yAxisFieldType}()`\n }\n }\n\n if (customData?.conditionData && customData?.conditionData?.conditionList?.length > 0) {\n queryString += `&${mapConditionsToPostgrest(customData?.conditionData)}`\n }\n\n if (customData?.dataSourceId) {\n moduleDataApi?.({\n id: customData?.dataSourceId,\n query: queryString,\n })\n .then((res: any) => {\n if (!res.success) {\n message.error(res.message)\n return\n }\n setChartData(res.data)\n })\n .finally(() => {\n setloading(false)\n })\n }\n } else {\n setChartData([])\n }\n })\n\n useEffect(() => {\n if (customData) {\n fetchChartData()\n }\n }, [\n customData?.dataSourceId,\n customData?.conditionData,\n customData?.xAxis,\n customData?.yAxis,\n customData?.yAxisField,\n customData?.yAxisFieldType,\n customData?.isGroup,\n customData?.groupField,\n ])\n\n /* ============================== split =============================== */\n const fieldOptions = useMemo(() => {\n let ret = globalData?.sourceData?.find(item => item.value === customData?.dataSourceId)?.fields\n return ret\n }, [globalData, customData?.dataSourceId])\n\n const [chartOptions, setChartOptions] = useState<any>()\n\n const initChartOptions = useMemoizedFn(() => {\n if (customData && chartData && customData.type && chartData.length > 0) {\n const label = {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.xchartOptions?.includes('label'),\n position: 'top',\n formatter: '{c}',\n }\n const newXAxisField = customData?.xAxis === 'tags' ? 'tag' : customData?.xAxis\n const newGroupField = customData?.groupField === 'tags' ? 'tag' : customData?.groupField\n const isShowLegend = customData?.chartOptions?.includes('legend')\n\n const getFieldLabel = (field: any) => {\n const fieldData = fieldOptions?.find(item => item.value === field)\n return fieldData?.label\n }\n\n const getFieldVal = ({ item, field }: { item: any; field: any }) => {\n return getTransformValue({\n fieldOptions,\n val: item[field],\n field: field,\n fieldMap: globalData?.fieldMap,\n })\n }\n\n const sortChartData = (\n data: any[],\n sortField: 'xAxis' | 'yAxisField' | 'recordValue',\n sortOrder: 'asc' | 'desc'\n ) => {\n const orderMultiplier = sortOrder === 'asc' ? 1 : -1\n\n return [...data].sort((a, b) => {\n let valA, valB\n\n switch (sortField) {\n case 'xAxis':\n valA = getFieldVal({\n item: a,\n field: newXAxisField,\n })\n valB = getFieldVal({\n item: b,\n field: newXAxisField,\n })\n break\n\n case 'yAxisField':\n valA = a[customData?.yAxisFieldType] || 0\n valB = b[customData?.yAxisFieldType] || 0\n break\n\n case 'recordValue':\n default:\n valA =\n customData.yAxis === 'recordTotal' ? a?.count : a[customData?.yAxisFieldType] || 0\n valB =\n customData.yAxis === 'recordTotal' ? b?.count : b[customData?.yAxisFieldType] || 0\n break\n }\n\n if (valA > valB) return 1 * orderMultiplier\n if (valA < valB) return -1 * orderMultiplier\n return 0\n })\n }\n\n const valueCounts: Record<string, any> = {}\n const valuePercentages: Record<string, any> = {}\n const valueGroups: Record<string, Record<string, number>> = {}\n const valueGroupPercentages: Record<string, Record<string, number>> = {}\n const categories = new Set<string>()\n const stackCategories = new Set<string>()\n\n // 数据分组处理\n chartData.forEach((item: any) => {\n const category = getFieldVal({\n item: item,\n field: newXAxisField,\n })\n\n categories.add(category)\n\n const val =\n customData.yAxis === 'recordTotal' ? item?.count : item[customData?.yAxisFieldType] || 0\n\n if (customData?.isGroup && customData?.groupField) {\n const stackCategory = getFieldVal({\n item: item,\n field: newGroupField,\n })\n\n const key = category ?? t('unknown')\n\n stackCategories.add(stackCategory)\n\n if (!valueGroups[stackCategory]) {\n valueGroups[stackCategory] = {}\n }\n valueGroups[stackCategory][key] = val\n } else {\n const key = category ?? t('unknown')\n valueCounts[key] = val\n }\n })\n\n if (customData?.isGroup && customData?.groupField) {\n const totalPerCategory: Record<string, number> = {}\n\n Object.keys(valueGroups).forEach(stackCategory => {\n Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {\n totalPerCategory[key] = (totalPerCategory[key] || 0) + val\n })\n })\n\n Object.keys(valueGroups).forEach(stackCategory => {\n valueGroupPercentages[stackCategory] = {}\n Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {\n const total = totalPerCategory[key] || 1 // 防止除以 0\n valueGroupPercentages[stackCategory][key] = (val / total) * 100\n })\n })\n } else {\n Object.entries(valueCounts).forEach(([key, val]) => {\n const total = val || 1 // 防止除以 0\n valuePercentages[key] = (val / total) * 100\n })\n }\n\n if (customData?.sortField && customData?.sortOrder) {\n const sortedChartData = sortChartData(chartData, customData.sortField, customData.sortOrder)\n\n const sortedCategories = sortedChartData.map(item =>\n getFieldVal({\n item,\n field: newXAxisField,\n })\n )\n categories.clear()\n sortedCategories.forEach(cat => categories.add(cat))\n }\n\n const labels = Array.from(categories)\n const stackLabels = Array.from(stackCategories)\n\n const chartConfig: any = getChartConfig(customData.type, labels)\n\n const series = []\n if (customData?.isGroup && customData?.groupField) {\n stackLabels.forEach(stackCategory => {\n const data =\n customData.type === 'chart-bar-percentage' ||\n customData.type === 'chart-strip-bar-percentage'\n ? labels.map(label => valueGroupPercentages[stackCategory][label]?.toFixed(2) || 0)\n : labels.map(label => valueGroups[stackCategory][label] || 0)\n series.push(\n getSerie({\n type: customData.type,\n data,\n label,\n name: stackCategory,\n isGroup: customData?.isGroup,\n groupField: customData?.groupField,\n labels,\n })\n )\n })\n } else {\n const data =\n customData.type === 'chart-bar-percentage' ||\n customData.type === 'chart-strip-bar-percentage'\n ? labels.map(label => valuePercentages[label]?.toFixed(2) || 0) // 使用百分比数据\n : labels.map(label => valueCounts[label] || 0)\n series.push(\n getSerie({\n type: customData.type,\n data,\n label,\n name:\n customData.yAxis === 'recordTotal'\n ? t('pb.statisticsText')\n : getFieldLabel(customData?.yAxisField),\n isGroup: customData?.isGroup,\n groupField: customData?.groupField,\n labels,\n })\n )\n }\n\n const grids = getGrid({ series, chartConfig, width })\n\n const options: EChartsOption = {\n legend: {\n type: 'scroll',\n\n left: 'center',\n right: 'center',\n top: '0',\n show: isShowLegend,\n itemWidth: 12,\n itemHeight: 12,\n data: series?.map((item: any) => item?.name || '') || [],\n },\n grid: {\n top: grids.top,\n left: grids.left,\n right: grids.right,\n bottom: grids.bottom,\n },\n graphic: {\n elements: [\n {\n type: 'text',\n left: 'center',\n bottom: '10px',\n style: {\n text: customeStyle?.xtitle || '',\n fill: '#333', // 文本颜色\n fontSize: 12,\n fontWeight: 'bold',\n },\n },\n {\n type: 'text',\n left: '10px',\n top: 'center',\n style: {\n text: customeStyle?.ytitle || '',\n fill: '#333', // 文本颜色\n fontSize: 12,\n fontWeight: 'bold',\n },\n rotation: Math.PI / 2,\n },\n ],\n },\n xAxis: {\n ...chartConfig.xAxis,\n axisTick: {\n show: customData?.chartOptions?.includes('axis'),\n },\n axisLine: {\n show:\n customData?.chartOptions?.includes('axis') ||\n customeStyle?.xchartOptions?.includes('axisLine'),\n },\n axisLabel: {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.xchartOptions?.includes('label'),\n rotate: grids.axisLabelRotate, // 使标签倾斜,调整为合适的角度\n // interval: 0, // 保证所有标签都显示\n formatter: (value: string) => {\n return value.length > 15 ? `${value.slice(0, 15)}...` : value // 截断并添加 \"...\"\n },\n ...chartConfig.xAxis?.axisLabel,\n },\n splitLine: {\n show: customData?.chartOptions?.includes('splitLine'), // 不显示x轴网格线\n },\n },\n yAxis: {\n ...chartConfig.yAxis,\n axisTick: {\n show: customData?.chartOptions?.includes('axis'),\n },\n axisLine: {\n show:\n customData?.chartOptions?.includes('axis') ||\n customeStyle?.ychartOptions?.includes('axisLine'),\n },\n axisLabel: {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.ychartOptions?.includes('label'),\n formatter: (value: string) => {\n return value.length > 15 ? `${value.slice(0, 15)}...` : value // 截断并添加 \"...\"\n },\n hideOverlap: true,\n ...chartConfig.yAxis?.axisLabel,\n },\n splitLine: {\n show: customData?.chartOptions?.includes('splitLine'), // 不显示x轴网格线\n },\n },\n series: series,\n tooltip: {\n trigger: 'item', // 触发方式:鼠标悬浮在坐标轴上\n axisPointer: {\n type: 'shadow', // 阴影指示器,鼠标悬停时显示柱状图的阴影\n },\n appendTo: 'body',\n },\n }\n setChartOptions(options)\n } else {\n setChartOptions({})\n }\n })\n\n useEffect(() => {\n initChartOptions()\n }, [\n customData?.sortField,\n customData?.sortOrder,\n customData?.type,\n customData?.chartOptions,\n customeStyle,\n chartData,\n width,\n height,\n fieldOptions,\n ])\n\n /* ============================== split =============================== */\n const echartRef = useRef<any>()\n const containerRef = useRef<HTMLDivElement>(null)\n const size = useSize(containerRef)\n\n useEffect(() => {\n if (!!size) {\n echartRef?.current?.resize()\n }\n }, [size])\n\n return (\n <div style={{ width: '100%', height: '100%' }} ref={containerRef}>\n {!loading && chartOptions ? (\n <BaseChart echartRef={echartRef} options={chartOptions} />\n ) : (\n <Spin\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n spinning={loading}\n />\n )}\n </div>\n )\n}\n\nexport default React.memo(ChartModule)\n"],"names":["label","_a","BaseChart"],"mappings":";;;;;;;;;;AAyBA,MAAM,cAA0C,CAAC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,SAAS;AACX,MAAM;AACE,QAAA,EAAE,WAAW,IAAI,cAAc;AAErC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAc;AAChD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAc;AACtC,QAAA,iBAAiB,cAAc,YAAY;;AAC/C,iBAAa,CAAA,CAAE;AACf,QAAI,YAAY;AAEd,iBAAW,IAAI;AACf,UAAI,cAAc;AAClB,YAAM,iBAAgB,yCAAY,WAAU,SAAS,QAAQ,yCAAY;AACzE,YAAM,iBAAgB,yCAAY,gBAAe,SAAS,QAAQ,yCAAY;AAE1E,UAAA,CAAC,WAAW,SAAS;AACnB,YAAA,WAAW,UAAU,eAAe;AAC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,QAAQ,OAAO,GAAG,KAAK,cACjD,UAAA,CAAC,WAAW,eACX,oBAACE,SAAU,WAAsB,SAAS,aAAc,CAAA,IAExD;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,gBAAgB;AAAA,QAChB,YAAY;AAAA,MACd;AAAA,MACA,UAAU;AAAA,IAAA;AAAA,EAAA,GAGhB;AAEJ;AAEA,MAAA,gBAAe,MAAM,KAAK,WAAW;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/chart-module/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { ModuleDataApi, SourceDataFieldsTypes } from '../../../types'\nimport { ChartCustomeDataTypes } from '../../add-module-modal/add-chart-modal/custome-data'\nimport { ChartCustomeStylesTypes } from '../../add-module-modal/add-chart-modal/custome-styles'\nimport BaseChart from './base-chart'\nimport { useAppContext } from '../../../context'\nimport { message, Spin } from 'antd'\nimport { mapConditionsToPostgrest } from '../utils'\nimport { t } from 'i18next'\nimport { getChartConfig, getGrid, getSerie } from './utils'\nimport { getTransformValue } from '../../../utils'\nimport React from 'react'\nimport { useMemoizedFn, useSize } from 'ahooks'\nimport { EChartsOption, LabelFormatterCallback } from 'echarts'\nimport IconEmpty from '@platox/pivot-table/dashboard-workbench/icon/icon-empty'\nimport Empty from './Empty'\n\ninterface ChartModuleProps {\n customData?: ChartCustomeDataTypes\n customeStyle?: ChartCustomeStylesTypes\n onChange?: (val: unknown) => void\n moduleDataApi?: ModuleDataApi\n width?: number\n height?: number\n}\n\nconst ChartModule: React.FC<ChartModuleProps> = ({\n moduleDataApi,\n customData,\n customeStyle,\n width = 2,\n height = 2,\n}) => {\n const { globalData } = useAppContext()\n /* ============================== split =============================== */\n const [chartData, setChartData] = useState<any>()\n const [loading, setloading] = useState<any>()\n const fetchChartData = useMemoizedFn(async () => {\n setChartData([])\n if (customData) {\n // 调用方法\n setloading(true)\n let queryString = ''\n const newXAxisField = customData?.xAxis === 'tags' ? 'tag' : customData?.xAxis\n const newGroupField = customData?.groupField === 'tags' ? 'tag' : customData?.groupField\n\n if (!customData.isGroup) {\n if (customData.yAxis === 'recordTotal') {\n queryString += `select=${newXAxisField},id.count()`\n }\n\n if (customData.yAxis === 'fieldValue' && customData?.yAxisField) {\n queryString += `select=${newXAxisField},${customData?.yAxisField}.${customData?.yAxisFieldType}()`\n }\n } else {\n if (customData.yAxis === 'recordTotal') {\n queryString += `select=${newXAxisField},${newGroupField},id.count()`\n }\n if (customData.yAxis === 'fieldValue' && customData?.yAxisField) {\n queryString += `select=${newXAxisField},${newGroupField},${customData?.yAxisField}.${customData?.yAxisFieldType}()`\n }\n }\n\n if (customData?.conditionData && customData?.conditionData?.conditionList?.length > 0) {\n queryString += `&${mapConditionsToPostgrest(customData?.conditionData)}`\n }\n\n if (customData?.dataSourceId) {\n moduleDataApi?.({\n id: customData?.dataSourceId,\n query: queryString,\n })\n .then((res: any) => {\n if (!res.success) {\n message.error(res.message)\n return\n }\n setChartData(res.data)\n })\n .finally(() => {\n setloading(false)\n })\n }\n } else {\n setChartData([])\n }\n })\n\n useEffect(() => {\n if (customData) {\n fetchChartData()\n }\n }, [\n customData?.dataSourceId,\n customData?.conditionData,\n customData?.xAxis,\n customData?.yAxis,\n customData?.yAxisField,\n customData?.yAxisFieldType,\n customData?.isGroup,\n customData?.groupField,\n ])\n\n /* ============================== split =============================== */\n const fieldOptions = useMemo(() => {\n let ret = globalData?.sourceData?.find(item => item.value === customData?.dataSourceId)?.fields\n return ret\n }, [globalData, customData?.dataSourceId])\n\n const [chartOptions, setChartOptions] = useState<any>()\n\n const initChartOptions = useMemoizedFn(() => {\n if (customData && chartData && customData.type && chartData.length > 0) {\n const formatter: LabelFormatterCallback = data => {\n if (customData?.isGroup && customData?.groupField) {\n return data?.value == 0 ? '' : `${data?.value}`\n } else {\n return `${data?.value}`\n }\n }\n const label = {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.xchartOptions?.includes('label'),\n position: 'top',\n // formatter: '{c}',\n formatter,\n }\n const newXAxisField = customData?.xAxis === 'tags' ? 'tag' : customData?.xAxis\n const newGroupField = customData?.groupField === 'tags' ? 'tag' : customData?.groupField\n const isShowLegend = customData?.chartOptions?.includes('legend')\n\n const getFieldLabel = (field: any) => {\n const fieldData = fieldOptions?.find(item => item.value === field)\n return fieldData?.label\n }\n\n const getFieldVal = ({ item, field }: { item: any; field: any }) => {\n return getTransformValue({\n fieldOptions,\n val: item[field],\n field: field,\n fieldMap: globalData?.fieldMap,\n })\n }\n\n const sortChartData = (\n data: any[],\n sortField: 'xAxis' | 'yAxisField' | 'recordValue',\n sortOrder: 'asc' | 'desc'\n ) => {\n const orderMultiplier = sortOrder === 'asc' ? 1 : -1\n\n return [...data].sort((a, b) => {\n let valA, valB\n\n switch (sortField) {\n case 'xAxis':\n valA = getFieldVal({\n item: a,\n field: newXAxisField,\n })\n valB = getFieldVal({\n item: b,\n field: newXAxisField,\n })\n break\n\n case 'yAxisField':\n valA = a[customData?.yAxisFieldType] || 0\n valB = b[customData?.yAxisFieldType] || 0\n break\n\n case 'recordValue':\n default:\n valA =\n customData.yAxis === 'recordTotal' ? a?.count : a[customData?.yAxisFieldType] || 0\n valB =\n customData.yAxis === 'recordTotal' ? b?.count : b[customData?.yAxisFieldType] || 0\n break\n }\n\n if (valA > valB) return 1 * orderMultiplier\n if (valA < valB) return -1 * orderMultiplier\n return 0\n })\n }\n\n const valueCounts: Record<string, any> = {}\n const valuePercentages: Record<string, any> = {}\n const valueGroups: Record<string, Record<string, number>> = {}\n const valueGroupPercentages: Record<string, Record<string, number>> = {}\n const categories = new Set<string>()\n const stackCategories = new Set<string>()\n\n // 数据分组处理\n chartData.forEach((item: any) => {\n const category = getFieldVal({\n item: item,\n field: newXAxisField,\n })\n\n categories.add(category)\n\n const val =\n customData.yAxis === 'recordTotal' ? item?.count : item[customData?.yAxisFieldType] || 0\n\n if (customData?.isGroup && customData?.groupField) {\n const stackCategory = getFieldVal({\n item: item,\n field: newGroupField,\n })\n\n const key = category ?? t('unknown')\n\n stackCategories.add(stackCategory)\n\n if (!valueGroups[stackCategory]) {\n valueGroups[stackCategory] = {}\n }\n valueGroups[stackCategory][key] = val\n } else {\n const key = category ?? t('unknown')\n valueCounts[key] = val\n }\n })\n\n if (customData?.isGroup && customData?.groupField) {\n const totalPerCategory: Record<string, number> = {}\n\n Object.keys(valueGroups).forEach(stackCategory => {\n Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {\n totalPerCategory[key] = (totalPerCategory[key] || 0) + val\n })\n })\n\n Object.keys(valueGroups).forEach(stackCategory => {\n valueGroupPercentages[stackCategory] = {}\n Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {\n const total = totalPerCategory[key] || 1 // 防止除以 0\n valueGroupPercentages[stackCategory][key] = (val / total) * 100\n })\n })\n } else {\n Object.entries(valueCounts).forEach(([key, val]) => {\n const total = val || 1 // 防止除以 0\n valuePercentages[key] = (val / total) * 100\n })\n }\n\n if (customData?.sortField && customData?.sortOrder) {\n const sortedChartData = sortChartData(chartData, customData.sortField, customData.sortOrder)\n\n const sortedCategories = sortedChartData.map(item =>\n getFieldVal({\n item,\n field: newXAxisField,\n })\n )\n categories.clear()\n sortedCategories.forEach(cat => categories.add(cat))\n }\n\n const labels = Array.from(categories)\n const stackLabels = Array.from(stackCategories)\n\n const chartConfig: any = getChartConfig(customData.type, labels)\n\n const series = []\n if (customData?.isGroup && customData?.groupField) {\n stackLabels.forEach(stackCategory => {\n const data =\n customData.type === 'chart-bar-percentage' ||\n customData.type === 'chart-strip-bar-percentage'\n ? labels.map(label => valueGroupPercentages[stackCategory][label]?.toFixed(2) || 0)\n : labels.map(label => valueGroups[stackCategory][label] || 0)\n series.push(\n getSerie({\n type: customData.type,\n data,\n label,\n name: stackCategory,\n isGroup: customData?.isGroup,\n groupField: customData?.groupField,\n labels,\n })\n )\n })\n } else {\n const data =\n customData.type === 'chart-bar-percentage' ||\n customData.type === 'chart-strip-bar-percentage'\n ? labels.map(label => valuePercentages[label]?.toFixed(2) || 0) // 使用百分比数据\n : labels.map(label => valueCounts[label] || 0)\n series.push(\n getSerie({\n type: customData.type,\n data,\n label,\n name:\n customData.yAxis === 'recordTotal'\n ? t('pb.statisticsText')\n : getFieldLabel(customData?.yAxisField),\n isGroup: customData?.isGroup,\n groupField: customData?.groupField,\n labels,\n })\n )\n }\n\n const grids = getGrid({ series, chartConfig, width })\n\n const options: EChartsOption = {\n legend: {\n type: 'scroll',\n\n left: 'center',\n right: 'center',\n top: '0',\n show: isShowLegend,\n itemWidth: 12,\n itemHeight: 12,\n data: series?.map((item: any) => item?.name || '') || [],\n },\n grid: {\n top: grids.top,\n left: grids.left,\n right: grids.right,\n bottom: grids.bottom,\n },\n graphic: {\n elements: [\n {\n type: 'text',\n left: 'center',\n bottom: '10px',\n style: {\n text: customeStyle?.xtitle || '',\n fill: '#333', // 文本颜色\n fontSize: 12,\n fontWeight: 'bold',\n },\n },\n {\n type: 'text',\n left: '10px',\n top: 'center',\n style: {\n text: customeStyle?.ytitle || '',\n fill: '#333', // 文本颜色\n fontSize: 12,\n fontWeight: 'bold',\n },\n rotation: Math.PI / 2,\n },\n ],\n },\n xAxis: {\n ...chartConfig.xAxis,\n axisTick: {\n show: customData?.chartOptions?.includes('axis'),\n },\n axisLine: {\n show:\n customData?.chartOptions?.includes('axis') ||\n customeStyle?.xchartOptions?.includes('axisLine'),\n },\n axisLabel: {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.xchartOptions?.includes('label'),\n rotate: grids.axisLabelRotate, // 使标签倾斜,调整为合适的角度\n interval: 'auto', // 自动隐藏\n formatter: (value: string) => {\n return value.length > 15 ? `${value.slice(0, 15)}...` : value // 截断并添加 \"...\"\n },\n ...chartConfig.xAxis?.axisLabel,\n },\n splitLine: {\n show: customData?.chartOptions?.includes('splitLine'), // 不显示x轴网格线\n },\n },\n yAxis: {\n ...chartConfig.yAxis,\n axisTick: {\n show: customData?.chartOptions?.includes('axis'),\n },\n axisLine: {\n show:\n customData?.chartOptions?.includes('axis') ||\n customeStyle?.ychartOptions?.includes('axisLine'),\n },\n axisLabel: {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.ychartOptions?.includes('label'),\n formatter: (value: string) => {\n return value.length > 15 ? `${value.slice(0, 15)}...` : value // 截断并添加 \"...\"\n },\n hideOverlap: true,\n ...chartConfig.yAxis?.axisLabel,\n },\n splitLine: {\n show: customData?.chartOptions?.includes('splitLine'), // 不显示x轴网格线\n },\n },\n series: series,\n tooltip: {\n trigger: 'item', // 触发方式:鼠标悬浮在坐标轴上\n axisPointer: {\n type: 'shadow', // 阴影指示器,鼠标悬停时显示柱状图的阴影\n },\n appendTo: 'body',\n },\n }\n setChartOptions(options)\n } else {\n setChartOptions(undefined)\n }\n })\n\n useEffect(() => {\n initChartOptions()\n }, [\n customData?.sortField,\n customData?.sortOrder,\n customData?.type,\n customData?.chartOptions,\n customeStyle,\n chartData,\n width,\n height,\n fieldOptions,\n ])\n\n /* ============================== split =============================== */\n const echartRef = useRef<any>()\n const containerRef = useRef<HTMLDivElement>(null)\n const size = useSize(containerRef)\n\n useEffect(() => {\n if (!!size) {\n echartRef?.current?.resize()\n }\n }, [size])\n\n const isLoading = loading && !chartOptions\n const isEmpyt = !loading && !chartOptions\n const isOk = !isLoading && !isEmpyt\n\n console.log('asd', {\n isLoading,\n isEmpyt,\n isOk,\n })\n\n return (\n <div style={{ width: '100%', height: '100%' }} ref={containerRef}>\n {isLoading && (\n <Spin\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n spinning={loading}\n />\n )}\n {isEmpyt && <Empty />}\n {isOk && <BaseChart echartRef={echartRef} options={chartOptions} />}\n </div>\n )\n}\n\nexport default React.memo(ChartModule)\n"],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