team.vue 11 KB

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