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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agilebuilder-ui",
3
- "version": "1.0.71tmp7",
3
+ "version": "1.0.72",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./lib/super-ui.js",
@@ -12,6 +12,7 @@
12
12
  "@tinymce/tinymce-vue": "4.0.4",
13
13
  "@zxing/library": "^0.20.0",
14
14
  "async-validator": "^4.2.5",
15
+ "compressorjs": "1.2.1",
15
16
  "font-awesome": "^4.7.0",
16
17
  "js-base64": "^3.7.7",
17
18
  "js-cookie": "^3.0.5",
@@ -19,8 +20,7 @@
19
20
  "path-to-regexp": "6.2.1",
20
21
  "sortablejs": "^1.15.0",
21
22
  "tinymce": "5.8.2",
22
- "uuid": "^9.0.1",
23
- "vue-plugin-load-script": "^1.3.2"
23
+ "uuid": "^9.0.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@element-plus/icons-vue": "^2.1.0",
@@ -34,7 +34,6 @@
34
34
  "vue": "3.3.4",
35
35
  "vue-i18n": "^9.5.0",
36
36
  "vue-router": "^4.2.5",
37
- "vuex": "^4.1.0",
38
- "axios": "^1.5.1"
37
+ "vuex": "^4.1.0"
39
38
  }
40
39
  }
