detailDialog.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <el-dialog
  3. v-model="dialogShow"
  4. title="订单详情"
  5. width="60%"
  6. destroy-on-close
  7. :close-on-click-modal="false"
  8. @close="handleClose"
  9. >
  10. <div class="detail-table">
  11. <ProTable
  12. ref="proTable"
  13. :columns="columns"
  14. :request-api="getTableList"
  15. :data-callback="dataCallback"
  16. :request-auto="false"
  17. :tool-button="false"
  18. :border="true"
  19. height="360"
  20. />
  21. </div>
  22. <template #footer>
  23. <span class="dialog-footer">
  24. <el-button @click="handleClose"> 关闭 </el-button>
  25. </span>
  26. </template>
  27. </el-dialog>
  28. </template>
  29. <script setup lang="ts">
  30. import { ref, defineExpose } from "vue";
  31. import { ElMessage } from "element-plus";
  32. import ProTable from "@/components/ProTable/index.vue";
  33. import type { ProTableInstance, ColumnProps } from "@/components/ProTable/interface";
  34. import { getLawyerDetails } from "@/api/modules/lawyer";
  35. const dialogShow = ref(false);
  36. const proTable = ref<ProTableInstance>();
  37. const currentQuery = ref<String>("");
  38. const columns: ColumnProps[] = [
  39. { prop: "index", label: "序号", type: "index", width: 60, align: "center" },
  40. { label: "用户ID", prop: "clientUserId", minWidth: 120 },
  41. { label: "用户名", prop: "clientUserName", minWidth: 160, showOverflowTooltip: true },
  42. { label: "订单编号", prop: "orderNumber", minWidth: 160, showOverflowTooltip: true },
  43. { label: "订单金额", prop: "orderAmount", minWidth: 140, align: "center" },
  44. { label: "购买时间", prop: "orderTime", minWidth: 180 }
  45. ];
  46. const getTableList = async (params: any) => {
  47. try {
  48. const queryParams = {
  49. lawyerId: currentQuery.value,
  50. pageNum: params.pageNum || 1,
  51. pageSize: params.pageSize || 10
  52. };
  53. const res: any = await getLawyerDetails(queryParams);
  54. return res;
  55. } catch (error) {
  56. ElMessage.error("加载详情失败,请稍后重试");
  57. throw error;
  58. }
  59. };
  60. const dataCallback = (data: any) => {
  61. return {
  62. list: data.records || [],
  63. total: data.total || 0
  64. };
  65. };
  66. const open = async (lawyerId: String) => {
  67. currentQuery.value = lawyerId;
  68. dialogShow.value = true;
  69. // 等待对话框显示后再刷新表格数据
  70. await new Promise(resolve => setTimeout(resolve, 100));
  71. proTable.value?.getTableList();
  72. };
  73. const handleClose = () => {
  74. dialogShow.value = false;
  75. currentQuery.value = "";
  76. };
  77. defineExpose({
  78. open
  79. });
  80. </script>
  81. <style scoped lang="scss">
  82. .detail-table {
  83. min-height: 360px;
  84. max-height: 560px;
  85. overflow: hidden;
  86. }
  87. .detail-table :deep(.el-table__body-wrapper) {
  88. max-height: 380px;
  89. overflow: auto;
  90. }
  91. .detail-pagination {
  92. display: flex;
  93. justify-content: flex-end;
  94. margin-top: 12px;
  95. }
  96. </style>