users.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="project-complete">
  4. <!-- 按钮 -->
  5. <Button :loading="loadIng > 0" type="primary" icon="md-add" @click="addUser">添加成员</Button>
  6. <!-- 列表 -->
  7. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  8. <!-- 分页 -->
  9. <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>
  10. </div>
  11. </drawer-tabs-container>
  12. </template>
  13. <style lang="scss" scoped>
  14. .project-complete {
  15. padding: 0 12px;
  16. .tableFill {
  17. margin: 12px 0 20px;
  18. }
  19. }
  20. </style>
  21. <script>
  22. import DrawerTabsContainer from "../DrawerTabsContainer";
  23. export default {
  24. name: 'ProjectUsers',
  25. components: {DrawerTabsContainer},
  26. props: {
  27. projectid: {
  28. default: 0
  29. },
  30. canload: {
  31. type: Boolean,
  32. default: true
  33. },
  34. },
  35. data () {
  36. return {
  37. loadYet: false,
  38. loadIng: 0,
  39. columns: [],
  40. lists: [],
  41. listPage: 1,
  42. listTotal: 0,
  43. noDataText: "数据加载中.....",
  44. }
  45. },
  46. created() {
  47. this.columns = [{
  48. "title": "头像",
  49. "minWidth": 60,
  50. "maxWidth": 100,
  51. render: (h, params) => {
  52. return h('img', {
  53. style: {
  54. width: "32px",
  55. height: "32px",
  56. verticalAlign: "middle",
  57. objectFit: "cover",
  58. borderRadius: "50%"
  59. },
  60. attrs: {
  61. src: params.row.userimg
  62. },
  63. });
  64. }
  65. }, {
  66. "title": "昵称",
  67. "minWidth": 80,
  68. "ellipsis": true,
  69. render: (h, params) => {
  70. return h('span', params.row.nickname || '-');
  71. }
  72. }, {
  73. "title": "用户名",
  74. "key": 'username',
  75. "minWidth": 80,
  76. "ellipsis": true,
  77. }, {
  78. "title": "职位/职称",
  79. "minWidth": 100,
  80. "ellipsis": true,
  81. render: (h, params) => {
  82. return h('span', params.row.profession || '-');
  83. }
  84. }, {
  85. "title": "成员角色",
  86. "minWidth": 100,
  87. render: (h, params) => {
  88. return h('span', params.row.isowner ? '项目负责人' : '成员');
  89. }
  90. }, {
  91. "title": "加入时间",
  92. "width": 160,
  93. render: (h, params) => {
  94. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  95. }
  96. }, {
  97. "title": "操作",
  98. "key": 'action',
  99. "width": 80,
  100. "align": 'center',
  101. render: (h, params) => {
  102. return h('Button', {
  103. props: {
  104. type: 'primary',
  105. size: 'small'
  106. },
  107. on: {
  108. click: () => {
  109. this.$Modal.confirm({
  110. title: '移出成员',
  111. content: '你确定要将此成员移出项目吗?',
  112. loading: true,
  113. onOk: () => {
  114. $A.aAjax({
  115. url: 'project/users/join',
  116. data: {
  117. act: 'delete',
  118. projectid: params.row.projectid,
  119. username: params.row.username,
  120. },
  121. error: () => {
  122. this.$Modal.remove();
  123. alert(this.$L('网络繁忙,请稍后再试!'));
  124. },
  125. success: (res) => {
  126. this.$Modal.remove();
  127. this.getLists();
  128. setTimeout(() => {
  129. if (res.ret === 1) {
  130. this.$Message.success(res.msg);
  131. }else{
  132. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  133. }
  134. }, 350);
  135. }
  136. });
  137. }
  138. });
  139. }
  140. }
  141. }, '删除');
  142. }
  143. }];
  144. },
  145. mounted() {
  146. if (this.canload) {
  147. this.loadYet = true;
  148. this.getLists(true);
  149. }
  150. },
  151. watch: {
  152. projectid() {
  153. if (this.loadYet) {
  154. this.getLists(true);
  155. }
  156. },
  157. canload(val) {
  158. if (val && !this.loadYet) {
  159. this.loadYet = true;
  160. this.getLists(true);
  161. }
  162. }
  163. },
  164. methods: {
  165. setPage(page) {
  166. this.listPage = page;
  167. this.getLists();
  168. },
  169. setPageSize(size) {
  170. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  171. this.listPageSize = size;
  172. this.getLists();
  173. }
  174. },
  175. getLists(resetLoad) {
  176. if (resetLoad === true) {
  177. this.listPage = 1;
  178. }
  179. if (this.projectid == 0) {
  180. this.lists = [];
  181. this.listTotal = 0;
  182. this.noDataText = "没有相关的数据";
  183. return;
  184. }
  185. this.loadIng++;
  186. $A.aAjax({
  187. url: 'project/users/lists',
  188. data: {
  189. page: Math.max(this.listPage, 1),
  190. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  191. projectid: this.projectid,
  192. },
  193. complete: () => {
  194. this.loadIng--;
  195. },
  196. success: (res) => {
  197. if (res.ret === 1) {
  198. this.lists = res.data.lists;
  199. this.listTotal = res.data.total;
  200. } else {
  201. this.lists = [];
  202. this.listTotal = 0;
  203. this.noDataText = res.msg;
  204. }
  205. }
  206. });
  207. },
  208. addUser() {
  209. this.userValue = "";
  210. this.$Modal.confirm({
  211. render: (h) => {
  212. return h('div', [
  213. h('div', {
  214. style: {
  215. fontSize: '16px',
  216. fontWeight: '500',
  217. marginBottom: '20px',
  218. }
  219. }, '添加成员'),
  220. h('UseridInput', {
  221. props: {
  222. value: this.userValue,
  223. multiple: true,
  224. placeholder: '请输入昵称/用户名搜索'
  225. },
  226. on: {
  227. input: (val) => {
  228. this.userValue = val;
  229. }
  230. }
  231. })
  232. ])
  233. },
  234. loading: true,
  235. onOk: () => {
  236. if (this.userValue) {
  237. let username = this.userValue;
  238. $A.aAjax({
  239. url: 'project/users/join',
  240. data: {
  241. act: 'join',
  242. projectid: this.projectid,
  243. username: username,
  244. },
  245. error: () => {
  246. this.$Modal.remove();
  247. alert(this.$L('网络繁忙,请稍后再试!'));
  248. },
  249. success: (res) => {
  250. this.$Modal.remove();
  251. this.getLists();
  252. setTimeout(() => {
  253. if (res.ret === 1) {
  254. this.$Message.success(res.msg);
  255. } else {
  256. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  257. }
  258. }, 350);
  259. }
  260. });
  261. } else {
  262. this.$Modal.remove();
  263. }
  264. },
  265. });
  266. }
  267. }
  268. }
  269. </script>