<template>
  <div class="center">
    <div class="center_css">
      <div class="top_css">
            <el-button type="primary" @click="AddRecord">新增</el-button>
            <el-date-picker class='date' v-model="value1" value-format="yyyy-MM-dd" @change="dateChange" type="daterange"
              range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
            </el-date-picker>
            <div class="screen">
              <el-input class='find' v-model="searchkeyWord" @keyup.enter.native="find" placeholder="可按编号和标题内容查找" clearable />
              <el-button class="search" @click="find"><img width="16" height="16" style="margin-left: -8px"
                  src="../../../public/img/sousuo.png"></el-button>
            </div>
      </div>
      <el-table :data="tableData" style="width: 98%; margin: 0 auto; border-radius: 10px" height="55.8vh" border highlight-current-row>
        <el-table-column prop="number" label="编号" />
        <el-table-column prop="title" label="标题" />
         <el-table-column prop="issuingDate" label="公告日期" />
        <el-table-column prop="issuingAgency" label="发布人" />
        <el-table-column prop="updateDate" label="更新日期" />
        <el-table-column label="操作" min-width="300">
          <template slot-scope="scope">
            <el-link target="_blank" type="primary" :underline="false" @click="look(scope.row)">查看</el-link>
            <el-divider direction="vertical" />
            <el-link target="_blank" type="primary" :underline="false" @click="del(scope.row)">删除</el-link>
            <el-divider direction="vertical" />
            <el-link target="_blank" type="primary" :underline="false" @click="edit(scope.row)">编辑</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination :current-page="currentPage" style="text-align: center; margin-top: 10px"
      :page-size="deptCircularPage.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="deptBudgetTotal"
      @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  </div>
