commonDepartment.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <template>
  2. <el-dialog
  3. custom-class="department"
  4. title="选择上级部门"
  5. width="526px"
  6. height="100%"
  7. expand-on-click-node
  8. :before-close="closeDialog"
  9. :visible.sync="isDialog"
  10. :close-on-click-modal="false"
  11. style="height:100%;"
  12. >
  13. <div style=" background-color: #fff;width: 100%;clear:both;">
  14. <el-row>
  15. <el-col :span="11" style="margin-bottom:0; padding-right:0;">
  16. <div class="department_box_left">
  17. <div style="width: 100%;height: 40px;background: #DCDFE6;
  18. font-size: 14px; color: #606266;line-height: 40px;
  19. padding-left: 14px;
  20. ">
  21. 所有部门
  22. </div>
  23. <div style="margin-bottom:0; padding:15px;" class="inline-block-btn-list">
  24. <div class="gap-right-8" style="display:inline-block; width:100%; margin-bottom:0;">
  25. <!-- <el-input
  26. placeholder="输入关键词查找"
  27. ref="search-bar"
  28. v-model="filter.keywords"
  29. class="input-with-select"
  30. @keyup.enter.native="onFilterChanged"
  31. >
  32. <el-button slot="append" icon="el-icon-search" @click="onFilterChanged"></el-button> -->
  33. <!-- </el-input> -->
  34. </div>
  35. </div>
  36. <el-scrollbar
  37. wrap-class="column-wrapper scrollable-items-container dept_tree"
  38. :native="false"
  39. style="min-height:320px"
  40. >
  41. <div style="">
  42. <!-- <el-table
  43. v-loading="loading"
  44. ref="multipleTable"
  45. :data="tableData"
  46. :border="false"
  47. tooltip-effect="dark"
  48. @row-click="rowClick"
  49. @selection-change="handleSelectionChange"
  50. @select-all="select_all"
  51. style="width: 100%"
  52. >
  53. <el-table-column type="selection" width="42" :selectable="isSelectable"></el-table-column>
  54. <el-table-column prop="name" label="选择人员">
  55. <template slot-scope="scope">
  56. <div class="rank_head" style="cursor: pointer;">
  57. <img
  58. v-if="scope.row.img_url != null"
  59. v-bind:src="scope.row.img_url"
  60. width="42px"
  61. height="42px"
  62. >
  63. <img
  64. v-if="scope.row.img_url == null"
  65. src="static/images/head_default.png"
  66. width="42px"
  67. height="42px"
  68. >
  69. {{scope.row.name}}
  70. </div>
  71. </template>
  72. </el-table-column>
  73. </el-table> -->
  74. <div class="department_tree" @click="handleNodeClick({value: 0})">
  75. <img src="static/images/two.png" style="width: 16px;height: 16px;vertical-align: text-bottom;margin-right: 8px;" />
  76. {{company.name}}
  77. </div>
  78. <!-- <el-tree
  79. node-key="id"
  80. ref="dept_tree_com"
  81. highlight-current
  82. :default-expand-all="true"
  83. :expand-on-click-node="false"
  84. :data="deptTree"
  85. @node-click="handleSelectionChange"
  86. ></el-tree> -->
  87. <el-tree ref="menum"
  88. node-key="id"
  89. :accordion="true"
  90. :highlight-current="true"
  91. :data="deptTree"
  92. :expand-on-click-node= "false"
  93. @node-click="handleNodeClick"
  94. @check="handleSelectionChange"
  95. >
  96. <span class="custom-tree-node" slot-scope="{ node, data }">
  97. <img src="static/images/one.png" style="width: 20px;height:16px;vertical-align: text-top;margin-right: 4px;" />
  98. <span>{{data.name}}</span>
  99. </span>
  100. </el-tree>
  101. <!-- -->
  102. </div>
  103. </el-scrollbar>
  104. </div>
  105. </el-col>
  106. <div class="line"></div>
  107. <el-col :span="11">
  108. <div class="department_box_right" style="">
  109. <div style="width: 100%;height: 40px;background: #DCDFE6;
  110. font-size: 14px; color: #606266;line-height: 40px;
  111. padding-left: 14px;
  112. ">
  113. 已选上级部门
  114. </div>
  115. <el-scrollbar
  116. wrap-class="column-wrapper scrollable-items-container dept_tree"
  117. :native="false"
  118. style="min-height:280px"
  119. >
  120. <div style="">
  121. <!-- @header-click="cmultipleSelectionlearEmployee" -->
  122. <el-table
  123. :data="multipleSelection"
  124. :border="false"
  125. style="width: 100%"
  126. >
  127. <!-- ('+(multipleSelection.length)+'人) -->
  128. <el-table-column prop="label">
  129. <template slot-scope="scope">
  130. <div class="rank_head" style="cursor: pointer;">
  131. <img src="static/images/one.png" style="width: 20px;height: 16x;vertical-align: text-bottom;margin-right: 4px;" />
  132. {{scope.row.label}}
  133. </div>
  134. </template>
  135. </el-table-column>
  136. <el-table-column
  137. width="50"
  138. column-key="clear"
  139. label-class-name="clearEmployeeBtn"
  140. >
  141. <template slot-scope="scope">
  142. <div class="rank_head" style="cursor: pointer; text-align: center;">
  143. <a
  144. @click="removeEmployee(scope.row.id)"
  145. class="el-icon-circle-close"
  146. style="color:#ff7d79;"
  147. ></a>
  148. </div>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. </div>
  153. </el-scrollbar>
  154. </div>
  155. </el-col>
  156. <!-- <el-col :span="24" style="border-top:1px solid #eee; margin-bottom:0;">
  157. <el-pagination
  158. background
  159. style="margin-top:0;"
  160. :page-sizes="[6,20,30,50,100,200]"
  161. layout="sizes, prev, pager, next"
  162. @size-change="handleSizeChange"
  163. :page-size="pageLimit"
  164. :total="totalCount"
  165. :current-page.sync="currentPage"
  166. @current-change="changePage"
  167. ></el-pagination>
  168. </!-->
  169. </el-row>
  170. <div slot="footer" class="dialog-footer" style="text-align: center;margin-top: 20px;">
  171. <el-button @click="checkoutEmploye">取 消</el-button>
  172. <el-button @click="checkout" type="primary" plain>确定</el-button>
  173. </div>
  174. </div>
  175. </el-dialog>
  176. </template>
  177. <script>
  178. export default {
  179. // multipleSelectionId
  180. props: {
  181. employeeSelectorIds: {
  182. type: Array,
  183. default: () => {return []}
  184. },
  185. isMore: {
  186. type: Boolean,
  187. default: true
  188. },
  189. isDepart: {
  190. type: Boolean,
  191. default: true
  192. },
  193. include_admin: {
  194. type: Boolean,
  195. default: false
  196. },
  197. },
  198. watch: {
  199. isDepart() {
  200. this.isDialog = this.isDepart
  201. this.loadBaseData()
  202. },
  203. tableData(val) {
  204. this.$nextTick(() => {
  205. this.pageSelectedId = []
  206. val.forEach(item => {
  207. if (this.employeeSelectorIds.indexOf(item.id) >= 0) {
  208. this.$refs['multipleTable'].toggleRowSelection(item, true)
  209. this.pageSelectedId.push(item.id)
  210. }
  211. })
  212. })
  213. },
  214. employeeSelectorIds(val) {
  215. this.$nextTick(() => {
  216. if (!this.tableData) { return }
  217. this.pageSelectedId = []
  218. this.tableData.forEach(item => {
  219. this.$refs['multipleTable'].toggleRowSelection(item, false)
  220. if (val.indexOf(item.id) >= 0) {
  221. this.$refs['multipleTable'].toggleRowSelection(item, true)
  222. this.pageSelectedId.push(item.id)
  223. }
  224. })
  225. })
  226. }
  227. },
  228. data() {
  229. return {
  230. loading: false,
  231. profile: this.$store.getters.user_info,
  232. accessEnabled: false,
  233. dialogTableVisible: false,
  234. filter: {
  235. dept_id: [],
  236. status: 1,
  237. keywords: ''
  238. },
  239. isDialog: false,
  240. totalCount: 0,
  241. pageLimit: 6,
  242. currentPage: 1,
  243. tableData: null,
  244. multipleSelection: [],
  245. multipleSelectionId: [],
  246. multipnew:[],
  247. multipleSelectionJson: {},
  248. pageSelectedId: [],
  249. dialogExcelVisible: false,
  250. deptTree: [],
  251. company:[],
  252. creatorId: '',
  253. department_list: []
  254. }
  255. },
  256. methods: {
  257. // 取消
  258. checkoutEmploye() {
  259. this.isDialog = false;
  260. this.$emit('changishow');
  261. },
  262. closeDialog() {
  263. this.isDialog = false;
  264. this.$emit('changishow');
  265. },
  266. checkout() {
  267. this.isDialog = false;
  268. this.$emit('changishow');
  269. this.$nextTick(() => {
  270. this.$emit('check', this.multipleSelection)
  271. this.multipleSelection = [];
  272. // self.$parent.$parent.$parent.$parent.set_target_ids(self.multipleSelection)
  273. })
  274. },
  275. clearEmployee(column, event) {
  276. const self = this
  277. if (column.columnKey == 'clear') {
  278. for (const i in this.tableData) {
  279. self.$refs['multipleTable'].toggleRowSelection(
  280. self.tableData[i],
  281. false
  282. )
  283. }
  284. this.multipleSelectionId = []
  285. this.multipleSelectionJson = {}
  286. this.multipleSelection = []
  287. this.pageSelectedId = []
  288. }
  289. },
  290. removeEmployee(id) {
  291. console.log()
  292. console.log(id)
  293. let newarray = [];
  294. newarray = this.multipleSelection
  295. let array = [];
  296. for (let i = 0; i < newarray.length; i++) {
  297. if (newarray[i].id != id ) {
  298. array.push(newarray[i])
  299. }
  300. }
  301. this.multipleSelection = array;
  302. },
  303. handleNodeClick(data){
  304. // 单选
  305. if(this.isMore) {
  306. let self = this;
  307. let newarray = [];
  308. let newData = [];
  309. if(data.value == 0) {
  310. this.company.label = this.company.name;
  311. newarray.push(this.company)
  312. }else {
  313. let neobject = {};
  314. neobject.count = (data.count)
  315. neobject.create_time = (data.create_time)
  316. neobject.delete_time = (data.delete_time)
  317. neobject.id = (data.id)
  318. neobject.label = (data.label)
  319. neobject.pid = (data.pid)
  320. neobject.site_id = (data.site_id)
  321. neobject.sub_count = (data.sub_count)
  322. newarray.push(neobject);
  323. }
  324. self.multipleSelection = newarray;
  325. }else {
  326. let self = this;
  327. let newarray = [];
  328. let newData = [];
  329. if(data.value == 0) {
  330. this.company.label = this.company.name;
  331. newarray.push(this.company)
  332. }else {
  333. let neobject = {};
  334. neobject.count = (data.count)
  335. neobject.create_time = (data.create_time)
  336. neobject.delete_time = (data.delete_time)
  337. neobject.id = (data.id)
  338. neobject.label = (data.label)
  339. neobject.pid = (data.pid)
  340. neobject.site_id = (data.site_id)
  341. neobject.sub_count = (data.sub_count)
  342. newarray.push(neobject);
  343. }
  344. if(self.multipleSelection.length == 0) {
  345. self.multipleSelection = self.multipleSelection.concat(newarray)
  346. }else {
  347. newData = self.multipleSelection;
  348. newData = newData.concat(newarray)
  349. console.log(newData)
  350. for(var i=0; i<newData.length; i++){
  351. for(var j=i+1; j<newData.length; j++){
  352. if(newData[i].id==newData[j].id){
  353. newData.splice(j,1);
  354. j--;
  355. }
  356. }
  357. }
  358. console.log(newData)
  359. self.multipleSelection = newData;
  360. }
  361. }
  362. // = self.multipleSelection.concat(newarray)
  363. // self.multipleSelection = newcheck;
  364. // for (const i in self.multipleSelection) {
  365. // if (newarray.indexOf(this.multipleSelection[i]) < 0) {
  366. // multipleSelectionId.push(this.multipleSelection[i])
  367. // }
  368. // }
  369. // self.multipleSelection = self.multipleSelectionId.concat(check);
  370. //self.multipleSelection = self.multipleSelection.concat(check)
  371. // if(self.multipleSelection.includes(id)) {
  372. // console.log("000")
  373. // }else {
  374. // self.multipleSelection = self.multipleSelection.concat(newarray)
  375. // }
  376. // for (const i in self.multipleSelection) {
  377. // if (newarray[0].id.indexOf(self.multipleSelection[i].id) < 0) {
  378. // self.multipleSelection = self.multipleSelection.concat(newarray)
  379. // }
  380. // console.log(self.multipleSelection[i].id )
  381. // console.log(newarray[0].id)
  382. // if(self.multipleSelection[i].id === newarray[0].id ) {
  383. // return;
  384. // }else {
  385. // self.multipleSelection = self.multipleSelection.concat(newarray)
  386. // }
  387. // if (newarray.indexOf(self.multipleSelection[i]) < 0) {
  388. // self.multipleSelection = self.multipleSelection.concat(newarray)
  389. // }
  390. // }
  391. // if(self.multipleSelection.length!=0&&self.multipleSelection[0].id
  392. // == data.id
  393. // ) {
  394. // console.log("000")
  395. // }else {
  396. // let newarray = []
  397. // if(data.value == 0) {
  398. // this.company.label = this.company.name;
  399. // newarray.push(this.company)
  400. // }else if(){
  401. // let neobject = {};
  402. // neobject.count = (data.count)
  403. // neobject.create_time = (data.create_time)
  404. // neobject.delete_time = (data.delete_time)
  405. // neobject.id = (data.id)
  406. // neobject.label = (data.label)
  407. // neobject.pid = (data.pid)
  408. // neobject.site_id = (data.site_id)
  409. // neobject.sub_count = (data.sub_count)
  410. // newarray.push(neobject);
  411. // console.log(newarray)
  412. // console.log("jfvihdu")
  413. // }
  414. // self.multipleSelection = self.multipleSelection.concat(newarray)
  415. // // self.multipleSelection = newarray
  416. // }
  417. // self.$nextTick(() => {
  418. // self.$emit('check', self.multipleSelection)
  419. // self.$parent.$parent.$parent.$parent.set_target_ids(self.multipleSelection)
  420. //})
  421. },
  422. handleSizeChange(val) {
  423. this.pageLimit = val
  424. //this.onFilterChanged()
  425. },
  426. onFilterChanged: function() {
  427. this.currentPage = 0
  428. //this.loadEmployeeList()
  429. },
  430. toggleSelection: function(rows) {
  431. if (rows) {
  432. rows.forEach(row => {
  433. this.$refs.multipleTable.toggleRowSelection(row)
  434. })
  435. } else {
  436. this.$refs.multipleTable.clearSelection()
  437. }
  438. },
  439. select_all(all) {
  440. const ids = []
  441. for (const i in all) {
  442. ids.push(all[i].id)
  443. }
  444. },
  445. //getcompany() {
  446. // this.multipleSelection.push(this.company);
  447. // this.$emit('check', this.multipleSelection)
  448. //},
  449. handleSelectionChange: function(a) {
  450. },
  451. rowClick(row, event, column) {
  452. this.$refs['multipleTable'].toggleRowSelection(row)
  453. },
  454. isSelectable: function(row, index) {
  455. return true
  456. },
  457. toSexName: function(row, column, cellValue) {
  458. return cellValue == '1' ? '女' : '男'
  459. },
  460. dateFormatter: function(row, column, cellValue) {
  461. return this.$moment(cellValue * 1000).format('YYYY年MM月DD日')
  462. },
  463. // 获取基本数据
  464. loadBaseData: function() {
  465. var self = this
  466. this.$http('get','' + '/api/department/tree')
  467. .then(function(response) {
  468. if (response.data.code == 1) {
  469. self.company = response.data.data.company;
  470. self.deptTree = response.data.data.list
  471. for(let i = 0; i < self.deptTree.length; i++) {
  472. self.deptTree[i].label = self.deptTree[i].name
  473. }
  474. // var jsonData = response.data
  475. // try {
  476. // self.deptTree = jsonData.dept_tree
  477. // self.creatorId = jsonData.creator_id
  478. // if (self.profile.manager_type < 2) {
  479. // self.filter.dept_id = [self.deptTree[0].value]
  480. // //self.loadEmployeeList()
  481. // }
  482. // } catch (err) {
  483. // console.log(err)
  484. // }
  485. }
  486. })
  487. .catch(function(error) {
  488. console.log(error)
  489. })
  490. },
  491. changePage: function(current) {
  492. if (isNaN(current) || current < 1) {
  493. return false
  494. }
  495. // this.loadEmployeeList()
  496. }
  497. },
  498. created() {
  499. this.loadBaseData()
  500. if (this.profile.manager_type > 1) {
  501. // this.loadEmployeeList()
  502. }
  503. }
  504. }
  505. </script>
  506. <style scoped>
  507. .el-dialog__body {
  508. clear: both;
  509. padding: 30px 0;
  510. }
  511. .el-table__footer-wrapper, .el-table__header-wrapper {
  512. display: none;
  513. }
  514. .el-table td, .el-table th.is-leaf {
  515. border: none;
  516. }
  517. .el-table::before {
  518. width: 0%;
  519. }
  520. .el-pagination {
  521. text-align: center;
  522. margin-top: 15px;
  523. }
  524. .dept_tree a.on {
  525. background-color: #f0f7ff;
  526. }
  527. .clearEmployeeBtn {
  528. cursor: pointer;
  529. color: #409eff;
  530. font-weight: normal;
  531. }
  532. .clearEmployeeBtn:hover {
  533. color: #66b1ff;
  534. }
  535. /* .rank_head img {
  536. width: 30px;
  537. height: 30px;
  538. -webkit-border-radius: 20px;
  539. -moz-border-radius: 20px;
  540. border-radius: 20px;
  541. margin-right: 5px;
  542. } */
  543. .rank_head * {
  544. vertical-align: middle;
  545. }
  546. /deep/ .department .el-dialog__header{
  547. padding: 30px 35px 27px;
  548. }
  549. /deep/ .department .el-dialog__body{
  550. padding: 0;
  551. }
  552. /deep/ .department .department_box_left .el-tree--highlight-current{
  553. overflow-y:auto;
  554. height:318px;
  555. }
  556. /deep/ .department .department_box_right .el-table__body-wrapper{
  557. overflow-y:auto;
  558. height:358px;
  559. }
  560. /deep/ .department .el-tree--highlight-current::-webkit-scrollbar{
  561. /*background:rgba(236,245,254,1);*/
  562. background:transparent;
  563. width:4px;
  564. }
  565. /deep/ .department .el-tree--highlight-current::-webkit-scrollbar-thumb {
  566. background:#409EFF;
  567. }
  568. .department{
  569. position:relative;
  570. display:block;
  571. text-align: center;
  572. margin-top:18vh !important;
  573. padding-bottom:30px;
  574. }
  575. /deep/ .department .el-table__body-wrapper::-webkit-scrollbar{
  576. /*background:rgba(236,245,254,1);*/
  577. background:transparent;
  578. width:4px;
  579. }
  580. /deep/ .department .el-table__body-wrapper::-webkit-scrollbar-thumb {
  581. background:#409EFF;
  582. }
  583. .department{
  584. position:relative;
  585. display:block;
  586. text-align: center;
  587. margin-top:18vh !important;
  588. padding-bottom:30px;
  589. }
  590. .department .department_box_left{
  591. display:inline-block;
  592. border-radius:4px;
  593. width:200px;
  594. height:420px;
  595. margin-left:35px;
  596. border:1px #DCDFE6 solid;
  597. }
  598. .department .department_box_right{
  599. display:inline-block;
  600. border-radius:4px;
  601. width:200px;
  602. height:420px;
  603. margin-right:35px;
  604. border:1px #DCDFE6 solid;
  605. }
  606. .department .el-row{
  607. position:relative;
  608. display:block;
  609. text-align: center;
  610. }
  611. .department .el-row .el-col-11:nth-child(1){
  612. position:relative;
  613. display:inline-block;
  614. text-align: left;
  615. float:left;
  616. }
  617. .department .el-row .el-col-11:nth-child(3){
  618. position:relative;
  619. display:inline-block;
  620. text-align: left;
  621. float:right;
  622. }
  623. .department .department_tree{
  624. line-height: 36px;
  625. margin-bottom:2px;
  626. background: #ECF5FE;
  627. padding-left: 16px;
  628. cursor: pointer;
  629. }
  630. .department .line{
  631. display:inline-block;
  632. border-right: 1px solid #D8D8D8;
  633. height: 420px;
  634. float:none;
  635. }
  636. .department .dialog-footer{
  637. padding-bottom:30px;
  638. }
  639. /deep/ .department .el-tree-node__expand-icon.is-leaf{
  640. color: #909399;
  641. padding:0 6px 0 20px;
  642. font-size: 16px;
  643. }
  644. /deep/ .department .department_box_right .el-table td{
  645. padding:4px 0px;
  646. border-bottom: 1px solid #EBEEF5;
  647. }
  648. .department .rank_head{
  649. padding-left:6px;
  650. }
  651. .department .rank_head a:before{
  652. color:#C0C4CC;
  653. }
  654. </style>