vue-devui 1.0.0-alpha.4 → 1.0.0-beta.10
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/accordion/index.d.ts +7 -0
- package/accordion/index.es.js +237 -1
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.d.ts +7 -0
- package/alert/index.es.js +175 -1
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/anchor/index.d.ts +7 -0
- package/anchor/index.es.js +263 -1
- package/anchor/index.umd.js +1 -1
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +301 -1
- package/avatar/index.umd.js +1 -1
- package/back-top/index.d.ts +7 -0
- package/back-top/index.es.js +128 -0
- package/back-top/index.umd.js +1 -0
- package/back-top/package.json +7 -0
- package/back-top/style.css +1 -0
- package/badge/index.d.ts +7 -0
- package/badge/index.es.js +95 -1
- package/badge/index.umd.js +1 -1
- package/breadcrumb/index.d.ts +7 -0
- package/breadcrumb/index.es.js +127 -1
- package/breadcrumb/index.umd.js +1 -1
- package/breadcrumb/style.css +1 -1
- package/button/index.d.ts +7 -0
- package/button/index.es.js +190 -1
- package/button/index.umd.js +1 -1
- package/card/index.d.ts +7 -0
- package/card/index.es.js +61 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.d.ts +7 -0
- package/carousel/index.es.js +329 -1
- package/carousel/index.umd.js +1 -1
- package/cascader/index.d.ts +7 -0
- package/cascader/index.es.js +1343 -1
- package/cascader/index.umd.js +1 -1
- package/cascader/style.css +1 -1
- package/checkbox/index.d.ts +7 -0
- package/checkbox/index.es.js +377 -1
- package/checkbox/index.umd.js +1 -1
- package/comment/index.d.ts +7 -0
- package/comment/index.es.js +85 -0
- package/comment/index.umd.js +1 -0
- package/comment/package.json +7 -0
- package/comment/style.css +1 -0
- package/countdown/index.d.ts +7 -0
- package/countdown/index.es.js +176 -0
- package/countdown/index.umd.js +1 -0
- package/countdown/package.json +7 -0
- package/countdown/style.css +1 -0
- package/date-picker/index.d.ts +7 -0
- package/date-picker/index.es.js +1172 -1
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.d.ts +7 -0
- package/dragdrop/index.es.js +32 -0
- package/dragdrop/index.umd.js +1 -0
- package/dragdrop/package.json +7 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +288 -0
- package/drawer/index.umd.js +1 -0
- package/drawer/package.json +7 -0
- package/drawer/style.css +1 -0
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +527 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.d.ts +7 -0
- package/editable-select/index.es.js +5793 -1
- package/editable-select/index.umd.js +27 -1
- package/editable-select/style.css +1 -1
- package/form/index.d.ts +7 -0
- package/form/index.es.js +2244 -0
- package/form/index.umd.js +1 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/fullscreen/index.d.ts +7 -0
- package/fullscreen/index.es.js +163 -1
- package/fullscreen/index.umd.js +1 -1
- package/gantt/index.d.ts +7 -0
- package/gantt/index.es.js +535 -0
- package/gantt/index.umd.js +1 -0
- package/gantt/package.json +7 -0
- package/gantt/style.css +1 -0
- package/grid/index.d.ts +7 -0
- package/grid/index.es.js +269 -0
- package/grid/index.umd.js +1 -0
- package/grid/package.json +7 -0
- package/grid/style.css +1 -0
- package/icon/index.d.ts +7 -0
- package/icon/index.es.js +75 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +480 -1
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/index.d.ts +7 -0
- package/input/index.d.ts +7 -0
- package/input/index.es.js +190 -1
- package/input/index.umd.js +1 -1
- package/input-icon/index.d.ts +7 -0
- package/input-icon/index.es.js +332 -0
- package/input-icon/index.umd.js +1 -0
- package/input-icon/package.json +7 -0
- package/input-icon/style.css +1 -0
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +240 -1
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +100 -0
- package/layout/index.umd.js +1 -0
- package/layout/package.json +7 -0
- package/layout/style.css +1 -0
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +256 -1
- package/loading/index.umd.js +1 -1
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +1027 -1
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.d.ts +7 -0
- package/nav-sprite/index.es.js +742 -0
- package/nav-sprite/index.umd.js +1 -0
- package/nav-sprite/package.json +7 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/MultiUpload.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Toast.js +3 -0
- package/nuxt/components/ToastService.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.d.ts +7 -0
- package/overlay/index.es.js +368 -1
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -33
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +642 -1
- package/pagination/index.umd.js +1 -1
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +205 -1
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.d.ts +7 -0
- package/popover/index.es.js +236 -1
- package/popover/index.umd.js +1 -1
- package/popover/style.css +1 -1
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +153 -1
- package/progress/index.umd.js +3 -1
- package/quadrant-diagram/index.d.ts +7 -0
- package/quadrant-diagram/index.es.js +489 -1
- package/quadrant-diagram/index.umd.js +1 -1
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +225 -1
- package/radio/index.umd.js +1 -1
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +220 -1
- package/rate/index.umd.js +1 -1
- package/read-tip/index.d.ts +7 -0
- package/read-tip/index.es.js +258 -0
- package/read-tip/index.umd.js +1 -0
- package/read-tip/package.json +7 -0
- package/read-tip/style.css +1 -0
- package/result/index.d.ts +7 -0
- package/result/index.es.js +119 -0
- package/result/index.umd.js +1 -0
- package/result/package.json +7 -0
- package/result/style.css +1 -0
- package/ripple/index.d.ts +7 -0
- package/ripple/index.es.js +181 -1
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +543 -1
- package/search/index.umd.js +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +706 -1
- package/select/index.umd.js +1 -1
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +297 -1
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.d.ts +7 -0
- package/slider/index.es.js +199 -1
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.d.ts +7 -0
- package/splitter/index.es.js +636 -1
- package/splitter/index.umd.js +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +280 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.d.ts +7 -0
- package/status/index.es.js +42 -1
- package/status/index.umd.js +1 -1
- package/steps-guide/index.d.ts +7 -0
- package/steps-guide/index.es.js +239 -1
- package/steps-guide/index.umd.js +1 -1
- package/steps-guide/style.css +1 -1
- package/sticky/index.d.ts +7 -0
- package/sticky/index.es.js +197 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +100 -1
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +1626 -1
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +195 -1
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.d.ts +7 -0
- package/tag/index.es.js +131 -0
- package/tag/index.umd.js +1 -0
- package/tag/package.json +7 -0
- package/tag/style.css +1 -0
- package/tag-input/index.d.ts +7 -0
- package/tag-input/index.es.js +329 -1
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.d.ts +7 -0
- package/textarea/index.es.js +132 -0
- package/textarea/index.umd.js +1 -0
- package/textarea/package.json +7 -0
- package/textarea/style.css +1 -0
- package/time-axis/index.d.ts +7 -0
- package/time-axis/index.es.js +299 -0
- package/time-axis/index.umd.js +1 -0
- package/time-axis/package.json +7 -0
- package/time-axis/style.css +1 -0
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +1053 -1
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.d.ts +7 -0
- package/toast/index.es.js +2060 -1
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +171 -1
- package/tooltip/index.umd.js +1 -1
- package/transfer/index.d.ts +7 -0
- package/transfer/index.es.js +1725 -1
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +907 -1
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/tree-select/index.d.ts +7 -0
- package/tree-select/index.es.js +528 -0
- package/tree-select/index.umd.js +1 -0
- package/tree-select/package.json +7 -0
- package/tree-select/style.css +1 -0
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +3179 -1
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +27755 -1
- package/vue-devui.umd.js +29 -1
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import { defineComponent, toRefs, ref, onMounted, watch, createVNode, withDirectives, resolveComponent, resolveDirective, createTextVNode } from "vue";
|
|
2
|
+
var ganttScale = "";
|
|
3
|
+
var GanttScaleUnit;
|
|
4
|
+
(function(GanttScaleUnit2) {
|
|
5
|
+
GanttScaleUnit2["day"] = "day";
|
|
6
|
+
GanttScaleUnit2["week"] = "week";
|
|
7
|
+
GanttScaleUnit2["month"] = "month";
|
|
8
|
+
})(GanttScaleUnit || (GanttScaleUnit = {}));
|
|
9
|
+
var GanttMarkerType;
|
|
10
|
+
(function(GanttMarkerType2) {
|
|
11
|
+
GanttMarkerType2["milestone"] = "milestone";
|
|
12
|
+
GanttMarkerType2["month"] = "month";
|
|
13
|
+
GanttMarkerType2["week"] = "week";
|
|
14
|
+
})(GanttMarkerType || (GanttMarkerType = {}));
|
|
15
|
+
var UnitRole;
|
|
16
|
+
(function(UnitRole2) {
|
|
17
|
+
UnitRole2[UnitRole2["day"] = 10] = "day";
|
|
18
|
+
UnitRole2[UnitRole2["week"] = 20] = "week";
|
|
19
|
+
UnitRole2[UnitRole2["month"] = 30] = "month";
|
|
20
|
+
})(UnitRole || (UnitRole = {}));
|
|
21
|
+
const isSameDate = (date, compareDate) => {
|
|
22
|
+
return date.getFullYear() === compareDate.getFullYear() && date.getMonth() === compareDate.getMonth() && date.getDate() === compareDate.getDate();
|
|
23
|
+
};
|
|
24
|
+
const useScaleData = (milestoneList) => {
|
|
25
|
+
const SCALE_START_LABLE_OFFSET = 7;
|
|
26
|
+
const generateDateInfo = (date, index2) => {
|
|
27
|
+
const dateInfo = {
|
|
28
|
+
dayOfMonthLabel: "",
|
|
29
|
+
dayOfWeekLabel: "",
|
|
30
|
+
monthLabel: "",
|
|
31
|
+
yearLabel: "",
|
|
32
|
+
date,
|
|
33
|
+
monthStart: false,
|
|
34
|
+
weekend: false,
|
|
35
|
+
today: false,
|
|
36
|
+
milestone: "",
|
|
37
|
+
highlightStart: false,
|
|
38
|
+
scaleStartVisable: true,
|
|
39
|
+
index: index2
|
|
40
|
+
};
|
|
41
|
+
const dayOfMonth = date.getDate();
|
|
42
|
+
dateInfo.dayOfMonthLabel = dayOfMonth + "";
|
|
43
|
+
if (dayOfMonth === 1) {
|
|
44
|
+
dateInfo.monthStart = true;
|
|
45
|
+
}
|
|
46
|
+
const dayOfWeek = date.getDay();
|
|
47
|
+
dateInfo.dayOfWeekLabel = dayOfWeek + "";
|
|
48
|
+
if (dayOfWeek === 6) {
|
|
49
|
+
dateInfo.weekend = true;
|
|
50
|
+
}
|
|
51
|
+
const month = date.getMonth() + 1;
|
|
52
|
+
dateInfo.monthLabel = month + "";
|
|
53
|
+
const year = date.getFullYear();
|
|
54
|
+
dateInfo.yearLabel = year + "";
|
|
55
|
+
if (isSameDate(date, new Date())) {
|
|
56
|
+
dateInfo.today = true;
|
|
57
|
+
}
|
|
58
|
+
if (new Date(year, month - 1, dayOfMonth + SCALE_START_LABLE_OFFSET).getMonth() > month - 1) {
|
|
59
|
+
dateInfo.scaleStartVisable = false;
|
|
60
|
+
}
|
|
61
|
+
if (milestoneList.value) {
|
|
62
|
+
milestoneList.value.forEach((milestone) => {
|
|
63
|
+
if (milestone.date) {
|
|
64
|
+
if (isSameDate(milestone.date, dateInfo.date)) {
|
|
65
|
+
dateInfo.milestone = milestone.lable;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return dateInfo;
|
|
71
|
+
};
|
|
72
|
+
const getNextDay = (date) => {
|
|
73
|
+
const nextDayDate = date.setDate(date.getDate() + 1);
|
|
74
|
+
return new Date(nextDayDate);
|
|
75
|
+
};
|
|
76
|
+
const generateScaleData = (startDate, endDate) => {
|
|
77
|
+
const scaleData = [];
|
|
78
|
+
let handleDate = startDate;
|
|
79
|
+
let index2 = 0;
|
|
80
|
+
while (!isSameDate(handleDate, endDate)) {
|
|
81
|
+
const dateInfo = generateDateInfo(handleDate, index2);
|
|
82
|
+
scaleData.push(dateInfo);
|
|
83
|
+
handleDate = getNextDay(new Date(handleDate));
|
|
84
|
+
index2++;
|
|
85
|
+
}
|
|
86
|
+
console.log({ scaleData });
|
|
87
|
+
return scaleData;
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
generateScaleData
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const i18nText = {
|
|
94
|
+
en: {
|
|
95
|
+
today: "today",
|
|
96
|
+
monthsOfYear: [
|
|
97
|
+
"January",
|
|
98
|
+
"February",
|
|
99
|
+
"March",
|
|
100
|
+
"April",
|
|
101
|
+
"May",
|
|
102
|
+
"June",
|
|
103
|
+
"July",
|
|
104
|
+
"August",
|
|
105
|
+
"September",
|
|
106
|
+
"October",
|
|
107
|
+
"November",
|
|
108
|
+
"December"
|
|
109
|
+
],
|
|
110
|
+
yearDisplay(year) {
|
|
111
|
+
return `${year}`;
|
|
112
|
+
},
|
|
113
|
+
monthDisplay(strMonthIndex) {
|
|
114
|
+
return this.monthsOfYear[Number(strMonthIndex) - 1];
|
|
115
|
+
},
|
|
116
|
+
yearAndMonthDisplay(year, strMonthIndex) {
|
|
117
|
+
return this.yearDisplay(year) + this.monthDisplay(strMonthIndex);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
zh: {
|
|
121
|
+
today: "\u4ECA\u5929",
|
|
122
|
+
monthsOfYear: [
|
|
123
|
+
"1\u6708",
|
|
124
|
+
"2\u6708",
|
|
125
|
+
"3\u6708",
|
|
126
|
+
"4\u6708",
|
|
127
|
+
"5\u6708",
|
|
128
|
+
"6\u6708",
|
|
129
|
+
"7\u6708",
|
|
130
|
+
"8\u6708",
|
|
131
|
+
"9\u6708",
|
|
132
|
+
"10\u6708",
|
|
133
|
+
"11\u6708",
|
|
134
|
+
"12\u6708"
|
|
135
|
+
],
|
|
136
|
+
yearDisplay(year) {
|
|
137
|
+
return `${year}\u5E74`;
|
|
138
|
+
},
|
|
139
|
+
monthDisplay(strMonthIndex) {
|
|
140
|
+
return this.monthsOfYear[Number(strMonthIndex) - 1];
|
|
141
|
+
},
|
|
142
|
+
yearAndMonthDisplay(year, strMonthIndex) {
|
|
143
|
+
return this.yearDisplay(year) + this.monthDisplay(strMonthIndex);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
var DGanttScale = defineComponent({
|
|
148
|
+
name: "DGanttScale",
|
|
149
|
+
props: {
|
|
150
|
+
unit: {
|
|
151
|
+
type: String,
|
|
152
|
+
default: GanttScaleUnit.day
|
|
153
|
+
},
|
|
154
|
+
height: {
|
|
155
|
+
type: Number
|
|
156
|
+
},
|
|
157
|
+
startDate: {
|
|
158
|
+
type: Date
|
|
159
|
+
},
|
|
160
|
+
endDate: {
|
|
161
|
+
type: Date
|
|
162
|
+
},
|
|
163
|
+
ganttScaleContainerOffsetLeft: {
|
|
164
|
+
type: Number
|
|
165
|
+
},
|
|
166
|
+
milestoneList: {
|
|
167
|
+
type: Array
|
|
168
|
+
},
|
|
169
|
+
scrollElement: {
|
|
170
|
+
type: Object
|
|
171
|
+
},
|
|
172
|
+
ganttBarContainerElement: {
|
|
173
|
+
type: Object
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
emits: ["addMilestone"],
|
|
177
|
+
setup(props, ctx) {
|
|
178
|
+
const {
|
|
179
|
+
startDate,
|
|
180
|
+
endDate,
|
|
181
|
+
milestoneList,
|
|
182
|
+
scrollElement,
|
|
183
|
+
unit
|
|
184
|
+
} = toRefs(props);
|
|
185
|
+
const scaleData = ref([]);
|
|
186
|
+
const viewSCaleData = ref([]);
|
|
187
|
+
const scaleWidth = ref({
|
|
188
|
+
day: 40,
|
|
189
|
+
week: 30,
|
|
190
|
+
month: 20
|
|
191
|
+
});
|
|
192
|
+
const highlight = ref(false);
|
|
193
|
+
const highlightStartText = ref("");
|
|
194
|
+
const highlightEndText = ref("");
|
|
195
|
+
const {
|
|
196
|
+
generateScaleData
|
|
197
|
+
} = useScaleData(milestoneList);
|
|
198
|
+
let viewScaleRange = [0, 0];
|
|
199
|
+
const addMilestone = (info) => {
|
|
200
|
+
ctx.emit("addMilestone", info);
|
|
201
|
+
};
|
|
202
|
+
const getViewScaleData = () => {
|
|
203
|
+
if (scrollElement.value) {
|
|
204
|
+
const containerWidth = scrollElement.value.clientWidth;
|
|
205
|
+
const scrollLeft = scrollElement.value.scrollLeft;
|
|
206
|
+
const start = Math.floor(scrollLeft / scaleWidth.value[unit.value]);
|
|
207
|
+
const offset = Math.ceil(containerWidth / scaleWidth.value[unit.value]);
|
|
208
|
+
viewScaleRange = [start - 2, start + offset + 2];
|
|
209
|
+
viewSCaleData.value = scaleData.value.filter((i) => {
|
|
210
|
+
return i.index >= viewScaleRange[0] && i.index <= viewScaleRange[1];
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
onMounted(() => {
|
|
215
|
+
if (startDate.value && endDate.value) {
|
|
216
|
+
scaleData.value = generateScaleData(startDate.value, endDate.value);
|
|
217
|
+
getViewScaleData();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
watch(() => props.scrollElement, () => {
|
|
221
|
+
getViewScaleData();
|
|
222
|
+
props.scrollElement.addEventListener("scroll", () => {
|
|
223
|
+
getViewScaleData();
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
return {
|
|
227
|
+
viewSCaleData,
|
|
228
|
+
scaleWidth,
|
|
229
|
+
addMilestone,
|
|
230
|
+
highlight,
|
|
231
|
+
highlightStartText,
|
|
232
|
+
highlightEndText
|
|
233
|
+
};
|
|
234
|
+
},
|
|
235
|
+
render() {
|
|
236
|
+
const {
|
|
237
|
+
unit,
|
|
238
|
+
viewSCaleData,
|
|
239
|
+
scaleWidth,
|
|
240
|
+
addMilestone,
|
|
241
|
+
highlight,
|
|
242
|
+
highlightStartText,
|
|
243
|
+
highlightEndText,
|
|
244
|
+
ganttBarContainerElement
|
|
245
|
+
} = this;
|
|
246
|
+
return createVNode("div", {
|
|
247
|
+
"class": "devui-gantt-scale-wrapper"
|
|
248
|
+
}, [viewSCaleData.map((data, index2) => withDirectives(createVNode("div", {
|
|
249
|
+
"class": `devui-gantt-scale ${unit} ${data.today} ${data.milestone}`,
|
|
250
|
+
"style": {
|
|
251
|
+
left: `${scaleWidth[unit] * data.index}px`,
|
|
252
|
+
width: `${scaleWidth[unit]}px`
|
|
253
|
+
}
|
|
254
|
+
}, [createVNode("div", {
|
|
255
|
+
"class": `devui-scale-start ${data.milestone}`
|
|
256
|
+
}, [data.milestone && unit === "day" && createVNode("div", null, [data.milestone]), (!data.milestone || unit !== "day") && data.scaleStartVisable && (index2 === 0 || data.monthStart) ? unit === "month" ? i18nText.zh.yearDisplay(data.yearLabel) : i18nText.zh.yearAndMonthDisplay(data.yearLabel, data.monthLabel) : ""]), createVNode("div", {
|
|
257
|
+
"class": "devui-scale-unit"
|
|
258
|
+
}, [highlight && data.highlightStart && createVNode("div", {
|
|
259
|
+
"class": "scale-highlight"
|
|
260
|
+
}, [createVNode("div", {
|
|
261
|
+
"style": "float: left"
|
|
262
|
+
}, [highlightStartText]), createVNode("div", {
|
|
263
|
+
"style": "float: right"
|
|
264
|
+
}, [highlightEndText]), createVNode("div", {
|
|
265
|
+
"style": "clear: both"
|
|
266
|
+
}, null)]), (!highlight || !data.highlightStart) && unit === "day" && createVNode("div", {
|
|
267
|
+
"class": `border-left ${data.today ? "today" : ""}`
|
|
268
|
+
}, [data.today ? i18nText.zh.today : data.dayOfMonthLabel]), (!highlight || !data.highlightStart) && unit === "week" && createVNode("div", {
|
|
269
|
+
"class": `${data.weekend || index2 === 0 ? "border-left" : ""}`
|
|
270
|
+
}, [index2 === 0 || data.weekend ? data.dayOfMonthLabel : ""]), (!highlight || !data.highlightStart) && unit === "month" && createVNode("div", {
|
|
271
|
+
"class": `${data.monthStart || index2 === 0 ? "border-left" : ""}`
|
|
272
|
+
}, [index2 === 0 || data.monthStart ? i18nText.zh.monthDisplay(data.monthLabel) : ""])]), createVNode("div", {
|
|
273
|
+
"class": `milestone-new ${unit}`,
|
|
274
|
+
"title": "milestone",
|
|
275
|
+
"onClick": () => addMilestone(data)
|
|
276
|
+
}, [createVNode(resolveComponent("d-icon"), {
|
|
277
|
+
"name": "add"
|
|
278
|
+
}, null)])]), [[resolveDirective("gantt-marker"), {
|
|
279
|
+
ganttBarContainerElement,
|
|
280
|
+
monthMark: data.monthMark,
|
|
281
|
+
weekend: data.weekend,
|
|
282
|
+
milestone: data.milestone,
|
|
283
|
+
today: data.today,
|
|
284
|
+
date: data.date,
|
|
285
|
+
unit,
|
|
286
|
+
last: index2 === viewSCaleData.length - 1
|
|
287
|
+
}]]))]);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
var ganttTools = "";
|
|
291
|
+
var GanttTools = defineComponent({
|
|
292
|
+
name: "DGanttTools",
|
|
293
|
+
props: {
|
|
294
|
+
unit: {
|
|
295
|
+
type: String,
|
|
296
|
+
default: null
|
|
297
|
+
},
|
|
298
|
+
isFullScreen: {
|
|
299
|
+
type: Boolean,
|
|
300
|
+
default: false
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
emits: ["goToday", "reduceUnit", "increaseUnit", "switchView"],
|
|
304
|
+
setup(props, ctx) {
|
|
305
|
+
const currentUnitLabel = ref(props.unit);
|
|
306
|
+
const views = ref([{
|
|
307
|
+
name: "Day",
|
|
308
|
+
value: "day"
|
|
309
|
+
}, {
|
|
310
|
+
name: "Week",
|
|
311
|
+
value: "week"
|
|
312
|
+
}, {
|
|
313
|
+
name: "Month",
|
|
314
|
+
value: "month"
|
|
315
|
+
}]);
|
|
316
|
+
const actionHandle = (type) => {
|
|
317
|
+
switch (type) {
|
|
318
|
+
case "today":
|
|
319
|
+
ctx.emit("goToday");
|
|
320
|
+
break;
|
|
321
|
+
case "reduce":
|
|
322
|
+
ctx.emit("reduceUnit");
|
|
323
|
+
break;
|
|
324
|
+
case "increase":
|
|
325
|
+
ctx.emit("increaseUnit");
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const selectView = (selectItem) => {
|
|
330
|
+
ctx.emit("switchView", selectItem.value);
|
|
331
|
+
};
|
|
332
|
+
return {
|
|
333
|
+
actionHandle,
|
|
334
|
+
currentUnitLabel,
|
|
335
|
+
views,
|
|
336
|
+
selectView
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
render() {
|
|
340
|
+
const {
|
|
341
|
+
isFullScreen,
|
|
342
|
+
actionHandle,
|
|
343
|
+
views,
|
|
344
|
+
selectView,
|
|
345
|
+
$slots
|
|
346
|
+
} = this;
|
|
347
|
+
return createVNode("div", {
|
|
348
|
+
"class": "tools-container",
|
|
349
|
+
"style": {
|
|
350
|
+
position: isFullScreen ? "fixed" : "absolute"
|
|
351
|
+
}
|
|
352
|
+
}, [createVNode(resolveComponent("d-button"), {
|
|
353
|
+
"btnStyle": "common",
|
|
354
|
+
"onClick": () => actionHandle("today"),
|
|
355
|
+
"class": "tool"
|
|
356
|
+
}, {
|
|
357
|
+
default: () => [createTextVNode("Today")]
|
|
358
|
+
}), createVNode("div", {
|
|
359
|
+
"class": "tool"
|
|
360
|
+
}, [createVNode(resolveComponent("d-select"), {
|
|
361
|
+
"modelValue": this.currentUnitLabel,
|
|
362
|
+
"onUpdate:modelValue": ($event) => this.currentUnitLabel = $event,
|
|
363
|
+
"options": views,
|
|
364
|
+
"onValueChange": selectView
|
|
365
|
+
}, null)]), createVNode(resolveComponent("d-button"), {
|
|
366
|
+
"btnStyle": "common",
|
|
367
|
+
"class": ["tool", "minus", this.currentUnitLabel === GanttScaleUnit.day ? "disabled" : ""],
|
|
368
|
+
"disabled": this.currentUnitLabel === GanttScaleUnit.day,
|
|
369
|
+
"onClick": () => actionHandle("reduce")
|
|
370
|
+
}, {
|
|
371
|
+
default: () => [createVNode(resolveComponent("d-icon"), {
|
|
372
|
+
"name": "minus"
|
|
373
|
+
}, null)]
|
|
374
|
+
}), createVNode(resolveComponent("d-button"), {
|
|
375
|
+
"btnStyle": "common",
|
|
376
|
+
"class": ["tool", "add", this.currentUnitLabel === GanttScaleUnit.month ? "disabled" : ""],
|
|
377
|
+
"disabled": this.currentUnitLabel === GanttScaleUnit.month,
|
|
378
|
+
"onClick": () => actionHandle("increase")
|
|
379
|
+
}, {
|
|
380
|
+
default: () => [createVNode(resolveComponent("d-icon"), {
|
|
381
|
+
"name": "add"
|
|
382
|
+
}, null)]
|
|
383
|
+
}), $slots.default && $slots.default()]);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
const ganttProps = {
|
|
387
|
+
startDate: {
|
|
388
|
+
type: Date
|
|
389
|
+
},
|
|
390
|
+
endDate: {
|
|
391
|
+
type: Date
|
|
392
|
+
},
|
|
393
|
+
unit: {
|
|
394
|
+
type: String,
|
|
395
|
+
default: GanttScaleUnit.day
|
|
396
|
+
},
|
|
397
|
+
progressRate: {
|
|
398
|
+
type: Number
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
var gantt = "";
|
|
402
|
+
const useGantt = (scaleUnit = GanttScaleUnit.day) => {
|
|
403
|
+
const DAY_DURATION = 24 * 60 * 60 * 1e3;
|
|
404
|
+
const getScaleUnitPixel = () => {
|
|
405
|
+
switch (scaleUnit) {
|
|
406
|
+
case GanttScaleUnit.day:
|
|
407
|
+
return 40;
|
|
408
|
+
case GanttScaleUnit.week:
|
|
409
|
+
return 30;
|
|
410
|
+
case GanttScaleUnit.month:
|
|
411
|
+
return 20;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
const getDuration = (startDate, endDate) => {
|
|
415
|
+
if (startDate && endDate) {
|
|
416
|
+
const timeOffset = endDate.getTime() - startDate.getTime();
|
|
417
|
+
const duration = timeOffset / DAY_DURATION + 1;
|
|
418
|
+
console.log("duration => ", duration);
|
|
419
|
+
return Math.round(duration);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
const getDurationWidth = (startDate, endDate) => {
|
|
423
|
+
if (startDate && endDate) {
|
|
424
|
+
const duration = getDuration(startDate, endDate);
|
|
425
|
+
return duration * getScaleUnitPixel();
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
getDurationWidth
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
var Gantt = defineComponent({
|
|
433
|
+
name: "DGantt",
|
|
434
|
+
components: {
|
|
435
|
+
DGanttScale,
|
|
436
|
+
DGanttTools: GanttTools
|
|
437
|
+
},
|
|
438
|
+
props: ganttProps,
|
|
439
|
+
setup(props, ctx) {
|
|
440
|
+
const {
|
|
441
|
+
startDate,
|
|
442
|
+
endDate
|
|
443
|
+
} = toRefs(props);
|
|
444
|
+
const ganttContainer = ref();
|
|
445
|
+
const ganttScaleWidth = ref();
|
|
446
|
+
const {
|
|
447
|
+
getDurationWidth
|
|
448
|
+
} = useGantt();
|
|
449
|
+
onMounted(() => {
|
|
450
|
+
ganttScaleWidth.value = getDurationWidth(startDate.value, endDate.value);
|
|
451
|
+
});
|
|
452
|
+
return {
|
|
453
|
+
ganttContainer,
|
|
454
|
+
ganttScaleWidth
|
|
455
|
+
};
|
|
456
|
+
},
|
|
457
|
+
render() {
|
|
458
|
+
const {
|
|
459
|
+
$slots,
|
|
460
|
+
startDate,
|
|
461
|
+
endDate,
|
|
462
|
+
unit,
|
|
463
|
+
ganttContainer,
|
|
464
|
+
ganttScaleWidth
|
|
465
|
+
} = this;
|
|
466
|
+
return createVNode("div", {
|
|
467
|
+
"style": {
|
|
468
|
+
position: "relative"
|
|
469
|
+
}
|
|
470
|
+
}, [createVNode("div", {
|
|
471
|
+
"class": "devui-gantt gantt-container",
|
|
472
|
+
"ref": "ganttContainer"
|
|
473
|
+
}, [createVNode("div", {
|
|
474
|
+
"class": "header",
|
|
475
|
+
"style": {
|
|
476
|
+
width: `${ganttScaleWidth}px`
|
|
477
|
+
}
|
|
478
|
+
}, [createVNode(resolveComponent("d-gantt-scale"), {
|
|
479
|
+
"startDate": startDate,
|
|
480
|
+
"endDate": endDate,
|
|
481
|
+
"unit": unit,
|
|
482
|
+
"scrollElement": ganttContainer
|
|
483
|
+
}, null)]), createVNode(resolveComponent("d-gantt-tools"), {
|
|
484
|
+
"unit": unit
|
|
485
|
+
}, null), createVNode("div", {
|
|
486
|
+
"class": "body",
|
|
487
|
+
"style": {
|
|
488
|
+
width: `${ganttScaleWidth}px`
|
|
489
|
+
}
|
|
490
|
+
}, null)])]);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
const ganttMarkerDirective = {
|
|
494
|
+
ganttBarContainerElement: null,
|
|
495
|
+
monthMarkElement: null,
|
|
496
|
+
weekendElement: null,
|
|
497
|
+
todayElement: null,
|
|
498
|
+
milestoneElement: null,
|
|
499
|
+
monthMark: "",
|
|
500
|
+
mounted(el, binding) {
|
|
501
|
+
const { ganttBarContainerElement, monthMark } = binding.value;
|
|
502
|
+
if (ganttBarContainerElement) {
|
|
503
|
+
this.ganttBarContainerElement = ganttBarContainerElement;
|
|
504
|
+
}
|
|
505
|
+
if (monthMark) {
|
|
506
|
+
this.monthMark = this.monthMark;
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
updated(el, binding) {
|
|
510
|
+
const { monthMark, weekend, today, milestone, unit } = binding.value;
|
|
511
|
+
if (monthMark) {
|
|
512
|
+
this.initMarkElement();
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
initMarkElement() {
|
|
516
|
+
if (this.ganttBarContainerElement) {
|
|
517
|
+
if (this.monthMark && !this.monthMarkElement)
|
|
518
|
+
;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
Gantt.install = function(app) {
|
|
523
|
+
app.component(Gantt.name, Gantt);
|
|
524
|
+
app.component(GanttTools.name, GanttTools);
|
|
525
|
+
app.directive("gantt-marker", ganttMarkerDirective);
|
|
526
|
+
};
|
|
527
|
+
var index = {
|
|
528
|
+
title: "Gantt \u7518\u7279\u56FE",
|
|
529
|
+
category: "\u6570\u636E\u5C55\u793A",
|
|
530
|
+
status: "10%",
|
|
531
|
+
install(app) {
|
|
532
|
+
app.use(Gantt);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
export { Gantt, index as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(u,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(u=typeof globalThis!="undefined"?globalThis:u||self,t(u.index={},u.Vue))})(this,function(u,t){"use strict";var U="",h;(function(e){e.day="day",e.week="week",e.month="month"})(h||(h={}));var V;(function(e){e.milestone="milestone",e.month="month",e.week="week"})(V||(V={}));var M;(function(e){e[e.day=10]="day",e[e.week=20]="week",e[e.month=30]="month"})(M||(M={}));const p=(e,o)=>e.getFullYear()===o.getFullYear()&&e.getMonth()===o.getMonth()&&e.getDate()===o.getDate(),E=e=>{const o=7,r=(a,l)=>{const i={dayOfMonthLabel:"",dayOfWeekLabel:"",monthLabel:"",yearLabel:"",date:a,monthStart:!1,weekend:!1,today:!1,milestone:"",highlightStart:!1,scaleStartVisable:!0,index:l},n=a.getDate();i.dayOfMonthLabel=n+"",n===1&&(i.monthStart=!0);const d=a.getDay();i.dayOfWeekLabel=d+"",d===6&&(i.weekend=!0);const m=a.getMonth()+1;i.monthLabel=m+"";const D=a.getFullYear();return i.yearLabel=D+"",p(a,new Date)&&(i.today=!0),new Date(D,m-1,n+o).getMonth()>m-1&&(i.scaleStartVisable=!1),e.value&&e.value.forEach(f=>{f.date&&p(f.date,i.date)&&(i.milestone=f.lable)}),i},s=a=>{const l=a.setDate(a.getDate()+1);return new Date(l)};return{generateScaleData:(a,l)=>{const i=[];let n=a,d=0;for(;!p(n,l);){const m=r(n,d);i.push(m),n=s(new Date(n)),d++}return console.log({scaleData:i}),i}}},g={en:{today:"today",monthsOfYear:["January","February","March","April","May","June","July","August","September","October","November","December"],yearDisplay(e){return`${e}`},monthDisplay(e){return this.monthsOfYear[Number(e)-1]},yearAndMonthDisplay(e,o){return this.yearDisplay(e)+this.monthDisplay(o)}},zh:{today:"\u4ECA\u5929",monthsOfYear:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],yearDisplay(e){return`${e}\u5E74`},monthDisplay(e){return this.monthsOfYear[Number(e)-1]},yearAndMonthDisplay(e,o){return this.yearDisplay(e)+this.monthDisplay(o)}}};var L=t.defineComponent({name:"DGanttScale",props:{unit:{type:String,default:h.day},height:{type:Number},startDate:{type:Date},endDate:{type:Date},ganttScaleContainerOffsetLeft:{type:Number},milestoneList:{type:Array},scrollElement:{type:Object},ganttBarContainerElement:{type:Object}},emits:["addMilestone"],setup(e,o){const{startDate:r,endDate:s,milestoneList:c,scrollElement:a,unit:l}=t.toRefs(e),i=t.ref([]),n=t.ref([]),d=t.ref({day:40,week:30,month:20}),m=t.ref(!1),D=t.ref(""),f=t.ref(""),{generateScaleData:x}=E(c);let w=[0,0];const A=k=>{o.emit("addMilestone",k)},S=()=>{if(a.value){const k=a.value.clientWidth,W=a.value.scrollLeft,N=Math.floor(W/d.value[l.value]),F=Math.ceil(k/d.value[l.value]);w=[N-2,N+F+2],n.value=i.value.filter(C=>C.index>=w[0]&&C.index<=w[1])}};return t.onMounted(()=>{r.value&&s.value&&(i.value=x(r.value,s.value),S())}),t.watch(()=>e.scrollElement,()=>{S(),e.scrollElement.addEventListener("scroll",()=>{S()})}),{viewSCaleData:n,scaleWidth:d,addMilestone:A,highlight:m,highlightStartText:D,highlightEndText:f}},render(){const{unit:e,viewSCaleData:o,scaleWidth:r,addMilestone:s,highlight:c,highlightStartText:a,highlightEndText:l,ganttBarContainerElement:i}=this;return t.createVNode("div",{class:"devui-gantt-scale-wrapper"},[o.map((n,d)=>t.withDirectives(t.createVNode("div",{class:`devui-gantt-scale ${e} ${n.today} ${n.milestone}`,style:{left:`${r[e]*n.index}px`,width:`${r[e]}px`}},[t.createVNode("div",{class:`devui-scale-start ${n.milestone}`},[n.milestone&&e==="day"&&t.createVNode("div",null,[n.milestone]),(!n.milestone||e!=="day")&&n.scaleStartVisable&&(d===0||n.monthStart)?e==="month"?g.zh.yearDisplay(n.yearLabel):g.zh.yearAndMonthDisplay(n.yearLabel,n.monthLabel):""]),t.createVNode("div",{class:"devui-scale-unit"},[c&&n.highlightStart&&t.createVNode("div",{class:"scale-highlight"},[t.createVNode("div",{style:"float: left"},[a]),t.createVNode("div",{style:"float: right"},[l]),t.createVNode("div",{style:"clear: both"},null)]),(!c||!n.highlightStart)&&e==="day"&&t.createVNode("div",{class:`border-left ${n.today?"today":""}`},[n.today?g.zh.today:n.dayOfMonthLabel]),(!c||!n.highlightStart)&&e==="week"&&t.createVNode("div",{class:`${n.weekend||d===0?"border-left":""}`},[d===0||n.weekend?n.dayOfMonthLabel:""]),(!c||!n.highlightStart)&&e==="month"&&t.createVNode("div",{class:`${n.monthStart||d===0?"border-left":""}`},[d===0||n.monthStart?g.zh.monthDisplay(n.monthLabel):""])]),t.createVNode("div",{class:`milestone-new ${e}`,title:"milestone",onClick:()=>s(n)},[t.createVNode(t.resolveComponent("d-icon"),{name:"add"},null)])]),[[t.resolveDirective("gantt-marker"),{ganttBarContainerElement:i,monthMark:n.monthMark,weekend:n.weekend,milestone:n.milestone,today:n.today,date:n.date,unit:e,last:d===o.length-1}]]))])}}),B="",b=t.defineComponent({name:"DGanttTools",props:{unit:{type:String,default:null},isFullScreen:{type:Boolean,default:!1}},emits:["goToday","reduceUnit","increaseUnit","switchView"],setup(e,o){const r=t.ref(e.unit),s=t.ref([{name:"Day",value:"day"},{name:"Week",value:"week"},{name:"Month",value:"month"}]);return{actionHandle:l=>{switch(l){case"today":o.emit("goToday");break;case"reduce":o.emit("reduceUnit");break;case"increase":o.emit("increaseUnit");break}},currentUnitLabel:r,views:s,selectView:l=>{o.emit("switchView",l.value)}}},render(){const{isFullScreen:e,actionHandle:o,views:r,selectView:s,$slots:c}=this;return t.createVNode("div",{class:"tools-container",style:{position:e?"fixed":"absolute"}},[t.createVNode(t.resolveComponent("d-button"),{btnStyle:"common",onClick:()=>o("today"),class:"tool"},{default:()=>[t.createTextVNode("Today")]}),t.createVNode("div",{class:"tool"},[t.createVNode(t.resolveComponent("d-select"),{modelValue:this.currentUnitLabel,"onUpdate:modelValue":a=>this.currentUnitLabel=a,options:r,onValueChange:s},null)]),t.createVNode(t.resolveComponent("d-button"),{btnStyle:"common",class:["tool","minus",this.currentUnitLabel===h.day?"disabled":""],disabled:this.currentUnitLabel===h.day,onClick:()=>o("reduce")},{default:()=>[t.createVNode(t.resolveComponent("d-icon"),{name:"minus"},null)]}),t.createVNode(t.resolveComponent("d-button"),{btnStyle:"common",class:["tool","add",this.currentUnitLabel===h.month?"disabled":""],disabled:this.currentUnitLabel===h.month,onClick:()=>o("increase")},{default:()=>[t.createVNode(t.resolveComponent("d-icon"),{name:"add"},null)]}),c.default&&c.default()])}});const v={startDate:{type:Date},endDate:{type:Date},unit:{type:String,default:h.day},progressRate:{type:Number}};var G="";const O=(e=h.day)=>{const o=24*60*60*1e3,r=()=>{switch(e){case h.day:return 40;case h.week:return 30;case h.month:return 20}},s=(a,l)=>{if(a&&l){const n=(l.getTime()-a.getTime())/o+1;return console.log("duration => ",n),Math.round(n)}};return{getDurationWidth:(a,l)=>{if(a&&l)return s(a,l)*r()}}};var y=t.defineComponent({name:"DGantt",components:{DGanttScale:L,DGanttTools:b},props:v,setup(e,o){const{startDate:r,endDate:s}=t.toRefs(e),c=t.ref(),a=t.ref(),{getDurationWidth:l}=O();return t.onMounted(()=>{a.value=l(r.value,s.value)}),{ganttContainer:c,ganttScaleWidth:a}},render(){const{$slots:e,startDate:o,endDate:r,unit:s,ganttContainer:c,ganttScaleWidth:a}=this;return t.createVNode("div",{style:{position:"relative"}},[t.createVNode("div",{class:"devui-gantt gantt-container",ref:"ganttContainer"},[t.createVNode("div",{class:"header",style:{width:`${a}px`}},[t.createVNode(t.resolveComponent("d-gantt-scale"),{startDate:o,endDate:r,unit:s,scrollElement:c},null)]),t.createVNode(t.resolveComponent("d-gantt-tools"),{unit:s},null),t.createVNode("div",{class:"body",style:{width:`${a}px`}},null)])])}});const T={ganttBarContainerElement:null,monthMarkElement:null,weekendElement:null,todayElement:null,milestoneElement:null,monthMark:"",mounted(e,o){const{ganttBarContainerElement:r,monthMark:s}=o.value;r&&(this.ganttBarContainerElement=r),s&&(this.monthMark=this.monthMark)},updated(e,o){const{monthMark:r,weekend:s,today:c,milestone:a,unit:l}=o.value;r&&this.initMarkElement()},initMarkElement(){this.ganttBarContainerElement&&this.monthMark&&!this.monthMarkElement}};y.install=function(e){e.component(y.name,y),e.component(b.name,b),e.directive("gantt-marker",T)};var $={title:"Gantt \u7518\u7279\u56FE",category:"\u6570\u636E\u5C55\u793A",status:"10%",install(e){e.use(y)}};u.Gantt=y,u.default=$,Object.defineProperty(u,"__esModule",{value:!0}),u[Symbol.toStringTag]="Module"});
|
package/gantt/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.devui-gantt-scale-wrapper{display:block;height:36px;line-height:18px}.devui-gantt-scale{display:inline-block;color:var(--devui-placeholder, #8a8e99);text-align:center;position:absolute;height:36px;font-weight:normal}.devui-gantt-scale.day:not(.milestone):hover .devui-scale-start{display:none}.devui-gantt-scale.day.milestone{background-image:linear-gradient(180deg,rgba(254,204,85,0) 0%,rgba(62,204,166,.1) 100%)}.devui-gantt-scale .devui-scale-start{width:100%;height:18px;position:absolute;left:1px;white-space:nowrap}.devui-gantt-scale .devui-scale-start.milestone{color:var(--devui-success, #50d4ab)}.devui-gantt-scale .devui-scale-unit{height:18px;position:absolute;top:18px;width:100%}.devui-gantt-scale .devui-scale-unit .border-left{height:18px;border-left:1px solid var(--devui-list-item-selected-bg, #e9edfa)}.devui-gantt-scale .devui-scale-unit .scale-highlight{position:absolute;height:18px;border-radius:var(--devui-border-radius, 2px);background-color:var(--devui-brand, #5e7ce0);padding:0 4px}.devui-gantt-scale .devui-scale-unit .scale-highlight div{color:var(--devui-base-bg, #ffffff);font-size:var(--devui-font-size, 12px);font-weight:normal}.devui-gantt-scale .devui-scale-unit .today{background:rgba(255,121,14,.2);border-radius:var(--devui-border-radius, 2px);height:16px}.devui-gantt-scale .milestone-new{display:none;position:absolute;width:18px;height:18px;margin-left:16px;border:1px solid var(--devui-list-item-selected-bg, #e9edfa);cursor:pointer}.devui-gantt-scale .milestone-new div{line-height:16px}.devui-gantt-scale:not(.milestone):hover .milestone-new.day{display:block}.devui-mark-line{position:absolute;top:0;bottom:0;width:2px;z-index:1;background:var(--devui-line, #adb0b8);opacity:.5}.devui-mark-line.today{opacity:.2;background:#ff790e}.devui-mark-line.today.day{margin-left:24px}.devui-mark-line.today.week{margin-left:9px}.devui-mark-line.today.month{margin-left:4px}.devui-mark-line.milestone{opacity:.2;background:var(--devui-success, #50d4ab)}.devui-mark-line.milestone.day{margin-left:24px}.devui-mark-line.milestone.week{margin-left:9px}.devui-mark-line.milestone.month{margin-left:4px}.devui-mark-stripe{position:absolute;top:0;bottom:0;z-index:1;background:linear-gradient(45deg,rgba(202,207,216,.2) 0,rgba(202,207,216,.2) 10%,transparent 10%,transparent 50%,rgba(202,207,216,.2) 50%,rgba(202,207,216,.2) 60%,transparent 60%,transparent);background-size:6px 6px}.devui-mark-stripe.day{width:100px}.devui-mark-stripe.week{width:40px}.devui-mark-stripe.month{width:20px}.tools-container{position:absolute;top:70px;right:20px;z-index:10}.tools-container .devui-dropdown-origin{border:0}.tools-container .devui-dropdown-origin:hover{color:var(--devui-link, #526ecc)!important}.tools-container .devui-btn{height:32px!important;color:var(--devui-text, #252b3a)!important;padding:0 8px!important;min-width:50px}.tools-container .devui-btn:hover{color:var(--devui-link, #526ecc)!important}.tools-container .tool.minus .devui-btn,.tools-container .tool.add .devui-btn{min-width:30px}.tools-container .devui-select-selection{width:90px}.tools-container .devui-select-selection .devui-select-input{height:32px}.tool.disabled{opacity:.5}.tool .switch-view{padding:0 8px}.tool .switch-view:hover{color:var(--devui-link, #526ecc)!important}.devui-dropdown-menu{top:10px!important;left:-6px!important}.gantt-container{overflow:scroll}.gantt-container .header{position:relative;border-bottom:1px solid var(--devui-dividing-line, #dfe1e6)}.gantt-container .body{position:relative;min-height:400px;height:100%}.gantt-container .body .item{height:40px;padding-top:8px}.tool{display:inline-flex;align-items:center;justify-content:center;height:32px;margin-left:12px;background-color:var(--devui-base-bg, #ffffff);box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) #5170ff66;cursor:pointer}.tool span{border:0!important}
|