create.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. /**
  22. * 我创建的任务
  23. */
  24. export default {
  25. name: 'HeaderCreate',
  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. created() {
  48. this.noDataText = this.$L("数据加载中.....");
  49. this.columns = [{
  50. "title": this.$L("任务名称"),
  51. "key": 'title',
  52. "minWidth": 120,
  53. render: (h, params) => {
  54. return this.renderTaskTitle(h, params);
  55. }
  56. }, {
  57. "title": this.$L("负责人"),
  58. "key": 'username',
  59. "minWidth": 80,
  60. }, {
  61. "title": this.$L("完成"),
  62. "minWidth": 70,
  63. "align": "center",
  64. render: (h, params) => {
  65. return h('span', params.row.complete ? '√' : '-');
  66. }
  67. }, {
  68. "title": this.$L("归档"),
  69. "minWidth": 70,
  70. "align": "center",
  71. render: (h, params) => {
  72. return h('span', params.row.archived ? '√' : '-');
  73. }
  74. }, {
  75. "title": this.$L("创建时间"),
  76. "width": 160,
  77. render: (h, params) => {
  78. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  79. }
  80. }];
  81. },
  82. mounted() {
  83. if (this.canload) {
  84. this.loadYet = true;
  85. this.getLists(true);
  86. }
  87. $A.setOnTaskInfoListener('components/project/header/create',(act, detail) => {
  88. if (detail.createuser != $A.getUserName()) {
  89. return;
  90. }
  91. //
  92. this.lists.some((task, i) => {
  93. if (task.id == detail.id) {
  94. this.lists.splice(i, 1, detail);
  95. return true;
  96. }
  97. });
  98. //
  99. switch (act) {
  100. case "delete": // 删除任务
  101. this.lists.some((task, i) => {
  102. if (task.id == detail.id) {
  103. this.lists.splice(i, 1);
  104. return true;
  105. }
  106. });
  107. break;
  108. }
  109. });
  110. },
  111. watch: {
  112. canload(val) {
  113. if (val && !this.loadYet) {
  114. this.loadYet = true;
  115. this.getLists(true);
  116. }
  117. }
  118. },
  119. methods: {
  120. setPage(page) {
  121. this.listPage = page;
  122. this.getLists();
  123. },
  124. setPageSize(size) {
  125. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  126. this.listPageSize = size;
  127. this.getLists();
  128. }
  129. },
  130. getLists(resetLoad) {
  131. if (resetLoad === true) {
  132. this.listPage = 1;
  133. }
  134. this.loadIng++;
  135. this.noDataText = this.$L("数据加载中.....");
  136. $A.aAjax({
  137. url: 'project/task/lists',
  138. data: {
  139. createuser: 1,
  140. archived: '全部',
  141. page: Math.max(this.listPage, 1),
  142. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  143. },
  144. complete: () => {
  145. this.loadIng--;
  146. },
  147. error: () => {
  148. this.noDataText = this.$L("数据加载失败!");
  149. },
  150. success: (res) => {
  151. if (res.ret === 1) {
  152. this.lists = res.data.lists;
  153. this.listTotal = res.data.total;
  154. this.noDataText = this.$L("没有相关的数据");
  155. } else {
  156. this.lists = [];
  157. this.listTotal = 0;
  158. this.noDataText = res.msg;
  159. }
  160. }
  161. });
  162. },
  163. }
  164. }
  165. </script>