管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2022-11-24 a7199e5a4f3e34b14d395e319a552c5c3b8b3a4d
src/views/datamanage/dataUpdata.vue
@@ -10,7 +10,9 @@
    ></My-bread>
    <el-divider />
    <div class="updateContent">
      <div class="contentIquery">
               <el-tabs v-model="activeTabName" @tab-click="handleTabClick">
    <el-tab-pane :label="$t('dataManage.dataUpObj.uploaddata')" name="first">
            <div class="contentIquery">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item :label="$t('dataManage.dataUpObj.catalogue')">
            <el-cascader
@@ -80,6 +82,12 @@
              :disabled="tableData.length == 0 ? true : false"
              >{{ $t('common.delete') }}</el-button
            >
             <el-button
              icon="el-icon-data-line"
              type="info"
               disabled
              >{{ $t('common.quayTest') }}</el-button
            >
            <el-button
              icon="el-icon-folder-add"
              type="warning"
@@ -91,10 +99,10 @@
        </el-form>
      </div>
      <div class="contentTable">
         <el-table
     :data="tableData"
        border
        style="width: 100%"
   <el-table
        :data="tableData"
        style="width: width:99%"
        height="99%"
        @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" />
@@ -105,15 +113,134 @@
          width="70px"
          fixed
        />
        <el-table-column
          <el-table-column
          align="center"
          prop="name"
          :label="$t('common.name')"
          fixed
        />
         <el-table-column
          align="center"
          prop="sizes"
          :label="$t('common.size')"
          fixed
         :formatter="changeSizeFile"
        />
         <el-table-column
          align="center"
          prop="guid"
          :label="$t('common.md5')"
          fixed
        />
    </el-table>
      <!-- <div style="margin-top: 10px" class="pagination_box">
      </div>
      </el-tab-pane>
    <el-tab-pane :label="$t('dataManage.dataUpObj.receiptdata')" name="second">
<div class="contentIquery" style="padding-bottom: 0% !important;">
        <el-form :inline="true" :model="formWarehousing" class="demo-form-inline">
          <el-form-item :label="$t('dataManage.dataUpObj.describe')">
<el-input v-model="formWarehousing.name" placeholder="请输入内容"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-upload" @click="setWarehouseSearch"
           class="primary">{{
              $t('common.iquery')
            }}</el-button>
            <el-button @click="setWarehouseReset"
              icon="el-icon-folder-add"
              type="info"
              >{{ $t('common.reset') }}</el-button
            >
          </el-form-item>
        </el-form>
      </div>
   <div class="contentTable" style="height:500px">
   <el-table
     :data="waretableData"
        style="width:99%"
        height="92%"
 >
        <el-table-column
          align="center"
          type="index"
          :label="$t('common.index')"
          width="70px"
          fixed
        />
          <el-table-column
          align="center"
          prop="name"
          :label="$t('common.name')"
          fixed
        />
         <el-table-column
          align="center"
          prop="dirName"
          :label="$t('dataManage.dataUpObj.catalogue')"
          fixed
        />
         <el-table-column
          align="center"
          prop="depName"
          :label="$t('dataManage.dataUpObj.company')"
          fixed
        />
             <el-table-column
          align="center"
          prop="verName"
          :label="$t('dataManage.dataUpObj.versionNo')"
          fixed
        />
             <el-table-column
          align="center"
          prop="type"
          :label="$t('common.type')"
          fixed
        />
        <el-table-column
          align="center"
          prop="sizes"
          :label="$t('common.size')"
          fixed
          :formatter="changeSizeFile"
        />
         <el-table-column
          align="center"
          prop="tab"
          :label="$t('dataManage.dataUpObj.tableName')"
          fixed
        />
         <el-table-column
          align="center"
          prop="rows"
          :label="$t('common.lineNuber')"
          fixed
        />
         <el-table-column
          align="center"
          prop="desc"
          :label="$t('dataManage.dataUpObj.describe')"
          fixed
        />
        <el-table-column
          align="center"
          prop="uname"
          :label="$t('dataManage.vmobj.createonuser')"
          fixed
        />
         <el-table-column
          align="center"
          prop="createTime"
          :label="$t('dataManage.vmobj.createontime')"
          fixed
              :formatter="changetimeFile"
        />
    </el-table>
      <div style="margin-top: 10px" class="pagination_box">
    <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
@@ -124,8 +251,11 @@
          :total="count"
        >
        </el-pagination>
      </div> -->
      </div>
      </div>
    </el-tab-pane>
  </el-tabs>
    </div>
  </div>
