From 1888b426ff2b6a529f5fdef0f0453dadef71824b Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期三, 17 四月 2024 10:17:38 +0800 Subject: [PATCH] 隐藏多单位的问题 --- src/views/productManage/product/IconCropper.vue | 40 ++++++++++++++++++++++++++++++---------- 1 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/views/productManage/product/IconCropper.vue b/src/views/productManage/product/IconCropper.vue index 4a2cf7c..ee360dc 100644 --- a/src/views/productManage/product/IconCropper.vue +++ b/src/views/productManage/product/IconCropper.vue @@ -2,7 +2,7 @@ <div class="cropper-wrapper"> <div v-if="isView"> <el-image :src="imageUrl" class="view-image"> - <div slot="error" class="image-slot"> + <div slot="error" class="image-slot no-cursor"> <i class="el-icon-picture-outline"></i> </div> </el-image> @@ -123,19 +123,34 @@ infoTrue: true // true 涓哄睍绀虹湡瀹炶緭鍑哄浘鐗囧楂� false 灞曠ず鐪嬪埌鐨勬埅鍥炬瀹介珮 }, // 闃叉閲嶅鎻愪氦 - loading: false + loading: false, + fileName: "" + } + }, + computed: { + myIsView() { + return this.isView + } + }, + watch: { + myIsView() { + this.setImgMethods() } }, mounted() { console.log(this.imageUrl) - if (!this.isView && this.imageUrl?.length > 0) { - this.isPreview = true - this.previewImg = this.imageUrl - } else { - this.isPreview = false - } + this.setImgMethods() }, methods: { + // 璁剧疆涓婁紶/鏇存崲鍥剧墖鏄剧ず鏂规硶 + setImgMethods() { + if (!this.isView && this.imageUrl?.length > 0) { + this.isPreview = true + this.previewImg = this.imageUrl + } else { + this.isPreview = false + } + }, // 涓婁紶鎸夐挳 闄愬埗鍥剧墖澶у皬鍜岀被鍨� handleChangeUpload(file, fileList) { const isJPG = file.raw.type === "image/jpeg" || file.raw.type === "image/png" @@ -149,6 +164,7 @@ return false } console.log(file, fileList) + this.fileName = file.name // 涓婁紶鎴愬姛鍚庡皢鍥剧墖鍦板潃璧嬪�肩粰瑁佸壀妗嗘樉绀哄浘鐗� this.$nextTick(async () => { // base64鏂瑰紡 @@ -205,8 +221,12 @@ this.dialogVisible = false this.previewImg = URL.createObjectURL(blob) this.isPreview = true - console.log(blob) - this.$emit("getImageData", blob) + // blob杞琭ile + let file = new File([blob], this.fileName, { type: blob.type }) + // file杞琭ormData + let formData = new FormData() + formData.append("files", file) + this.$emit("getImageData", formData) }) // 鑾峰彇鎴浘鐨� base64 鏁版嵁 // this.$refs.cropper.getCropData(data => { -- Gitblit v1.8.0