<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 +   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.approvalTypeName  }}</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.createrName  }}</span>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" min-width="110px" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ scope.row.createrDate  }}</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.typeName =='合同申请' && row.isDo == 1"  @click="form_detail1(row)">去审批</el-button>
            <el-button  class="miniPrimary" v-if="row.typeName =='合同申请' && row.isDo == 0"  @click="form_detail1(row)">查看</el-button>

            <el-button class="miniSuccess"  v-if="row.typeName =='出差申请'  && row.isDo == 1"  @click="form_detail2(row)">去审批</el-button>
            <el-button  class="miniPrimary" v-if="row.typeName =='出差申请' && row.isDo == 0"  @click="form_detail2(row)">查看</el-button>

            <el-button class="miniSuccess" v-if="row.typeName =='报销申请'  && row.isDo == 1"   @click="form_detail3(row)">去审批</el-button>
            <el-button  class="miniPrimary" v-if="row.typeName =='报销申请' && row.isDo == 0"  @click="form_detail3(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: 'ToDoApplyList',
  components: { Pagination },
  props: {
    todoApply: {
      type: Object,
      required: true
    }
  },
  data() {
    return {

      //列表请求
      tableObj: {
        getdataListParm: {
          name: 'getCheckToDoList',
          // page: 1,
          // offset: 1,
          // pagecount: 50,
          // 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: {
  todoApply: {
      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 = "CT221013001"
       var codeNum = row.orderCode
      // 跳合同款项 - 查看
      this.$router.push({ name: 'ContractApproval', params: { rowData: row, isHome: 'home',codeNum:codeNum }})


    },

    form_detail2(row) {
      console.log('点击了远程服务款项', row)
      // 跳远程服务款项 - 查看
       //var codeNum = "BT221009002"

       var codeNum = row.orderCode
      this.$router.push({ name: 'BusinessTravelApproval', params: { rowData: row, isHome: 'home',codeNum:codeNum }})
    },

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


  }
}
</script>
