@dt-frames/ui 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/curd/src/components/dialog.d.ts +20 -15
- package/es/components/curd/src/components/props.d.ts +4 -4
- package/es/components/curd/src/types/curd.type.d.ts +3 -2
- package/es/components/forms/src/components/formIcon.d.ts +10 -5
- package/es/components/index.d.ts +1 -1
- package/es/components/modal/src/components/modal.d.ts +2 -2
- package/es/components/modal/src/components/modalFooter.d.ts +9 -4
- package/es/components/modal/src/index.d.ts +10 -5
- package/es/components/modal/src/props.d.ts +2 -1
- package/es/components/table/src/hooks/useTable.d.ts +2 -2
- package/es/components/table/src/types/table.type.d.ts +2 -2
- package/es/components/upload/index.d.ts +1 -2
- package/es/components/upload/src/helper.d.ts +1 -0
- package/es/components/upload/src/index.d.ts +13 -9
- package/es/components/upload/src/props.d.ts +4 -1
- package/es/components/upload/src/upload.d.ts +18 -6
- package/es/index.js +220 -204
- package/es/style/components/upload/index.less +3 -11
- package/package.json +1 -1
- package/src/components/curd/src/components/dialog.vue +0 -1
- package/src/components/curd/src/components/props.ts +4 -4
- package/src/components/curd/src/hooks/useCurd.tsx +1 -1
- package/src/components/curd/src/types/curd.type.ts +3 -2
- package/src/components/index.ts +1 -2
- package/src/components/modal/src/components/modalFooter.vue +10 -2
- package/src/components/modal/src/index.vue +18 -7
- package/src/components/modal/src/props.ts +3 -2
- package/src/components/table/src/hooks/useRowSelection.ts +1 -1
- package/src/components/table/src/hooks/useTable.ts +1 -1
- package/src/components/table/src/hooks/useTableHeader.ts +2 -2
- package/src/components/table/src/types/table.type.ts +2 -2
- package/src/components/upload/index.less +3 -11
- package/src/components/upload/index.ts +0 -2
- package/src/components/upload/src/helper.ts +29 -1
- package/src/components/upload/src/props.ts +4 -1
- package/src/components/upload/src/upload.vue +88 -63
- package/src/components/upload/src/index.vue +0 -38
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
.dt-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
|
|
7
|
-
.ant-table-wrapper{
|
|
8
|
-
flex: 1;
|
|
9
|
-
.ant-table-body{
|
|
10
|
-
border-bottom: 1px solid #e7e7e7;
|
|
11
|
-
}
|
|
1
|
+
.dt-file {
|
|
2
|
+
td.orange{
|
|
3
|
+
color: orange;
|
|
12
4
|
}
|
|
13
5
|
}
|
|
14
6
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormSchema, ButtonProps } from "../../../forms";
|
|
2
|
-
import { PropType } from "vue";
|
|
2
|
+
import { PropType, VNodeChild } from "vue";
|
|
3
3
|
|
|
4
4
|
export const basicProps = {
|
|
5
5
|
title: {
|
|
@@ -14,9 +14,9 @@ export const basicProps = {
|
|
|
14
14
|
type: Array as PropType<FormSchema[]>,
|
|
15
15
|
default: []
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
type: Array as PropType<ButtonProps[]>,
|
|
19
|
-
default:
|
|
17
|
+
footer: {
|
|
18
|
+
type: Array as PropType<VNodeChild | JSX.Element | ButtonProps[]>,
|
|
19
|
+
default: undefined
|
|
20
20
|
},
|
|
21
21
|
canFullscreen: {
|
|
22
22
|
type: Boolean,
|
|
@@ -7,7 +7,7 @@ import { CrudOptType } from "../types/curd.type";
|
|
|
7
7
|
|
|
8
8
|
export function useCurd(curdOpt: CrudOptType) {
|
|
9
9
|
const formsVal = ref<Recordable>()
|
|
10
|
-
const [register, {
|
|
10
|
+
const [register, { openModal }] = useModalOut()
|
|
11
11
|
const { confirm } = useMessage()
|
|
12
12
|
|
|
13
13
|
const DtCurdModal = () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Recordable } from "@dt-frames/core"
|
|
2
|
-
import {
|
|
2
|
+
import { VNodeChild } from "vue"
|
|
3
|
+
import { FormSchema, FormProps, ButtonProps } from "../../../forms/src/types/form.type"
|
|
3
4
|
|
|
4
5
|
export type CrudOptType = {
|
|
5
6
|
// 标题
|
|
@@ -9,7 +10,7 @@ export type CrudOptType = {
|
|
|
9
10
|
// 条目
|
|
10
11
|
schemas: FormSchema[]
|
|
11
12
|
// 操作栏
|
|
12
|
-
|
|
13
|
+
footer?: VNodeChild | JSX.Element | ButtonProps[]
|
|
13
14
|
// 是否显示全屏
|
|
14
15
|
showFullscreen?: boolean
|
|
15
16
|
// 是否显示关闭按钮
|
package/src/components/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { useSource } from './source'
|
|
|
8
8
|
import { useCurd } from './curd'
|
|
9
9
|
import { export2Excel } from './excel'
|
|
10
10
|
import { DtIframe } from './iframe'
|
|
11
|
-
import { DtUpload
|
|
11
|
+
import { DtUpload } from './upload'
|
|
12
12
|
import { DtTree } from './tree'
|
|
13
13
|
|
|
14
14
|
const dtComponents = [
|
|
@@ -18,7 +18,6 @@ const dtComponents = [
|
|
|
18
18
|
{ name: 'dt-modal', component: DtModal },
|
|
19
19
|
{ name: 'dt-form', component: DtForm },
|
|
20
20
|
{ name: 'dt-upload', component: DtUpload },
|
|
21
|
-
{ name: 'dt-upload-modal', component: DtUploadModal },
|
|
22
21
|
{ name: 'dt-tree', component: DtTree },
|
|
23
22
|
];
|
|
24
23
|
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
<slot name="appendFooter"></slot>
|
|
3
3
|
<FormButtons
|
|
4
4
|
:mode="'dialog'"
|
|
5
|
-
:buttonList="
|
|
5
|
+
:buttonList="buttonList"
|
|
6
6
|
@handle-method="handleMethod($event)"
|
|
7
7
|
></FormButtons>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
|
-
import {
|
|
11
|
+
import { PropType, computed } from 'vue'
|
|
12
|
+
import { FormButtons, ButtonProps } from '../../../forms'
|
|
12
13
|
|
|
13
14
|
const emits = defineEmits([
|
|
14
15
|
'handleSave',
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
])
|
|
17
18
|
|
|
18
19
|
const props = defineProps({
|
|
20
|
+
buttons: Object as PropType<ButtonProps[]>,
|
|
19
21
|
showSave: {
|
|
20
22
|
type: Boolean,
|
|
21
23
|
default: true
|
|
@@ -27,6 +29,12 @@
|
|
|
27
29
|
{ name: '关闭', preIcon: 'mdi:close', flag: 'CANCEL' },
|
|
28
30
|
]
|
|
29
31
|
|
|
32
|
+
const buttonList = computed(() => {
|
|
33
|
+
if( props.buttons && props.buttons.length ) return props.buttons
|
|
34
|
+
|
|
35
|
+
return buttonActions
|
|
36
|
+
})
|
|
37
|
+
|
|
30
38
|
// 处理按钮点击事件
|
|
31
39
|
function handleMethod(item: ButtonProps) {
|
|
32
40
|
switch( item.flag ) {
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
<template #title v-if="!$slots.title">
|
|
13
13
|
{{ getMergeProps.title }}
|
|
14
14
|
</template>
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
<template #footer v-if="!$slots.footer">
|
|
17
17
|
<!-- 默认的footer内容 -->
|
|
18
|
-
<ModalFooter :showSave="getBindValue.showSave" @handle-save="handleSave" @handle-cancel="handleCancel">
|
|
18
|
+
<ModalFooter :buttons="(propsRef.footer as any)" :showSave="getBindValue.showSave" @handle-save="handleSave" @handle-cancel="handleCancel">
|
|
19
19
|
<template #[item]="data" v-for="item in Object.keys($slots)">
|
|
20
20
|
<slot :name="item" v-bind="data || {}"></slot>
|
|
21
21
|
</template>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
:minHeight="getBindValue.minHeight"
|
|
33
33
|
:height="getWrapperHeight"
|
|
34
34
|
:visible="visibleRef"
|
|
35
|
-
:modalFooterHeight="
|
|
35
|
+
:modalFooterHeight="modalFooterHeight"
|
|
36
36
|
v-bind="omit(getBindValue.wrapperProps, 'visible', 'height', 'modalFooterHeight')"
|
|
37
37
|
@ext-height="handleExtHeight"
|
|
38
38
|
@height-change="handleHeightChange"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
import ModalFooter from './components/modalFooter.vue'
|
|
57
57
|
|
|
58
58
|
import CloseIcon from './components/close-icon.vue';
|
|
59
|
-
import { isFunction, deepMerge, ModalProps, ModalMethods } from '@dt-frames/core';
|
|
59
|
+
import { isFunction, deepMerge, ModalProps, ModalMethods, isArray } from '@dt-frames/core';
|
|
60
60
|
|
|
61
61
|
const visibleRef = ref(false);
|
|
62
62
|
const propsRef = ref<Partial<ModalProps>>();
|
|
@@ -66,6 +66,12 @@
|
|
|
66
66
|
const props = defineProps( basicProps );
|
|
67
67
|
const emits = defineEmits(['visible-change', 'height-change', 'cancel', 'save', 'register', 'update:visible'])
|
|
68
68
|
|
|
69
|
+
const modalFooterHeight = computed(() => {
|
|
70
|
+
if( isArray(props.footer) ) {
|
|
71
|
+
return (unref(propsRef).footer as any).length ? 0 : undefined
|
|
72
|
+
}
|
|
73
|
+
return props.footer !== undefined && !props.footer ? 0 : undefined
|
|
74
|
+
})
|
|
69
75
|
|
|
70
76
|
const modalMethods: ModalMethods = {
|
|
71
77
|
setModalProps,
|
|
@@ -97,10 +103,16 @@
|
|
|
97
103
|
...unref(getMergeProps),
|
|
98
104
|
...(unref(propsRef) as any),
|
|
99
105
|
visible: unref(visibleRef),
|
|
100
|
-
wrapClassName: unref(getWrapClassName)
|
|
106
|
+
wrapClassName: unref(getWrapClassName)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let omitArr = unref(fullScreenRef) ? ['height', 'title'] : ['title']
|
|
110
|
+
|
|
111
|
+
if( isArray( unref(propsRef).footer ) ) {
|
|
112
|
+
omitArr.push( 'footer' )
|
|
101
113
|
}
|
|
102
114
|
|
|
103
|
-
return omit(bindValue,
|
|
115
|
+
return omit(bindValue, omitArr);
|
|
104
116
|
});
|
|
105
117
|
|
|
106
118
|
const getWrapperHeight = computed(() => {
|
|
@@ -132,7 +144,6 @@
|
|
|
132
144
|
extHeightRef.value = height;
|
|
133
145
|
}
|
|
134
146
|
|
|
135
|
-
|
|
136
147
|
function setModalProps(props: Partial<ModalProps>) {
|
|
137
148
|
|
|
138
149
|
propsRef.value = deepMerge(unref(propsRef) || ({} as any), props);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CSSProperties, PropType, VNodeChild } from "vue"
|
|
1
|
+
import { CSSProperties, PropType, VNodeChild } from "vue"
|
|
2
|
+
import { ButtonProps } from "../../forms"
|
|
2
3
|
|
|
3
4
|
// 支持设置的属性
|
|
4
5
|
const modalProps = {
|
|
@@ -33,7 +34,7 @@ export const basicProps = Object.assign({}, modalProps, {
|
|
|
33
34
|
keyboard : { type: Boolean, default: true },
|
|
34
35
|
maskStyle : Object as PropType<CSSProperties>,
|
|
35
36
|
|
|
36
|
-
footer : Object as PropType<VNodeChild | JSX.Element>,
|
|
37
|
+
footer : Object as PropType<VNodeChild | JSX.Element | ButtonProps[]>,
|
|
37
38
|
|
|
38
39
|
bodyStyle : Object as PropType<CSSProperties>,
|
|
39
40
|
|
|
@@ -6,7 +6,7 @@ import { useHeaderCode } from './useHeaderCode'
|
|
|
6
6
|
|
|
7
7
|
type Props = Partial<DynamicProps<BasicTableProps>>
|
|
8
8
|
|
|
9
|
-
export function useTable(tableProps?: Props) {
|
|
9
|
+
export function useTable(tableProps?: Props): [registerTable: (...args: any) => void, methods: TableActionType] {
|
|
10
10
|
const tableRef = ref<Nullable<TableActionType>>(null)
|
|
11
11
|
const loadedRef = ref<Nullable<boolean>>(false)
|
|
12
12
|
|
|
@@ -9,10 +9,10 @@ export function useTableHeader(
|
|
|
9
9
|
handlers: { onColumnsChange: (data: ColumnChangeParam[]) => void }
|
|
10
10
|
) {
|
|
11
11
|
const getHeaderProps = computed((): Recordable => {
|
|
12
|
-
const { tableSetting, toolbar
|
|
12
|
+
const { tableSetting, toolbar } = unref(propsRef)
|
|
13
13
|
|
|
14
14
|
const { getSlot } = useSlots()
|
|
15
|
-
const hideTitle = !toolbar
|
|
15
|
+
const hideTitle = !toolbar && !slots.toolbar && !slots.headerTop && !tableSetting
|
|
16
16
|
|
|
17
17
|
return {
|
|
18
18
|
title: hideTitle
|
|
@@ -154,7 +154,7 @@ export type TableActionType = {
|
|
|
154
154
|
getRowSelection: () => TableRowSelection<Recordable>
|
|
155
155
|
getCacheColumns: () => BasicColumn[]
|
|
156
156
|
setCacheColumnsByField?: (dataIndex: string | undefined, value: BasicColumn) => void
|
|
157
|
-
getSelectRows: ( ) =>
|
|
158
|
-
getSelectRowKeys: ( ) =>
|
|
157
|
+
getSelectRows: ( ) => Recordable[]
|
|
158
|
+
getSelectRowKeys: ( ) => string[]
|
|
159
159
|
emit?: any
|
|
160
160
|
}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
.dt-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
|
|
7
|
-
.ant-table-wrapper{
|
|
8
|
-
flex: 1;
|
|
9
|
-
.ant-table-body{
|
|
10
|
-
border-bottom: 1px solid #e7e7e7;
|
|
11
|
-
}
|
|
1
|
+
.dt-file {
|
|
2
|
+
td.orange{
|
|
3
|
+
color: orange;
|
|
12
4
|
}
|
|
13
5
|
}
|
|
14
6
|
|
|
@@ -26,7 +26,35 @@ export function useHelpers(
|
|
|
26
26
|
.join(',')
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
+
const getHelpText = computed(() => {
|
|
30
|
+
const helpText = unref(helpTextRef)
|
|
31
|
+
if (helpText) {
|
|
32
|
+
return helpText
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const helpTexts: string[] = []
|
|
36
|
+
|
|
37
|
+
const accept = unref(acceptRef)
|
|
38
|
+
if (accept.length > 0) {
|
|
39
|
+
helpTexts.push(`支持${ accept.join(',') }格式`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const maxSize = unref(maxSizeRef)
|
|
43
|
+
if (maxSize) {
|
|
44
|
+
helpTexts.push(`不超过${ maxSize }M`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const maxNumber = unref(maxNumberRef)
|
|
48
|
+
if (maxNumber && maxNumber !== Infinity) {
|
|
49
|
+
helpTexts.push(`最多可选择${ maxNumber }个文件`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return helpTexts.join(',') || '请上传pptx、doc、jpg、jpeg、png、bmp、gif、xls、xlsx、txt、rar、zip、7z、tar、gz格式文件'
|
|
53
|
+
|
|
54
|
+
})
|
|
55
|
+
|
|
29
56
|
return {
|
|
30
|
-
getStringAccept
|
|
57
|
+
getStringAccept,
|
|
58
|
+
getHelpText
|
|
31
59
|
}
|
|
32
60
|
}
|
|
@@ -34,7 +34,6 @@ export const basicUploadProps = {
|
|
|
34
34
|
// 文件最大多少MB
|
|
35
35
|
maxSize: {
|
|
36
36
|
type: Number as PropType<number>,
|
|
37
|
-
default: 2,
|
|
38
37
|
},
|
|
39
38
|
// 最大数量的文件,Infinity不限制
|
|
40
39
|
maxNumber: {
|
|
@@ -44,5 +43,9 @@ export const basicUploadProps = {
|
|
|
44
43
|
defaultFiles: {
|
|
45
44
|
type: Array as PropType<FileType[]>,
|
|
46
45
|
default: []
|
|
46
|
+
},
|
|
47
|
+
showView: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
47
50
|
}
|
|
48
51
|
}
|
|
@@ -1,46 +1,49 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="file
|
|
3
|
-
<div>
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
2
|
+
<div class="dt-file">
|
|
3
|
+
<div class="file-header">
|
|
4
|
+
<div>
|
|
5
|
+
<Upload
|
|
6
|
+
:accept="getStringAccept"
|
|
7
|
+
:multiple="multiple"
|
|
8
|
+
:before-upload="beforeUpload"
|
|
9
|
+
:show-upload-list="false"
|
|
10
|
+
>
|
|
11
|
+
<Button type="primary">
|
|
12
|
+
<span v-icon="'ic:baseline-file-upload'"></span>
|
|
13
|
+
文件上传
|
|
14
|
+
</Button>
|
|
15
|
+
</Upload>
|
|
16
|
+
<Button type="primary" v-if="showTemplateDownload" @click="templateDownload">
|
|
17
|
+
<span v-icon="'ic:baseline-file-download'"></span>
|
|
18
|
+
模板下载
|
|
13
19
|
</Button>
|
|
14
|
-
</
|
|
15
|
-
<
|
|
16
|
-
<span v-icon="'ic:baseline-file-download'"></span>
|
|
17
|
-
模板下载
|
|
18
|
-
</Button>
|
|
20
|
+
</div>
|
|
21
|
+
<slot></slot>
|
|
19
22
|
</div>
|
|
20
|
-
<slot></slot>
|
|
21
|
-
</div>
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
<div class="file-type-tips ant-alert-info">
|
|
25
|
+
<span v-icon="'ant-design:info-circle-outlined'"></span>
|
|
26
|
+
<i>{{ getHelpText }}</i>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<DtTable @register="registerTable"></DtTable>
|
|
30
|
+
|
|
31
|
+
<Image
|
|
32
|
+
:width="200"
|
|
33
|
+
:style="{ display: 'none' }"
|
|
34
|
+
:preview="{
|
|
35
|
+
visible: imgVisable,
|
|
36
|
+
onVisibleChange: setImgVisible,
|
|
37
|
+
}"
|
|
38
|
+
:src="imgSrcRef"
|
|
39
|
+
></Image>
|
|
39
40
|
|
|
41
|
+
</div>
|
|
42
|
+
|
|
40
43
|
</template>
|
|
41
44
|
|
|
42
45
|
<script lang="ts" setup>
|
|
43
|
-
import { h, ref, toRefs, watchEffect } from 'vue'
|
|
46
|
+
import { h, ref, toRefs, watchEffect, watch, computed } from 'vue'
|
|
44
47
|
import { Button, Upload, Image } from 'ant-design-vue'
|
|
45
48
|
import { DtTable, useTable } from '../../table'
|
|
46
49
|
import { basicUploadProps } from './props'
|
|
@@ -53,62 +56,77 @@
|
|
|
53
56
|
|
|
54
57
|
const filesRef = ref([])
|
|
55
58
|
const historyFilesRef = ref([])
|
|
56
|
-
const allFilesRef =
|
|
59
|
+
const allFilesRef = computed(() => {
|
|
60
|
+
return [...historyFilesRef.value, ...filesRef.value ]
|
|
61
|
+
})
|
|
57
62
|
|
|
58
63
|
// 控制图片预览显示隐藏
|
|
59
64
|
const imgVisable = ref( false )
|
|
65
|
+
const imgSrcRef = ref()
|
|
60
66
|
const setImgVisible = (value) => imgVisable.value = value
|
|
61
67
|
|
|
62
68
|
const props = defineProps( basicUploadProps )
|
|
63
69
|
|
|
64
70
|
const { accept, helpText, maxNumber, maxSize } = toRefs(props)
|
|
65
|
-
const {
|
|
71
|
+
const {
|
|
72
|
+
getStringAccept,
|
|
73
|
+
getHelpText
|
|
74
|
+
} = useHelpers( accept, helpText, maxNumber, maxSize )
|
|
66
75
|
|
|
76
|
+
const isImage = (fileType: string) => ['pdf', 'jpg', 'jpeg', 'png', 'bmp', 'gif'].includes( fileType )
|
|
67
77
|
|
|
68
|
-
const [registerTable
|
|
78
|
+
const [registerTable] = useTable({
|
|
69
79
|
tableSetting: false,
|
|
70
80
|
pagination: false,
|
|
71
81
|
dataSource: allFilesRef,
|
|
72
82
|
columns: [
|
|
73
83
|
{ title: '文件名称', dataIndex: 'fileName' },
|
|
74
|
-
{ title: '上传状态', dataIndex: 'fileStatue',
|
|
75
|
-
return h('span', {
|
|
76
|
-
style: `color: ${ row.status === 0 ? 'orange' : 'green' }`,
|
|
77
|
-
}, row.fileStatue)
|
|
78
|
-
} },
|
|
84
|
+
{ title: '上传状态', dataIndex: 'fileStatue', className: 'orange' },
|
|
79
85
|
],
|
|
80
86
|
operations: {
|
|
81
87
|
expand: true,
|
|
82
88
|
btns: [
|
|
83
89
|
{ title: '预览', icon: 'ic:baseline-remove-red-eye',
|
|
84
90
|
ifShow(row) {
|
|
85
|
-
|
|
86
|
-
return
|
|
91
|
+
if( !props.showView ) return false
|
|
92
|
+
return isImage( row.fileName.split('.').pop() )
|
|
87
93
|
},
|
|
88
|
-
action: () => {
|
|
89
|
-
|
|
94
|
+
action: ({ row }) => {
|
|
95
|
+
if( isImage( row.fileName.split('.').pop() ) ) {
|
|
96
|
+
setImgVisible(true)
|
|
97
|
+
}
|
|
90
98
|
}
|
|
91
99
|
},
|
|
92
|
-
{ title: '
|
|
93
|
-
|
|
100
|
+
{ title: '删除', icon: 'mdi:delete-outline', action: ({row}) => {
|
|
101
|
+
if( !row.status ) historyFilesRef.value = historyFilesRef.value.filter( it => it.fileId !== row.fileId )
|
|
102
|
+
else {
|
|
103
|
+
filesRef.value = filesRef.value.filter( it => it.fileId !== row.fileId )
|
|
104
|
+
}
|
|
105
|
+
} }
|
|
94
106
|
]
|
|
95
107
|
}
|
|
96
108
|
})
|
|
97
109
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
watch(
|
|
111
|
+
() => props.defaultFiles,
|
|
112
|
+
v => {
|
|
113
|
+
if( v ) {
|
|
114
|
+
historyFilesRef.value = props.defaultFiles.map((file, index) => {
|
|
115
|
+
return {
|
|
116
|
+
...file,
|
|
117
|
+
fileId: file.id || index,
|
|
118
|
+
fileName: file.fileName,
|
|
119
|
+
status: 0,
|
|
120
|
+
fileStatue: '历史上传'
|
|
121
|
+
}
|
|
122
|
+
})
|
|
106
123
|
}
|
|
107
|
-
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
immediate: true
|
|
127
|
+
}
|
|
128
|
+
)
|
|
108
129
|
|
|
109
|
-
allFilesRef.value = [...historyFilesRef.value, ...filesRef.value]
|
|
110
|
-
})
|
|
111
|
-
|
|
112
130
|
|
|
113
131
|
function beforeUpload(file: File) {
|
|
114
132
|
const { maxSize } = props
|
|
@@ -139,13 +157,20 @@
|
|
|
139
157
|
if (currentChunk < chunks) {
|
|
140
158
|
loadNext();
|
|
141
159
|
} else {
|
|
142
|
-
|
|
160
|
+
let fileObj = {
|
|
143
161
|
fileName: file.name,
|
|
144
162
|
fileId: spark.end(),
|
|
145
163
|
file,
|
|
146
164
|
status: 1,
|
|
147
165
|
fileStatue: '待上传'
|
|
148
|
-
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if( props.multiple ) {
|
|
169
|
+
filesRef.value.push(fileObj)
|
|
170
|
+
} else {
|
|
171
|
+
historyFilesRef.value = []
|
|
172
|
+
filesRef.value = [fileObj]
|
|
173
|
+
}
|
|
149
174
|
}
|
|
150
175
|
}
|
|
151
176
|
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DtModal
|
|
3
|
-
@save="handleSave()"
|
|
4
|
-
@register="register"
|
|
5
|
-
>
|
|
6
|
-
<div class="dt-upload-wrap">
|
|
7
|
-
<DtUpload ref="uploadRef" :defaultFiles="defaultFiles">
|
|
8
|
-
111
|
|
9
|
-
</DtUpload>
|
|
10
|
-
</div>
|
|
11
|
-
</DtModal>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script lang="ts" setup>
|
|
15
|
-
import { ref } from 'vue'
|
|
16
|
-
import { DtModal, useModal } from '../../modal'
|
|
17
|
-
import DtUpload from './upload.vue'
|
|
18
|
-
|
|
19
|
-
const uploadRef = ref(null)
|
|
20
|
-
const emites = defineEmits(['register'])
|
|
21
|
-
|
|
22
|
-
// 注册弹框
|
|
23
|
-
const [register] = useModal({
|
|
24
|
-
width: '700px',
|
|
25
|
-
title: '文件上传',
|
|
26
|
-
maskClosable: false,
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const defaultFiles = [
|
|
30
|
-
{ fileName: '叮咚发票667.09.pdf', fileId: '1' }
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
// 保存
|
|
34
|
-
function handleSave() {
|
|
35
|
-
console.log(uploadRef.value.allFilesRef)
|
|
36
|
-
alert("s-s-s-")
|
|
37
|
-
}
|
|
38
|
-
</script>
|