yangfeng
2023-08-29 5159d19ed210ec3e14d157f9ae6221299bd46e34
src/views/supplierManage/supplier/AddSupplier.vue
@@ -160,7 +160,7 @@
                      <span style="margin-left: 5px">合同附件</span>
                    </div>
                  </template>
                  <div class="annex-view">
                  <div v-if="file_id === 0" class="annex-view">
                    <div @click="addAnnexClick">
                      <el-upload
                        class="upload-demo"
@@ -178,13 +178,15 @@
                      </el-upload>
                    </div>
                  </div>
                  <div v-if="file_name && file_name.length > 0" class="file-content">
                  <!-- v-if="file_name && file_name.length > 0" -->
                  <div v-else class="file-content">
                    <div>{{ file_name }}</div>
                    <div>
                      <el-button type="text">预览</el-button>
                      <el-button type="text">下载</el-button>
                      <el-button type="text">删除</el-button>
                      <el-button type="text" @click="previewClick" style="margin-left: 10px">预览</el-button>
                      <el-button type="text" @click="downloadClick">下载</el-button>
                      <el-button type="text" @click="delContractClick">删除</el-button>
                    </div>
                    <div ref="file"></div>
                  </div>
                </el-form-item>
              </el-col>
@@ -208,11 +210,15 @@
  createContract,
  updateSupplier,
  getIndustryList,
  previewContract
  getSupplierTypeList,
  deleteContract
  // previewContract
} from "@/api/supplierManage/supplier"
import EditDropdownDialog from "@/views/other/commonDialog/EditDropdownDialog"
import { getSupplierTypeList } from "@/api/supplierManage/supplier"
import { getMemberListFromGrpc } from "@/api/common/other"
import download from "downloadjs"
// import { renderAsync } from "docx-preview"
// import axios from "axios"
export default {
  name: "AddSupplierDialog",
  props: {
@@ -263,8 +269,10 @@
        infomation: {}
      },
      fileList: [],
      file_name: "",
      file_id: this.addCommonConfig.infomation.fileId
      file_name: this.addCommonConfig.infomation.file_name,
      file_id: this.addCommonConfig.infomation.fileId,
      previewUrl: "",
      loading: false
    }
  },
  created() {
@@ -272,7 +280,7 @@
    this.getIndustryList()
    this.getMemberList()
    if (this.editConfig.title === "修改") {
      this.previewContract()
      // this.previewContract()
    }
  },
  methods: {
@@ -302,14 +310,6 @@
        pageSize: 100
      }).then((res) => {
        this.industryOptions = res.data.data.list
      })
    },
    // 合同附件信息
    async previewContract() {
      await previewContract({
        id: 1
      }).then((res) => {
        console.log(res.data)
      })
    },
    handleClose() {
@@ -364,7 +364,7 @@
        name: data.name || "",
        number: data.number || "",
        phone: data.phone || "",
        responsiblePersonId: data.responsiblePersonId || 0,
        responsiblePersonName: data.responsiblePersonName || "",
        status: data.status || 0,
        supplierType: data.supplierType || "",
        url: data.url || ""
@@ -416,6 +416,37 @@
    handleExceed(files, fileList) {
      console.log(fileList)
      this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件`)
    },
    // 下载合同
    downloadClick() {
      let url = "/api/con/downloadContract?id=" + this.file_id
      download(url, "", "")
    },
    // 删除合同
    delContractClick() {
      deleteContract({
        id: this.file_id
      }).then((res) => {
        console.log(res)
        this.$message.success(res.msg)
        this.file_id = 0
      })
    },
    // 预览合同
    async previewClick() {
      this.previewUrl = "/api/con/previewContract?id=" + this.file_id
      if (this.file_name.includes("pdf")) {
        window.open(this.previewUrl, "_blank")
      } else {
        let routeUrl = this.$router.resolve({
          path: "/PreviewFile",
          query: {
            //要传的参数
            previewUrl: this.previewUrl
          }
        })
        window.open(routeUrl.href, "_blank")
      }
    }
  }
}