
<template>
  <div>
    <!-- <add :data="list" @onSuccess="getList" :disabled="mainData.status !== '待审核'" v-if="tool.checkAuth($route.name,'update')"/> -->
    <tableLayout :layout="tablecols" :data="list" :opwidth="200" :custom="true" height="40vh" fixedName="operation">
      <template v-slot:customcol="scope">
        <div v-if="scope.column.columnname === 'province'">
          <span>{{scope.column.data['province']}}-{{scope.column.data['city']}}-{{scope.column.data['county']}}</span>
        </div>
        <div v-else-if="scope.column.columnname === 'errmsg'">
          <span style="color:red">{{scope.column.data[scope.column.columnname]}}</span>
        </div>
        <div v-else-if="scope.column.columnname == 'totalinvestment'">
          <span>{{scope.column.data[[scope.column.columnname]] !== 0?tool.formatAmount(scope.column.data[[scope.column.columnname]],2):'--'}}</span>
        </div>
        <div v-else-if="scope.column.columnname == 'costofconstruction'">
          <span>{{scope.column.data[[scope.column.columnname]] !== 0?tool.formatAmount(scope.column.data[[scope.column.columnname]],2):'--'}}</span>
        </div>
        <span v-else-if="!scope.column.data[scope.column.columnname] && scope.column.columnname != 'operation' ">--</span>
        <span v-else>{{scope.column.data[[scope.column.columnname]]}}</span>
      </template>
      <template v-slot:opreation="scope">
        <body-edit 
          v-if="tool.checkAuth($route.name,'handleClueTab')"
          :disabled="mainData.status !== '待审核'" 
          :data="scope.data" 
          @onSuccess="getList()"
        ></body-edit>
        <body-del 
          v-if="tool.checkAuth($route.name,'handleClueTab')" 
          :data="scope.data" 
          :disabled="mainData.status !== '待审核'"
          @onSuccess="getList()"
        ></body-del>
      </template>
    </tableLayout>
    <el-pagination
      background
      small
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="params.content.pageNumber"
      :page-size="params.content.pageSize"
      layout="total, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import BodyEdit from './edit'
import bodyDel from './body_del.vue'
import add from './add'

export default {
  props:['mainData'],
  components:{
    BodyEdit,
    bodyDel,
    add
  },
  data () {
    return {
      options:[],
      tablecols:[],
      list:[],
      total:0,
      params: {
        "id":20221102100102,
        "content": {
          pageNumber:1,
          pageSize:20,
          where: {
            condition:''
          }
        }
      }
    }
  },
  created () {
    this.getList()
    this.tablecols = this.tool.tabelCol(this.$route.name).clueImportDetailBOdyTable.tablecols
  },
  methods:{
    async getList () {
      this.params.content.sat_orderclueuploadbillid = this.$route.query.id
      let res = await this.$api.requested(this.params)
      this.list = res.data
      this.total = res.total
      console.log(this.list);
      
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.getList()
    },
  }
}

</script>
<style scoped>
/deep/.el-pagination {
  text-align: right;
  margin-top: 10px;
  margin-right: 40px;
}
</style>