xiaodai2022 2 years ago
parent
commit
4ab960e66c

+ 1 - 0
src/views/sellOut/zixunOrder/components/addEditForm.vue

@@ -662,6 +662,7 @@ export default {
               pgNo: e.pgNo,
               total_weight: e.total_weight,
               is_gold_price: e.is_gold_price,
+              enclosure_file:e.enclosure_file,
               specinfo: [],
             };
             e.specinfo.forEach((a) => {

+ 95 - 0
src/views/sellOut/zixunOrder/components/editForm.vue

@@ -549,6 +549,55 @@
                       </div>
                     </el-form-item>
                   </el-col>
+                  <el-col :span="8" class="clear">
+                    <el-form-item
+                      label="附件"
+                      prop="enclosure_file"
+                      class="activity-upload"
+                    >
+                      <div
+                        v-if="ruleForm && ruleForm.enclosure_file"
+                        class="clearfix tl"
+                      >
+                        <a
+                          :href="ruleForm.enclosure_file"
+                          download="附件"
+                          class="fl"
+                          >点击下载</a
+                        >
+
+                        <el-link
+                          :underline="false"
+                          v-if="type !== 'view'"
+                          @click="deleteUrl()"
+                          type="warning"
+                          style="margin: 0 0 0 16px"
+                          class="fr"
+                          >删除</el-link
+                        >
+                      </div>
+
+                      <div class="activity-upload" v-else>
+                        <div class="btnupload" style="position: relative">
+                          <i class="el-icon-plus avatar-uploader-icon"></i>
+                          <file-upload-pdf
+                            class="Upload"
+                            :accept="'.zip,.rar,.7z'"
+                            :multiple="false"
+                            :uploadcondition="beforeOtherUpload"
+                            @UploadErrorEvent="UploadErrorOtherenclosure_file"
+                            @UploadSuccessEvent="
+                              UploadSuccessOtherenclosure_file
+                            "
+                          />
+                        </div>
+                        <div class="txt-tips fl">
+                          <p>建议大小:小于5MB</p>
+                          <p>文件格式:.zip,.rar,.7z</p>
+                        </div>
+                      </div>
+                    </el-form-item>
+                  </el-col>
                   <el-col :span="8" v-show="is_noble">
                     <el-form-item label="金属种类" prop="metal_id">
                       <search-metal-kind
@@ -846,6 +895,7 @@ export default {
             p_good_img,
             p_arrtime,
             specinfo,
+            enclosure_file,
           } = JSON.parse(JSON.stringify(this.sitem));
           this.unit_name = unit_name;
           this.brand_name = brand;
@@ -908,6 +958,7 @@ export default {
             metal_id: metal_id || "",
             gold_price: gold_price || "",
             unit: unit ? [unit] : [],
+            enclosure_file: enclosure_file || "",
           };
           if (this.ruleForm.projectNo && this.ruleForm.projectNo.length === 1) {
             await this.selectChange(this.ruleForm.projectNo);
@@ -1228,6 +1279,50 @@ export default {
         this.$refs.ruleForm.validateField("good_img");
       }
     },
+    //其他文件上传失败
+    UploadErrorOtherenclosure_file(res) {
+      if (res !== "break") {
+        this.$refs.ruleForm.validateField("enclosure_file");
+      }
+    },
+
+    //判断其他文件规格
+    beforeOtherUpload(file) {
+      let isJPG = false;
+      if (file.type === "application/x-zip-compressed") {
+        isJPG = true;
+      }
+      let name = file.name;
+      let list = name.split(".");
+      if (list[list.length - 1] === "rar" || list[list.length - 1] === "7z") {
+        isJPG = true;
+      }
+
+      const isLt2M = file.size / 1024 / 1024 < 5;
+      if (!isJPG) {
+        this.$message.error("文件格式不正确!");
+      }
+      if (!isLt2M) {
+        this.$message.error("文件大小不能超过 5MB!");
+      }
+      return isJPG && isLt2M;
+    },
+
+    deleteUrl() {
+      this.ruleForm.enclosure_file = "";
+      this.$refs.ruleForm.validateField("enclosure_file");
+    },
+    // 其他文件上传成功
+    async UploadSuccessOtherenclosure_file(data) {
+      const { url } = data;
+      console.log(url);
+      if (url === "noToken") {
+        await this.logout();
+      } else {
+        this.ruleForm.enclosure_file = url;
+        this.$message.success("附件上传成功!");
+      }
+    },
   },
 };
 </script>