ci-plus 1.7.7 → 1.7.9
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 +4 -0
- package/package.json +1 -1
- package/src/fileRelated/uploadV3.vue +42 -19
- package/src/utils/lang/en.js +12 -0
- package/src/utils/lang/zh.js +13 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
v-model:file-list="fileList"
|
|
22
22
|
>
|
|
23
23
|
<template #trigger>
|
|
24
|
-
<el-button size="small" type="primary" style="width: 100%" plain>
|
|
24
|
+
<el-button size="small" type="primary" style="width: 100%" plain> {{ t('fileRelated.selectFile')}} </el-button>
|
|
25
25
|
</template>
|
|
26
26
|
<el-button
|
|
27
27
|
size="small"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
style="float: left; margin: 0 12px 0 0; width: 95px"
|
|
30
30
|
v-if="url"
|
|
31
31
|
>
|
|
32
|
-
|
|
32
|
+
{{t('fileRelated.downloadTemplate')}}
|
|
33
33
|
</el-button>
|
|
34
34
|
</el-upload>
|
|
35
35
|
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
v-model="affiliationAll"
|
|
40
40
|
filterable
|
|
41
41
|
:options="affiliationOptions"
|
|
42
|
-
placeholder="
|
|
42
|
+
:placeholder="t('fileRelated.selectCompany')"
|
|
43
43
|
style="width: 180px; margin-right: 5px"
|
|
44
44
|
clearable
|
|
45
45
|
@change="changeAll"
|
|
46
46
|
/>
|
|
47
47
|
<el-button size="small" type="primary" @click="submitUpload" style="flex: 2">
|
|
48
|
-
|
|
48
|
+
{{t('fileRelated.upload')}}
|
|
49
49
|
</el-button>
|
|
50
50
|
</div>
|
|
51
51
|
<template #reference>
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
@click="visible = !visible"
|
|
55
55
|
:size="props.otherConfig?.size || 'small'"
|
|
56
56
|
>
|
|
57
|
-
{{ props.title || '
|
|
57
|
+
{{ props.title || t('fileRelated.attachmentUpload') }}
|
|
58
58
|
</el-button>
|
|
59
59
|
</template>
|
|
60
60
|
</el-popover>
|
|
61
61
|
</template>
|
|
62
62
|
|
|
63
63
|
<script setup lang="ts">
|
|
64
|
-
defineOptions({ name: 'ci-
|
|
64
|
+
defineOptions({ name: 'ci-uploadV3' })
|
|
65
65
|
// 定义一个函数,用于处理字符串
|
|
66
66
|
const setFilePath = (arr: string[], url?: string) => {
|
|
67
67
|
// console.log('重新渲染数据', arr);
|
|
@@ -99,9 +99,9 @@ const fileArr = (url: string, pathArr: string[]) => {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
import {
|
|
104
|
-
import
|
|
102
|
+
import t from '../utils/lang/index'
|
|
103
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
104
|
+
import axios from 'axios'
|
|
105
105
|
import type {
|
|
106
106
|
UploadFile,
|
|
107
107
|
UploadFiles,
|
|
@@ -109,8 +109,17 @@ import type {
|
|
|
109
109
|
UploadProps,
|
|
110
110
|
UploadUserFile
|
|
111
111
|
} from 'element-plus'
|
|
112
|
-
import
|
|
113
|
-
|
|
112
|
+
import {
|
|
113
|
+
ElButton,
|
|
114
|
+
ElLoading,
|
|
115
|
+
ElMessage,
|
|
116
|
+
ElPopover,
|
|
117
|
+
ElSelectV2,
|
|
118
|
+
ElUpload,
|
|
119
|
+
genFileId,
|
|
120
|
+
UploadRawFile
|
|
121
|
+
} from 'element-plus'
|
|
122
|
+
import { onMounted, ref } from 'vue'
|
|
114
123
|
import ajaxBox from '../utils/ajaxBox'
|
|
115
124
|
import getAffiliationOptions from '../utils/getAffiliationOptions.ts'
|
|
116
125
|
const upload = ref<UploadInstance>()
|
|
@@ -154,7 +163,7 @@ const emits = defineEmits<{
|
|
|
154
163
|
console.log('附件props: ', props)
|
|
155
164
|
const datas: any = ref(props.data)
|
|
156
165
|
const mymultiple = ref<boolean>(props.multiple)
|
|
157
|
-
const mylimit = ref<number>(props.limit as number)
|
|
166
|
+
const mylimit = ref<number>((props.limit as number) || 1)
|
|
158
167
|
const myfilePath = ref<any>(props.filePath || [])
|
|
159
168
|
console.log('myfilePath: ', props.filePath)
|
|
160
169
|
|
|
@@ -174,8 +183,18 @@ console.log('fileList: ', fileList.value)
|
|
|
174
183
|
|
|
175
184
|
//当超出限制时,执行的钩子函数
|
|
176
185
|
const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
177
|
-
console.log('
|
|
178
|
-
|
|
186
|
+
console.log('%c Line:177 🥝 files', 'color:#e41a6a', files)
|
|
187
|
+
|
|
188
|
+
if (mylimit?.value === 1) {
|
|
189
|
+
upload.value!.clearFiles()
|
|
190
|
+
const file = files[0] as UploadRawFile
|
|
191
|
+
file.uid = genFileId()
|
|
192
|
+
upload.value!.handleStart(file)
|
|
193
|
+
}
|
|
194
|
+
if (mylimit?.value > 1) {
|
|
195
|
+
console.log('超出限制: ', files)
|
|
196
|
+
ElMessage.warning(`${t('fileRelated.exceedFiles')} ${mylimit?.value} ${t('fileRelated.reselect')}`)
|
|
197
|
+
}
|
|
179
198
|
}
|
|
180
199
|
|
|
181
200
|
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
|
|
@@ -198,8 +217,8 @@ const handleRemove: UploadProps['onRemove'] = (file, fileList) => {
|
|
|
198
217
|
//上传文件
|
|
199
218
|
const submitUpload = () => {
|
|
200
219
|
console.log(fileList.value.length)
|
|
201
|
-
if (!fileList.value.length) return ElMessage.warning('
|
|
202
|
-
exporLoading.value = ElLoading.service({ text: '
|
|
220
|
+
if (!fileList.value.length) return ElMessage.warning(t('fileRelated.pleaseFile'))
|
|
221
|
+
exporLoading.value = ElLoading.service({ text: t('fileRelated.importing') })
|
|
203
222
|
console.log('upload.value', upload.value)
|
|
204
223
|
upload.value!.submit()
|
|
205
224
|
visible.value = false
|
|
@@ -249,7 +268,7 @@ const onSuccess = async (res: any, file: any, fileList: any) => {
|
|
|
249
268
|
//文件上传失败回调
|
|
250
269
|
const onError = (response: any, file: any, fileList: any) => {
|
|
251
270
|
console.log('上传失败回调: ', response)
|
|
252
|
-
ElMessage.error(file.name + '
|
|
271
|
+
ElMessage.error(file.name + t('fileRelated.uploadFailed'))
|
|
253
272
|
// fileList.value.length = 0 // 清空文件列表
|
|
254
273
|
upload.value!.clearFiles() // 清空文件列表
|
|
255
274
|
visible.value = false // 关闭上传面板
|
|
@@ -297,13 +316,17 @@ const formwork = () => {
|
|
|
297
316
|
const params = props.parameter
|
|
298
317
|
ajaxBox.downFileFetchV2(url, params, {
|
|
299
318
|
method: 'GET',
|
|
300
|
-
fileName: props.templateName || '
|
|
319
|
+
fileName: props.templateName || t('fileRelated.template')
|
|
301
320
|
})
|
|
302
321
|
}
|
|
303
322
|
|
|
304
323
|
//选择框
|
|
305
324
|
onMounted(async () => {
|
|
306
|
-
|
|
325
|
+
if (props.url) {
|
|
326
|
+
affiliationOptions.value = await getAffiliationOptions()
|
|
327
|
+
} else {
|
|
328
|
+
affiliationOptions.value = []
|
|
329
|
+
}
|
|
307
330
|
})
|
|
308
331
|
|
|
309
332
|
// const getAffiliationOptions = async (
|
package/src/utils/lang/en.js
CHANGED
|
@@ -21,6 +21,18 @@ const en = {
|
|
|
21
21
|
last3Month: 'Last 3 Month' // 最近3个月
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
+
fileRelated:{
|
|
25
|
+
selectFile:'SELECT FILE',
|
|
26
|
+
downloadTemplate:'Download Template',
|
|
27
|
+
selectCompany:'Choose a company to belong to',
|
|
28
|
+
upload:'Upload',
|
|
29
|
+
attachmentUpload:'Attachment upload',
|
|
30
|
+
exceedFiles:'Exceeded the maximum file count of ',
|
|
31
|
+
reselect:' files, please select again',
|
|
32
|
+
pleaseFile:'Please select the file before uploading!',
|
|
33
|
+
importing:'Importing in progress ···',
|
|
34
|
+
uploadFailed:'Upload failed',
|
|
35
|
+
},
|
|
24
36
|
public: {
|
|
25
37
|
placeholders: 'Please choose', // 请选择
|
|
26
38
|
placeholderi: 'Please fill in', // 请填写
|
package/src/utils/lang/zh.js
CHANGED
|
@@ -21,6 +21,19 @@ const zh = {
|
|
|
21
21
|
last3Month: '最近3个月'
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
+
fileRelated:{
|
|
25
|
+
selectFile:'选择文件',
|
|
26
|
+
downloadTemplate:'下载模板',
|
|
27
|
+
selectCompany:'选择归属公司',
|
|
28
|
+
upload:'上传',
|
|
29
|
+
attachmentUpload:'附件上传',
|
|
30
|
+
exceedFiles:'超出最大文件数 ',
|
|
31
|
+
reselect:' 个文件,请重新选择',
|
|
32
|
+
pleaseFile:'请选择文件后在上传!',
|
|
33
|
+
importing:'导入中···',
|
|
34
|
+
uploadFailed:'上传失败',
|
|
35
|
+
template:'模板.xlsx'
|
|
36
|
+
},
|
|
24
37
|
public: {
|
|
25
38
|
placeholders: '请选择',
|
|
26
39
|
placeholderi: '请填写',
|