<!--
 * @Descripttion: (小程序客户/tb_customer 详情弹窗)
 * @version: (1.0)
 * @Author: (lwh)
 * @Date: (2023-06-05)
 * @LastEditors: (lwh)
 * @LastEditTime: (2023-06-05)
-->
<template>
  <el-dialog v-model="props.modelValue" title="历史登录信息" width="900px" @closed="closeDialog" @open="openDialog">
    <el-form ref="formRef" :model="formData" :disabled="true">

      <!-- 表格渲染  prop="对应的字段"-->
      <el-table v-loading="loading" :data="dataList" ref="tableRef" border highlight-current-row>
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column prop="customerNickName" label="用户名称" align="center" :show-overflow-tooltip="true" sortable />
        <el-table-column prop="createTime" label="登录时间" align="center" :show-overflow-tooltip="true" sortable />
      </el-table>
      <pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
        @pagination="getList" />

    </el-form>
  </el-dialog>
</template>

<script setup>
import { ElMessage } from 'element-plus'
import { reactive, ref, watch } from "vue";
import { customerLoginLogList, delCustomerLoginLog } from '@/api/business/Custom/CustomerLoginLogs/customerLoginLog.js'

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    customerGuid: 0
  },
})
const { queryParams } = toRefs(data)

// 打开弹窗时回调
const openDialog = async () => {
  getList()
}

const formData = ref({
  ...props.data,
});
watch(props, async (v) => {
  formData.value = v.data;
});

// -业务参数
// 数据列表
const dataList = ref([])
// 是否加载
const loading = ref(true)

// 查询数据
function getList() {
  console.log(formData.value.customerGuid);
  loading.value = true

  queryParams.value.customerGuid = formData.value.customerGuid
  customerLoginLogList(queryParams.value).then((res) => {
    if (res.code == 200) {
      loading.value = false;
      dataList.value = res.data.result;
      total.value = res.data.totalNum;
    }
  });
}


// 基础参数
const formRef = ref();
const labelWidth = 100;
const { proxy } = getCurrentInstance()
const props = defineProps({
  modelValue: Boolean,
  data: Object,
  done: Function,
});
const emits = defineEmits(["update:modelValue"]);


// -基础方法
const closeDialog = () => {
  emits("update:modelValue", false);
};

</script>
