@gct-paas/render 0.1.4-dev.12 → 0.1.4-dev.14

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.
Files changed (66) hide show
  1. package/dist/index.esm.min.js +1 -6118
  2. package/dist/index.min.css +2 -0
  3. package/es/Event/Dependency/displayRule.mjs +66 -2
  4. package/es/Event/baseEvent.d.ts +2 -2
  5. package/es/Event/baseEvent.mjs +3 -3
  6. package/es/Event/eventType.d.ts +1 -1
  7. package/es/Event/eventType.mjs +1 -0
  8. package/es/Event/index.d.ts +4 -2
  9. package/es/Event/index.mjs +3 -0
  10. package/es/Event/utils/runGlobalByPage.d.ts +1 -1
  11. package/es/Event/utils/runGlobalByPage.mjs +4 -4
  12. package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
  13. package/es/components/HandwritingPad.vue.d.ts +27 -0
  14. package/es/components/HandwritingPad.vue.mjs +7 -0
  15. package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
  16. package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
  17. package/es/components/index.d.ts +2 -0
  18. package/es/components/index.mjs +1 -0
  19. package/es/constant/date-time.d.ts +99 -0
  20. package/es/constant/date-time.mjs +187 -0
  21. package/es/constant/index.d.ts +93 -0
  22. package/es/constant/index.mjs +99 -0
  23. package/es/controller/design-render/design-render.controller.d.ts +18 -0
  24. package/es/controller/design-render/design-render.controller.mjs +78 -0
  25. package/es/controller/design-render-base/design-render-base.controller.d.ts +9 -0
  26. package/es/controller/design-render-base/design-render-base.controller.mjs +12 -0
  27. package/es/controller/design-render-container/design-render-container.controller.d.ts +4 -0
  28. package/es/controller/design-render-container/design-render-container.controller.mjs +5 -0
  29. package/es/controller/design-render-item/design-render-item.controller.d.ts +4 -0
  30. package/es/controller/design-render-item/design-render-item.controller.mjs +5 -0
  31. package/es/controller/index.d.ts +4 -0
  32. package/es/controller/index.mjs +4 -0
  33. package/es/hooks/index.d.ts +2 -0
  34. package/es/hooks/index.mjs +2 -0
  35. package/es/hooks/use-design-render-controller/use-design-render-controller.d.ts +11 -0
  36. package/es/hooks/use-design-render-controller/use-design-render-controller.mjs +32 -0
  37. package/es/index.d.ts +4 -0
  38. package/es/index.mjs +14 -3
  39. package/es/interface/controller/i-design-render-base.controller.d.ts +43 -0
  40. package/es/interface/controller/i-design-render-container.controller.d.ts +7 -0
  41. package/es/interface/controller/i-design-render-item.controller.d.ts +7 -0
  42. package/es/interface/controller/i-design-render.controller.d.ts +93 -0
  43. package/es/interface/index.d.ts +12 -0
  44. package/es/interface/provider/i-render-base-node.provider.d.ts +45 -0
  45. package/es/interface/provider/i-render-container-node.provider.d.ts +30 -0
  46. package/es/interface/provider/i-render-editor-node.provider.d.ts +29 -0
  47. package/es/interface/provider/i-render-item-node.provider.d.ts +30 -0
  48. package/es/interface/state/i-design-render-base.state.d.ts +19 -0
  49. package/es/interface/state/i-design-render-container.state.d.ts +11 -0
  50. package/es/interface/state/i-design-render-item.state.d.ts +11 -0
  51. package/es/interface/state/i-design-render.state.d.ts +18 -0
  52. package/es/register/index.d.ts +1 -0
  53. package/es/register/index.mjs +2 -0
  54. package/es/register/node/node.register.d.ts +92 -0
  55. package/es/register/node/node.register.mjs +116 -0
  56. package/es/state/design-render/design-render.state.d.ts +13 -0
  57. package/es/state/design-render/design-render.state.mjs +15 -0
  58. package/es/state/design-render-base/design-render-base.state.d.ts +4 -0
  59. package/es/state/design-render-base/design-render-base.state.mjs +6 -0
  60. package/es/state/design-render-container/design-render-container.state.d.ts +4 -0
  61. package/es/state/design-render-item/design-render-item.state.d.ts +4 -0
  62. package/es/state/index.d.ts +4 -0
  63. package/es/utils/expression/regularExpression/methods.mjs +1 -1
  64. package/es/utils/index.d.ts +1 -1
  65. package/es/utils/useStyle.mjs +8 -1
  66. package/package.json +9 -11
