attention.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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": 100,
  49. render: (h, params) => {
  50. return h('div', [
  51. h('Icon', {
  52. props: { type: params.row.complete ? 'md-checkbox-outline' : 'md-square-outline' },
  53. style: {marginRight: '4px', cursor: 'pointer', fontSize: '15px'},
  54. on: {
  55. click: () => {
  56. this.taskComplete(params.row, !params.row.complete, (detail) => {
  57. this.$emit("change", detail.complete ? 'complete' : 'unfinished', detail);
  58. });
  59. }
  60. }
  61. }),
  62. h('span', {
  63. style: {cursor: 'pointer'},
  64. on: {
  65. click: () => {
  66. let taskDetail = params.row;
  67. this.taskDetail(taskDetail, (act, detail) => {
  68. for (let key in detail) {
  69. if (detail.hasOwnProperty(key)) {
  70. this.$set(taskDetail, key, detail[key])
  71. }
  72. }
  73. //
  74. switch (act) {
  75. case "username": // 负责人
  76. case "delete": // 删除任务
  77. case "archived": // 归档
  78. this.lists.some((task, i) => {
  79. if (task.id == detail.id) {
  80. this.lists.splice(i, 1);
  81. return true;
  82. }
  83. });
  84. break;
  85. case "unarchived": // 取消归档
  86. this.lists.unshift(detail);
  87. break;
  88. }
  89. //
  90. this.$emit("change", act, detail);
  91. });
  92. }
  93. }
  94. }, params.row.title)
  95. ]);
  96. }
  97. }, {
  98. "title": "创建人",
  99. "key": 'createuser',
  100. "minWidth": 80,
  101. }, {
  102. "title": "负责人",
  103. "key": 'username',
  104. "minWidth": 80,
  105. }, {
  106. "title": "添加时间",
  107. "width": 160,
  108. render: (h, params) => {
  109. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.inorder));
  110. }
  111. }];
  112. },
  113. mounted() {
  114. if (this.canload) {
  115. this.loadYet = true;
  116. this.getLists(true);
  117. }
  118. },
  119. watch: {
  120. canload(val) {
  121. if (val && !this.loadYet) {
  122. this.loadYet = true;
  123. this.getLists(true);
  124. }
  125. }
  126. },
  127. methods: {
  128. setPage(page) {
  129. this.listPage = page;
  130. this.getLists();
  131. },
  132. setPageSize(size) {
  133. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  134. this.listPageSize = size;
  135. this.getLists();
  136. }
  137. },
  138. getLists(resetLoad) {
  139. if (resetLoad === true) {
  140. this.listPage = 1;
  141. }
  142. this.loadIng++;
  143. $A.aAjax({
  144. url: 'project/task/lists',
  145. data: {
  146. attention: 1,
  147. archived: '全部',
  148. page: Math.max(this.listPage, 1),
  149. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  150. },
  151. complete: () => {
  152. this.loadIng--;
  153. },
  154. success: (res) => {
  155. if (res.ret === 1) {
  156. this.lists = res.data.lists;
  157. this.listTotal = res.data.total;
  158. } else {
  159. this.lists = [];
  160. this.listTotal = 0;
  161. this.noDataText = res.msg;
  162. }
  163. }
  164. });
  165. },
  166. }
  167. }
  168. </script>