users.vue 12 KB

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