<template>
  <a-table
    ref="table"
    size="middle"
    :scroll="{x:true}"
    bordered
    :rowKey="(record,index)=>{return index}"
    :columns="columns"
    :dataSource="dataSource"
    :loading="loading"
    class="j-table-force-nowrap">
    <!-- :pagination="ipagination" -->
    
  </a-table>
</template>

<script>
  // import '@/assets/less/TableExpand.less'
  // import { mixinDevice } from '@/utils/mixin'
  // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  export default {
    name: '',
    // mixins:[JeecgListMixin, mixinDevice],
    props: {
      dataSource: {
        type: Array,
        default: []
      },
      loading: {
        type: Boolean,
        default: true
      },
      deptType: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        // 全部表头
        columnsAll: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'部门',
            align:"center",
            dataIndex: 'depart'
          },
          {
            title:'当期指标',
            align:"center",
            dataIndex: 'departKpi',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          // {
          //   title:'项目进度',
          //   align:"center",
          //   dataIndex: 'processpercent'
          // },
          {
            title:'当期合同额',
            align:"center",
            dataIndex: 'contractAmount',
            deptType: 'xd',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'当期已收款',
            align:"center",
            dataIndex: 'received',
            deptType: 'xd',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'当期完成额',
            align:"center",
            dataIndex: 'contractAmount',
            deptType: 'zr',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'完成度',
            align:"center",
            dataIndex: 'kpiCompletRate',
            customRender: (text, record) => {
              return (Number(text) * 100).toFixed(0) + '%'
            },
          },
        ],
        // 表头
        columns: [],
      }
    },
    created() {
    },
    watch: {
      // dataSource: {
      //   handler(newV, oldV){
      //     console.log(newV, oldV)
      //     this.loading = false
      //   },
      //   immediate: true
      // }
      deptType: {
        handler(newV, oldV){
          console.log(newV, oldV)
          this.columns = this.columnsAll.filter(res => {
            return res.deptType == newV || !res.deptType
          })
          console.log(this.columns)
        },
        immediate: true
      }
    },
    methods: {
      initDictConfig(){
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>