tong vor 4 Jahren
Ursprung
Commit
964329c672
2 geänderte Dateien mit 95 neuen und 46 gelöschten Zeilen
  1. 68 0
      src/components/Uploadfile/index.vue
  2. 27 46
      src/views/warehouseBusiness/inStock/index.vue

+ 68 - 0
src/components/Uploadfile/index.vue

@@ -0,0 +1,68 @@
+<template>
+  <div class="component-upload-image">
+    <el-upload
+      :action="uploadImgUrl"
+      list-type="picture-card"
+      :on-success="handleUploadSuccess"
+      :before-upload="handleBeforeUpload"
+      :on-error="handleUploadError"
+      name="file"
+      :show-file-list="false"
+      :headers="headers"
+      style="display: inline-block; vertical-align: top"
+    >
+      <img v-if="value" :src="value" class="avatar" />
+      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+    </el-upload>
+  </div>
+</template>
+
+<script>
+import { getToken } from "@/utils/auth";
+
+export default {
+  components: {},
+  data() {
+    return {
+      uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
+      headers: {
+        Authorization: "Bearer " + getToken(),
+      },
+    };
+  },
+  props: {
+    value: {
+      type: String,
+      default: "",
+    },
+  },
+  methods: {
+    handleUploadSuccess(res) {
+      this.$emit("input", res.url);
+      this.loading.close();
+    },
+    handleBeforeUpload() {
+      this.loading = this.$loading({
+        lock: true,
+        text: "上传中",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+    },
+    handleUploadError() {
+      this.$message({
+        type: "error",
+        message: "上传失败",
+      });
+      this.loading.close();
+    },
+  },
+  watch: {},
+};
+</script>
+
+<style scoped lang="scss">
+.avatar {
+  width: 100%;
+  height: 100%;
+}
+</style>

+ 27 - 46
src/views/warehouseBusiness/inStock/index.vue

@@ -966,50 +966,16 @@
           </template>
         </el-table-column>
         <el-table-column
-          prop="attachId"
-          header-align="center"
-          align="center"
-          width="250PX"
-          label="上传附件"
-        >
-          <template slot-scope="scope">
-            <el-button style="float: left; height: 38px">
-              <a
-                :href="scope.row.attachId"
-                target="_blank"
-                class="buttonText"
-                style="float: left; margin-left: 1px"
-                >查看</a
-              >
-            </el-button>
-            <el-upload
-              class="upload-demo"
-              ref="upload"
-              action="node"
-              :on-change="checkType"
-              :disabled="browseStatus"
-              :show-file-list="false"
-              :auto-upload="false"
-              style="float: left"
-            >
-              <el-button
-                slot="trigger"
-                @click="clickAttachId(scope.$index)"
-                size="small"
-                type="primary"
-                style="margin-left: 5px"
-                >上传
-              </el-button>
-            </el-upload>
-            <el-button
-              style="margin-left: 5px"
-              @click.native.prevent="deleteAttach(scope.row)"
-              :disabled="browseStatus"
-              size="small"
-              >删除
-            </el-button>
-          </template>
-        </el-table-column>
+  prop="attachId"
+  header-align="center"
+  align="center"
+  width="250PX"
+  label="上传附件"
+>
+  <template slot-scope="scope">
+    <uploadImage @input="showFile" v-model="scope.row.fUrl"/>
+  </template>
+</el-table-column>
         <el-table-column
           header-align="center"
           align="center"
@@ -1800,10 +1766,12 @@ import { listWarehouse } from "@/api/basicdata/warehouse";
 import { listGoods } from "@/api/basicdata/goods";
 
 import { listUser, queryUserVal } from "@/api/system/user";
-
+import UploadImage from '@/components/UploadImage'
 export default {
   name: "Warehousebills",
-  components: {},
+  components: {
+    UploadImage
+  },
   data() {
     return {
       // 遮罩层
@@ -1999,6 +1967,10 @@ export default {
     });
   },
   methods: {
+    // 上传成功返回数据
+    showFile (row) {
+  console.log(row)
+    },
     printSomething() {
       // 此处的style即为打印时的样式
       const style =
@@ -2010,6 +1982,15 @@ export default {
         scanStyles: false,
       });
     },
+    // 添加附件上传
+    addRelevt() {
+      this.relevantAttachments.push({
+        fUrl: null,
+        fName: null,
+        createBy: this.queryParams.createBy,
+        createTime: Date.parse(new Date())
+      })
+    },
     // 添加list
     addRelevant() {
       console.log(JSON.stringify(this.dataList));