<template>
  <div>
    <van-nav-bar
      title="待办事项"
    />
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white" style="width: 96%;margin: 2%;height:128px;border-radius: 6px;">
      <van-swipe-item v-for="(image,index) in images" :key="index">
        <img :src="image" style="width:100%;height: 128px"/>
      </van-swipe-item>
    </van-swipe>
    <van-cell-group @click="goDetail(item)" 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="">
            <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>
      </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="10" :offset="1">
              <p style="color: #878787">{{item.formData.activityBusinessType}}</p>
            </van-col>
            <van-col span="5" :offset="1">
              <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-group>
    <van-empty v-if="taskList.length<1" description="暂无事项" />
    <yinnongIndex></yinnongIndex>
  </div>
</template>

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

    export default {
      components: {
        onlineHomeIndex,
        yinnongIndex
      },
        name: "done",
      data(){
        return{
          taskList:[],
          activeName:this.$route.query.activeName?this.$route.query.activeName:'1',
          total:0,
          nickName:"",
          electronicSignature:"",
          queryParams: {
            pageNum: 1,
            pageSize: 100,
          },
          activityBusinessTypeOptions:[],
          images:['../../../../static/images/onlineHome/banner_03.png'],
        }
      },
      created() {
        this.getDicts("activity_business_type").then((response) => {
          this.activityBusinessTypeOptions = response.data;
          if(this.$route.query.activeName){
            this.activeName = this.$route.query.activeName
          }
          this.getList();
        });
        console.log(this.$route.query.fr)
        if(this.$route.query.fr){
          this.$cookies.set("from",this.$route.query.fr,"0")
        }
        getInfo().then((response) => {
            this.electronicSignature = response.user.electronicSignature;
            this.nickName = response.user.nickName;
        });
      },
      methods: {
        goOnlineHomeIndex(){
          if(this.$cookies.get("from")=="my"){
            this.$router.push({name:"yinnongMy"})
          }else{
            this.$router.push({name:"yinnongWorkbench"})
          }
        },
        getList() {
          this.taskList = []
          // this.$set(this.queryParams, "systemType", '4');
          ListTodo(this.queryParams).then((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 = '来自银农直联审批管理系统'
              }
              if(this.activityBusinessTypeOptions){
                this.activityBusinessTypeOptions.map(t => {
                  if(t.dictValue == res.formData.activityBusinessType){
                    res.formData.activityBusinessType = t.dictLabel
                    this.taskList.push(res)
                  }
                });
              }
            })
          })
        },
        goDetail(item){
          console.log(item)
          let type = item.formData.processKey;
          switch (type) {
            case 'homeuseZyyctcsq':
              this.$router.push({name:'sunVillageInfoPaidExitDetail',query: {id:item.formData.id,taskId:item.taskId,instanceId:item.formData.instanceId,type:item.type,electronicSignature:this.electronicSignature,nickName:this.nickName}})
              break;
            case 'home_check':
            case 'home_start':
              this.$router.push({name:'approvalForm',query: {id:item.formData.ydjfsqId,taskId:item.taskId,instanceId:item.formData.instanceId,type:item.type,electronicSignature:this.electronicSignature,nickName:this.nickName}})
              break;
            case 'home_apply':
              this.$router.push({name:'approvalForm',query: {id:item.formData.id,taskId:item.taskId,instanceId:item.formData.instanceId,type:item.type,electronicSignature:this.electronicSignature,nickName:this.nickName}})
              break;
            case 'baseApply':
            case 'landscope':
            case 'accepting':
              this.$router.push({name:'approvalForm',query: {id:item.formData.id,taskId:item.taskId,instanceId:item.formData.instanceId,type:item.type}})
              break;
            case 'toReviewTransferProcess':
            case 'yinnong_transfer':
              if(item.formData.transferType == '10'){
                this.$router.push({name:'approvalApproval10',query: {id:item.formData.id,taskId:item.taskId,type:item.type}})
                break;
              }
              if(item.formData.transferType == '11'){
                this.$router.push({name:'approvalApproval11',query: {id:item.formData.id,taskId:item.taskId,type:item.type}})
                break;
              }
              if(item.formData.transferType == '12'){
                this.$router.push({name:'approvalApproval12',query: {id:item.formData.id,taskId:item.taskId,type:item.type}})
                break;
              }
              if(item.formData.transferType != '10'&&item.formData.transferType != '11'&&item.formData.transferType != '12'){
                this.$router.push({name:'approvalApproval',query: {id:item.formData.id,taskId:item.taskId,type:item.type}})
                break;
              }
          }
        }
      },
    }
</script>

<style scoped>
  >>>.my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 144px;
    text-align: center;
  }
</style>
