users.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div class="project-complete">
  3. <!-- 列表 -->
  4. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  5. <!-- 分页 -->
  6. <Page class="pageBox" :total="listTotal" :current="listPage" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total></Page>
  7. </div>
  8. </template>
  9. <style lang="scss" scoped>
  10. .project-complete {
  11. .tableFill {
  12. margin: 20px;
  13. }
  14. }
  15. </style>
  16. <script>
  17. export default {
  18. name: 'ProjectUsers',
  19. props: {
  20. projectid: {
  21. default: 0
  22. },
  23. canload: {
  24. type: Boolean,
  25. default: true
  26. },
  27. },
  28. data () {
  29. return {
  30. loadYet: false,
  31. loadIng: 0,
  32. columns: [],
  33. lists: [],
  34. listPage: 1,
  35. listTotal: 0,
  36. noDataText: "数据加载中.....",
  37. }
  38. },
  39. created() {
  40. this.columns = [{
  41. "title": "头像",
  42. "minWidth": 50,
  43. "maxWidth": 100,
  44. render: (h, params) => {
  45. return h('img', {
  46. style: {
  47. width: "36px",
  48. height: "36px",
  49. verticalAlign: "middle",
  50. objectFit: "cover",
  51. borderRadius: "50%"
  52. },
  53. attrs: {
  54. src: params.row.userimg
  55. },
  56. });
  57. }
  58. }, {
  59. "title": "昵称",
  60. "minWidth": 80,
  61. "ellipsis": true,
  62. render: (h, params) => {
  63. return h('span', params.row.nickname || '-');
  64. }
  65. }, {
  66. "title": "用户名",
  67. "key": 'username',
  68. "minWidth": 80,
  69. "ellipsis": true,
  70. }, {
  71. "title": "职位/职称",
  72. "minWidth": 100,
  73. "ellipsis": true,
  74. render: (h, params) => {
  75. return h('span', params.row.profession || '-');
  76. }
  77. }, {
  78. "title": "成员角色",
  79. "minWidth": 100,
  80. render: (h, params) => {
  81. return h('span', params.row.isowner ? '项目负责人' : '成员');
  82. }
  83. }, {
  84. "title": "加入时间",
  85. "minWidth": 160,
  86. render: (h, params) => {
  87. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  88. }
  89. }, {
  90. "title": "操作",
  91. "key": 'action',
  92. "width": 80,
  93. "align": 'center',
  94. render: (h, params) => {
  95. return h('Button', {
  96. props: {
  97. type: 'primary',
  98. size: 'small'
  99. },
  100. on: {
  101. click: () => {
  102. }
  103. }
  104. }, '删除');
  105. }
  106. }];
  107. },
  108. mounted() {
  109. if (this.canload) {
  110. this.loadYet = true;
  111. this.getLists(true);
  112. }
  113. },
  114. watch: {
  115. projectid() {
  116. if (this.loadYet) {
  117. this.loadYet = true;
  118. this.getLists(true);
  119. }
  120. },
  121. canload(val) {
  122. if (val && !this.loadYet) {
  123. this.loadYet = true;
  124. this.getLists(true);
  125. }
  126. }
  127. },
  128. methods: {
  129. setPage(page) {
  130. this.listPage = page;
  131. this.getLists();
  132. },
  133. setPageSize(size) {
  134. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  135. this.listPageSize = size;
  136. this.getLists();
  137. }
  138. },
  139. getLists(resetLoad) {
  140. if (resetLoad === true) {
  141. this.listPage = 1;
  142. }
  143. if (this.projectid == 0) {
  144. this.lists = [];
  145. this.listTotal = 0;
  146. this.noDataText = "没有相关的数据";
  147. return;
  148. }
  149. this.loadIng++;
  150. $A.aAjax({
  151. url: 'project/users',
  152. data: {
  153. page: Math.max(this.listPage, 1),
  154. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  155. projectid: this.projectid,
  156. },
  157. complete: () => {
  158. this.loadIng--;
  159. },
  160. success: (res) => {
  161. if (res.ret === 1) {
  162. this.lists = res.data.lists;
  163. this.listTotal = res.data.total;
  164. } else {
  165. this.lists = [];
  166. this.listTotal = 0;
  167. this.noDataText = res.msg;
  168. }
  169. }
  170. });
  171. },
  172. }
  173. }
  174. </script>