G<template>
  <div>
    <!-- 试验间-笼具更换记录弹窗 -->
    <el-dialog :title="$t('page.business.study.studyRoom.ljjl')" :visible.sync="open" width="800px" append-to-body
      :close-on-click-modal="false">
      <el-form :model="searchForm" ref="searchForm" class="search-area" :inline="true" label-width="88px">
        <el-row>
          <el-col :span="24">
            <!-- 更换人 -->
            <el-form-item :label="$t('page.business.study.studyRoom.ghr')" prop="ghr">
              <el-input v-model="searchForm.ghr" :placeholder="$t('form.placeholderInput')" clearable
                @keyup.enter.native="search" />
            </el-form-item>

            <!-- 更换时间 -->
            <el-form-item :label="$t('page.business.study.studyRoom.ghsj') + '：'">
              <el-date-picker v-model="daterange" class="chat-histogram-daterange" type="daterange" range-separator="-"
                :start-placeholder="$t('form.startDate')" :end-placeholder="$t('form.endDate')"
                value-format="yyyy-MM-dd" @change="search" style="width: 250px;" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search">{{ $t('form.search') }}</el-button>
              <el-button icon="el-icon-refresh" @click="reset">{{ $t('form.reset') }}</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table v-loading="loading" :data="list">
        <el-table-column :label="$t('page.business.study.studyRoom.ghsj')" prop="createTime" />
        <el-table-column :label="$t('page.business.study.studyRoom.ghqlj')" prop="ljOld" />
        <el-table-column :label="$t('page.business.study.studyRoom.ghhlj')" prop="lj" />
        <el-table-column :label="$t('page.business.study.studyRoom.ghr')" align="center" prop="qyrMc" />
      </el-table>

      <pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
        @pagination="getList" />
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">{{ $t('form.cancel') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { studyRoom_historyList } from "@/api/business/study/studyRoom"
import { mapGetters } from 'vuex'
import BusinessSelect from '@/views/business/comps/select/BusinessSelect';
import SelectTestArea from '@/views/business/comps/select/SelectTestArea';
import SelectRoom from '@/views/business/comps/select/SelectRoom';
import SelectAnimalSpecies from '@/views/business/comps/select/SelectAnimalSpecies';
import SelectCage from '@/views/business/comps/select/SelectCage';
export default {
  name: "JlSyj",
  components: { BusinessSelect, SelectTestArea, SelectRoom, SelectCage, SelectAnimalSpecies },
  data() {
    return {
      open: false,
      daterange: [],
      loading: false,
      list: [],
      total: 0,
      searchForm: {
        pageNum: 1,
        pageSize: 10,
        ghr: '',
        startDate: '',
        endDate: '',
        studyRoomId: '',
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName','name'
    ]),
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    search() {
      this.searchForm.pageNum = 1
      this.getList()
    },
    reset() {
      this.resetForm("searchForm")
      this.search()
    },
    getList() {
      if (this.daterange != null && this.daterange.length > 0) {
        this.searchForm.startDate = this.daterange[0] + " 00:00:00"
        this.searchForm.endDate = this.daterange[1] + " 23:59:59"
      } else {
        this.searchForm.startDate = ''
        this.searchForm.endDate = ''
      }
      this.loading = true
      studyRoom_historyList(this.searchForm).then(response => {
        this.list = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    show(row) {
      this.searchForm.studyRoomId = row.id
      this.getList()
      this.open = true
    },

  }
}
</script>
