<template>
  <div class="dashboard-container">
    <el-form :inline="true" class="demo-form-inline mar-l-0 listStyle" style="width:100%;" :model="form" ref="form">
      <div class="all-row-b5 search-div" style="margin-bottom:10px;">
        <el-row>
          <el-col :span="8">
            <el-form-item label="监测点：" placeholder="请输入" label-position="left" prop="takNameId">
              <el-input v-model="form.jcd" class="search-width" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="上报地区：" placeholder="请输入" prop="takTask" class="pubWid">
              <el-select v-model="form.sbdq" clearable placeholder="全部" class="search-width">
                <el-option v-for="item in dataDictioPubArr" :key="item.cogKey" :label="item.cogValue"
                  :value="item.cogKey">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <div class="search-button">
              <span class="search-line"></span>
              <div class="search-select" @click="searchShowMore">更多条件 <i class="el-icon-arrow-up"
                  v-show="searchShowMoreBool"></i><i class="el-icon-arrow-down" v-show="!searchShowMoreBool"></i></div>
              <el-button class="outButton" size="mini" type="primary" @click="getList()">
                <i class="iconfont">&#xe67f;</i>
                查询</el-button>
             </div> 
          </el-col>
        
        <div v-show="searchShowMoreBool">
          <el-col :span="7">
            <el-form-item label="状态：" prop="runState">
              <el-select v-model="form.reportStatus" clearable placeholder="全部" class="search-width">
                <el-option v-for="item in reportStatuss" :key="item.key" :label="item.value" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="上报日期" class="fourLabel">
              <el-date-picker v-model="form.data" type="daterange" range-separator="至" start-placeholder="开始日期"
                end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </div>
      </el-row>
        <el-row>
          <div style="clear: both;border-top: 1px dashed rgb(90, 170, 250);margin-bottom: 10px;"></div>
          <div class="addBtnBg">
            <el-button class="outButton" icon="el-icon-search" size="primary" type="primary" @click='getList'>查询
            </el-button>
            <el-button class="outButton" icon="el-icon-search" size="primary" type="primary">清空</el-button>
          </div>
        </el-row>
      </div>
    </el-form>
    <el-row>
      <el-table tooltip-effect="dark" style="width: 100%;margin-top:10px;" align="center" border stripe
        highlight-current-rowv-loading="tableLoading" :data="tableData">
        <el-table-column align="center" label="序号" width="60">
          <template slot-scope="scope"><span>{{scope.$index+1}}</span></template>
        </el-table-column>
        <el-table-column align="center" :show-overflow-tooltip="true" label="上报地区" prop="sbdq">
        </el-table-column>
        <el-table-column align="center" :show-overflow-tooltip="true" label="上报监测点" prop="jcd">
        </el-table-column>
        <el-table-column align="center" :show-overflow-tooltip="true" prop="createBy" label="上报人">
        </el-table-column>
        <el-table-column align="center" :show-overflow-tooltip="true" prop="createTime" label="上报时间">
        </el-table-column>
        <el-table-column align="center" :show-overflow-tooltip="true" prop="sbkssj" label="上报开始时间">
        </el-table-column>
        <el-table-column align="center" :show-overflow-tooltip="true" prop="sbjssj" label="上报结束时间">
        </el-table-column>
        <el-table-column align="center" :show-overflow-tooltip="true" prop="lcid" label="状态">
        </el-table-column>
        <el-table-column width="200" label="操作">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="light" content="查看" placement="top">
              <el-button class="button operate_show_btn" size="mini" type="primary" @click.stop="see('see',scope.row)">
                <i class="iconfont">&#xe67e;</i>
              </el-button>
            </el-tooltip>
           </template>
        </el-table-column>
      </el-table>
      <!-- 分页开始 -->
      <div class="pagination-container">
        <el-pagination class="right" :current-page.sync="limit.page" :page-size="limit.size" :page-sizes="[10,20,30,40]"
          :total="limit.total" @size-change="getList" @current-change="getList"
          layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
      </div>
    </el-row>

  </div>