</template>
<script>
  import {
    getList,delFormData

  } from '@/api/officialWebsiteManagement'
  export default {
    data() {
      return {
        startDate: '',
        endDate: '',
         value1: '',
        tableData: [],
        // 分页
        searchkeyWord: '',
        currentPage: 1,
        pageSize: 10,
        deptBudgetTotal: 0,
        deptCircularPage: {},
        search: '',
        disabled: false,
      }
    },
    mounted() {
      this.getList()
    },
    methods: {
      dateChange(e) {
        this.startDate = e[0]
        this.endDate = e[1]
        this.getList()
      },
      AddRecord() {
        this.$router.push({
          path: 'newsAdd'
        })
      },
      getList() {
        this.loading = true
        const _obj = {}
        _obj.currentPage = this.currentPage
        _obj.pageSize = this.pageSize
        _obj.searchKeyWord = this.searchkeyWord
        _obj.startDate =  this.startDate
        _obj.endDate= this.endDate
        _obj.searchType = '公告'
        getList(_obj).then(response => {
            this.tableData = response.data.records
            this.deptBudgetTotal = response.data.total
            this.listLoading = false
          })
          .catch(() => {
            this.loading = false
          })
      },
      del(row) {
        this.$confirm('确定要删除该记录吗？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
          .then(() => {
            this.listLoading = true
            var _del = {}
            _del.id = row.id
            delFormData(_del).then(response => {
                this.$notify({
                  title: '成功',
                  message: '删除成功！',
                  type: 'success'
                })
                this.getList()
                this.listLoading = false
              })
              .catch(() => {
                this.loading = false
              })
          })
      },
      find() {
        this.getList()
      },
      look(row) {
        this.$router.push({
          path: 'newsLook',
          query: {
            id: row.id,
          }
        })
      },
      edit(row) {
        this.$router.push({
          path: 'newsEdit',
          query: {
            id: row.id,
          }
        })
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
        this.getList()
      }
    }
  }
</script>
<style lang="scss" scoped>
  .center {
    padding: 10px 20px;
    background: #f5f6f7;
    min-height: calc(100vh - 50px);

    .top_css {
      padding: 10px;
      display: flex;

      .search_btn {
        display: flex;
        margin-top: 20px;

        .search_item {
          text-align: center;
          font-size: 14px;
          font-weight: 600;
          line-height: 40px;
          width: 112px;
          height: 40px;
          background: #f7f8f9;
          cursor: pointer
        }

        .searchNo {
          color: #323233;
        }

        .search {
          color: #2f53eb;
          background: #ffffff;
        }
      }
    }

    .ask_css {
      position: absolute;
      margin: 3px 0 0 10px;
    }

    .center_css {
      background: #ffffff;
      border-radius: 1px;
      margin-top: 10px;
      padding-bottom: 10px;
    }

    .screen {
      display: flex;

      .search {
        width: 40px;
        height: 40px;
        background: #2f53eb;
        border-radius: 0px 2px 2px 0px;
        border: 1px solid #DCDFE6;
        margin-left:-1px;
      }

      .count_css {
        width: 80px;
        text-align: center;
        line-height: 40px;
        color: #666666;
      }
    }

    .el-button {
      padding: 10px 20px !important;
    }

    .center_css {

      ::v-deep .el-table th,
      ::v-deep .el-table td {
        text-align: center;
      }

      .fujian {
        font-size: 24px;
        color: #409eff;
      }

      .warning {
        font-size: 14px;
        color: #ed1d1d;
      }
    }
  }

  .car_css {
    width: 50%;
    display: inline-block;
    text-align: center;
    margin-top: 30px;
    position: relative;

    .status_css {
      background: #3AC602;
      width: 50px;
      height: 17px;
      position: absolute;
      top: 0px;
      right: 15px;
      border-radius: 3px;
    }

    .carno_css {
      padding: 1px 5px;
      background-color: #F5F6F7;
      color: #666666;
      border-radius: 12px;
      text-align: center;
      width: 100px;
      margin: 10px auto 0;
    }

    .carborder_css {
      border: 1px solid #F0F1F2;
      margin: 15px auto 0;
      width: 90%;
    }
  }

  .tips {
    color: #999999;
    font-size: 14px;
  }

  .car_item {
    width: 200px;
    height: 160px;
    border-radius: 5px;
  }

  .user {
    margin-bottom: 20px;

    .id_css {
      font-size: 14px;
    }

    .id_css,
    .name_css {
      margin: 5px 0;
      color: #0D0D0D;
    }

    .pay_name {
      color: #9D9D9D;
      font-size: 14px;
    }

    .name_css {
      font-size: 16px;
    }

    .user_item {
      margin: 25px 0;
      width: 450px;
      height: 300px;
    }

    .border_css {
      width: 100%;
      border: 1px solid #F0F1F2;
    }
  }

  ::v-deep .el-table--border .el-table__header th {
    background: #f7f8f9;
  }

  .btn_css {
    color: #409EFF;
    cursor: pointer
  }

  .btn_css1 {
    margin-left: -20px;
  }

  .sign {
    font-size: 14px;
    color: red;
  }

  .form_css {
    width: 100%;
    margin: 20px auto 20px;

    ::v-deep .el-checkbox {
      width: 40%;
      height: 30px;
    }

    // ::v-deep .el-dialog__body{
    // 	padding: 10px 20px;
    // }
    ::v-deep .el-dialog__title {
      font-size: 16px;
    }

    ::v-deep .el-textarea__inner {
      background: #F0F1F2;
    }

    .form_btn {
      text-align: right;
      margin-top: 10px;
    }
  }

  //发送信息
  .Info_css {
    .Info_title {
      color: #323233;
      font-size: 16px;
    }

    .Info_item {
      margin: 20px 0;
    }

    .Info_btn {
      text-align: right;
      margin-top: 10px;
    }
  }

  //附件
  .file {
    .fujian_css {
      width: 631px;
      display: flex;
      margin: 0 auto;
      text-align: center;
      line-height: 32px;
      border: 1px solid #F0F1F2;
      border-right: 0px;
      border-radius: 2px 0px 0px 2px;

      .fujian_item {
        cursor: pointer;
        width: 90px;
        height: 32px;
        border-right: 1px solid #F0F1F2;
      }

      .file_btn {
        color: #2F53EB;
        background-color: #CFDBFE;
      }
    }

    .file_img {
      width: 525px;
      height: 332px;
      margin: 20px auto;
    }

    .img_css {
      width: 525px;
      height: 332px;
    }

    .btn {
      width: 400px;
      margin: 0 auto;
    }
  }
  .date{
    margin:0 10px;
  }
  .find::v-deep input.el-input__inner{
    border-radius:0;
  }
</style>
