WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2024-05-16 bc8f7123657eb2dde8a328928140c94ea0cc3d29
forms/imagePicker/CImagePicker.vue
@@ -21,9 +21,9 @@
            :showAddBtn="!selectedFull"
            :length="3"
            :files="files"
            :onChange="(files,operationType,index)=>handleChange(files,operationType,index)"
            :onFail="evt=>handleFail(evt)"
            :onImageClick="(index, file)=>handleImgView(index,file)"
            :onChange="(files,operationType,index) => handleChange(files,operationType,index)"
            :onFail="evt => handleFail(evt)"
            :onImageClick="(index, file) => handleImgView(index,file)"
        />
        <CImageCompressor ref="compressor" />
        <CImagePreview ref="imgPreview" />
@@ -68,6 +68,11 @@
            type: Object,
            default: () => {},
        },
        // 是否开启缩略图
        needThumb: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        return {
@@ -110,7 +115,7 @@
                    if (file.file && file.file.originalFileObj) {
                        if (
                            /image\/(gif|png|jpg|jpeg)/.test(
                                file.file.originalFileObj.type
                                file.file.originalFileObj.type,
                            )
                        ) {
                            return true;
@@ -213,7 +218,10 @@
                        callback(state, res);
                    }
                },
                this.params
                $fetchCommon.transKeyName('underline', {
                    ...this.params,
                    needThumb: this.needThumb ? 1 : 0,
                }),
            );
        },
    },
@@ -233,7 +241,7 @@
// 图片上传节流
const _readyUpload = {};
export const uploadImage = (files, callback, params) => {
export const uploadImage = (files, callback, formData = {}) => {
    if (!files || files.length === 0) {
        callback('success', []);
        return;
@@ -277,7 +285,7 @@
                        ...requestFile,
                        header,
                        name: 'file',
                        formData: { ...params },
                        formData,
                        timeout: 30 * 1000,
                        success(res) {
                            let res2;
@@ -298,7 +306,7 @@
                            if (res2.state.code === 2000) {
                                const imgUrl = $fetchCommon.transImgPath(
                                    'fix',
                                    res2.data.src || res2.data.file || res2.data.url
                                    res2.data.src || res2.data.file || res2.data.url,
                                );
                                _readyUpload[file.url] = imgUrl;
                                resolve(imgUrl);
@@ -325,7 +333,7 @@
                            });
                        },
                    });
                })
                }),
            );
        }
        // 其他类型视为 url,忽略