WebApp【公共组件库】@前端(For Git Submodule)
‘chensiAb’
2025-03-25 08c9d23e86b545a34e00a5fb5dae81ebabe50dea
forms/imagePicker/CImagePicker.vue
@@ -68,6 +68,16 @@
            type: Object,
            default: () => {},
        },
        // 是否开启缩略图
        needThumb: {
            type: Boolean,
            default: false,
        },
        // 上传地址来源
        uploadUrlSource: {
            type: String,
            default: '',
        },
    },
    data() {
        return {
@@ -110,7 +120,7 @@
                    if (file.file && file.file.originalFileObj) {
                        if (
                            /image\/(gif|png|jpg|jpeg)/.test(
                                file.file.originalFileObj.type
                                file.file.originalFileObj.type,
                            )
                        ) {
                            return true;
@@ -133,8 +143,13 @@
                const needs = nextFiles
                    .map((file, needIndex) => {
                        const fileInfo = file.file;
                        // 没有 file 信息对象,或者不是 blob 类型
                        if (!fileInfo || fileInfo.path.indexOf('blob') < 0) {
                        // 没有 file 信息对象,或者不是 blob、wxfile、tmp 类型
                        if (
                            !fileInfo ||
                            (fileInfo.path.indexOf('blob') < 0 &&
                                fileInfo.path.indexOf('wxfile') < 0 &&
                                fileInfo.path.indexOf('http://tmp/') < 0)
                        ) {
                            return false;
                        }
                        // 尺寸小于 1M 的图片
@@ -213,7 +228,11 @@
                        callback(state, res);
                    }
                },
                this.params
                $fetchCommon.transKeyName('underline', {
                    ...this.params,
                    needThumb: this.needThumb ? 1 : 0,
                }),
                this.uploadUrlSource,
            );
        },
    },
@@ -233,12 +252,17 @@
// 图片上传节流
const _readyUpload = {};
export const uploadImage = (files, callback, params) => {
export const uploadImage = (files, callback, formData = {}, uploadUrlSource) => {
    if (!files || files.length === 0) {
        callback('success', []);
        return;
    }
    let url = $fetchCommon.getUploadImgURL();
    let url = '';
    if (uploadUrlSource === 'LPG') {
        url = $fetchCommon.getLPGUploadImgURL();
    } else {
        url = $fetchCommon.getUploadImgURL();
    }
    if (url.indexOf('http') < 0) {
        url = $hostBoot.getHost() + url;
    }
@@ -277,7 +301,7 @@
                        ...requestFile,
                        header,
                        name: 'file',
                        formData: { ...params },
                        formData,
                        timeout: 30 * 1000,
                        success(res) {
                            let res2;
@@ -298,7 +322,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 +349,7 @@
                            });
                        },
                    });
                })
                }),
            );
        }
        // 其他类型视为 url,忽略