
<template>

  <div>

    <data-table
      ref="pagingTable"
      :options="options"
      :list-query="listQuery"
      @multi-actions="handleMultiAction"
    >
      <template slot="filter-content">
        <el-input v-model="listQuery.params.bookname" style="width: 200px" placeholder="搜索书名" class="filter-item"/>
        <el-select v-model="listQuery.params.state" style="width: 200px" placeholder="搜索借还类型"
                   class="filter-item">
          <el-option
            v-for="item in stateDicData"
            :key="item.value"
            :label="item.text"
            :value="item.value">
          </el-option>
        </el-select>
        <el-date-picker
          v-model="listQuery.params.createTime"
          type="datetime"
          format="yyyy-MM-dd"
          placeholder="选择开始时间"
          value-format="yyyy-MM-dd"
          class="filter-item" style="width: 200px"
        />
        <el-date-picker
          v-model="listQuery.params.updateTime"
          type="datetime"
          format="yyyy-MM-dd"
          placeholder="选择结束时间"
          value-format="yyyy-MM-dd"
          class="filter-item" style="width: 200px"
        />

      </template>
      <!--      表格-->
      <template slot="data-columns">
        <!--        <el-table-column type="selection" width="55"/>-->

        <el-table-column align="center" label="书名" prop="bookname"/>


        <el-table-column :formatter="dataFormatter" align="center" label="借还类型" prop="state" class-name="DIC_JHTYPE"/>
        <el-table-column align="center" label="发生时间">
          <template slot-scope="scope">
            {{ scope.row.createTime | xmDateFormat }}
          </template>
        </el-table-column>




      </template>
      <!--      表格end-->
    </data-table>


  </div>

</template>

<script>
import DataTable from '@/components/DataTable'
import MeetRole from '@/components/MeetRole'
import DepartTreeSelect from '@/components/DepartTreeSelect'
import {fetchTree} from '@/api/sys/depart/depart'
import {getSelectOptions} from '@/api/sys/dict/dict'
import {dataFormatter} from '@/utils'
import {saveData} from '@/api/sys/bookgl/bookgl'
import {getBjList, getZyList} from "@/api/sys/grxxgl/grxxgl";
import {jieshuData} from "@/api/sys/jieshu/jieshu";
import {huanshuData} from "@/api/sys/huanshu/huanshu";


export default {
  name: 'BysxxglList',
  components: {
    DepartTreeSelect,
    DataTable,
    MeetRole
  },

  data() {
    return {

      defaultProps: {
        value: 'value',
        text: 'text',
        label: 'deptName',
        children: 'children'
      },
      qcglData: {},
      dialogVisible: false,// 编辑是否显示

      listQuery: {
        current: 0,
        size: 10,
        total: 0,
        params: {}
      },

      formData: {
        avatar: ''
      },

      stateDicData: [],// 状态字典
      tszlDicData: [],// 图书种类字典DIC_TSZL


      options: {
        //  列表请求URL
        listUrl: '/tlog/logcontrol/paging',
        // 启用禁用
        stateUrl: '/tsjxxb/controller/state',
        // 删除
        deleteUrl: '/tsjxxb/controller/delete',
        //  批量操作列表
        multiActions: [
          {
            value: 'enable',
            label: '启用'
          }, {
            value: 'disable',
            label: '禁用'
          },
          {
            value: 'delete',
            label: '删除'
          }
        ]
      }
    }
  },

  //  页面初始化
  created() {
    getSelectOptions('DIC_TSZL').then(response => {
      //  图书种类字典
      this.tszlDicData = response.data
    })

    getSelectOptions('DIC_JHTYPE').then(response => {
      //  借书还书字典
      this.stateDicData = response.data
    })


  },

// 方法
  methods: {
    //  格式化字典
    dataFormatter,


    handleAdd() {
      this.formData = {}
      this.dialogVisible = true
      console.log('新增')
    },

    //借出申请按钮按下
    handleUpdate(row) {
      this.dialogVisible = true
      this.formData = row
      //  this.formData.roles = row.roleIds.split(',')
      //this.formData.password = null
    },

    //取消按钮按下
    handleUpCancel() {
      this.dialogVisible = false;
    },

    departSelected(data) {
      this.formData.id = data.id
      console.log(data + "----depart")
    },
    // 还书按钮按下
    handleSave() {
      //this.formData.bid = this.formData.id;
      huanshuData(this.formData).then((response) => {
        this.$message({
          type: 'success',
          message: '成功!'
        }, {
          type: 'error',
          message: response.msg
        })
        this.dialogVisible = false
        this.$refs.pagingTable.getList()
      })
    },

    //  批量操作监听
    handleMultiAction(obj) {
      if (obj.opt === 'cancel') {
        this.handleCancelOrder(obj.ids)
      }
    }
  }
}
</script>
