iview_code

 ---

ivew code

this.search.statementInfoType='应收';
this.search.page= 1;
this.search.pageSize= 100000;

列表固定高度

<div style="height:400px;overflow-y:auto;overflow-x:hidden; padding: 5px 10px 10px 10px; margin-top: -12px;">
<template>
<Table ref="table" size="small" class="margin-bottom-10" :columns="importDatawindow_columns" :loading="setting.loading" :border="setting.showBorder" :data="importDatawindow_table_data.records"></Table>
</template>
</div>

<Table ref="table" :stripe="true" class="margin-bottom-10" size="small" :columns="columns" :loading="setting.loading" :border="setting.showBorder" :data="data.records"></Table>

<Page :total="data.total" class="tr" @on-change="pageChange" :current.sync="data.current" :page-size="dataFilter.pageSize" @on-page-size-change="pageSizeChange" show-elevator show-sizer show-total></Page>

<div>总共:{{data.total}} 条</div>

 

 

{
title: '序号',
type: 'index',
width: 60,
align: 'center'
},

 

this.data.records.forEach(function(item, index) {
console.log(item)
})

 

导出

import { post_down } from "@/libs/axios-cfg"
async export_data(status){

try {

let res = await post_down("/projectstoreimport/export_data", {
status:status,
batch_no : this.data.batchNo,
url: 'https://'+this.url ,
project_id:this.openmodel_info.project_id,
})

console.log( res )
let data = new Blob([res.data], { type: 'application/vnd.ms-excel;' });
// let url = window.URL.createObjectURL(blob);
// window.location.href = url;
console.log( data)
if (typeof window.chrome !== 'undefined') {
// Chrome
var link = document.createElement('a');
link.href = window.URL.createObjectURL(data);
// link.download = 'filename.xlsx';
link.click();
} else if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE
var blob = new Blob([data], { type: 'application/force-download?charset=GBK' });
window.navigator.msSaveBlob(blob, filename);
} else {
// Firefox
var file = new File([data], filename, { type: 'application/force-download?charset=UTF-8' });
window.open(URL.createObjectURL(file));
}
} catch (error) {
this.$throw(error)
}
},

 

------------------------------------------------------------------------------------------------------------------------------表格跨页勾选------------------------------------------------------------------------------------------------------------------------------

      <Card style="margin-top: 3px;">
         <div style="height:410px;overflow-y:auto;overflow-x:hidden; padding: 5px 10px 10px 10px; margin-top: -12px;">
          <template >
              <Table
              :stripe="true"
              @on-select="select_row_table"
              @on-select-cancel="select_row_table_cancel"
              @on-select-all="select_row_table_all"
              @on-select-all-cancel="select_row_table_all_cancel"
              @on-selection-change="select_row_table"
              ref="mytable" class="margin-bottom-1" size="small"  :columns="columns" :loading="setting.loading" :border="setting.showBorder" :data="data.records"></Table>

              <div style="display: flex;flex-direction: row;justify-content: space-between;margin-top: 5px;">
                  <div style="display: flex;flex-direction: row;">
                    <Button class="but_bg" type="primary" :loading="loading" @click="check_all">全选</Button>
                    <Button class="but_bg" type="primary" :loading="loading" @click="check_all_cancel">取消全选</Button>
                  </div>
                  <Page :total="data.total" class="tr" @on-change="pageChange" :current.sync="data.current" :page-size="dataFilter.pageSize" @on-page-size-change="pageSizeChange" show-elevator show-sizer show-total ></Page>
              </div>
         </template>
        </div>
      </Card>

 

    check_all(){
        this.openmodel_info.check_all_tag = true ;
        this.check_ids_return_show();
    },
    check_all_cancel(){
        this.openmodel_info.check_all_tag = false ;
        this.check_ids_return_show();
    },
    select_row_table_all(selection, row){
        this.openmodel_info.check_all_tag = null ; //初始化全选
        for (let index in this.$refs.mytable.objData) {
            let tag = this.$refs.mytable.objData[index]._isChecked ;
            let id = this.$refs.mytable.objData[index].id ;
            if(this.openmodel_info.check_ids.includes(id)==false ){
                this.openmodel_info.check_ids.push( id) ;
            }
        }
    },
    select_row_table_all_cancel(selection, row){
        this.openmodel_info.check_all_tag = null ; //初始化全选
        for (let index in this.$refs.mytable.objData) {
            let tag = this.$refs.mytable.objData[index]._isChecked ;
            let id = this.$refs.mytable.objData[index].id ;
            for(var i = 0; i < this.openmodel_info.check_ids.length; i++){
                if( this.openmodel_info.check_ids[i] === id){
                    if( tag == false ){
                        this.openmodel_info.check_ids.splice(i,1);
                    }
                }
            }
        }
    },

    select_row_table(selection, row){
      this.openmodel_info.check_all_tag = null ; //初始化全选
      if( row ==undefined){
        return ;
      }
      let id = row.id ;
      if(this.openmodel_info.check_ids.includes(id)==false ){
          this.openmodel_info.check_ids.push( id) ;
      }
      console.log( this.openmodel_info.check_ids ,'新增');
    },


    select_row_table_cancel(selection, row){
      this.openmodel_info.check_all_tag = null ; //初始化全选
      if( row ==undefined){
        return ;
      }
      let id = row.id ;
      for(var i = 0; i < this.openmodel_info.check_ids.length; i++){
          if(this.openmodel_info.check_ids[i] === id){
              this.openmodel_info.check_ids.splice(i,1);
          }
      }
      console.log( this.openmodel_info.check_ids,'删除');
    },

    check_ids_return_show(){
      if( this.openmodel_info.check_all_tag == null  ){
         this.openmodel_info.check_ids.forEach((item) => {
           for (let index in this.$refs.mytable.objData) {
              if (item == this.$refs.mytable.objData[index].id) {
                this.$refs.mytable.objData[index]._isChecked = true;//回显选中
              }
            }
         });
      }
      else if( this.openmodel_info.check_all_tag == true) {
        for (let index in this.$refs.mytable.objData) {
          this.$refs.mytable.objData[index]._isChecked = true;//回显选中
        }
      }
      else if( this.openmodel_info.check_all_tag == false) {
          for (let index in this.$refs.mytable.objData) {
            this.$refs.mytable.objData[index]._isChecked = false;//回显选中
          }
      }
    },

 

          this.search.page=this.dataFilter.page;
          this.search.pageSize=this.dataFilter.pageSize;
          this.search.proStatus=this.$route.query.proStatus ;
          this.search.id=this.$route.query.projectId;

 

posted on 2022-06-23 09:36  adolfmc  阅读(30)  评论(0编辑  收藏  举报