ci-plus 1.5.3 → 1.5.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/package.json +2 -2
- package/src/dailog/dialog.vue +2 -2
- package/src/fileRelated/uploadV2.vue +153 -39
- package/src/identificationCard/identificationCard.vue +1644 -1388
- package/src/identificationCard/identificationCard1.5.4.vue +1639 -0
- package/src/utils/cardPrint.ts +59 -67
- package/src/utils/cardPrint1.5.4.ts +863 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ci-plus",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "ci组件库",
|
|
5
5
|
"main": "./index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"vue",
|
|
13
13
|
"element-plus",
|
|
14
14
|
"ui组件库二次封装",
|
|
15
|
-
"
|
|
15
|
+
"给芜湖伦比单独更新标识卡"
|
|
16
16
|
],
|
|
17
17
|
"type": "module",
|
|
18
18
|
"author": {
|
package/src/dailog/dialog.vue
CHANGED
|
@@ -142,7 +142,7 @@ const domInfo = reactive({
|
|
|
142
142
|
baseW: 0,
|
|
143
143
|
baseH: 0
|
|
144
144
|
})
|
|
145
|
-
const
|
|
145
|
+
const containers = ref<HTMLElement>(null)
|
|
146
146
|
|
|
147
147
|
const updateTarget = (event: MouseEvent) => {
|
|
148
148
|
if (!MyDialogRef.value) {
|
|
@@ -180,7 +180,7 @@ const onTdMousedown = (e: MouseEvent) => {
|
|
|
180
180
|
|
|
181
181
|
<div id="dia">
|
|
182
182
|
<el-dialog
|
|
183
|
-
class="
|
|
183
|
+
class="containers"
|
|
184
184
|
v-if="dialogVisible"
|
|
185
185
|
v-model="dialogVisible"
|
|
186
186
|
:title="title"
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-popover
|
|
2
|
+
<el-popover
|
|
3
|
+
placement="bottom"
|
|
4
|
+
:width="300"
|
|
5
|
+
:trigger="props.otherConfig?.trigger || 'hover'"
|
|
6
|
+
>
|
|
3
7
|
<el-upload
|
|
4
8
|
ref="upload"
|
|
5
9
|
class="upload-demo"
|
|
@@ -16,7 +20,14 @@
|
|
|
16
20
|
v-model:file-list="fileList"
|
|
17
21
|
>
|
|
18
22
|
<template #trigger>
|
|
19
|
-
<el-button
|
|
23
|
+
<el-button
|
|
24
|
+
size="small"
|
|
25
|
+
type="primary"
|
|
26
|
+
style="width: 100%"
|
|
27
|
+
plain
|
|
28
|
+
>
|
|
29
|
+
选择文件
|
|
30
|
+
</el-button>
|
|
20
31
|
</template>
|
|
21
32
|
<el-button
|
|
22
33
|
size="small"
|
|
@@ -28,14 +39,32 @@
|
|
|
28
39
|
</el-button>
|
|
29
40
|
</el-upload>
|
|
30
41
|
|
|
31
|
-
<div
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
<div
|
|
43
|
+
style="width: 100%; display: flex"
|
|
44
|
+
v-if="url"
|
|
45
|
+
>
|
|
46
|
+
<el-button
|
|
47
|
+
size="small"
|
|
48
|
+
@click="visible = false"
|
|
49
|
+
style="flex: 1"
|
|
50
|
+
>
|
|
51
|
+
取消
|
|
52
|
+
</el-button>
|
|
53
|
+
<el-button
|
|
54
|
+
size="small"
|
|
55
|
+
type="primary"
|
|
56
|
+
@click="submitUpload"
|
|
57
|
+
style="flex: 2"
|
|
58
|
+
>
|
|
34
59
|
上传
|
|
35
60
|
</el-button>
|
|
36
61
|
</div>
|
|
37
62
|
<template #reference>
|
|
38
|
-
<el-button
|
|
63
|
+
<el-button
|
|
64
|
+
type="success"
|
|
65
|
+
@click="visible = true"
|
|
66
|
+
:size="props.otherConfig?.size || 'small'"
|
|
67
|
+
>
|
|
39
68
|
{{ props.title || '附件上传' }}
|
|
40
69
|
</el-button>
|
|
41
70
|
</template>
|
|
@@ -72,7 +101,7 @@ const fileArr = (url: string, pathArr: string[]) => {
|
|
|
72
101
|
objArr.push({
|
|
73
102
|
name: item.name,
|
|
74
103
|
oldName: item.oldName,
|
|
75
|
-
url: url + item.oldName
|
|
104
|
+
url: url + item.oldName,
|
|
76
105
|
})
|
|
77
106
|
})
|
|
78
107
|
return objArr
|
|
@@ -87,35 +116,53 @@ import {
|
|
|
87
116
|
ElMessage,
|
|
88
117
|
ElLoading,
|
|
89
118
|
ElButton,
|
|
90
|
-
ElPopover
|
|
119
|
+
ElPopover,
|
|
120
|
+
ElUpload,
|
|
91
121
|
} from 'element-plus'
|
|
92
|
-
import axios from 'axios'
|
|
93
122
|
import type {
|
|
94
123
|
UploadFile,
|
|
95
124
|
UploadFiles,
|
|
96
125
|
UploadInstance,
|
|
97
126
|
UploadProps,
|
|
98
|
-
UploadUserFile
|
|
127
|
+
UploadUserFile,
|
|
99
128
|
} from 'element-plus'
|
|
129
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
130
|
+
import ajaxBox from '../utils/ajaxBox'
|
|
100
131
|
const upload = ref<UploadInstance>()
|
|
101
132
|
const exporLoading = ref()
|
|
102
133
|
const visible = ref(false)
|
|
103
134
|
|
|
104
135
|
interface Props {
|
|
105
136
|
url?: string // 上传和下载模板的接口(当需要将附件传递回父组件时不需要传递此属性)
|
|
106
|
-
parameter?:
|
|
107
|
-
data?:
|
|
137
|
+
parameter?: Object // 模板下载的时候请求需要携带的参数:{state: 1}
|
|
138
|
+
data?: Object //上传携带的其他数据对象:{userId: 1, userName: '张三'}
|
|
108
139
|
title?: string // 上传按钮的名称
|
|
109
140
|
multiple?: boolean // 是否支持多文件
|
|
110
141
|
limit?: number // 最大文件数量
|
|
111
142
|
filePath?: UploadFile[] //UploadRawFile[] // 父组件传递的附件数据,用于显示附件列表和上传附件后传递给父组件附件数据
|
|
112
|
-
RowIndex?: number // 父组件传递的行索引,用于父组件中删除了附件找到对应的行
|
|
143
|
+
RowIndex?: number // 父组件传递的行索引,用于父组件中删除了附件找到对应的行(用于表格表单中上传附件)
|
|
144
|
+
templateName?: string //模板名称
|
|
145
|
+
timeOn?: boolean // 是否开启耗时任务 默认不开启
|
|
146
|
+
// 其他的一些配置:请求的baseurl地址,有耗时任务的时候耗时任务的配置,模板下载的一些配置等
|
|
147
|
+
otherConfig: {
|
|
148
|
+
size?: 'large' | 'default' | 'small' // 按钮大小
|
|
149
|
+
trigger?: 'click' | 'focus' | 'hover' | 'contextmenu' // 按钮触发方式 默认 hover
|
|
150
|
+
baseUrl?: string // 上请求的baseurl地址
|
|
151
|
+
datakey: string // 耗时请求的参数key值
|
|
152
|
+
// 耗时任务的配置
|
|
153
|
+
timeConfig: {
|
|
154
|
+
url: string
|
|
155
|
+
method: 'put' | 'post' | 'get' | 'PUT' | 'POST' | 'GET'
|
|
156
|
+
data?: object // 可选属性
|
|
157
|
+
params?: object // 可选属性
|
|
158
|
+
}
|
|
159
|
+
}
|
|
113
160
|
}
|
|
114
161
|
const props = defineProps<Props>()
|
|
115
162
|
const emits = defineEmits<{
|
|
116
163
|
(e: 'reloadTable'): void // 组件中上传附件后刷新父组件表格数据方法
|
|
117
|
-
(e: 'getFile', files: UploadFiles, file?: UploadFile, rowindex?: number): void
|
|
118
|
-
(e: 'update:file', files: UploadFiles): void
|
|
164
|
+
(e: 'getFile', files: UploadFiles, file?: UploadFile, rowindex?: number): void // 编辑表单的时候回显附件用到
|
|
165
|
+
(e: 'update:file', files: UploadFiles): void // 编辑表单的时候回显附件用到
|
|
119
166
|
}>()
|
|
120
167
|
console.log('附件props: ', props)
|
|
121
168
|
const datas = ref(props.data)
|
|
@@ -167,38 +214,105 @@ const submitUpload = () => {
|
|
|
167
214
|
visible.value = false
|
|
168
215
|
}
|
|
169
216
|
//文件上传成功回调
|
|
170
|
-
const onSuccess = (res: any, file: any, fileList: any) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
217
|
+
const onSuccess = async (res: any, file: any, fileList: any) => {
|
|
218
|
+
console.log('fileList: ', fileList)
|
|
219
|
+
console.log('file: ', file)
|
|
220
|
+
console.log('上传成功回调: ', res)
|
|
221
|
+
// exporLoading.value.close() // 关闭加载动画
|
|
222
|
+
if (res.code !== 200) {
|
|
223
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
224
|
+
exporLoading.value.close() // 关闭加载动画
|
|
225
|
+
return ElMessage.warning(res.msg)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 判断是否要走耗时逻辑
|
|
229
|
+
if (!props.timeOn || !res.data) {
|
|
230
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
231
|
+
visible.value = false // 关闭上传面板
|
|
232
|
+
exporLoading.value.close() // 关闭加载动画
|
|
233
|
+
ElMessage.success(res.msg)
|
|
234
|
+
emits('reloadTable')
|
|
235
|
+
return
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// 处理耗时请求的参数
|
|
239
|
+
let datas = {}
|
|
240
|
+
datas[props.otherConfig?.datakey] = res.data.task_id
|
|
241
|
+
// 耗时轮训
|
|
242
|
+
const data = await askForTask(datas)
|
|
243
|
+
console.log('data: ', data)
|
|
244
|
+
if (data.code === 200) {
|
|
245
|
+
// fileList.value.length = 0 // 清空文件列表
|
|
246
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
247
|
+
visible.value = false // 关闭上传面板
|
|
248
|
+
exporLoading.value.close() // 关闭加载动画
|
|
249
|
+
ElMessage.success(data.msg)
|
|
250
|
+
emits('reloadTable')
|
|
251
|
+
} else if (data.code === 0) {
|
|
252
|
+
exporLoading.value.close() // 关闭加载动画
|
|
253
|
+
ElMessage.success(data.msg || '导入失败')
|
|
254
|
+
} else {
|
|
255
|
+
ElMessage.success(data.msg || '请求超时或者其他错误,请联系管理员.')
|
|
256
|
+
}
|
|
175
257
|
}
|
|
176
258
|
//文件上传失败回调
|
|
177
259
|
const onError = (response: any, file: any, fileList: any) => {
|
|
178
|
-
|
|
260
|
+
console.log('上传失败回调: ', response)
|
|
261
|
+
ElMessage.error(file.name + '上传失败')
|
|
262
|
+
// fileList.value.length = 0 // 清空文件列表
|
|
263
|
+
upload.value!.clearFiles() // 清空文件列表
|
|
264
|
+
visible.value = false // 关闭上传面板
|
|
265
|
+
exporLoading.value.close() // 关闭加载动画
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// 耗时请求函数
|
|
269
|
+
const askForTask: (task_info: any) => Promise<any> = async (task_info: any) => {
|
|
270
|
+
// 处理父组件传递的配置
|
|
271
|
+
const axiosConfig: AxiosRequestConfig = {
|
|
272
|
+
...props.otherConfig?.timeConfig,
|
|
273
|
+
}
|
|
274
|
+
// 处理请求的参数
|
|
275
|
+
if (
|
|
276
|
+
props.otherConfig?.timeConfig?.method === 'get' ||
|
|
277
|
+
props.otherConfig?.timeConfig?.method === 'GET'
|
|
278
|
+
) {
|
|
279
|
+
axiosConfig.params = {
|
|
280
|
+
...props.otherConfig?.timeConfig.params,
|
|
281
|
+
...task_info,
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
axiosConfig.data = {
|
|
285
|
+
...props.otherConfig?.timeConfig.data,
|
|
286
|
+
...task_info,
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const res = await axios(axiosConfig)
|
|
291
|
+
// 如果返回的code是50001 就继续轮询,直到返回的code不是50001
|
|
292
|
+
if (res.data.code === 50001)
|
|
293
|
+
return await new Promise((resolve) => {
|
|
294
|
+
setTimeout(() => resolve(askForTask(task_info)), 2000)
|
|
295
|
+
})
|
|
296
|
+
return res.data
|
|
297
|
+
} catch (error) {
|
|
298
|
+
console.error('Error fetching task:', error)
|
|
299
|
+
throw error
|
|
300
|
+
}
|
|
179
301
|
}
|
|
180
302
|
|
|
181
303
|
//下载模板
|
|
182
304
|
const formwork = () => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
305
|
+
const url = props.url + '_get/'
|
|
306
|
+
const params = props.parameter
|
|
307
|
+
ajaxBox.downFileFetchV2(url, params, {
|
|
308
|
+
method: 'GET',
|
|
309
|
+
fileName: props.templateName || '模板.xlsx',
|
|
188
310
|
})
|
|
189
|
-
.then((res) => {
|
|
190
|
-
const url = URL.createObjectURL(new Blob([res.data]))
|
|
191
|
-
let link: HTMLAnchorElement | null = document.createElement('a')
|
|
192
|
-
link.href = url
|
|
193
|
-
link.setAttribute('download', '模板.xlsx')
|
|
194
|
-
document.body.appendChild(link)
|
|
195
|
-
link.click()
|
|
196
|
-
link = null
|
|
197
|
-
})
|
|
198
|
-
.catch((error) => {
|
|
199
|
-
console.log(error)
|
|
200
|
-
})
|
|
201
311
|
}
|
|
202
312
|
</script>
|
|
203
313
|
|
|
204
|
-
<style scoped
|
|
314
|
+
<style scoped lang="scss">
|
|
315
|
+
:deep(.el-upload) {
|
|
316
|
+
width: calc(100% - 110px);
|
|
317
|
+
}
|
|
318
|
+
</style>
|