<template>
  <div class="home-page">
    <div class="task-body">
      <!-- 左侧菜单 -->
      <div class="menu">
        <div class="taskManager">云资源申请</div>
        <div
          v-for="(item, index) in menuItems"
          :key="index"
          :class="['menu-item', { active: selectedMenu === item.value }]"
          @click="selectMenu(item.value)"
        >
<!--          <img :src="item.url" alt="" class="menu-img">-->
          <div class="menu-text">{{ item.label }}</div>
        </div>
      </div>
      <!-- 右侧内容 -->
      <div class="content">
        <div class="back">
          <div @click="goBack">
            <i class="el-icon-back back-icon"></i>
            <div class="back-text">返回</div>
          </div>
          <div>
            <el-button v-if="selectedMenu === 'putIn'" @click="handleAdd" type="primary" size="mini" icon="el-icon-plus" >新增</el-button>
          </div>
        </div>
        <el-tabs v-model="activeName" @tab-click="tabChange" v-if="selectedMenu === 'putIn'">
          <el-tab-pane :label="item.name" :name="item.value" v-for="(item,index) in tabList" :key="index"></el-tab-pane>
          <div class="list-body">
            <div class="company-news" v-for="(item,index) in wealthList" :key="index" :title="item.title" @click="taskChange(item)">
              <div class="box-con">
                <span :style="{background:statusChange(item.status)}">{{dictionaryEscape('zy-gdzt', JSON.stringify(item.status))}}</span>
              </div>
              <div class="company-left">
                <div class="notice-month">08-20</div>
                <div class="notice-year">2025</div>
              </div>
              <div class="company-right">
                <div class="company-title" :title="item.applyCode">申请编号：{{item.applyCode}}</div>
                <div class="company-flex">
                  <div class="company-content">
                    <div class="company-unit company-use">应用系统名称：{{item.applyAppName}}</div>
                    <div class="company-unit">单位名称：{{item.applyUnitName}}</div>
                  </div>
<!--                    <img src="@/assets/img/homePage/arrow1.png" alt="" class="company-arrow">-->
                </div>
              </div>
            </div>
            <div class="task-page">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="params.pageBean.page"
                :page-sizes="[10, 20, 30, 40, 50]"
                :page-size="params.pageBean.pageSize"
                layout="total, sizes, prev, pager, next"
                :total="params.pageBean.total">
              </el-pagination>
            </div>
          </div>
        </el-tabs>
        <div class="list-body" v-else>
          <div class="company-news" v-for="(item,index) in wealthList" :key="index" :title="item.title" @click="taskChange(item)">
            <div class="box-con">
              <span :style="{background:statusChange(item.status)}">{{dictionaryEscape('zy-gdzt', JSON.stringify(item.status))}}</span>
            </div>
            <div class="company-left">
              <div class="notice-month">08-20</div>
              <div class="notice-year">2025</div>
            </div>
            <div class="company-right">
              <div class="company-title" :title="item.applyCode">申请编号：{{item.applyCode}}</div>
              <div class="company-flex">
                <div class="company-content">
                  <div class="company-unit company-use">应用系统名称：{{item.applyAppName}}</div>
                  <div class="company-unit">单位名称：{{item.applyUnitName}}</div>
                </div>
                <!--                    <img src="@/assets/img/homePage/arrow1.png" alt="" class="company-arrow">-->
              </div>
            </div>
          </div>
          <div class="task-page">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="params.pageBean.page"
              :page-sizes="[10, 20, 30, 40, 50]"
              :page-size="params.pageBean.pageSize"
              layout="total, sizes, prev, pager, next"
              :total="params.pageBean.total">
            </el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { dictionaryEscape } from '@/utils/dictionary'
