<template>
  <el-dialog title="高危记录" :close-on-click-modal="false" :visible.sync="open" width="900px" append-to-body>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="类型" prop="type">
        <el-select v-model="queryParams.type" clearable size="small">
          <el-option
              v-for="dict in userErrorLogTypeList"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
              @keyup.enter.native="handleQuery"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="发生地点" prop="homeIndex">
        <el-select v-model="queryParams.homeIndex" clearable size="small">
          <el-option
              v-for="dict in userErrorLogHomeIndexList"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
              @keyup.enter.native="handleQuery"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="userErrorLogList" >
      <el-table-column :label="systemName+'号'" align="center" prop="usercode"/>
      <el-table-column label="昵称" align="center" prop="nickname"/>
      <el-table-column label="头像" align="center" prop="avatar">
        <template v-slot="scope">
          <image-avatar :src="scope.row.avatar"/>
        </template>
      </el-table-column>
      <el-table-column label="类型" align="center" prop="type" >
        <template v-slot="scope">
          <cai-dict-tag :options="userErrorLogTypeList" :value="scope.row.type"/>
        </template>
      </el-table-column>
      <el-table-column label="发生地点" align="center" prop="homeIndex" >
        <template v-slot="scope">
          <cai-dict-tag :options="userErrorLogHomeIndexList" :value="scope.row.homeIndex"/>
        </template>
      </el-table-column>
      <el-table-column label="发生时间" align="center" prop="createTime" />
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />
    <div slot="footer" class="dialog-footer">
      <el-button @click="open = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {getUserByUsercode, listUserByUserCode} from "@/api/cai/user";
import { listMemberPrice } from '@/api/cai/memberPrice'
import { addUserMember } from '@/api/cai/userMember'
import {updateAccountCoin} from "@/api/cai/account";
import {listGoods} from "@/api/cai/goods";
import {
  accountTypeList,
  genderList,
  userErrorLogHomeIndexList,
  userErrorLogTypeList,
  yesOrNoList
} from '@/constant/statusMap'
import {listAccountChangeLog, listChangeType} from "@/api/cai/accountChangeLog";
import { listUserErrorLog } from '@/api/cai/userErrorLog'

export default {
  components: {
  },
  data () {
    return {
      userErrorLogTypeList,userErrorLogHomeIndexList,genderList,
      systemName: process.env.VUE_APP_SYSTEM_HOME,
      open: false,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 账户明细表格数据
      userErrorLogList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type: undefined,
        homeIndex: undefined,
        userId: undefined,
        mobile: undefined,
      },
    }
  },
  created() {
  },
  methods: {
    init (userId) {
      this.open = true;
      this.queryParams.userId = userId
      this.getList();
    },
    /** 查询账户明细列表 */
    getList() {
      this.loading = true;
      listUserErrorLog(this.queryParams).then(response => {
        this.userErrorLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
}
</script>
<style lang="scss" scoped>
.context-avatar-center {
  display: flex;
  align-items: center; /* 垂直居中 */
  justify-content: center; /* 水平居中 */
}
</style>
