5d0ccc4b49b42e5616b2b5acbd5ff079cec2703d.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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. <a-input placeholder="请输入真实名字" v-model="queryParam.realname"></a-input>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="8">
  29. <a-form-item label="手机号码">
  30. <a-input placeholder="请输入手机号码查询" v-model="queryParam.phone"></a-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="handleAdd" type="primary" icon="plus" >添加用户</a-button>
  59. <a-button type="primary" icon="download" @click="handleExportXls('用户信息')">导出</a-button>
  60. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  61. <a-button type="primary" icon="import">导入</a-button>
  62. </a-upload>
  63. <j-third-app-button biz-type="user" :selected-row-keys="selectedRowKeys" syncToApp syncToLocal @sync-finally="onSyncFinally"/>
  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>
  80. <a-button style="margin-left: 8px">
  81. 批量操作
  82. <a-icon type="down"/>
  83. </a-button>
  84. </a-dropdown>
  85. <j-super-query :fieldList="superQueryFieldList" @handleSuperQuery="handleSuperQuery"/>
  86. </div>
  87. <!-- table区域-begin -->
  88. <div>
  89. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  90. <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
  91. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  92. </div>
  93. <a-table
  94. ref="table"
  95. bordered
  96. size="middle"
  97. rowKey="id"
  98. :columns="columns"
  99. :dataSource="dataSource"
  100. :pagination="ipagination"
  101. :loading="loading"
  102. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  103. @change="handleTableChange">
  104. <template slot="avatarslot" slot-scope="text, record, index">
  105. <div class="anty-img-wrap">
  106. <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>
  107. </div>
  108. </template>
  109. <span slot="action" slot-scope="text, record">
  110. <a @click="handleEdit(record)" >编辑</a>
  111. <a-divider type="vertical" />
  112. <a-dropdown>
  113. <a class="ant-dropdown-link">
  114. 更多 <a-icon type="down"/>
  115. </a>
  116. <a-menu slot="overlay">
  117. <a-menu-item>
  118. <a href="javascript:;" @click="handleDetail(record)">详情</a>
  119. </a-menu-item>
  120. <a-menu-item>
  121. <a href="javascript:;" @click="handleChangePassword(record.username)">密码</a>
  122. </a-menu-item>
  123. <a-menu-item>
  124. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  125. <a>删除</a>
  126. </a-popconfirm>
  127. </a-menu-item>
  128. <a-menu-item v-if="record.status==1">
  129. <a-popconfirm title="确定冻结吗?" @confirm="() => handleFrozen(record.id,2,record.username)">
  130. <a>冻结</a>
  131. </a-popconfirm>
  132. </a-menu-item>
  133. <a-menu-item v-if="record.status==2">
  134. <a-popconfirm title="确定解冻吗?" @confirm="() => handleFrozen(record.id,1,record.username)">
  135. <a>解冻</a>
  136. </a-popconfirm>
  137. </a-menu-item>
  138. <a-menu-item>
  139. <a href="javascript:;" @click="handleAgentSettings(record.username)">代理人</a>
  140. </a-menu-item>
  141. </a-menu>
  142. </a-dropdown>
  143. </span>
  144. </a-table>
  145. </div>
  146. <!-- table区域-end -->
  147. <user-modal ref="modalForm" @ok="modalFormOk"></user-modal>
  148. <password-modal ref="passwordmodal" @ok="passwordModalOk"></password-modal>
  149. <sys-user-agent-modal ref="sysUserAgentModal"></sys-user-agent-modal>
  150. <!-- 用户回收站 -->
  151. <user-recycle-bin-modal :visible.sync="recycleBinVisible" @ok="modalFormOk"/>
  152. </a-card>
  153. </template>
  154. <script>
  155. import UserModal from './modules/UserModal'
  156. import PasswordModal from './modules/PasswordModal'
  157. import {putAction,getFileAccessHttpUrl} from '@/api/manage';
  158. import {frozenBatch} from '@/api/api'
  159. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  160. import SysUserAgentModal from "./modules/SysUserAgentModal";
  161. import JInput from '@/components/jeecg/JInput'
  162. import UserRecycleBinModal from './modules/UserRecycleBinModal'
  163. import JSuperQuery from '@/components/jeecg/JSuperQuery'
  164. import JThirdAppButton from '@/components/jeecgbiz/thirdApp/JThirdAppButton'
  165. export default {
  166. name: "UserList",
  167. mixins: [JeecgListMixin],
  168. components: {
  169. JThirdAppButton,
  170. SysUserAgentModal,
  171. UserModal,
  172. PasswordModal,
  173. JInput,
  174. UserRecycleBinModal,
  175. JSuperQuery
  176. },
  177. data() {
  178. return {
  179. description: '这是用户管理页面',
  180. queryParam: {},
  181. recycleBinVisible: false,
  182. columns: [
  183. /*{
  184. title: '#',
  185. dataIndex: '',
  186. key:'rowIndex',
  187. width:60,
  188. align:"center",
  189. customRender:function (t,r,index) {
  190. return parseInt(index)+1;
  191. }
  192. },*/
  193. {
  194. title: '用户账号',
  195. align: "center",
  196. dataIndex: 'username',
  197. width: 120,
  198. sorter: true
  199. },
  200. {
  201. title: '用户姓名',
  202. align: "center",
  203. width: 100,
  204. dataIndex: 'realname',
  205. },
  206. {
  207. title: '头像',
  208. align: "center",
  209. width: 120,
  210. dataIndex: 'avatar',
  211. scopedSlots: {customRender: "avatarslot"}
  212. },
  213. {
  214. title: '性别',
  215. align: "center",
  216. width: 80,
  217. dataIndex: 'sex_dictText',
  218. sorter: true
  219. },
  220. {
  221. title: '生日',
  222. align: "center",
  223. width: 100,
  224. dataIndex: 'birthday'
  225. },
  226. {
  227. title: '手机号码',
  228. align: "center",
  229. width: 100,
  230. dataIndex: 'phone'
  231. },
  232. {
  233. title: '部门',
  234. align: "center",
  235. width: 180,
  236. dataIndex: 'orgCodeTxt'
  237. },
  238. {
  239. title: '负责部门',
  240. align: "center",
  241. width: 180,
  242. dataIndex: 'departIds_dictText'
  243. },
  244. {
  245. title: '状态',
  246. align: "center",
  247. width: 80,
  248. dataIndex: 'status_dictText'
  249. },
  250. {
  251. title: '操作',
  252. dataIndex: 'action',
  253. scopedSlots: {customRender: 'action'},
  254. align: "center",
  255. width: 170
  256. }
  257. ],
  258. superQueryFieldList: [
  259. { type: 'input', value: 'username', text: '用户账号', },
  260. { type: 'input', value: 'realname', text: '用户姓名', },
  261. { type: 'select', value: 'sex', dbType: 'int', text: '性别', dictCode: 'sex' },
  262. ],
  263. url: {
  264. syncUser: "/act/process/extActProcess/doSyncUser",
  265. list: "/sys/user/list",
  266. delete: "/sys/user/delete",
  267. deleteBatch: "/sys/user/deleteBatch",
  268. exportXlsUrl: "/sys/user/exportXls",
  269. importExcelUrl: "sys/user/importExcel",
  270. },
  271. }
  272. },
  273. computed: {
  274. importExcelUrl: function(){
  275. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  276. }
  277. },
  278. methods: {
  279. getAvatarView: function (avatar) {
  280. return getFileAccessHttpUrl(avatar)
  281. },
  282. batchFrozen: function (status) {
  283. if (this.selectedRowKeys.length <= 0) {
  284. this.$message.warning('请选择一条记录!');
  285. return false;
  286. } else {
  287. let ids = "";
  288. let that = this;
  289. let isAdmin = false;
  290. that.selectionRows.forEach(function (row) {
  291. if (row.username == 'admin') {
  292. isAdmin = true;
  293. }
  294. });
  295. if (isAdmin) {
  296. that.$message.warning('管理员账号不允许此操作,请重新选择!');
  297. return;
  298. }
  299. that.selectedRowKeys.forEach(function (val) {
  300. ids += val + ",";
  301. });
  302. that.$confirm({
  303. title: "确认操作",
  304. content: "是否" + (status == 1 ? "解冻" : "冻结") + "选中账号?",
  305. onOk: function () {
  306. frozenBatch({ids: ids, status: status}).then((res) => {
  307. if (res.success) {
  308. that.$message.success(res.message);
  309. that.loadData();
  310. that.onClearSelected();
  311. } else {
  312. that.$message.warning(res.message);
  313. }
  314. });
  315. }
  316. });
  317. }
  318. },
  319. handleMenuClick(e) {
  320. if (e.key == 1) {
  321. this.batchDel();
  322. } else if (e.key == 2) {
  323. this.batchFrozen(2);
  324. } else if (e.key == 3) {
  325. this.batchFrozen(1);
  326. }
  327. },
  328. handleFrozen: function (id, status, username) {
  329. let that = this;
  330. //TODO 后台校验管理员角色
  331. if ('admin' == username) {
  332. that.$message.warning('管理员账号不允许此操作!');
  333. return;
  334. }
  335. frozenBatch({ids: id, status: status}).then((res) => {
  336. if (res.success) {
  337. that.$message.success(res.message);
  338. that.loadData();
  339. } else {
  340. that.$message.warning(res.message);
  341. }
  342. });
  343. },
  344. handleChangePassword(username) {
  345. this.$refs.passwordmodal.show(username);
  346. },
  347. handleAgentSettings(username){
  348. this.$refs.sysUserAgentModal.agentSettings(username);
  349. this.$refs.sysUserAgentModal.title = "用户代理人设置";
  350. },
  351. passwordModalOk() {
  352. //TODO 密码修改完成 不需要刷新页面,可以把datasource中的数据更新一下
  353. },
  354. onSyncFinally({isToLocal}) {
  355. // 同步到本地时刷新下数据
  356. if (isToLocal) {
  357. this.loadData()
  358. }
  359. },
  360. }
  361. }
  362. </script>
  363. <style scoped>
  364. @import '~@assets/less/common.less'
  365. </style>