gaoluyang
2025-02-19 7e35455e4bbad2edfe64bf6f56beff105c94eb94
src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue
@@ -16,13 +16,10 @@
          <el-button size="small" type="primary" style="height: 38px">附件上传</el-button>
        </el-upload>
      </div>
      <div style="height: 70vh;overflow-y: auto;" v-if="filesDialogVisible">
        <ValueTable ref="fileList"
                    :url="$api.insOrderPlan.getFileList"
                    :delUrl="$api.insOrderPlan.delfile"
                    class="value-table"
                    :key="upIndex"
                    :componentData="componentData"/>
      <div v-if="filesDialogVisible">
        <lims-table :tableData="tableData" :column="column"
                    @pagination="pagination" height="500px" key="tableData"
                    :page="page" :tableLoading="tableLoading"></lims-table>
      </div>
    </el-dialog>
  </div>
@@ -31,11 +28,13 @@
<script>
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";
export default {
  name: "filesLookVisible",
  // import 引入的组件需要注入到对象中才能使用
  components: {ValueTable},
  components: {limsTable, ValueTable},
  props: {
    filesDialogVisible: {
      type: Boolean,
@@ -49,7 +48,67 @@
  data() {
    // 这里存放数据
    return {
      upIndex: 0,
      tableData: [],
      tableLoading: false,
      column: [
        {
          dataType: 'tag',
          label: '类型',
          prop: 'type',
          formatData: (params) => {
            if (params == 1) {
              return '合格'
            } else if (params == 0) {
              return '不合格'
            } else if (params == 3) {
              return '不判定'
            } else {
              return ''
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
            } else if (params == 0) {
              return 'danger'
            } else if (params == 3) {
              return ''
            }  else {
              return ''
            }
          }
        },
        {label: '附件名称', prop: 'fileName'},
        {label: '上传人', prop: 'name'},
        {label: '上传时间', prop: 'createTime'},
        {
          dataType: 'action',
          fixed: 'right',
          label: '操作',
          width: '170px',
          operation: [
            {
              name: '下载',
              type: 'text',
              clickFun: (row) => {
                this.handleDown(row);
              }
            },
            {
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.delete(row);
              }
            },
          ]
        }
      ],
      page: {
        total:0,
        size:10,
        current:1
      },
      isShow: this.filesDialogVisible,
      dataVisibleTitle: [
        {
@@ -62,50 +121,9 @@
        },
      ],
      dataVisibleIndex: 0, // tab栏选择值
      componentData: {
        entity: {
          insOrderId:''
        },
        isIndex: true,
        showSelect: false,
        select: false,
        sort: false,
        init:false,
        do: [
          {
            id: 'parent',
            font: '下载',
            type: 'text',
            method: 'handleDown'
          },{
            id: 'delete',
            font: '删除',
            type: 'text',
            method: 'doDiy',
          }
        ],
        isPage: false,
        linkEvent: {},
        tagField: {
          type:{
            select:[
              {
                value: 1,
                label: '图片'
              },
              {
                value: 2,
                label: '文件'
              }
            ]
          }
        },
        currentId: '',
        selectField: {},
        requiredAdd: [],
        requiredUp: []
      entity: {
        insOrderId:''
      },
    }
  },
  mounted() {
@@ -119,20 +137,31 @@
      this.refreshTable()
    },
    // 查询回调
    refreshTable(e) {
    refreshTable() {
      if (this.dataVisibleIndex === 0) {
        this.componentData.entity.insOrderId = this.filesLookInfo.enterOrderId
        this.entity.insOrderId = this.filesLookInfo.enterOrderId
      } else {
        this.componentData.entity.insOrderId = this.filesLookInfo.quarterOrderId
        this.entity.insOrderId = this.filesLookInfo.quarterOrderId
      }
      this.$nextTick(() => {
        this.$refs['fileList'].selectList(e)
      this.tableLoading = true
      const params = {...this.entity}
      getFileList(params).then(res => {
        this.tableLoading = false
        if (res.code === 200) {
          this.tableData = res.data.records
          this.page.total = res.data.total
        }
      }).catch(err => {
        this.tableLoading = false
      })
    },
    pagination (page) {
      this.page.size = page.limit
      this.refreshTable()
    },
    // 下载
    handleDown(row){
      this.$axios.post(this.$api.insOrderPlan.downFile, {
        id: row.id,
      }).then(res => {
      downFile({id: row.id,}).then(res => {
        if (res.code === 200) {
          let url = '';
          if(res.data.type==1){
@@ -179,6 +208,24 @@
      this.$message.error('上传失败')
      this.$refs.upload.clearFiles()
    },
    // 删除
    delete (row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        delfile({id: row.id}).then(res => {
          if (res.code === 500) {
            return
          }
          this.$message.success('删除成功')
          this.getList()
        }).catch(e => {
          this.$message.error('删除失败')
        })
      }).catch(() => {})
    }
  },
  computed: {
    headers() {
@@ -187,7 +234,7 @@
      }
    },
    action() {
      return this.javaApi + this.$api.insOrderPlan.uploadFile
      return this.javaApi + '/insOrderPlan/uploadFile'
    }
  },
}
@@ -197,7 +244,8 @@
.tab {
  list-style-type: none;
  display: flex;
  margin-bottom: 12px;
  margin-top: 0 !important;
  padding-left: 0 !important;
}
.tab li {