GSTC.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="gstc" ref="gstc"></div>
  3. </template>
  4. <style lang="scss">
  5. .gantt-schedule-timeline-calendar__list-column-row {
  6. .gantt-schedule-timeline-calendar__list-column-row-content {
  7. display: flex;
  8. cursor: pointer;
  9. &:hover {
  10. .gantt-schedule-timeline-calendar-goto {
  11. display: flex;
  12. }
  13. }
  14. .gantt-schedule-timeline-calendar-overdue {
  15. display: flex;
  16. align-items: center;
  17. margin-right: 2px;
  18. em {
  19. font-size: 12px;
  20. height: 22px;
  21. line-height: 22px;
  22. color: #ffffff;
  23. padding: 0 4px;
  24. border-radius: 3px;
  25. background: #ff0000;
  26. transform: scale(0.9);
  27. transform-origin: 0 center;
  28. }
  29. }
  30. .gantt-schedule-timeline-calendar-title {
  31. flex: 1;
  32. padding-right: 6px;
  33. }
  34. .gantt-schedule-timeline-calendar-goto {
  35. font-family: Ionicons;
  36. font-weight: 400;
  37. text-align: center;
  38. display: none;
  39. justify-content: center;
  40. align-items: center;
  41. width: 32px;
  42. margin-right: 8px;
  43. font-size: 16px;
  44. color: #888888;
  45. &:before {
  46. content: "\F216";
  47. }
  48. &:hover {
  49. color: #333333;
  50. }
  51. }
  52. }
  53. }
  54. </style>
  55. <script>
  56. import GSTC from "gantt-schedule-timeline-calendar";
  57. import "gantt-schedule-timeline-calendar/dist/style.css";
  58. export default {
  59. name: "GSTC",
  60. props: ["config"],
  61. data() {
  62. return {
  63. state: null,
  64. gstc: null,
  65. }
  66. },
  67. mounted() {
  68. this.state = GSTC.api.stateFromConfig(this.config);
  69. this.$emit("state", this.state);
  70. this.$refs.gstc.addEventListener('gstc-loaded', () => {
  71. this.gstc.api.scrollToTime(new Date().getTime());
  72. });
  73. this.gstc = GSTC({
  74. element: this.$refs.gstc,
  75. state: this.state
  76. });
  77. //
  78. this.$watch(
  79. "config",
  80. (config) => {
  81. this.state.update("config", current => {
  82. if (current !== config) {
  83. return GSTC.api.mergeDeep({}, current, config);
  84. } else {
  85. return current;
  86. }
  87. });
  88. },
  89. {deep: true}
  90. );
  91. },
  92. destroyed() {
  93. this.gstc.app.destroy();
  94. },
  95. methods: {
  96. getGstc() {
  97. return this.gstc;
  98. },
  99. getState() {
  100. return this.state;
  101. },
  102. setPeriod(val) {
  103. GSTC.api.setPeriod(val);
  104. },
  105. updateTime(id, time) {
  106. this.state.update('config.chart.items', items => {
  107. for (let itemId in items) {
  108. if (items.hasOwnProperty(itemId) && itemId == id) {
  109. items[itemId].time = $A.cloneData(time);
  110. }
  111. }
  112. return items;
  113. });
  114. }
  115. }
  116. };
  117. </script>