ci-plus 1.8.3 → 1.8.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 +5 -0
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/components.d.ts +2 -0
- package/src/dailog/style/index.less +49 -49
- package/src/fileRelated/index/ciuploadV4.ts +4 -0
- package/src/fileRelated/uploadV3.vue +1 -1
- package/src/fileRelated/uploadV4.vue +424 -0
- package/src/index.ts +1 -0
- package/src/utils/getAffiliationOptions.ts +103 -3
- package/src/utils/index.ts +15 -2
- package/src/utils/lang/en.js +2 -0
- package/src/utils/lang/zh.js +2 -0
package/README.md
CHANGED
package/index.ts
CHANGED
package/package.json
CHANGED
package/src/components.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ declare module '@vue/runtime-core' {
|
|
|
25
25
|
CiSeeFile: typeof components.SeeFile
|
|
26
26
|
CiUpload: typeof components.Upload
|
|
27
27
|
CiUploadV2: typeof components.UploadV2
|
|
28
|
+
CiUploadV3: typeof components.UploadV3
|
|
29
|
+
CiUploadV4: typeof components.UploadV4
|
|
28
30
|
|
|
29
31
|
CiSelect: typeof components.Select
|
|
30
32
|
CiSelectTable: typeof components.SelectTable
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
// 内容区域
|
|
43
43
|
.el-dialog__body {
|
|
44
44
|
height: calc(100% - 45px);
|
|
45
|
-
padding-bottom:
|
|
45
|
+
padding-bottom: 10px !important;
|
|
46
46
|
overflow: auto;
|
|
47
47
|
.my-body {
|
|
48
48
|
text-align: left;
|
|
@@ -71,56 +71,56 @@
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// 此处样式会全局生效
|
|
74
|
-
.el-dialog {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
// .el-dialog {
|
|
75
|
+
// padding: 0 !important;
|
|
76
|
+
// // height: 100% !important;
|
|
77
|
+
// // max-height: calc(100% - 10vh);
|
|
78
|
+
// .el-dialog__header {
|
|
79
|
+
// height: 35px !important;
|
|
80
|
+
// line-height: 35px !important;
|
|
81
|
+
// margin: 0 !important;
|
|
82
|
+
// padding: 0px !important;
|
|
83
|
+
// background-color: rgba(0, 0, 0, 0.1) !important;
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
85
|
+
// .my-header {
|
|
86
|
+
// display: flex;
|
|
87
|
+
// height: 35px;
|
|
88
|
+
// line-height: 35px;
|
|
89
|
+
// margin: 0 10px;
|
|
90
|
+
// .title {
|
|
91
|
+
// flex: 1;
|
|
92
|
+
// .el-dialog__title {
|
|
93
|
+
// margin: 0px !important;
|
|
94
|
+
// padding: 0px !important;
|
|
95
|
+
// height: 35px !important;
|
|
96
|
+
// line-height: 35px;
|
|
97
|
+
// margin: 0 !important;
|
|
98
|
+
// padding: 0 !important;
|
|
99
|
+
// text-align: left !important;
|
|
100
|
+
// font-weight: 700;
|
|
101
|
+
// }
|
|
102
|
+
// }
|
|
103
|
+
// .btn {
|
|
104
|
+
// max-width: 100px;
|
|
105
|
+
// display: flex;
|
|
106
|
+
// justify-content: flex-end;
|
|
107
|
+
// height: 35px;
|
|
108
|
+
// line-height: 35px;
|
|
109
|
+
// align-items: center;
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
114
|
+
// // 内容区域
|
|
115
|
+
// .el-dialog__body {
|
|
116
|
+
// height: calc(100% - 45px);
|
|
117
|
+
// padding-bottom: 10px !important;
|
|
118
|
+
// overflow: auto;
|
|
119
|
+
// .my-body {
|
|
120
|
+
// text-align: left;
|
|
121
|
+
// }
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
124
124
|
.drag {
|
|
125
125
|
position: absolute;
|
|
126
126
|
width: 16px;
|
|
@@ -121,7 +121,7 @@ import {
|
|
|
121
121
|
} from 'element-plus'
|
|
122
122
|
import { onMounted, ref } from 'vue'
|
|
123
123
|
import ajaxBox from '../utils/ajaxBox'
|
|
124
|
-
import getAffiliationOptions from '../utils/getAffiliationOptions.ts'
|
|
124
|
+
import {getAffiliationOptions} from '../utils/getAffiliationOptions.ts'
|
|
125
125
|
const upload = ref<UploadInstance>()
|
|
126
126
|
const exporLoading = ref()
|
|
127
127
|
const visible = ref(false)
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
<!-- /**
|
|
2
|
+
* @module uploadV4
|
|
3
|
+
* @author : 卖女孩的小火柴
|
|
4
|
+
* !description : 其它入库 导入组件
|
|
5
|
+
* @version : 1.0.0
|
|
6
|
+
* @since : 创建时间 2025-08-14 14:36:38
|
|
7
|
+
*/ -->
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<el-popover
|
|
11
|
+
placement="bottom"
|
|
12
|
+
:width="300"
|
|
13
|
+
:trigger="props.otherConfig?.trigger || 'hover'"
|
|
14
|
+
:visible="visible"
|
|
15
|
+
>
|
|
16
|
+
<el-upload
|
|
17
|
+
ref="upload"
|
|
18
|
+
class="upload-demo"
|
|
19
|
+
:action="uploadUrl"
|
|
20
|
+
:limit="mylimit || 1"
|
|
21
|
+
:on-exceed="handleExceed"
|
|
22
|
+
:auto-upload="false"
|
|
23
|
+
:on-success="onSuccess"
|
|
24
|
+
:on-error="onError"
|
|
25
|
+
:on-change="handleChange"
|
|
26
|
+
:on-remove="handleRemove"
|
|
27
|
+
:data="datas"
|
|
28
|
+
:multiple="mymultiple || false"
|
|
29
|
+
v-model:file-list="fileList"
|
|
30
|
+
>
|
|
31
|
+
<template #trigger>
|
|
32
|
+
<el-button size="small" type="primary" style="width: 100%" plain>
|
|
33
|
+
{{ t('fileRelated.selectFile') }}
|
|
34
|
+
</el-button>
|
|
35
|
+
</template>
|
|
36
|
+
<el-button
|
|
37
|
+
size="small"
|
|
38
|
+
@click="formwork"
|
|
39
|
+
style="float: left; margin: 0 12px 0 0; width: 95px"
|
|
40
|
+
v-if="url"
|
|
41
|
+
>
|
|
42
|
+
{{ t('fileRelated.downloadTemplate') }}
|
|
43
|
+
</el-button>
|
|
44
|
+
</el-upload>
|
|
45
|
+
|
|
46
|
+
<div class="slot" style="display: flex; flex-direction: column; align-items: flex-end">
|
|
47
|
+
<div style="width: 100%; margin: 4px 2px" v-if="ifShowAffiliation">
|
|
48
|
+
<el-select-v2
|
|
49
|
+
size="small"
|
|
50
|
+
v-model="affiliationAll"
|
|
51
|
+
filterable
|
|
52
|
+
:options="affiliationOptions"
|
|
53
|
+
:placeholder="t('fileRelated.selectCompany')"
|
|
54
|
+
style="width: 100%; margin-right: 5px"
|
|
55
|
+
clearable
|
|
56
|
+
@change="changeAll"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
<div style="width: 100%; margin: 4px 2px" v-if="ifShowWarehouse">
|
|
60
|
+
<el-select-v2
|
|
61
|
+
size="small"
|
|
62
|
+
v-model="warehouseAll"
|
|
63
|
+
filterable
|
|
64
|
+
:options="warehouseOptions"
|
|
65
|
+
:placeholder="t('fileRelated.selectWarehouse')"
|
|
66
|
+
style="width: 100%; margin-right: 5px"
|
|
67
|
+
clearable
|
|
68
|
+
@change="changeWarehouseAll"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<!-- 添加一个插槽 -->
|
|
72
|
+
<slot></slot>
|
|
73
|
+
<div>
|
|
74
|
+
<el-button size="small" type="primary" @click="submitUpload" style="flex: 2">
|
|
75
|
+
{{ t('fileRelated.upload') }}
|
|
76
|
+
</el-button>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<template #reference>
|
|
81
|
+
<el-button
|
|
82
|
+
:type="exporLoading ? 'danger' : 'success'"
|
|
83
|
+
@click="visible = !visible"
|
|
84
|
+
:size="props.otherConfig?.size || 'small'"
|
|
85
|
+
:loading="exporLoading"
|
|
86
|
+
>
|
|
87
|
+
{{ props.title || t('fileRelated.attachmentUpload') }}
|
|
88
|
+
</el-button>
|
|
89
|
+
</template>
|
|
90
|
+
</el-popover>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<script setup lang="ts">
|
|
94
|
+
defineOptions({ name: 'ci-uploadV3' })
|
|
95
|
+
|
|
96
|
+
// 定义一个函数,用于处理字符串
|
|
97
|
+
|
|
98
|
+
const setFilePath = (arr: string[], url?: string) => {
|
|
99
|
+
// console.log('重新渲染数据', arr);
|
|
100
|
+
if (arr && arr.length > 0) {
|
|
101
|
+
let newArr: { name: string; oldName: string }[] = []
|
|
102
|
+
arr.forEach((item, i) => {
|
|
103
|
+
let segments = item.split('.')
|
|
104
|
+
let parts = segments[0].split('/') // 获取每名称
|
|
105
|
+
let name = parts[parts.length - 1] + '.' + segments[segments.length - 1]
|
|
106
|
+
let oldName = url ? url + item : item //原来的名称
|
|
107
|
+
// let url = segments[0] + '.' + segments[segments.length - 1]
|
|
108
|
+
newArr.push({ name, oldName })
|
|
109
|
+
})
|
|
110
|
+
return newArr
|
|
111
|
+
} else {
|
|
112
|
+
return [] // 如果数组为空,则返回空数组
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 将路径处理成附件的参数
|
|
117
|
+
const fileArr = (url: string, pathArr: string[]) => {
|
|
118
|
+
if (pathArr && pathArr.length > 0) {
|
|
119
|
+
let objArr: any = []
|
|
120
|
+
if (pathArr.length > 0) {
|
|
121
|
+
pathArr.map((item: any) => {
|
|
122
|
+
objArr.push({
|
|
123
|
+
name: item.name,
|
|
124
|
+
oldName: item.oldName,
|
|
125
|
+
url: url + item.oldName
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
return objArr
|
|
129
|
+
} else {
|
|
130
|
+
return []
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
import t from '../utils/lang/index'
|
|
135
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
136
|
+
import { computed, onMounted, ref } from 'vue'
|
|
137
|
+
import ajaxBox from '../utils/ajaxBox'
|
|
138
|
+
import { getAffiliationOptions, getWarehouseList, axios } from '../utils/getAffiliationOptions.ts'
|
|
139
|
+
|
|
140
|
+
import type {
|
|
141
|
+
UploadFile,
|
|
142
|
+
UploadFiles,
|
|
143
|
+
UploadInstance,
|
|
144
|
+
UploadProps,
|
|
145
|
+
UploadUserFile
|
|
146
|
+
} from 'element-plus'
|
|
147
|
+
import {
|
|
148
|
+
ElButton,
|
|
149
|
+
ElLoading,
|
|
150
|
+
ElMessage,
|
|
151
|
+
ElPopover,
|
|
152
|
+
ElSelectV2,
|
|
153
|
+
ElUpload,
|
|
154
|
+
genFileId,
|
|
155
|
+
UploadRawFile
|
|
156
|
+
} from 'element-plus'
|
|
157
|
+
|
|
158
|
+
const upload = ref<UploadInstance>()
|
|
159
|
+
const exporLoading = ref(false)
|
|
160
|
+
const visible = ref(false)
|
|
161
|
+
const affiliationAll = ref() // 选择的归属公司
|
|
162
|
+
const warehouseAll = ref() // 选择的仓库
|
|
163
|
+
const affiliationOptions = ref<any[]>([]) // 获取归属公司列表数据
|
|
164
|
+
const warehouseOptions = ref<any[]>([]) // 获取仓库列表数据
|
|
165
|
+
|
|
166
|
+
interface Props {
|
|
167
|
+
url?: string // 上传和下载模板的接口(当需要将附件传递回父组件时不需要传递此属性)
|
|
168
|
+
uploadUrl?: string // 上传附件的接口
|
|
169
|
+
parameter?: Object // 模板下载的时候请求需要携带的参数:{state: 1}
|
|
170
|
+
data?: Object //上传携带的其他数据对象:{userId: 1, userName: '张三'}
|
|
171
|
+
title?: string // 上传按钮的名称
|
|
172
|
+
multiple?: boolean // 是否支持多文件
|
|
173
|
+
limit?: number // 最大文件数量
|
|
174
|
+
ifShowAffiliation?: boolean // 是否显示归属公司
|
|
175
|
+
requiredAffiliation?: boolean // 是否必选归属公司
|
|
176
|
+
ifShowWarehouse?: boolean // 是否显示仓库
|
|
177
|
+
requiredWarehouse?: boolean // 是否必选仓库
|
|
178
|
+
filePath?: UploadFile[] //UploadRawFile[] // 父组件传递的附件数据,用于显示附件列表和上传附件后传递给父组件附件数据
|
|
179
|
+
RowIndex?: number // 父组件传递的行索引,用于父组件中删除了附件找到对应的行(用于表格表单中上传附件)
|
|
180
|
+
templateName?: string //模板名称
|
|
181
|
+
timeOn?: boolean // 是否开启耗时任务 默认不开启
|
|
182
|
+
// 其他的一些配置:请求的baseurl地址,有耗时任务的时候耗时任务的配置,模板下载的一些配置等
|
|
183
|
+
otherConfig: {
|
|
184
|
+
size?: 'large' | 'default' | 'small' // 按钮大小
|
|
185
|
+
trigger?: 'click' | 'focus' | 'hover' | 'contextmenu' // 按钮触发方式 默认 hover
|
|
186
|
+
baseUrl?: string // 上请求的baseurl地址
|
|
187
|
+
datakey: string // 耗时请求的参数key值
|
|
188
|
+
// 耗时任务的配置
|
|
189
|
+
timeConfig: {
|
|
190
|
+
url: string // 查询耗时任务地址
|
|
191
|
+
method: 'put' | 'post' | 'get' | 'PUT' | 'POST' | 'GET'
|
|
192
|
+
data?: object // 可选属性
|
|
193
|
+
params?: object // 可选属性
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const props = defineProps<Props>()
|
|
198
|
+
|
|
199
|
+
// 默认值:是否显示归属公司
|
|
200
|
+
const ifShowAffiliation = computed(() => {
|
|
201
|
+
return props.ifShowAffiliation || true
|
|
202
|
+
})
|
|
203
|
+
// 默认值:是否显示仓库
|
|
204
|
+
const ifShowWarehouse = computed(() => {
|
|
205
|
+
return props.ifShowWarehouse || false
|
|
206
|
+
})
|
|
207
|
+
// 默认值:是否必选归属公司
|
|
208
|
+
const requiredAffiliation = computed(() => {
|
|
209
|
+
return props.requiredAffiliation || false
|
|
210
|
+
})
|
|
211
|
+
// 默认值:是否必选仓库
|
|
212
|
+
const requiredWarehouse = computed(() => {
|
|
213
|
+
return props.requiredWarehouse || false
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
const emits = defineEmits<{
|
|
217
|
+
(e: 'reloadTable'): void // 组件中上传附件后刷新父组件表格数据方法
|
|
218
|
+
(e: 'getFile', files: UploadFiles, file?: UploadFile, rowindex?: number): void // 编辑表单的时候回显附件用到
|
|
219
|
+
(e: 'update:file', files: UploadFiles): void // 编辑表单的时候回显附件用到
|
|
220
|
+
}>()
|
|
221
|
+
console.log('附件props: ', props)
|
|
222
|
+
const datas: any = ref(props.data)
|
|
223
|
+
const mymultiple = ref<boolean>(props.multiple)
|
|
224
|
+
const mylimit = ref<number>((props.limit as number) || 1)
|
|
225
|
+
const myfilePath = ref<any>(props.filePath || [])
|
|
226
|
+
console.log('myfilePath: ', props.filePath)
|
|
227
|
+
|
|
228
|
+
const changeAll = (val: string) => {
|
|
229
|
+
datas.value.factory_affiliation_id = val
|
|
230
|
+
datas.value.factory_affiliation_name = affiliationOptions.value.find(
|
|
231
|
+
(item: any) => item.value === val
|
|
232
|
+
)?.label
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const changeWarehouseAll = (val: string) => {
|
|
236
|
+
datas.value.warehouse_id = val
|
|
237
|
+
datas.value.warehouse_name = warehouseOptions.value.find((item: any) => item.value === val)?.label
|
|
238
|
+
|
|
239
|
+
console.log('%c Line:236 🍐 datas.value', 'color:#ea7e5c', datas.value)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// 对数组中的每个字符串应用处理函数
|
|
243
|
+
let pathArr = setFilePath(myfilePath.value)
|
|
244
|
+
|
|
245
|
+
// 打印处理后的数组
|
|
246
|
+
// 将父组件中传递过来的名称,处理成el-upload需要的格式
|
|
247
|
+
let pathUrlArr = fileArr(import.meta.env.VITE_BASE_URL9999, pathArr)
|
|
248
|
+
console.log('fileObj(): ', pathUrlArr)
|
|
249
|
+
const fileList = ref<UploadUserFile[]>(pathUrlArr)
|
|
250
|
+
console.log('fileList: ', fileList.value)
|
|
251
|
+
|
|
252
|
+
//当超出限制时,执行的钩子函数
|
|
253
|
+
const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
254
|
+
console.log('%c Line:177 🥝 files', 'color:#e41a6a', files)
|
|
255
|
+
|
|
256
|
+
if (mylimit?.value === 1) {
|
|
257
|
+
upload.value!.clearFiles()
|
|
258
|
+
const file = files[0] as UploadRawFile
|
|
259
|
+
file.uid = genFileId()
|
|
260
|
+
upload.value!.handleStart(file)
|
|
261
|
+
}
|
|
262
|
+
if (mylimit?.value > 1) {
|
|
263
|
+
console.log('超出限制: ', files)
|
|
264
|
+
ElMessage.warning(
|
|
265
|
+
`${t('fileRelated.exceedFiles')} ${mylimit?.value} ${t('fileRelated.reselect')}`
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
|
|
271
|
+
const handleChange = (file: any, fileLists: any) => {
|
|
272
|
+
if (!props.url) {
|
|
273
|
+
emits('getFile', fileLists) //将选中的文件传递回父组件
|
|
274
|
+
emits('update:file', fileLists) //同步父组件绑定的附件字段,以便父组件提交表单的时候一起将附件提交
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// 文件列表删除时
|
|
278
|
+
const handleRemove: UploadProps['onRemove'] = (file, fileList) => {
|
|
279
|
+
console.log('file: ', file)
|
|
280
|
+
console.log('fileList: ', fileList)
|
|
281
|
+
// 如果没有url时 在删除的时候将文件流同步回父组件
|
|
282
|
+
if (!props.url) {
|
|
283
|
+
emits('getFile', fileList, file, props.RowIndex)
|
|
284
|
+
emits('update:file', fileList)
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//上传文件
|
|
288
|
+
const submitUpload = () => {
|
|
289
|
+
if (!fileList.value || !fileList.value.length) {
|
|
290
|
+
return ElMessage.warning(t('fileRelated.pleaseFile'))
|
|
291
|
+
}
|
|
292
|
+
console.log(fileList.value.length)
|
|
293
|
+
if (!datas.value.warehouse_id && requiredWarehouse.value) {
|
|
294
|
+
return ElMessage.warning(t('fileRelated.pleaseSelectWarehouse'))
|
|
295
|
+
}
|
|
296
|
+
if (!datas.value.factory_affiliation_id && requiredAffiliation.value) {
|
|
297
|
+
return ElMessage.warning(t('fileRelated.selectCompany'))
|
|
298
|
+
}
|
|
299
|
+
// exporLoading.value = ElLoading.service({ text: t('fileRelated.importing') })
|
|
300
|
+
exporLoading.value = true
|
|
301
|
+
console.log('upload.value', upload.value)
|
|
302
|
+
upload.value!.submit()
|
|
303
|
+
visible.value = false
|
|
304
|
+
}
|
|
305
|
+
//文件上传成功回调
|
|
306
|
+
const onSuccess = async (res: any, file: any, fileList: any) => {
|
|
307
|
+
console.log('fileList: ', fileList)
|
|
308
|
+
console.log('file: ', file)
|
|
309
|
+
console.log('上传成功回调: ', res)
|
|
310
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
311
|
+
if (res.code !== 200) {
|
|
312
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
313
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
314
|
+
exporLoading.value = false
|
|
315
|
+
return ElMessage.warning(res.msg)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 判断是否要走耗时逻辑
|
|
319
|
+
if (!props.timeOn || !res.data) {
|
|
320
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
321
|
+
visible.value = false // 关闭上传面板
|
|
322
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
323
|
+
exporLoading.value = false
|
|
324
|
+
ElMessage.success(res.msg)
|
|
325
|
+
emits('reloadTable')
|
|
326
|
+
return
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// 处理耗时请求的参数
|
|
330
|
+
let datas = {}
|
|
331
|
+
datas[props.otherConfig?.datakey] = res.data.task_id
|
|
332
|
+
// 耗时轮训
|
|
333
|
+
const data = await askForTask(datas)
|
|
334
|
+
console.log('data: ', data)
|
|
335
|
+
if (data.code === 200) {
|
|
336
|
+
// fileList.value.length = 0 // 清空文件列表
|
|
337
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
338
|
+
visible.value = false // 关闭上传面板
|
|
339
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
340
|
+
exporLoading.value = false
|
|
341
|
+
ElMessage.success(data.msg)
|
|
342
|
+
emits('reloadTable')
|
|
343
|
+
} else if (data.code === 0) {
|
|
344
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
345
|
+
exporLoading.value = false
|
|
346
|
+
ElMessage.error(data.msg || '导入失败')
|
|
347
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
348
|
+
} else {
|
|
349
|
+
ElMessage.error(data.msg || '请求超时或者其他错误,请联系管理员.')
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
//文件上传失败回调
|
|
353
|
+
const onError = (response: any, file: any, fileList: any) => {
|
|
354
|
+
console.log('上传失败回调: ', response)
|
|
355
|
+
ElMessage.error(file.name + t('fileRelated.uploadFailed'))
|
|
356
|
+
// fileList.value.length = 0 // 清空文件列表
|
|
357
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
358
|
+
visible.value = false // 关闭上传面板
|
|
359
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
360
|
+
exporLoading.value = false
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// 耗时请求函数
|
|
364
|
+
const askForTask: (task_info: any) => Promise<any> = async (task_info: any) => {
|
|
365
|
+
// 处理父组件传递的配置
|
|
366
|
+
const axiosConfig: AxiosRequestConfig = {
|
|
367
|
+
...props.otherConfig?.timeConfig
|
|
368
|
+
}
|
|
369
|
+
// 处理请求的参数
|
|
370
|
+
if (
|
|
371
|
+
props.otherConfig?.timeConfig?.method === 'get' ||
|
|
372
|
+
props.otherConfig?.timeConfig?.method === 'GET'
|
|
373
|
+
) {
|
|
374
|
+
axiosConfig.params = {
|
|
375
|
+
...props.otherConfig?.timeConfig.params,
|
|
376
|
+
...task_info
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
axiosConfig.data = {
|
|
380
|
+
...props.otherConfig?.timeConfig.data,
|
|
381
|
+
...task_info
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
const res = await axios(axiosConfig)
|
|
386
|
+
// 如果返回的code是50001 就继续轮询,直到返回的code不是50001
|
|
387
|
+
if (res.data.code === 50001)
|
|
388
|
+
return await new Promise((resolve) => {
|
|
389
|
+
setTimeout(() => resolve(askForTask(task_info)), 2000)
|
|
390
|
+
})
|
|
391
|
+
return res.data
|
|
392
|
+
} catch (error) {
|
|
393
|
+
console.error('Error fetching task:', error)
|
|
394
|
+
throw error
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
//下载模板
|
|
399
|
+
const formwork = () => {
|
|
400
|
+
const url = props.url as string
|
|
401
|
+
const params = props.parameter
|
|
402
|
+
ajaxBox.downFileFetchV2(url, params, {
|
|
403
|
+
method: 'GET',
|
|
404
|
+
fileName: props.templateName || t('fileRelated.template')
|
|
405
|
+
})
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
//选择框
|
|
409
|
+
onMounted(async () => {
|
|
410
|
+
if (props.url) {
|
|
411
|
+
affiliationOptions.value = await getAffiliationOptions()
|
|
412
|
+
warehouseOptions.value = await getWarehouseList()
|
|
413
|
+
} else {
|
|
414
|
+
affiliationOptions.value = []
|
|
415
|
+
warehouseOptions.value = []
|
|
416
|
+
}
|
|
417
|
+
})
|
|
418
|
+
</script>
|
|
419
|
+
|
|
420
|
+
<style scoped lang="scss">
|
|
421
|
+
:deep(.el-upload) {
|
|
422
|
+
width: calc(100% - 110px);
|
|
423
|
+
}
|
|
424
|
+
</style>
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './fileRelated/index/ciseeFile' // 导出附件查看组件
|
|
|
18
18
|
export * from './fileRelated/index/ciupload' // 导出附件上传组件
|
|
19
19
|
export * from './fileRelated/index/ciuploadV2' // 导出附件上传v2组件
|
|
20
20
|
export * from './fileRelated/index/ciuploadV3' // 导出附件上传v3组件
|
|
21
|
+
export * from './fileRelated/index/ciuploadV4' // 导出附件上传v4组件
|
|
21
22
|
|
|
22
23
|
export * from './select' // 导出select组件
|
|
23
24
|
export * from './selectTable' // 导出selectTable组件
|
|
@@ -2,6 +2,51 @@ import apis from './baseApi'
|
|
|
2
2
|
import axios from 'axios'
|
|
3
3
|
const { produceModule } = apis
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
export interface User {
|
|
7
|
+
user_code: string // 登录名:'148128'
|
|
8
|
+
user_name: string // 用户名:'方卿'
|
|
9
|
+
org_id: string // 公司ID:'1780861656362131456'
|
|
10
|
+
org_name: string // 公司名称:'杭州人本轴承有限公司动力分厂'
|
|
11
|
+
dept_id: string // 团队ID:'1712341581808545792'
|
|
12
|
+
dept_name: string // 团队名称:'质控4团队'
|
|
13
|
+
tenantId: string // 租户id:'1739466802218676224'
|
|
14
|
+
}
|
|
15
|
+
// 在pc端获取用户信息
|
|
16
|
+
const UserData = JSON.parse(localStorage.getItem('UserData') || '{}')
|
|
17
|
+
let users = {
|
|
18
|
+
org_id: UserData.orgId,
|
|
19
|
+
org_name: UserData.orgName,
|
|
20
|
+
user_code: UserData.loginName,
|
|
21
|
+
user_name: UserData.name,
|
|
22
|
+
dept_id: UserData.deptId,
|
|
23
|
+
dept_name: UserData.deptName,
|
|
24
|
+
}
|
|
25
|
+
let user = JSON.parse(JSON.stringify(users))
|
|
26
|
+
|
|
27
|
+
const cardPrintAxios = axios.create({
|
|
28
|
+
withCredentials: true,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
cardPrintAxios.interceptors.request.use(
|
|
32
|
+
(config) => {
|
|
33
|
+
// if (userInfo.accessToken)
|
|
34
|
+
// config.headers['Authorization'] = userInfo.accessToken
|
|
35
|
+
if (config.method == 'get' && config.params) {
|
|
36
|
+
Object.assign(config.params, user)
|
|
37
|
+
} else if (config.method !== 'get') {
|
|
38
|
+
if (config.data instanceof FormData) {
|
|
39
|
+
let data: FormData = config.data
|
|
40
|
+
Object.keys(user).forEach((k) => {
|
|
41
|
+
if (!data.has(k)) data.append(k, user[k as keyof User])
|
|
42
|
+
})
|
|
43
|
+
} else Object.assign(config.data, user)
|
|
44
|
+
}
|
|
45
|
+
return config
|
|
46
|
+
},
|
|
47
|
+
(error) => Promise.reject(error),
|
|
48
|
+
)
|
|
49
|
+
|
|
5
50
|
interface AffiliationRES {
|
|
6
51
|
id: string // 归属公司 id
|
|
7
52
|
name: string // 归属公司 名称
|
|
@@ -30,12 +75,65 @@ interface AffiliationRES {
|
|
|
30
75
|
const getAffiliationOptions = async (
|
|
31
76
|
list?: any[],
|
|
32
77
|
keys: string[] = ['label', 'value'],
|
|
33
|
-
val: string[] = ['name', 'id']
|
|
78
|
+
val: string[] = ['name', 'id'],
|
|
34
79
|
) => {
|
|
35
80
|
let url = produceModule + 'company_optional_scope_get/'
|
|
36
81
|
let options: { [key: string]: any }[] = []
|
|
37
82
|
try {
|
|
38
|
-
const res = await
|
|
83
|
+
const res = await cardPrintAxios.get(url, {
|
|
84
|
+
params: {
|
|
85
|
+
page: 1,
|
|
86
|
+
pageSize: 100000,
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
console.log('%c Line:360 🍊🍤 res666', 'color:#7f2b82', res)
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
res.status === 200 &&
|
|
93
|
+
res.data.code === 200 &&
|
|
94
|
+
Array.isArray(res.data?.data) &&
|
|
95
|
+
res.data.data.length > 0
|
|
96
|
+
) {
|
|
97
|
+
res.data.data.forEach((item: AffiliationRES) => {
|
|
98
|
+
const obj: { [key: string]: any } = {}
|
|
99
|
+
keys.forEach((key, index) => {
|
|
100
|
+
const valueKey = val[index]
|
|
101
|
+
obj[key] = item[valueKey as keyof AffiliationRES]
|
|
102
|
+
})
|
|
103
|
+
options.push(obj)
|
|
104
|
+
})
|
|
105
|
+
} else {
|
|
106
|
+
console.error('请求失败:', res.data.msg)
|
|
107
|
+
options = []
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error('请求失败:', error)
|
|
111
|
+
options = []
|
|
112
|
+
}
|
|
113
|
+
console.log('%c Line:1338 🥝 result', 'color:#ea7e5c', options)
|
|
114
|
+
list = options
|
|
115
|
+
return options
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 获取仓库列表数据 warehouse_get
|
|
119
|
+
const getWarehouseList = async (
|
|
120
|
+
list?: any[],
|
|
121
|
+
keys: string[] = ['label', 'value'],
|
|
122
|
+
val: string[] = ['name', 'id'],
|
|
123
|
+
storage_type: string = 'CAILIAO', // 仓库类型
|
|
124
|
+
search?: string, // 搜索条件,
|
|
125
|
+
) => {
|
|
126
|
+
let url = produceModule + 'warehouse_get/'
|
|
127
|
+
let options: { [key: string]: any }[] = []
|
|
128
|
+
try {
|
|
129
|
+
const res = await cardPrintAxios.get(url, {
|
|
130
|
+
params: {
|
|
131
|
+
page: 1,
|
|
132
|
+
pageSize: 100000,
|
|
133
|
+
warehouse_type_codes: storage_type,
|
|
134
|
+
name: search,
|
|
135
|
+
},
|
|
136
|
+
})
|
|
39
137
|
console.log('%c Line:360 🍊 res', 'color:#7f2b82', res)
|
|
40
138
|
if (
|
|
41
139
|
res.status === 200 &&
|
|
@@ -64,4 +162,6 @@ const getAffiliationOptions = async (
|
|
|
64
162
|
return options
|
|
65
163
|
}
|
|
66
164
|
|
|
67
|
-
|
|
165
|
+
// 导出独立实例
|
|
166
|
+
export { cardPrintAxios as axios, getAffiliationOptions, getWarehouseList }
|
|
167
|
+
export default cardPrintAxios
|
package/src/utils/index.ts
CHANGED
|
@@ -7,7 +7,14 @@ import { cardPrint, setCardList } from './cardPrint'
|
|
|
7
7
|
import apis from './baseApi'
|
|
8
8
|
import { dayjs, setDate, setDateTime } from './Dayjs'
|
|
9
9
|
import ajaxBox from './ajaxBox' // 处理文件下载方法
|
|
10
|
-
import
|
|
10
|
+
import cardPrintAxios, {
|
|
11
|
+
getAffiliationOptions,
|
|
12
|
+
getWarehouseList,
|
|
13
|
+
axios
|
|
14
|
+
} from './getAffiliationOptions' // 处理文件下载方法
|
|
15
|
+
|
|
16
|
+
// 表头组件的一些方法
|
|
17
|
+
import { setId, getSend, sort } from '../sortableTable/utils/dataOpt'
|
|
11
18
|
|
|
12
19
|
let func = {
|
|
13
20
|
cardPrint,
|
|
@@ -16,9 +23,15 @@ let func = {
|
|
|
16
23
|
setDate,
|
|
17
24
|
setDateTime,
|
|
18
25
|
getAffiliationOptions,
|
|
26
|
+
getWarehouseList,
|
|
27
|
+
cardPrintAxios, // 一个简易的axios
|
|
28
|
+
axios,
|
|
19
29
|
apis,
|
|
20
30
|
ajaxBox,
|
|
21
|
-
dayjs
|
|
31
|
+
dayjs,
|
|
32
|
+
setId,
|
|
33
|
+
getSend,
|
|
34
|
+
sort
|
|
22
35
|
}
|
|
23
36
|
// 导出 所有方法
|
|
24
37
|
export default func
|
package/src/utils/lang/en.js
CHANGED
|
@@ -25,11 +25,13 @@ const en = {
|
|
|
25
25
|
selectFile:'SELECT FILE',
|
|
26
26
|
downloadTemplate:'Download Template',
|
|
27
27
|
selectCompany:'Choose a company to belong to',
|
|
28
|
+
selectWarehouse: 'Select warehouse',
|
|
28
29
|
upload:'Upload',
|
|
29
30
|
attachmentUpload:'Attachment upload',
|
|
30
31
|
exceedFiles:'Exceeded the maximum file count of ',
|
|
31
32
|
reselect:' files, please select again',
|
|
32
33
|
pleaseFile:'Please select the file before uploading!',
|
|
34
|
+
pleaseSelectWarehouse: 'Please select the warehouse',
|
|
33
35
|
importing:'Importing in progress ···',
|
|
34
36
|
uploadFailed:'Upload failed',
|
|
35
37
|
},
|
package/src/utils/lang/zh.js
CHANGED
|
@@ -25,11 +25,13 @@ const zh = {
|
|
|
25
25
|
selectFile:'选择文件',
|
|
26
26
|
downloadTemplate:'下载模板',
|
|
27
27
|
selectCompany:'选择归属公司',
|
|
28
|
+
selectWarehouse: '选择仓库',
|
|
28
29
|
upload:'上传',
|
|
29
30
|
attachmentUpload:'附件上传',
|
|
30
31
|
exceedFiles:'超出最大文件数 ',
|
|
31
32
|
reselect:' 个文件,请重新选择',
|
|
32
33
|
pleaseFile:'请选择文件后在上传!',
|
|
34
|
+
pleaseSelectWarehouse: '请选择仓库',
|
|
33
35
|
importing:'导入中···',
|
|
34
36
|
uploadFailed:'上传失败',
|
|
35
37
|
template:'模板.xlsx'
|