@@ -0,0 +1,249 @@
1
+ <template>
2
+ <div>
3
+ <FileUploadComponent
4
+ ref="fileUploadRef"
5
+ :disabled="disabled"
6
+ :systemCode="systemCode"
7
+ :accept="accept"
8
+ :multiple="multiple"
9
+ :limitFileSize="limitFileSize"
10
+ :fileList="fileListResult"
11
+ :beforeRemove="beforeRemove"
12
+ :onRemove="onRemove"
13
+ :beforeDownload="beforeDownload"
14
+ :baseURL="baseURLVal"
15
+ @chooseFile="pickBrowserFiles"
16
+ @remove="removeFile"
17
+ />
18
+ </div>
19
+ </template>
20
+ <script lang="ts" setup>
21
+ import { ref, defineEmits } from 'vue'
22
+ import { getToken, getCookieCache } from '../../../../src/utils/auth.js' // 获得token
23
+ import Compressor from 'compressorjs'
24
+ import { ElMessage } from 'element-plus'
25
+ import { useI18n } from 'vue-i18n'
26
+ import FileUploadComponent from './file-upload-component.vue'
27
+ const props = defineProps({
28
+ openFsUpload: {
29
+ type: Object,
30
+ default: true
31
+ },
32
+ entity: {
33
+ type: Object,
34
+ default: () => {
35
+ return null
36
+ }
37
+ },
38
+ fileInfo: {
39
+ type: Object,
40
+ default: () => ({})
41
+ },
42
+ systemCode: {
43
+ type: String,
44
+ default: ''
45
+ },
46
+ displayType: {
47
+ type: String,
48
+ default: 'input'
49
+ },
50
+ // 是否禁止编辑,为true只能下载,不能删除和上传
51
+ disabled: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ accept: {
56
+ type: String,
57
+ default: ''
58
+ },
59
+ multiple: {
60
+ type: Boolean,
61
+ default: false
62
+ },
63
+ limit: {
64
+ type: Number,
65
+ default: 1
66
+ },
67
+ // 文件大小限制,单位是M,默认是30M
68
+ limitFileSize: {
69
+ type: Number,
70
+ default: 30
71
+ },
72
+ placeholder: {
73
+ type: String,
74
+ default: '拖拽文件 或 点击上传'
75
+ },
76
+ action: {
77
+ type: String,
78
+ default: ''
79
+ },
80
+ headers: {
81
+ type: Object,
82
+ default: () => ({ Authorization: null })
83
+ },
84
+ // 已上传文件列表
85
+ fileList: {
86
+ type: Array,
87
+ default: () => []
88
+ },
89
+ onSuccess: {
90
+ type: Function,
91
+ default: () => {}
92
+ },
93
+ beforeRemove: {
94
+ type: Function,
95
+ default: () => {}
96
+ },
97
+ onRemove: {
98
+ type: Function,
99
+ default: () => {}
100
+ },
101
+ beforeDownload: {
102
+ type: Function,
103
+ default: () => {}
104
+ },
105
+ pageContext: {
106
+ type: Object,
107
+ default: () => ({})
108
+ },
109
+ configure: {
110
+ type: Object,
111
+ default: () => ({})
112
+ },
113
+ // 组件id,在表单或列表中应该唯一,一般传字段名即可
114
+ componentId: {
115
+ type: String,
116
+ default: function () {
117
+ return 'file-upload'
118
+ }
119
+ },
120
+ // 组件名称,一般是字段label
121
+ componentName: {
122
+ type: String,
123
+ default: function () {
124
+ return 'file-upload'
125
+ }
126
+ },
127
+ options: {
128
+ type: Object,
129
+ default: null
130
+ },
131
+ // 列表编码
132
+ listCode: {
133
+ type: String,
134
+ default: null
135
+ },
136
+ // 打开相机和相册选项,默认是都可以打开
137
+ openCameraOrChoosePhoto: {
138
+ type: String,
139
+ default: 'openCameraAndChoosePhoto'
140
+ },
141
+ beforeUpload: {
142
+ type: Function,
143
+ default: () => {}
144
+ }
145
+ })
146
+
147
+ const fileListResult = ref(props.fileList)
148
+ let baseURL = window.$vueApp.config.globalProperties.baseURL
149
+ if (props.options) {
150
+ baseURL = props.options.backendUrl
151
+ }
152
+ if (!baseURL) {
153
+ baseURL = window.$vueApp.config.globalProperties.baseURL
154
+ }
155
+ const baseURLVal = ref(baseURL)
156
+
157
+ const baseAPI = window.$vueApp.config.globalProperties.baseAPI
158
+ const fileUploadRef = ref(null)
159
+ const emits = defineEmits(['remove', 'uploadend'])
160
+
161
+ // 表示点击了选择文件按钮
162
+ function pickBrowserFiles() {
163
+ // console.log('---点击了选择文件按钮---')
164
+ const message = {
165
+ type: 'pickFiles',
166
+ multiple: props.multiple,
167
+ componentId: props.componentId,
168
+ componentName: props.componentName,
169
+ systemCode: props.systemCode,
170
+ token: getToken(),
171
+ listCode: props.listCode
172
+ }
173
+ window.parent.postMessage(JSON.stringify(message), '*')
174
+ }
175
+
176
+ function pickFileDone(data) {
177
+ appFileDone(data)
178
+ }
179
+ function uploadFileDone(data) {
180
+ // 表示文件上传到服务器成功
181
+ appFileDone(data)
182
+ }
183
+ function appFileDone(data) {
184
+ const files = data.files
185
+ let myFiles = files
186
+ if (files && typeof files === 'string') {
187
+ myFiles = JSON.parse(files)
188
+ }
189
+ if (myFiles && !Array.isArray(myFiles)) {
190
+ myFiles = [myFiles]
191
+ }
192
+ uploadFileSuccess(myFiles)
193
+ }
194
+ function uploadFileSuccess(files) {
195
+ // this.isUploading = true
196
+ let isCanUpload = true
197
+ if (props.beforeUpload && typeof props.beforeUpload === 'function') {
198
+ for (let i = 0; i < files.length; i++) {
199
+ const file = files[i]
200
+ const isMobile = true
201
+ // eslint-disable-next-line no-useless-call
202
+ isCanUpload = props.beforeUpload({
203
+ fileObj: file,
204
+ files: files,
205
+ isMobile,
206
+ pageContext: props.pageContext,
207
+ configureObj: props.configure
208
+ })
209
+ if (isCanUpload !== undefined && isCanUpload === false) {
210
+ break
211
+ }
212
+ }
213
+ }
214
+ if (isCanUpload !== undefined && !isCanUpload) {
215
+ // 不能提交文件
216
+ return
217
+ }
218
+ // this.isUploading = false
219
+ // 表示文件上传到服务器成功
220
+ if (files) {
221
+ // files:[{name:'',serverPath:''},{name:'',serverPath:''}]
222
+ if (props.multiple) {
223
+ files.forEach((file) => {
224
+ fileListResult.value.push(file)
225
+ })
226
+ } else {
227
+ // 单选时将已选文件移除,然后再替换为新上传的文件
228
+ const rmFiles = JSON.parse(JSON.stringify(fileListResult.value))
229
+ fileListResult.value = files
230
+ emits('remove', { rmFiles, serverFiles: fileListResult.value })
231
+ }
232
+ }
233
+ console.log('uploadFileSuccess111111----fileListResult.value=', JSON.stringify(fileListResult.value))
234
+
235
+ fileUploadRef.value.changeFileList(fileListResult.value)
236
+ // this.isUploading = false
237
+ emits('uploadend', fileListResult.value)
238
+ }
239
+
240
+ function removeFile(param) {
241
+ console.log('removeFile----param=', param)
242
+ const file = param.file
243
+ if (file) {
244
+ emits('remove', { rmFiles: [file], serverFiles: fileListResult.value, index: param.index })
245
+ }
246
+ }
247
+ </script>
248
+
249
+ <style lang="scss" scoped></style>