yangys
2025-09-25 e4c84d44e70e09ec6d69716bd6c722a953f980da
src/views/tasks/machinereturnfiles.vue
@@ -1,4 +1,9 @@
<template>
  <div class="gongkongMain">
  <div >
      <el-tree :data="treeData" :props="defaultProps" node-key="id" :default-expand-all="false" :default-expanded-keys="defaultKeys" @node-click="handleNodeClick" />
    </div>
    <div>
  <basic-container>
    <avue-crud
      :addBtn="false"
@@ -18,20 +23,27 @@
    >
      <template #menu-left>
        <!-- el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">导出</el-button> -->
        <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="receiveBtn">批量接收</el-button>
        <el-button type="primary" v-if="this.search.dirType!='REC'" size="default" icon="el-icon-circle-plus" plain @click="receiveAll">全部接收</el-button>
        <el-button type="primary" v-if="this.search.dirType!='REC'" :disabled="this.selection.length==0" size="default" icon="el-icon-circle-plus" plain @click="receiveBtn">接收已选</el-button>
        <el-button type="primary" v-if="this.search.dirType!='REC'" :disabled="this.selection.length==0" size="default" icon="el-icon-circle-plus" plain @click="rejectBtn">拒绝</el-button>
      </template>
      <!--
      <template #menu="scope">
        <el-button type="primary" text size="default" icon="el-icon-document-delete" @click.stop="rejectBtn(scope.row, scope.index)">拒绝</el-button>
        <el-button type="primary" text size="default" icon="el-icon-document-add" @click.stop="acceptBtn(scope.row, scope.index)">接收</el-button>
        <el-button type="primary" v-if="scope.row.dirType==='TEMP'" text size="default" icon="el-icon-document-delete" @click.stop="rejectBtn(scope.row, scope.index)">拒绝</el-button>
        <el-button type="primary" v-if="scope.row.dirType==='TEMP'" text size="default" icon="el-icon-document-add" @click.stop="acceptBtn(scope.row, scope.index)">接收</el-button>
      </template>
      -->
    </avue-crud>
  </basic-container>
  </div>
  </div>
</template>
<script>
  import { ElMessage } from 'element-plus';
