Bladeren bron

feat: 处理rgb图片上传,兼容上传图片插件处理

332777428@qq.com 5 maanden geleden
bovenliggende
commit
8868de7be3
3 gewijzigde bestanden met toevoegingen van 54 en 11 verwijderingen
  1. 51 10
      src/components/Upload/index.vue
  2. 1 1
      src/utils/request.js
  3. 2 0
      src/views/operation/piano/index.vue

+ 51 - 10
src/components/Upload/index.vue

@@ -1,11 +1,33 @@
 <template>
   <div class="upload">
-    <el-upload v-if="isBtn()" :platformId="platformId" :action="action" :headers="headers" :multiple="multiple"
-      :data="data" :name="name" :show-file-list="showFileList" :drag="drag" :accept="accept" :listType="listType"
-      :autoUpload="autoUpload" :disabled="disabled" :before-upload="beforeUpload" :on-progress="onProgress"
-      :on-success="onSuccess" :on-error="onError" :width="width" :height="height">
+    <el-upload
+      v-if="isBtn()"
+      :platformId="platformId"
+      :action="action"
+      :headers="headers"
+      :multiple="multiple"
+      :data="data"
+      :name="name"
+      :show-file-list="showFileList"
+      :drag="drag"
+      :accept="accept"
+      :listType="listType"
+      :autoUpload="autoUpload"
+      :disabled="disabled"
+      :before-upload="beforeUpload"
+      :on-progress="onProgress"
+      :on-success="onSuccess"
+      :on-error="onError"
+      :width="width"
+      :height="height"
+    >
       <!-- <el-button v-if="listType !== 'picture-card'" :type="type" ref="upload"> -->
-      <el-button v-if="listType !== 'picture-card'" type="primary" size="mini" ref="upload">
+      <el-button
+        v-if="listType !== 'picture-card'"
+        type="primary"
+        size="mini"
+        ref="upload"
+      >
         <slot v-if="percentage <= 0 && !form.file">点击上传</slot>
         <span v-if="percentage > 0 && !form.file">{{ title }}</span>
         <span v-if="form.file">上传成功</span>
@@ -14,8 +36,14 @@
         <i class="el-icon-plus" />
       </div>
     </el-upload>
-    <el-progress v-if="isPercentage()" type="circle" :percentage="percentage" :status="status"
-      @click.native="handleUpload" :width="146" />
+    <el-progress
+      v-if="isPercentage()"
+      type="circle"
+      :percentage="percentage"
+      :status="status"
+      @click.native="handleUpload"
+      :width="146"
+    />
     <div class="img" v-if="isImg()">
       <i class="el-icon-delete" v-if="!disabled" @click="onDelete" />
       <el-image :src="form.file" />
@@ -50,6 +78,10 @@ export default {
       type: String,
       default: "text",
     },
+    listTypes: {
+      type: String,
+      default: "text",
+    },
     platformId: {
       type: Number,
       default: null,
@@ -98,6 +130,7 @@ export default {
       obj: {
         text: `${baseUrl}/system/file/file/upload`, // 文件上传
         "picture-card": `${baseUrl}/system/file/picture/upload`, // 图片上传
+        "picture-rgb": `${baseUrl}/system/file/getRGBUrl`, // 图片上传
         audio: `${baseUrl}/system/file/mp3/upload`, // 音频上传
         zip: `${baseUrl}/system/file/file/uploadFolderZip`, // 压缩包上传
         mp3: `${baseUrl}/admin/program/batch/upload`, // 歌曲批量上传
@@ -142,7 +175,13 @@ export default {
 
   created() {
     // 根据上传类型 变更 上传地址
-    this.action = this.obj[this.listType];
+    console.log("gadfqwerqewrqr===00==" + this.listType);
+    if (this.listTypes == "picture-rgb") {
+      this.action = this.obj[this.listTypes];
+    } else {
+      this.action = this.obj[this.listType];
+    }
+    console.log("gadfqwerqewrqr===11==" + this.action);
     // 回显图片
     this.form.file = this.url;
   },
@@ -158,8 +197,10 @@ export default {
         // var w = Number(this.width);
         // var h = Number(this.height);
         // 检查并转换 width 和 height 为数字
-        const w = typeof this.width === 'String' ? Number(this.width) : this.width;
-        const h = typeof this.height === 'String' ? Number(this.height) : this.height;
+        const w =
+          typeof this.width === "String" ? Number(this.width) : this.width;
+        const h =
+          typeof this.height === "String" ? Number(this.height) : this.height;
         // console.log("传入的:", w, h, "666", typeof this.height === 'string')
         const data = await this.readerImg(file);
         let _width =

+ 1 - 1
src/utils/request.js

@@ -65,7 +65,7 @@ service.interceptors.request.use(config => {
       const s_time = sessionObj.time; // 请求时间
       var interval; // 间隔时间(ms),小于此时间视为重复提交
 
-//      console.log("获取请求链接==" + JSON.stringify(config.url));
+      // console.log("获取请求链接==" + JSON.stringify(config.url));
       ///活动管理-新增赠送流量特殊处理
       if (config.url === "/admin/activity/doExchange") {
         interval = 2000;

+ 2 - 0
src/views/operation/piano/index.vue

@@ -67,9 +67,11 @@
         :rules="rules"
         label-width="auto"
       >
+        <!-- listType="picture-rbg" -->
         <el-form-item label="上传:" prop="pic">
           <Upload
             listType="picture-card"
+            listTypes="picture-rgb"
             width="480"
             height="480"
             :url="dialogData.pic"