YuangongList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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="handleRelation(record.id)">关联房间</a>
  119. </a-menu-item>
  120. <a-menu-item>
  121. <a href="javascript:;" @click="handleDetail(record)">详情</a>
  122. </a-menu-item>
  123. <a-menu-item>
  124. <a href="javascript:;" @click="handleChangePassword(record.username)">密码</a>
  125. </a-menu-item>
  126. <a-menu-item>
  127. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  128. <a>删除</a>
  129. </a-popconfirm>
  130. </a-menu-item>
  131. <a-menu-item v-if="record.status==1">
  132. <a-popconfirm title="确定冻结吗?" @confirm="() => handleFrozen(record.id,2,record.username)">
  133. <a>冻结</a>
  134. </a-popconfirm>
  135. </a-menu-item>
  136. <a-menu-item v-if="record.status==2">
  137. <a-popconfirm title="确定解冻吗?" @confirm="() => handleFrozen(record.id,1,record.username)">
  138. <a>解冻</a>
  139. </a-popconfirm>
  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. <user-room-relation @ok="saveRelationOk" ref="userroomrelationmodal"></user-room-relation>
  150. <sys-user-agent-modal ref="sysUserAgentModal"></sys-user-agent-modal>
  151. <!-- 用户回收站 -->
  152. <user-recycle-bin-modal :visible.sync="recycleBinVisible" @ok="modalFormOk"/>
  153. </a-card>
  154. </template>
  155. <script>
  156. import UserModal from './modules/UserModal'
  157. import UserRoomRelation from './modules/UserRoomRelationModal.vue'
  158. import PasswordModal from './modules/PasswordModal'
  159. import {putAction,getFileAccessHttpUrl} from '@/api/manage';
  160. import {frozenBatch} from '@/api/api'
  161. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  162. import SysUserAgentModal from "./modules/SysUserAgentModal";
  163. import JInput from '@/components/jeecg/JInput'
  164. import UserRecycleBinModal from './modules/UserRecycleBinModal'
  165. import JSuperQuery from '@/components/jeecg/JSuperQuery'
  166. import JThirdAppButton from '@/components/jeecgbiz/thirdApp/JThirdAppButton'
  167. export default {
  168. name: "UserList",
  169. mixins: [JeecgListMixin],
  170. components: {
  171. JThirdAppButton,
  172. SysUserAgentModal,
  173. UserModal,
  174. PasswordModal,
  175. JInput,
  176. UserRecycleBinModal,
  177. UserRoomRelation,
  178. JSuperQuery
  179. },
  180. data() {
  181. return {
  182. description: '这是用户管理页面',
  183. queryParam: {},
  184. recycleBinVisible: false,
  185. columns: [
  186. /*{
  187. title: '#',
  188. dataIndex: '',
  189. key:'rowIndex',
  190. width:60,
  191. align:"center",
  192. customRender:function (t,r,index) {
  193. return parseInt(index)+1;
  194. }
  195. },*/
  196. {
  197. title: '用户账号',
  198. align: "center",
  199. dataIndex: 'username',
  200. width: 120,
  201. sorter: true
  202. },
  203. {
  204. title: '用户姓名',
  205. align: "center",
  206. width: 100,
  207. dataIndex: 'realname',
  208. },
  209. {
  210. title: '头像',
  211. align: "center",
  212. width: 120,
  213. dataIndex: 'avatar',
  214. scopedSlots: {customRender: "avatarslot"}
  215. },
  216. {
  217. title: '性别',
  218. align: "center",
  219. width: 80,
  220. dataIndex: 'sex_dictText',
  221. sorter: true
  222. },
  223. {
  224. title: '生日',
  225. align: "center",
  226. width: 100,
  227. dataIndex: 'birthday'
  228. },
  229. {
  230. title: '手机号码',
  231. align: "center",
  232. width: 100,
  233. dataIndex: 'phone'
  234. },
  235. {
  236. title: '部门',
  237. align: "center",
  238. width: 180,
  239. dataIndex: 'orgCodeTxt'
  240. },
  241. {
  242. title: '负责部门',
  243. align: "center",
  244. width: 180,
  245. dataIndex: 'departIds_dictText'
  246. },
  247. {
  248. title: '状态',
  249. align: "center",
  250. width: 80,
  251. dataIndex: 'status_dictText'
  252. },
  253. {
  254. title: '操作',
  255. dataIndex: 'action',
  256. scopedSlots: {customRender: 'action'},
  257. align: "center",
  258. width: 170
  259. }
  260. ],
  261. superQueryFieldList: [
  262. { type: 'input', value: 'username', text: '用户账号', },
  263. { type: 'input', value: 'realname', text: '用户姓名', },
  264. { type: 'select', value: 'sex', dbType: 'int', text: '性别', dictCode: 'sex' },
  265. ],
  266. url: {
  267. syncUser: "/act/process/extActProcess/doSyncUser",
  268. list: "/sys/user/list",
  269. delete: "/sys/user/delete",
  270. deleteBatch: "/sys/user/deleteBatch",
  271. exportXlsUrl: "/sys/user/exportXls",
  272. importExcelUrl: "sys/user/importExcel",
  273. },
  274. }
  275. },
  276. computed: {
  277. importExcelUrl: function(){
  278. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  279. }
  280. },
  281. methods: {
  282. saveRelationOk() {
  283. },
  284. getAvatarView: function (avatar) {
  285. return getFileAccessHttpUrl(avatar)
  286. },
  287. batchFrozen: function (status) {
  288. if (this.selectedRowKeys.length <= 0) {
  289. this.$message.warning('请选择一条记录!');
  290. return false;
  291. } else {
  292. let ids = "";
  293. let that = this;
  294. let isAdmin = false;
  295. that.selectionRows.forEach(function (row) {
  296. if (row.username == 'admin') {
  297. isAdmin = true;
  298. }
  299. });
  300. if (isAdmin) {
  301. that.$message.warning('管理员账号不允许此操作,请重新选择!');
  302. return;
  303. }
  304. that.selectedRowKeys.forEach(function (val) {
  305. ids += val + ",";
  306. });
  307. that.$confirm({
  308. title: "确认操作",
  309. content: "是否" + (status == 1 ? "解冻" : "冻结") + "选中账号?",
  310. onOk: function () {
  311. frozenBatch({ids: ids, status: status}).then((res) => {
  312. if (res.success) {
  313. that.$message.success(res.message);
  314. that.loadData();
  315. that.onClearSelected();
  316. } else {
  317. that.$message.warning(res.message);
  318. }
  319. });
  320. }
  321. });
  322. }
  323. },
  324. handleMenuClick(e) {
  325. if (e.key == 1) {
  326. this.batchDel();
  327. } else if (e.key == 2) {
  328. this.batchFrozen(2);
  329. } else if (e.key == 3) {
  330. this.batchFrozen(1);
  331. }
  332. },
  333. handleFrozen: function (id, status, username) {
  334. let that = this;
  335. //TODO 后台校验管理员角色
  336. if ('admin' == username) {
  337. that.$message.warning('管理员账号不允许此操作!');
  338. return;
  339. }
  340. frozenBatch({ids: id, status: status}).then((res) => {
  341. if (res.success) {
  342. that.$message.success(res.message);
  343. that.loadData();
  344. } else {
  345. that.$message.warning(res.message);
  346. }
  347. });
  348. },
  349. handleChangePassword(username) {
  350. this.$refs.passwordmodal.show(username);
  351. },
  352. handleRelation(userId) {
  353. this.$refs.userroomrelationmodal.show(userId)
  354. },
  355. passwordModalOk() {
  356. //TODO 密码修改完成 不需要刷新页面,可以把datasource中的数据更新一下
  357. },
  358. onSyncFinally({isToLocal}) {
  359. // 同步到本地时刷新下数据
  360. if (isToLocal) {
  361. this.loadData()
  362. }
  363. },
  364. }
  365. }
  366. </script>
  367. <style scoped>
  368. @import '~@assets/less/common.less'
  369. </style>