EmployeeSelector.vue 29 KB

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