index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <div class="iegeu">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="岗位编码" prop="postCode">
  5. <el-input v-model="queryParams.postCode" placeholder="请输入岗位编码" clearable size="small" @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item label="岗位名称" prop="postName">
  8. <el-input v-model="queryParams.postName" placeholder="请输入岗位名称" clearable size="small" @keyup.enter.native="handleQuery" />
  9. </el-form-item>
  10. <el-form-item label="状态" prop="status">
  11. <!-- <el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
  12. <el-option
  13. v-for="dict in statusOptions"
  14. :key="dict.dictValue"
  15. :label="dict.dictLabel"
  16. :value="dict.dictValue"
  17. />
  18. </el-select> -->
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <div class="tab_bott">
  26. <div class="tabBot_oje">
  27. <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
  28. <!-- :setCheckedKeys='setCheckedKeys' :getCheckedKeys = "getCheckedKeys" -->
  29. <el-tab-pane label="按部门" name="first">
  30. <div class="head-container">
  31. <el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
  32. </div>
  33. <div class="head-container">
  34. <el-tree
  35. :data="deptOptions"
  36. :props="defaultProps"
  37. :expand-on-click-node="false"
  38. :filter-node-method="filterNode"
  39. ref="tree"
  40. default-expand-all
  41. @node-click="handleNodeClick"
  42. />
  43. </div>
  44. </el-tab-pane>
  45. <!-- v-hasPermi="['sys_dept:M'] == true ? jue = 0 :jue = 1" -->
  46. <el-tab-pane v-if="['sys_dept:M'] == true ? jue = 0 :jue = 1" label="按角色" name="second" style="height: 400px;">
  47. <treeselect v-model="form.parentId" :options="deptOptionstwo" :normalizer="normalizer" :flat="true" :maxHeight="150" @select="djieskle" placeholder="点击选择角色" />
  48. </el-tab-pane>
  49. <el-tab-pane label="按组" name="third" style="height: 400px;">
  50. <treeselect
  51. v-model="form.parentIdty"
  52. :options="deptOptionsthre"
  53. :normalizer="normalizerty"
  54. :flat="true"
  55. @select="djieskletwo"
  56. :maxHeight="350"
  57. placeholder="点击选择组"
  58. />
  59. </el-tab-pane>
  60. </el-tabs>
  61. </div>
  62. <div class="tabBot_two">
  63. <el-card class="box-card box-cardtt" shadow="always">
  64. <div slot="header" class="clearfix" >
  65. <span>人员</span>
  66. <!-- <div> -->
  67. <el-button style=" float: right; padding: 3px 10px;" type="danger" plain @click="eledelte">删除</el-button>
  68. <el-button style=" float: right; padding: 3px 10px;margin-right: 20px;" type="primary" plain @click="quande">全选</el-button>
  69. <!-- </div> -->
  70. </div>
  71. <ul class="infinite-list infinite-listty" v-infinite-scroll="load" style="overflow:auto">
  72. <li
  73. v-for="(item, index) in liseh"
  74. :class="[ quandet==true? 'infinite-list-itemty infinite-list-itemss' : item.id == idneese.id ? 'infinite-list-itemty infinite-list-itemss' : 'infinite-list-itemty']"
  75. :key="index"
  76. @click="reyantt(item)"
  77. >
  78. {{ item.userName }}
  79. <!-- <el-checkbox
  80. style="margin-right: 30px"
  81. :indeterminate="item.isIndeterminate"
  82. v-model="item.isCheck"
  83. @change="checkTitle(item.isCheck, index)"
  84. >全选</el-checkbox
  85. >
  86. <el-checkbox-group
  87. v-model="item.checkedData"
  88. @change="checkItem(item.checkedData, index)"
  89. >
  90. <el-checkbox
  91. v-for="(items, index) in item.children"
  92. :label="items.id"
  93. :key="items.id"
  94. >{{ items.userName }}</el-checkbox
  95. >
  96. </el-checkbox-group> -->
  97. </li>
  98. </ul>
  99. </el-card>
  100. <el-card class="box-card box-cardtt" shadow="always">
  101. <div slot="header" class="clearfix">
  102. <span>已选择</span>
  103. <el-button style="float: right; padding: 3px 0" type="text" @click = 'determine'>确定</el-button>
  104. </div>
  105. <ul class="infinite-list infinite-listty" v-infinite-scroll="load" style="overflow:auto">
  106. <li v-for="item in lisehtwo" @click="lidele(item)" :key="item.id" class="infinite-list-item">
  107. {{ item.userName }}
  108. <img src="../../../assets/images/dele.png" alt="" class="index_navTimeimg" />
  109. </li>
  110. </ul>
  111. </el-card>
  112. </div>
  113. </div>
  114. </div>
  115. </template>
  116. <script>
  117. import Flowshoe from '@/components/flowshoe';
  118. import { getTableQuery, getQueryList, tableSubimt, tableSubimtanit, addbjectSave, delMenutab, tabsubm, getUserProfiletab, bohuie } from '@/api/system/table.js';
  119. import { group, getRole, getPersonnel, getMembers,delRoleses } from '@/api/system/election';
  120. import { listDept } from '@/api/system/dept';
  121. import { getInfo } from '@/api/login';
  122. import { listRole } from '@/api/system/role';
  123. import { treeselect } from '@/api/system/dept';
  124. import Treeselect from '@riophae/vue-treeselect';
  125. import '@riophae/vue-treeselect/dist/vue-treeselect.css';
  126. export default {
  127. name: 'table',
  128. inject: ['reload'],
  129. components: { Flowshoe, Treeselect },
  130. data() {
  131. return {
  132. instanceId: 0,
  133. modalShow: false,
  134. // 部门树选项
  135. deptOptions: undefined,
  136. // 角色
  137. deptOptionstwo: [],
  138. deptOptionsthre: [],
  139. // 部门名称
  140. deptName: undefined,
  141. // 无限滚动
  142. count: 0,
  143. activeName: 'first',
  144. liseh: [
  145. // {
  146. // isCheck: false,
  147. // isIndeterminate: true,
  148. // checkedData: [],
  149. // children: [
  150. // ],
  151. // }
  152. ],
  153. lisehtwo: [],
  154. queryParams: {},
  155. showSearch: true,
  156. data: [],
  157. defaultProps: {
  158. children: 'children',
  159. label: 'label'
  160. },
  161. // 表单参数
  162. form: {},
  163. deptList: [],
  164. rtuer: false,
  165. showtabc: 0,
  166. showche: false,
  167. idneese: {},
  168. quandet:false,
  169. dhiuw:[],
  170. // 组id
  171. elezu:0,
  172. jeihqdcee:[],
  173. jue:false,
  174. buemg:false,
  175. zuge:false,
  176. iuid:0
  177. };
  178. },
  179. created() {
  180. this.iuid = this.$route.query.id - 0;
  181. this.jegeuser()
  182. this.members(this.iuid,1)
  183. },
  184. mounted() {
  185. console.log(this.jue)
  186. this.getTreeselect();
  187. // this.staff(100)
  188. // this.getUser();
  189. // this.tablsie()
  190. },
  191. watch: {
  192. // 根据名称筛选部门树
  193. deptName(val) {
  194. this.$refs.tree.filter(val);
  195. }
  196. },
  197. methods: {
  198. getList() {},
  199. load() {
  200. this.count += 2;
  201. },
  202. // 树形结构
  203. // 节点单击事件
  204. handleNodeClick(data) {
  205. console.log(data);
  206. this.queryParams.deptId = data.id;
  207. this.staff(data.id);
  208. this.quandet = false
  209. // this.getList();
  210. },
  211. /** 查询部门下拉树结构 */
  212. getTreeselect() {
  213. treeselect().then(response => {
  214. this.deptOptions = response.data;
  215. });
  216. },
  217. // 查询角色
  218. getTreeselectjue() {
  219. this.loading = true;
  220. listRole(this.queryParams).then(response => {
  221. this.deptOptionstwo = this.handleTree(response.rows, 'id');
  222. this.loading = false;
  223. });
  224. },
  225. // 查询组
  226. getTreeselecu() {
  227. this.loading = true;
  228. group(this.queryParams).then(response => {
  229. this.deptOptionsthre = this.handleTree(response.data, 'id');
  230. this.loading = false;
  231. });
  232. },
  233. /** 转换角色数据结构 */
  234. normalizer(node) {
  235. // if (node.children && !node.children.length) {
  236. // delete node.children;
  237. // }
  238. return {
  239. id: node.id,
  240. label: node.roleName
  241. };
  242. },
  243. /** 转换组数据结构 */
  244. normalizerty(node) {
  245. return {
  246. id: node.id,
  247. label: node.groupName
  248. };
  249. },
  250. // getCheckedKeys(leafOnly) {
  251. // console.log(leafOnly)
  252. // console.log(this.$refs.tree.getCheckedKeys());
  253. // },
  254. setCheckedKeys(keys, leafOnly) {
  255. console.log(keys, leafOnly);
  256. this.$refs.tree.setCheckedKeys([3]);
  257. },
  258. resetChecked() {
  259. this.$refs.tree.setCheckedKeys([]);
  260. },
  261. handleClick(index) {
  262. console.log(index.index);
  263. this.showtabc = index.index;
  264. this.showche = false;
  265. if (index.index == 0) {
  266. this.getTreeselect();
  267. } else if (index.index == 1) {
  268. this.getTreeselectjue();
  269. } else if (index.index == 2) {
  270. this.getTreeselecu();
  271. }
  272. },
  273. // 搜索
  274. handleQuery() {},
  275. // 重置
  276. resetQuery() {},
  277. // 点击组/角色
  278. djieskle(node, instanceId) {
  279. this.personnel(node.id);
  280. console.log(node, instanceId);
  281. },
  282. djieskletwo(node, instanceId) {
  283. this.members(node.id,2);
  284. this.elezu = node.id
  285. console.log(node, instanceId);
  286. },
  287. check(data, value) {
  288. console.log(this.$refs.tree.getCheckedKeys());
  289. // 获取选中的子节点
  290. // let checkedKeys = this.$refs.tree.getCheckedKeys();
  291. // 获取选中的父节点
  292. let hafCheckedKeys = this.$refs.tree.getHalfCheckedKeys();
  293. console.log(this.$refs.tree.getHalfCheckedKeys());
  294. console.log(data, value);
  295. },
  296. // 点击全选
  297. quande(){
  298. var dueg = []
  299. dueg = (this.dhiuw)
  300. this.quandet = true
  301. var that = this
  302. // dueg.push(index)
  303. // this.lisehtwo = dueg
  304. // this.lisehtwo.push(index);
  305. // this.lisehtwo = [...new Set(this.lisehtwo)];
  306. // that.positions.map(train => {
  307. // that.new_Positions.push(train.trainId);
  308. // });
  309. // that.resultArr = []; //去重后的数组
  310. var flag;
  311. for (var i in dueg) {
  312. flag = true;
  313. for (var j in that.lisehtwo) {
  314. if (that.lisehtwo[j].id == dueg[i].id) {
  315. flag = false;
  316. break;
  317. }
  318. }
  319. if (flag) {
  320. that.lisehtwo.push(dueg[i]);
  321. }
  322. }
  323. that.jeihqdcee = that.lisehtwo
  324. },
  325. // 点击全部删除
  326. eledelte(){
  327. this.lisehtwo = []
  328. this.jeihqdcee = this.lisehtwo
  329. },
  330. // 点击删除
  331. lidele(index) {
  332. for (let i = this.lisehtwo.length - 1; i >= 0; i--) {
  333. if (this.lisehtwo[i].id == index.id) {
  334. this.lisehtwo.splice(i, 1)
  335. }
  336. }
  337. this.jeihqdcee = this.lisehtwo
  338. },
  339. // 点击添加
  340. reyantt(index) {
  341. var dueg = [];
  342. this.idneese = index;
  343. var that = this
  344. dueg.push(index)
  345. // this.lisehtwo = dueg
  346. // this.lisehtwo.push(index);
  347. // this.lisehtwo = [...new Set(this.lisehtwo)];
  348. // that.positions.map(train => {
  349. // that.new_Positions.push(train.trainId);
  350. // });
  351. // that.resultArr = []; //去重后的数组
  352. var flag;
  353. for (var i in dueg) {
  354. flag = true;
  355. for (var j in that.lisehtwo) {
  356. if (that.lisehtwo[j].id == dueg[i].id) {
  357. flag = false;
  358. break;
  359. }
  360. }
  361. if (flag) {
  362. that.lisehtwo.push(dueg[i]);
  363. }
  364. }
  365. this.jeihqdcee = this.lisehtwo
  366. // for(var i = 0 ; i <this.lisehtwo.length; i++ ){
  367. // if(this.lisehtwo[i].id == index.id){
  368. // this.lisehtwo.splice(i,1)
  369. // }
  370. // }
  371. // })
  372. },
  373. // 点击确定
  374. determine(){
  375. var eledete = []
  376. this.lisehtwo.filter(route=>{
  377. eledete.push(route.id)
  378. })
  379. eledete = eledete.join(',')
  380. console.log(eledete)
  381. // this.elezu
  382. this.loading = true;
  383. delRoleses(this.iuid,eledete).then(response => {
  384. // this.lisehtwo = response.data;
  385. // this.dhiuw = response.data
  386. if(response.code == 200){
  387. this.msgSuccess('操作成功');
  388. this.$router.go(-1)
  389. }
  390. this.loading = false;
  391. });
  392. },
  393. checkItem(val, index) {
  394. console.log(val);
  395. this.showche = !this.showche;
  396. console.log(this.showche);
  397. var that = this;
  398. let jueg = [];
  399. let checkedCount = val.length;
  400. this.liseh[index].isCheck = checkedCount === this.liseh[index].children.length;
  401. this.liseh[index].isIndeterminate = checkedCount > 0 && checkedCount < this.liseh[index].children.length;
  402. this.liseh[index].children.filter(router => {
  403. // console.log(123)
  404. for (var i = 0; i < val.length; i++) {
  405. if (this.showche == true) {
  406. //选中
  407. console.log('选中');
  408. if (router.id == val[i]) {
  409. jueg.push(router);
  410. this.lisehtwo.push(router);
  411. // console.log(router)
  412. console.log(this.lisehtwo);
  413. for (var j = 0; j < that.lisehtwo.length; j++) {
  414. if (that.lisehtwo[i].id !== val[i]) {
  415. this.lisehtwo.push(router);
  416. }
  417. }
  418. // that.lisehtwo.filter(routers=>{
  419. // console.log(this.lisehtwo)
  420. // console.log(routers,val[i])
  421. // if(routers.id !== val[i]){
  422. // this.lisehtwo.push(router)
  423. // }
  424. // })
  425. }
  426. } else {
  427. // 取消选中
  428. }
  429. }
  430. });
  431. // this.lisehtwo.push(jueg)
  432. console.log(this.lisehtwo);
  433. // console.log(this.liseh[index].isIndeterminate)
  434. },
  435. checkTitle(val, index) {
  436. console.log(val, index);
  437. let arr = [];
  438. let jueg = [];
  439. const re = this.liseh[index].children;
  440. //全选
  441. if (val) {
  442. for (let i = 0; i < re.length; i++) {
  443. arr[i] = re[i]['id'];
  444. jueg[i] = re[i];
  445. this.lisehtwo.push(re[i]);
  446. }
  447. // this.lisehtwo.push(jueg)
  448. } else {
  449. this.lisehtwo = [];
  450. }
  451. console.log(this.lisehtwo);
  452. this.liseh[index].checkedData = arr;
  453. this.liseh[index].isIndeterminate = false;
  454. },
  455. // 筛选节点
  456. filterNode(value, data) {
  457. if (!value) return true;
  458. return data.label.indexOf(value) !== -1;
  459. },
  460. // 按照部门查询人员
  461. staff(index) {
  462. this.loading = true;
  463. var that = this;
  464. getRole(index).then(response => {
  465. // this.deptOptionsthre = this.handleTree(response.data, "id");
  466. // this.rtuer = true
  467. this.liseh = response.data;
  468. this.dhiuw = response.data
  469. this.loading = false;
  470. });
  471. },
  472. // 按照角色查询人员
  473. personnel(index) {
  474. this.loading = true;
  475. getPersonnel(index).then(response => {
  476. // this.deptOptionsthre = this.handleTree(response.data, "id"); this.liseh = response.data;
  477. this.liseh = response.data;
  478. this.dhiuw = response.data
  479. this.loading = false;
  480. });
  481. },
  482. // 按照组查询人员
  483. members(index,val) {
  484. if(val == 1){
  485. // 最外层
  486. let hueg = []
  487. let jheugq = []
  488. hueg = this.lisehtwo
  489. this.loading = true;
  490. console.log(this.lisehtwo)
  491. this.lisehtwo.splice(0,this.dhiuw.length-2)
  492. console.log(this.lisehtwo)
  493. console.log(this.dhiuw.length-2)
  494. this.liseh = []
  495. // for (let i = this.dhiuw.length - 1; i >= 0; i--) {
  496. // if (this.dhiuw[i].id == urls) {
  497. // this.config.splice(i, 1);
  498. // }
  499. // }
  500. // this.jeihqdcee = this.lisehtwo
  501. getMembers(index).then(response => {
  502. // this.deptOptionsthre = this.handleTree(response.data, "id"); this.liseh = response.data;
  503. // response.data
  504. // this.lisehtwo.push(response.data)
  505. // this.lisehtwo = []
  506. this.dhiuw = []
  507. this.dhiuw = response.data
  508. console.log(this.dhiuw,87)
  509. if(this.dhiuw.length == 0){
  510. console.log(34,this.dhiuw)
  511. this.lisehtwo = this.jeihqdcee
  512. }else{
  513. // this.dhiuw.filter(route=>{
  514. // this.lisehtwo.push(route)
  515. this.lisehtwo = this.lisehtwo.concat(this.dhiuw)
  516. // })
  517. }
  518. this.loading = false;
  519. });
  520. }else if(val == 2){
  521. // 里层点击
  522. getMembers(index).then(response => {
  523. this.liseh = response.data;
  524. this.dhiuw = response.data
  525. this.loading = false;
  526. });
  527. }
  528. },
  529. //获取权限
  530. jegeuser(){
  531. getInfo().then(res =>{
  532. console.log(res.permissions)
  533. res.permissions.filter( route =>{
  534. if(route == 'system:role:list'){
  535. this.jue = true
  536. }
  537. if(route == 'system:user:list'){
  538. this.buemg = true
  539. }
  540. if(route == 'system:group:index'){
  541. this.zuge = true
  542. }
  543. })
  544. // this.jue
  545. })
  546. }
  547. }
  548. };
  549. </script>
  550. <style scoped lang="scss">
  551. .iegeu {
  552. padding: 30px;
  553. }
  554. .infinite-list {
  555. height: 150px;
  556. margin-bottom: 20px;
  557. .infinite-list-item {
  558. width: 20% !important;
  559. display: flex;
  560. // justify-content: space-between;
  561. align-items: center;
  562. text-align: center;
  563. list-style: none;
  564. height: 30px;
  565. // line-height: 30px;
  566. }
  567. .infinite-list-itemss {
  568. color: #1890ff;
  569. }
  570. }
  571. .infinite-listty {
  572. display: flex;
  573. flex-wrap: wrap;
  574. .infinite-list-itemty {
  575. width: 20%;
  576. display: flex;
  577. // justify-content: space-between;
  578. height: 40px;
  579. line-height: 40px;
  580. // text-align: center;
  581. list-style: none;
  582. // border-radius: 40px;
  583. // border: 1px solid #eee;
  584. // border-bottom: 1px solid #eee;
  585. }
  586. }
  587. .tab_bott {
  588. display: flex;
  589. }
  590. .tabBot_oje {
  591. width: 40%;
  592. }
  593. .tabBot_two {
  594. width: 50%;
  595. margin-left: 30px;
  596. }
  597. .box-cardtt {
  598. margin-top: 30px;
  599. }
  600. .index_navTimeimg {
  601. width: 10px;
  602. height: 10px;
  603. margin-left: 5px;
  604. }
  605. </style>