Schedule.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <Tree :data="requirements" @change="handleTreeChange" @nodeClick="handleNodeClick" ref="tree"></Tree>
  3. <RightForm ref="rightForm"/>
  4. </template>
  5. <script>
  6. import Tree from '@/components/Tree.vue';
  7. import RightForm from '@/components/RightForm.vue';
  8. import { RequirementAPI } from '@/api';
  9. export default {
  10. name: 'Schedule',
  11. components: { Tree, RightForm },
  12. data() {
  13. return {
  14. requirements: [
  15. {
  16. id: 1,
  17. title: 't1',
  18. parent: null,
  19. state: '未开始',
  20. },
  21. {
  22. id: 2,
  23. title: 't2',
  24. parent: 1,
  25. state: '未开始',
  26. },
  27. {
  28. id: 3,
  29. title: 't3',
  30. parent: 1,
  31. state: '未开始',
  32. },
  33. {
  34. id: 4,
  35. title: 't4',
  36. parent: 2,
  37. state: '未开始',
  38. },
  39. {
  40. id: 5,
  41. title: 't5',
  42. parent: 2,
  43. state: '进行中',
  44. },
  45. {
  46. id: 6,
  47. title: 't6',
  48. parent: 4,
  49. state: '已完成',
  50. },
  51. ],
  52. };
  53. },
  54. methods: {
  55. async handleTreeChange(msg) {
  56. // TODO: 补充API定义
  57. const { type, id } = msg;
  58. await RequirementAPI[type](id);
  59. // this.requirements = await RequirementAPI.getTreeNode(projectId);
  60. this.$refs.tree.regenerateTree();
  61. },
  62. handleNodeClick(id) {
  63. this.$refs.rightForm.showForm();
  64. },
  65. },
  66. };
  67. </script>
  68. <style>
  69. </style>