<template>
  <div class="corePersonnel">
    <head-form
      title="同地区城投"
      :form-data="formData"
      :query-params="queryParams"
      :total="tableDataTotal"
      :isExcel="true"
      @handle-search="handleSearch"
    />

    <tables
      :tableLoading="tableLoading"
      :tableData="tableData"
      :forData="forData"
      :tableDataTotal="tableDataTotal"
      :queryParams="queryParams"
      @handle-current-change="handleCurrentChange"
      @sort-change="sortChange"
    >
      <template slot="companyName" slot-scope="data">
        <router-link :to="''+ data.row.companyId" style="color: #0081FF">{{ data.row.companyName }}</router-link>
      </template>
    </tables>

  </div>
</template>

<script>
import mixin from '../mixins/mixin'
import dataRegion from '@/assets/json/dataRegion'
import {
  urbanInvestmentPage
} from '@/api/detail/party-a/urbanLnvestment'
export default {
  name: 'SameRegion',
  mixins: [mixin],
  components: {

  },
  data() {
    return {
      queryParams: {
        provinceId: 500000,
        cityId: 500100,
        pageNum: 1,
        pageSize: 15
      },
      forData: [
        {label: '企业名称', prop: 'companyName', width: '369', slot: true},
        {label: '区域', prop: 'area', width: '100'},
        {label: '主体评级', prop: 'bratingSubjectLevel', width: '110'},
        {label: '债劵余额（亿元）', prop: 'bondBalance', width: '130'},
        {label: '行政级别', prop: 'uipExecutiveLevel', width: '120'},
        {label: '股东背景', prop: 'shareholderBg', width: '120'},
        {label: '股权关系', prop: 'equityRelationship', width: '120'},
        {label: '平台重要性', prop: 'platformImportance', width: '120'},
        {label: '城投业务类型', prop: 'uipBusinessType', width: '120'},
        {label: '实控人', prop: 'actualController', width: '280'},
        {label: '最新报告期', prop: 'latestReportPeriod', width: '120'},
        {label: '总资产（亿元）', prop: 'totalAssets', width: '120'},
        {label: '归母净资产（亿元）', prop: 'belongNetAssets', width: '140'},
        {label: '货币资金（亿元）', prop: 'monetaryFunds', width: '130'},
        {label: '土地资产（亿元）', prop: 'landAssets', width: '130'},
        {label: '受限资产（亿元）', prop: 'restrictedAssets', width: '130'},
        {label: '应收账款（亿元）', prop: 'accountsReceivable', width: '130'},
        {label: '其他应收款（亿元）', prop: 'otherReceivable', width: '140'},
        {label: '公益性&准公益性主营占比（%）', prop: 'econData001', width: '200'},
        {label: '应收类款项来自政府占比（%）', prop: 'receivableFromGovRatio', width: '200'},
        {label: '政府补助（亿元）', prop: 'govSubsidy', width: '130'},
        {label: '专项应付款（亿元）', prop: 'specialPayable', width: '140'},
        {label: '营业收入（亿元）', prop: 'operatingIncome', width: '130'},
        {label: '所属开发区', prop: 'developmentZone', width: '120'}
      ],
      formData: [
        { type: 1, fieldName: 'penalizeReasonType', value: '', placeholder: '筛选',
          options: []
        },
        { type: 3, fieldName: 'keys', value: '', placeholder: '请输入关键词', options: []},
      ],
      props: {
        value: 'id',
        multiple: true,
      },
      addressList: [],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0,
    }
  },
  created() {
    this.handleQuery()
  },
  computed: {

  },
  methods: {
    dataRegion() {
      // await axios.post("https://files.jiansheku.com/file/json/common/dataRegion.json", {}, {
      //   headers: {
      //     'Content-Type': 'application/json'
      //   }
      // }).then(res => {
      //   if (res.data.code == 200) {
      //     console.log(res.data.data)
      //   }
      // })
      var str = [];
      for (let x = 0; x < 3; x++) {
        for (let i = 0; i < dataRegion.length; i++) {
          if (dataRegion[i].regionLevel == x + 1 && x + 1 == 1) {
            str.push({
              'id': dataRegion[i].id,
              "label": dataRegion[i].regionName,
              "short": dataRegion[i].short,
              "value": dataRegion[i].parentId,
              "children": []
            });
          } else if (dataRegion[i].regionLevel == x + 1 && x + 1 == 2) {
            for (let j = 0; j < str.length; j++) {
              if (str[j].id == dataRegion[i].parentId) {
                str[j].children.push({
                  'id': dataRegion[i].id,
                  "label": dataRegion[i].regionName,
                  "short": dataRegion[i].short,
                  "value": dataRegion[i].parentId,
                  "children": []
                });
              }
            }
          } else if (dataRegion[i].regionLevel == x + 1 && x + 1 == 3) {
            for (let j = 0; j < str.length; j++) {
              for (let k = 0; k < str[j].children.length; k++) {
                if (str[j].children[k].id == dataRegion[i].parentId) {
                  str[j].children[k].children.push({
                    'id': dataRegion[i].id,
                    "label": dataRegion[i].regionName,
                    "short": dataRegion[i].short,
                    "value": dataRegion[i].parentId
                    // "children":[]
                  });
                }
              }
            }
          }
        }
      }
      this.addressList = str;
    },
    handleQuery(params){
      this.tableLoading = true
      let data = params ? params : this.queryParams
      urbanInvestmentPage(data).then(res => {
          this.tableData = res.data.list
          this.tableDataTotal = res.data.totalCount
        this.tableLoading = false
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.corePersonnel{
  background: #ffffff;
  border-radius: 4px;
  padding: 16px;
  .query-box{
    margin: 10px 0 20px;
  }
}
</style>
