  <template>
   <d2-container>
    <div class="d2-table-view-full" >
       <div class="d2-table-view-header">
      <el-form size="small" :inline="true" :model="filter" @keyup.enter.native="handleList" class="demo-form-inline">
        <el-form-item label="起止时间">
      	<el-date-picker
      			v-model="time"
      			type="datetimerange"
      			value-format="yyyy-MM-dd HH:mm:ss"
      			@change="dateChange"
      			range-separator="至"
      			start-placeholder="开始时间"
      			end-placeholder="结束时间">
      	</el-date-picker>
        </el-form-item>
        <el-form-item label="描述">
      	<el-input v-model="filter.context" placeholder="描述"/>
        </el-form-item>
        <el-form-item>
      	<el-button type="primary"  @click="handleList('1')">查询</el-button>
        </el-form-item>
      </el-form>
       </div>
       <div class="d2-table-view-content">
 				<div class="d2-table-view-handle">
					 
 				</div>
       <d2-crud
       		title="日志列表"
       		ref="d2Crud"
       		:options="tableOptions"
       		:loading="loading"
       		:columns="columns"
       		:data="data"
       		@row-remove="handleRowRemove"
       		:rowHandle="rowHandle"/>
       </div>
       <div class="d2-table-view-footer">
       <el-pagination
               @current-change="handleCurrentChange"
               @size-change="handleSizeChange"
               :page-size="tableOptions.pageList[0]"
               :page-sizes="tableOptions.pageList"
               :current-page.sync="currentPage"
               layout="total,sizes, prev, pager, next,jumper"
               :total="pagination.total">
       </el-pagination>
       </div>
     </div>
      
   </d2-container>
 </template>
 <script>
  // import { LogList, LogDelete } from '../../../api/sys/log'
   import { tableOptions } from '../../../assets/options'
 
   export default {
     name: 'system-log',
     data () {
       return {
 				func:{
 					select:false,
 					delete:false
 				},
         tableOptions,
         loading: false,
         time: '',
         filter: {
           startDate: '',
           endDate: '',
           context: '',
           limit: 10,
           page: 1
         },
         pagination: {
           total: 0
         },
         currentPage:1,
         columns: [
           {
             title: '日志时间',
             key: 'createDate',
             minWidth: '180'
           },
           {
             title: '操作人员',
             key: 'userName',
             minWidth: '180'
           },
           {
             title: '描述',
             key: 'context',
             minWidth: '180'
           },
         ],
         rowHandle: {
           columnHeader: '操作',
           minWidth: '180',
           align: 'center',
          /* remove: {
             size: 'small',
             fixed: 'right',
             confirm: true,
             show (index, row) {
 
               return true
             },
             disabled (index, row) {
 
               return false
             }
           }, */
         },
         data: []
       }
     },
     methods: {
       handleList (val) {
          if(val){this.filter.page=1
         this.currentPage = 1}
       this.loading = true
        /* LogList(this.filter).then(res => {
           this.loading = false
           this.data = res.data.rows
           this.pagination.total = res.data.records
         }).catch(err => {
           this.loading = false
         }) */
				   this.loading = false
       },
 
       handleCurrentChange (val) {
         this.filter.page = val
         this.handleList()
       },
 			handleSizeChange (val) {
 			this.filter.page = 1
 			this.filter.limit = val
 			this.handleList()
 			},
       handleRowRemove ({index, row}, done) {
       /*  let logId = row.logId
         LogDelete({
           logId
         }).then(res => {
           this.$message({
             message: '删除成功',
             type: 'success'
           })
           done()
           this.handleList()
         }) */
       },
       dateChange (val) {
        if(val == null){
        	this.filter.startDate = ''
        	this.filter.endDate = ''
        }else{
        	this.filter.startDate = val[0]
        	this.filter.endDate = val[1]
        }
       }
     },
     mounted () {
       this.time = this.$setInitTime()
       this.filter.startDate = this.time[0].format('yyyy-MM-dd hh:mm:ss')
       this.filter.endDate = this.time[1].format('yyyy-MM-dd hh:mm:ss')
       this.tableOptions = this.$calcTableHeight(tableOptions,20)
       this.filter.limit = this.tableOptions.pageList[0]
       this.handleList()
     }
   }
 </script>