<template>
  <div>
    <van-nav-bar
      title="我的事项"
      left-arrow
      @click-left="$router.back(-1)"
    />
    <van-tabs v-model="activeName" title-active-color="#1D6FE9" color="#1D6FE9" line-width="20px" swipeable @click="getList">
      <van-tab title="待办" name="1" >
      </van-tab>
      <van-tab title="已办" name="2">
      </van-tab>
    </van-tabs>
    <van-cell-group v-for="(item,index) in taskList" :key="index" style="width: 96%;margin:2%;border-radius: 6px;overflow: hidden;padding-top: 10px;padding-bottom: 10px;box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);">
      <van-cell>
        <template #title>
          <van-row style="margin-bottom:10px ">
            <van-col span="23" :offset="1">

              <h3 style="display: inline-block;line-height: 30px;margin-left: 6px;width: 100%;overflow: hidden;">
                <van-image
                  height="20"
                  width="20"
                  style="vertical-align: middle;margin-right: 10px"
                  src="../../../static/images/onlineHome/done.png"></van-image>{{item.projectName}}</h3>
            </van-col>
          </van-row>
        </template>
        <template #label>
          <van-row style="margin: 5px 0">
            <van-col span="15" :offset="1">
              <p style="font-size: 14px;">申请：</p>
            </van-col>
            <van-col span="6" :offset="2">
              <p style="font-size: 14px;font-weight:bold;text-align: right;color: #1D6FE9">{{activeName=='1'?'待审批':'已审批'}}</p>
            </van-col>
          </van-row>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <van-row>
            <van-col span="6" :offset="1">
              <p style="color: #878787">{{item.createTime?item.createTime.substring(0,10):item.startTime.substring(0,10)}}</p>
            </van-col>
            <van-col span="16" :offset="1">
              <p style="color: #878787">{{item.tableName}}</p>
            </van-col>
          </van-row>
        </template>
      </van-cell>
    </van-cell-group>
  </div>
</template>

<script>
    import onlineHomeIndex from "../onlineHomeIndex";
    import {ListDone, ListTodo} from "../../api/onlineHome/done";

    export default {
      components: {
        onlineHomeIndex
      },
        name: "doneDetail",
      data(){
        return{
          taskList:[],
          activeName:'1',
          total:0,
          queryParams: {
            pageNum: 1,
            pageSize: 100,
          },
        }
      },
      created() {
        this.getList();
      },
      methods: {
        getList() {
          this.taskList = []
          this.$set(this.queryParams, "systemType", '');
          if(this.activeName=='1'){
            ListTodo(this.queryParams).then((response) => {
              console.log(response)
              response.rows.map(res => {
                if(res.tableName?res.tableName.indexOf('house')>0:""){
                  res.tableName = '来自农村宅基地管理系统'
                }else if(res.tableName?res.tableName.indexOf('sys_seal')>0:""){
                  res.tableName = '来自银农直联审批管理系统'
                }else if(res.tableName?res.tableName.indexOf('yinnong')>0:""){
                  res.tableName = '来自银农直联审批管理系统'
                }
                this.taskList.push(res)
              })
            })
          }else{
            ListDone(this.queryParams).then((response) => {
              console.log(response)
              response.rows.map(res => {
                if(res.tableName?res.tableName.indexOf('house')>0:""){
                  res.tableName = '来自农村宅基地管理系统'
                }else if(res.tableName?res.tableName.indexOf('sys_seal')>0:""){
                  res.tableName = '来自银农直联审批管理系统'
                }else if(res.tableName?res.tableName.indexOf('yinnong')>0:""){
                  res.tableName = '来自银农直联审批管理系统'
                }
                this.taskList.push(res)
              })
            })
          }
        },
      },
    }
</script>

<style scoped>

</style>
