ci-plus 1.1.3 → 1.1.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
CHANGED
|
@@ -31,20 +31,13 @@ defineOptions({ name: 'ci-seeFile' })
|
|
|
31
31
|
import { ref, watch } from 'vue'
|
|
32
32
|
import axios from 'axios'
|
|
33
33
|
import { ElMessage } from 'element-plus'
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
35
36
|
url?: string[] // 传入要显示的附件地址数组
|
|
36
37
|
baseUrl?: string // 图片展示的基础路径
|
|
37
|
-
}
|
|
38
|
-
/*
|
|
39
|
-
数据结构说明:
|
|
40
|
-
props.url:[
|
|
41
|
-
"media/material/3.1708222741.7763922.webp",
|
|
42
|
-
"media/material/3号(number-3)_爱给网_aigei_com.1708222741.7783866.png"
|
|
43
|
-
]
|
|
38
|
+
}
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
props.baseUrl : http://10.20.72.231:9999/
|
|
47
|
-
*/
|
|
40
|
+
const props = defineProps<Props>()
|
|
48
41
|
|
|
49
42
|
// 定义一个函数,用于处理字符串
|
|
50
43
|
export const setFilePath = (arr: string[], url?: string) => {
|
|
@@ -85,9 +78,6 @@ export const fileArr = (url: string, pathArr: string[]) => {
|
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
const emits = defineEmits(['onClick'])
|
|
88
|
-
|
|
89
|
-
// console.log('props', props.url)
|
|
90
|
-
|
|
91
81
|
const pathArr = ref<any[]>([])
|
|
92
82
|
// 对数组中的每个字符串应用处理函数
|
|
93
83
|
// @ts-ignore
|
|
@@ -97,7 +87,6 @@ pathArr.value = setFilePath(props.url, props.baseUrl || 'http://10.20.72.231:999
|
|
|
97
87
|
watch(
|
|
98
88
|
() => props.url,
|
|
99
89
|
(newVal) => {
|
|
100
|
-
// console.log('newVal: ', newVal)
|
|
101
90
|
// 对新值进行处理
|
|
102
91
|
// @ts-ignore
|
|
103
92
|
pathArr.value = setFilePath(newVal, props.baseUrl || 'http://10.20.72.231:9999/')
|
|
@@ -95,18 +95,18 @@ import type {
|
|
|
95
95
|
const upload = ref<UploadInstance>()
|
|
96
96
|
const exporLoading = ref()
|
|
97
97
|
const visible = ref(false)
|
|
98
|
-
// const filelist = ref([])
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
interface Props {
|
|
101
100
|
url?: string // 上传和下载模板的接口(当需要将附件传递回父组件时不需要传递此属性)
|
|
102
|
-
parameter?: () =>
|
|
103
|
-
data?: () =>
|
|
101
|
+
parameter?: () => void // 模板下载的时候请求需要携带的参数:{state: 1}
|
|
102
|
+
data?: () => void //上传携带的其他数据对象:{userId: 1, userName: '张三'}
|
|
104
103
|
title?: string // 上传按钮的名称
|
|
105
104
|
multiple?: boolean // 是否支持多文件
|
|
106
105
|
limit?: number // 最大文件数量
|
|
107
106
|
filePath?: UploadFile[] //UploadRawFile[] // 父组件传递的附件数据,用于显示附件列表和上传附件后传递给父组件附件数据
|
|
108
107
|
RowIndex?: number // 父组件传递的行索引,用于父组件中删除了附件找到对应的行
|
|
109
|
-
}
|
|
108
|
+
}
|
|
109
|
+
const props = defineProps<Props>()
|
|
110
110
|
const emits = defineEmits<{
|
|
111
111
|
(e: 'reloadTable'): void // 组件中上传附件后刷新父组件表格数据方法
|
|
112
112
|
(e: 'getFile', files: UploadFiles, file?: UploadFile, rowindex?: number): void
|
|
@@ -133,22 +133,11 @@ console.log('fileList: ', fileList.value)
|
|
|
133
133
|
const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
134
134
|
console.log('超出限制: ', files)
|
|
135
135
|
ElMessage.warning(`超出最大文件数:${mylimit?.value}个文件,请重新选择`)
|
|
136
|
-
// upload.value!.clearFiles()
|
|
137
|
-
// const file = files[0] as UploadRawFile
|
|
138
|
-
// file.uid = genFileId()
|
|
139
|
-
// upload.value!.handleStart(file)
|
|
140
136
|
}
|
|
141
137
|
|
|
142
138
|
// 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
|
|
143
139
|
const handleChange = (file: any, fileLists: any) => {
|
|
144
|
-
// console.log('file: ', file)
|
|
145
|
-
// console.log('fileList: ', fileLists)
|
|
146
|
-
// filelist.value = fileLists //更新文件列表数据
|
|
147
|
-
// 如果没有url就将选中的附件文件流传递回父组件
|
|
148
140
|
if (!props.url) {
|
|
149
|
-
// const files: UploadRawFile[] = fileLists.map(
|
|
150
|
-
// (item) => item.raw,
|
|
151
|
-
// ) as UploadRawFile[]
|
|
152
141
|
emits('getFile', fileLists) //将选中的文件传递回父组件
|
|
153
142
|
emits('update:file', fileLists) //同步父组件绑定的附件字段,以便父组件提交表单的时候一起将附件提交
|
|
154
143
|
}
|
|
@@ -159,9 +148,6 @@ const handleRemove: UploadProps['onRemove'] = (file, fileList) => {
|
|
|
159
148
|
console.log('fileList: ', fileList)
|
|
160
149
|
// 如果没有url时 在删除的时候将文件流同步回父组件
|
|
161
150
|
if (!props.url) {
|
|
162
|
-
// const files: UploadRawFile[] = fileList.map(
|
|
163
|
-
// (item) => item.raw,
|
|
164
|
-
// ) as UploadRawFile[]
|
|
165
151
|
emits('getFile', fileList, file, props.RowIndex)
|
|
166
152
|
emits('update:file', fileList)
|
|
167
153
|
}
|