2024-05-07 04:53:57 +00:00
|
|
|
<template>
|
|
|
|
|
<div :id="createdId">
|
|
|
|
|
<el-popover
|
|
|
|
|
placement="bottom"
|
|
|
|
|
trigger="click"
|
|
|
|
|
ref="popoverRef"
|
|
|
|
|
effect="light"
|
|
|
|
|
:show-arrow="false"
|
|
|
|
|
>
|
|
|
|
|
<span slot="reference">
|
|
|
|
|
<el-input ref="inputValue" :value="slable" :placeholder="splaceholder" @input="changeValue" @focus="onfocus" @blur="onblur" @clear="onclear" clearable >
|
|
|
|
|
<template slot="suffix">
|
|
|
|
|
<i class="el-icon-arrow-down select-down" :class="visible&&'rotate180'"></i>
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
</span>
|
|
|
|
|
<div >
|
2024-05-12 21:26:33 +00:00
|
|
|
<!-- class="el-table--scrollable-y" border max-height="300px" -->
|
|
|
|
|
<el-table
|
|
|
|
|
v-loading="loading"
|
2024-05-07 04:53:57 +00:00
|
|
|
style="width: 100%;"
|
2024-05-12 21:26:33 +00:00
|
|
|
:data="dataList"
|
|
|
|
|
@row-click="onRowClick"
|
|
|
|
|
stripe
|
|
|
|
|
size="mini"
|
2024-05-07 04:53:57 +00:00
|
|
|
element-loading-text="Loading" ref="comboGridTable" fit highlight-current-row>
|
2024-05-12 21:26:33 +00:00
|
|
|
<!-- <el-table-column label="序号" align="center" min-width="50">
|
2024-05-07 04:53:57 +00:00
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<span v-text="getIndex(scope.$index)"> </span>
|
|
|
|
|
</template>
|
2024-05-12 21:26:33 +00:00
|
|
|
</el-table-column> -->
|
|
|
|
|
<el-table-column label="员工编号" align="left" prop="empCode" width="100" />
|
|
|
|
|
<el-table-column label="员工名称" align="center" prop="empName" width="100" :show-overflow-tooltip="true" />
|
|
|
|
|
<el-table-column label="所属网点" align="center" prop="ownerSiteName" width="100" :show-overflow-tooltip="true" />
|
2024-05-07 04:53:57 +00:00
|
|
|
|
|
|
|
|
</el-table>
|
|
|
|
|
<el-pagination v-show="pagination" small
|
|
|
|
|
:total="total"
|
|
|
|
|
:page-size="5"
|
|
|
|
|
layout="prev, pager, next, total"
|
|
|
|
|
@current-change="changePage"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
import emitter from 'element-ui/src/mixins/emitter';
|
|
|
|
|
import { getStaffList } from "@/api/emis/emisStaff";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "EmisUserSimplePicker",
|
|
|
|
|
mixins: [emitter],
|
|
|
|
|
props: {
|
|
|
|
|
value: {
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
required: false
|
|
|
|
|
},
|
|
|
|
|
sideCode: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: false
|
|
|
|
|
},
|
|
|
|
|
postCode:{
|
|
|
|
|
type: String,
|
|
|
|
|
required: false
|
|
|
|
|
},
|
|
|
|
|
isInitiated:{
|
|
|
|
|
type: [Boolean,String],
|
|
|
|
|
required: false,
|
|
|
|
|
default:false
|
|
|
|
|
},
|
|
|
|
|
placeholder:{
|
|
|
|
|
type: String,
|
|
|
|
|
required: false
|
|
|
|
|
},
|
|
|
|
|
disabled:{
|
|
|
|
|
type: [Boolean,String],
|
|
|
|
|
required: false
|
|
|
|
|
},
|
|
|
|
|
pagination: {
|
|
|
|
|
type: Boolean, default: true
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
createdId: '0',
|
|
|
|
|
loading:false,
|
|
|
|
|
visible:false,
|
|
|
|
|
dataList: [],
|
|
|
|
|
total:0,
|
|
|
|
|
svalue: this.value,
|
|
|
|
|
slable: null,
|
|
|
|
|
isEdit:false,
|
|
|
|
|
splaceholder:this.placeholder,
|
|
|
|
|
firstFlag:true,
|
|
|
|
|
queryParams:{
|
|
|
|
|
pageNum:1,
|
|
|
|
|
pageSize:5,
|
2024-05-21 08:45:05 +00:00
|
|
|
empCode:this.value,
|
2024-05-07 04:53:57 +00:00
|
|
|
searchValue:null,
|
2024-05-16 22:28:20 +00:00
|
|
|
ownerSiteCode:null,
|
|
|
|
|
postCode:null
|
2024-05-07 04:53:57 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
value(newVal,oldVal) {
|
|
|
|
|
this.svalue = newVal;
|
2024-05-16 22:28:20 +00:00
|
|
|
console.log("empCode1==>"+newVal);
|
|
|
|
|
console.log("this.svalue1==>"+this.svalue);
|
|
|
|
|
console.log("this.svalue1==>"+this.firstFlag);
|
|
|
|
|
if(this.svalue!=null&&this.firstFlag){
|
|
|
|
|
this.queryParams.empCode=this.svalue;
|
|
|
|
|
this.queryData();
|
|
|
|
|
}
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
2024-05-16 09:08:05 +00:00
|
|
|
siteCode(newVal){
|
2024-05-16 22:28:20 +00:00
|
|
|
console.log("siteCode==>"+newVal);
|
|
|
|
|
this.queryParams.ownerSiteCode=newVal;
|
|
|
|
|
this.queryData();
|
|
|
|
|
},
|
|
|
|
|
postCode(newVal){
|
|
|
|
|
console.log("postCode==>"+newVal);
|
|
|
|
|
this.queryParams.postCode=newVal;
|
|
|
|
|
this.queryData();
|
2024-05-07 04:53:57 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
// 给个随机id 判断是否clickoutside
|
|
|
|
|
this.createdId = String(new Date().getTime())
|
|
|
|
|
},
|
|
|
|
|
created() {
|
2024-05-16 22:28:20 +00:00
|
|
|
this.queryData();
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
changeValue(val) {
|
|
|
|
|
if(this.queryParams.searchValue === val ) return;
|
2024-05-16 22:28:20 +00:00
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
this.slable = val;
|
|
|
|
|
this.isEdit = true;
|
|
|
|
|
this.queryParams.searchValue = val
|
|
|
|
|
this.queryParams.pageNum = 1
|
|
|
|
|
|
2024-05-16 22:28:20 +00:00
|
|
|
this.queryData()
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
|
|
|
|
onRowClick(row, column, event) {
|
|
|
|
|
this.svalue=row.empCode;
|
|
|
|
|
this.showItem(row)
|
|
|
|
|
|
|
|
|
|
this.queryParams.searchValue=row.empName;
|
|
|
|
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
this.$emit("onChange",row);
|
|
|
|
|
this.$refs.popoverRef.doClose();
|
|
|
|
|
},
|
|
|
|
|
changePage(cur) {
|
|
|
|
|
this.queryParams.pageNum = cur
|
2024-05-16 22:28:20 +00:00
|
|
|
this.queryData()
|
2024-05-07 04:53:57 +00:00
|
|
|
|
|
|
|
|
this.visible = true
|
|
|
|
|
this.$refs.popoverRef.doShow();
|
|
|
|
|
},
|
|
|
|
|
onfocus(el) {
|
2024-05-16 22:28:20 +00:00
|
|
|
this.firstFlag = false;
|
|
|
|
|
this.queryParams.empCode=null;
|
|
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
if(this.slable) {
|
|
|
|
|
this.splaceholder= this.slable
|
|
|
|
|
}
|
|
|
|
|
this.visible = true
|
|
|
|
|
this.slable = null;
|
|
|
|
|
this.queryParams.searchValue = null;
|
|
|
|
|
this.queryParams.pageNum = 1
|
2024-05-16 22:28:20 +00:00
|
|
|
this.queryData();
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
|
|
|
|
onclear(el){
|
2024-05-16 22:28:20 +00:00
|
|
|
this.firstFlag = false;
|
|
|
|
|
this.queryParams.empCode=null;
|
|
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
this.splaceholder = this.placeholder;
|
|
|
|
|
this.slable = null;
|
|
|
|
|
this.svalue = null;
|
|
|
|
|
|
|
|
|
|
this.queryParams.searchValue = null;
|
|
|
|
|
this.queryParams.pageNum = 1;
|
|
|
|
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
this.dispatch('ElFormItem', 'el.form.blur', [this.svalue]);
|
|
|
|
|
|
|
|
|
|
if(this.visible){
|
2024-05-16 22:28:20 +00:00
|
|
|
this.queryData();
|
2024-05-07 04:53:57 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onblur(el) {
|
|
|
|
|
if(this.slable=='' || this.slable=='' || !this.isEdit) {
|
|
|
|
|
this.slable = this.splaceholder;
|
|
|
|
|
}
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
this.dispatch('ElFormItem', 'el.form.blur', [this.svalue]);
|
|
|
|
|
},
|
2024-05-16 22:28:20 +00:00
|
|
|
queryData() {
|
2024-05-13 04:36:25 +00:00
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
this.loading = true;
|
2024-05-16 22:28:20 +00:00
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
getStaffList(this.queryParams).then(response => {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.total = response.total;
|
|
|
|
|
this.dataList = response.rows;
|
2024-05-16 22:28:20 +00:00
|
|
|
this.firstFlag = false;
|
|
|
|
|
|
|
|
|
|
if(response.rows.length > 0) {
|
|
|
|
|
const curItem = response.rows.find(item => item.empCode === this.svalue);
|
|
|
|
|
this.showItem(curItem);
|
|
|
|
|
}else{
|
|
|
|
|
const curItem ={
|
|
|
|
|
empCode:this.svalue,
|
|
|
|
|
empName:''
|
|
|
|
|
};
|
|
|
|
|
this.showItem(curItem);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
showItem(item){
|
2024-05-13 04:36:25 +00:00
|
|
|
console.log(item);
|
|
|
|
|
|
2024-05-13 06:10:38 +00:00
|
|
|
// this.slable=item.empCode+'-'+item.empName;
|
2024-05-16 22:28:20 +00:00
|
|
|
if(item!=null){
|
|
|
|
|
this.slable=item.empName;
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
this.$emit("onChange",item);
|
|
|
|
|
this.dispatch('ElFormItem', 'el.form.change', [this.svalue]);
|
|
|
|
|
}
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
|
|
|
|
getIndex($index) {
|
|
|
|
|
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|