ZBLOG

要将 FollowUpModal 以弹窗的形式打开,你可以使用 Ant Design Vue 的 Modal 组件来实现。你需要在点击 “跟进” 按钮时,显示这个模态框,并通过 prop 将需要传递的数据传给 FollowUpModal

下面是修改后的代码示例:

  1. <template>
  2. <a-table
  3. :columns="columns"
  4. :data-source="data"
  5. :scroll="{
  6. x: columns.reduce((sum, col) => sum + (col.width || 0), 0) > 1800 ? undefined : 'max-content'
  7. }"
  8. :pagination="{
  9. current: currentPage,
  10. pageSize: pageSize,
  11. total: totalRecords,
  12. pageSizeOptions: ['10', '20', '30', '40', '100'],
  13. onShowSizeChange: handlePageSizeChange,
  14. onChange: handlePageChange,
  15. showQuickJumper: true,
  16. showSizeChanger: true,
  17. showTotal: (total, range) => `显示 ${range[0]}~${range[1]} 条记录,共 ${total} 条记录`
  18. }"
  19. >
  20. <template #bodyCell="{ column, record }">
  21. <template v-if="column.key === 'operation'">
  22. <a-button @click="openModal('followUp', record)">跟进</a-button>
  23. <a-button @click="complete(record)">完成</a-button>
  24. </template>
  25. </template>
  26. </a-table>
  27. <!-- Follow Up Modal -->
  28. <a-modal
  29. v-model:visible="isModalVisible"
  30. title="跟进"
  31. @ok="handleOk"
  32. @cancel="handleCancel"
  33. >
  34. <FollowUpModal :record="currentRecord" />
  35. </a-modal>
  36. </template>
  37. <script setup>
  38. import { ref } from 'vue';
  39. import FollowUpModal from '../workOrderManager/components/followUpPage.vue';
  40. const columns = ref([]);
  41. const data = ref([]);
  42. const currentPage = ref(1);
  43. const pageSize = ref(10);
  44. const totalRecords = ref(100);
  45. const isModalVisible = ref(false);
  46. const currentRecord = ref(null);
  47. const openModal = (action, record) => {
  48. if (action === 'followUp') {
  49. currentRecord.value = record;
  50. isModalVisible.value = true;
  51. }
  52. };
  53. const handleOk = () => {
  54. // Handle the OK action here
  55. isModalVisible.value = false;
  56. };
  57. const handleCancel = () => {
  58. isModalVisible.value = false;
  59. };
  60. const complete = (record) => {
  61. console.log('完成', record);
  62. };
  63. </script>
  64. <style scoped>
  65. /* Add any styles you may need */
  66. </style>

修改说明:

  1. 模态框 (<a-modal>):添加了一个 <a-modal> 元素来包裹 FollowUpModal,并根据 isModalVisible 控制其显示与隐藏。
  2. 按钮事件:在 “跟进” 按钮中,使用 @click 指令调用 openModal 方法,同时传入相应的记录。
  3. 记录管理:定义了一个名为 currentRecord 的响应式变量,用于存储当前要在模态框中处理的记录。
  4. 确定和取消处理方法:分别处理确定和取消操作时关闭模态框。

这样,当用户点击“跟进”按钮时,会弹出包含 FollowUpModal 的模态框。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=22455

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?