<template>
  <div class="app-container">
    <div class="header boxShadow">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="操作人" prop="name">
          <el-input v-model="formInline.userRealName" placeholder="请输入姓名" clearable></el-input>
        </el-form-item>
        <el-form-item label="操作日期" prop="operationTime">
          <el-date-picker type="date" placeholder="选择日期" v-model="formInline.operationTime" style="width: 100%;" clearable></el-date-picker>
        </el-form-item>

        <el-form-item class="fr">
          <el-button type="primary" @click="search">查询</el-button>
          <!-- <el-button type="primary" @click="handleAdd">新增</el-button> -->
        </el-form-item>
      </el-form>
    </div>
    <van-list>
      <div class="list boxShadow" v-for="(item,index) in list" :key="index">
        <div class="list-main">

          <div class="list-content">
            <div class="list-title">{{ item.userName}}</div>
            <van-row class="content-1">
              <van-col span="6">角色: <span>{{item.userRoleName}}</span></van-col>
              <van-col span="6">登录时间: <span>{{item.loginTime}}</span></van-col>
              <van-col span="6">注销时间: <span>{{item.loginOutTime}} </span></van-col>
              <!-- <van-col span="6">是否存在异常:<span><strong>{{item.isAbnormal}}</strong> </span></van-col> -->
            </van-row>
            <van-row class="content-1">
              <van-col span="6">菜单名称: <span>{{item.organization}} </span></van-col>
              <van-col span="6">操作时间: <span>{{item.operationTime}} </span></van-col>
              <van-col span="6">执行操作: <span>{{item.operationType}} </span></van-col>
            </van-row>
          </div>
        </div>

      </div>
    </van-list>
    <div class="pagination-container">
      <el-pagination class="right" background :current-page.sync="listQuery.page" :page-size="listQuery.limit" :page-sizes="[5, 10, 20, 30]" :total="listQuery.total" @size-change="sizeChange" @current-change="pageChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
    </div>
  </div>
</template>

<script>
import { getLogList } from '@/api/system/index.js'

export default {
  data () {
    return {
      notice: false,
      formInline: {
        userRealName: '',
        operationTime: ''
      },
      list: [
        {
          id:'',
          userRealName: '张琪',
          loginOutTime: '',
          loginTime: '',
          operationTime:'',
          operationType:'',
          orgCode:'',
          orgName: '北京直属库',
          userRoleName: '管理员',
          userName: 'chnnkrt',
          userAddress: '北京直属库',
          organization:'',
        },
      ],
      loading: 'false',
      finished: 'false',
      diaForm: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      formLabelWidth: '100px',
      listQuery: {
        condition: "",
        page: 1,
        limit: 10,
        total: 10,
      },
    }
  },
  created () {

  },
  mounted () {
    this.getList()
  },
  methods: {
    search () {
      this.getList()
    },
    getList () {
      let condition = {
        userRealName: this.formInline.userRealName.trim(),
        operationTime: this.formInline.operationTime,
        orgCode: JSON.parse(localStorage.getItem("userInfo")).orgCode
      }
      let data = {
        pageIndex: this.listQuery.page,
        pageSize: this.listQuery.limit,
        condition: JSON.stringify(condition)
      }
      getLogList(data).then(res => {
        if(res.code == 200) {
          this.list = res.data.records
          this.listQuery.limit = res.data.size
          this.listQuery.total = res.data.total
        }
      }).catch(err => {
        console.log(err)
      })
    },
    handleSizeChange (val) {
      // console.log(`每页 ${val} 条`);
    },
    sizeChange (v) {
      this.listQuery.limit = v
      // console.log(`每页 ${v} 条`);
      this.getList()
      this.list.splice(v, this.list.length - 1)
    },
    pageChange (v) {
      this.listQuery.page = v
      this.getList()
      // console.log(`当前页: ${v}`);
    },
  }
}
</script>
<style lang='scss' scoped>
.boxShadow {
  box-shadow: 5px -5px 10px -4px #efe3e3, -5px 5px 10px -4px #efe3e3;
}
::v-deep .van-notice-bar {
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.header {
  background-color: #fff;
  border-radius: 15px;
  padding: 15px;
  // height: 160px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  // align-items: center;
  .header-title {
    font-size: 14px;
    font-weight: 600;
    padding-left: 10px;
    border-left: 4px solid #5283e7;
  }
  .van-notice-bar {
    padding: 10px 0 10px 0;
  }
  .el-form {
    .el-form-item {
      margin-bottom: 0;
    }
    .fr {
      float: right;
    }
  }
}
.list {
  background-color: #fff;
  border-radius: 15px;
  margin-top: 10px;
  .list-main {
    padding-left: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    .list-title {
      font-size: 15px;
      font-weight: 700;
      padding: 10px 0;
    }
    .list-content {
      width: 100%;
      padding: 10px 10px 10px 5px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .content-1 {
        font-size: 13px;
        display: flex;
        justify-content: space-between;
        margin-top: 10px;
        // padding: 5px 0;
        strong {
          color: #d24848;
        }
        .text-colorc {
          color: #b8b8b8;
        }
      }
      .content-1:nth-last-child(1) {
        padding-bottom: 10px;
      }
    }
    .list-btns {
      // width: 22%;
      background-color: #edf2fd;
      display: flex;
      justify-content: space-evenly;
      align-items: center;
    }
  }
}
</style>