</template>

<script>
  import { mapGetters } from 'vuex'
  import { showDataLists } from '@/api/emergencyManagement/monitoringWarning/index'
  
  export default {
    name: 'Daily',
    data() {
      return {
        searchShowMoreBool: false,

        reportStatuss: [
          {
            key: '1',
            value: '提交',
          }, {
            key: '2',
            value: '发布',
          }, {
            key: '3',
            value: '驳回',
          }
        ],
        form: {
          data: '',
          jcd: '',
          sbdq: '',
          reportStatus: ''
        },
        yearArr: [{
          index: 1,
          value: '发布'
        }],
        status: [{
          index: 1,
          dictName: '未提交',
        }, {
          index: 2,
          dictName: '已提交',
        }, {
          index: 3,
          dictName: '审核通过',
        }, {
          index: 4,
          dictName: '驳回',
        }],
        dataDictioPubArr: [{
          index: 1
        }],
        tableData: [],
        limit: {
          page: 1,
          size: 10,
          total: 0
        }
      }
    },
    computed: {
      ...mapGetters([
        'name'
      ])
    },
    created() {
      this.getList();
    },
    methods: {
      //更多条件点击事件
      searchShowMore() {
        this.searchShowMoreBool = !this.searchShowMoreBool;
      },
      // List init
      getList() {
        if (this.form.data.length > 1) {
          this.startDate = this.form.data[0]
          this.endDate = this.form.data[1]
        }
        const data = {
          'startDate': this.startDate,
          'endDate': this.endDate,
          'jcd': this.form.jcd,
          // 'point': this.form.point,
          'reportStatus': this.form.reportStatus,
          "priceType": "LtdXKgAUOJ3D7tpkHxP",
          'sbdq': this.form.sbdq,
          'page': this.limit.page,
          'size': this.limit.size
        }
        showDataLists(data).then(response => {
          this.tableData = response.data.resultList
          this.limit.total = response.data.total
          this.tableData.forEach((o) => {
            // if (o.status === '1') {
            //     o.status = false
            // } else {
            //     o.status = true
            // }
            if (o.status === '0') {
              o.status = '暂存'
            }
            if (o.status === '1') {
              o.status = '已上报'
            }
          })
          this.isloading = false
          // this.formPage.total = response.data.total
          console.log('request数据成功')
        }).catch(function (error) {
          console.log(error)
        })
      },
      handleChangeSize(value) {

      },
      handleCurrentChangePage(value) {
      },
      see(state, row) {
        if (state === 'see') {
          this.$router.push({ path: '/emergencyManagement/monitoringWarning/detail', query: { id: row.id, state: 'see' } })
        } else if (state === 'edit') {
          this.$router.push({ path: '/emergencyManagement/monitoringWarning/detail', query: { id: row.id, state: 'edit' } })
        }
      },
      addBtn() {
        this.$router.push({ path: '/dailyManage/main-detail' })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .search {
    &-div {
      .el-col-8 {
        width: 32%;
        height: 48px;

        .search-input {
          .el-form-item {
            // display: inline-block;
            // width: auto!important;
            // margin-bottom: 15px;
          }
        }

        .search-button {
          margin-right: 40px;
          float: right;

          .search-line {
            cursor: pointer;
            border-left: 1px dashed #737bf1;
            height: 38px;
            display: inline-block;
            margin-right: 14px;
            float: left;
          }

          .search-select {
            color: #409eff;
            background: #deebf9;
            border-color: #b3d8ff;
            display: inline-block;
            height: 36px;
            line-height: 36px;
            margin-right: 10px;
            border-radius: 4px;
            font-size: 14px;
            padding: 0 8px;
            cursor: pointer;
          }
        }
      }
    }
  }

  .dashboard {
    &-container {
      margin: 30px;
    }

    &-text {
      font-size: 30px;
      line-height: 46px;
    }
  }
</style>