<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-news__topic}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataListSearch()">
        <el-form-item label="上报到网格化平台的街道">
          <el-cascader v-model="streetIds" :options="streetOptions" :props="{ checkStrictly: true }" clearable filterable></el-cascader>
        </el-form-item>
        <el-form-item label="项目来源区域">
          <el-cascader v-model="ids" :options="options" :props="{ checkStrictly: true }" clearable filterable></el-cascader>
        </el-form-item>
        <el-form-item label="项目摘要" prop="topicContent">
          <el-input v-model="dataForm.searchContent" placeholder="项目摘要" clearable @keyup.native="btKeyUpsearchContent"></el-input>
        </el-form-item>
        <div class="block">
        <el-form-item label="上报网格化平台时间"
                      prop="reportStartTime" label-width="166px">
          <el-date-picker v-model="dataForm.reportStartTime"
                          type="date"
                          :picker-options="pickerBeginDateBefore"
                          value-format="yyyy-MM-dd"
                          format="yyyy-MM-dd"
                          placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="至"
                      label-width="25px"
                      prop="reportEndTime">
          <el-date-picker v-model="dataForm.reportEndTime"
                          type="date"
                          :picker-options="pickerBeginDateAfter"
                          value-format="yyyy-MM-dd"
                          format="yyyy-MM-dd"
                          placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getDataListSearch()">{{ $t('query') }}</el-button>
        </el-form-item>
        </div>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column label="序号" type="index" show-overflow-tooltip align="center" width="50"></el-table-column>
        <el-table-column prop="itemContent" label="项目内容" min-width=400 show-overflow-tooltip header-align="center" align="center"></el-table-column>
        <el-table-column prop="createdTime" label="转项目时间" width=180 header-align="center" align="center"></el-table-column>
        <el-table-column prop="grid" label="网格名称" width=180 show-overflow-tooltip header-align="center" align="center"></el-table-column>
        <el-table-column prop="reportDept" label="上报部门" width=180 show-overflow-tooltip header-align="center" align="center"></el-table-column>
        <el-table-column prop="reportTime" label="吹哨时间" width=180 header-align="center" align="center"></el-table-column>
        <el-table-column prop="lastHandlerDept" label="最新进展处理部门" width=180 show-overflow-tooltip header-align="center" align="center"></el-table-column>
        <el-table-column prop="lastHandlerTime" label="最新进展处理时间" width=180 header-align="center" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="look(scope.row.id)">{{ $t('look') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
export default {
  mixins: [mixinViewModule],
  name: 'reportUnSolvedItemList',
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/analysis/item/pageReportUnsolvedItem',
        getDataListIsPage: true
      },
      closeVisible: false,
      dataForm: {
        id: '',
        streetId: '',
        communityId: '',
        gridId: '',
        reportDept: '',
        reportStartTime: '',
        reportEndTime: '',
        searchContent: ''
      },
      pickerBeginDateBefore: {
        disabledDate: (time) => {
          let beginDateVal = this.dataForm.startTime
          if (beginDateVal) {
            return time.getTime() > new Date(beginDateVal).getTime()
          }
        }
      },
      pickerBeginDateAfter: {
        disabledDate: (time) => {
          let EndDateVal = this.dataForm.endTime
          if (EndDateVal) {
            return time.getTime() < new Date(EndDateVal).getTime()
          }
        }
      },
      ids: [],
      options: [],
      streetIds: [],
      streetOptions: []
    }
  },
  components: {
  },
  created: function () {
    this.getOptions()
    this.getStreetOptions()
  },
  watch: {
    'ids': function (val) {
      if (val.length === 0) {
        this.dataForm.streetId = ''
        this.dataForm.communityId = ''
        this.dataForm.gridId = ''
      }
      if (val.length === 1) {
        this.dataForm.streetId = this.ids[0]
        this.dataForm.communityId = ''
        this.dataForm.gridId = ''
      }
      if (val.length === 2) {
        this.dataForm.streetId = this.ids[0]
        this.dataForm.communityId = this.ids[1]
        this.dataForm.gridId = ''
      }
      if (val.length === 3) {
        this.dataForm.streetId = this.ids[0]
        this.dataForm.communityId = this.ids[1]
        this.dataForm.gridId = this.ids[2]
      }
    },
    'streetIds': function (val) {
      if (val.length === 0) {
        this.dataForm.reportDept = ''
      } else if (val.length === 1) {
        this.dataForm.reportDept = this.streetIds[0]
      }
    }
  },
  methods: {
    getOptions () {
      this.$http.get(`/sys/user/deptOptions/getByLoginUser`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        this.options = res.data.options
      }).catch(() => {})
    },
    getStreetOptions () {
      this.$http.get(`/sys/user/deptOptions/getStreetByLoginUser`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        this.streetOptions = res.data.options
      }).catch(() => {})
    },
    look (id) {
      this.$parent.selectComponent = 'ItemDetailView'
      this.$router.push({ path: '/analysis-item-report-unsolved-item', query: { id: id } })
    },
    btKeyUpsearchContent(e){
      e.target.value = e.target.value.replace(/[`~!#$%^&*()_\+=<>?:"{}|~！#￥%……&*（）={}|《》？：“”【】、；‘’，。、]/g, '')
      this.dataForm.searchContent = e.target.value
    },
  }
}
</script>
