index.vue 17 KB

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