|
@@ -4,30 +4,31 @@
|
|
|
<el-row :gutter="10">
|
|
|
<el-col :xs="11" :sm="11" :md="11" :lg="11" :xl="11" class="scroller-box one">
|
|
|
<div class="search-box">
|
|
|
- <div class="search flex-box" style="margin-bottom: 7px;">
|
|
|
- <el-input v-model="keyword" placeholder="请输入姓名" clearable></el-input>
|
|
|
- </div>
|
|
|
+ <div class="search flex-box" style="margin-bottom: 7px;"><el-input v-model="keyword" placeholder="请输入姓名" clearable></el-input></div>
|
|
|
<div class="search flex-box" v-if="can_select_dept">
|
|
|
- <el-cascader
|
|
|
- v-model="dept_id"
|
|
|
- ref="dept"
|
|
|
- :options="dept_list"
|
|
|
- :props="{ checkStrictly: true,value:'id',label:'name',children:'_child'}"
|
|
|
- clearable
|
|
|
- filterable
|
|
|
- placeholder="全公司">
|
|
|
- </el-cascader>
|
|
|
+ <el-cascader
|
|
|
+ v-model="dept_id"
|
|
|
+ ref="dept"
|
|
|
+ :options="dept_list"
|
|
|
+ :props="{ checkStrictly: true, value: 'id', label: 'name', children: '_child' }"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ placeholder="全公司"
|
|
|
+ ></el-cascader>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="flex-box" style="padding: 10px;border-bottom: 1px solid #f1f1f1;">
|
|
|
- <div class="flex-1"></div>
|
|
|
- <el-checkbox v-if="isChecKedAll&&multi" v-model="checked" @change="checkedChange" :indeterminate="indeterminate">全选</el-checkbox>
|
|
|
+ <div class="flex-box-end" style="padding: 10px;border-bottom: 1px solid #f1f1f1;height: 40px;box-sizing: border-box;">
|
|
|
+ <el-checkbox v-if="isChecKedAll && multi" v-model="checked" @change="checkedChange" :indeterminate="indeterminate">全选</el-checkbox>
|
|
|
</div>
|
|
|
- <el-scrollbar wrap-class="column-wrapper scrollable-items-container" :style="{height: height}" :native="false" v-loading="table_loading">
|
|
|
+ <el-scrollbar :style="{ height: can_select_dept ? '310px' : '350px' }" :native="false" v-loading="table_loading">
|
|
|
<div class="choose_left">
|
|
|
<div class="persons_box" style="padding-top:4px;" v-if="list.length > 0">
|
|
|
<a class="employee_cell_a" href="javascript:void(0)" v-for="(item, index) in list" :key="index">
|
|
|
- <div class="employee_cell flex-box flex-v-ce" v-if="can_select_employee&& item.name.indexOf(keyword) >= 0" @click.prevent.stop="select_employee(item)">
|
|
|
+ <div
|
|
|
+ class="employee_cell flex-box flex-v-ce"
|
|
|
+ v-if="can_select_employee && item.name.indexOf(keyword) >= 0"
|
|
|
+ @click.prevent.stop="select_employee(item)"
|
|
|
+ >
|
|
|
<div class="employee_checkbox"><el-checkbox v-model="item.checked"></el-checkbox></div>
|
|
|
<userImage :user_name="item.name" :img_url="item.img_url" width="30px" height="30px"></userImage>
|
|
|
<div class="employee_name">{{ item.name }}</div>
|
|
@@ -52,7 +53,6 @@
|
|
|
<div class="employee_delete"><el-button type="default" size="mini" @click="dept_cancel(item)" icon="el-icon-close" circle></el-button></div>
|
|
|
<div class="employee_cell_clear"></div>
|
|
|
</div>
|
|
|
-
|
|
|
<div class="employee_cell" v-for="(item, index) in employee_selected_list" :key="index">
|
|
|
<userImage :user_name="item.name" :img_url="item.img_url" width="30px" height="30px"></userImage>
|
|
|
<div class="employee_name">{{ item.name }}</div>
|
|
@@ -70,362 +70,384 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-
|
|
|
export default {
|
|
|
- props: {
|
|
|
- can_select_dept: {//指定是否能选择部门
|
|
|
- type: Boolean,
|
|
|
- default: true
|
|
|
- },
|
|
|
- can_select_employee: {//指定是否能选择员工
|
|
|
- type: Boolean,
|
|
|
- default: true
|
|
|
- },
|
|
|
- selected: {//已经选择的员工和部门
|
|
|
- type: Object,
|
|
|
- default: () => {
|
|
|
- return {
|
|
|
- employee: [],
|
|
|
- dept: []
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- multi: {//指定员工是否能多选
|
|
|
- type: Boolean,
|
|
|
- default: true
|
|
|
- },
|
|
|
- dept_multi: {//指定部门是否能多选
|
|
|
- type: Boolean,
|
|
|
- default: true
|
|
|
- },
|
|
|
- employee_list: {//指定显示的员工列表,注意:传值后组件的员工数据将不是统一向服务器获取的,而是指定的员工列表,格式是:[{id: 1, name: “张三”, img_url: “”}]
|
|
|
- type: Array,
|
|
|
- default: () => {
|
|
|
- return []
|
|
|
- }
|
|
|
- },
|
|
|
- close_clear_data: {//关闭时是否清空选择的数据
|
|
|
- type: Boolean,
|
|
|
- default: true
|
|
|
- },
|
|
|
- max: {//当multi为true时,用来限制选择人数,0不生效
|
|
|
- type: Number,
|
|
|
- default: 0
|
|
|
- },
|
|
|
- user_no_select:{//是否能选择创始人
|
|
|
- type: Boolean,
|
|
|
- default: true
|
|
|
- },
|
|
|
- isChecKedAll:{//是否能全人员
|
|
|
- type: Boolean,
|
|
|
- default: true
|
|
|
- },
|
|
|
- my_no_select:{//当前设置人的id,过滤某位人员,一般为自己
|
|
|
- type: Number,
|
|
|
- default: 0
|
|
|
- },
|
|
|
- isCreatorSelect:{//当employee_list为空时,依然显示空值而不是显示人员列表
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
- use_Administrator_list:{//未指定员工并请求人员接口时,保留管理员,过滤员工
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- name: "EmployeeSelector",
|
|
|
- data() {
|
|
|
- let selected = JSON.parse(JSON.stringify(this.selected));
|
|
|
- let user_no_select = JSON.parse(JSON.stringify(this.user_no_select));
|
|
|
- let height=this.can_select_dept? '310px':'350px'
|
|
|
- return {
|
|
|
- table_loading:false,
|
|
|
- employee_selected_list: selected.employee,
|
|
|
- dept_selected_list: selected.dept,
|
|
|
- employee_selected: [],
|
|
|
- dept_selected: [],
|
|
|
- com_height: '100%',
|
|
|
-
|
|
|
- height:height,
|
|
|
- list: [],//人员列表
|
|
|
- dept_name: '',//部门名称
|
|
|
- dept_id: 0,//部门ID
|
|
|
- pid:0,//部门ID实传
|
|
|
- dept_list: [],//部门列表
|
|
|
- dept_list_arr: [],//收集的部门
|
|
|
- keyword: '',//搜索值
|
|
|
- checked: false,//是否全选
|
|
|
- indeterminate: false,
|
|
|
- not_user: user_no_select,
|
|
|
- all_list:[],
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- dept_id(val){
|
|
|
- if(val.length>1){
|
|
|
- this.pid=val[val.length-1];
|
|
|
- }else{
|
|
|
- this.pid=val[0];
|
|
|
+ props: {
|
|
|
+ can_select_dept: {
|
|
|
+ //指定是否能选择部门
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ can_select_employee: {
|
|
|
+ //指定是否能选择员工
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ selected: {
|
|
|
+ //已经选择的员工和部门
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return {
|
|
|
+ employee: [],
|
|
|
+ dept: []
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ multi: {
|
|
|
+ //指定员工是否能多选
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ dept_multi: {
|
|
|
+ //指定部门是否能多选
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ employee_list: {
|
|
|
+ //指定显示的员工列表,注意:传值后组件的员工数据将不是统一向服务器获取的,而是指定的员工列表,格式是:[{id: 1, name: “张三”, img_url: “”}]
|
|
|
+ type: Array,
|
|
|
+ default: () => {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close_clear_data: {
|
|
|
+ //关闭时是否清空选择的数据
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ max: {
|
|
|
+ //当multi为true时,用来限制选择人数,0不生效
|
|
|
+ type: Number,
|
|
|
+ default: 0
|
|
|
+ },
|
|
|
+ user_no_select: {
|
|
|
+ //是否能选择创始人
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ isChecKedAll: {
|
|
|
+ //是否能全人员
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ my_no_select: {
|
|
|
+ //当前设置人的id,过滤某位人员,一般为自己
|
|
|
+ type: Number,
|
|
|
+ default: 0
|
|
|
+ },
|
|
|
+ isCreatorSelect: {
|
|
|
+ //当employee_list为空时,依然显示空值而不是显示人员列表
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ use_Administrator_list: {
|
|
|
+ //未指定员工并请求人员接口时,保留管理员,过滤员工
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.dept.dropDownVisible = false;
|
|
|
- this.get_user_list();
|
|
|
- this.checked=false;
|
|
|
- });
|
|
|
},
|
|
|
- selected(val) {
|
|
|
- let selected = JSON.parse(JSON.stringify(val))
|
|
|
- this.employee_selected = []
|
|
|
- this.dept_selected = []
|
|
|
- this.employee_selected_list = selected.employee
|
|
|
- this.dept_selected_list = selected.dept
|
|
|
- for (let i in selected.employee) {
|
|
|
- this.employee_selected.push(selected.employee[i].id)
|
|
|
- }
|
|
|
- for (let i in selected.dept) {
|
|
|
- this.dept_selected.push(selected.dept[i].dept_id)
|
|
|
- }
|
|
|
- },
|
|
|
- //搜索
|
|
|
- keyword(val) {
|
|
|
- this.checked=false;
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- //全选择
|
|
|
- checkedChange(val){
|
|
|
- if (val) {
|
|
|
- for (let i in this.list) {
|
|
|
- this.$set(this.list[i], 'checked', true)
|
|
|
- }
|
|
|
- this.$nextTick(() => {
|
|
|
- let employeeSelectedList = JSON.parse(JSON.stringify(this.employee_selected_list))
|
|
|
- let employeeSelectedIds = [], total = 0
|
|
|
- employeeSelectedList.forEach(element => {
|
|
|
- employeeSelectedIds.push(element.id)
|
|
|
- });
|
|
|
- for (const i in this.list) {
|
|
|
- if (employeeSelectedIds.includes(this.list[i].id)) {
|
|
|
- total += 1
|
|
|
- }else{
|
|
|
- this.employee_selected_list.push(this.list[i])
|
|
|
- }
|
|
|
- }
|
|
|
- this.list.length == total?this.indeterminate = true:this.indeterminate = false
|
|
|
- })
|
|
|
- }else{
|
|
|
- this.clear_data()
|
|
|
- }
|
|
|
- },
|
|
|
- //添加或移除已添加的员工
|
|
|
- employee_cancel(item) {
|
|
|
- this.employee_selected_list.map((arr,index)=>{
|
|
|
- if(arr.id==item.id){
|
|
|
- this.employee_selected_list.splice(index,1);
|
|
|
- }
|
|
|
- })
|
|
|
- this.list.map((arr,index)=>{
|
|
|
- if(arr.id==item.id){
|
|
|
- this.$set(arr, 'checked', false)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- //获取部门
|
|
|
- get_dept_list() {
|
|
|
- this.$axios('get','/api/department/tree').then(res => {
|
|
|
- this.dept_list =this.getTreeData(res.data.data.list);
|
|
|
- });
|
|
|
+ name: 'EmployeeSelector',
|
|
|
+ data() {
|
|
|
+ let selected = JSON.parse(JSON.stringify(this.selected));
|
|
|
+ let user_no_select = JSON.parse(JSON.stringify(this.user_no_select));
|
|
|
+ return {
|
|
|
+ table_loading: false,
|
|
|
+ employee_selected_list: selected.employee,
|
|
|
+ dept_selected_list: selected.dept,
|
|
|
+ employee_selected: [],
|
|
|
+ dept_selected: [],
|
|
|
+ com_height: '100%',
|
|
|
+ list: [], //人员列表
|
|
|
+ dept_name: '', //部门名称
|
|
|
+ dept_id: 0, //部门ID
|
|
|
+ pid: 0, //部门ID实传
|
|
|
+ dept_list: [], //部门列表
|
|
|
+ dept_list_arr: [], //收集的部门
|
|
|
+ keyword: '', //搜索值
|
|
|
+ checked: false, //是否全选
|
|
|
+ indeterminate: false,
|
|
|
+ not_user: user_no_select,
|
|
|
+ all_list: []
|
|
|
+ };
|
|
|
},
|
|
|
- // 递归判断列表,把最后的children设为undefined
|
|
|
- getTreeData(data) {
|
|
|
- for (var i = 0; i < data.length; i++) {
|
|
|
- if (data[i]._child.length < 1) {
|
|
|
- // children若为空数组,则将children设为undefined
|
|
|
- data[i]._child = undefined;
|
|
|
+ watch: {
|
|
|
+ dept_id(val) {
|
|
|
+ if (val.length > 1) {
|
|
|
+ this.pid = val[val.length - 1];
|
|
|
} else {
|
|
|
- // children若不为空数组,则继续 递归调用 本方法
|
|
|
- this.getTreeData(data[i]._child);
|
|
|
+ this.pid = val[0];
|
|
|
}
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.dept.dropDownVisible = false;
|
|
|
+ this.get_user_list();
|
|
|
+ this.checked = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ selected(val) {
|
|
|
+ let selected = JSON.parse(JSON.stringify(val));
|
|
|
+ this.employee_selected = [];
|
|
|
+ this.dept_selected = [];
|
|
|
+ this.employee_selected_list = selected.employee;
|
|
|
+ this.dept_selected_list = selected.dept;
|
|
|
+ for (let i in selected.employee) {
|
|
|
+ this.employee_selected.push(selected.employee[i].id);
|
|
|
+ }
|
|
|
+ for (let i in selected.dept) {
|
|
|
+ this.dept_selected.push(selected.dept[i].dept_id);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //搜索
|
|
|
+ keyword(val) {
|
|
|
+ this.checked = false;
|
|
|
}
|
|
|
- return data;
|
|
|
- },
|
|
|
- //选择部门
|
|
|
- dept_cancel(item) {
|
|
|
- this.dept_selected.splice(this.dept_selected.indexOf(item.id), 1)
|
|
|
- let delete_index = -1
|
|
|
- for (let i in this.dept_selected_list) {
|
|
|
- if (this.dept_selected.indexOf(this.dept_selected_list[i].id) < 0) {
|
|
|
- delete_index = i
|
|
|
- }
|
|
|
- }
|
|
|
- if (delete_index >= 0) {
|
|
|
- this.dept_selected_list.splice(delete_index, 1)
|
|
|
- for (let i in this.dept_list) {
|
|
|
- if (this.dept_list[i].dept_id == item.id) {
|
|
|
- this.$set(this.dept_list[i], 'checked', false)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- //选择员工
|
|
|
- select_employee(item) {
|
|
|
- if (item.checked) {
|
|
|
- item.checked = false
|
|
|
- this.employee_cancel(item)
|
|
|
- } else {
|
|
|
- if (!this.multi) {
|
|
|
- this.employee_selected = []
|
|
|
- this.employee_selected_list = []
|
|
|
- for (let i in this.list) {
|
|
|
- this.$set(this.list[i], 'checked', false)
|
|
|
- }
|
|
|
- }
|
|
|
- if (this.max > 0 && this.employee_selected_list.length == this.max && this.multi) {
|
|
|
- this.$message.error('最多只能选择' + this.max + '人')
|
|
|
- return false
|
|
|
- }
|
|
|
- this.employee_selected.push(item.id)
|
|
|
- this.employee_selected_list.push({
|
|
|
- id: item.id,
|
|
|
- name: item.name,
|
|
|
- img_url: item.img_url
|
|
|
- })
|
|
|
- item.checked = true
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- clear_data() {
|
|
|
- this.employee_selected = []
|
|
|
- this.employee_selected_list = []
|
|
|
- this.dept_selected = []
|
|
|
- this.dept_selected_list = []
|
|
|
- this.checked = false
|
|
|
- for (let i in this.list) {
|
|
|
- this.$set(this.list[i], 'checked', false)
|
|
|
- }
|
|
|
- for (let i in this.dept_list) {
|
|
|
- this.$set(this.dept_list[i], 'checked', false)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- close() {
|
|
|
- if (this.close_clear_data) {
|
|
|
- this.employee_selected = []
|
|
|
- this.employee_selected_list = []
|
|
|
- this.dept_selected = []
|
|
|
- this.dept_selected_list = []
|
|
|
- for (let i in this.list) {
|
|
|
- this.$set(this.list[i], 'checked', false)
|
|
|
- }
|
|
|
- for (let i in this.dept_list) {
|
|
|
- this.$set(this.dept_list[i], 'checked', false)
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- confirm() {
|
|
|
- this.$emit('confirm', {
|
|
|
- employee: this.employee_selected_list,
|
|
|
- dept: this.dept_selected_list
|
|
|
- })
|
|
|
- this.close()
|
|
|
},
|
|
|
- filtration(){//获取员工列表,限制已禁用的员工
|
|
|
- this.$axios('get','/api/employee/index',{ dept_id: 0, page: 0,page_size: 2000}).then((res) => {
|
|
|
- if(res.data.code == 1){
|
|
|
- let list = res.data.data.list
|
|
|
- let data = []
|
|
|
- list.forEach((item,index)=>{
|
|
|
- if(item.is_official == 1){
|
|
|
- data.push(item)
|
|
|
+ methods: {
|
|
|
+ //全选择
|
|
|
+ checkedChange(val) {
|
|
|
+ if (val) {
|
|
|
+ for (let i in this.list) {
|
|
|
+ this.$set(this.list[i], 'checked', true);
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ let employeeSelectedList = JSON.parse(JSON.stringify(this.employee_selected_list));
|
|
|
+ let employeeSelectedIds = [],
|
|
|
+ total = 0;
|
|
|
+ employeeSelectedList.forEach(element => {
|
|
|
+ employeeSelectedIds.push(element.id);
|
|
|
+ });
|
|
|
+ for (const i in this.list) {
|
|
|
+ if (employeeSelectedIds.includes(this.list[i].id)) {
|
|
|
+ total += 1;
|
|
|
+ } else {
|
|
|
+ this.employee_selected_list.push(this.list[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.list.length == total ? (this.indeterminate = true) : (this.indeterminate = false);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.clear_data();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //添加或移除已添加的员工
|
|
|
+ employee_cancel(item) {
|
|
|
+ this.employee_selected_list.map((arr, index) => {
|
|
|
+ if (arr.id == item.id) {
|
|
|
+ this.employee_selected_list.splice(index, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.list.map((arr, index) => {
|
|
|
+ if (arr.id == item.id) {
|
|
|
+ this.$set(arr, 'checked', false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //获取部门
|
|
|
+ get_dept_list() {
|
|
|
+ this.$axios('get', '/api/department/tree').then(res => {
|
|
|
+ this.dept_list = this.getTreeData(res.data.data.list);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 递归判断列表,把最后的children设为undefined
|
|
|
+ getTreeData(data) {
|
|
|
+ for (var i = 0; i < data.length; i++) {
|
|
|
+ if (data[i]._child.length < 1) {
|
|
|
+ // children若为空数组,则将children设为undefined
|
|
|
+ data[i]._child = undefined;
|
|
|
+ } else {
|
|
|
+ // children若不为空数组,则继续 递归调用 本方法
|
|
|
+ this.getTreeData(data[i]._child);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ //选择部门
|
|
|
+ dept_cancel(item) {
|
|
|
+ this.dept_selected.splice(this.dept_selected.indexOf(item.id), 1);
|
|
|
+ let delete_index = -1;
|
|
|
+ for (let i in this.dept_selected_list) {
|
|
|
+ if (this.dept_selected.indexOf(this.dept_selected_list[i].id) < 0) {
|
|
|
+ delete_index = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (delete_index >= 0) {
|
|
|
+ this.dept_selected_list.splice(delete_index, 1);
|
|
|
+ for (let i in this.dept_list) {
|
|
|
+ if (this.dept_list[i].dept_id == item.id) {
|
|
|
+ this.$set(this.dept_list[i], 'checked', false);
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
- this.userdatars(data)
|
|
|
- }else{
|
|
|
- this.userdatars()
|
|
|
- }
|
|
|
- }).catch(()=>{
|
|
|
- this.userdatars()
|
|
|
- }).finally(()=>{
|
|
|
-
|
|
|
- })
|
|
|
- },
|
|
|
- userdatars(userlist){
|
|
|
- var employee_selected_list=this.employee_selected_list;
|
|
|
- let list = this.employee_list
|
|
|
- if(userlist){
|
|
|
- list = [...list].filter(x => [...userlist].some(y => y.id === x.id))
|
|
|
- }
|
|
|
- list.map((item)=>{
|
|
|
- item['checked'] = false;
|
|
|
- for(var i in employee_selected_list){//判断传进来的员工是否是员工集合里的,是就设为已点击状态
|
|
|
- if(employee_selected_list[i].id==item.id){
|
|
|
- item['checked'] = true;
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- this.list=list;
|
|
|
- this.table_loading = false;
|
|
|
- },
|
|
|
- //获取员工详情
|
|
|
- get_user_list() {
|
|
|
- this.table_loading = true;
|
|
|
- var that=this;
|
|
|
- var employee_selected_list=this.employee_selected_list;
|
|
|
- if (this.employee_list.length > 0||this.isCreatorSelect) {
|
|
|
- this.filtration()
|
|
|
- return false
|
|
|
- }
|
|
|
- this.list = []
|
|
|
- this.$axios('get','/api/employee/index',{ dept_id: this.pid,keywords: this.keyword, page: 0,page_size: 2000}).then((res) => {
|
|
|
- var employee=res.data.data.list||[];
|
|
|
- if(this.use_Administrator_list){//使用管理员列表
|
|
|
- employee = this.useAdministratorList(employee)
|
|
|
- }
|
|
|
- var userAll=[];
|
|
|
- employee.forEach((item,i)=>{
|
|
|
- if(!this.not_user && item.is_creator == 1){//过滤创始人
|
|
|
- return null;
|
|
|
- }else if(this.my_no_select==item.id){//过滤掉当前设置人
|
|
|
- return null;
|
|
|
- }else if(item.is_official==1){
|
|
|
- userAll.push(item);
|
|
|
}
|
|
|
- })
|
|
|
- userAll.map((item)=>{
|
|
|
- item['checked'] = false;
|
|
|
- for(var i in employee_selected_list){//判断传进来的员工是否是员工集合里的,是就设为已点击状态
|
|
|
- if(employee_selected_list[i].id==item.id){
|
|
|
- item['checked'] = true;
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- that.list = userAll
|
|
|
- }).finally(() => {
|
|
|
- that.table_loading = false;
|
|
|
- })
|
|
|
+ },
|
|
|
+ //选择员工
|
|
|
+ select_employee(item) {
|
|
|
+ if (item.checked) {
|
|
|
+ item.checked = false;
|
|
|
+ this.employee_cancel(item);
|
|
|
+ } else {
|
|
|
+ if (!this.multi) {
|
|
|
+ this.employee_selected = [];
|
|
|
+ this.employee_selected_list = [];
|
|
|
+ for (let i in this.list) {
|
|
|
+ this.$set(this.list[i], 'checked', false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.max > 0 && this.employee_selected_list.length == this.max && this.multi) {
|
|
|
+ this.$message.error('最多只能选择' + this.max + '人');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.employee_selected.push(item.id);
|
|
|
+ this.employee_selected_list.push({
|
|
|
+ id: item.id,
|
|
|
+ name: item.name,
|
|
|
+ img_url: item.img_url
|
|
|
+ });
|
|
|
+ item.checked = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ clear_data() {
|
|
|
+ this.employee_selected = [];
|
|
|
+ this.employee_selected_list = [];
|
|
|
+ this.dept_selected = [];
|
|
|
+ this.dept_selected_list = [];
|
|
|
+ this.checked = false;
|
|
|
+ for (let i in this.list) {
|
|
|
+ this.$set(this.list[i], 'checked', false);
|
|
|
+ }
|
|
|
+ for (let i in this.dept_list) {
|
|
|
+ this.$set(this.dept_list[i], 'checked', false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ close() {
|
|
|
+ if (this.close_clear_data) {
|
|
|
+ this.employee_selected = [];
|
|
|
+ this.employee_selected_list = [];
|
|
|
+ this.dept_selected = [];
|
|
|
+ this.dept_selected_list = [];
|
|
|
+ for (let i in this.list) {
|
|
|
+ this.$set(this.list[i], 'checked', false);
|
|
|
+ }
|
|
|
+ for (let i in this.dept_list) {
|
|
|
+ this.$set(this.dept_list[i], 'checked', false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ confirm() {
|
|
|
+ this.$emit('confirm', {
|
|
|
+ employee: this.employee_selected_list,
|
|
|
+ dept: this.dept_selected_list
|
|
|
+ });
|
|
|
+ this.close();
|
|
|
+ },
|
|
|
+ filtration() {
|
|
|
+ //获取员工列表,限制已禁用的员工
|
|
|
+ this.$axios('get', '/api/employee/index', { dept_id: this.pid, page: 0, page_size: 2000 })
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code == 1) {
|
|
|
+ let list = res.data.data.list;
|
|
|
+ let data = [];
|
|
|
+ list.forEach((item, index) => {
|
|
|
+ if (item.is_official == 1) {
|
|
|
+ data.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.userdatars(data);
|
|
|
+ } else {
|
|
|
+ this.userdatars();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.userdatars();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ userdatars(userlist) {
|
|
|
+ var employee_selected_list = this.employee_selected_list;
|
|
|
+ let list = this.employee_list;
|
|
|
+ if (userlist) {
|
|
|
+ list = [...userlist].filter(x => [...list].some(y => y.id === x.id));
|
|
|
+ }
|
|
|
+ list.map(item => {
|
|
|
+ item['checked'] = false;
|
|
|
+ for (var i in employee_selected_list) {
|
|
|
+ //判断传进来的员工是否是员工集合里的,是就设为已点击状态
|
|
|
+ if (employee_selected_list[i].id == item.id) {
|
|
|
+ item['checked'] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.list = list;
|
|
|
+ this.table_loading = false;
|
|
|
+ },
|
|
|
+ //获取员工详情
|
|
|
+ get_user_list() {
|
|
|
+ this.table_loading = true;
|
|
|
+ var that = this;
|
|
|
+ var employee_selected_list = this.employee_selected_list;
|
|
|
+ if (this.employee_list.length > 0 || this.isCreatorSelect) {
|
|
|
+ this.filtration();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.list = [];
|
|
|
+ this.$axios('get', '/api/employee/index', { dept_id: this.pid, keywords: this.keyword, page: 0, page_size: 2000 })
|
|
|
+ .then(res => {
|
|
|
+ var employee = res.data.data.list || [];
|
|
|
+ if (this.use_Administrator_list) {
|
|
|
+ //使用管理员列表
|
|
|
+ employee = this.useAdministratorList(employee);
|
|
|
+ }
|
|
|
+ var userAll = [];
|
|
|
+ employee.forEach((item, i) => {
|
|
|
+ if (!this.not_user && item.is_creator == 1) {
|
|
|
+ //过滤创始人
|
|
|
+ return null;
|
|
|
+ } else if (this.my_no_select == item.id) {
|
|
|
+ //过滤掉当前设置人
|
|
|
+ return null;
|
|
|
+ } else if (item.is_official == 1) {
|
|
|
+ userAll.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ userAll.map(item => {
|
|
|
+ item['checked'] = false;
|
|
|
+ for (var i in employee_selected_list) {
|
|
|
+ //判断传进来的员工是否是员工集合里的,是就设为已点击状态
|
|
|
+ if (employee_selected_list[i].id == item.id) {
|
|
|
+ item['checked'] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ that.list = userAll;
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ that.table_loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ useAdministratorList(list) {
|
|
|
+ //过滤掉普通员工,返回管理员
|
|
|
+ let arr = [];
|
|
|
+ list.forEach((item, i) => {
|
|
|
+ if (
|
|
|
+ item.employee_detail.role_list.findIndex(
|
|
|
+ value => value.name == 'dept_manager' || value.name == 'creator' || value.name == 'point_manager' || value.name == 'admin'
|
|
|
+ ) >= 0
|
|
|
+ ) {
|
|
|
+ arr.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return arr;
|
|
|
+ }
|
|
|
},
|
|
|
- useAdministratorList(list){//过滤掉普通员工,返回管理员
|
|
|
- let arr = []
|
|
|
- list.forEach((item,i)=>{
|
|
|
- if (item.employee_detail.role_list.findIndex((value)=>value.name=='dept_manager'||value.name=='creator'||value.name=='point_manager'||value.name=='admin') >= 0) {
|
|
|
- arr.push(item)
|
|
|
+ created() {
|
|
|
+ var that = this;
|
|
|
+ that.checked = false;
|
|
|
+ setTimeout(() => {
|
|
|
+ that.get_user_list();
|
|
|
+ if (that.can_select_dept) {
|
|
|
+ that.get_dept_list();
|
|
|
}
|
|
|
- })
|
|
|
- return arr
|
|
|
+ }, 200);
|
|
|
}
|
|
|
- },
|
|
|
- created() {
|
|
|
- var that=this;
|
|
|
- that.checked=false;
|
|
|
- setTimeout(() => {
|
|
|
- that.get_user_list();
|
|
|
- if(that.can_select_dept){
|
|
|
- that.get_dept_list();
|
|
|
- }
|
|
|
- }, 200)
|
|
|
- }
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
@@ -447,7 +469,6 @@ a {
|
|
|
width: 80%;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/* 左边框 */
|
|
|
.employee_selector_box .choose_left {
|
|
|
padding: 8px 10px 8px 10px;
|
|
@@ -473,13 +494,11 @@ a {
|
|
|
padding-left: 8px;
|
|
|
}
|
|
|
|
|
|
-.employee_selector_box ::v-deep .el-scrollbar__thumb {
|
|
|
+/* .employee_selector_box ::v-deep .el-scrollbar__thumb {
|
|
|
width: 2px;
|
|
|
margin: 15px 0 0 6px;
|
|
|
background: #409eff;
|
|
|
-}
|
|
|
-
|
|
|
-/* 左边框 */
|
|
|
+} */
|
|
|
|
|
|
/* 右边距 */
|
|
|
.employee_selector_box .option-box {
|
|
@@ -532,6 +551,7 @@ a {
|
|
|
color: #606266;
|
|
|
padding: 8px 0;
|
|
|
background-color: transparent;
|
|
|
+ border-bottom: 1px #f1f1f1 solid;
|
|
|
}
|
|
|
|
|
|
.employee_cell .employee_cell_clear {
|