wt 3 anos atrás
pai
commit
31bfe3089b
1 arquivos alterados com 32 adições e 27 exclusões
  1. 32 27
      src/views/system/product/index.vue

+ 32 - 27
src/views/system/product/index.vue

@@ -81,8 +81,7 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="公司LOGO" prop="logo" ref="img">
-              <!-- <el-checkbox-group v-model="form.logo" v-show="false"></el-checkbox-group> -->
+            <!-- <el-form-item label="公司LOGO" prop="logo" ref="img">
                 <el-upload
                   action="#"
                   accept="image/png,image/jpg,image/jpeg"
@@ -106,6 +105,19 @@
               <el-dialog :visible.sync="dialogVisible" >
                 <img width="100%" :src="dialogImageUrl" alt="">
               </el-dialog>
+            </el-form-item> -->
+            <el-form-item label="单位LOGO" prop="logo" ref="img">
+              <el-upload
+                class="upload-demo"
+                action="#"
+                :limit = 1
+                :on-change="handleChange"
+                :file-list="fileList"
+                :auto-upload="false"
+                accept=".jpg,.jpeg,.JPG,.JPEG,.PNG,.png,.GIF,.gif"   
+                >
+                <el-button size="small" type="primary">点击上传</el-button>
+              </el-upload>
             </el-form-item>
          </el-col>
         </el-row>
@@ -169,7 +181,7 @@ export default {
         logo:"",
         batchNo:undefined,
         businessType:"产品logo",
-        uploadType:"file"
+        uploadType:"file",
       },
       // 表单校验
       rules: {
@@ -192,6 +204,7 @@ export default {
       },
       formData:undefined,
       limit:100,
+      num:0,
     };
   },
   created() {
@@ -282,13 +295,9 @@ export default {
       this.form.name =undefined
       this.form.introduce =undefined
       this.form.logo =undefined
-      this.form.batchNo =undefined
       this.reset();
       this.open = true;
       this.title = "添加参数";
-      setTimeout(()=>{
-        document.getElementsByClassName("el-upload--picture-card")[0].style.display="block"
-      },200)
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
@@ -302,16 +311,6 @@ export default {
       Object.assign(this.form, row.id ? this.adminList.find(val=>val.id === row.id) : this.adminList.find(val=>val.id === this.ids[0]))
       this.open = true;
       this.title = "修改参数";
-      setTimeout(() =>{
-        if(this.fileList.length>0){
-        }else{
-          this.fileList.push([])
-          this.fileList[0].url = row.logo
-        }
-        document.getElementsByClassName("el-upload--picture-card")[0].style.display="none"
-      },100)
-      this.limit = 1
-      // });
     },
     // 图片上传尺寸大小检验
     beforeUpload (file) {
@@ -355,18 +354,23 @@ export default {
         };
       });
     },
-    uploadFile(param){
+    handleChange(param){
       this.limit = 1
-      document.getElementsByClassName("el-upload--picture-card")[0].style.display="none"
-      fileId().then(res=>{
-        this.$nextTick(() => {
-            this.$refs['form'].clearValidate(['logo']);
+      this.num++
+      if(this.num>1){
+        this.num = 0
+        return false
+      }else{
+        fileId().then(res=>{ //获取文件批号
+          this.$nextTick(() => {
+              this.$refs['form'].clearValidate(['logo']);
+          })
+          this.form.batchNo = res.data
+          this.form.logo = res.data
+          this.formData = new FormData()// FormData 对象
+          this.formData.append('files', param.raw)
         })
-        this.form.batchNo = res.msg
-        this.form.logo = res.msg
-        this.formData = new FormData()// FormData 对象
-        this.formData.append('files', param.file)// 文件对象
-      })
+      }
     },
     handSuccess(){
       this.$refs.img.clearValidate();
@@ -385,6 +389,7 @@ export default {
         if (valid) {
           this.loading = true
           // 上传图片
+          this.form.businessType = "产品logo",
           uploadFileApi(this.form.batchNo,this.form.businessType,this.formData).then(response => {
             if(response.data.length>0){
               let ids = new FormData()