index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <el-popover placement="bottom-start" :visible="visible" :width="width" v-bind="$attrs">
  3. <header class="flx-justify-between mt-4 mb-8">
  4. <div class="flx-start">
  5. <el-button type="primary" @click="confirm">
  6. {{ $t("common.okText") }}
  7. </el-button>
  8. <el-button text @click="close"> {{ $t("common.cancelText") }}</el-button>
  9. </div>
  10. <div class="text-h4-m text-title">{{ title }}</div>
  11. </header>
  12. <slot>
  13. <LjVxeTable
  14. :columns="columns"
  15. :data="data"
  16. :footerMethod="footerMethod"
  17. :table-props="{
  18. editConfig: { trigger: 'click', mode: 'row' }
  19. }"
  20. :tool-button="[]"
  21. table-cls=""
  22. :header-cell-class-name="headerCellClassName"
  23. >
  24. </LjVxeTable>
  25. </slot>
  26. <template #reference>
  27. <slot name="reference" :show="show"></slot>
  28. </template>
  29. </el-popover>
  30. </template>
  31. <script setup lang="ts" name="PopoverConfirm">
  32. import { ref } from "vue";
  33. import LjVxeTable from "@/components/LjVxeTable/index.vue";
  34. interface PopoverConfirmProps {
  35. columns?: any[];
  36. data?: any[];
  37. title: string;
  38. width?: string | number;
  39. /**
  40. * 表尾
  41. * @param data
  42. */
  43. footerMethod?: (data: any) => any;
  44. }
  45. const emit = defineEmits(["confirm"]);
  46. withDefaults(defineProps<PopoverConfirmProps>(), {
  47. columns: () => [],
  48. data: () => [],
  49. title: "",
  50. width: "auto"
  51. });
  52. const visible = ref(false);
  53. // 修改表头样式
  54. const headerCellClassName = ({ column }: any) => {
  55. if (column?.editRender) {
  56. return "vxecol-edit";
  57. }
  58. return null;
  59. };
  60. const confirm = () => {
  61. emit("confirm", () => {
  62. close();
  63. });
  64. };
  65. const show = () => {
  66. visible.value = true;
  67. };
  68. const close = () => {
  69. visible.value = false;
  70. };
  71. </script>
  72. <style>
  73. .vxe-table--ignore-clear {
  74. z-index: 3000 !important;
  75. }
  76. </style>