import { putInTableData,auditTableData } from '@/api/publicBasic/resourceBid'
export default {
  data() {
    return {
      activeName:'5',
      selectedMenu: 'putIn',
      menuItems: [
        { label: '资源申请', value: 'putIn'},
        { label: '资源审核', value: 'audit'},
        { label: '资源执行', value: 'execute'},
      ],
      tabList:[
        {
        name:'全部',
        value:'5'
      },{
        name:'已执行',
        value:'40'
      },{
        name:'待执行',
        value:'30'
      },{
        name:'审核未通过',
        value:'20'
      },{
        name:'待审批',
        value:'10'
      },{
        name:'草稿',
        value:'0'
      }
      ],
      wealthList:[
        {
          "createTime": "2024-08-15 15:44:50",
          "isDele": "0",
          "id": "1823989206050017280",
          "applyCode": "2024080011",
          "applyUnitName": "测试流程",
          "applyUnitContacts": "测试流程",
          "applyUnitContactsPhone": "19898989898",
          "applyUnitContactsMail": "96@163.com",
          "applyDate": "2024-08-15",
          "applyAppName": "测试流程",
          "applyAppDevelopUnit": "测试流程",
          "cloudType": 2,
          "appPurpose": "测试流程",
          "applyAppContracts": "测试流程",
          "applyAppContractsPhone": "18989898989",
          "virtualMachineNum": 99,
          "cpuNum": 99,
          "memoryCapacity": 288,
          "dataCapacity": 2048,
          "status": 10,
          "applyUnitOpinion": "管理员<br/>2024-08-15 17:06:47",
          "tenantId": "-1",
          "pkVal": "1823989206050017280"
        },
        {
          "createTime": "2024-08-15 17:39:19",
          "isDele": "0",
          "id": "1824018013536522240",
          "applyCode": "2024080012",
          "applyUnitName": "测试草稿",
          "applyUnitContacts": "123",
          "applyUnitContactsPhone": "16965854576",
          "applyUnitContactsMail": "1258@163.com",
          "applyDate": "2024-08-15",
          "applyAppName": "测试",
          "applyAppDevelopUnit": "测试",
          "cloudType": 1,
          "appPurpose": "测试",
          "applyAppContracts": "测试",
          "applyAppContractsPhone": "19898775415",
          "virtualMachineNum": 99,
          "cpuNum": 99,
          "memoryCapacity": 558,
          "dataCapacity": 2048,
          "status": 30,
          "applyUnitOpinion": "管理员<br/>2024-08-16 15:54:17",
          "managerUnitOpinion": "同意<br/>管理员<br/>2024-08-16 15:54:58",
          "cloudApplyFile": [
            {
              "createTime": "2024-08-16 15:07:25",
              "isDele": "0",
              "id": "1824342177178849280",
              "type": "pdf",
              "sourceId": "1824018013536522240",
              "name": "SSH2.0技术介绍.pdf",
              "url": "http://111.10.223.232:29001/yhxt/resourceApply/0bfb0b90b8fe49694caed65347ee896e.pdf",
              "group": "cloudApply",
              "suffix": "pdf",
              "pkVal": "1824342177178849280"
            }
          ],
          "tenantId": "-1",
          "pkVal": "1824018013536522240"
        },
        {
          "createTime": "2024-08-15 17:41:58",
          "isDele": "0",
          "id": "1824018680661544960",
          "applyCode": "2024080013",
          "applyUnitName": "测试草稿",
          "applyUnitContacts": "测试",
          "applyUnitContactsPhone": "19696969696",
          "applyUnitContactsMail": "163@163.com",
          "applyDate": "2024-08-15",
          "applyAppName": "测试草稿",
          "applyAppDevelopUnit": "测试草稿",
          "cloudType": 1,
          "appPurpose": "测试草稿",
          "applyAppContracts": "测试草稿",
          "applyAppContractsPhone": "18798575225",
          "virtualMachineNum": 99,
          "cpuNum": 99,
          "memoryCapacity": 99,
          "dataCapacity": 99,
          "status": 40,
          "applyUnitOpinion": "管理员<br/>2024-08-16 14:49:40",
          "managerUnitOpinion": "同意<br/>管理员<br/>2024-08-16 14:59:45",
          "tenantId": "-1",
          "pkVal": "1824018680661544960"
        },
        {
          "createTime": "2024-08-16 15:52:16",
          "isDele": "0",
          "id": "1824353464361291776",
          "applyCode": "2024080014",
          "applyUnitName": "测试附件",
          "applyUnitContacts": "测试",
          "applyUnitContactsPhone": "19898989898",
          "applyUnitContactsMail": "154@163.com",
          "applyDate": "2024-08-16",
          "applyAppName": "测试",
          "applyAppDevelopUnit": "测试",
          "cloudType": 1,
          "appPurpose": "测试",
          "applyAppContracts": "测试",
          "applyAppContractsPhone": "18975989515",
          "virtualMachineNum": 99,
          "cpuNum": 56,
          "memoryCapacity": 555,
          "dataCapacity": 555,
          "status": 0,
          "tenantId": "-1",
          "pkVal": "1824353464361291776"
        },
        {
          "createTime": "2024-08-16 17:31:52",
          "isDele": "0",
          "id": "1824378527844274176",
          "applyCode": "2024080015",
          "applyUnitName": "测试单位123",
          "applyUnitContacts": "张三",
          "applyUnitContactsPhone": "15877776666",
          "applyUnitContactsMail": "123@123.com",
          "applyDate": "2024-08-16",
          "applyAppName": "测试应用",
          "applyAppDevelopUnit": "测试开发单位",
          "cloudType": 2,
          "appPurpose": "测试",
          "applyAppContracts": "王五",
          "applyAppContractsPhone": "13200009999",
          "virtualMachineNum": 2,
          "cpuNum": 8,
          "memoryCapacity": 32,
          "dataCapacity": 128,
          "status": 40,
          "applyUnitOpinion": "管理员<br/>2024-08-16 17:39:33",
          "managerUnitOpinion": "通过，请执行<br/>管理员<br/>2024-08-16 17:40:12",
          "tenantId": "-1",
          "pkVal": "1824378527844274176"
        },
        {
          "createTime": "2024-08-21 14:14:16",
          "isDele": "0",
          "id": "1826140744830816256",
          "applyCode": "2024080016",
          "applyUnitName": "1",
          "applyUnitContacts": "1",
          "applyUnitContactsPhone": "18883172675",
          "applyUnitContactsMail": "1394074092@qq.com",
          "applyDate": "2024-08-21",
          "applyAppName": "1",
          "applyAppDevelopUnit": "1",
          "cloudType": 1,
          "appPurpose": "1",
          "applyAppContracts": "1",
          "applyAppContractsPhone": "18883172675",
          "virtualMachineNum": 1,
          "cpuNum": 1,
          "memoryCapacity": 1,
          "dataCapacity": 1,
          "status": 0,
          "tenantId": "-1",
          "pkVal": "1826140744830816256"
        }
      ],
      params:{
        pageBean: {
          page: 1,
          pageSize: 10,
          total: 0,
        },
        querys: [{
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property:'status',
          relation: 'AND',
          value: null,
        }],
      }
    }
  },
  created() {
    if(JSON.stringify(this.$route.query) !== '{}'){
       this.selectedMenu = this.$route.query.selectedMenu;
       if(this.$route.query.pageType === 'apply'){
         this.loadData()
       }else if(this.$route.query.pageType === 'audit'){
         this.params.querys[0].value = 10
         this.auditDataChange()
       }else{
         this.params.querys[0].value = 30
         this.auditDataChange()
       }
    }else{
      this.loadData()
    }
  },
  methods: {
    dictionaryEscape,
    statusChange(status){
      switch (status) {
        case 0:
          return '#909399';
        case 10:
          return '#E6A23C';
        case 20:
          return '#F56C6C';
        case 30:
          return '#409EFF';
        case 40:
          return '#67C23A';
        default:
          return '#409EFF';
      }
    },
    // 左边菜单点击
    selectMenu(value) {
      this.params.pageBean.page = 1;
      this.params.pageBean.pageSize = 10;
      this.selectedMenu = value
      if(value === "putIn") {
        this.loadData()
      }else if(value === "audit") {
        this.params.querys[0].value = 10
        this.auditDataChange()
      }else{
        this.params.querys[0].value = 30
        this.auditDataChange()
      }
    },
    // 返回
    goBack(){
      this.$router.push({path:'/platLayout/homePage'});
    },
    // 资源新增
    handleAdd(){
      this.$router.push({ path: '/platLayout/resourceAddEditPage', query: { pageType:'apply', type:'add', id:'',selectedMenu:this.selectedMenu } });
    },
    // 右边内容点击
    taskChange(item){
      if(this.selectedMenu === 'putIn'){
        this.$router.push({ path: '/platLayout/resourceAddEditPage', query: { pageType:'apply', type:'edit', id: item.id,selectedMenu:this.selectedMenu } });
      }else if(this.selectedMenu === 'audit'){
        this.$router.push({ path: '/platLayout/resourceAddEditPage', query: { pageType:'audit', type:'edit', id: item.id,selectedMenu:this.selectedMenu } });
      }else{
        this.$router.push({ path: '/platLayout/resourceAddEditPage', query: { pageType:'excute', type:'edit', id: item.id,selectedMenu:this.selectedMenu } });
      }
    },
    // tab点击事件
    tabChange(){
      this.params.pageBean.page = 1;
      this.params.pageBean.pageSize = 10;
      this.params.querys[0].value = this.activeName;
      this.loadData()
    },
    // 资源申请列表
    async loadData() {
      const { rows,page,pageSize,total } = await putInTableData(this.params)
      this.wealthList = rows
      this.pageResult.page = page
      this.pageResult.pageSize = pageSize
      this.pageResult.total = total
    },
    // 资源审核、资源执行
    async auditDataChange(){
      const { rows,page,pageSize,total } = await auditTableData(this.params)
      this.wealthList = rows
      this.pageResult.page = page
      this.pageResult.pageSize = pageSize
      this.pageResult.total = total
    },
    // 分页
    handleSizeChange(size){
      this.params.pageBean.page = 1
      this.params.pageBean.pageSize = size
      if(this.selectedMenu === 'putIn'){
        this.loadData()
      }else{
        this.auditDataChange()
      }
    },
    handleCurrentChange(page){
      this.params.pageBean.page = page
      if(this.selectedMenu === 'putIn'){
        this.loadData()
      }else{
        this.auditDataChange()
      }
    }
  }
}
</script>

