spring
2025-02-21 1309d6a2a55fc1cf07de57da3891a8d3230b2db8
src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue
@@ -3,23 +3,20 @@
    <el-dialog title="附件查看" :visible.sync="isShow" width="80%" @closed="$emit('closeFilesLook')">
      <div style="display: flex;justify-content: space-between;">
        <ul class="tab">
          <li v-for="(m,i) in dataVisibleTitle" :key="i" :class="{active:i===dataVisibleIndex}" @click="handleDataVisibleTab(m,i)">{{m.label}}</li>
          <li v-for="(m, i) in dataVisibleTitle" :key="i" :class="{ active: i === dataVisibleIndex }"
            @click="handleDataVisibleTab(m, i)">{{ m.label }}</li>
        </ul>
        <el-upload :action="action"
                   :auto-upload="true"
                   :data="{orderId: dataVisibleIndex === 0 ? filesLookInfo.enterOrderId : filesLookInfo.quarterOrderId}"
                   :on-success="handleSuccessUp" :show-file-list="false"
                   accept='.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar' :headers="headers"
                   :before-upload="beforeUpload"
                   style="width: 80px !important;"
                   :on-error="onError" ref='upload'>
        <el-upload :action="action" :auto-upload="true"
          :data="{ orderId: dataVisibleIndex === 0 ? filesLookInfo.enterOrderId : filesLookInfo.quarterOrderId }"
          :on-success="handleSuccessUp" :show-file-list="false"
          accept='.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar' :headers="headers"
          :before-upload="beforeUpload" style="width: 80px !important;" :on-error="onError" ref='upload'>
          <el-button size="small" type="primary" style="height: 38px">附件上传</el-button>
        </el-upload>
      </div>
      <div v-if="filesDialogVisible">
        <lims-table :tableData="tableDataFile" :column="columnFile"
                    @pagination="paginationFile" height="500px" key="tableDataFile"
                    :page="pageFile" :tableLoading="tableLoadingFile"></lims-table>
        <lims-table :tableData="tableDataFile" :column="columnFile" @pagination="paginationFile" height="500px"
          key="tableDataFile" :page="pageFile" :tableLoading="tableLoadingFile"></lims-table>
      </div>
    </el-dialog>
  </div>
@@ -29,12 +26,12 @@
import ValueTable from "@/components/Table/value-table.vue";
import file from "@/utils/file";
import limsTable from "@/components/Table/lims-table.vue";
import {delfile, downFile, getFileList} from "@/api/business/rawMaterialOrder";
import { delfile, downFile, getFileList } from "@/api/business/rawMaterialOrder";
import { getToken } from "@/utils/auth";
export default {
  name: "filesLookVisible",
  // import 引入的组件需要注入到对象中才能使用
  components: {limsTable, ValueTable},
  components: { limsTable, ValueTable },
  props: {
    filesDialogVisible: {
      type: Boolean,
@@ -42,7 +39,7 @@
    },
    filesLookInfo: {
      type: Object,
      default: () => {}
      default: () => { }
    },
  },
  data() {
@@ -74,9 +71,9 @@
            }
          }
        },
        {label: '附件名称', prop: 'fileName'},
        {label: '上传人', prop: 'name'},
        {label: '上传时间', prop: 'createTime'},
        { label: '附件名称', prop: 'fileName' },
        { label: '上传人', prop: 'name' },
        { label: '上传时间', prop: 'createTime' },
        {
          dataType: 'action',
          fixed: 'right',
@@ -101,9 +98,9 @@
        }
      ],
      pageFile: {
        total:0,
        size:10,
        current:1
        total: 0,
        size: 10,
        current: 1
      },
      isShow: this.filesDialogVisible,
      dataVisibleTitle: [
@@ -118,7 +115,7 @@
      ],
      dataVisibleIndex: 0, // tab栏选择值
      entity: {
        insOrderId:''
        insOrderId: ''
      },
    }
  },
@@ -128,7 +125,7 @@
  // 方法集合
  methods: {
    // 切换数据查看tab栏
    handleDataVisibleTab (m, i) {
    handleDataVisibleTab(m, i) {
      this.dataVisibleIndex = i
      this.getFileList()
    },
@@ -140,7 +137,7 @@
        this.entity.insOrderId = this.filesLookInfo.quarterOrderId
      }
      this.tableLoadingFile = true
      const params = {...this.entity}
      const params = { ...this.entity }
      getFileList(params).then(res => {
        this.tableLoadingFile = false
        if (res.code === 200) {
@@ -151,20 +148,20 @@
        this.tableLoadingFile = false
      })
    },
    paginationFile (page) {
    paginationFile(page) {
      this.pageFile.size = page.limit
      this.getFileList()
    },
    // 下载
    handleDown(row){
      downFile({id: row.id,}).then(res => {
    handleDown(row) {
      downFile({ id: row.id, }).then(res => {
        if (res.code === 200) {
          let url = '';
          if(res.data.type==1){
            url = this.javaApi+'/img/'+res.data.fileUrl
            file.downloadIamge(url,row.fileName)
          }else{
            url = this.javaApi+'/word/'+res.data.fileUrl
          if (res.data.type == 1) {
            url = this.javaApi + '/img/' + res.data.fileUrl
            file.downloadIamge(url, row.fileName)
          } else {
            url = this.javaApi + '/word/' + res.data.fileUrl
            const link = document.createElement('a');
            link.href = url;
            link.download = row.fileName;
@@ -175,7 +172,7 @@
      })
    },
    handleSuccessUp(response, ) {
    handleSuccessUp(response,) {
      this.upLoading = false;
      if (response.code == 200) {
        this.$message.success('上传成功');
@@ -205,13 +202,13 @@
      this.$refs.upload.clearFiles()
    },
    // 删除
    delete (row) {
    delete(row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        delfile({id: row.id}).then(res => {
        delfile({ id: row.id }).then(res => {
          if (res.code === 500) {
            return
          }
@@ -220,13 +217,13 @@
        }).catch(e => {
          this.$message.error('删除失败')
        })
      }).catch(() => {})
      }).catch(() => { })
    }
  },
  computed: {
    headers() {
      return {
        'token': sessionStorage.getItem('token')
        'Authorization': "Bearer " + getToken()
      }
    },
    action() {