@@ -135,7 +265,8 @@
import $ from 'jquery';
import MyBread from '../../components/MyBread.vue';
import { getToken } from '@/utils/auth';
import { selectdirTab, queryDepTree,dataUploadSelectVerByDirid,dataUploadSelectPath,dataUploadSelectFiles,dataUploadDeleteFiles,dataUploadInsertFiles} from '../../api/api';
import { selectdirTab, queryDepTree, dataUploadSelectVerByDirid, dataUploadSelectPath, dataUploadSelectFiles, dataUploadDeleteFiles, dataUploadInsertFiles,
dataUpload_selectByPageForUpload} from '../../api/api';
export default {
  name: 'dataUpdata',
  components: {
@@ -143,21 +274,27 @@
  },
  data() {
    return {
      activeTabName: 'first',
      btnStatus: 0,
      count: 0,
      formInline: {
        verid:'',
        verid: '',
        gather: '',
      },
      formWarehousing: {
          name:''
      },
      catalogOption: [],
      companyOption: [],
      tableData: [],
      waretableData:[],
      listTable: [],
      multipleSelection: [],
      fullscreenLoading: false,
      listData: {
        pageIndex: 1,
        pageSize: 10,
       name: null,
      },
      pickerOptions: {
        disabledDate(time) {
@@ -214,39 +351,120 @@
  },
  methods: {
    changetimeFile(res){
    //数据删除
  async setFileDelete() {
      this.handlerLoading(true);
    var data = JSON.stringify(this.multipleSelection);
    const res = await dataUploadDeleteFiles(data);
 if (res.code != 200) {
       this.$message.error('删除失败');
//shijianchuo是整数,否则要parseInt转换
      var time = new Date(res.createTime);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return (
        y +
        '-' +
        this.add0(m) +
        '-' +
        this.add0(d) +
        ' ' +
        h +
        ':' +
        mm +
        ':' +
        s
      );
    },
      //格式化时间
    add0(m) {
      return m < 10 ? '0' + m : m;
    },
    setWarehouseSearch(){
   this.listData={
              pageIndex:1,
              pageSize:10,
              name:this.formWarehousing.name,
            }
            this.getAllWareTable();
    },
    setWarehouseReset(){
     this.formWarehousing.name='';
   this.listData={
              pageIndex:1,
              pageSize:10,
              name:null,
            }
            this.getAllWareTable();
    },
    handleTabClick(tab, event) {
        if(this.activeTabName =='second'){
            this.setWarehouseReset();
        }
    },
    handleSizeChange(val){
      this.listData.pageIndex= 1;
      this.listData.pageSize =val;
          this.getAllWareTable();
    },
handleCurrentChange(val){
  this.listData.pageIndex= val;
  this.getAllWareTable();
},
    //获取入库数据列表
   async getAllWareTable(){
      const res = await  dataUpload_selectByPageForUpload(this.listData);
        if (res.code != 200) {
        this.$message.error('列表数据获取失败');
        return;
      }
  this.getFileLength();
      debugger
      this.count = res.count;
 this.waretableData =res.result;
    },
    //大小值改變
    changeSizeFile(row, column, cellValue, index) {
      if (cellValue >= 1024) {
        return parseFloat(cellValue / 1204).toFixed(3) + "GB"
      } else {
        return cellValue + "MB"
      }
    },
    //数据删除
    async setFileDelete() {
      this.handlerLoading(true);
      var data = JSON.stringify(this.multipleSelection);
      const res = await dataUploadDeleteFiles(data);
      if (res.code != 200) {
        this.$message.error('删除失败');
        return;
      }
      this.getFileLength();
      this.handlerLoading(false);
    },
    //数据入库
 async setFileWare() {
      if(this.multipleSelection.length==0){
       this.$message.error('请选择要入库的数据');
    async setFileWare() {
      if (this.multipleSelection.length == 0) {
        this.$message.error('请选择要入库的数据');
        return
      }
        var obj = {
              metaEntity: this.formInline,
              fileEntities: this.multipleSelection
            };
        const res = await dataUploadInsertFiles(JSON.stringify(obj));
         if (res.code != 200) {
      var obj = {
        metaEntity: this.formInline,
        fileEntities: this.multipleSelection
      };
      const res = await dataUploadInsertFiles(JSON.stringify(obj));
      if (res.code != 200) {
        this.$message.error('文件上传数据获取失败');
        return;
      }
  this.getFileLength();
      this.getFileLength();
    },
@@ -265,73 +483,73 @@
    },
    //文件上传
    setFileUpload() {
       this.handlerLoading(true);
      this.handlerLoading(true);
      var token = getToken();
 var formData = new FormData();
      var formData = new FormData();
      var fs = document.getElementById("uploadfile");
      if (fs.files.length == 0) {
        this.handlerLoading(false);
        return this.$message.error('请选择需要上传的文件');
      }
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file
      }
 $.ajax(BASE_URL+"/dataUpload/uploadFiles?token="+token + "&path=" + this.formInline.path, {
      $.ajax(BASE_URL + "/dataUpload/uploadFiles?token=" + token + "&path=" + this.formInline.path, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success:(rs)=> {
                 this.getFileLength();
        success: (rs) => {
          this.getFileLength();
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
          this.$message({
            message: '上传成功',
            type: 'success'
          });
        },
        error:(rs)=> {
        error: (rs) => {
          alert("上传文件失败!");
        }
      });
            this.handlerLoading(false);
      document.getElementById("uploadfile").value = "";
      this.handlerLoading(false);
    },
    //获取文件上传数据
   async getFileLength() {
    async getFileLength() {
      const res = await dataUploadSelectFiles(this.formInline.path);
      if (res.code != 200) {
        this.$message.error('文件上传数据获取失败');
        return;
      }
      if(res.result == null){
     this.count =0;
      if (res.result == null) {
        this.count = 0;
        this.setClearTableData();
      }else{
      } else {
        this.count = res.result.length;
        this.tableData = res.result;
      }
      // this.listData.pageIndex = 1;
      // this.listData.pageSize = 10;
      // this.setViewTable();
    },
    //清除表格信息
    setClearTableData() {
      this.tableData = [];
      this.listTable = [];
    },
    //分页控制
    handleSizeChange(res) {
      this.listData.pageIndex = 1;
      this.listData.pageSize = res;
      this.setViewTable();
    },
    handleCurrentChange(res) {
      this.listData.pageIndex = res;
      this.setViewTable();
    },
    // //分页控制
    // handleSizeChange(res) {
    //   this.listData.pageIndex = 1;
    //   this.listData.pageSize = res;
    //   this.setViewTable();
    // },
    // handleCurrentChange(res) {
    //   this.listData.pageIndex = res;
    //   this.setViewTable();
    // },
    //表格选中事件
    handleSelectionChange(res) {
      this.multipleSelection = res;
@@ -341,7 +559,7 @@
      $("#uploadfile").click();
    },
    handleFileChange() {
  var fs = document.getElementById("uploadfile");
      var fs = document.getElementById("uploadfile");
    },
    //当前时间获取
@@ -379,10 +597,10 @@
    companyChange(value) {
      this.formInline.depid = value;
    },
 //获取文件上传路径
   async getFilePath() {
    //获取文件上传路径
    async getFilePath() {
      const res = await dataUploadSelectPath();
    if (res.code != 200) {
      if (res.code != 200) {
        this.$message.error('单位列表获取失败');
        return;
      }
@@ -400,10 +618,9 @@
    },
    //版本号获取
    async getselectVerByDirid() {
      this.verOption=[];
      this.formInline.verid ="";
      const res =  await dataUploadSelectVerByDirid(this.formInline.dirid);
      this.verOption = [];
      this.formInline.verid = "";
      const res = await dataUploadSelectVerByDirid({ dirid: this.formInline.dirid });
      if (res.code != 200) {
        this.$message.error('版本列表获取失败');
        return;
@@ -411,8 +628,6 @@
      this.verOption = res.result;
      this.formInline.verid = res.result[0].id;
    },
    //目录列表获取
    async getSelectdirTab() {
      const res = await selectdirTab();
@@ -451,15 +666,15 @@
    position: relative;
    .contentIquery {
      width: 98%;
      width: 97%;
      height: 16%;
      border: 1px solid white;
      padding: 1%;
      border-radius: 5px;
    }
    .contentTable {
      width: 98%;
      height: 72%;
      width: 97%;
      height: 400px;
      border: 1px solid white;
      padding: 1%;
      border-radius: 5px;
@@ -596,5 +811,11 @@
  /deep/.el-loading-spinner i {
    color: #1890ff !important;
  }
  /deep/.el-tabs__active-bar {
    background: #409eff;
  }
  /deep/ .el-tabs__item {
    color: #409eff;
  }
}
</style>