capital-modal.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <script setup lang="ts">
  2. import { onMounted, ref, unref } from "vue";
  3. import { ElTable } from "element-plus";
  4. import { useAsync } from "/@/hooks";
  5. import { httpTradeList } from "/@/api/InvoiceSales/refund";
  6. import { CAPITAL_COLUMNS } from "/@/utils/details/tragelog";
  7. const visible = ref(false);
  8. const selectOrder = ref<Array<Record<string, string>>>([]);
  9. const emit = defineEmits(["on-add-order"]);
  10. const tableRef = ref<InstanceType<typeof ElTable>>(null);
  11. const { run, data, getPaginationParams, loading, pagination } = useAsync({
  12. initalData: [],
  13. isList: true,
  14. initalPagination: {
  15. currentPage: 1,
  16. pageSize: 10,
  17. total: 0
  18. }
  19. });
  20. const requestPaymentlist = () => {
  21. run(httpTradeList({ status: "2", ...getPaginationParams() }));
  22. };
  23. function handleConfirm() {
  24. visible.value = false;
  25. emit("on-add-order", unref(selectOrder.value[0]));
  26. }
  27. function handleSelectionChange(values) {
  28. if (values.length > 1) {
  29. const value = values.pop();
  30. tableRef.value.clearSelection();
  31. tableRef.value.toggleRowSelection(value, true);
  32. selectOrder.value = [value];
  33. } else {
  34. selectOrder.value = [values[0]];
  35. }
  36. }
  37. defineExpose({
  38. onDisplay: () => (visible.value = true)
  39. });
  40. onMounted(() => requestPaymentlist());
  41. </script>
  42. <template>
  43. <el-dialog v-model="visible" title="资金认领" center>
  44. <el-table
  45. border
  46. ref="tableRef"
  47. :data="data"
  48. size="small"
  49. row-key="id"
  50. @selection-change="handleSelectionChange"
  51. v-loading="loading"
  52. >
  53. <el-table-column type="selection" width="55" />
  54. <el-table-column
  55. v-for="({ field }, index) in CAPITAL_COLUMNS"
  56. :key="index"
  57. :prop="field"
  58. show-overflow-tooltip
  59. />
  60. </el-table>
  61. <el-pagination
  62. :total="pagination.total"
  63. v-model:current-page="pagination.currentPage"
  64. @current-change="requestPaymentlist"
  65. />
  66. <div w-full flex justify-end mt-2>
  67. <el-button type="primary" size="small" @click="handleConfirm"
  68. >确定</el-button
  69. >
  70. <el-button size="small" @click="() => (visible = false)">取消</el-button>
  71. </div>
  72. </el-dialog>
  73. </template>
  74. <style lang="scss" scoped>
  75. :deep(.el-table__header) {
  76. .el-checkbox {
  77. display: none;
  78. }
  79. }
  80. </style>