<!--
 * @Descripttion: 
 * @version: 
 * @Author: 王三华
 * @Date: 2023-10-16 13:59:22
-->
<template>
  <view class="content">
    <view class="header_a">
      <view class="header">
        <img @click="isTop=true"
             src="@/assets/images/search.png"
             alt="">
        <!-- <img @click="isFont=true"
           src="@/assets/images/change.png"
           alt=""> -->
      </view>
    </view>
    <view class="zhan"></view>
    <!-- table -->
    <view class="kuang"
          v-for="(item,index) in tableData"
          :key="index">
      <table class="tftable"
             border="1">
        <tr>
          <td align="right">{{ '操作人' }}</td>
          <td align="left">{{ item.userName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '菜单' }}</td>
          <td align="left">{{ item.operationModule }}</td>
        </tr>
        <tr>
          <td align="right">{{ '业务类型' }}</td>
          <td align="left">{{ item.operationBusiness }}</td>
        </tr>
        <tr>
          <td align="right">{{ '操作功能' }}</td>
          <td align="left">{{ item.operationMethod }}</td>
        </tr>
        <tr>
          <td align="right">{{ '操作内容' }}</td>
          <td align="left">{{ item.operationParam }}</td>
        </tr>
        <tr>
          <td align="right">{{ '操作日期' }}</td>
          <td align="left">{{ item.operationTime }}</td>
        </tr>
        <tr>
          <td align="right">{{ 'IP地址' }}</td>
          <td align="left">{{ item.ipaddr }}</td>
        </tr>
      </table>
      <view class="table_f">
        <u-button  @click="openDetails(item)"
                  size="small"
                  color="#48B2FD"
                  :text="'查看'"></u-button>
                  </view>
    </view>
    <!-- 顶部搜索 -->
    <u-popup :show="isTop"
             mode="top"
             @close="isTop=false">
      <view class="tt">
        <u--form labelPosition="left"
                 labelWidth="auto"
                 :model="select"
                 ref="uForm">
          <u-row gutter="10">
            <u-col span="6">
              <u-form-item :label="'操作人'">
                <u--input fontSize="12"
                          v-model="select.userName"></u--input>
              </u-form-item>
            </u-col>
            <u-col span="6">
              <u-form-item :label="'操作模块'">
                <picker :range="moduleList"
                        range-key="item"
                        @change="bindPickerChange1">
                  <u--input disabled
                            fontSize="12"
                            disabledColor="#ffffff"
                            v-model="select.operationModuleVal"
                            suffixIcon="arrow-down"
                            suffixIconStyle="font-size: 12px;"></u--input>
                </picker>
              </u-form-item>
            </u-col>
          </u-row>
          <u-row gutter="10">
            <u-col span="6">
              <u-form-item :label="'操作功能'">
                <picker :range="methodList"
                        range-key="item"
                        @change="bindPickerChange2">
                  <u--input disabled
                            fontSize="12"
                            disabledColor="#ffffff"
                            v-model="select.operationMethodVal"
                            suffixIcon="arrow-down"
                            suffixIconStyle="font-size: 12px;"></u--input>
                </picker>
              </u-form-item>
            </u-col>
            <u-col span="6">
              <u-form-item :label="'IP地址'">
                <u--input fontSize="12"
                          v-model="select.ipaddr"></u--input>
              </u-form-item>
            </u-col>

          </u-row>
          <u-row gutter="10">
            <u-col span="12">
              <u-form-item :label="'操作日期'"
                           @click="isData=true">
                <u--input disabled
                          fontSize="12"
                          disabledColor="#ffffff"
                          v-model="select.operationTimeVal"
                          suffixIcon="arrow-down"
                          suffixIconStyle="font-size: 12px;"></u--input>
              </u-form-item>
            </u-col>
          </u-row>
        </u--form>
        <view class="footer">
          <u-button @click="getList1"
                    color="#C8161D"
                    text="搜索"
                    class="btnn"></u-button>
          <u-button @click="reset"
                    text="重置"></u-button>
        </view>
      </view>
      <u-calendar @close="isData = false"
                  :closeOnClickOverlay="true"
                  :show="isData"
                  :allowSameDay="true"
                  mode="range"
                  :maxDate="calendar.maxDate"
                  :minDate="calendar.minDate"
                  :monthNum="calendar.monthNum"
                  @confirm="confirm"></u-calendar>
    </u-popup>
    <view class="pp">
    <u-popup :show="isDetails" @close="isDetails=false" mode="center" closeable>
      <view class="tt1">
			<view v-html="noticeContent" class="img-auto"></view>
    </view>
		</u-popup>
  </view>
    <!-- 悬浮球 -->
    <drag-button />
    <export-ball ref="exportBall"
    v-hasButtons="['operationRecordExport']"
                 @handleExport="handleExport" />
  </view>
</template>

