SupplyProject.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <script setup lang="ts">
  2. import { ref } from 'vue';
  3. import { type VxeGridInstance, type VxeGridProps } from 'vxe-pc-ui';
  4. import type { SupplierModel } from '@/model/care.model';
  5. type FollowModel = Partial<SupplierModel>;
  6. const props = defineProps<{ data: FollowModel }>();
  7. // 定义居家项目表格数据
  8. const homeData = ref<Array<{ project: string }>>([]);
  9. // 定义线下项目表格数据
  10. const offlineData = ref<Array<{ project: string }>>([]);
  11. // 居家项目表格配置
  12. const homeGridOptions = reactive<VxeGridProps>({
  13. border: true,
  14. autoResize: true,
  15. columns: [
  16. { type: 'seq', title: '序号', width: 80 },
  17. { field: 'project', title: '居家项目', width: 320 },
  18. ],
  19. data: homeData.value,
  20. });
  21. // 线下项目表格配置
  22. const offlineGridOptions = reactive<VxeGridProps>({
  23. border: true,
  24. autoResize: true,
  25. columns: [
  26. { type: 'seq', title: '序号', width: 80 },
  27. { field: 'project', title: '线下项目', width: 320 },
  28. ],
  29. data: offlineData.value,
  30. });
  31. // 表格引用
  32. const homeGridRef = ref<VxeGridInstance>();
  33. const offlineGridRef = ref<VxeGridInstance>();
  34. onMounted(() => {
  35. if (props?.data?.offlineCPTypes?.length > 0) {
  36. props.data.offlineCPTypes.forEach((item: string) => {
  37. offlineData.value.push({ project: item });
  38. });
  39. }else{
  40. offlineData.value = [];
  41. }
  42. if (props?.data?.onlineCPTypes?.length > 0) {
  43. props.data.onlineCPTypes.forEach((item: string) => {
  44. homeData.value.push({ project: item });
  45. });
  46. }else{
  47. homeData.value = [];
  48. }
  49. });
  50. </script>
  51. <template>
  52. <div class="tables-container">
  53. <div class="table-wrapper">
  54. <vxe-grid ref="homeGridRef" v-bind="homeGridOptions" />
  55. </div>
  56. <div class="table-wrapper">
  57. <vxe-grid ref="offlineGridRef" v-bind="offlineGridOptions" />
  58. </div>
  59. </div>
  60. </template>
  61. <style scoped lang="scss">
  62. .tables-container {
  63. display: flex;
  64. padding: 20px;
  65. height: 600px;
  66. }
  67. .table-wrapper {
  68. flex: 1;
  69. }
  70. </style>