user-manage-operation.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <a-card class="user-manage-operation" :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="24">
  6. <a-col :md="6" :sm="12">
  7. <a-form-item label="账号">
  8. <a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="6" :sm="12">
  12. <a-form-item label="姓名">
  13. <a-input placeholder="请输入姓名查询" v-model="queryParam.realname"></a-input>
  14. </a-form-item>
  15. </a-col>
  16. <a-col :md="6" :sm="12">
  17. <a-form-item label="汇报上级">
  18. <a-input placeholder="请输入姓名查询" v-model="queryParam.leaderName"></a-input>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="12">
  22. <a-form-item label="用户角色">
  23. <a-input placeholder="请输入用户角色" v-model="queryParam.roleName"></a-input>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="12">
  27. <a-form-item label="部门分配">
  28. <a-tree-select
  29. style="width: 100%"
  30. :dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }"
  31. :treeData="treeData"
  32. v-model="queryParam.departId"
  33. placeholder="无"
  34. >
  35. </a-tree-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="8">
  39. <a-form-item label="邮箱">
  40. <a-input placeholder="请输入邮箱查询" v-model="queryParam.email"></a-input>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="8">
  44. <a-form-item label="状态">
  45. <a-select v-model="queryParam.status" placeholder="请选择用户状态查询">
  46. <a-select-option value="1">正常</a-select-option>
  47. <a-select-option value="2">冻结</a-select-option>
  48. </a-select>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="8">
  52. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  53. <a-button type="primary" @click="handleSearchQuery" icon="search">查询</a-button>
  54. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  55. </span>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. </div>
  60. <div>
  61. <a-table
  62. ref="table"
  63. bordered
  64. size="middle"
  65. :columns="columns"
  66. :dataSource="dataSource"
  67. :pagination="false"
  68. :loading="controlLoading"
  69. >
  70. <template slot="avatarslot" slot-scope="text, record">
  71. <div class="anty-img-wrap">
  72. <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>
  73. </div>
  74. </template>
  75. <template slot="leaderName" slot-scope="text, record">
  76. <span>{{ text ? text : '-' }}</span>
  77. </template>
  78. <template slot="sex" slot-scope="text, record">
  79. <span>{{ text ? (text == 1 ? '男' : '女') : '未填写' }}</span>
  80. </template>
  81. <template slot="status" slot-scope="text, record">
  82. <span>{{ text ? (text == 1 ? '正常' : '冻结') : '未填写' }}</span>
  83. </template>
  84. <template slot="departName" slot-scope="text, record">
  85. <span>{{ text ? text : '-' }}</span>
  86. </template>
  87. <span slot="action" slot-scope="text, record">
  88. <a @click="handleEdit(record)">编辑</a>
  89. </span>
  90. </a-table>
  91. <a-pagination
  92. class="pagin-table-class"
  93. :total="totalAll"
  94. :show-total="total => `共 ${totalAll} 条`"
  95. size="small"
  96. show-size-changer
  97. show-quick-jumper
  98. @change="onShowSizeChange"
  99. @showSizeChange="onShowSizeChange"
  100. />
  101. </div>
  102. <user-modal ref="modalForm" @ok="handleModalFormOk"></user-modal>
  103. </a-card>
  104. </template>
  105. <script>
  106. import UserModal from '@/views/system/modules/UserModal';
  107. import {mapGetters} from 'vuex';
  108. import {queryIdTree} from '@/api/api';
  109. import {getAction} from '@/api/manage';
  110. import {urlAcount} from './user-manage-operation-server.js';
  111. export default {
  112. name: 'user-manage-operation',
  113. components: {
  114. UserModal
  115. },
  116. data() {
  117. return {
  118. controlLoading: false,
  119. dataSource: [],
  120. totalAll: 0,
  121. tablePag: {
  122. page: 1,
  123. size: 10
  124. },
  125. description: '这是用户管理页面',
  126. treeData: [],
  127. queryParam: {},
  128. columns: [
  129. {
  130. title: '用户账号',
  131. align: 'center',
  132. dataIndex: 'username',
  133. width: 120
  134. },
  135. {
  136. title: '真实姓名',
  137. align: 'center',
  138. width: 100,
  139. dataIndex: 'realname'
  140. },
  141. {
  142. title: '头像',
  143. align: 'center',
  144. width: 120,
  145. dataIndex: 'avatar',
  146. scopedSlots: { customRender: 'avatarslot' }
  147. },
  148. {
  149. title: '性别',
  150. align: 'center',
  151. width: 80,
  152. dataIndex: 'sex',
  153. scopedSlots: { customRender: 'sex' },
  154. sorter: true
  155. },
  156. {
  157. title: '手机号码',
  158. align: 'center',
  159. width: 100,
  160. dataIndex: 'phone'
  161. },
  162. {
  163. title: '邮箱',
  164. align: 'center',
  165. dataIndex: 'email'
  166. },
  167. {
  168. title: '汇报上级',
  169. align: 'center',
  170. dataIndex: 'leaderName',
  171. scopedSlots: {customRender: 'leaderName'}
  172. },
  173. {
  174. title: '所属部门',
  175. align: 'center',
  176. dataIndex: 'departName',
  177. scopedSlots: {customRender: 'departName'}
  178. },
  179. {
  180. title: '用户角色',
  181. align: 'center',
  182. dataIndex: 'roleName',
  183. scopedSlots: {customRender: 'roleName'}
  184. },
  185. {
  186. title: '状态',
  187. align: 'center',
  188. width: 80,
  189. dataIndex: 'status',
  190. scopedSlots: {customRender: 'status'}
  191. },
  192. {
  193. title: '操作',
  194. dataIndex: 'action',
  195. scopedSlots: {customRender: 'action'},
  196. align: 'center',
  197. width: 170
  198. }
  199. ]
  200. }
  201. },
  202. created() {
  203. this.$nextTick(() => {
  204. this.loadTreeData();
  205. });
  206. },
  207. mounted() {
  208. this.handleGetDataInit();
  209. },
  210. methods: {
  211. ...mapGetters(['userInfo']),
  212. searchReset() {
  213. this.queryParam = {};
  214. this.handleGetDataInit();
  215. },
  216. handleEdit(record, sign) {
  217. this.$refs.modalForm.edit(record, sign);
  218. this.$refs.modalForm.title = "编辑";
  219. this.$refs.modalForm.disableSubmit = false;
  220. },
  221. handleSearchQuery() {
  222. this.tablePag = {
  223. page: 1,
  224. size: 10
  225. };
  226. this.handleGetDataInit();
  227. },
  228. handleModalFormOk() {
  229. this.tablePag = {
  230. page: 1,
  231. size: 10
  232. };
  233. this.handleGetDataInit();
  234. },
  235. handleGetDataInit() {
  236. this.controlLoading = true;
  237. const paramsData = this.queryParam;
  238. paramsData.id = this.userInfo().id;
  239. paramsData.pageNo = this.tablePag.page;
  240. paramsData.pageSize = this.tablePag.size;
  241. getAction(urlAcount + '/bytedance-api/sys/user/listV2', paramsData).then(result => {
  242. if (result.code === 200) {
  243. this.controlLoading = false;
  244. this.dataSource = result.result.list;
  245. this.totalAll = result.result.total;
  246. }
  247. else {
  248. this.$message.error(result.message);
  249. }
  250. }).catch(error => {
  251. console.log(error, 'eeee');
  252. });
  253. },
  254. onShowSizeChange(current, pageSize) {
  255. console.log(current, pageSize, 'current, pageSize');
  256. this.tablePag = {
  257. page: current,
  258. size: pageSize
  259. };
  260. this.handleGetDataInit();
  261. },
  262. loadTreeData() {
  263. queryIdTree().then(res => {
  264. if (res.success) {
  265. this.treeData = [];
  266. for (let i = 0; i < res.result.length; i++) {
  267. let temp = res.result[i];
  268. this.treeData.push(temp);
  269. }
  270. }
  271. });
  272. },
  273. getAvatarView(avatar) {
  274. return window._CONFIG['domianURL'] + '/sys/common/view' + '/' + avatar;
  275. }
  276. }
  277. };
  278. </script>
  279. <style lang="less" scoped>
  280. @import '~@assets/less/common.less';
  281. .user-manage-operation {
  282. .pagin-table-class {
  283. display: flex;
  284. justify-content: flex-end;
  285. margin-top: 20px;
  286. }
  287. }
  288. </style>