users.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. },
  24. data () {
  25. return {
  26. loadIng: 0,
  27. columns: [],
  28. lists: [],
  29. listPage: 1,
  30. listTotal: 0,
  31. noDataText: "数据加载中.....",
  32. }
  33. },
  34. created() {
  35. this.columns = [{
  36. "title": "头像",
  37. "minWidth": 50,
  38. "maxWidth": 100,
  39. render: (h, params) => {
  40. return h('img', {
  41. style: {
  42. width: "36px",
  43. height: "36px",
  44. verticalAlign: "middle",
  45. objectFit: "cover",
  46. borderRadius: "50%"
  47. },
  48. attrs: {
  49. src: params.row.userimg
  50. },
  51. });
  52. }
  53. }, {
  54. "title": "昵称",
  55. "minWidth": 80,
  56. "ellipsis": true,
  57. render: (h, params) => {
  58. return h('span', params.row.nickname || '-');
  59. }
  60. }, {
  61. "title": "用户名",
  62. "key": 'username',
  63. "minWidth": 80,
  64. "ellipsis": true,
  65. }, {
  66. "title": "职位/职称",
  67. "minWidth": 100,
  68. "ellipsis": true,
  69. render: (h, params) => {
  70. return h('span', params.row.profession || '-');
  71. }
  72. }, {
  73. "title": "成员角色",
  74. "minWidth": 100,
  75. render: (h, params) => {
  76. return h('span', params.row.isowner ? '项目负责人' : '成员');
  77. }
  78. }, {
  79. "title": "加入时间",
  80. "minWidth": 160,
  81. render: (h, params) => {
  82. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  83. }
  84. }, {
  85. "title": "操作",
  86. "key": 'action',
  87. "width": 80,
  88. "align": 'center',
  89. render: (h, params) => {
  90. return h('Button', {
  91. props: {
  92. type: 'primary',
  93. size: 'small'
  94. },
  95. on: {
  96. click: () => {
  97. }
  98. }
  99. }, '删除');
  100. }
  101. }];
  102. },
  103. mounted() {
  104. this.listPage = 1;
  105. this.getLists();
  106. },
  107. watch: {
  108. projectid() {
  109. this.listPage = 1;
  110. this.getLists();
  111. }
  112. },
  113. methods: {
  114. setPage(page) {
  115. this.listPage = page;
  116. this.getLists();
  117. },
  118. setPageSize(size) {
  119. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  120. this.listPageSize = size;
  121. this.getLists();
  122. }
  123. },
  124. getLists() {
  125. if (this.projectid == 0) {
  126. this.lists = [];
  127. this.listTotal = 0;
  128. this.noDataText = "没有相关的数据";
  129. return;
  130. }
  131. this.loadIng++;
  132. $A.aAjax({
  133. url: 'project/users',
  134. data: {
  135. page: Math.max(this.listPage, 1),
  136. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  137. projectid: this.projectid,
  138. },
  139. complete: () => {
  140. this.loadIng--;
  141. },
  142. success: (res) => {
  143. if (res.ret === 1) {
  144. this.lists = res.data.lists;
  145. this.listTotal = res.data.total;
  146. } else {
  147. this.lists = [];
  148. this.listTotal = 0;
  149. this.noDataText = res.msg;
  150. }
  151. }
  152. });
  153. },
  154. }
  155. }
  156. </script>