EmployeeSelector.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="visible_"
  5. :close-on-click-modal="false"
  6. :before-close="close_before"
  7. append-to-body
  8. @open="openDialog"
  9. width="640px"
  10. top="5%"
  11. class="employee_select_dialog"
  12. >
  13. <slot name="header"></slot>
  14. <div class="employee_selector_box" v-if="visible_">
  15. <el-row :gutter="10">
  16. <el-col :xs="11" :sm="11" :md="11" :lg="11" :xl="11" class="scroller-box one">
  17. <div class="search-box">
  18. <div class="search flex-box"><el-input v-model="keyword" placeholder="请输入内容" clearable></el-input></div>
  19. <div class="search flex-box" style="margin-top: 7px;">
  20. <el-cascader
  21. v-show="can_select_employee && deptId==0"
  22. style="width: 100%;"
  23. v-model="dept_id"
  24. ref="dept"
  25. :options="dept_list"
  26. :props="{ checkStrictly: true, value: 'id', label: 'name', children: 'children' }"
  27. clearable
  28. :disabled="deptId > 0"
  29. placeholder="全公司"
  30. ></el-cascader>
  31. </div>
  32. </div>
  33. <div class="dept_path scroll-bar flex-box flex-d-wrap" v-if="can_select_dept">
  34. <template v-if="pid_list_arr.length > 0">
  35. <div @click="back_by_index(0)" class="blue" style="cursor: pointer;">全公司</div>
  36. <div v-for="(item, index) in pid_list_arr" :key="index" @click="back_by_index(index + 1, item)" class="font-flex-word" style="max-width: 120px;">
  37. <i class="el-icon-arrow-right"></i>
  38. <span class="blue" style="cursor: pointer;">{{ item.name }}</span>
  39. </div>
  40. </template>
  41. </div>
  42. <!-- 人员 -->
  43. <div class="flex-box-end" v-if="can_select_employee && isChecKedAll && multi" style="padding: 10px;border-bottom: 1px solid #f1f1f1;">
  44. <el-checkbox v-model="checked" @change="checkedChange">全选</el-checkbox>
  45. </div>
  46. <el-scrollbar
  47. wrap-class="column-wrapper scrollable-items-container"
  48. :native="false"
  49. :class="(can_select_dept || isChecKedAll)? 'scrollbarHeight1' : 'scrollbarHeight2'"
  50. v-loading="table_loading"
  51. >
  52. <div class="choose_left">
  53. <template v-if="can_select_dept">
  54. <div class="persons_box" style="padding-top:4px;" v-if="dept_list.length > 0">
  55. <div v-for="(item, index) in dept_list" :key="index">
  56. <div class="flex-box flex-v-ce deptList" @click="select_dept(item, index)" v-show="item.name.indexOf(keyword) >= 0">
  57. <div :class="[item.checked? 'showCheckbox':'']" class="checkbox"><span class="isCheckbox"></span></div>
  58. <div class="employee_name flex-1 font-flex-word">{{ item.name }}</div>
  59. <div v-if="item.children" class="blue" @click.stop="show_child(item)">| 下级</div>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <template v-if="can_select_employee">
  65. <div class="persons_box" style="padding-top:4px;" v-if="list.length > 0">
  66. <div class="employee_cell_a" v-for="(item, index) in list" :key="index" v-show="item.id">
  67. <div class="employee_cell" @click.prevent.stop="select_employee(item)">
  68. <div class="employee_checkbox"><el-checkbox v-model="item.checked"></el-checkbox></div>
  69. <div class="employee_img_url"><img :src="item.img_url" class="employee_cell_head_img" /></div>
  70. <div class="employee_name">{{ item.name }}</div>
  71. <div class="employee_cell_clear"></div>
  72. </div>
  73. </div>
  74. </div>
  75. <div v-else class="fontColorC" style="text-align: center;margin-top: 50px;">暂无可选人员</div>
  76. </template>
  77. </div>
  78. </el-scrollbar>
  79. </el-col>
  80. <el-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2" class="col-line"><span style="opacity: 0;">空</span></el-col>
  81. <el-col :xs="11" :sm="11" :md="11" :lg="11" :xl="11" class="scroller-box">
  82. <div class="option-box">
  83. <span style="line-height: 40px; padding-left: 10px;" class="fl" v-if="multi && can_select_employee">已选择{{ employee_selected_list.length }}个员工</span>
  84. <el-button type="type" @click="clear_data">清空</el-button>
  85. </div>
  86. <el-scrollbar wrap-class="column-wrapper scrollable-items-container" :native="false" style="height: 400px;">
  87. <div class="choose_right">
  88. <div class="employee_cell" v-for="(item, index) in dept_selected_list" :key="index">
  89. <div class="employee_name">{{ item.dept_name }}</div>
  90. <div class="employee_delete"><el-button type="default" size="mini" @click="dept_delete(item, index)" icon="el-icon-close" circle></el-button></div>
  91. <div class="employee_cell_clear"></div>
  92. </div>
  93. <div class="employee_cell" v-for="(item, index) in employee_selected_list" :key="index">
  94. <div class="employee_img_url" v-if="item.img_url"><img :src="item.img_url" class="employee_cell_head_img" /></div>
  95. <div class="employee_img_url" v-else><img src="static/images/head_default.png" class="employee_cell_head_img" /></div>
  96. <div class="employee_name">{{ item.name }}</div>
  97. <div class="employee_delete"><el-button type="default" size="mini" @click="employee_cancel(item, true)" icon="el-icon-close" circle></el-button></div>
  98. <div class="employee_cell_clear"></div>
  99. </div>
  100. </div>
  101. </el-scrollbar>
  102. </el-col>
  103. </el-row>
  104. </div>
  105. <span slot="footer" class="dialog-footer">
  106. <el-button @click="close">取 消</el-button>
  107. <el-button type="primary" @click="confirm">确 定</el-button>
  108. </span>
  109. </el-dialog>
  110. </template>
  111. <script>
  112. export default {
  113. props: {
  114. title: {
  115. // 标题
  116. type: String,
  117. default: '选择部门和员工'
  118. },
  119. deptId: {
  120. //指定部门ID,人员列表就是该部门的
  121. type: Number,
  122. default: 0
  123. },
  124. visible: {
  125. // 是否显示组件
  126. type: Boolean,
  127. default: false
  128. },
  129. can_select_dept: {
  130. // 是否能选择部门(单选择部门,不能选择人员)
  131. type: Boolean,
  132. default: false
  133. },
  134. dept_not_select: {
  135. // 排除部门ID
  136. type: Array,
  137. default: () => {
  138. return [];
  139. }
  140. },
  141. dept_multi: {
  142. // 指定部门是否能多选
  143. type: Boolean,
  144. default: true
  145. },
  146. dept_children: {
  147. //选择部门时是否包含子部门
  148. type: Boolean,
  149. default: true
  150. },
  151. can_select_employee: {
  152. // 指定是否能选择员工
  153. type: Boolean,
  154. default: true
  155. },
  156. employee_not_select: {
  157. // 排除员工的ID,包含ID时不出现在选择列表中
  158. type: Array,
  159. default: () => {
  160. return [];
  161. }
  162. },
  163. selected: {
  164. // 已经选择的员工和部门
  165. type: Object,
  166. default: () => {
  167. return { employee: [], dept: [] };
  168. }
  169. },
  170. multi: {
  171. // 指定员工是否能多选
  172. type: Boolean,
  173. default: true
  174. },
  175. user_employee_list: {
  176. // 为true时,employee_list才生效
  177. type: Boolean,
  178. default: false
  179. },
  180. employee_list: {
  181. // 指定显示的员工列表,注意:传值后组件的员工数据将不是统一向服务器获取的,而是指定的员工列表,格式是:[{id: 1, name: “张三”, img_url: “”}]
  182. type: Array,
  183. default: () => {
  184. return [];
  185. }
  186. },
  187. isChecKedAll: {
  188. //是否全选
  189. type: Boolean,
  190. default: true
  191. },
  192. close_clear_data: {
  193. //关闭时是否清除选择的数据
  194. type: Boolean,
  195. default: true
  196. },
  197. max: {
  198. //选择的人数限制
  199. type: Number,
  200. default: 0
  201. },
  202. is_filtration_creator: {
  203. //是否去除创始人
  204. type: Boolean,
  205. default: true
  206. },
  207. is_manager_only: {
  208. //是否只显示管理者
  209. type: Boolean,
  210. default: false
  211. },
  212. dimission_employee: {
  213. //是否去除已经离职的人
  214. type: Boolean,
  215. default: true
  216. },
  217. include_self: {
  218. //是否显示自己
  219. type: Boolean,
  220. default: true
  221. },
  222. child:{
  223. //当人员列表点击部门筛选时不显示子部门人员 ,目前只在设置主管有使用到
  224. type: Boolean,
  225. default: true
  226. },
  227. isRequired:{
  228. //是否必须选择人员或者部门
  229. type: Boolean,
  230. default: false
  231. },
  232. include_deleted:{
  233. //是否查询已被删除的人员
  234. type: Boolean,
  235. default: false
  236. }
  237. },
  238. name: 'EmployeeSelector',
  239. data() {
  240. return {
  241. // 基础配置
  242. table_loading: false,
  243. searchBox: [], //用于搜索的全部人员
  244. keyword: '',
  245. checked: false,
  246. visible_: false,
  247. // 选择人员相关
  248. employee_selected_list: [],
  249. employee_selected: [],
  250. list: [],
  251. // 选择部门相关
  252. dept_selected_list: [],
  253. dept_name: '',
  254. dept_id: [],
  255. dept_select_id: 0,
  256. dept_list: [],
  257. dept_list_all: [], //备用全部部门
  258. pid_list_arr: []
  259. };
  260. },
  261. watch: {
  262. // 当动态改变“employee_list”时,获取employee_list与employee_selected_list的交集,用于考勤组功能
  263. employee_list(val) {
  264. var eSList = this.employee_selected_list;
  265. this.employee_selected_list = [...eSList].filter(x => [...val].some(y => y.id === x.id));
  266. },
  267. visible(val) {
  268. this.visible_ = JSON.parse(JSON.stringify(val));
  269. if (val) {
  270. setTimeout(() => {
  271. this.get_user_list();
  272. this.get_dept_list();
  273. }, 200);
  274. }
  275. },
  276. dept_id(val) {
  277. this.dept_select_id = val[val.length - 1];
  278. this.$nextTick(() => {
  279. if (this.can_select_employee) {
  280. this.$refs.dept.dropDownVisible = false;
  281. }
  282. this.get_user_list();
  283. this.checked = false;
  284. });
  285. },
  286. keyword(val) {
  287. this.list = this.searchBox.filter(item => item.name.includes(this.keyword));
  288. if (!val) {
  289. this.checked = false;
  290. }
  291. }
  292. },
  293. methods: {
  294. //打开Dialog的回调,用刷每次打开都初始化selected
  295. openDialog() {
  296. if (this.deptId != 0) {
  297. this.dept_id = [this.deptId];
  298. this.dept_select_id = this.deptId;
  299. }
  300. let selected = this.selected;
  301. this.employee_selected = [];
  302. this.employee_selected_list=[];
  303. this.dept_selected_list=[];
  304. if(selected.employee[0]&&selected.employee[0].id){
  305. this.employee_selected_list = JSON.parse(JSON.stringify(selected.employee));
  306. for (let i in selected.employee) {
  307. this.employee_selected.push(selected.employee[i].id);
  308. }
  309. }
  310. if(selected.dept.length>0){
  311. this.dept_selected_list =JSON.parse(JSON.stringify(selected.dept));
  312. }
  313. },
  314. close_before(done) {
  315. this.close();
  316. done();
  317. },
  318. // 全选(只用选择人员)
  319. checkedChange(val) {
  320. if (val) {
  321. this.$nextTick(() => {
  322. let employeeSelectedList = JSON.parse(JSON.stringify(this.employee_selected_list)); //获取选择的人员
  323. let employeeSelectedIds = [],
  324. total = 0;
  325. employeeSelectedList.forEach(element => {
  326. employeeSelectedIds.push(element.id);
  327. });
  328. for (let i in this.list) {
  329. this.$set(this.list[i], 'checked', true);
  330. if (!employeeSelectedIds.includes(this.list[i].id)) {
  331. //去除已经选择的人员
  332. this.employee_selected_list.push(this.list[i]);
  333. }
  334. }
  335. });
  336. } else {
  337. this.employee_selected_list = [];
  338. this.employee_selected = [];
  339. for (let i in this.list) {
  340. this.$set(this.list[i], 'checked', false);
  341. }
  342. }
  343. },
  344. // 点击部门导航
  345. back_by_index(index, item) {
  346. this.pid_list_arr.splice(index, 100);
  347. if (index == 0) {
  348. this.dept_list = this.dept_list_all;
  349. return false;
  350. }
  351. if (item.children) {
  352. this.dept_list = item.children;
  353. }
  354. },
  355. //下一级
  356. show_child(item) {
  357. if (item.children) {
  358. this.dept_list = item.children;
  359. }
  360. this.pid_list_arr.push(item);
  361. },
  362. //获取一个部门的下的所有子部门
  363. getChildrens(list) {
  364. var dept_list = [];
  365. list.forEach(item => {
  366. item.checked = true;
  367. dept_list.push({ dept_id: item.id, dept_name: item.name, avatar: 'static/images/e66f.jpg' });
  368. if (item.children) {
  369. dept_list.push(...this.getChildrens(item.children));
  370. }
  371. });
  372. return dept_list;
  373. },
  374. //选择部门
  375. select_dept(item, index) {
  376. if (item.checked) {
  377. this.dept_cancel(item);
  378. } else {
  379. if (!this.dept_multi) {
  380. //是否能多选
  381. this.dept_selected_list = [];
  382. for (let i in this.dept_list_all) {
  383. this.dept_cancel(this.dept_list_all[i], true);
  384. }
  385. }
  386. item.checked = true;
  387. if (item.children && this.dept_children) {
  388. //是否存在子部门
  389. this.dept_selected_list.push({ dept_id: item.id, dept_name: item.name, avatar: 'static/images/e66f.jpg' });
  390. var arr = this.getChildrens(item.children);
  391. arr=arr.filter(e=>{ //过来已经选择过的
  392. return !this.returnArr(e.dept_id)
  393. })
  394. this.dept_selected_list.push(...arr);
  395. } else {
  396. this.dept_selected_list.push({ dept_id: item.id, dept_name: item.name, avatar: 'static/images/e66f.jpg' });
  397. }
  398. }
  399. },
  400. returnArr(dept_id){
  401. let is=false;
  402. this.dept_selected_list.forEach(e=>{
  403. if(e.dept_id==dept_id){
  404. is=true;
  405. }
  406. })
  407. return is
  408. },
  409. //清除选择的部门
  410. dept_cancel(item, is) {
  411. item.checked = false;
  412. if (item.children&&this.dept_children) {
  413. //左边
  414. item.children.forEach(childrens => {
  415. this.dept_cancel(childrens);
  416. });
  417. }
  418. if (is) {
  419. return false;
  420. }
  421. var deptSelectedList = this.dept_selected_list;
  422. deptSelectedList.forEach((dept, index) => {
  423. //右边
  424. if (dept.dept_id == item.id) {
  425. deptSelectedList.splice(index, 1);
  426. }
  427. });
  428. },
  429. //删除部门
  430. dept_delete(item) {
  431. var dept_list = this.dept_list;
  432. var obj = this.getDeptz(item.dept_id, dept_list); //递归找到所属部门
  433. this.dept_cancel(obj);
  434. },
  435. // 递归获取指定ID部门
  436. getDeptz(id, arr) {
  437. var obj = {};
  438. for (let i = 0; i < arr.length; i++) {
  439. if (id == arr[i].id) {
  440. obj = arr[i];
  441. break;
  442. } else if (arr[i].children) {
  443. if (this.getDeptz(id, arr[i].children).id) {
  444. obj = this.getDeptz(id, arr[i].children);
  445. }
  446. }
  447. }
  448. return obj;
  449. },
  450. //清除选择的人员
  451. employee_cancel(item) {
  452. this.checked = false;
  453. this.employee_selected.splice(this.employee_selected.indexOf(item.id), 1);
  454. let delete_index = -1;
  455. for (let i in this.employee_selected_list) {
  456. if (this.employee_selected.indexOf(this.employee_selected_list[i].id) < 0) {
  457. delete_index = i;
  458. }
  459. }
  460. if (delete_index >= 0) {
  461. for (let i in this.list) {
  462. if (this.list[i].id == item.id) {
  463. this.$set(this.list[i], 'checked', false);
  464. }
  465. }
  466. for (let i in this.employee_selected_list) {
  467. if (this.employee_selected_list[i].id == item.id) {
  468. this.employee_selected_list.splice(i, 1);
  469. }
  470. }
  471. }
  472. },
  473. //选择人员
  474. select_employee(item) {
  475. if (item.checked) {
  476. item.checked = false;
  477. this.employee_cancel(item);
  478. } else {
  479. if (!this.multi) {
  480. this.employee_selected = [];
  481. this.employee_selected_list = [];
  482. for (let i in this.list) {
  483. this.$set(this.list[i], 'checked', false);
  484. }
  485. }
  486. if (this.max > 0 && this.employee_selected.length == this.max && this.multi) {
  487. this.$message.error('最多只能选择' + this.max + '人');
  488. return false;
  489. }
  490. this.employee_selected.push(item.id);
  491. this.employee_selected_list.push({ id: item.id, name: item.name, img_url: item.img_url });
  492. item.checked = true;
  493. }
  494. },
  495. //清空
  496. clear_data() {
  497. this.checked = false;
  498. this.employee_selected = [];
  499. this.employee_selected_list = [];
  500. this.dept_selected_list = [];
  501. for (let i in this.list) {
  502. this.$set(this.list[i], 'checked', false);
  503. }
  504. for (let i in this.dept_list) {
  505. this.$set(this.dept_list[i], 'checked', false);
  506. }
  507. for (let i in this.dept_list_all) {
  508. this.$set(this.dept_list_all[i], 'checked', false);
  509. }
  510. },
  511. //关闭||清空数据
  512. close() {
  513. this.keyword='';
  514. this.$emit('update:visible', false);
  515. if (this.close_clear_data) {
  516. this.checked = false;
  517. this.keyword='';
  518. this.employee_selected = [];
  519. this.employee_selected_list = [];
  520. this.dept_selected_list = [];
  521. this.pid_list_arr=[];
  522. for (let i in this.list) {
  523. this.$set(this.list[i], 'checked', false);
  524. }
  525. for (let i in this.dept_list) {
  526. this.$set(this.dept_list[i], 'checked', false);
  527. }
  528. for (let i in this.dept_list_all) {
  529. this.$set(this.dept_list_all[i], 'checked', false);
  530. }
  531. }
  532. },
  533. // 确定
  534. confirm() {
  535. if(this.isRequired){
  536. if(this.can_select_dept){
  537. if(this.dept_selected_list.length==0){
  538. this.$message.error("请选择部门");
  539. return false
  540. }
  541. }else{
  542. if(this.employee_selected_list.length==0){
  543. this.$message.error("请选择人员");
  544. return false
  545. }
  546. }
  547. }
  548. if(this.max > 0 && this.dept_selected_list.length > this.max){
  549. this.$message.error('最多只能选'+ this.max +'个部门');
  550. return
  551. }
  552. if(this.max > 0 && this.employee_selected_list.length > this.max){
  553. this.$message.error('最多只能选'+ this.max +'人');
  554. return
  555. }
  556. this.$emit('confirm', {
  557. employee: this.employee_selected_list,
  558. dept: this.dept_selected_list
  559. });
  560. this.close();
  561. },
  562. // 获取部门
  563. get_dept_list() {
  564. this.$axiosUser('get', '/api/pro/department/tree', '', 'v2').then(res => {
  565. var list = res.data.data.list;
  566. var dept_list = [];
  567. // 排除部门
  568. if (this.dept_not_select.length > 0) {
  569. dept_list = list.filter(item => {
  570. return this.dept_not_select.indexOf(item.id) == -1;
  571. });
  572. } else {
  573. dept_list = list;
  574. }
  575. dept_list = this.getTreeData(dept_list); //过滤children
  576. //默认选中部门
  577. if (this.dept_selected_list.length > 0) {
  578. this.dept_selected_list.forEach(item => {
  579. this.setDeptChecked(item.dept_id, dept_list);
  580. });
  581. }
  582. this.dept_list = dept_list;
  583. this.dept_list_all = this.dept_list;
  584. });
  585. },
  586. //设置默认部门
  587. setDeptChecked(id, arr) {
  588. for (let i = 0; i < arr.length; i++) {
  589. if (id == arr[i].id) {
  590. arr[i].checked = true;
  591. break;
  592. } else if (arr[i].children) {
  593. this.setDeptChecked(id, arr[i].children);
  594. }
  595. }
  596. },
  597. getTreeData(data) {
  598. for (var i = 0; i < data.length; i++) {
  599. data[i].checked = false;
  600. if (data[i].children.length < 1) {
  601. // children若为空数组,则将children设为undefined
  602. data[i].children = undefined;
  603. } else {
  604. // children若不为空数组,则继续 递归调用 本方法
  605. this.getTreeData(data[i].children);
  606. }
  607. }
  608. return data;
  609. },
  610. // 默认选择中的人勾上
  611. parse_list(data) {
  612. let _list = [];
  613. data.map(item => {
  614. item['checked'] = false;
  615. for (var i in this.employee_selected_list) {
  616. //判断传进来的员工是否是员工集合里的,是就设为已点击状态
  617. if (this.employee_selected_list[i].id == item.id) {
  618. item['checked'] = true;
  619. }
  620. }
  621. if (item.img_url == '') {
  622. item.img_url = 'static/images/head_default.png';
  623. }
  624. });
  625. this.searchBox = data;
  626. this.list = data;
  627. },
  628. //获取人员
  629. get_user_list() {
  630. this.table_loading = true;
  631. this.$axiosUser('get', '/api/pro/employee/index', { dept_id: this.dept_select_id, keywords: this.keyword, page: 1, page_size: 2000, child:this.child? '1':'0' }, 'v2')
  632. .then(res => {
  633. let list = this.filtration(res.data.data.list);
  634. // 当有指定显示列表时
  635. if (this.user_employee_list) {
  636. var employee_list = this.employee_list;
  637. var userData = [];
  638. if(this.include_deleted){
  639. userData=employee_list;
  640. }else{
  641. list.map(item => {
  642. // 列表数据是否是自己的管理范围
  643. employee_list.map(item2 => {
  644. if (item.id == item2.id) {
  645. userData.push(item);
  646. }
  647. });
  648. });
  649. }
  650. this.parse_list(userData);
  651. } else {
  652. // 没有指定人员列表
  653. this.parse_list(list);
  654. }
  655. })
  656. .finally(() => {
  657. this.table_loading = false;
  658. });
  659. },
  660. // 过滤各种条件:如:自己,创始人,只显示管理者等。。。
  661. filtration(data) {
  662. var list = data;
  663. // 是否去除已经离职的人
  664. if(this.dimission_employee){
  665. for (let i = 0; i < list.length; i++) {
  666. if (list[i].status == 2) {
  667. list.splice(i, 1);
  668. i--
  669. }
  670. }
  671. }
  672. var managerList = []; // 管理者列表
  673. // 只显示管理者
  674. if (this.is_manager_only) {
  675. var isManager;
  676. list.map(item => {
  677. isManager = false;
  678. item.employee_detail.role_list.map(item2 => {
  679. if (item2.name == 'creator' || item2.name == 'point_manager' || item2.name == 'dept_manager' || item2.name == 'admin') {
  680. isManager = true;
  681. }
  682. });
  683. if (isManager) {
  684. managerList.push(item);
  685. }
  686. });
  687. list = managerList;
  688. }
  689. // 过滤自己
  690. if (!this.include_self) {
  691. const currUserId = this.$store.getters.user_info.id;
  692. for (let i = 0; i < list.length; i++) {
  693. if (list[i].id == currUserId) {
  694. list.splice(i, 1);
  695. i--
  696. }
  697. }
  698. }
  699. // 过滤创始人
  700. if (this.is_filtration_creator) {
  701. for (let i = 0; i < list.length; i++) {
  702. if (list[i].is_creator == 1) {
  703. list.splice(i,1);
  704. i--
  705. }
  706. }
  707. }
  708. //过滤指定人员[]
  709. if (this.employee_not_select.length > 0) {
  710. for (let i = 0; i < list.length; i++) {
  711. if (this.employee_not_select.indexOf(list[i].id) >= 0) {
  712. list.splice(i, 1);
  713. i--
  714. }
  715. }
  716. }
  717. return list;
  718. }
  719. },
  720. created() {}
  721. };
  722. </script>
  723. <style scoped lang="scss">
  724. /deep/ .el-dialog__body {
  725. padding:20px;
  726. color: #606266;
  727. font-size: 14px;
  728. word-break: break-all;
  729. }
  730. .showCheckbox .isCheckbox{
  731. height: 6px;
  732. width: 6px;
  733. background-color: #409EFF;
  734. display: inline-block;
  735. border-radius: 2px;
  736. line-height: 14px;
  737. position: relative;
  738. top: -6px;
  739. }
  740. .showCheckbox{
  741. border: 1px solid #409EFF !important;
  742. }
  743. .checkbox{
  744. height: 14px;
  745. width: 14px;
  746. border: 1px solid #dcdfe6;
  747. background: #fff;
  748. border-radius: 2px;
  749. position: relative;
  750. box-sizing: border-box;
  751. text-align: center;
  752. }
  753. .deptList {
  754. padding: 12px 0;
  755. border-bottom: 1px solid #f1f1f1;
  756. cursor: pointer;
  757. }
  758. .employee_selector_box {
  759. width: 600px;
  760. // padding: 20px;
  761. box-sizing: border-box;
  762. margin: 0 auto;
  763. }
  764. /* 搜索框 */
  765. .employee_selector_box .search {
  766. margin: 0 auto;
  767. width: 80%;
  768. min-height: 36px;
  769. }
  770. .employee_selector_box .search-box button {
  771. display: inline-block;
  772. vertical-align: middle;
  773. margin-left: 10px;
  774. width: auto;
  775. padding: 0;
  776. background: none;
  777. border-radius: 0px;
  778. border: none;
  779. }
  780. /* /搜索框 */
  781. /* 左边框 */
  782. .employee_selector_box .choose_left {
  783. padding: 8px 10px 8px 10px;
  784. }
  785. .employee_selector_box .choose_left .employee_cell {
  786. border-bottom: 1px #f1f1f1 solid;
  787. }
  788. .employee_selector_box .choose_left .employee_cell_a .employee_cell {
  789. border-bottom: none;
  790. }
  791. .employee_selector_box .choose_left .employee_checkbox {
  792. padding-left: 8px;
  793. }
  794. .employee_selector_box .choose_left .employee_img_url {
  795. padding-left: 8px;
  796. }
  797. .employee_selector_box .choose_left .employee_name {
  798. padding-left: 8px;
  799. }
  800. .employee_selector_box ::v-deep .el-scrollbar__thumb {
  801. width: 2px;
  802. margin: 15px 0 0 6px;
  803. background: #409EFF;
  804. }
  805. /* 左边框 */
  806. /* 右边距 */
  807. .employee_selector_box .option-box {
  808. padding: 14px 0;
  809. }
  810. .employee_selector_box .option-box button {
  811. margin-right: 16px;
  812. }
  813. .employee_selector_box .choose_right {
  814. padding: 8px 10px;
  815. }
  816. .employee_selector_box .choose_right .employee_delete .el-button {
  817. transform: scale(0.5);
  818. background: #c0c4cc;
  819. }
  820. .employee_selector_box .choose_right .employee_delete .el-button /deep/ .el-icon-close {
  821. color: #fff;
  822. }
  823. .employee_selector_box .choose_right .employee_delete .el-button:active {
  824. background: #409EFF;
  825. }
  826. .employee_selector_box .choose_right .employee_delete .el-button:active /deep/ .el-icon-close {
  827. color: #fff;
  828. }
  829. .employee_selector_box .choose_right .employee_cell .employee_name {
  830. padding-left: 8px;
  831. }
  832. .employee_selector_box .choose_right .employee_cell .employee_img_url {
  833. padding-left: 8px;
  834. }
  835. /* 右边距 */
  836. .employee_selector_box /deep/ .employee_cell {
  837. padding: 8px 0;
  838. border-bottom: 1px #f1f1f1 solid;
  839. }
  840. .employee_selector_box /deep/ .employee_cell:hover {
  841. background: #ecf5ff;
  842. }
  843. .employee_cell {
  844. display: -webkit-inline-box;
  845. cursor: pointer;
  846. width: 100%;
  847. color: #606266;
  848. padding: 8px 0;
  849. background-color: transparent;
  850. }
  851. .employee_cell .employee_cell_clear {
  852. clear: both;
  853. }
  854. .employee_cell .employee_img_url {
  855. display: table-cell;
  856. vertical-align: middle;
  857. width: 30px;
  858. padding-left: 0px;
  859. }
  860. .employee_cell .employee_img_url img {
  861. width: 24px;
  862. height: 24px;
  863. border-radius: 50%;
  864. }
  865. .employee_cell .employee_checkbox {
  866. display: table-cell;
  867. vertical-align: middle;
  868. width: 30px;
  869. text-align: center;
  870. }
  871. .employee_cell .employee_name {
  872. display: table-cell;
  873. vertical-align: middle;
  874. color: #606266;
  875. }
  876. .employee_delete {
  877. display: table-cell;
  878. text-align: right;
  879. padding-right: 0px;
  880. }
  881. .employee_cell_a {
  882. display: block;
  883. }
  884. .employee_cell_a:hover {
  885. background-color: #ecf5ff;
  886. border-radius: 4px;
  887. }
  888. .dept_child_cell {
  889. display: table-cell;
  890. vertical-align: middle;
  891. }
  892. .dept_child_cell span {
  893. float: right;
  894. padding-right: 8px;
  895. }
  896. .dept_child_cell span:hover {
  897. color: #1c1c1c;
  898. }
  899. .dept_child_cell span:active {
  900. color: #1c1c1c;
  901. }
  902. .scroller-box {
  903. height: 440px;
  904. padding-right: 0px !important;
  905. background-color: #fdfdfd;
  906. border: 1px solid #eee;
  907. border-radius: 4px;
  908. overflow: hidden;
  909. }
  910. /* .scroller-box.one{
  911. height: 440px;
  912. } */
  913. .col-line {
  914. position: relative;
  915. height: 400px;
  916. }
  917. .col-line:before {
  918. content: ' ';
  919. width: 1px;
  920. height: 400px;
  921. position: absolute;
  922. top: 0;
  923. bottom: 0;
  924. left: 50%;
  925. background-color: #eee;
  926. }
  927. .search-box {
  928. background-color: #fff;
  929. padding: 14px 5px;
  930. border-bottom: 1px solid #eee;
  931. margin: 0 -5px;
  932. }
  933. .option-box {
  934. padding: 5px;
  935. background-color: #fff;
  936. border-bottom: 1px solid #eee;
  937. margin: 0 -5px;
  938. text-align: right;
  939. }
  940. .child_btn {
  941. color: #409EFF;
  942. }
  943. .dept_path {
  944. padding: 10px 0;
  945. border-bottom: 1px solid #f1f1f1;
  946. min-height: 37px;
  947. }
  948. .scrollbarHeight1 {
  949. height: 310px;
  950. }
  951. .scrollbarHeight2 {
  952. height: 350px;
  953. }
  954. </style>