ci-plus 1.9.3 → 1.9.5
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
CHANGED
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
<!-- /**
|
|
2
|
+
* @module uploadV6
|
|
3
|
+
* @author : 卖女孩的小火柴
|
|
4
|
+
* !description : 在v5基础上调整优化
|
|
5
|
+
* @version : 1.0.0
|
|
6
|
+
* @since : 创建时间 2026-01-07 10:00:00
|
|
7
|
+
*/ -->
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<el-popover
|
|
11
|
+
placement="bottom"
|
|
12
|
+
:width="300"
|
|
13
|
+
:trigger="props.otherConfig?.trigger || 'hover'"
|
|
14
|
+
:visible="visible"
|
|
15
|
+
>
|
|
16
|
+
<slot name="top">
|
|
17
|
+
<el-button
|
|
18
|
+
:size="props.otherConfig?.size || 'small'"
|
|
19
|
+
@click="formwork"
|
|
20
|
+
style="width: 100%"
|
|
21
|
+
v-if="url"
|
|
22
|
+
>
|
|
23
|
+
<!-- {{ t('fileRelated.downloadTemplate') }} -->
|
|
24
|
+
下载模板
|
|
25
|
+
</el-button>
|
|
26
|
+
</slot>
|
|
27
|
+
<el-upload
|
|
28
|
+
ref="upload"
|
|
29
|
+
class="upload-demo"
|
|
30
|
+
:action="uploadUrl"
|
|
31
|
+
:limit="mylimit || 1"
|
|
32
|
+
:on-exceed="handleExceed"
|
|
33
|
+
:auto-upload="false"
|
|
34
|
+
:on-success="onSuccess"
|
|
35
|
+
:on-error="onError"
|
|
36
|
+
:on-change="handleChange"
|
|
37
|
+
:on-remove="handleRemove"
|
|
38
|
+
:data="datas"
|
|
39
|
+
:multiple="mymultiple || false"
|
|
40
|
+
v-model:file-list="fileList"
|
|
41
|
+
:size="props.otherConfig?.size || 'small'"
|
|
42
|
+
>
|
|
43
|
+
<template #trigger>
|
|
44
|
+
<div class="my-trigger">
|
|
45
|
+
<slot name="trigger">
|
|
46
|
+
<slot name="selectFile">
|
|
47
|
+
<el-button
|
|
48
|
+
:size="props.otherConfig?.size || 'small'"
|
|
49
|
+
type="primary"
|
|
50
|
+
style="width: 100%"
|
|
51
|
+
plain
|
|
52
|
+
>
|
|
53
|
+
<!-- {{ t('fileRelated.selectFile') }} -->
|
|
54
|
+
选择文件
|
|
55
|
+
</el-button>
|
|
56
|
+
</slot>
|
|
57
|
+
</slot>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
</el-upload>
|
|
61
|
+
|
|
62
|
+
<slot name="center">
|
|
63
|
+
<div class="slot" style="display: flex; flex-direction: column; align-items: flex-end">
|
|
64
|
+
<div style="width: 100%; margin: 4px 2px; display: flex" v-if="ifShowAffiliation">
|
|
65
|
+
<span style="line-height: 30px; color: red; margin-right: 4px" v-if="requiredAffiliation">
|
|
66
|
+
*
|
|
67
|
+
</span>
|
|
68
|
+
<el-select-v2
|
|
69
|
+
:size="props.otherConfig?.size || 'small'"
|
|
70
|
+
v-model="affiliationAll"
|
|
71
|
+
filterable
|
|
72
|
+
:options="affiliationOptions"
|
|
73
|
+
style="width: 100%; margin-right: 5px"
|
|
74
|
+
clearable
|
|
75
|
+
@change="changeAll"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
<div style="width: 100%; margin: 4px 2px; display: flex" v-if="ifShowWarehouse">
|
|
79
|
+
<span style="line-height: 30px; color: red; margin-right: 4px" v-if="requiredWarehouse">
|
|
80
|
+
*
|
|
81
|
+
</span>
|
|
82
|
+
<el-select-v2
|
|
83
|
+
:size="props.otherConfig?.size || 'small'"
|
|
84
|
+
v-model="warehouseAll"
|
|
85
|
+
filterable
|
|
86
|
+
:options="warehouseOptions"
|
|
87
|
+
style="width: 100%; margin-right: 5px"
|
|
88
|
+
clearable
|
|
89
|
+
@change="changeWarehouseAll"
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
<!-- 添加一个插槽 -->
|
|
93
|
+
<slot></slot>
|
|
94
|
+
<div>
|
|
95
|
+
<el-button
|
|
96
|
+
:size="props.otherConfig?.size || 'small'"
|
|
97
|
+
type="primary"
|
|
98
|
+
@click="submitUpload"
|
|
99
|
+
style="flex: 2"
|
|
100
|
+
>
|
|
101
|
+
<!-- {{ t('fileRelated.upload') }} -->
|
|
102
|
+
上传
|
|
103
|
+
</el-button>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</slot>
|
|
107
|
+
|
|
108
|
+
<template #reference>
|
|
109
|
+
<el-button
|
|
110
|
+
:type="exporLoading ? 'danger' : 'success'"
|
|
111
|
+
@click="visible = !visible"
|
|
112
|
+
:size="props.otherConfig?.size || 'small'"
|
|
113
|
+
:loading="exporLoading"
|
|
114
|
+
>
|
|
115
|
+
<!-- {{ props.title || t('fileRelated.attachmentUpload') }} -->
|
|
116
|
+
{{ props.title || '附件上传' }}
|
|
117
|
+
</el-button>
|
|
118
|
+
</template>
|
|
119
|
+
</el-popover>
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<script setup lang="ts">
|
|
123
|
+
defineOptions({ name: 'ci-uploadV6' })
|
|
124
|
+
|
|
125
|
+
// 定义一个函数,用于处理字符串
|
|
126
|
+
|
|
127
|
+
const setFilePath = (arr: string[], url?: string) => {
|
|
128
|
+
// console.log('重新渲染数据', arr);
|
|
129
|
+
if (arr && arr.length > 0) {
|
|
130
|
+
let newArr: { name: string; oldName: string }[] = []
|
|
131
|
+
arr.forEach((item, i) => {
|
|
132
|
+
let segments = item.split('.')
|
|
133
|
+
let parts = segments[0].split('/') // 获取每名称
|
|
134
|
+
let name = parts[parts.length - 1] + '.' + segments[segments.length - 1]
|
|
135
|
+
let oldName = url ? url + item : item //原来的名称
|
|
136
|
+
// let url = segments[0] + '.' + segments[segments.length - 1]
|
|
137
|
+
newArr.push({ name, oldName })
|
|
138
|
+
})
|
|
139
|
+
return newArr
|
|
140
|
+
} else {
|
|
141
|
+
return [] // 如果数组为空,则返回空数组
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 将路径处理成附件的参数
|
|
146
|
+
const fileArr = (url: string, pathArr: string[]) => {
|
|
147
|
+
if (pathArr && pathArr.length > 0) {
|
|
148
|
+
let objArr: any = []
|
|
149
|
+
if (pathArr.length > 0) {
|
|
150
|
+
pathArr.map((item: any) => {
|
|
151
|
+
objArr.push({
|
|
152
|
+
name: item.name,
|
|
153
|
+
oldName: item.oldName,
|
|
154
|
+
url: url + item.oldName
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
return objArr
|
|
158
|
+
} else {
|
|
159
|
+
return []
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
import t from '../utils/lang/index'
|
|
164
|
+
import ajaxBox from '../utils/ajaxBox'
|
|
165
|
+
import { getAffiliationOptions, getWarehouseList, axios } from '../utils/getAffiliationOptions.ts'
|
|
166
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
167
|
+
import { computed, onMounted, ref } from 'vue'
|
|
168
|
+
// import t from '@/views/MaterialWarehouse/lang'
|
|
169
|
+
// import ajaxBox from '@/views/MaterialWarehouse/utils/ajaxBox'
|
|
170
|
+
// import { getAffiliationOptions, getWarehouseList, axios } from '@/views/MaterialWarehouse/utils/getAffiliationOptions.ts'
|
|
171
|
+
|
|
172
|
+
import type {
|
|
173
|
+
UploadFile,
|
|
174
|
+
UploadFiles,
|
|
175
|
+
UploadInstance,
|
|
176
|
+
UploadProps,
|
|
177
|
+
UploadUserFile
|
|
178
|
+
} from 'element-plus'
|
|
179
|
+
import {
|
|
180
|
+
ElButton,
|
|
181
|
+
ElLoading,
|
|
182
|
+
ElMessage,
|
|
183
|
+
ElPopover,
|
|
184
|
+
ElSelectV2,
|
|
185
|
+
ElUpload,
|
|
186
|
+
genFileId,
|
|
187
|
+
UploadRawFile
|
|
188
|
+
} from 'element-plus'
|
|
189
|
+
|
|
190
|
+
const upload = ref<UploadInstance>()
|
|
191
|
+
const exporLoading = ref(false)
|
|
192
|
+
const visible = ref(false)
|
|
193
|
+
const affiliationAll = ref() // 选择的归属公司
|
|
194
|
+
const warehouseAll = ref() // 选择的仓库
|
|
195
|
+
const affiliationOptions = ref<any[]>([]) // 获取归属公司列表数据
|
|
196
|
+
const warehouseOptions = ref<any[]>([]) // 获取仓库列表数据
|
|
197
|
+
|
|
198
|
+
interface Props {
|
|
199
|
+
url?: string // 上传和下载模板的接口(当需要将附件传递回父组件时不需要传递此属性)
|
|
200
|
+
uploadUrl?: string // 上传附件的接口
|
|
201
|
+
parameter?: Object // 模板下载的时候请求需要携带的参数:{state: 1}
|
|
202
|
+
data?: any //上传携带的其他数据对象:{userId: 1, userName: '张三'}
|
|
203
|
+
title?: string // 上传按钮的名称
|
|
204
|
+
multiple?: boolean // 是否支持多文件
|
|
205
|
+
limit?: number // 最大文件数量
|
|
206
|
+
ifShowAffiliation?: boolean // 是否显示归属公司
|
|
207
|
+
requiredAffiliation?: boolean // 是否必选归属公司
|
|
208
|
+
ifShowWarehouse?: boolean // 是否显示仓库
|
|
209
|
+
requiredWarehouse?: boolean // 是否必选仓库
|
|
210
|
+
ifDefaultAffiliation?: boolean // 是否默认选中归属工厂
|
|
211
|
+
defaultAffiliationOrgid?: string // 默认选中归属工厂的 orgid(当前登陆账号的单位)
|
|
212
|
+
filePath?: UploadFile[] //UploadRawFile[] // 父组件传递的附件数据,用于显示附件列表和上传附件后传递给父组件附件数据
|
|
213
|
+
RowIndex?: number // 父组件传递的行索引,用于父组件中删除了附件找到对应的行(用于表格表单中上传附件)
|
|
214
|
+
templateName?: string //模板名称
|
|
215
|
+
timeOn?: boolean // 是否开启耗时任务 默认不开启
|
|
216
|
+
// 其他的一些配置:请求的baseurl地址,有耗时任务的时候耗时任务的配置,模板下载的一些配置等
|
|
217
|
+
otherConfig: {
|
|
218
|
+
size?: 'large' | 'default' | 'small' // 按钮大小
|
|
219
|
+
trigger?: 'click' | 'focus' | 'hover' | 'contextmenu' // 按钮触发方式 默认 hover
|
|
220
|
+
baseUrl?: string // 上请求的baseurl地址
|
|
221
|
+
datakey: string // 耗时请求的参数key值
|
|
222
|
+
// 耗时任务的配置
|
|
223
|
+
timeConfig: {
|
|
224
|
+
url: string // 查询耗时任务地址
|
|
225
|
+
method: 'put' | 'post' | 'get' | 'PUT' | 'POST' | 'GET'
|
|
226
|
+
data?: object // 可选属性
|
|
227
|
+
params?: object // 可选属性
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const props = defineProps<Props>()
|
|
232
|
+
|
|
233
|
+
// 默认值:是否显示归属公司
|
|
234
|
+
const ifShowAffiliation = computed(() => {
|
|
235
|
+
return props.ifShowAffiliation
|
|
236
|
+
})
|
|
237
|
+
// 默认值:是否显示仓库
|
|
238
|
+
const ifShowWarehouse = computed(() => {
|
|
239
|
+
return props.ifShowWarehouse || false
|
|
240
|
+
})
|
|
241
|
+
// 默认值:是否必选归属公司
|
|
242
|
+
const requiredAffiliation = computed(() => {
|
|
243
|
+
return props.requiredAffiliation || false
|
|
244
|
+
})
|
|
245
|
+
// 默认值:是否必选仓库
|
|
246
|
+
const requiredWarehouse = computed(() => {
|
|
247
|
+
return props.requiredWarehouse || false
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
// 是否默认选中归属工厂(默认值true)
|
|
251
|
+
const ifDefaultAffiliation = computed(() => {
|
|
252
|
+
return props.ifDefaultAffiliation || true
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
// 获取本地缓存中当前登陆账号的公司
|
|
256
|
+
const raw = localStorage.getItem('UserData')
|
|
257
|
+
const UserData = raw ? JSON.parse(raw) : {}
|
|
258
|
+
const defaultAffiliationOrgid = computed(() => {
|
|
259
|
+
return props.defaultAffiliationOrgid || UserData?.resOrgId
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
const emits = defineEmits<{
|
|
263
|
+
(e: 'reloadTable', res: any): void // 组件中上传附件后刷新父组件表格数据方法
|
|
264
|
+
(e: 'getFile', files: UploadFiles, file?: UploadFile, rowindex?: number): void // 编辑表单的时候回显附件用到
|
|
265
|
+
(e: 'update:file', files: UploadFiles): void // 编辑表单的时候回显附件用到
|
|
266
|
+
// 失败回调
|
|
267
|
+
(e: 'errorCb', err: any): void
|
|
268
|
+
}>()
|
|
269
|
+
console.log('附件props: ', props)
|
|
270
|
+
const datas: any = ref(props.data)
|
|
271
|
+
const mymultiple = ref<boolean>(props.multiple)
|
|
272
|
+
const mylimit = ref<number>((props.limit as number) || 1)
|
|
273
|
+
const myfilePath = ref<any>(props.filePath || [])
|
|
274
|
+
console.log('myfilePath: ', props.filePath)
|
|
275
|
+
|
|
276
|
+
const changeAll = (val: string) => {
|
|
277
|
+
datas.value.factory_affiliation_id = val
|
|
278
|
+
datas.value.factory_affiliation_name = affiliationOptions.value.find(
|
|
279
|
+
(item: any) => item.value === val
|
|
280
|
+
)?.label
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const changeWarehouseAll = (val: string) => {
|
|
284
|
+
datas.value.warehouse_id = val
|
|
285
|
+
datas.value.warehouse_name = warehouseOptions.value.find((item: any) => item.value === val)?.label
|
|
286
|
+
|
|
287
|
+
console.log('%c Line:236 🍐 datas.value', 'color:#ea7e5c', datas.value)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// 对数组中的每个字符串应用处理函数
|
|
291
|
+
let pathArr = setFilePath(myfilePath.value)
|
|
292
|
+
|
|
293
|
+
// 打印处理后的数组
|
|
294
|
+
// 将父组件中传递过来的名称,处理成el-upload需要的格式
|
|
295
|
+
let pathUrlArr = fileArr(import.meta.env.VITE_BASE_URL9999, pathArr)
|
|
296
|
+
console.log('fileObj(): ', pathUrlArr)
|
|
297
|
+
const fileList = ref<UploadUserFile[]>(pathUrlArr)
|
|
298
|
+
console.log('fileList: ', fileList.value)
|
|
299
|
+
|
|
300
|
+
//当超出限制时,执行的钩子函数
|
|
301
|
+
const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
302
|
+
console.log('%c Line:177 🥝 files', 'color:#e41a6a', files)
|
|
303
|
+
|
|
304
|
+
if (mylimit?.value === 1) {
|
|
305
|
+
upload.value!.clearFiles()
|
|
306
|
+
const file = files[0] as UploadRawFile
|
|
307
|
+
file.uid = genFileId()
|
|
308
|
+
upload.value!.handleStart(file)
|
|
309
|
+
}
|
|
310
|
+
if (mylimit?.value > 1) {
|
|
311
|
+
console.log('超出限制: ', files)
|
|
312
|
+
ElMessage.warning(
|
|
313
|
+
`${t('fileRelated.exceedFiles')} ${mylimit?.value} ${t('fileRelated.reselect')}`
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
|
|
319
|
+
const handleChange = (file: any, fileLists: any) => {
|
|
320
|
+
if (!props.url) {
|
|
321
|
+
emits('getFile', fileLists) //将选中的文件传递回父组件
|
|
322
|
+
emits('update:file', fileLists) //同步父组件绑定的附件字段,以便父组件提交表单的时候一起将附件提交
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
// 文件列表删除时
|
|
326
|
+
const handleRemove: UploadProps['onRemove'] = (file, fileList) => {
|
|
327
|
+
console.log('file: ', file)
|
|
328
|
+
console.log('fileList: ', fileList)
|
|
329
|
+
// 如果没有url时 在删除的时候将文件流同步回父组件
|
|
330
|
+
if (!props.url) {
|
|
331
|
+
emits('getFile', fileList, file, props.RowIndex)
|
|
332
|
+
emits('update:file', fileList)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
//上传文件
|
|
336
|
+
const submitUpload = (val?: any) => {
|
|
337
|
+
try {
|
|
338
|
+
if (!fileList.value || !fileList.value.length) {
|
|
339
|
+
return ElMessage.warning(t('fileRelated.pleaseFile'))
|
|
340
|
+
}
|
|
341
|
+
console.log(fileList.value.length)
|
|
342
|
+
|
|
343
|
+
// console.log('%c Line:312 🍎 选中归属公司', 'color:#ed9ec7', datas.value.factory_affiliation_id);
|
|
344
|
+
console.log('%c Line:319 🍔 必填', 'color:#93c0a4', requiredAffiliation.value)
|
|
345
|
+
// if (!datas.value.factory_affiliation_id && requiredAffiliation.value) {
|
|
346
|
+
// return ElMessage.warning(t('fileRelated.selectCompany'));
|
|
347
|
+
// }
|
|
348
|
+
|
|
349
|
+
// if(requiredAffiliation.value){
|
|
350
|
+
// if(!datas.value.factory_affiliation_id){
|
|
351
|
+
// return ElMessage.warning(t('fileRelated.selectCompany'))
|
|
352
|
+
// }
|
|
353
|
+
// }
|
|
354
|
+
|
|
355
|
+
// if (!datas.value.warehouse_id && requiredWarehouse.value) {
|
|
356
|
+
// return ElMessage.warning(t('fileRelated.pleaseSelectWarehouse'));
|
|
357
|
+
// }
|
|
358
|
+
|
|
359
|
+
console.log('%c Line:320 🍏通过了--------', 'color:#33a5ff')
|
|
360
|
+
// exporLoading.value = ElLoading.service({ text: t('fileRelated.importing') })
|
|
361
|
+
exporLoading.value = true
|
|
362
|
+
console.log('upload.value', upload.value)
|
|
363
|
+
upload.value!.submit()
|
|
364
|
+
visible.value = false
|
|
365
|
+
} catch (error) {
|
|
366
|
+
console.log('%c Line:368 🌶 error', 'color:#4fff4B', error)
|
|
367
|
+
exporLoading.value = false
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
//文件上传成功回调
|
|
371
|
+
const onSuccess = async (res: any, file: any, fileList: any) => {
|
|
372
|
+
console.log('fileList: ', fileList)
|
|
373
|
+
console.log('file: ', file)
|
|
374
|
+
console.log('上传成功回调: ', res)
|
|
375
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
376
|
+
if (res.code !== 200) {
|
|
377
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
378
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
379
|
+
exporLoading.value = false
|
|
380
|
+
emits('errorCb', res) // 传递错误信息给父组件
|
|
381
|
+
return ElMessage.error(res.msg)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// 判断是否要走耗时逻辑
|
|
385
|
+
if (!props.timeOn || !res.data) {
|
|
386
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
387
|
+
visible.value = false // 关闭上传面板
|
|
388
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
389
|
+
exporLoading.value = false
|
|
390
|
+
ElMessage.success(res.msg)
|
|
391
|
+
emits('reloadTable', res) // 传递成功信息给父组件
|
|
392
|
+
return
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// 处理耗时请求的参数
|
|
396
|
+
let datas = {}
|
|
397
|
+
// @ts-ignore
|
|
398
|
+
datas[props.otherConfig?.datakey] = res.data.task_id
|
|
399
|
+
// 耗时轮训
|
|
400
|
+
const data = await askForTask(datas)
|
|
401
|
+
console.log('data: ', data)
|
|
402
|
+
if (data.code === 200) {
|
|
403
|
+
// fileList.value.length = 0 // 清空文件列表
|
|
404
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
405
|
+
visible.value = false // 关闭上传面板
|
|
406
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
407
|
+
exporLoading.value = false
|
|
408
|
+
ElMessage.success(data.msg)
|
|
409
|
+
emits('reloadTable', data) // 传递成功信息给父组件
|
|
410
|
+
} else if (data.code === 0) {
|
|
411
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
412
|
+
exporLoading.value = false
|
|
413
|
+
ElMessage.error(data.msg || '导入失败')
|
|
414
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
415
|
+
} else {
|
|
416
|
+
ElMessage.error(data.msg || '请求超时或者其他错误,请联系管理员.')
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
//文件上传失败回调
|
|
420
|
+
const onError = (response: any, file: any, fileList: any) => {
|
|
421
|
+
console.log('上传失败回调: ', response)
|
|
422
|
+
try {
|
|
423
|
+
ElMessage.error(file.name + t('fileRelated.uploadFailed'))
|
|
424
|
+
// fileList.value.length = 0 // 清空文件列表
|
|
425
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
426
|
+
visible.value = false // 关闭上传面板
|
|
427
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
428
|
+
exporLoading.value = false
|
|
429
|
+
} catch (error) {
|
|
430
|
+
console.log('%c Line:430 🍫 error', 'color:#7f2b82', error)
|
|
431
|
+
exporLoading.value = false
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// 耗时请求函数
|
|
436
|
+
const askForTask: (task_info: any) => Promise<any> = async (task_info: any) => {
|
|
437
|
+
// 处理父组件传递的配置
|
|
438
|
+
const axiosConfig: AxiosRequestConfig = {
|
|
439
|
+
...props.otherConfig?.timeConfig
|
|
440
|
+
}
|
|
441
|
+
// 处理请求的参数
|
|
442
|
+
if (
|
|
443
|
+
props.otherConfig?.timeConfig?.method === 'get' ||
|
|
444
|
+
props.otherConfig?.timeConfig?.method === 'GET'
|
|
445
|
+
) {
|
|
446
|
+
axiosConfig.params = {
|
|
447
|
+
...props.otherConfig?.timeConfig.params,
|
|
448
|
+
...task_info
|
|
449
|
+
}
|
|
450
|
+
} else {
|
|
451
|
+
axiosConfig.data = {
|
|
452
|
+
...props.otherConfig?.timeConfig.data,
|
|
453
|
+
...task_info
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
const res = await axios(axiosConfig)
|
|
458
|
+
// 如果返回的code是50001 就继续轮询,直到返回的code不是50001
|
|
459
|
+
if (res.data.code === 50001)
|
|
460
|
+
return await new Promise((resolve) => {
|
|
461
|
+
setTimeout(() => resolve(askForTask(task_info)), 2000)
|
|
462
|
+
})
|
|
463
|
+
return res.data
|
|
464
|
+
} catch (error) {
|
|
465
|
+
console.error('Error fetching task:', error)
|
|
466
|
+
throw error
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
//下载模板
|
|
471
|
+
const formwork = () => {
|
|
472
|
+
const url = props.url as string
|
|
473
|
+
const params = props.parameter
|
|
474
|
+
ajaxBox.downFileFetchV2(url, params, {
|
|
475
|
+
method: 'GET',
|
|
476
|
+
fileName: props.templateName || t('fileRelated.template')
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
//选择框
|
|
481
|
+
onMounted(async () => {
|
|
482
|
+
if (props.url && ifShowAffiliation.value) {
|
|
483
|
+
affiliationOptions.value = await getAffiliationOptions()
|
|
484
|
+
if (props.data && ifShowWarehouse.value) {
|
|
485
|
+
warehouseOptions.value = await getWarehouseList({
|
|
486
|
+
storage_type: props.data?.storage_type || 'CAILIAO'
|
|
487
|
+
})
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
affiliationOptions.value = []
|
|
491
|
+
warehouseOptions.value = []
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// 判断是否默认选中归属公司
|
|
495
|
+
if (ifDefaultAffiliation.value) {
|
|
496
|
+
affiliationAll.value = defaultAffiliationOrgid.value
|
|
497
|
+
datas.value.factory_affiliation_id = defaultAffiliationOrgid.value
|
|
498
|
+
}
|
|
499
|
+
})
|
|
500
|
+
|
|
501
|
+
// 修改附件上传接口的参数 datas.value
|
|
502
|
+
const updateDatas = (newDatas: any) => {
|
|
503
|
+
datas.value = { ...datas.value, ...newDatas }
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// 向组件外暴露方法
|
|
507
|
+
defineExpose({
|
|
508
|
+
datas,
|
|
509
|
+
updateDatas,
|
|
510
|
+
submitUpload
|
|
511
|
+
})
|
|
512
|
+
</script>
|
|
513
|
+
|
|
514
|
+
<style scoped lang="scss">
|
|
515
|
+
:deep(.el-upload) {
|
|
516
|
+
width: calc(100% - 110px);
|
|
517
|
+
}
|
|
518
|
+
</style>
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './fileRelated/index/ciuploadV2' // 导出附件上传v2组件
|
|
|
20
20
|
export * from './fileRelated/index/ciuploadV3' // 导出附件上传v3组件
|
|
21
21
|
export * from './fileRelated/index/ciuploadV4' // 导出附件上传v4组件
|
|
22
22
|
export * from './fileRelated/index/ciuploadV5' // 导出附件上传v5组件
|
|
23
|
+
export * from './fileRelated/index/ciuploadV6' // 导出附件上传v6组件
|
|
23
24
|
|
|
24
25
|
export * from './select' // 导出select组件
|
|
25
26
|
export * from './selectTable' // 导出selectTable组件
|
|
@@ -695,6 +695,7 @@ watch(
|
|
|
695
695
|
// 判断是否是当前列的筛选条件
|
|
696
696
|
if (filter.value || filter) {
|
|
697
697
|
hasValue.value = true
|
|
698
|
+
value.value = filter.value // 上面 if (newVal && typeof newVal == 'string')为else的时候会重置了 value.value的值
|
|
698
699
|
} else {
|
|
699
700
|
hasValue.value = false
|
|
700
701
|
value.value = '' // 重置value的值
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ColumnCls, TableColumnInstance, TableInstance } from 'element-plus'
|
|
2
2
|
import ElDialog from 'element-plus/es/components/dialog'
|
|
3
|
-
import { Component, Ref, h } from 'vue'
|
|
3
|
+
import { Component, Ref, h, CSSProperties } from 'vue'
|
|
4
4
|
export interface Scope<T> {
|
|
5
5
|
row: T
|
|
6
6
|
$index: number
|
|
@@ -11,7 +11,10 @@ export type Mutable<T> = {
|
|
|
11
11
|
-readonly [P in keyof T]: T[P]
|
|
12
12
|
}
|
|
13
13
|
export type Props<T> = Mutable<
|
|
14
|
-
Partial<Omit<T, `$${string}` | `_${string}` | '$' | '_'>>
|
|
14
|
+
Partial<Omit<T, `$${string}` | `_${string}` | '$' | '_'>> & {
|
|
15
|
+
style?: CSSProperties | string
|
|
16
|
+
class?: string | Record<string, boolean> | Array<string | Record<string, boolean>>
|
|
17
|
+
}
|
|
15
18
|
>
|
|
16
19
|
export type anyObj = { [key: string | number | symbol]: any }
|
|
17
20
|
export interface SortColumn {
|
|
@@ -22,10 +25,7 @@ export interface SortColumn {
|
|
|
22
25
|
col: Props<TableColumnInstance>
|
|
23
26
|
scope?(props: any): string
|
|
24
27
|
component?: (createVNode: typeof h, data: Scope<any>) => Component
|
|
25
|
-
header?: (
|
|
26
|
-
createVNode: typeof h,
|
|
27
|
-
data: Pick<Scope<any>, '$index' | 'column'>,
|
|
28
|
-
) => Component
|
|
28
|
+
header?: (createVNode: typeof h, data: Pick<Scope<any>, '$index' | 'column'>) => Component
|
|
29
29
|
children?: SortColumn[]
|
|
30
30
|
}
|
|
31
31
|
export type SortColumnSend = Pick<SortColumn, 'id' | 'hide'> & {
|
|
@@ -34,10 +34,7 @@ export type SortColumnSend = Pick<SortColumn, 'id' | 'hide'> & {
|
|
|
34
34
|
ban: boolean
|
|
35
35
|
}
|
|
36
36
|
export interface SortableTableIns
|
|
37
|
-
extends /* @vue-ignore */ Omit<
|
|
38
|
-
Props<TableInstance>,
|
|
39
|
-
'data' | 'ref' | 'headerCellClassName'
|
|
40
|
-
> {
|
|
37
|
+
extends /* @vue-ignore */ Omit<Props<TableInstance>, 'data' | 'ref' | 'headerCellClassName'> {
|
|
41
38
|
table?: /* @vue-ignore */
|
|
42
39
|
Props<TableInstance> | /* @vue-ignore */ Ref<Props<TableInstance>>['value']
|
|
43
40
|
modelValue: SortColumn[] | Ref<SortColumn[]>['value']
|
|
@@ -48,6 +45,6 @@ export interface SortableTableIns
|
|
|
48
45
|
export interface SortableTableDialog {
|
|
49
46
|
config?: /* @vue-ignore */
|
|
50
47
|
| Props<InstanceType<typeof ElDialog>>
|
|
51
|
-
|
|
48
|
+
| /* @vue-ignore */ Ref<Props<InstanceType<typeof ElDialog>>>['value']
|
|
52
49
|
modelValue: SortColumn[] | Ref<SortColumn[]>['value']
|
|
53
50
|
}
|