@@ -0,0 +1,2 @@
1
+ .handwriting-pad[data-v-d5b980b7]{display:inline-block}.canvas[data-v-d5b980b7]{touch-action:none;background:0 0;display:block}
2
+ /*$vite$:1*/
@@ -3,7 +3,7 @@ import "../../utils/index.mjs";
3
3
  import { formMap, getPremission } from "../utils/runGlobalByPage.mjs";
4
4
  import { DisplayType } from "@gct-paas/core";
5
5
  import { watchDebounced } from "@vueuse/core";
6
- import { ref, toRef } from "vue";
6
+ import { reactive, ref, toRef } from "vue";
7
7
  //#region src/Event/Dependency/displayRule.ts
8
8
  /**单组件显隐控制 */
9
9
  function useVisibileByRuleHook(props, id) {
@@ -70,5 +70,69 @@ function playValueByRule(form, formCacheMap, displayRule, callback) {
70
70
  });
71
71
  calculate(displayRule, cache).then(callback);
72
72
  }
73
+ /**
74
+ * 需要做控制的数组组件
75
+ * @param optopns 被控制的数组
76
+ * @param tableForm 需要添加的额外的form {key:object }
77
+ * @returns
78
+ */
79
+ function useDisplayRuleOptions(optopns, tableForm) {
80
+ const OptionsFlag = reactive({});
81
+ return toRef(() => {
82
+ if (!optopns) return [];
83
+ return optopns.filter((i) => {
84
+ const { displayRule, hidden, displayType } = i.props || i;
85
+ /**按钮权限 */
86
+ if (!getPremission(i.id)) OptionsFlag[i.id] = false;
87
+ else if (displayType === DisplayType.CONFIG) OptionsFlag[i.id] = !hidden;
88
+ else getOptionsByDisplayRule({
89
+ displayRule,
90
+ tableForm
91
+ }, (f) => {
92
+ OptionsFlag[i.id] = f;
93
+ });
94
+ return OptionsFlag[i.id];
95
+ });
96
+ });
97
+ }
98
+ function useDisplayRuleColumnByStyles(optopnslist, tableForm) {
99
+ if (!optopnslist?.length) return;
100
+ const ColumnEmptyRule = [];
101
+ const ColumnRule = [];
102
+ optopnslist.forEach((i, index) => {
103
+ if (i.displayRule) ColumnRule.push({
104
+ ...i,
105
+ id: index
106
+ });
107
+ else ColumnEmptyRule.push({
108
+ ...i,
109
+ id: index
110
+ });
111
+ });
112
+ const tagWidgetStyle = useDisplayRuleOptionsBytable(ColumnRule, tableForm);
113
+ const tagDefaultStyle = useDisplayRuleOptionsBytable(ColumnEmptyRule, tableForm);
114
+ return toRef(() => tagWidgetStyle?.value || tagDefaultStyle?.value);
115
+ }
116
+ /**
117
+ * 需要做控制的逻辑数组
118
+ * @param optopns 被控制的数组
119
+ * @param tableForm 需要添加的额外的form {key:object }
120
+ * @returns
121
+ */
122
+ function useDisplayRuleOptionsBytable(optopns, tableForm) {
123
+ const OptionsFlag = reactive({});
124
+ if (!optopns) return;
125
+ return toRef(() => optopns.find((i) => {
126
+ const { displayRule, hidden, displayType } = i.props || i;
127
+ if (displayType === DisplayType.CONFIG) OptionsFlag[i.id] = !hidden;
128
+ else getOptionsByDisplayRule({
129
+ displayRule,
130
+ tableForm
131
+ }, (f) => {
132
+ OptionsFlag[i.id] = f;
133
+ });
134
+ return OptionsFlag[i.id];
135
+ }));
136
+ }
73
137
  //#endregion
