<!-- 系统配置 - 权限配置 -->
<template>
  <div class="page">
    <topBar v-if="topList.length > 0"
            :top-list="topList"
            :moren="moren" />
    <div class="thetopbox">
      <el-form ref="form"
               :model="select"
               label-width="auto">
        <el-row :gutter="20">
          <el-col :span="4">
            <el-form-item label="被操作人编号">
              <el-input v-model="select.memberCode"
                        clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="被操作人姓名">
              <el-input v-model="select.memberName"
                        clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="操作类型">
              <el-select clearable
                         filterable
                         v-model="select.businessType">
                <el-option v-for="item in ywsqList"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="操作人编号">
              <el-input v-model="select.operatorUserName"
                        clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'签呈状态'">
              <el-select clearable
                         filterable
                         v-model="select.businessStatus">
                <el-option v-for="item in approveStatusList"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="审核人编号">
              <el-input v-model="select.approveUserName"
                        clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="'操作时间'">
              <el-date-picker v-model="select.operateTime"
                              value-format="yyyy-MM-dd"
                              type="daterange"
                              :range-separator="'至'"
                              :start-placeholder="'开始日期'"
                              :end-placeholder="'结束日期'">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="'审核时间'">
              <el-date-picker v-model="select.approveTime"
                              value-format="yyyy-MM-dd"
                              type="daterange"
                              :range-separator="'至'"
                              :start-placeholder="'开始日期'"
                              :end-placeholder="'结束日期'">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4"
                  style="margin-left: 25px">
            <div class="searchbox">
              <el-button class="searchbtn"
                         @click="research()"> {{ '搜索' }}</el-button>
              <el-button @click="reChongzhi"> {{ '重置' }}</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="maintop">
      <div class="mainbtn">
        <el-button size="small"
                   @click="handleExport"
                   v-hasButtons="['operationDetailsExport']"
                   style="background-color: #ffad41"
                   class="thebtn1"> {{ '导出' }}</el-button>
      </div>
    </div>
    <div class="main">
      <div class="maintable">
        <el-table :data="tableData"
        v-loading="loading"
                  style="width: 100%"
                  height="690px"
                  :header-cell-style="{ background: '#EEEEEE' }"
                  :row-class-name="tableRowClassName"
                  @selection-change="handleSelectionChange">
          <el-table-column type="selection" />
          <el-table-column align="center"
                           prop="memberCode"
                           label="被操作人编号" />
          <el-table-column align="center"
                           prop="memberName"
                           label="被操作人姓名" />
          <el-table-column align="center"
                           prop="businessTypeVal"
                           label="操作类型" />
          <el-table-column align="center"
                           prop="operateUserName"
                           label="操作人编号" />
          <el-table-column align="center"
                           prop="operateNickName"
                           label="操作人姓名" />
          <el-table-column align="center"
                           prop="businessStatusVal"
                           label="审核状态" />
          <el-table-column align="center"
                           prop="approveUserName"
                           label="审核人编号" />
          <el-table-column align="center"
                           prop="approveNickName"
                           label="审核人姓名" />
          <el-table-column align="center"
                           prop="operateTime"
                           label="操作时间" />
          <el-table-column align="center"
                           prop="approveTime"
                           label="审核时间" />
        </el-table>
      </div>
    </div>
    <pagination v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="research" />
  </div>
</template>

<script>
import topBar from '@/components/topBar'
import * as man from '@/api/manage.js'

import * as api from '@/api/notice'
import { Message } from 'element-ui'

export default {
  name: 'Qxpz',
  components: {
    topBar,
  },
  data() {
    return {
      loading:false,
      tableData: [],
      moren: 'operationDetails',
      topList: [
        {
          name: '业务操作明细',
          path: 'operationDetails',
        },
      ],

      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total: 0,
      select: {},
      ywsqList: [],
      approveStatusList: [],
    }
  },
  created() {
    this.research()
    this.getData()
  },
  methods: {
    // 导出
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then((_) => {
        this.download(
          '/system/manage/business-log/export',
          Object.assign({}, this.queryParams, this.select),
          `业务操作明细${new Date().getTime()}.xlsx`
        )
      })
    },
    getData() {
      // 获取功能
      api.methodType().then((res) => {
        this.methodList = res.data
      })
      // 获取模块
      api.moduleType().then((res) => {
        this.moduleList = res.data
      })
      man.approvalBusiness().then((res) => {
        this.ywsqList = res.data
      })
      man.approvalStatus().then((res) => {
        this.approveStatusList = res.data
      })
    },

    research() {
      this.loading = true
      api
        .businessList(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          this.tableData = res.rows
          const regex = new RegExp('<img', 'gi')
          this.tableData.forEach((item) => {
            if (item.content) {
              item.content = item.content.replace(
                regex,
                `<img style="max-width: 200px;"`
              )
            }
          })
          this.total = res.total
          this.loading = false
        })
    },
    reChongzhi() {
      this.select = {}
      this.research()
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return 'warning-row'
      } else if (rowIndex % 2 == 0) {
        return 'success-row'
      }
      return ''
    },
  },
}
</script>

<style>
.el-tooltip__popper {
  max-width: 45%;
  text-align: center;
}
</style>
<style lang="scss" scoped>
.img-auto {
  text-align: center;
  height: 660px;
  overflow-y: auto;
  ::v-deep p {
    font-size: 14px;
  }
  ::v-deep img {
    max-width: 100%;
    height: auto;
  }
}
.title {
  color: #333;
  font-weight: bold;
  margin: 10px auto 10px 0;
  font-size: 16px;
  text-align: center;
}
::v-deep .el-dialog__header {
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 20px;
}
::v-deep .el-dialog__title {
  font-size: 32px;
  color: #333;
  font-weight: bold;
}
::v-deep .el-select {
  width: 100%;
}
::v-deep .el-check_s .el-input__inner {
  width: 100%;
}

::v-deep .el-dialog__header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.button-s {
  padding: 0 2px !important;
}

::v-deep .el-row {
  //margin-top: 10px;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}

::v-deep .el-table .success-row {
  background: #ffffff;
}
::v-deep .el-table thead {
  color: #000000;
}
.openClose {
  margin-top: 10px;
  margin-right: 10px;
  color: #666666;
  text-align: center;
}
.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    background: #ffffff;
    border-radius: 8px;
    padding-bottom: 10px;
    .searchbox {
      display: flex;
      align-items: center;
      .searchtitle {
        margin-right: 10px;
      }
      .searchbtn {
        background: #c8161d;
        color: #ffffff;
      }
    }
  }
  .maintop {
    display: flex;
    //padding: 10px 0;
    justify-content: space-between;
    align-items: center;
    .mainbtn {
      .thebtn1 {
        color: #ffffff;
        background: rgba(67, 145, 253, 1);
      }
    }
  }
  .main {
    // margin-top: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    .maintable {
      overflow: auto;
    }
  }
}
::v-deep .el-date-editor--daterange {
  width: 100%;
}
</style>
