UserList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="12">
  8. <a-form-item label="账号">
  9. <!--<a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>-->
  10. <j-input placeholder="输入账号模糊查询" v-model="queryParam.username"></j-input>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="8">
  14. <a-form-item label="性别">
  15. <a-select v-model="queryParam.sex" placeholder="请选择性别">
  16. <a-select-option value="">请选择</a-select-option>
  17. <a-select-option value="1">男性</a-select-option>
  18. <a-select-option value="2">女性</a-select-option>
  19. </a-select>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="toggleSearchStatus">
  23. <a-col :md="6" :sm="8">
  24. <a-form-item label="真实名字">
  25. <j-input placeholder="请输入真实名字" v-model="queryParam.realname"></j-input>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="8">
  29. <a-form-item label="手机号码">
  30. <j-input placeholder="请输入手机号码查询" v-model="queryParam.phone"></j-input>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="8">
  34. <a-form-item label="用户状态">
  35. <a-select v-model="queryParam.status" placeholder="请选择">
  36. <a-select-option value="">请选择</a-select-option>
  37. <a-select-option value="1">正常</a-select-option>
  38. <a-select-option value="2">冻结</a-select-option>
  39. </a-select>
  40. </a-form-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="8">
  44. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  45. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  46. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  47. <a @click="handleToggleSearch" style="margin-left: 8px">
  48. {{ toggleSearchStatus ? '收起' : '展开' }}
  49. <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
  50. </a>
  51. </span>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. <!-- 操作按钮区域 -->
  57. <div class="table-operator" style="border-top: 5px">
  58. <a-button @click="showUserSelection" type="primary" icon="plus">添加用户</a-button>
  59. <a-button @click="handleSyncUser" v-has="'user:syncbpm'" type="primary" icon="plus">同步流程</a-button>
  60. <a-button type="primary" icon="download" @click="handleExportXls('用户信息')">导出</a-button>
  61. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  62. <a-button type="primary" icon="import">导入</a-button>
  63. </a-upload>
  64. <a-button type="primary" icon="hdd" @click="recycleBinVisible=true">回收站</a-button>
  65. <a-dropdown v-if="selectedRowKeys.length > 0">
  66. <a-menu slot="overlay" @click="handleMenuClick">
  67. <a-menu-item key="1">
  68. <a-icon type="delete" @click="batchDel"/>
  69. 删除
  70. </a-menu-item>
  71. <a-menu-item key="2">
  72. <a-icon type="lock" @click="batchFrozen('2')"/>
  73. 冻结
  74. </a-menu-item>
  75. <a-menu-item key="3">
  76. <a-icon type="unlock" @click="batchFrozen('1')"/>
  77. 解冻
  78. </a-menu-item>
  79. <a-menu-item key="4">
  80. <a-icon type="edit" @click="showModal()"/>
  81. 变更社保/公积金基数
  82. </a-menu-item>
  83. </a-menu>
  84. <a-button style="margin-left: 8px">
  85. 批量操作
  86. <a-icon type="down"/>
  87. </a-button>
  88. </a-dropdown>
  89. </div>
  90. <div>
  91. <a-modal v-model:visible="userVisible" title="变更社保/公积金基数" @ok="handleOk">
  92. <p>社保基数</p>
  93. <p><a-input-number style="width: 100%;" placeholder="请输入社保基数" v-model="sheBao" :min="1" ></a-input-number></p>
  94. <p>公积金基数</p>
  95. <p><a-input-number style="width: 100%;" placeholder="请输入公积金基数" v-model="gongJiJin" :min="1" ></a-input-number></p>
  96. </a-modal>
  97. </div>
  98. <!-- table区域-begin -->
  99. <div>
  100. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  101. <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
  102. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  103. </div>
  104. <a-table
  105. ref="table"
  106. bordered
  107. size="middle"
  108. rowKey="id"
  109. :columns="columns"
  110. :dataSource="dataSource"
  111. :pagination="ipagination"
  112. :loading="loading"
  113. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  114. @change="handleTableChange">
  115. <template slot="avatarslot" slot-scope="text, record, index">
  116. <div class="anty-img-wrap">
  117. <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>
  118. </div>
  119. </template>
  120. <span slot="action" slot-scope="text, record">
  121. <a @click="handleEdit(record)">编辑</a>
  122. <a-divider type="vertical"/>
  123. <a-dropdown>
  124. <a class="ant-dropdown-link">
  125. 更多 <a-icon type="down"/>
  126. </a>
  127. <a-menu slot="overlay">
  128. <a-menu-item>
  129. <a href="javascript:;" @click="handleDetail(record)">详情</a>
  130. </a-menu-item>
  131. <!-- <a-menu-item>
  132. <a href="javascript:;" @click="handleChangePassword(record.username)">密码</a>
  133. </a-menu-item> -->
  134. <a-menu-item>
  135. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  136. <a>删除</a>
  137. </a-popconfirm>
  138. </a-menu-item>
  139. <a-menu-item v-if="record.status==1">
  140. <a-popconfirm title="确定冻结吗?" @confirm="() => handleFrozen(record.id,2,record.username)">
  141. <a>冻结</a>
  142. </a-popconfirm>
  143. </a-menu-item>
  144. <a-menu-item v-if="record.status==2">
  145. <a-popconfirm title="确定解冻吗?" @confirm="() => handleFrozen(record.id,1,record.username)">
  146. <a>解冻</a>
  147. </a-popconfirm>
  148. </a-menu-item>
  149. <!-- <a-menu-item>
  150. <a href="javascript:;" @click="handleAgentSettings(record.username)">代理人</a>
  151. </a-menu-item> -->
  152. </a-menu>
  153. </a-dropdown>
  154. </span>
  155. </a-table>
  156. </div>
  157. <!-- table区域-end -->
  158. <user-modal ref="modalForm" @ok="modalFormOk"></user-modal>
  159. <password-modal ref="passwordmodal" @ok="passwordModalOk"></password-modal>
  160. <sys-user-agent-modal ref="sysUserAgentModal"></sys-user-agent-modal>
  161. <!-- 用户回收站 -->
  162. <user-recycle-bin-modal :visible.sync="recycleBinVisible" @ok="modalFormOk"/>
  163. <a-modal title="新增用户选择" :width="450" :visible="newUserVisible" :closable="false" :maskClosable="false">
  164. <template slot="footer">
  165. <a-button type="primary" @click="handleAddUser">确认</a-button>
  166. <a-button type="primary" @click="newUserVisible = false">取消</a-button>
  167. </template>
  168. <a-form>
  169. <a-form-item
  170. :labelCol="{ span: 4 }"
  171. :wrapperCol="{ span: 20 }"
  172. style="margin-bottom:10px"
  173. >
  174. <!-- <a-tooltip placement="topLeft">
  175. <template slot="title">
  176. <span>请选择最新添加的用户</span>
  177. </template>
  178. <a-avatar style="backgroundColor:#87d068" icon="gold" />
  179. </a-tooltip> -->
  180. <a-select
  181. @change="selectUser"
  182. placeholder="请选择需要添加的用户"
  183. style="margin-left:10px;width: 80%"
  184. >
  185. <a-icon slot="suffixIcon" type="gold" />
  186. <a-select-option v-for="d in newUserList" :key="d.user_id" :value="d.user_id">
  187. {{ d.user_cn_name }} -- {{ d.dept_cn_name }}
  188. </a-select-option>
  189. </a-select>
  190. </a-form-item>
  191. </a-form>
  192. </a-modal>
  193. </a-card>
  194. </template>
  195. <script>
  196. import UserModal from './modules/NewUserModal'
  197. import PasswordModal from './modules/PasswordModal'
  198. import {putAction,getFileAccessHttpUrl,getAction} from '@/api/manage';
  199. import {frozenBatch} from '@/api/api'
  200. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  201. import SysUserAgentModal from "./modules/SysUserAgentModal";
  202. import JInput from '@/components/jeecg/JInput'
  203. import UserRecycleBinModal from './modules/UserRecycleBinModal'
  204. export default {
  205. name: "UserList",
  206. mixins: [JeecgListMixin],
  207. components: {
  208. SysUserAgentModal,
  209. UserModal,
  210. PasswordModal,
  211. JInput,
  212. UserRecycleBinModal
  213. },
  214. data() {
  215. return {
  216. description: '这是用户管理页面',
  217. queryParam: {},
  218. recycleBinVisible: false,
  219. userVisible: false,
  220. newUserVisible: false,
  221. newUserList: [],
  222. userSelected:{},
  223. sheBao: '',
  224. gongJiJin: '',
  225. ipagination:{
  226. pageSizeOptions: ["10", "20", "30", "300"]
  227. },
  228. columns: [
  229. /*{
  230. title: '#',
  231. dataIndex: '',
  232. key:'rowIndex',
  233. width:60,
  234. align:"center",
  235. customRender:function (t,r,index) {
  236. return parseInt(index)+1;
  237. }
  238. },*/
  239. {
  240. title: '用户账号',
  241. align: "center",
  242. dataIndex: 'username',
  243. width: 120
  244. },
  245. {
  246. title: '用户姓名',
  247. align: "center",
  248. width: 100,
  249. dataIndex: 'realname',
  250. },
  251. {
  252. title: '头像',
  253. align: "center",
  254. width: 120,
  255. dataIndex: 'avatar',
  256. scopedSlots: {customRender: "avatarslot"}
  257. },
  258. {
  259. title: '性别',
  260. align: "center",
  261. width: 80,
  262. dataIndex: 'sex_dictText',
  263. sorter: true
  264. },
  265. {
  266. title: '生日',
  267. align: "center",
  268. width: 100,
  269. dataIndex: 'birthday'
  270. },
  271. {
  272. title: '手机号码',
  273. align: "center",
  274. width: 100,
  275. dataIndex: 'phone'
  276. },
  277. // {
  278. // title: '公司',
  279. // align: "center",
  280. // width: 180,
  281. // dataIndex: 'pkOrgName'
  282. // },
  283. {
  284. title: '部门',
  285. align: "center",
  286. width: 180,
  287. dataIndex: 'orgCode'
  288. },
  289. {
  290. title: '状态',
  291. align: "center",
  292. width: 80,
  293. dataIndex: 'status_dictText'
  294. },
  295. {
  296. title: '操作',
  297. dataIndex: 'action',
  298. scopedSlots: {customRender: 'action'},
  299. align: "center",
  300. width: 170
  301. }
  302. ],
  303. url: {
  304. imgerver: window._CONFIG['staticDomainURL'],
  305. syncUser: "/process/extActProcess/doSyncUser",
  306. list: "/sys/user/list",
  307. delete: "/sys/user/delete",
  308. deleteBatch: "/sys/user/deleteBatch",
  309. updateUserBatch: "/sys/user/updateUserBatch",
  310. exportXlsUrl: "/sys/user/exportXls",
  311. importExcelUrl: "sys/user/importExcel",
  312. },
  313. }
  314. },
  315. computed: {
  316. importExcelUrl: function(){
  317. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  318. }
  319. },
  320. methods: {
  321. getAvatarView: function (avatar) {
  322. return getFileAccessHttpUrl(avatar,this.url.imgerver,"http")
  323. },
  324. showModal: function () {
  325. this.gongJiJin = '';
  326. this.sheBao = '';
  327. this.userVisible = true;
  328. },
  329. handleOk() {
  330. let ids = "";
  331. let that = this;
  332. if(this.gongJiJin == '' && this.sheBao == ''){
  333. this.$message.warning('请填写要修改的数据!');
  334. return false;
  335. }else{
  336. if (this.selectedRowKeys.length <= 0) {
  337. this.$message.warning('请选择一条记录!');
  338. return false;
  339. }else{
  340. that.selectedRowKeys.forEach(function (val) {
  341. ids += val + ",";
  342. });
  343. putAction(this.url.updateUserBatch, {ids:ids,gongJiJin:this.gongJiJin,sheBao:this.sheBao}).then((res) => {
  344. if (res.success) {
  345. that.$message.success("操作成功");
  346. that.loadData();
  347. } else {
  348. that.$message.warning(res.message);
  349. that.loadData();
  350. }
  351. }).finally(() => {
  352. that.gongJiJin = '';
  353. that.sheBao = '';
  354. that.selectedRowKeys = [];
  355. })
  356. }
  357. }
  358. console.log(this.gongJiJin);
  359. console.log(this.sheBao);
  360. this.userVisible = false;
  361. },
  362. batchFrozen: function (status) {
  363. if (this.selectedRowKeys.length <= 0) {
  364. this.$message.warning('请选择一条记录!');
  365. return false;
  366. } else {
  367. let ids = "";
  368. let that = this;
  369. let isAdmin = false;
  370. that.selectionRows.forEach(function (row) {
  371. if (row.username == 'admin') {
  372. isAdmin = true;
  373. }
  374. });
  375. if (isAdmin) {
  376. that.$message.warning('管理员账号不允许此操作,请重新选择!');
  377. return;
  378. }
  379. that.selectedRowKeys.forEach(function (val) {
  380. ids += val + ",";
  381. });
  382. that.$confirm({
  383. title: "确认操作",
  384. content: "是否" + (status == 1 ? "解冻" : "冻结") + "选中账号?",
  385. onOk: function () {
  386. frozenBatch({ids: ids, status: status}).then((res) => {
  387. if (res.success) {
  388. that.$message.success(res.message);
  389. that.loadData();
  390. that.onClearSelected();
  391. } else {
  392. that.$message.warning(res.message);
  393. }
  394. });
  395. }
  396. });
  397. }
  398. },
  399. handleMenuClick(e) {
  400. if (e.key == 1) {
  401. this.batchDel();
  402. } else if (e.key == 2) {
  403. this.batchFrozen(2);
  404. } else if (e.key == 3) {
  405. this.batchFrozen(1);
  406. }else if (e.key == 4) {
  407. this.showModal();
  408. }
  409. },
  410. handleFrozen: function (id, status, username) {
  411. let that = this;
  412. //TODO 后台校验管理员角色
  413. if ('admin' == username) {
  414. that.$message.warning('管理员账号不允许此操作!');
  415. return;
  416. }
  417. frozenBatch({ids: id, status: status}).then((res) => {
  418. if (res.success) {
  419. that.$message.success(res.message);
  420. that.loadData();
  421. } else {
  422. that.$message.warning(res.message);
  423. }
  424. });
  425. },
  426. handleChangePassword(username) {
  427. this.$refs.passwordmodal.show(username);
  428. },
  429. handleAgentSettings(username){
  430. this.$refs.sysUserAgentModal.agentSettings(username);
  431. this.$refs.sysUserAgentModal.title = "用户代理人设置";
  432. },
  433. handleSyncUser() {
  434. },
  435. passwordModalOk() {
  436. //TODO 密码修改完成 不需要刷新页面,可以把datasource中的数据更新一下
  437. },
  438. showUserSelection(){
  439. getAction(`/sys/user/recently/added`)
  440. .then(res => {
  441. if (res.success) {
  442. this.newUserList = res.result
  443. // this.newUserList = [
  444. // {
  445. // "user_id": "zhangds5",
  446. // "user_cn_name": "张大山",
  447. // "active_state": "1",
  448. // "update_time": "2022-12-22 10:35:55",
  449. // "dept_code": "c01",
  450. // "dept_cn_name": "办公室",
  451. // "contact": "",
  452. // "email": "",
  453. // "registry_date": "2022-12-19 10:35:55"
  454. // }
  455. // ]
  456. this.newUserVisible = true;
  457. } else {
  458. this.$message.error(res.message)
  459. this.newUserVisible = false;
  460. }
  461. })
  462. .catch(() => {
  463. this.newUserVisible = false;
  464. })
  465. },
  466. selectUser (value) {
  467. this.newUserList.forEach(u=>{
  468. if(u.user_id == value)
  469. this.userSelected = u;
  470. })
  471. },
  472. handleAddUser(){
  473. console.log(this.userSelected);
  474. let u = this.userSelected;
  475. let user = {
  476. username : u.user_id,
  477. realname: u.user_cn_name,
  478. }
  479. this.handleEdit(user);
  480. }
  481. }
  482. }
  483. </script>
  484. <style scoped>
  485. @import '~@assets/less/common.less'
  486. </style>