5bedb5b0b6a0947bae3aae8edd5ae7cc18046d4d.svn-base 11 KB

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