attention.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="project-todo-attention">
  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 :simple="windowMax768"></Page>
  8. </div>
  9. </drawer-tabs-container>
  10. </template>
  11. <style lang="scss" scoped>
  12. .project-todo-attention {
  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. /**
  22. * 我关注的任务
  23. */
  24. export default {
  25. name: 'TodoAttention',
  26. components: {DrawerTabsContainer},
  27. props: {
  28. canload: {
  29. type: Boolean,
  30. default: true
  31. },
  32. },
  33. mixins: [
  34. Task
  35. ],
  36. data () {
  37. return {
  38. loadYet: false,
  39. loadIng: 0,
  40. columns: [],
  41. lists: [],
  42. listPage: 1,
  43. listTotal: 0,
  44. noDataText: "",
  45. }
  46. },
  47. mounted() {
  48. if (this.canload) {
  49. this.loadYet = true;
  50. this.getLists(true);
  51. }
  52. $A.setOnTaskInfoListener('components/project/todo/attention', (act, detail) => {
  53. if (detail.follower.indexOf(this.usrName) === -1) {
  54. this.lists.some((task, i) => {
  55. if (task.id == detail.id) {
  56. this.lists.splice(i, 1);
  57. return true;
  58. }
  59. });
  60. return;
  61. }
  62. //
  63. this.lists.some((task, i) => {
  64. if (task.id == detail.id) {
  65. this.lists.splice(i, 1, detail);
  66. return true;
  67. }
  68. });
  69. //
  70. switch (act) {
  71. case "unattention": // 取消关注
  72. case "delete": // 删除任务
  73. this.lists.some((task, i) => {
  74. if (task.id == detail.id) {
  75. this.lists.splice(i, 1);
  76. return true;
  77. }
  78. });
  79. break;
  80. case "attention": // 添加关注
  81. let username = this.usrName;
  82. if (detail.follower.filter((uname) => { return uname == username }).length == 0) {
  83. return;
  84. }
  85. let has = false;
  86. this.lists.some((task) => {
  87. if (task.id == detail.id) {
  88. return has = true;
  89. }
  90. });
  91. if (!has) {
  92. this.lists.unshift(detail);
  93. }
  94. break;
  95. }
  96. });
  97. },
  98. watch: {
  99. canload(val) {
  100. if (val && !this.loadYet) {
  101. this.loadYet = true;
  102. this.getLists(true);
  103. }
  104. }
  105. },
  106. methods: {
  107. initLanguage() {
  108. this.noDataText = this.$L("数据加载中.....");
  109. this.columns = [{
  110. "title": this.$L("任务名称"),
  111. "key": 'title',
  112. "minWidth": 120,
  113. render: (h, params) => {
  114. return this.renderTaskTitle(h, params);
  115. }
  116. }, {
  117. "title": this.$L("创建人"),
  118. "key": 'createuser',
  119. "minWidth": 80,
  120. render: (h, params) => {
  121. return h('UserView', {
  122. props: {
  123. username: params.row.createuser
  124. }
  125. });
  126. }
  127. }, {
  128. "title": this.$L("负责人"),
  129. "key": 'username',
  130. "minWidth": 80,
  131. render: (h, params) => {
  132. return h('UserView', {
  133. props: {
  134. username: params.row.username
  135. }
  136. });
  137. }
  138. }, {
  139. "title": this.$L("完成"),
  140. "minWidth": 70,
  141. "align": "center",
  142. render: (h, params) => {
  143. return h('span', params.row.complete ? '√' : '-');
  144. }
  145. }, {
  146. "title": this.$L("归档"),
  147. "minWidth": 70,
  148. "align": "center",
  149. render: (h, params) => {
  150. return h('span', params.row.archived ? '√' : '-');
  151. }
  152. }, {
  153. "title": this.$L("关注时间"),
  154. "width": 160,
  155. render: (h, params) => {
  156. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.attentiondate));
  157. }
  158. }];
  159. },
  160. setPage(page) {
  161. this.listPage = page;
  162. this.getLists();
  163. },
  164. setPageSize(size) {
  165. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  166. this.listPageSize = size;
  167. this.getLists();
  168. }
  169. },
  170. getLists(resetLoad) {
  171. if (resetLoad === true) {
  172. this.listPage = 1;
  173. }
  174. this.loadIng++;
  175. this.noDataText = this.$L("数据加载中.....");
  176. $A.apiAjax({
  177. url: 'project/task/lists',
  178. data: {
  179. attention: 1,
  180. archived: '全部',
  181. page: Math.max(this.listPage, 1),
  182. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  183. },
  184. complete: () => {
  185. this.loadIng--;
  186. },
  187. error: () => {
  188. this.noDataText = this.$L("数据加载失败!");
  189. },
  190. success: (res) => {
  191. if (res.ret === 1) {
  192. this.lists = res.data.lists;
  193. this.listTotal = res.data.total;
  194. this.noDataText = this.$L("没有相关的数据");
  195. } else {
  196. this.lists = [];
  197. this.listTotal = 0;
  198. this.noDataText = res.msg;
  199. }
  200. }
  201. });
  202. },
  203. }
  204. }
  205. </script>