EmployeeSelector.vue 29 KB

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