<script>
import * as api from '@/api/information'
import { isLocals, isLocalSymbol } from '@/util/numberToCurrency'
export default {
  data() {
    return {
      isDetails:false,
      select: {},
      isData: false,
      isTop: false,
      setTime: 0,
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
      },
      tableData: [],
      methodList: [],
      moduleList: [],
      calendar: {
        minDate: '',
        maxDate: '',
        monthNum: 25,
      },
      peyTypeList: [
        {
          value: '1',
          label: '支付宝',
        },
        {
          value: '2',
          label: '微信',
        },
        {
          value: '3',
          label: '银行卡',
        },
      ],
      noticeContent:''
    }
  },
  onLoad(options) {
    this.getData()
    this.chooseTimed()
  },
  onShow() {
    this.getSearch()
  },
  onPullDownRefresh() {
    this.getList1()
  },
  methods: {
    isLocalSymbol,
    isLocals,
    openDetails(item){
     this.noticeContent = item
      this.isDetails = true
    },
    // 设置默认日期，最大值为今天，最小值为去年今天
    chooseTimed() {
      let date = new Date()
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month <= 9) {
        month = '0' + month
      }
      if (day <= 9) {
        day = '0' + day
      }
      let minyear = year - 1
      let maxyear = year + 1
      this.calendar.minDate = minyear + '-' + month + '-' + day
      this.calendar.maxDate = maxyear + '-' + month + '-' + day
    },
    getData() {
      api.methodType().then((res) => {
        this.methodList = res.data
      })
      // 获取模块
      api.moduleType().then((res) => {
        this.moduleList = res.data
      })
    },
    bindPickerChange1(e) {
      this.$set(
        this.select,
        'operationModuleVal',
        this.moduleList[e.detail.value]
      )
      this.$set(this.select, 'operationModule', this.moduleList[e.detail.value])
    },
    bindPickerChange2(e) {
      this.$set(
        this.select,
        'operationMethodVal',
        this.methodList[e.detail.value]
      )
      this.$set(this.select, 'operationMethod', this.methodList[e.detail.value])
    },
    onReachBottom() {
      this.queryParams.pageNum++
      this.getSearch()
    },
    //查询会员信息
    getSearch() {
      api
        .operationLogList(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          uni.stopPullDownRefresh()
          this.total = res.total
          this.tableData = this.tableData.concat(res.rows)
        })
    },
    getList1() {
      this.tableData = []
      this.queryParams.pageNum = 1
      this.isTop = false
      this.tableData = []
      this.getSearch()
    },
    reset() {
      this.select = {}
    },
    handleExport() {
      let url = '/system/manage/operation-log/export'
      let obj = Object.assign({}, this.select, this.queryParams)
      this.$refs.exportBall.handleExport(url, obj, `操作记录`)
    },
    confirm(e) {
      this.$set(this.select, 'operationTime', [e[0], e[e.length - 1]])
      this.$set(
        this.select,
        'operationTimeVal',
        e[0] + ' 至 ' + e[e.length - 1]
      )
      this.isData = false
    },
  },
}
</script>
<style lang="scss" scoped>
.content {
  background: #f9f9f9;
  // padding: 20rpx;
}
.header_a {
  position: fixed;
  width: 100%;
  z-index: 1;
}
.header {
  margin: 20rpx;
  background: #ffffff;
  box-shadow: 0px 2px 10px 0px rgba(204, 204, 204, 0.4);
  border-radius: 10px 10px 10px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30rpx 40rpx;
  img {
    width: 24px;
    height: 24px;
  }
}
.zhan {
  height: 130rpx;
}
.kuang {
  margin: 20rpx;
  background: #f9f9f9;
  border-radius: 10px 10px 10px 10px;
}
.table_f {
  display: flex;
  uni-button {
    margin: 20rpx 10rpx;
  }
}
.tftable {
  table-layout:fixed;
  font-size: 12px;
  border-collapse: collapse;
  border-radius: 10px;
  width: 100%;
  background: #fff;
  border: 1px solid #f9f9f9;
  margin-top: 20rpx;
  td {
    font-size: 11px;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #999;
    padding: 20rpx 40rpx;
    width: 50%;
    // height: 60px;
    border-left: 1px solid #333;
    border-bottom: 1px solid #333;
    white-space: pre-wrap;
    word-wrap: break-word;
  }
  td:nth-child(odd) {
    border-left: 1px solid #f9f9f9;
  }
  tr :nth-child(2) {
    color: #333333;
  }
}
.tt {
  padding: 20rpx;
  margin-top: 40px;
}
.tt1 {
  padding: 20rpx;
  margin-top: 40px;
  // width: 60%;
}
::v-deep .u-transition {
  z-index: 998 !important;
}
.footer {
  display: flex;
  align-items: center;
  padding: 20rpx 60rpx;
  .btnn {
    margin-right: 40rpx;
  }
}
::v-deep .u-input {
  padding: 0 9px !important;
}
::v-deep .u-form-item__body__left__content__label {
  font-size: 12px;
}
::v-deep .u-form-item__body {
  padding: 5px 0;
}
.theflex {
  display: flex;
  align-items: center;
}
.img-auto {
  text-align: center;
  height: 500px;
  overflow-y: auto;
  ::v-deep p {
    font-size: 14px;
  }
  ::v-deep img {
    max-width: 100%;
    height: auto;
  }
}
.pp ::v-deep .u-popup__content{
  width: 70%;
}
</style>