<style scoped lang="scss">
::v-deep .el-pager li.active{
  color: #43a1ff;
}
::v-deep .el-pager li{
  color: #f0f0f0;
  background: transparent;
}
::v-deep .el-pagination .btn-prev{
  background: transparent;
}
::v-deep .el-pagination .btn-next{
  background: transparent;
}
::v-deep .el-pagination__total{
  color: #f0f0f0;
}
::v-deep .el-tabs__item{
  font-size: 18px;
}
.home-page{
  width: 100%;
  //background: #F5F8FA;
  display: flex;
  justify-content: center;
  .task-body{
    width: 1200px;
    display: flex;
    margin: 16px 0;
  }
}
.menu {
  width: 200px;
  padding: 16px;
  box-sizing: border-box;
  margin-right: 15px;
  background-color: #114066;
  border-radius: 10px;
  .taskManager{
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: #f0f0f0;
    padding-bottom: 16px;
    border-bottom: 1px solid #E6E6E6;
  }
  .menu-item {
    display: flex;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
    cursor: pointer;
    justify-content: center;
    margin-top: 10px;
    .menu-img{
      width: 16px;
      height: 16px;
      margin-right: 10px;
    }
    .menu-text{
      transition: all 0.3s;
      color: #f0f0f0;
      font-size: 18px;
      font-family: Microsoft YaHei, Microsoft YaHei;
    }
  }
  .menu-item:hover{
    background: #1150A0;
    border-radius: 10px;
    box-shadow: 0 0 10px 0 rgba(0,0,0,0.1);
  }
  .menu-item:hover .menu-text{
    //color: #1150A0;
  }
  .active  {
    background: #1150A0;
    border-radius: 10px;
    box-shadow: 0 0 10px 0 rgba(0,0,0,0.1);
  }
}
.back{
  cursor: pointer;
  margin: 8px 0 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 29px;
  .back-icon{
    font-size: 16px;
    color: #f0f0f0;
  }
  .back-text{
    color: #f0f0f0;
    font-size: 16px;
    margin-left: 4px;
    display: inline;
  }
}
.content {
  width: 990px;
  padding: 16px;
  border-radius: 10px;
  box-sizing: border-box;
  background-color: #114066;
  .list-body{
    height: calc(100% - 140px);
    overflow-y: auto;
    //padding: 0 10px 0 0;
  }
  .task-relative{
    position: relative;
    top: 0;
    left: 0;
  }
  .task-page{
    width: calc(990px - 32px);
    text-align: center;
    position: fixed;
    bottom: 32px;
  }
  .task-empty{
    margin-top: 150px;
  }
  .company-news{
    display: flex;
    width: 100%;
    //box-shadow: 0 0 10px 0 rgba(0,0,0,0.1);
    border-radius: 10px;
    padding: 16px;
    box-sizing: border-box;
    cursor: pointer;
    border-bottom: 1px solid;
    border-image: linear-gradient(270deg,#f0f0f0,#D0DDED) 1;
    position: relative;
    top: 0;
    left: 0;
    overflow: hidden;
    .box-con{
      width:80px;
      height:80px;
      position: absolute;
      top:-40px;
      right:-40px;
      transform: rotate(45deg);
      span{
        position: absolute;
        bottom:0;
        display: block;
        font-size:14px;
        color:#fff;
        width:80px;
        text-align: center;
      }
    }
    .company-left{
      display: flex;
      flex-direction: column;
      width: 68px;
      margin-right: 16px;
      .notice-month {
        color: #999999;
        font-size: 20px;
        font-weight: 700;
        margin-top: 2px;
        font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
      }
      .notice-year {
        color: #999999;
        font-size: 16px;
        font-weight: 700;
        margin-top: 10px;
      }
    }
    .company-right{
      flex: 1;
      display: flex;
      flex-direction: column;
    }
    .company-title{
      font-size: 19px;
      color: #f0f0f0;
      display: -webkit-box;          /* 使用 flexbox */
      -webkit-box-orient: vertical; /* 垂直排列子元素 */
      -webkit-line-clamp: 1;        /* 限制显示的行数为 2 */
      overflow: hidden;              /* 隐藏超出部分 */
      text-overflow: ellipsis;
    }
    .company-content{
      display: flex;
      line-height: 25px;
      margin: 12px 0;
      .company-use{
        margin-right: 40px;
      }
      .company-unit{
        font-size:15px;
        color: #999999;
      }
    }
    .company-flex{
      display: flex;
      align-items: center;
      justify-content: space-between;
      .company-time{
        font-size: 15px;
        color: #999999;
      }
      .company-arrow{
        width:18px;
        height: 12px;
      }
    }
  }
  .company-news:first-child{
    margin-top: 0;
  }
  .company-news:nth-last-child(2){
    border: none;
  }
  .company-news:hover .company-title{
    color: #0963C4;
  }
  .company-news:hover .notice-month{
    color: #0963C4;
  }
  .company-news:hover .notice-year{
    color: #0963C4;
  }
  .company-news:hover{
    //border: none;
    //box-shadow: inset 0 0 10px 0 rgba(0,0,0,0.4);
    background: #0F304F50;
  }
}
</style>
