cases.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div class="table-box button-table">
  3. <ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam" :data-callback="dataCallback">
  4. <template #operation="scope">
  5. <el-button type="primary" link @click="toDetail(scope.row)"> 查看详情 </el-button>
  6. </template>
  7. </ProTable>
  8. </div>
  9. </template>
  10. <script setup lang="tsx" name="cases">
  11. import { reactive, ref } from "vue";
  12. import { useRouter } from "vue-router";
  13. import { ElLoading } from "element-plus";
  14. import ProTable from "@/components/ProTable/index.vue";
  15. import { ColumnProps, ProTableInstance } from "@/components/ProTable/interface";
  16. import { getPersonCaseList } from "@/api/modules/operationManagement";
  17. import { localGet } from "@/utils";
  18. const router = useRouter();
  19. const proTable = ref<ProTableInstance>();
  20. // 上传情况枚举
  21. const uploadStatusEnum = [
  22. { label: "未上传", value: 0 },
  23. { label: "已上传", value: 1 }
  24. ];
  25. const columns = reactive<ColumnProps<any>[]>([
  26. { prop: "nickName", label: "姓名", minWidth: 300 },
  27. { prop: "phone", label: "联系方式", width: 300 },
  28. {
  29. prop: "activityName",
  30. label: "所属活动",
  31. minWidth: 300,
  32. search: {
  33. el: "input",
  34. props: { placeholder: "请输入" },
  35. order: 2
  36. }
  37. },
  38. {
  39. prop: "hasResult",
  40. label: "上传情况",
  41. width: 300,
  42. enum: uploadStatusEnum,
  43. fieldNames: { label: "label", value: "value" },
  44. search: { el: "select", props: { placeholder: "请选择" }, order: 1 },
  45. render: (scope: any) => {
  46. const status = scope.row.hasResult;
  47. const statusItem = uploadStatusEnum.find(item => item.value === status);
  48. return statusItem ? statusItem.label : "-";
  49. }
  50. },
  51. { prop: "operation", label: "操作", fixed: "right", width: 300 }
  52. ]);
  53. const initParam = reactive({
  54. storeId: localGet("createdId")
  55. });
  56. const dataCallback = (data: any) => ({
  57. list: data?.records ?? [],
  58. total: data?.total ?? 0
  59. });
  60. const getTableList = async (params: any) => {
  61. // 显示全屏loading
  62. const loadingInstance = ElLoading.service({
  63. lock: true,
  64. text: "加载中...",
  65. background: "rgba(0, 0, 0, 0.7)"
  66. });
  67. try {
  68. // 转换参数格式以匹配新接口
  69. const newParams: any = {
  70. storeId: params.storeId || localGet("createdId"),
  71. pageNum: params.page || params.pageNum || 1,
  72. pageSize: params.size || params.pageSize || 10
  73. };
  74. // 上传情况筛选(未上传0 / 已上传1)
  75. newParams.hasResult = params.hasResult;
  76. // 所属活动(活动名称)筛选
  77. if (params.activityName) {
  78. newParams.activityName = params.activityName.trim();
  79. }
  80. const result = await getPersonCaseList(newParams);
  81. return result;
  82. } finally {
  83. // 关闭loading
  84. loadingInstance.close();
  85. }
  86. };
  87. const toDetail = (row: any) => {
  88. router.push(`/operationManagement/caseDetail?activityId=${row.activityId}&userId=${row.userId}`);
  89. };
  90. </script>