DeptUserInfo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <!-- 搜索区域 -->
  6. <a-form layout="inline">
  7. <a-row :gutter="10">
  8. <a-col :md="7" :sm="4">
  9. <a-form-item label="用户账号" style="margin-left:8px">
  10. <a-input placeholder="请输入账号" v-model="queryParam.username"></a-input>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="4">
  14. <a-form-item label="是否只显示本层级" style="margin-left:8px">
  15. <a-switch default-checked @change="onChange" v-model="queryParam.info" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="7" :sm="4">
  19. <a-form-item label="岗位" style="margin-left:8px">
  20. <a-input placeholder="请输入岗位" v-model="queryParam.position"></a-input>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="7" :sm="4">
  24. <a-form-item label="人员名称" style="margin-left:8px">
  25. <a-input placeholder="请输入岗位" v-model="queryParam.realname"></a-input>
  26. </a-form-item>
  27. </a-col>
  28. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  29. <a-col :md="6" :sm="24">
  30. <a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 18px">查询</a-button>
  31. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  32. </a-col>
  33. </span>
  34. </a-row>
  35. </a-form>
  36. </div>
  37. <!-- 操作按钮区域 -->
  38. <div class="table-operator" :md="24" :sm="24" style="margin-top: -15px">
  39. <!--<a-button @click="handleEdit" type="primary" icon="edit" style="margin-top: 16px">用户编辑</a-button>-->
  40. <a-button @click="handleAddUserDepart" type="primary" icon="plus">添加已有用户</a-button>
  41. <a-button @click="handleAdd" type="primary" icon="plus" style="margin-top: 16px">新建用户</a-button>
  42. <a-dropdown v-if="selectedRowKeys.length > 0">
  43. <a-menu slot="overlay">
  44. <a-menu-item key="1" @click="batchDel">
  45. <a-icon type="delete"/>
  46. 取消关联
  47. </a-menu-item>
  48. </a-menu>
  49. <a-button style="margin-left: 8px"> 批量操作
  50. <a-icon type="down"/>
  51. </a-button>
  52. </a-dropdown>
  53. </div>
  54. <!-- table区域-begin -->
  55. <div>
  56. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  57. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
  58. selectedRowKeys.length }}</a>项
  59. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  60. </div>
  61. <a-table
  62. ref="table"
  63. size="middle"
  64. bordered
  65. rowKey="id"
  66. :columns="columns"
  67. :dataSource="dataSource"
  68. :pagination="ipagination"
  69. :loading="loading"
  70. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  71. @change="handleTableChange">
  72. <span slot="action" slot-scope="text, record">
  73. <a @click="handleEdit(record)">编辑</a>
  74. <a-divider type="vertical"/>
  75. <a-dropdown>
  76. <a class="ant-dropdown-link">
  77. 更多 <a-icon type="down"/>
  78. </a>
  79. <a-menu slot="overlay">
  80. <a-menu-item>
  81. <a href="javascript:;" @click="handleDeptRole(record)">部门角色</a>
  82. </a-menu-item>
  83. <a-menu-item>
  84. <a href="javascript:;" @click="handleDetail(record)">用户详情</a>
  85. </a-menu-item>
  86. <a-menu-item>
  87. <a-popconfirm title="确定取消与选中部门关联吗?" @confirm="() => handleDelete(record.id)">
  88. <a>取消关联</a>
  89. </a-popconfirm>
  90. </a-menu-item>
  91. </a-menu>
  92. </a-dropdown>
  93. </span>
  94. </a-table>
  95. </div>
  96. <!-- table区域-end -->
  97. <!-- 表单区域 -->
  98. <user-modal ref="modalForm" @ok="modalFormOk"></user-modal>
  99. <Select-User-Modal ref="selectUserModal" @selectFinished="selectOK"></Select-User-Modal>
  100. <dept-role-user-modal ref="deptRoleUser"></dept-role-user-modal>
  101. </a-card>
  102. </template>
  103. <script>
  104. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  105. import {getAction, postAction, deleteAction} from '@/api/manage'
  106. import SelectUserModal from './SelectUserModal'
  107. import UserModal from './UserModal'
  108. import DeptRoleUserModal from './DeptRoleUserModal'
  109. export default {
  110. name: "DeptUserInfo",
  111. mixins: [JeecgListMixin],
  112. components: {
  113. DeptRoleUserModal,
  114. SelectUserModal,
  115. UserModal
  116. },
  117. data() {
  118. return {
  119. description: '用户信息',
  120. currentDeptId: '',
  121. currentDept: {},
  122. // 表头
  123. columns: [{
  124. title: '用户账号',
  125. align: "center",
  126. dataIndex: 'username'
  127. },{
  128. title: '岗位',
  129. align: "center",
  130. dataIndex: 'position',
  131. width: 120
  132. },{
  133. title: '角色',
  134. align: "center",
  135. dataIndex: 'roleName',
  136. width: 120
  137. },
  138. {
  139. title: '用户名称',
  140. align: "center",
  141. dataIndex: 'realname'
  142. },
  143. {
  144. title: '部门',
  145. align: "center",
  146. dataIndex: 'orgCode'
  147. },
  148. // {
  149. // title: '性别',
  150. // align: "center",
  151. // dataIndex: 'sex_dictText'
  152. // },
  153. {
  154. title: '电话',
  155. align: "center",
  156. dataIndex: 'phone'
  157. },
  158. {
  159. title: '操作',
  160. dataIndex: 'action',
  161. scopedSlots: {customRender: 'action'},
  162. align: "center",
  163. width: 120
  164. }],
  165. url: {
  166. list: "/sys/user/departUserList",
  167. edit: "/sys/user/editSysDepartWithUser",
  168. delete: "/sys/user/deleteUserInDepart",
  169. deleteBatch: "/sys/user/deleteUserInDepartBatch",
  170. }
  171. }
  172. },
  173. created() {
  174. },
  175. methods: {
  176. onChange(checked) {
  177. console.log(`a-switch to ${checked}`);
  178. },
  179. searchReset() {
  180. this.queryParam = {}
  181. this.loadData(1);
  182. },
  183. loadData(arg) {
  184. if (!this.url.list) {
  185. this.$message.error("请设置url.list属性!")
  186. return
  187. }
  188. //加载数据 若传入参数1则加载第一页的内容
  189. if (arg === 1) {
  190. this.ipagination.current = 1;
  191. }
  192. //if (this.currentDeptId === '') return;
  193. let params = this.getQueryParams();//查询条件
  194. params.depId = this.currentDeptId;
  195. getAction(this.url.list, params).then((res) => {
  196. if (res.success && res.result) {
  197. this.dataSource = res.result.records;
  198. this.ipagination.total = res.result.total;
  199. }
  200. })
  201. },
  202. batchDel: function () {
  203. if (!this.url.deleteBatch) {
  204. this.$message.error("请设置url.deleteBatch属性!")
  205. return
  206. }
  207. if (!this.currentDeptId) {
  208. this.$message.error("未选中任何部门,无法取消部门与用户的关联!")
  209. return
  210. }
  211. if (this.selectedRowKeys.length <= 0) {
  212. this.$message.warning('请选择一条记录!');
  213. return;
  214. } else {
  215. var ids = "";
  216. for (var a = 0; a < this.selectedRowKeys.length; a++) {
  217. ids += this.selectedRowKeys[a] + ",";
  218. }
  219. var that = this;
  220. console.log(this.currentDeptId);
  221. this.$confirm({
  222. title: "确认取消",
  223. content: "是否取消用户与选中部门的关联?",
  224. onOk: function () {
  225. deleteAction(that.url.deleteBatch, {depId: that.currentDeptId, userIds: ids}).then((res) => {
  226. if (res.success) {
  227. that.$message.success("删除用户与选中部门关系成功!");
  228. that.loadData();
  229. that.onClearSelected();
  230. } else {
  231. that.$message.warning(res.message);
  232. }
  233. });
  234. }
  235. });
  236. }
  237. },
  238. handleDelete: function (id) {
  239. if (!this.url.delete) {
  240. this.$message.error("请设置url.delete属性!")
  241. return
  242. }
  243. if (!this.currentDeptId) {
  244. this.$message.error("未选中任何部门,无法取消部门与用户的关联!")
  245. return
  246. }
  247. var that = this;
  248. deleteAction(that.url.delete, {depId: this.currentDeptId, userId: id}).then((res) => {
  249. if (res.success) {
  250. that.$message.success("删除用户与选中部门关系成功!");
  251. if (this.selectedRowKeys.length>0){
  252. for(let i =0; i<this.selectedRowKeys.length;i++){
  253. if (this.selectedRowKeys[i] == id){
  254. this.selectedRowKeys.splice(i,1);
  255. break;
  256. }
  257. }
  258. }
  259. that.loadData();
  260. } else {
  261. that.$message.warning(res.message);
  262. }
  263. });
  264. },
  265. open(record) {
  266. //console.log(record);
  267. this.currentDeptId = record.id;
  268. this.currentDept = record;
  269. this.loadData(1);
  270. },
  271. clearList() {
  272. this.currentDeptId = '';
  273. this.dataSource = [];
  274. },
  275. hasSelectDept() {
  276. if (this.currentDeptId == '') {
  277. this.$message.error("请选择一个部门!")
  278. return false;
  279. }
  280. return true;
  281. },
  282. handleAddUserDepart() {
  283. if (this.currentDeptId == '' ) {
  284. this.$message.error("请选择一个部门!")
  285. } else {
  286. this.$refs.selectUserModal.visible = true;
  287. }
  288. },
  289. handleEdit: function (record) {
  290. this.$refs.modalForm.title = "编辑";
  291. this.$refs.modalForm.departDisabled = true;
  292. this.$refs.modalForm.disableSubmit = false;
  293. this.$refs.modalForm.edit(record);
  294. },
  295. handleAdd: function () {
  296. if (this.currentDeptId == '') {
  297. this.$message.error("请选择一个部门!")
  298. } else {
  299. this.$refs.modalForm.departDisabled = true;
  300. //初始化负责部门
  301. this.$refs.modalForm.nextDepartOptions=[{value:this.currentDept.key,label:this.currentDept.title}]
  302. this.$refs.modalForm.title = "新增";
  303. this.$refs.modalForm.edit({activitiSync:'1',userIdentity:1,selecteddeparts:this.currentDeptId})
  304. }
  305. },
  306. selectOK(data) {
  307. let params = {};
  308. params.depId = this.currentDeptId;
  309. params.userIdList = [];
  310. for (var a = 0; a < data.length; a++) {
  311. params.userIdList.push(data[a]);
  312. }
  313. console.log(params);
  314. postAction(this.url.edit, params).then((res) => {
  315. if (res.success) {
  316. this.$message.success(res.message);
  317. this.loadData();
  318. } else {
  319. this.$message.warning(res.message);
  320. }
  321. })
  322. },
  323. handleDeptRole(record){
  324. if(this.currentDeptId != ''){
  325. this.$refs.deptRoleUser.add(record,this.currentDeptId);
  326. this.$refs.deptRoleUser.title = "部门角色分配";
  327. }else{
  328. this.$message.warning("请先选择一个部门!");
  329. }
  330. }
  331. }
  332. }
  333. </script>
  334. <style scoped>
  335. /** Button按钮间距 */
  336. .ant-btn {
  337. margin-left: 3px
  338. }
  339. .ant-card {
  340. margin-left: -30px;
  341. margin-right: -30px;
  342. }
  343. .table-page-search-wrapper {
  344. margin-top: -16px;
  345. margin-bottom: 16px;
  346. }
  347. </style>