<template>
  <div class="content-main">
    <div class="search-bm-boder">
      <el-row>
        <el-form :inline="true" class="demo-form-inline search-form" :model="form" ref="form" label-width="58px">
          <el-form-item label="监测点:" placeholder="请输入" prop="orgName">
            <el-input v-model="form.orgName" class="inputCompatible" clearable></el-input>
          </el-form-item>
          <el-form-item label="上报地区:" placeholder="请输入" label-width="73px" prop="sbdq">
            <el-select v-model="form.sbdq" clearable placeholder="全部" class="inputCompatible">
              <el-option
                v-for="item in dataDictioPubArr"
                :key="item.countyCode"
                :label="item.countyName"
                :value="item.countyCode"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="状态:" prop="lcid">
            <el-select v-model="form.lcid" clearable placeholder="全部" class="inputCompatible">
              <el-option
                v-for="item in reportStatuss"
                :key="item.key"
                :label="item.value"
                :value="item.key"
              ></el-option>
            </el-select>
          </el-form-item>
          <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 type="primary" @click="getList" size="small" class="iconfont iconchaxun">查询</el-button>
            <el-button type="primary" @click="resetInfo('form')" size="small" class="iconfont iconzhongzhi"
              >重置</el-button
            >
          </div>
          <div v-show="searchShowMoreBool">
            <el-form-item label="上报时间:" prop="data">
              <el-date-picker
                v-model="form.data"
                class="dateInputCompatible"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              ></el-date-picker>
            </el-form-item>
          </div>
        </el-form>
      </el-row>
    </div>
    <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="areaName"
        ></el-table-column>
        <el-table-column
          align="center"
          :show-overflow-tooltip="true"
          label="上报监测点"
          prop="orgName"
          width="250"
        ></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="dayTime" 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="statusName" 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"
               
              >
                <i class="iconfont">&#xe67e;</i>
              </el-button>
            </el-tooltip> -->
            <el-tooltip class="item" effect="light" content="查看" placement="top">
              <el-button
                type="primary"
                size="small"
                class="iconfont iconchakan2 operate_show_btn"
                @click.stop="see('see', scope.row)"
              ></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,reportArea } from '@/api/grainCirculationPrice/grainPriceQuotation/historyData/index'
  import { treeOrg } from '@/api/grainCirculationPrice/grainPriceQuotation/weekQuotation/index'

export default {
  name: 'Daily',
  data() {
    return {
      searchShowMoreBool: false,

      reportStatuss: [
        {
          key: '1',
          value: '提交'
        },
        {
          key: '2',
          value: '发布'
        },
        {
          key: '3',
          value: '驳回'
        }
      ],
      form: {
        data: '',
        lcid: '',
        orgName: '',
        sbdq: ''
      },
      yearArr: [
        {
          index: 1,
          value: '发布'
        }
      ],
      status: [
        {
          index: 1,
          dictName: '未提交'
        },
        {
          index: 2,
          dictName: '已提交'
        },
        {
          index: 3,
          dictName: '审核通过'
        },
        {
          index: 4,
          dictName: '驳回'
        }
      ],
      dataDictioPubArr: [],
      tableData: [],
      limit: {
        page: 1,
        size: 10,
        total: 0
      }
    }
  },
  computed: {
    ...mapGetters(['name'])
  },
  created() {
    this.beforeCreate()
    this.getList()
  },
  methods: {
    beforeCreate() {
      
      reportArea().then(res => {
         if(res.status == 'SUCCESS') {
              this.dataDictioPubArr = res.data
          }
        console.log(this.dataDictioPubArr,123)
      })
    },

    resetInfo(formName) {
      this.$refs[formName].resetFields()
      this.getList()
    },
    //更多条件点击事件
    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,
        orgName: this.form.orgName,
        // 'point': this.form.point,
        reportStatus: this.form.lcid,
        areaCode: 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({
          name: 'historyDataDetail',
          query: { id: row.id, state: 'see' }
        })
      } else if (state === 'edit') {
        this.$router.push({
          name: 'historyDataDetail',
          query: { id: row.id, state: 'edit' }
        })
      }
    },
    addBtn() {
      this.$router.push({ name: 'historyDataDetail' })
    }
  }
}
</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>
