attention.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="project-complete">
  4. <!-- 列表 -->
  5. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  6. <!-- 分页 -->
  7. <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total transfer></Page>
  8. </div>
  9. </drawer-tabs-container>
  10. </template>
  11. <style lang="scss" scoped>
  12. .project-complete {
  13. .tableFill {
  14. margin: 12px 12px 20px;
  15. }
  16. }
  17. </style>
  18. <script>
  19. import DrawerTabsContainer from "../../DrawerTabsContainer";
  20. import Task from "../../../mixins/task";
  21. export default {
  22. name: 'TodoAttention',
  23. components: {DrawerTabsContainer},
  24. props: {
  25. canload: {
  26. type: Boolean,
  27. default: true
  28. },
  29. },
  30. mixins: [
  31. Task
  32. ],
  33. data () {
  34. return {
  35. loadYet: false,
  36. loadIng: 0,
  37. columns: [],
  38. lists: [],
  39. listPage: 1,
  40. listTotal: 0,
  41. noDataText: "数据加载中.....",
  42. }
  43. },
  44. created() {
  45. this.columns = [{
  46. "title": "任务名称",
  47. "key": 'title',
  48. "minWidth": 120,
  49. render: (h, params) => {
  50. return this.renderTaskTitle(h, params);
  51. }
  52. }, {
  53. "title": "创建人",
  54. "key": 'createuser',
  55. "minWidth": 80,
  56. }, {
  57. "title": "负责人",
  58. "key": 'username',
  59. "minWidth": 80,
  60. }, {
  61. "title": "完成",
  62. "minWidth": 70,
  63. "align": "center",
  64. render: (h, params) => {
  65. return h('span', params.row.complete ? '√' : '-');
  66. }
  67. }, {
  68. "title": "归档",
  69. "minWidth": 70,
  70. "align": "center",
  71. render: (h, params) => {
  72. return h('span', params.row.archived ? '√' : '-');
  73. }
  74. }, {
  75. "title": "关注时间",
  76. "width": 160,
  77. render: (h, params) => {
  78. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.attentiondate));
  79. }
  80. }];
  81. },
  82. mounted() {
  83. if (this.canload) {
  84. this.loadYet = true;
  85. this.getLists(true);
  86. }
  87. $A.setOnTaskInfoListener('components/project/todo/attention',(act, detail) => {
  88. this.lists.some((task, i) => {
  89. if (task.id == detail.id) {
  90. this.lists.splice(i, 1, detail);
  91. return true;
  92. }
  93. });
  94. //
  95. switch (act) {
  96. case "unattention": // 取消关注
  97. case "delete": // 删除任务
  98. this.lists.some((task, i) => {
  99. if (task.id == detail.id) {
  100. this.lists.splice(i, 1);
  101. return true;
  102. }
  103. });
  104. break;
  105. case "attention": // 添加关注
  106. let username = $A.getUserName();
  107. if (detail.follower.filter((uname) => { return uname == username }).length > 0) {
  108. let has = false;
  109. this.lists.some((task) => {
  110. if (task.id == detail.id) {
  111. return has = true;
  112. }
  113. });
  114. if (!has) {
  115. this.lists.unshift(detail);
  116. }
  117. }
  118. break;
  119. }
  120. });
  121. },
  122. watch: {
  123. canload(val) {
  124. if (val && !this.loadYet) {
  125. this.loadYet = true;
  126. this.getLists(true);
  127. }
  128. }
  129. },
  130. methods: {
  131. setPage(page) {
  132. this.listPage = page;
  133. this.getLists();
  134. },
  135. setPageSize(size) {
  136. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  137. this.listPageSize = size;
  138. this.getLists();
  139. }
  140. },
  141. getLists(resetLoad) {
  142. if (resetLoad === true) {
  143. this.listPage = 1;
  144. }
  145. this.loadIng++;
  146. this.noDataText = "数据加载中.....";
  147. $A.aAjax({
  148. url: 'project/task/lists',
  149. data: {
  150. attention: 1,
  151. archived: '全部',
  152. page: Math.max(this.listPage, 1),
  153. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  154. },
  155. complete: () => {
  156. this.loadIng--;
  157. },
  158. success: (res) => {
  159. if (res.ret === 1) {
  160. this.lists = res.data.lists;
  161. this.listTotal = res.data.total;
  162. this.noDataText = "没有相关的数据";
  163. } else {
  164. this.lists = [];
  165. this.listTotal = 0;
  166. this.noDataText = res.msg;
  167. }
  168. }
  169. });
  170. },
  171. }
  172. }
  173. </script>