team.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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)">刷新</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.columns = [{
  112. "title": "头像",
  113. "minWidth": 60,
  114. "maxWidth": 100,
  115. render: (h, params) => {
  116. return h('img', {
  117. style: {
  118. width: "32px",
  119. height: "32px",
  120. verticalAlign: "middle",
  121. objectFit: "cover",
  122. borderRadius: "50%"
  123. },
  124. attrs: {
  125. src: params.row.userimg
  126. },
  127. });
  128. }
  129. }, {
  130. "title": "昵称",
  131. "minWidth": 80,
  132. "ellipsis": true,
  133. render: (h, params) => {
  134. return h('span', params.row.nickname || '-');
  135. }
  136. }, {
  137. "title": "用户名",
  138. "key": 'username',
  139. "minWidth": 80,
  140. "ellipsis": true,
  141. }, {
  142. "title": "职位/职称",
  143. "minWidth": 100,
  144. "ellipsis": true,
  145. render: (h, params) => {
  146. return h('span', params.row.profession || '-');
  147. }
  148. }, {
  149. "title": "加入时间",
  150. "width": 160,
  151. render: (h, params) => {
  152. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.regdate));
  153. }
  154. }, {
  155. "title": "操作",
  156. "key": 'action',
  157. "width": isAdmin ? 160 : 80,
  158. "align": 'center',
  159. render: (h, params) => {
  160. let array = [];
  161. array.push(h('Button', {
  162. props: {
  163. type: 'primary',
  164. size: 'small'
  165. },
  166. style: {
  167. fontSize: '12px'
  168. },
  169. on: {
  170. click: () => {
  171. this.$Modal.info({
  172. title: '会员信息',
  173. content: `<p>昵称: ${params.row.nickname || '-'}</p><p>职位/职称: ${params.row.profession || '-'}</p>`
  174. });
  175. }
  176. }
  177. }, '查看'));
  178. if (isAdmin) {
  179. array.push(h('Button', {
  180. props: {
  181. type: 'warning',
  182. size: 'small'
  183. },
  184. style: {
  185. fontSize: '12px',
  186. marginLeft: '5px'
  187. },
  188. on: {
  189. click: () => {
  190. this.$Modal.confirm({
  191. title: '删除团队成员',
  192. content: '你确定要删除此团队成员吗?',
  193. loading: true,
  194. onOk: () => {
  195. $A.aAjax({
  196. url: 'users/team/delete?id=' + params.row.id,
  197. error: () => {
  198. this.$Modal.remove();
  199. alert(this.$L('网络繁忙,请稍后再试!'));
  200. },
  201. success: (res) => {
  202. this.$Modal.remove();
  203. this.getLists();
  204. setTimeout(() => {
  205. if (res.ret === 1) {
  206. this.$Message.success(res.msg);
  207. }else{
  208. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  209. }
  210. }, 350);
  211. }
  212. });
  213. }
  214. });
  215. }
  216. }
  217. }, '删除'));
  218. }
  219. return h('div', array);
  220. }
  221. }];
  222. //
  223. this.ruleAdd = {
  224. username: [
  225. { required: true, message: this.$L('请填写用户名!'), trigger: 'change' },
  226. { type: 'string', min: 2, message: this.$L('用户名长度至少2位!'), trigger: 'change' }
  227. ],
  228. userpass: [
  229. { required: true, message: this.$L('请填写登录密码!'), trigger: 'change' },
  230. { type: 'string', min: 6, message: this.$L('密码长度至少6位!'), trigger: 'change' }
  231. ]
  232. };
  233. },
  234. mounted() {
  235. this.getLists(true);
  236. this.userInfo = $A.getUserInfo((res, isLogin) => {
  237. if (this.userInfo.id != res.id) {
  238. this.userInfo = res;
  239. isLogin && this.getLists(true);
  240. }
  241. }, false);
  242. },
  243. deactivated() {
  244. this.addShow = false;
  245. },
  246. methods: {
  247. setPage(page) {
  248. this.listPage = page;
  249. this.getLists();
  250. },
  251. setPageSize(size) {
  252. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  253. this.listPageSize = size;
  254. this.getLists();
  255. }
  256. },
  257. getLists(resetLoad) {
  258. if (resetLoad === true) {
  259. this.listPage = 1;
  260. }
  261. this.loadIng++;
  262. this.noDataText = "数据加载中.....";
  263. $A.aAjax({
  264. url: 'users/team/lists',
  265. data: {
  266. page: Math.max(this.listPage, 1),
  267. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  268. },
  269. complete: () => {
  270. this.loadIng--;
  271. },
  272. error: () => {
  273. this.noDataText = "数据加载失败!";
  274. },
  275. success: (res) => {
  276. if (res.ret === 1) {
  277. this.lists = res.data.lists;
  278. this.listTotal = res.data.total;
  279. this.noDataText = "没有相关的数据";
  280. }else{
  281. this.lists = [];
  282. this.listTotal = 0;
  283. this.noDataText = res.msg;
  284. }
  285. }
  286. });
  287. },
  288. onAdd() {
  289. this.$refs.add.validate((valid) => {
  290. if (valid) {
  291. this.loadIng++;
  292. $A.aAjax({
  293. url: 'users/team/add',
  294. data: this.formAdd,
  295. complete: () => {
  296. this.loadIng--;
  297. },
  298. success: (res) => {
  299. if (res.ret === 1) {
  300. this.addShow = false;
  301. this.$Message.success(res.msg);
  302. this.$refs.add.resetFields();
  303. //
  304. this.getLists(true);
  305. }else{
  306. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  307. }
  308. }
  309. });
  310. }
  311. });
  312. }
  313. },
  314. }
  315. </script>