users.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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="$A.windowMaxWidth(768)"></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. created() {
  47. this.noDataText = this.$L("数据加载中.....");
  48. this.columns = [{
  49. "title": this.$L("头像"),
  50. "minWidth": 60,
  51. "maxWidth": 100,
  52. render: (h, params) => {
  53. return h('UserImg', {
  54. props: {
  55. info: params.row,
  56. },
  57. style: {
  58. width: "30px",
  59. height: "30px",
  60. fontSize: "16px",
  61. lineHeight: "30px",
  62. borderRadius: "15px",
  63. verticalAlign: "middle"
  64. },
  65. });
  66. }
  67. }, {
  68. "title": this.$L("用户名"),
  69. "key": 'username',
  70. "minWidth": 80,
  71. "ellipsis": true,
  72. }, {
  73. "title": this.$L("昵称"),
  74. "minWidth": 80,
  75. "ellipsis": true,
  76. render: (h, params) => {
  77. return h('span', params.row.nickname || '-');
  78. }
  79. }, {
  80. "title": this.$L("职位/职称"),
  81. "minWidth": 100,
  82. "ellipsis": true,
  83. render: (h, params) => {
  84. return h('span', params.row.profession || '-');
  85. }
  86. }, {
  87. "title": this.$L("成员角色"),
  88. "minWidth": 100,
  89. render: (h, params) => {
  90. return h('span', params.row.isowner ? this.$L('项目负责人') : this.$L('成员'));
  91. }
  92. }, {
  93. "title": this.$L("加入时间"),
  94. "width": 160,
  95. render: (h, params) => {
  96. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  97. }
  98. }, {
  99. "title": this.$L("操作"),
  100. "key": 'action',
  101. "width": 80,
  102. "align": 'center',
  103. render: (h, params) => {
  104. return h('Button', {
  105. props: {
  106. type: 'primary',
  107. size: 'small'
  108. },
  109. style: {
  110. fontSize: '12px'
  111. },
  112. on: {
  113. click: () => {
  114. this.$Modal.confirm({
  115. title: this.$L('移出成员'),
  116. content: this.$L('你确定要将此成员移出项目吗?'),
  117. loading: true,
  118. onOk: () => {
  119. $A.apiAjax({
  120. url: 'project/users/join',
  121. data: {
  122. act: 'delete',
  123. projectid: params.row.projectid,
  124. username: params.row.username,
  125. },
  126. error: () => {
  127. this.$Modal.remove();
  128. alert(this.$L('网络繁忙,请稍后再试!'));
  129. },
  130. success: (res) => {
  131. this.$Modal.remove();
  132. this.getLists();
  133. setTimeout(() => {
  134. if (res.ret === 1) {
  135. this.$Message.success(res.msg);
  136. }else{
  137. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  138. }
  139. }, 350);
  140. }
  141. });
  142. }
  143. });
  144. }
  145. }
  146. }, this.$L('删除'));
  147. }
  148. }];
  149. },
  150. mounted() {
  151. if (this.canload) {
  152. this.loadYet = true;
  153. this.getLists(true);
  154. }
  155. },
  156. watch: {
  157. projectid() {
  158. if (this.loadYet) {
  159. this.getLists(true);
  160. }
  161. },
  162. canload(val) {
  163. if (val && !this.loadYet) {
  164. this.loadYet = true;
  165. this.getLists(true);
  166. }
  167. }
  168. },
  169. methods: {
  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>