agilebuilder-ui 1.0.71-tmp7 → 1.0.72
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/lib/super-ui.css +1 -1
- package/lib/super-ui.js +29640 -27931
- package/lib/super-ui.umd.cjs +95 -87
- package/package.json +4 -5
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-app.vue +249 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-browser.vue +484 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-component.vue +127 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-input.vue +220 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload.vue +255 -0
- package/packages/fs-upload-new/src/fs-button-upload.vue +3 -2
- package/packages/fs-upload-new/src/fs-drag-upload.vue +2 -6
- package/packages/fs-upload-new/src/fs-preview-new.vue +30 -13
- package/packages/fs-upload-new/src/fs-upload-new.vue +88 -8
- package/src/i18n/langs/cn.js +2 -0
- package/src/i18n/langs/en.js +2 -0
- package/src/permission.js +122 -108
- package/src/utils/common-util.js +24 -86
- package/src/utils/i18n-util.js +0 -127
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-input
|
|
4
|
+
ref="item"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
v-model="fileNames"
|
|
7
|
+
:placeholder="$t('imatrixUIMessage.fileUpload')"
|
|
8
|
+
:readonly="true"
|
|
9
|
+
>
|
|
10
|
+
<template v-slot:append>
|
|
11
|
+
<el-button v-if="!disabled" :icon="Upload" size="default" @click="openAnnexUpload" />
|
|
12
|
+
</template>
|
|
13
|
+
</el-input>
|
|
14
|
+
|
|
15
|
+
<el-dialog
|
|
16
|
+
v-model="annexUploadFlag"
|
|
17
|
+
:append-to-body="true"
|
|
18
|
+
:show-close="true"
|
|
19
|
+
:title="$t('imatrixUIMessage.upload')"
|
|
20
|
+
width="80%"
|
|
21
|
+
@close="annexUploadFlag=false"
|
|
22
|
+
>
|
|
23
|
+
<FileUploadMobile
|
|
24
|
+
:disabled="disabled"
|
|
25
|
+
:fileInfo="fileInfo"
|
|
26
|
+
:systemCode="systemCode"
|
|
27
|
+
:accept="accept"
|
|
28
|
+
:multiple="multiple"
|
|
29
|
+
:limit="limit"
|
|
30
|
+
:limitFileSize="limitFileSize"
|
|
31
|
+
:placeholder="placeholder"
|
|
32
|
+
:action="action"
|
|
33
|
+
:headers="headers"
|
|
34
|
+
:file-list="fileList"
|
|
35
|
+
:beforeUpload="beforeUpload"
|
|
36
|
+
:onSuccess="onSuccess"
|
|
37
|
+
:beforeRemove="beforeRemove"
|
|
38
|
+
:onRemove="onRemove"
|
|
39
|
+
:beforeDownload="beforeDownload"
|
|
40
|
+
:pageContext="pageContext"
|
|
41
|
+
:configure="configure"
|
|
42
|
+
:openFsUpload="openFsUpload"
|
|
43
|
+
@uploadend="uploadendMobile"
|
|
44
|
+
@remove="removeMobileFile"
|
|
45
|
+
/>
|
|
46
|
+
</el-dialog>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script lang="ts" setup>
|
|
51
|
+
import { ref, defineEmits } from 'vue'
|
|
52
|
+
import { ElMessage } from 'element-plus'
|
|
53
|
+
import FileUploadMobile from './file-upload.vue'
|
|
54
|
+
import {
|
|
55
|
+
Upload
|
|
56
|
+
} from '@element-plus/icons-vue'
|
|
57
|
+
|
|
58
|
+
const props = defineProps({
|
|
59
|
+
openFsUpload: {
|
|
60
|
+
type: Object,
|
|
61
|
+
default: true
|
|
62
|
+
},
|
|
63
|
+
entity: {
|
|
64
|
+
type: Object,
|
|
65
|
+
default: () => {
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
fileInfo: {
|
|
70
|
+
type: Object,
|
|
71
|
+
default: () => ({})
|
|
72
|
+
},
|
|
73
|
+
systemCode: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: ''
|
|
76
|
+
},
|
|
77
|
+
displayType: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: 'input'
|
|
80
|
+
},
|
|
81
|
+
// 是否禁止编辑,为true只能下载,不能删除和上传
|
|
82
|
+
disabled: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false
|
|
85
|
+
},
|
|
86
|
+
accept: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: ''
|
|
89
|
+
},
|
|
90
|
+
multiple: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: false
|
|
93
|
+
},
|
|
94
|
+
limit: {
|
|
95
|
+
type: Number,
|
|
96
|
+
default: 1
|
|
97
|
+
},
|
|
98
|
+
// 文件大小限制,单位是M,默认是30M
|
|
99
|
+
limitFileSize: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 30
|
|
102
|
+
},
|
|
103
|
+
placeholder: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: '拖拽文件 或 点击上传'
|
|
106
|
+
},
|
|
107
|
+
action: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: ''
|
|
110
|
+
},
|
|
111
|
+
headers: {
|
|
112
|
+
type: Object,
|
|
113
|
+
default: () => ({ Authorization: null })
|
|
114
|
+
},
|
|
115
|
+
// 已上传文件列表
|
|
116
|
+
fileList: {
|
|
117
|
+
type: Array,
|
|
118
|
+
default: () => []
|
|
119
|
+
},
|
|
120
|
+
onSuccess: {
|
|
121
|
+
type: Function,
|
|
122
|
+
default: () => {}
|
|
123
|
+
},
|
|
124
|
+
beforeRemove: {
|
|
125
|
+
type: Function,
|
|
126
|
+
default: () => {}
|
|
127
|
+
},
|
|
128
|
+
onRemove: {
|
|
129
|
+
type: Function,
|
|
130
|
+
default: () => {}
|
|
131
|
+
},
|
|
132
|
+
beforeDownload: {
|
|
133
|
+
type: Function,
|
|
134
|
+
default: () => {}
|
|
135
|
+
},
|
|
136
|
+
pageContext: {
|
|
137
|
+
type: Object,
|
|
138
|
+
default: () => ({})
|
|
139
|
+
},
|
|
140
|
+
configure: {
|
|
141
|
+
type: Object,
|
|
142
|
+
default: () => ({})
|
|
143
|
+
},
|
|
144
|
+
// 组件id,在表单或列表中应该唯一,一般传字段名即可
|
|
145
|
+
componentId: {
|
|
146
|
+
type: String,
|
|
147
|
+
default: function () {
|
|
148
|
+
return 'file-upload'
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
// 组件名称,一般是字段label
|
|
152
|
+
componentName: {
|
|
153
|
+
type: String,
|
|
154
|
+
default: function () {
|
|
155
|
+
return 'file-upload'
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
options: {
|
|
159
|
+
type: Object,
|
|
160
|
+
default: null
|
|
161
|
+
},
|
|
162
|
+
// 列表编码
|
|
163
|
+
listCode: {
|
|
164
|
+
type: String,
|
|
165
|
+
default: null
|
|
166
|
+
},
|
|
167
|
+
// 打开相机和相册选项,默认是都可以打开
|
|
168
|
+
openCameraOrChoosePhoto: {
|
|
169
|
+
type: String,
|
|
170
|
+
default: 'openCameraAndChoosePhoto'
|
|
171
|
+
},
|
|
172
|
+
beforeUpload: {
|
|
173
|
+
type: Function,
|
|
174
|
+
default: () => {}
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
const emits = defineEmits(['remove', 'uploadend'])
|
|
179
|
+
const annexUploadFlag = ref(false)
|
|
180
|
+
const fileNames = ref(null)
|
|
181
|
+
|
|
182
|
+
const openAnnexUpload = ()=>{
|
|
183
|
+
console.log('点击选择文件按钮---')
|
|
184
|
+
annexUploadFlag.value = true
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function uploadendMobile(fileList) {
|
|
188
|
+
const fileServerPaths = Array.from(props.fileList,({serverPath})=>serverPath)
|
|
189
|
+
// console.log('uploadendMobile---props.fileList=', props.fileList,'fileServerPaths=',fileServerPaths, 'fileList=', fileList)
|
|
190
|
+
fileList.forEach(file=>{
|
|
191
|
+
// 如果已经存在就不要重复添加到fileList中了
|
|
192
|
+
if(fileServerPaths.indexOf(file.serverPath) < 0){
|
|
193
|
+
props.fileList.push({
|
|
194
|
+
showName: file.name,
|
|
195
|
+
serverPath: file.serverPath
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
fileNames.value =props.fileList.map((item: any) => item.showName).join(',')
|
|
200
|
+
props.onSuccess()
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
function removeMobileFile(param) {
|
|
205
|
+
// console.log('removeMobileFile---props.fileList=', props.fileList, 'param=', param)
|
|
206
|
+
const deleteFile = param.rmFiles && param.rmFiles.length > 0 ? param.rmFiles[0] : null
|
|
207
|
+
if(deleteFile){
|
|
208
|
+
let index = props.fileList.findIndex((item: any) => item.serverPath === deleteFile.serverPath)
|
|
209
|
+
if (index > -1) {
|
|
210
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
211
|
+
props.fileList.splice(index, 1)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
fileNames.value =props.fileList.map((item: any) => item.showName).join(',')
|
|
215
|
+
props.onRemove()
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<file-upload-app
|
|
4
|
+
v-if="userAgent === 'app'"
|
|
5
|
+
ref="fileUploadRef"
|
|
6
|
+
:file-list="fileList"
|
|
7
|
+
:multiple="multiple"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
:open-camera-or-choose-photo="openCameraOrChoosePhoto"
|
|
10
|
+
:options="options"
|
|
11
|
+
:fileInfo="fileInfo"
|
|
12
|
+
:systemCode="systemCode"
|
|
13
|
+
:accept="accept"
|
|
14
|
+
:limit="limit"
|
|
15
|
+
:limitFileSize="limitFileSize"
|
|
16
|
+
:placeholder="placeholder"
|
|
17
|
+
:action="action"
|
|
18
|
+
:headers="headers"
|
|
19
|
+
:beforeUpload="beforeUpload"
|
|
20
|
+
:onSuccess="onSuccess"
|
|
21
|
+
:beforeRemove="beforeRemove"
|
|
22
|
+
:onRemove="onRemove"
|
|
23
|
+
:beforeDownload="beforeDownload"
|
|
24
|
+
:pageContext="pageContext"
|
|
25
|
+
:configure="configure"
|
|
26
|
+
:openFsUpload="openFsUpload"
|
|
27
|
+
@uploadend="uploadedFile"
|
|
28
|
+
@remove="removeFile"
|
|
29
|
+
/>
|
|
30
|
+
<file-upload-browser
|
|
31
|
+
v-else-if="userAgent === 'browser'"
|
|
32
|
+
ref="fileUploadRef"
|
|
33
|
+
:file-list="fileList"
|
|
34
|
+
:multiple="multiple"
|
|
35
|
+
:disabled="disabled"
|
|
36
|
+
:open-camera-or-choose-photo="openCameraOrChoosePhoto"
|
|
37
|
+
:options="options"
|
|
38
|
+
:fileInfo="fileInfo"
|
|
39
|
+
:systemCode="systemCode"
|
|
40
|
+
:accept="accept"
|
|
41
|
+
:limit="limit"
|
|
42
|
+
:limitFileSize="limitFileSize"
|
|
43
|
+
:placeholder="placeholder"
|
|
44
|
+
:action="action"
|
|
45
|
+
:headers="headers"
|
|
46
|
+
:beforeUpload="beforeUpload"
|
|
47
|
+
:onSuccess="onSuccess"
|
|
48
|
+
:beforeRemove="beforeRemove"
|
|
49
|
+
:onRemove="onRemove"
|
|
50
|
+
:beforeDownload="beforeDownload"
|
|
51
|
+
:pageContext="pageContext"
|
|
52
|
+
:configure="configure"
|
|
53
|
+
:openFsUpload="openFsUpload"
|
|
54
|
+
@uploadend="uploadedFile"
|
|
55
|
+
@remove="removeFile"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
<script lang="ts" setup>
|
|
60
|
+
import { ref, defineEmits } from 'vue'
|
|
61
|
+
import { ElMessage } from 'element-plus'
|
|
62
|
+
import { useI18n } from 'vue-i18n'
|
|
63
|
+
import FileUploadApp from './file-upload-app.vue'
|
|
64
|
+
import FileUploadBrowser from './file-upload-browser.vue'
|
|
65
|
+
import apis from './api.js'
|
|
66
|
+
|
|
67
|
+
const props = defineProps({
|
|
68
|
+
openFsUpload: {
|
|
69
|
+
type: Object,
|
|
70
|
+
default: true
|
|
71
|
+
},
|
|
72
|
+
entity: {
|
|
73
|
+
type: Object,
|
|
74
|
+
default: () => {
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
fileInfo: {
|
|
79
|
+
type: Object,
|
|
80
|
+
default: () => ({})
|
|
81
|
+
},
|
|
82
|
+
systemCode: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: ''
|
|
85
|
+
},
|
|
86
|
+
displayType: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: 'input'
|
|
89
|
+
},
|
|
90
|
+
// 是否禁止编辑,为true只能下载,不能删除和上传
|
|
91
|
+
disabled: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
accept: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: ''
|
|
98
|
+
},
|
|
99
|
+
multiple: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false
|
|
102
|
+
},
|
|
103
|
+
limit: {
|
|
104
|
+
type: Number,
|
|
105
|
+
default: 1
|
|
106
|
+
},
|
|
107
|
+
// 文件大小限制,单位是M,默认是30M
|
|
108
|
+
limitFileSize: {
|
|
109
|
+
type: Number,
|
|
110
|
+
default: 30
|
|
111
|
+
},
|
|
112
|
+
placeholder: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: '拖拽文件 或 点击上传'
|
|
115
|
+
},
|
|
116
|
+
action: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: ''
|
|
119
|
+
},
|
|
120
|
+
headers: {
|
|
121
|
+
type: Object,
|
|
122
|
+
default: () => ({ Authorization: null })
|
|
123
|
+
},
|
|
124
|
+
// 已上传文件列表
|
|
125
|
+
fileList: {
|
|
126
|
+
type: Array,
|
|
127
|
+
default: () => []
|
|
128
|
+
},
|
|
129
|
+
onSuccess: {
|
|
130
|
+
type: Function,
|
|
131
|
+
default: () => {}
|
|
132
|
+
},
|
|
133
|
+
beforeRemove: {
|
|
134
|
+
type: Function,
|
|
135
|
+
default: () => {}
|
|
136
|
+
},
|
|
137
|
+
onRemove: {
|
|
138
|
+
type: Function,
|
|
139
|
+
default: () => {}
|
|
140
|
+
},
|
|
141
|
+
beforeDownload: {
|
|
142
|
+
type: Function,
|
|
143
|
+
default: () => {}
|
|
144
|
+
},
|
|
145
|
+
pageContext: {
|
|
146
|
+
type: Object,
|
|
147
|
+
default: () => ({})
|
|
148
|
+
},
|
|
149
|
+
configure: {
|
|
150
|
+
type: Object,
|
|
151
|
+
default: () => ({})
|
|
152
|
+
},
|
|
153
|
+
// 组件id,在表单或列表中应该唯一,一般传字段名即可
|
|
154
|
+
componentId: {
|
|
155
|
+
type: String,
|
|
156
|
+
default: function () {
|
|
157
|
+
return 'file-upload'
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
// 组件名称,一般是字段label
|
|
161
|
+
componentName: {
|
|
162
|
+
type: String,
|
|
163
|
+
default: function () {
|
|
164
|
+
return 'file-upload'
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
options: {
|
|
168
|
+
type: Object,
|
|
169
|
+
default: null
|
|
170
|
+
},
|
|
171
|
+
// 列表编码
|
|
172
|
+
listCode: {
|
|
173
|
+
type: String,
|
|
174
|
+
default: null
|
|
175
|
+
},
|
|
176
|
+
// 打开相机和相册选项,默认是都可以打开
|
|
177
|
+
openCameraOrChoosePhoto: {
|
|
178
|
+
type: String,
|
|
179
|
+
default: 'openCameraAndChoosePhoto'
|
|
180
|
+
},
|
|
181
|
+
beforeUpload: {
|
|
182
|
+
type: Function,
|
|
183
|
+
default: () => {}
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
const baseAPI = window.$vueApp.config.globalProperties.baseAPI
|
|
187
|
+
const deleteServerFileUrl = baseAPI + '/component/super-form/deleteFile'
|
|
188
|
+
const emits = defineEmits(['uploadend', 'remove', 'pickup-file', 'close'])
|
|
189
|
+
const { t } = useI18n()
|
|
190
|
+
|
|
191
|
+
const userAgent = ref(null)
|
|
192
|
+
const userAgentDetail = ref(null)
|
|
193
|
+
const rmFileServerPaths = ref([])
|
|
194
|
+
const fileUploadRef = ref(null)
|
|
195
|
+
|
|
196
|
+
const userAgentOrg = navigator.userAgent
|
|
197
|
+
userAgentDetail.value = userAgentOrg
|
|
198
|
+
if (userAgentOrg.indexOf(' uni-app ') > 0) {
|
|
199
|
+
// 表示uni-app中访问的
|
|
200
|
+
userAgent.value = 'app'
|
|
201
|
+
} else {
|
|
202
|
+
// 表示手机浏览器访问的
|
|
203
|
+
userAgent.value = 'browser'
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 点击确定(上传)按钮的回调方法
|
|
207
|
+
function uploadedFile(fileList) {
|
|
208
|
+
emits('uploadend', fileList)
|
|
209
|
+
}
|
|
210
|
+
function deleteServerFiles() {
|
|
211
|
+
return window.$vueApp.config.globalProperties.$http.post(deleteServerFileUrl, rmFileServerPaths.value)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function removeFile({ rmFiles, serverFiles, newFiles }) {
|
|
215
|
+
if (rmFiles && rmFiles.length > 0) {
|
|
216
|
+
rmFiles.forEach((item) => {
|
|
217
|
+
if (item.serverPath && rmFileServerPaths.value && rmFileServerPaths.value.indexOf(item.serverPath) < 0) {
|
|
218
|
+
rmFileServerPaths.value.push(item.serverPath)
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
if (rmFileServerPaths.value && rmFileServerPaths.value.length > 0) {
|
|
222
|
+
// 删除minio等服务器上的附件
|
|
223
|
+
deleteServerFiles().then(() => {
|
|
224
|
+
// 更新字段的值
|
|
225
|
+
ElMessage({
|
|
226
|
+
showClose: true,
|
|
227
|
+
message: t('fileUpload.updateSuccess'),
|
|
228
|
+
type: 'success'
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
emits('remove', { rmFiles, serverFiles, newFiles })
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// 移动端选择文件结束
|
|
236
|
+
function pickFileDone(data) {
|
|
237
|
+
if (userAgent.value === 'app') {
|
|
238
|
+
fileUploadRef.value.pickFileDone(data)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// 移动端上传文件结束
|
|
242
|
+
function uploadFileDone(data) {
|
|
243
|
+
if (userAgent.value === 'app') {
|
|
244
|
+
fileUploadRef.value.uploadFileDone(data)
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function clearTempFile() {
|
|
248
|
+
if (fileUploadRef.value) {
|
|
249
|
+
fileUploadRef.value.clearQueenFile()
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
defineExpose({pickFileDone,uploadFileDone})
|
|
253
|
+
</script>
|
|
254
|
+
|
|
255
|
+
<style lang="scss" scoped></style>
|
|
@@ -112,7 +112,7 @@ if (props.action) {
|
|
|
112
112
|
defaultAction.value = props.action
|
|
113
113
|
} else {
|
|
114
114
|
let tempAction = baseURL + '/common/fs-upload'
|
|
115
|
-
if (
|
|
115
|
+
if (isPlateSys(props.systemCode)) {
|
|
116
116
|
tempAction = baseAPI + '/component/super-form/uploads'
|
|
117
117
|
}
|
|
118
118
|
defaultAction.value = tempAction
|
|
@@ -122,7 +122,8 @@ if (!props.headers || !props.headers['Authorization']) {
|
|
|
122
122
|
props.headers.Authorization = getToken()
|
|
123
123
|
}
|
|
124
124
|
const handleBeforeUpload = (file: File) => {
|
|
125
|
-
|
|
125
|
+
const isMobile = false
|
|
126
|
+
return props.beforeUpload({fileObj: file, files:[file], isMobile, pageContext: props.pageContext, configureObj: props.configure})
|
|
126
127
|
}
|
|
127
128
|
const onSuccess = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
|
128
129
|
// eslint-disable-next-line vue/no-mutating-props
|
|
@@ -78,10 +78,6 @@ const props = defineProps({
|
|
|
78
78
|
type: Array<{ showName: string; serverPath: string }>,
|
|
79
79
|
default: () => []
|
|
80
80
|
},
|
|
81
|
-
handleBeforeUpload: {
|
|
82
|
-
type: Function,
|
|
83
|
-
default: () => {}
|
|
84
|
-
},
|
|
85
81
|
onSuccess: {
|
|
86
82
|
type: Function,
|
|
87
83
|
default: () => {}
|
|
@@ -119,7 +115,7 @@ if (props.action) {
|
|
|
119
115
|
defaultAction.value = props.action
|
|
120
116
|
} else {
|
|
121
117
|
let tempAction = baseURL + '/common/fs-upload'
|
|
122
|
-
if (
|
|
118
|
+
if (isPlateSys(props.systemCode)) {
|
|
123
119
|
tempAction = baseAPI + '/component/super-form/uploads'
|
|
124
120
|
}
|
|
125
121
|
defaultAction.value = tempAction
|
|
@@ -129,7 +125,7 @@ if (!props.headers || !props.headers['Authorization']) {
|
|
|
129
125
|
props.headers.Authorization = getToken()
|
|
130
126
|
}
|
|
131
127
|
const handleBeforeUpload = (file: File) => {
|
|
132
|
-
return props.
|
|
128
|
+
return props.beforeUpload(file)
|
|
133
129
|
}
|
|
134
130
|
const onSuccess = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
|
135
131
|
// eslint-disable-next-line vue/no-mutating-props
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
</el-tag>
|
|
21
21
|
</div>
|
|
22
22
|
</div>
|
|
23
|
-
<span v-else class="el-upload-list__item-actions">
|
|
23
|
+
<span v-else class="el-upload-list__item-actions mobile-item-action">
|
|
24
24
|
<span
|
|
25
|
-
v-if="isPreview(file.showName)"
|
|
25
|
+
v-if="isPreview(file.showName ? file.showName: file.name)"
|
|
26
26
|
class="el-upload-list__item-preview"
|
|
27
|
-
@click="preview(file.showName, file.serverPath)"
|
|
27
|
+
@click="preview(file.showName ? file.showName: file.name, file.serverPath)"
|
|
28
28
|
>
|
|
29
29
|
<el-icon><zoom-in /></el-icon>
|
|
30
30
|
</span>
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
<span
|
|
39
39
|
v-if="!disabled"
|
|
40
40
|
class="el-upload-list__item-delete"
|
|
41
|
-
@click="
|
|
41
|
+
@click="handleOnRemove(file)"
|
|
42
42
|
>
|
|
43
43
|
<el-icon><Delete /></el-icon>
|
|
44
44
|
</span>
|
|
@@ -48,7 +48,12 @@
|
|
|
48
48
|
</el-dialog>
|
|
49
49
|
</div>
|
|
50
50
|
</template>
|
|
51
|
-
|
|
51
|
+
<style scoped>
|
|
52
|
+
/* .el-upload-list--picture-card .el-upload-list__item-actions, */
|
|
53
|
+
.mobile-item-action {
|
|
54
|
+
z-index: 2000;
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
52
57
|
<script setup lang="ts">
|
|
53
58
|
import { Close, Paperclip, Download } from '@element-plus/icons-vue'
|
|
54
59
|
import { ref, defineProps } from 'vue'
|
|
@@ -104,6 +109,7 @@ const dialogVisible = ref<boolean>(false)
|
|
|
104
109
|
const previewImageInfo = ref<any>({})
|
|
105
110
|
const previewSrcList = ref<string[]>([])
|
|
106
111
|
const isMobile = ref(isMobileBrowser())
|
|
112
|
+
const emits = defineEmits(['remove'])
|
|
107
113
|
const handleDownload = (file: any) => {
|
|
108
114
|
if (isPromise(props.beforeDownload)) {
|
|
109
115
|
props.beforeDownload(props.pageContext, props.configure, file).then((res: any) => {
|
|
@@ -123,7 +129,8 @@ const handleDownload = (file: any) => {
|
|
|
123
129
|
}
|
|
124
130
|
const download = (file: any) => {
|
|
125
131
|
const token = getToken()
|
|
126
|
-
const
|
|
132
|
+
const fileName = file.showName ? file.showName: file.name
|
|
133
|
+
const showName = fileName.replace('#', '~~').replace('?', '~$').replace('&', '$')
|
|
127
134
|
let url =
|
|
128
135
|
baseURL +
|
|
129
136
|
'/common/super-form/downloads?showName=' +
|
|
@@ -145,10 +152,19 @@ const download = (file: any) => {
|
|
|
145
152
|
window.location.href = url
|
|
146
153
|
}
|
|
147
154
|
const handleOnRemove = (file: any) => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
let isCanRemove = true
|
|
156
|
+
if (props.beforeRemove && typeof props.beforeRemove === 'function') {
|
|
157
|
+
const isMobile = true
|
|
158
|
+
isCanRemove = props.beforeRemove(props.pageContext, props.configure, file, isMobile)
|
|
159
|
+
}
|
|
160
|
+
if (isCanRemove!==undefined && !isCanRemove) {
|
|
161
|
+
// 不能删除文件
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
const index = props.fileList.findIndex((item: any) => (item.serverPath === file.uuid || item.serverPath === file.serverPath))
|
|
165
|
+
console.log('handleOnRemove----props.fileList=', props.fileList, 'index=', index)
|
|
166
|
+
props.fileList.splice(index, 1)
|
|
167
|
+
emits('remove', {file, index: index})
|
|
152
168
|
props.onRemove(file)
|
|
153
169
|
}
|
|
154
170
|
|
|
@@ -156,7 +172,7 @@ const isPromise = (p: any) => {
|
|
|
156
172
|
return p && Object.prototype.toString.call(p) === '[object Promise]'
|
|
157
173
|
}
|
|
158
174
|
const preview = (showName: string, serverPath: string) => {
|
|
159
|
-
console.log('preview')
|
|
175
|
+
console.log('preview----props.fileList=', props.fileList)
|
|
160
176
|
|
|
161
177
|
let isImg = false
|
|
162
178
|
if (showName && isImage(showName)) {
|
|
@@ -166,7 +182,8 @@ const preview = (showName: string, serverPath: string) => {
|
|
|
166
182
|
previewImageInfo.value.src = getPreviewSrc(showName, serverPath)
|
|
167
183
|
const srcList: string[] = []
|
|
168
184
|
props.fileList.forEach((item: any) => {
|
|
169
|
-
|
|
185
|
+
const fileName = item.showName ? item.showName: item.name
|
|
186
|
+
srcList.push(getPreviewSrc(fileName, item.serverPath))
|
|
170
187
|
})
|
|
171
188
|
previewSrcList.value = srcList
|
|
172
189
|
dialogVisible.value = true
|
|
@@ -221,7 +238,7 @@ function getPreviewSrc(showName: string, serverPath: string) {
|
|
|
221
238
|
showName = formatName(showName)
|
|
222
239
|
const token = getToken()
|
|
223
240
|
let url = baseURL + '/common/super-form/downloads?jwt=' + token
|
|
224
|
-
if (
|
|
241
|
+
if (isPlateSys(props.systemCode)) {
|
|
225
242
|
url = baseAPI + '/component/super-form/downloads?jwt=' + token
|
|
226
243
|
}
|
|
227
244
|
url = getReplaceUrlDomain(url)
|