team.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div class="w-main team">
  3. <v-title>{{$L('团队')}}-{{$L('轻量级的团队在线协作')}}</v-title>
  4. <w-header value="team"></w-header>
  5. <div class="w-nav">
  6. <div class="nav-row">
  7. <div class="w-nav-left">
  8. <div class="page-nav-left">
  9. <span><i class="ft icon">&#xE90D;</i> {{$L('团队成员')}}</span>
  10. <div v-if="loadIng > 0" class="page-nav-loading"><w-loading></w-loading></div>
  11. <div v-else class="page-nav-refresh"><em @click="getLists(true)">{{$L('刷新')}}</em></div>
  12. </div>
  13. </div>
  14. <div class="w-nav-flex"></div>
  15. <div class="w-nav-right">
  16. <span class="ft hover" @click="addShow=true"><i class="ft icon">&#xE740;</i> {{$L('添加团队成员')}}</span>
  17. </div>
  18. </div>
  19. </div>
  20. <w-content>
  21. <div class="team-main">
  22. <div class="team-body">
  23. <!-- 列表 -->
  24. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  25. <!-- 分页 -->
  26. <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></Page>
  27. </div>
  28. </div>
  29. </w-content>
  30. <Modal
  31. v-model="addShow"
  32. :title="$L('添加团队成员')"
  33. :closable="false"
  34. :mask-closable="false">
  35. <Form ref="add" :model="formAdd" :rules="ruleAdd" :label-width="80">
  36. <FormItem prop="userimg" :label="$L('头像')">
  37. <ImgUpload v-model="formAdd.userimg"></ImgUpload>
  38. </FormItem>
  39. <FormItem prop="nickname" :label="$L('昵称')">
  40. <Input type="text" v-model="formAdd.nickname"></Input>
  41. </FormItem>
  42. <FormItem prop="profession" :label="$L('职位/职称')">
  43. <Input v-model="formAdd.profession"></Input>
  44. </FormItem>
  45. <FormItem prop="username" :label="$L('用户名')">
  46. <Input type="text" v-model="formAdd.username" :placeholder="$L('添加后不可修改')"></Input>
  47. </FormItem>
  48. <FormItem prop="userpass" :label="$L('登录密码')">
  49. <Input type="password" v-model="formAdd.userpass" :placeholder="$L('最少6位数')"></Input>
  50. </FormItem>
  51. </Form>
  52. <div slot="footer">
  53. <Button type="default" @click="addShow=false">{{$L('取消')}}</Button>
  54. <Button type="primary" :loading="loadIng > 0" @click="onAdd">{{$L('添加')}}</Button>
  55. </div>
  56. </Modal>
  57. </div>
  58. </template>
  59. <style lang="scss" scoped>
  60. .team {
  61. .team-main {
  62. display: flex;
  63. flex-direction: column;
  64. width: 100%;
  65. height: 100%;
  66. padding: 15px;
  67. .team-body {
  68. display: flex;
  69. flex-direction: column;
  70. width: 100%;
  71. height: 100%;
  72. min-height: 500px;
  73. background: #fefefe;
  74. border-radius: 3px;
  75. .tableFill {
  76. margin: 20px;
  77. background-color: #ffffff;
  78. }
  79. }
  80. }
  81. }
  82. </style>
  83. <script>
  84. import WHeader from "../components/WHeader";
  85. import WContent from "../components/WContent";
  86. import ImgUpload from "../components/ImgUpload";
  87. export default {
  88. components: {ImgUpload, WContent, WHeader},
  89. data () {
  90. return {
  91. loadIng: 0,
  92. userInfo: {},
  93. columns: [],
  94. lists: [],
  95. listPage: 1,
  96. listTotal: 0,
  97. noDataText: "",
  98. addShow: false,
  99. formAdd: {
  100. userimg: '',
  101. profession: '',
  102. username: '',
  103. nickname: '',
  104. userpass: ''
  105. },
  106. ruleAdd: {}
  107. }
  108. },
  109. created() {
  110. let isAdmin = $A.identity('admin');
  111. this.noDataText = this.$L("数据加载中.....");
  112. this.columns = [{
  113. "title": this.$L("头像"),
  114. "minWidth": 60,
  115. "maxWidth": 100,
  116. render: (h, params) => {
  117. return h('img', {
  118. style: {
  119. width: "32px",
  120. height: "32px",
  121. verticalAlign: "middle",
  122. objectFit: "cover",
  123. borderRadius: "50%"
  124. },
  125. attrs: {
  126. src: params.row.userimg
  127. },
  128. });
  129. }
  130. }, {
  131. "title": this.$L("昵称"),
  132. "minWidth": 80,
  133. "ellipsis": true,
  134. render: (h, params) => {
  135. return h('span', params.row.nickname || '-');
  136. }
  137. }, {
  138. "title": this.$L("用户名"),
  139. "key": 'username',
  140. "minWidth": 80,
  141. "ellipsis": true,
  142. }, {
  143. "title": this.$L("职位/职称"),
  144. "minWidth": 100,
  145. "ellipsis": true,
  146. render: (h, params) => {
  147. return h('span', params.row.profession || '-');
  148. }
  149. }, {
  150. "title": this.$L("加入时间"),
  151. "width": 160,
  152. render: (h, params) => {
  153. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.regdate));
  154. }
  155. }, {
  156. "title": this.$L("操作"),
  157. "key": 'action',
  158. "width": isAdmin ? 160 : 80,
  159. "align": 'center',
  160. render: (h, params) => {
  161. let array = [];
  162. array.push(h('Button', {
  163. props: {
  164. type: 'primary',
  165. size: 'small'
  166. },
  167. style: {
  168. fontSize: '12px'
  169. },
  170. on: {
  171. click: () => {
  172. this.$Modal.info({
  173. title: this.$L('会员信息'),
  174. content: `<p>${this.$L('昵称')}: ${params.row.nickname || '-'}</p><p>${this.$L('职位/职称')}: ${params.row.profession || '-'}</p>`
  175. });
  176. }
  177. }
  178. }, this.$L('查看')));
  179. if (isAdmin) {
  180. array.push(h('Button', {
  181. props: {
  182. type: 'warning',
  183. size: 'small'
  184. },
  185. style: {
  186. fontSize: '12px',
  187. marginLeft: '5px'
  188. },
  189. on: {
  190. click: () => {
  191. this.$Modal.confirm({
  192. title: this.$L('删除团队成员'),
  193. content: this.$L('你确定要删除此团队成员吗?'),
  194. loading: true,
  195. onOk: () => {
  196. $A.aAjax({
  197. url: 'users/team/delete?id=' + params.row.id,
  198. error: () => {
  199. this.$Modal.remove();
  200. alert(this.$L('网络繁忙,请稍后再试!'));
  201. },
  202. success: (res) => {
  203. this.$Modal.remove();
  204. this.getLists();
  205. setTimeout(() => {
  206. if (res.ret === 1) {
  207. this.$Message.success(res.msg);
  208. }else{
  209. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  210. }
  211. }, 350);
  212. }
  213. });
  214. }
  215. });
  216. }
  217. }
  218. }, this.$L('删除')));
  219. }
  220. return h('div', array);
  221. }
  222. }];
  223. //
  224. this.ruleAdd = {
  225. username: [
  226. { required: true, message: this.$L('请填写用户名!'), trigger: 'change' },
  227. { type: 'string', min: 2, message: this.$L('用户名长度至少2位!'), trigger: 'change' }
  228. ],
  229. userpass: [
  230. { required: true, message: this.$L('请填写登录密码!'), trigger: 'change' },
  231. { type: 'string', min: 6, message: this.$L('密码长度至少6位!'), trigger: 'change' }
  232. ]
  233. };
  234. },
  235. mounted() {
  236. this.getLists(true);
  237. this.userInfo = $A.getUserInfo((res, isLogin) => {
  238. if (this.userInfo.id != res.id) {
  239. this.userInfo = res;
  240. isLogin && this.getLists(true);
  241. }
  242. }, false);
  243. },
  244. deactivated() {
  245. this.addShow = false;
  246. },
  247. methods: {
  248. setPage(page) {
  249. this.listPage = page;
  250. this.getLists();
  251. },
  252. setPageSize(size) {
  253. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  254. this.listPageSize = size;
  255. this.getLists();
  256. }
  257. },
  258. getLists(resetLoad) {
  259. if (resetLoad === true) {
  260. this.listPage = 1;
  261. }
  262. this.loadIng++;
  263. this.noDataText = this.$L("数据加载中.....");
  264. $A.aAjax({
  265. url: 'users/team/lists',
  266. data: {
  267. page: Math.max(this.listPage, 1),
  268. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  269. },
  270. complete: () => {
  271. this.loadIng--;
  272. },
  273. error: () => {
  274. this.noDataText = this.$L("数据加载失败!");
  275. },
  276. success: (res) => {
  277. if (res.ret === 1) {
  278. this.lists = res.data.lists;
  279. this.listTotal = res.data.total;
  280. this.noDataText = this.$L("没有相关的数据");
  281. }else{
  282. this.lists = [];
  283. this.listTotal = 0;
  284. this.noDataText = res.msg;
  285. }
  286. }
  287. });
  288. },
  289. onAdd() {
  290. this.$refs.add.validate((valid) => {
  291. if (valid) {
  292. this.loadIng++;
  293. $A.aAjax({
  294. url: 'users/team/add',
  295. data: this.formAdd,
  296. complete: () => {
  297. this.loadIng--;
  298. },
  299. success: (res) => {
  300. if (res.ret === 1) {
  301. this.addShow = false;
  302. this.$Message.success(res.msg);
  303. this.$refs.add.resetFields();
  304. //
  305. this.getLists(true);
  306. }else{
  307. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  308. }
  309. }
  310. });
  311. }
  312. });
  313. }
  314. },
  315. }
  316. </script>