users.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="book-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. .book-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: 'BookUsers',
  25. components: {DrawerTabsContainer},
  26. props: {
  27. id: {
  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. id() {
  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. "width": 160,
  109. render: (h, params) => {
  110. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  111. }
  112. }, {
  113. "title": this.$L("操作"),
  114. "key": 'action',
  115. "width": 80,
  116. "align": 'center',
  117. render: (h, params) => {
  118. return h('Button', {
  119. props: {
  120. type: 'primary',
  121. size: 'small'
  122. },
  123. style: {
  124. fontSize: '12px'
  125. },
  126. on: {
  127. click: () => {
  128. this.$Modal.confirm({
  129. title: this.$L('移出成员'),
  130. content: this.$L('你确定要将此成员移出项目吗?'),
  131. loading: true,
  132. onOk: () => {
  133. $A.apiAjax({
  134. url: 'docs/users/join',
  135. data: {
  136. act: 'delete',
  137. id: params.row.bookid,
  138. username: params.row.username,
  139. },
  140. error: () => {
  141. this.$Modal.remove();
  142. alert(this.$L('网络繁忙,请稍后再试!'));
  143. },
  144. success: (res) => {
  145. this.$Modal.remove();
  146. this.getLists();
  147. setTimeout(() => {
  148. if (res.ret === 1) {
  149. this.$Message.success(res.msg);
  150. }else{
  151. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  152. }
  153. }, 350);
  154. }
  155. });
  156. }
  157. });
  158. }
  159. }
  160. }, this.$L('删除'));
  161. }
  162. }];
  163. },
  164. setPage(page) {
  165. this.listPage = page;
  166. this.getLists();
  167. },
  168. setPageSize(size) {
  169. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  170. this.listPageSize = size;
  171. this.getLists();
  172. }
  173. },
  174. getLists(resetLoad) {
  175. if (resetLoad === true) {
  176. this.listPage = 1;
  177. }
  178. if (this.id == 0) {
  179. this.lists = [];
  180. this.listTotal = 0;
  181. this.noDataText = this.$L("没有相关的数据");
  182. return;
  183. }
  184. this.loadIng++;
  185. this.noDataText = this.$L("数据加载中.....");
  186. $A.apiAjax({
  187. url: 'docs/users/lists',
  188. data: {
  189. page: Math.max(this.listPage, 1),
  190. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  191. id: this.id,
  192. },
  193. complete: () => {
  194. this.loadIng--;
  195. },
  196. error: () => {
  197. this.noDataText = this.$L("数据加载失败!");
  198. },
  199. success: (res) => {
  200. if (res.ret === 1) {
  201. this.lists = res.data.lists;
  202. this.listTotal = res.data.total;
  203. this.noDataText = this.$L("没有相关的数据");
  204. } else {
  205. this.lists = [];
  206. this.listTotal = 0;
  207. this.noDataText = res.msg;
  208. }
  209. }
  210. });
  211. },
  212. addUser() {
  213. this.userValue = "";
  214. this.$Modal.confirm({
  215. render: (h) => {
  216. return h('div', [
  217. h('div', {
  218. style: {
  219. fontSize: '16px',
  220. fontWeight: '500',
  221. marginBottom: '20px',
  222. }
  223. }, this.$L('添加成员')),
  224. h('UserInput', {
  225. props: {
  226. value: this.userValue,
  227. multiple: true,
  228. nousername: this.usrName,
  229. nobookid: this.id,
  230. placeholder: this.$L('请输入昵称/用户名搜索')
  231. },
  232. on: {
  233. input: (val) => {
  234. this.userValue = val;
  235. }
  236. }
  237. })
  238. ])
  239. },
  240. loading: true,
  241. onOk: () => {
  242. if (this.userValue) {
  243. let username = this.userValue;
  244. $A.apiAjax({
  245. url: 'docs/users/join',
  246. data: {
  247. act: 'join',
  248. id: this.id,
  249. username: username,
  250. },
  251. error: () => {
  252. this.$Modal.remove();
  253. alert(this.$L('网络繁忙,请稍后再试!'));
  254. },
  255. success: (res) => {
  256. this.$Modal.remove();
  257. this.getLists();
  258. setTimeout(() => {
  259. if (res.ret === 1) {
  260. this.$Message.success(res.msg);
  261. } else {
  262. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  263. }
  264. }, 350);
  265. }
  266. });
  267. } else {
  268. this.$Modal.remove();
  269. }
  270. },
  271. });
  272. }
  273. }
  274. }
  275. </script>