company-modal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <script setup lang="ts">
  2. import { ElTable } from "element-plus";
  3. import { reactive, ref, unref } from "vue";
  4. import { useResponseHandle } from "/@/hooks/core/useAsync";
  5. import { httpCompanyList } from "/@/api/interest/account";
  6. const paymentList = ref<Array<Record<string, string>>>([]);
  7. const selectOrder = ref<Array<Record<string, string>>>([]);
  8. const params = ref({
  9. name: ""
  10. });
  11. const loading = ref(false);
  12. const visible = ref(false);
  13. const emit = defineEmits(["choose"]);
  14. const tableRef = ref<InstanceType<typeof ElTable>>(null);
  15. const responseHandle = useResponseHandle();
  16. const pagination = reactive({
  17. currentPage: 1,
  18. pageSize: 10,
  19. total: 0
  20. });
  21. async function requestPaymentList() {
  22. const { pageSize: size, currentPage: page } = pagination;
  23. loading.value = true;
  24. const { code, message, data } = await httpCompanyList({
  25. ...params.value,
  26. size,
  27. page
  28. });
  29. responseHandle({
  30. code,
  31. message,
  32. handler: () => {
  33. pagination.total = data.count;
  34. paymentList.value = data.list;
  35. }
  36. });
  37. loading.value = false;
  38. }
  39. function handleConfirm() {
  40. visible.value = false;
  41. emit("choose", unref(selectOrder));
  42. }
  43. function handleSelectionChange(values) {
  44. selectOrder.value = values;
  45. }
  46. function onSearch(_isReset = false) {
  47. if (_isReset) {
  48. params.value = {
  49. name: ""
  50. };
  51. }
  52. pagination.currentPage = 1;
  53. requestPaymentList();
  54. }
  55. defineExpose({
  56. onDisplay: () => {
  57. visible.value = true;
  58. }
  59. });
  60. </script>
  61. <template>
  62. <el-dialog
  63. v-model="visible"
  64. title="业务公司"
  65. center
  66. width="1040px"
  67. @open="() => requestPaymentList()"
  68. @close="() => (params.name = '')"
  69. >
  70. <div flex mb-2>
  71. <div flex flex-1 gap="5" pr="20px">
  72. <el-input placeholder="公司名称" size="small" v-model="params.name" />
  73. </div>
  74. <div flex width="120px">
  75. <el-button size="small" type="primary" @click="() => onSearch()"
  76. >搜索</el-button
  77. >
  78. <el-button size="small" @click="() => onSearch(true)">重置</el-button>
  79. </div>
  80. </div>
  81. <el-table
  82. v-loading="loading"
  83. border
  84. ref="tableRef"
  85. :data="paymentList"
  86. size="small"
  87. row-key="id"
  88. @selection-change="handleSelectionChange"
  89. >
  90. <el-table-column type="selection" width="55" />
  91. <el-table-column label="公司编号" prop="companyNo" show-overflow-tooltip />
  92. <el-table-column label="公司名称" prop="name" show-overflow-tooltip />
  93. <!--<el-table-column label="公司类型" prop="nature" show-overflow-tooltip />-->
  94. </el-table>
  95. <div flex justify-between mt-2>
  96. <el-pagination
  97. v-model:current-page="pagination.currentPage"
  98. v-model:page-size="pagination.pageSize"
  99. :total="pagination.total"
  100. @current-change="requestPaymentList"
  101. />
  102. <el-button type="primary" size="small" @click="handleConfirm"
  103. >确定</el-button
  104. >
  105. </div>
  106. </el-dialog>
  107. </template>
  108. <style lang="scss" scoped>
  109. :deep(.el-table__header) {
  110. .el-checkbox {
  111. display: none;
  112. }
  113. }
  114. </style>