<!--
 * @Author: 曹捷
 * @Date: 2019-08-13 10:49:35
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-08-30 09:34:51
 * @Description: 操作日志
 -->
<template>
  <obitUniversalTable name="操作日志" v-if="$fmt(['sys_oper_type','sys_common_status'])">
    <template #search>
      <obit-search-form :params="params" :paramList="paramList" @search="pageQuery(true)">
      </obit-search-form>
    </template>
    <template #btn>
      <!-- <a-button @click="$router.push({path:'/system/log/test'})" danger class="m-r-15">
        <i class="iconfont icon-ashbin  p-r-5"></i> 测试
      </a-button> -->
      <a-button @click="removeAll" danger class="m-r-15">
        <i class="iconfont icon-ashbin  p-r-5"></i> 删除
      </a-button>
      <a-button type="primary" @click="addDialog(0)">
        <i class="iconfont icon-add-bold p-r-5"></i> 新 增
      </a-button>
    </template>
    <a-table class="obit-atable" :columns="tableColumns" :data-source="pageDataList" :row-selection="rowSelection"
      rowKey="operId" :loading="pageLoading">
      <template #expandedRowRender="{ record }">
        <a-descriptions title="操作日志详细">
          <a-descriptions-item label="操作模块">{{record.title}}</a-descriptions-item>
          <a-descriptions-item label="请求地址">{{record.operUrl}}</a-descriptions-item>
          <a-descriptions-item label="登录信息">{{record.operName}}</a-descriptions-item>
          <a-descriptions-item label="ip">{{record.operIp}}</a-descriptions-item>
          <a-descriptions-item label="ip地址">{{record.operLocation}}</a-descriptions-item>
          <a-descriptions-item label="请求方式">{{record.requestMethod}}</a-descriptions-item>
          <a-descriptions-item label="请求参数">{{record.params}}</a-descriptions-item>
          <a-descriptions-item label="返回参数">{{record.operParam}}</a-descriptions-item>
          <a-descriptions-item label="操作方法">{{record.method}}</a-descriptions-item>
          <a-descriptions-item label="操作状态">{{$fmt('sys_common_status',record.status)}}</a-descriptions-item>
          <a-descriptions-item label="操作时间">{{record.operTime}}</a-descriptions-item>
        </a-descriptions>
      </template>
    </a-table>
  </obitUniversalTable>
</template>

<script>
import { getCurrentInstance, inject, onMounted, reactive, toRefs } from 'vue'
import page from './../../../../hook/page.js'

export default {
  setup (props, contenxt) {
    let { proxy } = getCurrentInstance()
    let http = inject('http')
    let pageIns = page({
      url: 'system/operlog/pageList',
      key: 'operId',
      removeAll: 'system/operlog/removeAll'
    })
    let _data = reactive({
      noticeType: {},
      tableColumns: [
        { dataIndex: 'operId', title: '日志编号', },
        { dataIndex: 'title', title: '系统模块', },
        { dataIndex: 'operatorType', customRender: ({ text, record, index }) => proxy.$fmt('sys_oper_type', text), title: '操作类型' },
        { dataIndex: 'requestMethod', title: '请求方式' },
        { dataIndex: 'operName', title: '操作人' },
        { dataIndex: 'operIp', title: '操作地址' },
        { dataIndex: 'operLocation', title: '操作地点' },
        { dataIndex: 'status', customRender: ({ text, record, index }) => proxy.$fmt('sys_common_status', text), title: '操作状态' },
        { dataIndex: 'operTime', title: '操作日期' }
      ],
      paramList: [
        { name: '系统模块', key: 'title' },
        { name: '操作人员', key: 'operName' },
        {
          type: 'ajax',
          key: 'businessType',
          name: '操作类型',
          valuename: 'dictValue',
          labelname: 'dictLabel',
          ajaxurl: 'system/dict/data/type/sys_oper_type',
        },
        {
          type: 'ajax',
          key: 'status',
          name: '状态',
          valuename: 'dictValue',
          labelname: 'dictLabel',
          ajaxurl: 'system/dict/data/type/sys_common_status'
        },
        { name: '操作时间', type: 'dateBetween', startKey: 'beginTime', endKey: 'endTime' },
      ]
    })
    let _methods = {}
    onMounted(() => {
      pageIns._method.pageQuery()
    })
    return {
      ...toRefs(pageIns._data),
      ...pageIns._method,
      ...toRefs(_data),
      ..._methods,
    }
  },
}
</script>

<style lang="less">
.table-tree {
}
</style>