<template>
<div style="padding-bottom:50px;">

  <div class="table">


      <el-table :key="tableObj.tableKey" v-loading="tableObj.listLoading" element-loading-text="给我一点时间" :data="tableObj.list" border fit highlight-current-row style="width: 100%;" :row-style="rowStyle" :cell-style="cellStyle" class="elTable table-fixed" >

        <el-table-column label="序号" align="center" type="index" width="50px" fixed="left">
          <template slot-scope="scope">
            <span>{{ scope.$index + (tableObj.pageNum-1) * tableObj.pageSize + 1 }}</span>
          </template>
        </el-table-column>

        <el-table-column label="款项类型" min-width="120px" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ scope.row.costTypeName  }}</span>
          </template>
        </el-table-column>
        <el-table-column label="单据编号" min-width="110px" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ scope.row.orderCode  }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户" min-width="110px" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ scope.row.customerName  }}</span>
          </template>
        </el-table-column>
        <el-table-column label="合同金额" min-width="110px" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ scope.row.cost  }}</span>
          </template>
        </el-table-column>


        <el-table-column label="创建人" min-width="110px" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ scope.row.createrName  }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="{row}">
            <!-- <el-button  class="miniSuccess" v-show = "row.serviceName == '远程服务'" @click="form_detail1(row)">去完成</el-button>
             -->
            <el-button  class="miniSuccess"  v-if="row.costTypeName =='合同款项' " @click="form_detail1(row)">去完成</el-button>
            <el-button class="miniSuccess"   v-if="row.costTypeName =='远程服务款项' " @click="form_detail2(row)">去完成</el-button>
            <el-button class="miniSuccess"   v-if="row.costTypeName =='现场服务款项' " @click="form_detail3(row)">去完成</el-button>
            <el-button class="miniSuccess"   v-if="row.costTypeName =='维修服务款项' " @click="form_detail4(row)">去完成</el-button>
            <el-button class="miniSuccess"    v-if="row.costTypeName =='报销款项' "@click="form_detail5(row)">去完成</el-button>
          </template>
        </el-table-column>


      </el-table>

    </div>
</div>
</template>
<script>


import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons, calculativeWidth } from '@/api/common'
import Cookies from 'js-cookie'
import { parseTime } from '@/utils/index.js'
import Pagination from '@/components/Pagination'
import { MessageBox } from 'element-ui'
import { getToken } from '@/utils/auth'

export default {
  name: 'ToDoReviewList',
  components: { Pagination },
  props: {
    todoReview: {
      type: Object,
      required: true
    }
  },
  data() {
    return {

      //列表请求
      tableObj: {
        getdataListParm: {
          name: 'getCostToDoList',
          page: 1,
          offset: 1,
          pagecount: 1000,
          returntype: 'Map',
          parammaps: {
            "userId":Cookies.get('g_userId'),
           }
        },
        tableKey: 0,
        list: [


        ],
        total: 0,
        listLoading: false,
        temp: {},


      },
      isokDisable: false,
      selectList: [],
         rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
         cellStyle: { padding: 0 + 'px' }


    }
  },
 watch: {
  todoReview: {
      deep: true,
      handler: function (item) {
         console.log("父组件：", item)

        //  if(item.title == 'see'){
        //     this.tableObj.getdataListParm.parammaps.stockupIds = item.stockupIds
        //     this.tableObj.getdataListParm.name =  'getStockupSelectByDelivery2'
        //   }else{
        //       this.tableObj.getdataListParm.parammaps.stockupIds = ""
        //       this.tableObj.getdataListParm.name =  'getStockupSelectByDelivery'
        //   }

        //   this.get_table_data()

      }
    },

  },
  mounted() {

  },


  created() {

    this.get_table_data()

  },
  beforeDestroy() {

  },
  methods: {


    //加载表格
    get_table_data() {

      this.tableObj.listLoading = true
      GetDataByName(this.tableObj.getdataListParm).then(response => {
        console.log('table数据', response.data.list)
        if (response.data.list !== null) {

          this.tableObj.list = response.data.list
          this.tableObj.pageNum = response.data.pageNum
          this.tableObj.pageSize = response.data.pageSize
          this.tableObj.total = response.data.total
        } else {
          this.tableObj.list = []
        }
        setTimeout(() => {
          this.tableObj.listLoading = false
        }, 100)
      })
    },


    //事件 - 清空查询信息
    form_clear() {
      console.log('点击了重置')

      this.tableObj.getdataListParm.parammaps.contractCode  = ''


      this.tableObj.getdataListParm.offset = 1
      this.get_table_data()
    },


    form_detail1(row) {
      console.log('点击了合同款项 ', row)
      // var codeNum = "CT220711003"
      var codeNum = row.contractCode
      var stages = row.stages
      // 跳合同款项 - 查看
      this.$router.push({ name: 'ContractPayment', params: { rowData: row, isHome: 'home',codeNum:codeNum, stages:stages }})


    },

    form_detail2(row) {
      console.log('点击了远程服务款项', row)
      // 跳远程服务款项 - 查看
     // var codeNum = "RS221009001"
      var codeNum = row.contractCode
      this.$router.push({ name: 'RemotePayment', params: { rowData: row, isHome: 'home',codeNum:codeNum }})
    },

    form_detail3(row) {
      console.log('点击了现场服务款项', row)
      // 跳现场服务款项- 查看
      // var codeNum = "FS221014001"
      var codeNum = row.contractCode
       this.$router.push({ name: 'SitePayment', params: { rowData: row, isHome: 'home',codeNum:codeNum }})
    },

    form_detail4(row) {
      console.log('点击了维修服务款项', row)
      // 跳维修服务款项- 查看
      // var codeNum = "MS221012001"
      var codeNum = row.contractCode
       this.$router.push({ name: 'RepairPayment', params: { rowData: row, isHome: 'home',codeNum:codeNum }})
    },

    form_detail5(row) {
      console.log('点击了报销款项', row)
      // 跳报销款项- 查看
       //var codeNum = "EA220928003"
       var codeNum = row.contractCode
       this.$router.push({ name: 'ExpensesPayment', params: { rowData: row, isHome: 'home',codeNum:codeNum }})
    },


  }
}
</script>