import { ElMessage } from 'element-plus';
import { exportBlob } from '@/api/common';
import { downloadXls } from '@/utils/util';
import { downloadXls ,getQueryString} from '@/utils/util';
import { getToken } from '@/utils/auth';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
@@ -41,17 +53,27 @@
      selection: [],
      search: {
        keyword: "",
        machineGroupCode: ""
        machineGroupCode: "",
        dirType:"",
      },
      loading: true,
      treeData: [],
      defaultProps: {
        children: 'children',
        label: 'name',
        isLeaf: (data) => !data.hasChildren
      },
      currentNode:{},//当前节点数据
      mypage: {
        size: 10,
        current: 1,
        total: 0,
      },
      option: {
        size:'small',
        index: true,
        selection: true,
        selectionWidth:30,
        addBtn: false,
        editBtn: false,
        delBtn: false,
@@ -59,35 +81,56 @@
        emptyBtn: false,
        searchLabelWidth: "120",
        searchSpan: 8,
        menu:false,
        width:'100%',
        column: [
          {
            label: '任务编码',
            prop: 'programName',
            hide: true
          },
        {
          {
            label: '文件名称',
            prop: 'name',
            showOverflowTooltip:true,
          },
          {
            label: '机床号',
            prop: 'machineCode',
            showOverflowTooltip:true,
          },
          {
            label: '文件固化状态',
            prop: 'isCured',
            label: '程序状态',
            prop: 'programStatus',
            showOverflowTooltip:true,
            render: ({ row,value }) => {
              var txt = '未知';
              switch(row.programStatus){
                case 1:
                  txt = '试切';
                  break;
                case 2:
                  txt = '固化';
                  break;
                case 3:
                  txt = '临时更改单';
                  break;
                default:
                  txt = '未知';
              }
              return txt;
            }
          },
          {
            label: '文件大小',
            prop: 'fileSizeDisplay',
          },
          {
            label: '文件到达时间',
            prop: 'arrivedTime',
            showOverflowTooltip:true,
            prop: 'fileCreateTime',
          },/*
          {
            label: '文件数据库编号',
            prop: '',
          },*/
          {
            label: '关键信息',
            label: '关键字',
            prop: 'keyword',
            search: true,
            hide: true,
@@ -114,6 +157,29 @@
    selectionChange(selection) {
      this.selection = selection;
    },
    receiveAll() {
      //接收符合条件的所有数据
      this.$confirm('确定要接收符合条件的所有文件吗?', {  //同接收接口相同
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'warning',
      }).then(() => {
        //调用接口
        this.loading = true;
        axios({
          url: '/blade-mdm/machinefile/file/temp-accept-all',
          method: 'post',
          params: {}
        }).then(
          res => {
            this.loading = false;
            this.onLoad();
          }
        );
      })
    },
    receiveBtn() {
      if(this.selection.length == 0) {
        ElMessage({message: '请选择数据',type: 'error'})
@@ -130,7 +196,7 @@
        //调用接口
        this.loading = true;
        axios({
          url: '/blade-mdm/machineback/file/accept',
          url: '/blade-mdm/machinefile/collect/temp-accept',
          method: 'post',
          params: {ids: ids.join(',')},
        }).then(
@@ -150,7 +216,7 @@
        //调用接口
        this.loading = true;
        axios({
          url: '/blade-mdm/machineback/file/accept',
          url: '/blade-mdm/machinefile/collect/temp-accept',
          method: 'post',
          params: {ids: row.id},
        }).then(
@@ -170,7 +236,7 @@
        //调用接口
        this.loading = true;
        axios({
          url: '/blade-mdm/machineback/file/reject',
          url: '/blade-mdm/machinefile/collect/temp-reject',
          method: 'post',
          params: {ids: row.id},
        }).then(
@@ -189,7 +255,7 @@
      }).then(() => {
        NProgress.start();
        exportBlob(
          `/blade-mdm/machineback/file/export-excel?${this.website.tokenHeader}=${getToken()}`
          `/blade-mdm/machinefile/file/export-excel?${this.website.tokenHeader}=${getToken()}`
        ).then(res => {
          downloadXls(res.data, `机床回传文件数据${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
          NProgress.done();
@@ -206,9 +272,11 @@
    },
    currentChange(current) {
      this.mypage.current = current;
      this.onLoad();
    },
    sizeChange(size) {
      this.mypage.size = size;
      this.onLoad();
    },
    refreshChange() {
      
@@ -220,13 +288,20 @@
        machineSpec: this.search.machineSpec,
        current: this.mypage.current,
        size: this.mypage.size,
        nodeType: this.currentNode.nodeType,
        nodeId: this.currentNode.nodeType!='dir'?this.currentNode.id:undefined,
        dirType:this.currentNode.dirType,
        machineCode: this.currentNode.machineCode,
      }
      console.log('myupage',this.mypage)
      axios({
        url: '/blade-mdm/machineback/file/page',
        url: '/blade-mdm/machinefile/collect/file-page-for-acceept',
        method: 'get',
        params: obj,
      }).then(
        res => {
          var screenHeight = window.innerHeight;
          this.option.maxHeight = (screenHeight - 390) + 'px';
          const data = res.data.data;
          this.mypage.total = data.total;
          this.data = data.records;
@@ -237,11 +312,70 @@
        }
      );
    }
    },
    handleNodeClick(treeNode,b,c,d) {
      console.log(treeNode)
      this.currentNode = treeNode;
      this.search.dirType = treeNode.dirType;
      this.onLoad();
    },
    treeLoad () {
      axios({
        url: '/blade-mdm/gkw/node/load-tree?includeSend=0',
        method: 'get',
      }).then(
        res => {
          this.treeData = res.data.data;
          var firstIndex = 0;
          res.data.data.forEach((item,index)=> {
            if(item.children.length != 0) {
              firstIndex = index;
            }
          })
          //defaultKeys.push(item.id);
          this.defaultKeys = [res.data.data[firstIndex].id];
        }
      )
    },
  },
  mounted() {
    this.treeLoad();
    this.search.dirType = getQueryString("dirType");
  }
};
</script>
<style lang="scss">
.gongkongMain {
  display: flex;
  padding: 0px;
  margin: 0px 7px 10px 7px;
  background-color: #fff;
  border-top: 1px solid #ccc;
  > div {
    padding: 12px;
  }
}
.gongkongMain > div:nth-child(1) {
  width:17%;
  border-right: 1px solid #ccc;
}
.gongkongMain div:nth-child(2) {
  flex: 1;
}
.paginationTree {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}
/*
.Avue-crud{
  :deep(.el-table) {
    .el-table__body-wrapper,
    .el-table__fixed-body-wrapper {
      max-height:calc(100vh - 630px)!important;
      overflow-y: auto;
    }
  }
}
*/
</style>