74
- export { useVisibileByRuleHook };
138
+ export { useDisplayRuleColumnByStyles, useDisplayRuleOptions, useVisibileByRuleHook };
@@ -30,8 +30,8 @@ export declare class Events<TContext extends Context = Context> {
30
30
  /**流程信息 */
31
31
  ProcessAppRoved?: ProcessAppRovedData;
32
32
  pageLayoutMode?: pageLayoutModeEnum;
33
- constructor({ js, css, pageKey, ContextPc, }: EventsConstructor & {
34
- ContextPc: ContextConstructor<TContext>;
33
+ constructor({ js, css, pageKey, ContextVm, }: EventsConstructor & {
34
+ ContextVm: ContextConstructor<TContext>;
35
35
  });
36
36
  /**初始化流程节点信息 */
37
37
  runProcessBySaskId({ taskId, processInstanceId, examineAndApproveState, refFormId, }: IObject): Promise<void>;
@@ -5,9 +5,9 @@ import { $httpBizService, $request, BizService } from "./bizServiceRequest.mjs";
5
5
  import { globalLoading } from "./utils/globalLoading.mjs";
6
6
  import { ProcessAppRovedData } from "./utils/processRovedInfo.mjs";
7
7
  import { FormComponents, INNER_EVENT, t } from "@gct-paas/core";
8
+ import dayjs from "dayjs";
8
9
  import * as _ from "lodash-es";
9
10
  import { cloneDeep, differenceBy } from "lodash-es";
10
- import dayjs from "dayjs";
11
11
  import BigNumberJS from "bignumber.js";
12
12
  import { useStyleTag } from "@vueuse/core";
13
13
  import { toRaw } from "vue";
@@ -23,7 +23,7 @@ var Events = class {
23
23
  /**流程信息 */
24
24
  ProcessAppRoved;
25
25
  pageLayoutMode;
26
- constructor({ js, css, pageKey, ContextPc }) {
26
+ constructor({ js, css, pageKey, ContextVm }) {
27
27
  this.cssData = this.#createCss(css);
28
28
  /**
29
29
  * 绑定外部搜索的表格组件
@@ -41,7 +41,7 @@ var Events = class {
41
41
  * 组件订阅中心
42
42
  */
43
43
  this.#Oberver = {};
44
- this.context = new ContextPc({
44
+ this.context = new ContextVm({
45
45
  $ref: this.getComponent.bind(this),
46
46
  $asyncRef: this.getSyncComponent.bind(this)
47
47
  });
@@ -3,7 +3,7 @@ export interface InitNodeOptions {
3
3
  /**组件方法 */
4
4
  elRef: Record<string, FunctionType> | null;
5
5
  /**组件类型 */
6
- type: FormComponents;
6
+ type: string | FormComponents;
7
7
  }
8
8
  export interface EventsConstructor {
9
9
  js: string;
@@ -0,0 +1 @@
1
+ import "@gct-paas/core";
@@ -1,5 +1,7 @@
1
- export { Globals, pageGlobaVariables, globalVarCaches, formMap, setFormData, pageDataforJson, getPageTitle, getPremission, } from './utils/runGlobalByPage';
1
+ export { Globals, pageGlobaVariables, globalVarCaches, formMap, setFormData, pageDataforJson, getPageTitle, getPremission, PageTypeEnum, } from './utils/runGlobalByPage';
2
2
  export { Events, Context, GctComponent, type ModalInstance } from './baseEvent';
3
- export { type EventsConstructor } from './eventType';
3
+ export * from './eventType';
4
4
  export * from './Dependency/useDependencyToShow';
5
5
  export * from './Dependency/useDependency';
6
+ export * from './Dependency/controller';
7
+ export * from './Dependency/displayRule';
@@ -1,4 +1,7 @@
1
1
  import "./utils/runGlobalByPage.mjs";
2
2
  import "./baseEvent.mjs";
3
+ import "./eventType.mjs";
4
+ import "./Dependency/controller.mjs";
5
+ import "./Dependency/displayRule.mjs";
3
6
  import "./Dependency/useDependencyToShow.mjs";
4
7
  import "./Dependency/useDependency.mjs";
@@ -326,7 +326,7 @@ export declare class Globals {
326
326
  name: string | undefined;
327
327
  }>;
328
328
  /**注册钩子 */
329
- static usePageHooks<T extends Events = Events>(Event: T, pageEvents: RuntimePageJson['pageEvents'], globalEvents: RuntimePageJson['globalEvents'], pageCallback?: (Event: T) => Promise<void>): {
329
+ static usePageHooks<T extends Events = Events>(Event: T, pageEvents?: RuntimePageJson['pageEvents'], globalEvents?: RuntimePageJson['globalEvents'], pageCallback?: (Event: T) => Promise<void>): {
330
330
  pageload: import('vue').Ref<boolean, boolean>;
331
331
  };
332
332
  }
@@ -266,7 +266,7 @@ var Globals = class Globals {
266
266
  if (pageCallback) await pageCallback(Event);
267
267
  pageload.value = true;
268
268
  /**全局钩子 */
269
- if (globalEvents.pageMounted) for (const fun of this.globalHookCaches.pageMounted) await fun();
269
+ if (globalEvents?.pageMounted) for (const fun of this.globalHookCaches.pageMounted) await fun();
270
270
  const { extraParams, name } = pageEvents?.pageMounted || {};
271
271
  if (name)
272
272
  /**页面钩子 */
@@ -282,12 +282,12 @@ var Globals = class Globals {
282
282
  /**页面销毁时候的钩子函数 */
283
283
  Event.runExportByName(name, extraParams);
284
284
  /**全局钩子 */
285
- if (globalEvents.pageDestroyed) for (const fun of this.globalHookCaches.pageDestroyed) await fun();
285
+ if (globalEvents?.pageDestroyed) for (const fun of this.globalHookCaches.pageDestroyed) await fun();
286
286
  });
287
287
  onActivated(async () => {
288
288
  Globals.setContextByKey(Event.context);
289
289
  /**全局钩子 */
290
- if (globalEvents.pageActivated) for (const fun of this.globalHookCaches.pageActivated) await fun();
290
+ if (globalEvents?.pageActivated) for (const fun of this.globalHookCaches.pageActivated) await fun();
291
291
  const { extraParams, name } = pageEvents?.pageActivated || {};
292
292
  if (name)
293
293
  /**页面钩子 */
@@ -299,4 +299,4 @@ var Globals = class Globals {
299
299
  };
300
300
  var getPremission = Globals.getPremission.bind(Globals);
301
301
  //#endregion
302
- export { Globals, formMap, getPageTitle, getPremission, globalVarCaches, pageDataforJson, pageGlobaVariables, setFormData };
302
+ export { Globals, PageTypeEnum, formMap, getPageTitle, getPremission, globalVarCaches, pageDataforJson, pageGlobaVariables, setFormData };
@@ -0,0 +1,8 @@
1
+ //#region \0plugin-vue:export-helper
2
+ var _plugin_vue_export_helper_default = (sfc, props) => {
3
+ const target = sfc.__vccOpts || sfc;
4
+ for (const [key, val] of props) target[key] = val;
5
+ return target;
6
+ };
7
+ //#endregion
8
+ export { _plugin_vue_export_helper_default as default };
@@ -0,0 +1,27 @@
1
+ type __VLS_Props = {
2
+ width?: number;
3
+ height?: number;
4
+ backgroundColor?: string;
5
+ lineWidth?: number;
6
+ strokeStyle?: string;
7
+ };
8
+ /** 清空 */
9
+ declare function clear(): void;
10
+ /** 获取签名 */
11
+ declare function getValue(): string | undefined;
12
+ /** 回显 */
13
+ declare function setValue(base64: string): void;
14
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {
15
+ getValue: typeof getValue;
16
+ setValue: typeof setValue;
17
+ clear: typeof clear;
18
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
+ width: number;
20
+ height: number;
21
+ backgroundColor: string;
22
+ lineWidth: number;
23
+ strokeStyle: string;
24
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
25
+ canvasRef: HTMLCanvasElement;
26
+ }, HTMLDivElement>;
27
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default from "./HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs";
2
+ import './HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css';/* empty css */
3
+ import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.mjs";
4
+ //#region src/components/HandwritingPad.vue
5
+ var HandwritingPad_default = /* @__PURE__ */ _plugin_vue_export_helper_default(HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default, [["__scopeId", "data-v-d5b980b7"]]);
6
+ //#endregion
7
+ export { HandwritingPad_default as default };
@@ -0,0 +1,109 @@
1
+ import { createElementBlock, createElementVNode, defineComponent, onMounted, openBlock, ref } from "vue";
2
+ //#region src/components/HandwritingPad.vue?vue&type=script&setup=true&name=HandwritingPad&lang.ts
3
+ var _hoisted_1 = { class: "handwriting-pad" };
4
+ var _hoisted_2 = ["width", "height"];
5
+ var HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default = /* @__PURE__ */ defineComponent({
6
+ __name: "HandwritingPad",
7
+ props: {
8
+ width: { default: 300 },
9
+ height: { default: 150 },
10
+ backgroundColor: { default: "transparent" },
11
+ lineWidth: { default: 2 },
12
+ strokeStyle: { default: "#000" }
13
+ },
14
+ setup(__props, { expose: __expose }) {
15
+ const props = __props;
16
+ const canvasRef = ref(null);
17
+ let ctx = null;
18
+ let isDrawing = false;
19
+ let startX = 0;
20
+ let startY = 0;
21
+ onMounted(() => {
22
+ ctx = canvasRef.value.getContext("2d");
23
+ if (props.backgroundColor !== "transparent") {
24
+ ctx.fillStyle = props.backgroundColor;
25
+ ctx.fillRect(0, 0, props.width, props.height);
26
+ }
27
+ ctx.lineWidth = props.lineWidth;
28
+ ctx.strokeStyle = props.strokeStyle;
29
+ });
30
+ /** 统一坐标获取 */
31
+ function getPoint(e) {
32
+ const rect = canvasRef.value.getBoundingClientRect();
33
+ if ("touches" in e) return {
34
+ x: e.touches[0].clientX - rect.left,
35
+ y: e.touches[0].clientY - rect.top
36
+ };
37
+ return {
38
+ x: e.offsetX,
39
+ y: e.offsetY
40
+ };
41
+ }
42
+ function start(e) {
43
+ e.preventDefault();
44
+ isDrawing = true;
45
+ const { x, y } = getPoint(e);
46
+ startX = x;
47
+ startY = y;
48
+ }
49
+ function move(e) {
50
+ if (!isDrawing || !ctx) return;
51
+ e.preventDefault();
52
+ const { x, y } = getPoint(e);
53
+ ctx.beginPath();
54
+ ctx.moveTo(startX, startY);
55
+ ctx.lineTo(x, y);
56
+ ctx.stroke();
57
+ ctx.closePath();
58
+ startX = x;
59
+ startY = y;
60
+ }
61
+ function end(e) {
62
+ e.preventDefault();
63
+ isDrawing = false;
64
+ }
65
+ /** 清空 */
66
+ function clear() {
67
+ ctx?.clearRect(0, 0, props.width, props.height);
68
+ if (props.backgroundColor !== "transparent") {
69
+ ctx.fillStyle = props.backgroundColor;
70
+ ctx.fillRect(0, 0, props.width, props.height);
71
+ }
72
+ }
73
+ /** 获取签名 */
74
+ function getValue() {
75
+ return canvasRef.value?.toDataURL();
76
+ }
77
+ /** 回显 */
78
+ function setValue(base64) {
79
+ const img = new Image();
80
+ img.src = base64;
81
+ img.onload = () => {
82
+ ctx?.drawImage(img, 0, 0);
83
+ };
84
+ }
85
+ __expose({
86
+ getValue,
87
+ setValue,
88
+ clear
89
+ });
90
+ return (_ctx, _cache) => {
91
+ return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("canvas", {
92
+ ref_key: "canvasRef",
93
+ ref: canvasRef,
94
+ width: __props.width,
95
+ height: __props.height,
96
+ class: "canvas",
97
+ onMousedown: start,
98
+ onMousemove: move,
99
+ onMouseup: end,
100
+ onMouseleave: end,
101
+ onTouchstart: start,
102
+ onTouchmove: move,
103
+ onTouchend: end
104
+ }, null, 40, _hoisted_2)]);
105
+ };
106
+ }
107
+ });
108
+ //#endregion
109
+ export { HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default as default };
@@ -0,0 +1,9 @@
1
+
2
+ .handwriting-pad[data-v-d5b980b7] {
3
+ display: inline-block;
4
+ }
5
+ .canvas[data-v-d5b980b7] {
6
+ display: block;
7
+ background: transparent;
8
+ touch-action: none;
9
+ }
@@ -0,0 +1,2 @@
1
+ import { default as HandwritingPad } from './HandwritingPad.vue';
2
+ export { HandwritingPad };
@@ -0,0 +1 @@
1
+ import "./HandwritingPad.vue.mjs";
@@ -0,0 +1,99 @@
1
+ import { FieldSysVarDefaultValueEnum } from '@gct-paas/core';
2
+ import { default as dayjs, Dayjs } from 'dayjs';
3
+ export declare const DESIGN_TYPE = "view-design";
4
+ export declare const DESIGN_DATA_KEY_TAG = "id";
5
+ /**
6
+ * 设计项标识标签属性
7
+ */
8
+ export declare enum DesignItemAttribute {
9
+ /**
10
+ * 可以激活项的标识
11
+ */
12
+ ACTIVE_TAG = "design-active-item",
13
+ /**
14
+ * 拖拽项标识属性
15
+ */
16
+ DRAG_TAG = "design-drop-item",
17
+ /**
18
+ * 项排序值标识
19
+ */
20
+ INDEX_TAG = "design-item-index",
21
+ /**
22
+ * 设计项标识属性
23
+ */
24
+ NODE_ID_TAG = "design-item-id",
25
+ /**
26
+ * 项文本名称
27
+ */
28
+ DESIGN_NAME = "design-item-name",
29
+ /**
30
+ * 分组标识
31
+ */
32
+ GROUP_TAG = "design-group-tag",
33
+ /**
34
+ * 拖拽组类型
35
+ */
36
+ DRAG_GROUP_TYPE = "drag-group-type",
37
+ /**
38
+ * 是否为行内元素
39
+ */
40
+ IS_INLINE_BLOCK = "is-inline-block",
41
+ /**
42
+ * 特殊情况下,例如表格将表格元素自己复制了好几份,需要指定实际呈现元素在 querySelectorAll 中的位置。便于悬浮或者选中时位置的计算
43
+ */
44
+ SELECTOR_INDEX = "selector-index"
45
+ }
46
+ /** 日期时间可选范围 */
47
+ export declare const DateRangeMap: {
48
+ WEEK_NOW: (current: number) => {
49
+ disabled: boolean;
50
+ minDate: dayjs.Dayjs;
51
+ maxDate: dayjs.Dayjs;
52
+ };
53
+ MONTH_NOW: (current: number) => {
54
+ disabled: boolean;
55
+ minDate: dayjs.Dayjs;
56
+ maxDate: dayjs.Dayjs;
57
+ };
58
+ QUARTER_NOW: (current: number) => {
59
+ disabled: boolean;
60
+ minDate: dayjs.Dayjs;
61
+ maxDate: dayjs.Dayjs;
62
+ };
63
+ YEAR_NOW: (current: number) => {
64
+ disabled: boolean;
65
+ minDate: dayjs.Dayjs;
66
+ maxDate: dayjs.Dayjs;
67
+ };
68
+ WEEk_BEFORE: (current: number) => {
69
+ disabled: boolean;
70
+ minDate: dayjs.Dayjs;
71
+ maxDate: dayjs.Dayjs;
72
+ };
73
+ MONTH_BEFORE: (current: number) => {
74
+ disabled: boolean;
75
+ minDate: dayjs.Dayjs;
76
+ maxDate: dayjs.Dayjs;
77
+ };
78
+ QUARTER_BEFORE: (current: number) => {
79
+ disabled: boolean;
80
+ minDate: dayjs.Dayjs;
81
+ maxDate: dayjs.Dayjs;
82
+ };
83
+ YEAR_BEFORE: (current: number) => {
84
+ disabled: boolean;
85
+ minDate: dayjs.Dayjs;
86
+ maxDate: dayjs.Dayjs;
87
+ };
88
+ DATE_BEFORE: (current: number) => {
89
+ disabled: boolean;
90
+ maxDate: dayjs.Dayjs;
91
+ };
92
+ DATE_AFTER: (current: number) => {
93
+ disabled: boolean;
94
+ minDate: dayjs.Dayjs;
95
+ };
96
+ };
97
+ export declare const getDisabledDate: (current: Dayjs, rangeType: keyof typeof DateRangeMap) => boolean;
98
+ export declare const getMobileDateRange: (rangeType: keyof typeof DateRangeMap) => any;
99
+ export declare const getDefaultDate: (type: FieldSysVarDefaultValueEnum, formatType: string) => string | undefined;
@@ -0,0 +1,187 @@
1
+ import { FieldSysVarDefaultValueEnum } from "@gct-paas/core";
2
+ import dayjs from "dayjs";
3
+ //#region src/constant/date-time.ts
4
+ var DESIGN_TYPE = "view-design";
5
+ var DESIGN_DATA_KEY_TAG = "id";
6
+ /**
7
+ * 设计项标识标签属性
8
+ */
9
+ var DesignItemAttribute = /* @__PURE__ */ function(DesignItemAttribute) {
10
+ /**
11
+ * 可以激活项的标识
12
+ */
13
+ DesignItemAttribute["ACTIVE_TAG"] = "design-active-item";
14
+ /**
15
+ * 拖拽项标识属性
16
+ */
17
+ DesignItemAttribute["DRAG_TAG"] = "design-drop-item";
18
+ /**
19
+ * 项排序值标识
20
+ */
21
+ DesignItemAttribute["INDEX_TAG"] = "design-item-index";
22
+ /**
23
+ * 设计项标识属性
24
+ */
25
+ DesignItemAttribute["NODE_ID_TAG"] = "design-item-id";
26
+ /**
27
+ * 项文本名称
28
+ */
29
+ DesignItemAttribute["DESIGN_NAME"] = "design-item-name";
30
+ /**
31
+ * 分组标识
32
+ */
33
+ DesignItemAttribute["GROUP_TAG"] = "design-group-tag";
34
+ /**
35
+ * 拖拽组类型
36
+ */
37
+ DesignItemAttribute["DRAG_GROUP_TYPE"] = "drag-group-type";
38
+ /**
39
+ * 是否为行内元素
40
+ */
41
+ DesignItemAttribute["IS_INLINE_BLOCK"] = "is-inline-block";
42
+ /**
43
+ * 特殊情况下,例如表格将表格元素自己复制了好几份,需要指定实际呈现元素在 querySelectorAll 中的位置。便于悬浮或者选中时位置的计算
44
+ */
45
+ DesignItemAttribute["SELECTOR_INDEX"] = "selector-index";
46
+ return DesignItemAttribute;
47
+ }({});
48
+ /** 日期时间可选范围 */
49
+ var DateRangeMap = {
50
+ WEEK_NOW: (current) => {
51
+ const startDate = dayjs().startOf("week").add(1, "day");
52
+ const endDate = dayjs().endOf("week").add(1, "day");
53
+ const startTDS = startDate.valueOf();
54
+ const endTDS = endDate.valueOf();
55
+ return {
56
+ disabled: current < startTDS || current > endTDS,
57
+ minDate: startDate,
58
+ maxDate: endDate
59
+ };
60
+ },
61
+ MONTH_NOW: (current) => {
62
+ const startDate = dayjs().startOf("month");
63
+ const endDate = dayjs().endOf("month");
64
+ const startTDS = startDate.valueOf();
65
+ const endTDS = endDate.valueOf();
66
+ return {
67
+ disabled: current < startTDS || current > endTDS,
68
+ minDate: startDate,
69
+ maxDate: endDate
70
+ };
71
+ },
72
+ QUARTER_NOW: (current) => {
73
+ const startDate = dayjs().startOf("quarter");
74
+ const endDate = dayjs().endOf("quarter");
75
+ const startTDS = startDate.valueOf();
76
+ const endTDS = endDate.valueOf();
77
+ return {
78
+ disabled: current < startTDS || current > endTDS,
79
+ minDate: startDate,
80
+ maxDate: endDate
81
+ };
82
+ },
83
+ YEAR_NOW: (current) => {
84
+ const startDate = dayjs().startOf("year");
85
+ const endDate = dayjs().endOf("year");
86
+ const startTDS = startDate.valueOf();
87
+ const endTDS = endDate.valueOf();
88
+ return {
89
+ disabled: current < startTDS || current > endTDS,
90
+ minDate: startDate,
91
+ maxDate: endDate
92
+ };
93
+ },
94
+ WEEk_BEFORE: (current) => {
95
+ dayjs.locale("zh-cn");
96
+ const lastWeekStart = dayjs().startOf("week").subtract(1, "week");
97
+ const lastWeekEnd = lastWeekStart.clone().endOf("week");
98
+ const startTDS = lastWeekStart.valueOf();
99
+ const endTDS = lastWeekEnd.valueOf();
100
+ return {
101
+ disabled: current < startTDS || current > endTDS,
102
+ minDate: lastWeekStart,
103
+ maxDate: lastWeekEnd
104
+ };
105
+ },
106
+ MONTH_BEFORE: (current) => {
107
+ const startDate = dayjs().add(-1, "month").startOf("month");
108
+ const endDate = dayjs().add(-1, "month").endOf("month");
109
+ const startTDS = startDate.valueOf();
110
+ const endTDS = endDate.valueOf();
111
+ return {
112
+ disabled: current < startTDS || current > endTDS,
113
+ minDate: startDate,
114
+ maxDate: endDate
115
+ };
116
+ },
117
+ QUARTER_BEFORE: (current) => {
118
+ const startDate = dayjs().add(-1, "quarter").startOf("quarter");
119
+ const endDate = dayjs().add(-1, "quarter").endOf("quarter");
120
+ const startTDS = startDate.valueOf();
121
+ const endTDS = endDate.valueOf();
122
+ return {
123
+ disabled: current < startTDS || current > endTDS,
124
+ minDate: startDate,
125
+ maxDate: endDate
126
+ };
127
+ },
128
+ YEAR_BEFORE: (current) => {
129
+ const startDate = dayjs().add(-1, "year").startOf("year");
130
+ const endDate = dayjs().add(-1, "year").endOf("year");
131
+ const startTDS = startDate.valueOf();
132
+ const endTDS = endDate.valueOf();
133
+ return {
134
+ disabled: current < startTDS || current > endTDS,
135
+ minDate: startDate,
136
+ maxDate: endDate
137
+ };
138
+ },
139
+ DATE_BEFORE: (current) => {
140
+ const endDate = dayjs().add(-1, "day");
141
+ return {
142
+ disabled: current < endDate.valueOf(),
143
+ maxDate: endDate
144
+ };
145
+ },
146
+ DATE_AFTER: (current) => {
147
+ const startDate = dayjs();
148
+ return {
149
+ disabled: current > startDate.valueOf(),
150
+ minDate: startDate
151
+ };
152
+ }
153
+ };
154
+ var getDisabledDate = (current, rangeType) => {
155
+ const tds = dayjs(current).valueOf();
156
+ const func = DateRangeMap[rangeType];
157
+ if (func) {
158
+ const { disabled } = func(tds);
159
+ return disabled;
160
+ }
161
+ return false;
162
+ };
163
+ var getMobileDateRange = (rangeType) => {
164
+ const func = DateRangeMap[rangeType];
165
+ if (func) {
166
+ const { minDate, maxDate } = func(0);
167
+ return Object.assign({}, minDate && { minDate: new Date(minDate) }, maxDate && { maxDate: new Date(maxDate) });
168
+ }
169
+ return {};
170
+ };
171
+ var getDefaultDate = (type, formatType) => {
172
+ let defaultDate;
173
+ switch (type) {
174
+ case FieldSysVarDefaultValueEnum.SYS_DATE:
175
+ defaultDate = dayjs().format(formatType ?? "YYYY-MM-DD");
176
+ break;
177
+ case FieldSysVarDefaultValueEnum.SYS_DATE_TIME:
178
+ defaultDate = dayjs().format(formatType ?? "YYYY-MM-DD HH:mm:ss");
179
+ break;
180
+ case FieldSysVarDefaultValueEnum.SYS_TIME:
181
+ defaultDate = dayjs().format(formatType ?? "HH:mm:ss");
182
+ break;
183
+ }
184
+ return defaultDate;
185
+ };
186
+ //#endregion
187
+ export { DESIGN_DATA_KEY_TAG, DESIGN_TYPE, DateRangeMap, DesignItemAttribute, getDefaultDate, getDisabledDate, getMobileDateRange };