@dt-frames/ui 1.0.1 → 1.0.4
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/README.md +1 -15
- package/es/assets/style/reset.less +0 -3
- package/es/components/iframe/index.d.ts +2 -2
- package/es/components/index.d.ts +2 -2
- package/es/index.css +1 -1
- package/es/index.js +34 -392
- package/es/style/assets/style/reset.less +0 -3
- package/es/style/components/forms/index.less +84 -0
- package/es/style/components/iframe/index.less +3 -0
- package/es/style/components/modal/index.less +63 -0
- package/es/style/components/table/index.less +162 -0
- package/es/style/theme/sider/index.less +25 -25
- package/es/style/theme/theme.less +2 -1
- package/es/theme/header/components/notify.d.ts +0 -1
- package/es/theme/header/components/user-info.d.ts +1 -1
- package/package.json +47 -40
- package/src/assets/data/icons/actions.ts +427 -0
- package/src/assets/data/icons/code.ts +10 -0
- package/src/assets/data/icons/commuticate.ts +190 -0
- package/src/assets/data/icons/currency.ts +46 -0
- package/src/assets/data/icons/devices.ts +128 -0
- package/src/assets/data/icons/edit.ts +165 -0
- package/src/assets/data/icons/file.ts +104 -0
- package/src/assets/data/icons/math.ts +53 -0
- package/src/assets/data/icons/message.ts +75 -0
- package/src/assets/data/icons/navigate.ts +181 -0
- package/src/assets/data/icons/other.ts +333 -0
- package/src/assets/data/icons.ts +58 -0
- package/src/assets/imgs/logo/logo.png +0 -0
- package/src/assets/locales/en_US.json +3 -0
- package/src/assets/locales/zh_CN.json +3 -0
- package/src/assets/style/index.less +10 -0
- package/src/assets/style/reset.less +17 -0
- package/src/components/container/index.less +85 -0
- package/src/components/container/index.ts +8 -0
- package/src/components/container/src/bar.ts +107 -0
- package/src/components/container/src/lazy-container.vue +9 -0
- package/src/components/container/src/scroll-bar.vue +117 -0
- package/src/components/container/src/scroll-container.vue +61 -0
- package/src/components/curd/index.ts +5 -0
- package/src/components/curd/src/components/dialog.vue +65 -0
- package/src/components/curd/src/components/props.ts +32 -0
- package/src/components/curd/src/hooks/useCurd.tsx +72 -0
- package/src/components/curd/src/types/curd.type.ts +29 -0
- package/src/components/excel/index.ts +6 -0
- package/src/components/excel/src/export2Excel.ts +44 -0
- package/src/components/forms/index.less +84 -0
- package/src/components/forms/index.ts +12 -0
- package/src/components/forms/src/componentMap.ts +44 -0
- package/src/components/forms/src/components/formButton.vue +150 -0
- package/src/components/forms/src/components/formIcon.vue +50 -0
- package/src/components/forms/src/components/formItem.vue +407 -0
- package/src/components/forms/src/components/radioButton.vue +58 -0
- package/src/components/forms/src/const/form.const.ts +7 -0
- package/src/components/forms/src/hooks/helper.ts +70 -0
- package/src/components/forms/src/hooks/useForm.ts +130 -0
- package/src/components/forms/src/hooks/useFormActions.ts +63 -0
- package/src/components/forms/src/hooks/useFormEvents.ts +247 -0
- package/src/components/forms/src/hooks/useFormValue.ts +49 -0
- package/src/components/forms/src/hooks/useFormValues.ts +131 -0
- package/src/components/forms/src/hooks/useLabelWidth.ts +57 -0
- package/src/components/forms/src/index.vue +306 -0
- package/src/components/forms/src/prop.ts +80 -0
- package/src/components/forms/src/types/form.type.ts +269 -0
- package/src/components/icons/index.less +96 -0
- package/src/components/icons/index.ts +7 -0
- package/src/components/icons/src/pick-icon.vue +117 -0
- package/src/components/icons/src/svg-icon.vue +117 -0
- package/src/components/iframe/index.less +3 -0
- package/src/components/iframe/index.ts +5 -0
- package/src/components/iframe/src/index.vue +38 -0
- package/src/components/index.ts +46 -0
- package/src/components/modal/index.less +63 -0
- package/src/components/modal/index.ts +8 -0
- package/src/components/modal/src/components/close-icon.vue +47 -0
- package/src/components/modal/src/components/modal-wrap.vue +118 -0
- package/src/components/modal/src/components/modal.tsx +30 -0
- package/src/components/modal/src/components/modalFooter.vue +38 -0
- package/src/components/modal/src/hooks/useDrag.ts +107 -0
- package/src/components/modal/src/hooks/useFullScreen.ts +27 -0
- package/src/components/modal/src/hooks/useModal.ts +177 -0
- package/src/components/modal/src/index.vue +173 -0
- package/src/components/modal/src/props.ts +43 -0
- package/src/components/modal/src/types/modal.type.ts +27 -0
- package/src/components/router/base-router.vue +11 -0
- package/src/components/router/index.ts +3 -0
- package/src/components/source/index.ts +1 -0
- package/src/components/source/src/hooks/useFetch.ts +70 -0
- package/src/components/source/src/hooks/usePage.ts +3 -0
- package/src/components/source/src/hooks/useSource.ts +178 -0
- package/src/components/source/src/index.ts +5 -0
- package/src/components/source/src/types/source.type.ts +68 -0
- package/src/components/source/src/types/table.type.ts +8 -0
- package/src/components/table/index.less +162 -0
- package/src/components/table/index.ts +7 -0
- package/src/components/table/src/components/TableActions.vue +108 -0
- package/src/components/table/src/components/TableHeader.vue +77 -0
- package/src/components/table/src/components/TableRender.vue +76 -0
- package/src/components/table/src/components/setting/Column.vue +355 -0
- package/src/components/table/src/components/setting/Download.vue +55 -0
- package/src/components/table/src/components/setting/Fullscreen.vue +43 -0
- package/src/components/table/src/components/setting/Size.vue +42 -0
- package/src/components/table/src/components/setting/index.vue +64 -0
- package/src/components/table/src/const.ts +13 -0
- package/src/components/table/src/hooks/useColumns.ts +319 -0
- package/{es/assets/app-antd-dark-theme-style.e3b0c442.css → src/components/table/src/hooks/useCustomRow.ts} +0 -0
- package/src/components/table/src/hooks/useDataSource.ts +99 -0
- package/src/components/table/src/hooks/useLoading.ts +29 -0
- package/src/components/table/src/hooks/usePagination.ts +76 -0
- package/src/components/table/src/hooks/useRowSelection.ts +146 -0
- package/src/components/table/src/hooks/useRows.ts +30 -0
- package/src/components/table/src/hooks/useTable.ts +77 -0
- package/src/components/table/src/hooks/useTableHeader.ts +48 -0
- package/src/components/table/src/hooks/useTableInstance.ts +29 -0
- package/src/components/table/src/hooks/useTableScroll.ts +227 -0
- package/src/components/table/src/index.vue +198 -0
- package/src/components/table/src/props.ts +152 -0
- package/src/components/table/src/types/table.type.ts +133 -0
- package/src/components/table/src/types/tableHeader.type.ts +27 -0
- package/{es/assets/app-theme-style.e3b0c442.css → src/components/type.ts} +0 -0
- package/src/directives/icon.ts +36 -0
- package/src/directives/index.ts +26 -0
- package/src/directives/permission.ts +20 -0
- package/src/global.d.ts +8 -0
- package/src/index.ts +4 -0
- package/src/theme/content/index.vue +37 -0
- package/src/theme/feature/back-top.vue +11 -0
- package/src/theme/feature/index.vue +7 -0
- package/src/theme/footer/index.less +16 -0
- package/src/theme/footer/index.vue +24 -0
- package/src/theme/header/components/bread-crumb.vue +26 -0
- package/src/theme/header/components/fullscreen.vue +12 -0
- package/src/theme/header/components/handler.ts +81 -0
- package/src/theme/header/components/index.ts +21 -0
- package/src/theme/header/components/lang-picker.vue +36 -0
- package/src/theme/header/components/logo.vue +33 -0
- package/src/theme/header/components/menu-search.vue +62 -0
- package/src/theme/header/components/notify.vue +22 -0
- package/src/theme/header/components/setting-theme.vue +123 -0
- package/src/theme/header/components/theme-drawer/enum.ts +12 -0
- package/src/theme/header/components/theme-drawer/feature.vue +75 -0
- package/src/theme/header/components/theme-drawer/index.ts +7 -0
- package/src/theme/header/components/theme-drawer/menu-type.vue +40 -0
- package/src/theme/header/components/theme-drawer/select-item.vue +46 -0
- package/src/theme/header/components/theme-drawer/switch-item.vue +39 -0
- package/src/theme/header/components/theme-drawer/theme-color.vue +26 -0
- package/src/theme/header/components/trigger.vue +14 -0
- package/src/theme/header/components/user-info.vue +43 -0
- package/src/theme/header/const/index.ts +40 -0
- package/src/theme/header/helper/menu-tree.ts +64 -0
- package/src/theme/header/index.less +438 -0
- package/src/theme/header/index.ts +0 -0
- package/src/theme/header/index.vue +96 -0
- package/src/theme/header/multiple-header.vue +67 -0
- package/src/theme/header/set-theme.less +68 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/sider/components/basic-menu/basic-menu-item.vue +14 -0
- package/src/theme/sider/components/basic-menu/basic-menu.vue +122 -0
- package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +46 -0
- package/src/theme/sider/components/basic-menu/menu-item-content.vue +13 -0
- package/src/theme/sider/components/drag-bar.vue +26 -0
- package/src/theme/sider/components/layout-menu.vue +132 -0
- package/src/theme/sider/components/props.ts +97 -0
- package/src/theme/sider/components/sider-trigger.vue +24 -0
- package/src/theme/sider/helper/sider.ts +52 -0
- package/src/theme/sider/helper/split-menu.ts +146 -0
- package/src/theme/sider/hooks/useDragLine.ts +86 -0
- package/src/theme/sider/hooks/useOpenKeys.ts +57 -0
- package/src/theme/sider/index.less +203 -0
- package/src/theme/sider/index.vue +88 -0
- package/src/theme/tabs/components/TabContent.vue +36 -0
- package/src/theme/tabs/components/TabRedo.vue +18 -0
- package/src/theme/tabs/hooks/useMultifyTabs.ts +96 -0
- package/src/theme/tabs/hooks/useTabDropdown.ts +89 -0
- package/src/theme/tabs/index.less +165 -0
- package/src/theme/tabs/index.vue +98 -0
- package/src/theme/tabs/types/tabs.type.ts +8 -0
- package/src/theme/theme.less +67 -0
- package/src/theme/theme.vue +90 -0
- package/src/theme/transition.less +99 -0
- package/es/assets/data/icon.d.ts +0 -4
- package/es/assets/data/icon.ts +0 -69
- package/es/assets/data/icon11.ts +0 -69
- package/es/assets/style/var.less +0 -42
- package/es/components/icons/pick-icon.d.ts +0 -529
- package/es/components/icons/svg-icon.d.ts +0 -44
- package/es/components/table/src/hooks/useFormat.d.ts +0 -2
- package/es/components/table/src/hooks/useVirtualScroll.d.ts +0 -5
- package/es/components/table/src/utils/format.d.ts +0 -1
- package/es/style/assets/style/var.less +0 -42
- package/es/theme/content/index.d.ts +0 -29
- package/es/theme/header/components/menu-search.d.ts +0 -528
- package/es/theme/header/components/setting-theme.d.ts +0 -2550
- package/es/theme/header/index.d.ts +0 -4369
- package/es/theme/header/multiple-header.d.ts +0 -2001
- package/es/theme/styles/hooks/changeTheme.d.ts +0 -1
- package/es/theme/styles/hooks/generate.d.ts +0 -13
- package/es/theme/styles/index.d.ts +0 -2
- package/es/theme/tabs/components/TabRedo.d.ts +0 -49
- package/es/theme/tabs/index.d.ts +0 -1399
- package/es/theme/theme/initTheme.d.ts +0 -3
- package/es/theme/theme/util.d.ts +0 -5
- package/es/theme/theme.d.ts +0 -4911
- package/es/themes/generate.ts +0 -74
- package/es/themes/index.ts +0 -10
- package/es/themes/modifyVars.ts +0 -33
- package/es/themes/themePlugiin.ts +0 -74
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
computed,
|
|
5
|
+
ref,
|
|
6
|
+
getCurrentInstance,
|
|
7
|
+
onUnmounted,
|
|
8
|
+
inject,
|
|
9
|
+
Ref,
|
|
10
|
+
} from 'vue';
|
|
11
|
+
import { off, on, renderThumbStyle, BAR_MAP, Nullable } from '@dt-frames/core';
|
|
12
|
+
|
|
13
|
+
export default defineComponent({
|
|
14
|
+
name: 'Bar',
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
vertical: Boolean,
|
|
18
|
+
size: String,
|
|
19
|
+
move: Number,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
setup(props) {
|
|
23
|
+
const instance = getCurrentInstance();
|
|
24
|
+
const thumb = ref();
|
|
25
|
+
const wrap = inject('scroll-bar-wrap', {} as Ref<Nullable<HTMLElement>>) as any;
|
|
26
|
+
const bar = computed(() => {
|
|
27
|
+
return BAR_MAP[props.vertical ? 'vertical' : 'horizontal'];
|
|
28
|
+
});
|
|
29
|
+
const barStore = ref({} as any);
|
|
30
|
+
const cursorDown = ref();
|
|
31
|
+
const clickThumbHandler = (e: any) => {
|
|
32
|
+
if (e.ctrlKey || e.button === 2) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
window.getSelection()?.removeAllRanges();
|
|
36
|
+
startDrag(e);
|
|
37
|
+
barStore.value[bar.value.axis] =
|
|
38
|
+
e.currentTarget[bar.value.offset] -
|
|
39
|
+
(e[bar.value.client] - e.currentTarget.getBoundingClientRect()[bar.value.direction]);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const clickTrackHandler = (e: any) => {
|
|
43
|
+
const offset = Math.abs(
|
|
44
|
+
e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client],
|
|
45
|
+
);
|
|
46
|
+
const thumbHalf = thumb.value[bar.value.offset] / 2;
|
|
47
|
+
const thumbPositionPercentage =
|
|
48
|
+
((offset - thumbHalf) * 100) / instance?.vnode.el?.[bar.value.offset];
|
|
49
|
+
|
|
50
|
+
wrap.value[bar.value.scroll] =
|
|
51
|
+
(thumbPositionPercentage * wrap.value[bar.value.scrollSize]) / 100;
|
|
52
|
+
};
|
|
53
|
+
const startDrag = (e: any) => {
|
|
54
|
+
e.stopImmediatePropagation();
|
|
55
|
+
cursorDown.value = true;
|
|
56
|
+
on(document, 'mousemove', mouseMoveDocumentHandler);
|
|
57
|
+
on(document, 'mouseup', mouseUpDocumentHandler);
|
|
58
|
+
document.onselectstart = () => false;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const mouseMoveDocumentHandler = (e: any) => {
|
|
62
|
+
if (cursorDown.value === false) return;
|
|
63
|
+
const prevPage = barStore.value[bar.value.axis];
|
|
64
|
+
|
|
65
|
+
if (!prevPage) return;
|
|
66
|
+
|
|
67
|
+
const offset =
|
|
68
|
+
(instance?.vnode.el?.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) *
|
|
69
|
+
-1;
|
|
70
|
+
const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
|
|
71
|
+
const thumbPositionPercentage =
|
|
72
|
+
((offset - thumbClickPosition) * 100) / instance?.vnode.el?.[bar.value.offset];
|
|
73
|
+
wrap.value[bar.value.scroll] =
|
|
74
|
+
(thumbPositionPercentage * wrap.value[bar.value.scrollSize]) / 100;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
function mouseUpDocumentHandler() {
|
|
78
|
+
cursorDown.value = false;
|
|
79
|
+
barStore.value[bar.value.axis] = 0;
|
|
80
|
+
off(document, 'mousemove', mouseMoveDocumentHandler);
|
|
81
|
+
document.onselectstart = null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
onUnmounted(() => {
|
|
85
|
+
off(document, 'mouseup', mouseUpDocumentHandler);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return () =>
|
|
89
|
+
h(
|
|
90
|
+
'div',
|
|
91
|
+
{
|
|
92
|
+
class: ['scrollbar__bar', 'is-' + bar.value.key],
|
|
93
|
+
onMousedown: clickTrackHandler,
|
|
94
|
+
},
|
|
95
|
+
h('div', {
|
|
96
|
+
ref: thumb,
|
|
97
|
+
class: 'scrollbar__thumb',
|
|
98
|
+
onMousedown: clickThumbHandler,
|
|
99
|
+
style: renderThumbStyle({
|
|
100
|
+
size: props.size,
|
|
101
|
+
move: props.move,
|
|
102
|
+
bar: bar.value,
|
|
103
|
+
}),
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="scrollbar">
|
|
3
|
+
<div
|
|
4
|
+
ref="wrap"
|
|
5
|
+
:class="[wrapClass, 'scrollbar__wrap', native ? '' : 'scrollbar__wrap--hidden-default' ]"
|
|
6
|
+
:style="style"
|
|
7
|
+
@scroll="handleScroll"
|
|
8
|
+
>
|
|
9
|
+
<component
|
|
10
|
+
:is="tag"
|
|
11
|
+
ref="resize"
|
|
12
|
+
:class="['scrollbar__view', viewClass]"
|
|
13
|
+
:style="viewStyle"
|
|
14
|
+
>
|
|
15
|
+
<slot></slot>
|
|
16
|
+
</component>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<template v-if="!native">
|
|
20
|
+
<bar :move="moveX" :size="sizeWidth" />
|
|
21
|
+
<bar vertical :move="moveY" :size="sizeHeight" />
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, provide, ref, unref } from "vue";
|
|
29
|
+
import { addResizeListener, removeResizeListener, useAppStore } from "@dt-frames/core";
|
|
30
|
+
import Bar from './bar';
|
|
31
|
+
|
|
32
|
+
const { getScrollConf } = useAppStore()
|
|
33
|
+
const { native } = getScrollConf
|
|
34
|
+
|
|
35
|
+
const sizeWidth = ref('0');
|
|
36
|
+
const sizeHeight = ref('0');
|
|
37
|
+
const moveX = ref(0);
|
|
38
|
+
const moveY = ref(0);
|
|
39
|
+
const wrap = ref();
|
|
40
|
+
const resize = ref();
|
|
41
|
+
|
|
42
|
+
const props = defineProps({
|
|
43
|
+
wrapClass: {
|
|
44
|
+
type: [String, Array],
|
|
45
|
+
default: ''
|
|
46
|
+
},
|
|
47
|
+
wrapStyle: Array,
|
|
48
|
+
viewClass: {
|
|
49
|
+
type: [String, Array],
|
|
50
|
+
default: '',
|
|
51
|
+
},
|
|
52
|
+
viewStyle: {
|
|
53
|
+
type: [String, Array],
|
|
54
|
+
default: '',
|
|
55
|
+
},
|
|
56
|
+
noresize: Boolean,
|
|
57
|
+
tag: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: 'div'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
provide('scroll-bar-wrap', wrap);
|
|
64
|
+
|
|
65
|
+
// 设置容器style
|
|
66
|
+
const style = computed(() => {
|
|
67
|
+
let rsStyle = {};
|
|
68
|
+
|
|
69
|
+
if( Array.isArray(props.wrapStyle) ) {
|
|
70
|
+
props.wrapStyle.forEach( it => {
|
|
71
|
+
if( it ) rsStyle = Object.assign( {}, rsStyle, it );
|
|
72
|
+
} )
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return rsStyle;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// 设置容器的滚动事件
|
|
80
|
+
const handleScroll = () => {
|
|
81
|
+
if (!native) {
|
|
82
|
+
moveY.value = ( unref(wrap).scrollTop * 100 ) / unref( wrap ).clientHeight;
|
|
83
|
+
moveX.value = ( unref(wrap).scrollLeft * 100 ) / unref( wrap ).clientWidth;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const update = () => {
|
|
88
|
+
if (!unref(wrap)) return;
|
|
89
|
+
|
|
90
|
+
const heightPercentage = (unref(wrap).clientHeight * 100) / unref(wrap).scrollHeight;
|
|
91
|
+
const widthPercentage = (unref(wrap).clientWidth * 100) / unref(wrap).scrollWidth;
|
|
92
|
+
|
|
93
|
+
sizeHeight.value = heightPercentage < 100 ? heightPercentage + '%' : '';
|
|
94
|
+
sizeWidth.value = widthPercentage < 100 ? widthPercentage + '%' : '';
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
onMounted(() => {
|
|
98
|
+
if ( native ) return;
|
|
99
|
+
nextTick(update);
|
|
100
|
+
|
|
101
|
+
if (!props.noresize) {
|
|
102
|
+
addResizeListener(unref(resize), update);
|
|
103
|
+
addResizeListener(unref(wrap), update);
|
|
104
|
+
addEventListener('resize', update);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
onBeforeUnmount(() => {
|
|
109
|
+
if (native) return;
|
|
110
|
+
if (!props.noresize) {
|
|
111
|
+
removeResizeListener(unref(resize), update);
|
|
112
|
+
removeResizeListener(unref(wrap), update);
|
|
113
|
+
removeEventListener('resize', update);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
</script>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Scrollbar ref="scrollbarRef" class="scroll-container" v-bind="$attrs">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</Scrollbar>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
|
|
9
|
+
import { nextTick, ref, unref } from 'vue';
|
|
10
|
+
import { useScrollTo } from '@dt-frames/core';
|
|
11
|
+
|
|
12
|
+
import Scrollbar from './scroll-bar.vue';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const scrollbarRef = ref(null);
|
|
16
|
+
|
|
17
|
+
// 滚动到指定位置
|
|
18
|
+
function scrollTo( to: number, duration = 500 ) {
|
|
19
|
+
const scrollbar = unref(scrollbarRef);
|
|
20
|
+
if (!scrollbar) return;
|
|
21
|
+
|
|
22
|
+
nextTick(() => {
|
|
23
|
+
const wrap = unref(scrollbar.wrap);
|
|
24
|
+
if (!wrap) return;
|
|
25
|
+
|
|
26
|
+
const { start } = useScrollTo({
|
|
27
|
+
el: wrap,
|
|
28
|
+
to,
|
|
29
|
+
duration,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
start();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
function getScrollWrap() {
|
|
38
|
+
const scrollbar = unref(scrollbarRef);
|
|
39
|
+
return !scrollbar ? null : scrollbar.wrap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function scrollBottom() {
|
|
44
|
+
const scrollbar = unref(scrollbarRef);
|
|
45
|
+
if (!scrollbar) return;
|
|
46
|
+
|
|
47
|
+
nextTick(() => {
|
|
48
|
+
const wrap = unref(scrollbar.wrap) as any;
|
|
49
|
+
if (!wrap) return;
|
|
50
|
+
|
|
51
|
+
const scrollHeight = wrap.scrollHeight as number;
|
|
52
|
+
const { start } = useScrollTo({
|
|
53
|
+
el: wrap,
|
|
54
|
+
to: scrollHeight,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
start();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
</script>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- <a>打开弹框</a> -->
|
|
3
|
+
<DtModal @register="registerDialog" @save="handleSave">
|
|
4
|
+
<DtForm @register="registerForm" ></DtForm>
|
|
5
|
+
</DtModal>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts" setup>
|
|
9
|
+
import { isFunction, Recordable } from "@dt-frames/core";
|
|
10
|
+
import { omit } from 'lodash-es'
|
|
11
|
+
import { Ref, PropType, watch, toRaw, unref, watchEffect } from "vue";
|
|
12
|
+
import { useForm, DtForm } from "../../../forms";
|
|
13
|
+
import { DtModal, useModal } from "../../../modal"
|
|
14
|
+
import { basicProps } from "./props";
|
|
15
|
+
|
|
16
|
+
const props = defineProps( {
|
|
17
|
+
...basicProps,
|
|
18
|
+
...{
|
|
19
|
+
onRegister: { type: Function },
|
|
20
|
+
formProps: {
|
|
21
|
+
type: Object as PropType<Ref<Recordable>>
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} )
|
|
25
|
+
|
|
26
|
+
const [registerDialog, { }] = useModal({
|
|
27
|
+
...omit(toRaw(props), [
|
|
28
|
+
'actions',
|
|
29
|
+
'curd',
|
|
30
|
+
'formProps',
|
|
31
|
+
'onRegister',
|
|
32
|
+
'schemas'
|
|
33
|
+
])
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const [ registerForm, { getFormValues, setFormValues } ] = useForm({
|
|
37
|
+
schemas: props.schemas,
|
|
38
|
+
mode: 'dialog'
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
watch(
|
|
42
|
+
() => props.formProps.value,
|
|
43
|
+
v => {
|
|
44
|
+
if( v ) {
|
|
45
|
+
setFormValues( toRaw(v) )
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
function handleSave() {
|
|
52
|
+
if( props.curd && isFunction( props.curd?.onAdd ) ) {
|
|
53
|
+
|
|
54
|
+
let obj = Object.assign(
|
|
55
|
+
{},
|
|
56
|
+
props.formProps.value || {},
|
|
57
|
+
getFormValues()
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
obj.id
|
|
61
|
+
? props.curd.onUpdate( obj )
|
|
62
|
+
: props.curd.onAdd( obj )
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FormSchema, ButtonProps } from "../../../forms";
|
|
2
|
+
import { PropType } from "vue";
|
|
3
|
+
|
|
4
|
+
export const basicProps = {
|
|
5
|
+
title: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: ''
|
|
8
|
+
},
|
|
9
|
+
width: {
|
|
10
|
+
type: String as PropType<number | string>,
|
|
11
|
+
default: '50%'
|
|
12
|
+
},
|
|
13
|
+
schemas: {
|
|
14
|
+
type: Array as PropType<FormSchema[]>,
|
|
15
|
+
default: []
|
|
16
|
+
},
|
|
17
|
+
actions: {
|
|
18
|
+
type: Array as PropType<ButtonProps[]>,
|
|
19
|
+
default: []
|
|
20
|
+
},
|
|
21
|
+
canFullscreen: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
},
|
|
25
|
+
closable: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true
|
|
28
|
+
},
|
|
29
|
+
curd: {
|
|
30
|
+
type: Object as PropType<{[key: string]: Function}>
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DtCreateDialog, error, isFunction, Recordable } from "@dt-frames/core";
|
|
2
|
+
import { DtForm, useForm } from "../../../forms";
|
|
3
|
+
import { h, ref, unref } from "vue"
|
|
4
|
+
import { useModal, useModalOut } from "../../../modal"
|
|
5
|
+
import DtModal from "../components/dialog.vue";
|
|
6
|
+
import { CrudOptType } from "../types/curd.type";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function useCurd(curdOpt: CrudOptType) {
|
|
10
|
+
const formProps = ref<Recordable>()
|
|
11
|
+
const [register, { closeModal, setModalProps, openModal }] = useModalOut()
|
|
12
|
+
|
|
13
|
+
const DtCurdModal = () => {
|
|
14
|
+
return h(
|
|
15
|
+
<div class="curdModal">
|
|
16
|
+
<DtModal
|
|
17
|
+
{ ...curdOpt }
|
|
18
|
+
formProps = { formProps }
|
|
19
|
+
onRegister = { register }
|
|
20
|
+
></DtModal>
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 新增弹框
|
|
26
|
+
function add() {
|
|
27
|
+
openModal()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 删除
|
|
31
|
+
function del({ row }: Recordable) {
|
|
32
|
+
const { primaryKey = 'id', curd } = curdOpt
|
|
33
|
+
|
|
34
|
+
if( curd && curd.onDeletes && isFunction( curd.onDeletes ) ) {
|
|
35
|
+
curd.onDeletes( [row[ primaryKey ]] )
|
|
36
|
+
} else {
|
|
37
|
+
error(`缺少curd函数配置, 请将useSource中返回的curd参数传入useCurd配置项中!`)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 编辑弹框
|
|
42
|
+
function update({ row }: Recordable) {
|
|
43
|
+
const { primaryKey = 'id', curd } = curdOpt
|
|
44
|
+
|
|
45
|
+
curd.onQueryById(row[primaryKey]).then( rsp => {
|
|
46
|
+
formProps.value = rsp
|
|
47
|
+
} )
|
|
48
|
+
|
|
49
|
+
openModal()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// 批量删除
|
|
54
|
+
function dels(ids: string[] = []) {
|
|
55
|
+
const { curd } = curdOpt
|
|
56
|
+
|
|
57
|
+
if( curd && curd.onDeletes && isFunction( curd.onDeletes ) ) {
|
|
58
|
+
curd.onDeletes( ids )
|
|
59
|
+
} else {
|
|
60
|
+
error(`缺少curd函数配置, 请将useSource中返回的curd参数传入useCurd配置项中!`)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
DtCurdModal,
|
|
66
|
+
add,
|
|
67
|
+
del,
|
|
68
|
+
dels,
|
|
69
|
+
update
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Recordable } from "@dt-frames/core"
|
|
2
|
+
import { FormSchema, ButtonProps } from "../../../forms/src/types/form.type"
|
|
3
|
+
|
|
4
|
+
export type CrudOptType = {
|
|
5
|
+
// 标题
|
|
6
|
+
title?: string
|
|
7
|
+
// 弹框宽度
|
|
8
|
+
width?: string | number
|
|
9
|
+
// 条目
|
|
10
|
+
schemas: FormSchema[]
|
|
11
|
+
// 操作栏
|
|
12
|
+
actions?: ButtonProps[]
|
|
13
|
+
// 是否显示全屏
|
|
14
|
+
showFullscreen?: boolean
|
|
15
|
+
// 是否显示关闭按钮
|
|
16
|
+
showClose?: boolean
|
|
17
|
+
// 物理主键
|
|
18
|
+
primaryKey?: string
|
|
19
|
+
// 增删改查接口
|
|
20
|
+
curd?: {
|
|
21
|
+
onAdd?: ( model: Recordable ) => void
|
|
22
|
+
onUpdate?: ( model: Recordable ) => void
|
|
23
|
+
onDeletes?: ( keys: string[] ) => void
|
|
24
|
+
onExport?: () => void
|
|
25
|
+
onQueryById?: ( id: string ) => Promise<Recordable>
|
|
26
|
+
[key: string]: any
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as xlsx from 'xlsx'
|
|
2
|
+
import type { WorkBook } from 'xlsx'
|
|
3
|
+
import { DownloadType } from "../../table/src/types/tableHeader.type";
|
|
4
|
+
import { dateFormat } from '@dt-frames/core';
|
|
5
|
+
|
|
6
|
+
export function handleDownloadPage({
|
|
7
|
+
columns = [],
|
|
8
|
+
rows = []
|
|
9
|
+
}: DownloadType,
|
|
10
|
+
exportName: string = ''
|
|
11
|
+
) {
|
|
12
|
+
const titles = columns.map( it => it.title )
|
|
13
|
+
|
|
14
|
+
const content = rows.reduce( (total, it) => {
|
|
15
|
+
const rowData = columns.map( column => it[column.dataIndex.toString()] )
|
|
16
|
+
|
|
17
|
+
total.push( rowData )
|
|
18
|
+
return total
|
|
19
|
+
}, [] ) as string[][]
|
|
20
|
+
|
|
21
|
+
export2Excel(
|
|
22
|
+
[titles].concat(content) as string[][],
|
|
23
|
+
exportName
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export function export2Excel(data: string[][] = [], exportName: string = '') {
|
|
29
|
+
const worksheet = xlsx.utils.aoa_to_sheet(data)
|
|
30
|
+
const fileName = exportName + '_' + dateFormat(new Date(), 'yyyyMMdd') + '.xlsx'
|
|
31
|
+
|
|
32
|
+
const workbook: WorkBook = {
|
|
33
|
+
SheetNames: [fileName],
|
|
34
|
+
Sheets: {
|
|
35
|
+
[fileName]: worksheet,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
xlsx.writeFile(
|
|
40
|
+
workbook,
|
|
41
|
+
fileName,
|
|
42
|
+
{ bookType: 'xlsx' }
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
@import '../modal/index.less';
|
|
2
|
+
|
|
3
|
+
.text-secondary{
|
|
4
|
+
color: #666;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.suffix-item .suffix {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
padding-left: 6px;
|
|
10
|
+
margin-top: 1px;
|
|
11
|
+
line-height: 1;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.form-btns{
|
|
16
|
+
button{
|
|
17
|
+
margin-left: 12px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.advanced{
|
|
21
|
+
margin-left: 8px;
|
|
22
|
+
.text{
|
|
23
|
+
margin-right: 5px;
|
|
24
|
+
}
|
|
25
|
+
.basic-arrow{
|
|
26
|
+
margin-left: -8px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.basic-arrow{
|
|
32
|
+
display: inline-block;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
transform: rotate(0deg);
|
|
35
|
+
transition: all 0.3s ease 0.1s;
|
|
36
|
+
transform-origin: center center;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
.dt-icon{
|
|
40
|
+
vertical-align: middle;
|
|
41
|
+
color: @primary-color !important;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&--active{
|
|
45
|
+
transform: rotate(180deg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.form-btns{
|
|
50
|
+
.ant-form-item-control-input-content{
|
|
51
|
+
display: flex;
|
|
52
|
+
.ant-btn{
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
.ant-btn .dt-icon{
|
|
57
|
+
font-size: 20px;
|
|
58
|
+
height: 100%;
|
|
59
|
+
|
|
60
|
+
svg{
|
|
61
|
+
display: block;
|
|
62
|
+
height: 100%;
|
|
63
|
+
text-align: center;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.preIcon{
|
|
67
|
+
padding-right: 2px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ant-btn-primary .dt-icon svg{
|
|
72
|
+
color: #fff;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.basic-form--compact{
|
|
78
|
+
.ant-form-item {
|
|
79
|
+
margin-bottom: 14px !important;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import DtForm from './src/index.vue'
|
|
2
|
+
import { useForm } from './src/hooks/useForm'
|
|
3
|
+
import { ButtonProps, FormSchema } from './src/types/form.type'
|
|
4
|
+
import FormButtons from './src/components/formButton.vue'
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
FormButtons,
|
|
8
|
+
DtForm,
|
|
9
|
+
useForm,
|
|
10
|
+
FormSchema,
|
|
11
|
+
ButtonProps
|
|
12
|
+
}
|