2024-05-07 04:53:57 +00:00
|
|
|
<template>
|
|
|
|
|
<div :id="createdId">
|
|
|
|
|
<el-popover
|
|
|
|
|
placement="bottom"
|
|
|
|
|
trigger="click"
|
|
|
|
|
ref="popoverRef"
|
2024-05-25 09:36:22 +00:00
|
|
|
:popper-options="{ boundariesElement: '.el-form', removeOnDestroy: true }"
|
|
|
|
|
>
|
|
|
|
|
<div >
|
|
|
|
|
<el-table
|
|
|
|
|
ref="comboGridTable"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
style="width: 100%;"
|
|
|
|
|
:data="optionItems"
|
|
|
|
|
@row-click="onRowClick"
|
|
|
|
|
:row-key="row => row.empCode"
|
|
|
|
|
stripe
|
|
|
|
|
:row-style="isRed"
|
|
|
|
|
element-loading-text="Loading"
|
|
|
|
|
>
|
|
|
|
|
<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" />
|
|
|
|
|
|
|
|
|
|
</el-table>
|
|
|
|
|
<el-pagination v-show="pagination" small
|
|
|
|
|
:total="total"
|
|
|
|
|
:page-size="5"
|
|
|
|
|
layout="prev, pager, next, total"
|
|
|
|
|
@current-change="changePage"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<el-input
|
|
|
|
|
slot="reference"
|
|
|
|
|
ref="inputValue"
|
|
|
|
|
:value="slable"
|
|
|
|
|
:placeholder="placeholder"
|
2024-05-25 14:22:10 +00:00
|
|
|
@input="onInput"
|
|
|
|
|
@click.native="onClick"
|
2024-05-25 09:36:22 +00:00
|
|
|
@blur="onBlur"
|
|
|
|
|
@clear="onClear"
|
|
|
|
|
clearable
|
2024-05-07 04:53:57 +00:00
|
|
|
>
|
|
|
|
|
<template slot="suffix">
|
2024-05-25 09:36:22 +00:00
|
|
|
<!-- <i class="el-icon-arrow-down select-down" :class="visible&&'rotate180'"></i> -->
|
|
|
|
|
<i slot="suffix" class="el-icon-search"></i>
|
2024-05-07 04:53:57 +00:00
|
|
|
</template>
|
2024-05-25 09:36:22 +00:00
|
|
|
</el-input>
|
2024-05-07 04:53:57 +00:00
|
|
|
|
|
|
|
|
</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: {
|
2024-05-25 09:36:22 +00:00
|
|
|
type: String,
|
2024-05-07 04:53:57 +00:00
|
|
|
required: false
|
|
|
|
|
},
|
|
|
|
|
sideCode: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: false
|
|
|
|
|
},
|
|
|
|
|
postCode:{
|
|
|
|
|
type: String,
|
|
|
|
|
required: false
|
|
|
|
|
},
|
2024-05-25 09:36:22 +00:00
|
|
|
placeholder:{
|
2024-05-07 04:53:57 +00:00
|
|
|
type: String,
|
|
|
|
|
required: false
|
|
|
|
|
},
|
2024-05-25 09:36:22 +00:00
|
|
|
disabled:{
|
2024-05-07 04:53:57 +00:00
|
|
|
type: [Boolean,String],
|
|
|
|
|
required: false
|
2024-05-25 09:36:22 +00:00
|
|
|
},
|
|
|
|
|
pagination: {
|
|
|
|
|
type: Boolean, default: true
|
|
|
|
|
},
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
createdId: '0',
|
|
|
|
|
loading:false,
|
2024-05-25 09:36:22 +00:00
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
total:0,
|
2024-05-25 09:36:22 +00:00
|
|
|
optionItems: [],
|
|
|
|
|
|
|
|
|
|
// 缺省值
|
|
|
|
|
defaultTotal:0,
|
|
|
|
|
defaultItems:null,
|
|
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
svalue: this.value,
|
|
|
|
|
slable: null,
|
2024-05-25 09:36:22 +00:00
|
|
|
|
|
|
|
|
isInputing: false,
|
|
|
|
|
|
2024-05-25 14:22:10 +00:00
|
|
|
isInit:true,
|
|
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
queryParams:{
|
|
|
|
|
pageNum:1,
|
|
|
|
|
pageSize:5,
|
2024-05-25 09:36:22 +00:00
|
|
|
empCode:null,
|
2024-05-07 04:53:57 +00:00
|
|
|
searchValue:null,
|
2024-05-25 09:36:22 +00:00
|
|
|
ownerSiteCode:this.sideCode,
|
|
|
|
|
postCode:this.postCode
|
2024-05-07 04:53:57 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
value(newVal,oldVal) {
|
2024-05-25 09:36:22 +00:00
|
|
|
this.svalue=this.value;
|
|
|
|
|
this.queryData(null,this.svalue);
|
2024-07-10 22:40:54 +00:00
|
|
|
|
|
|
|
|
if(!this.svalue){
|
|
|
|
|
this.slable=null;
|
|
|
|
|
}
|
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
|
|
|
this.queryParams.ownerSiteCode=newVal;
|
2024-05-25 09:36:22 +00:00
|
|
|
this.defaultItems=null;
|
2024-05-16 22:28:20 +00:00
|
|
|
},
|
|
|
|
|
postCode(newVal){
|
|
|
|
|
this.queryParams.postCode=newVal;
|
2024-05-25 09:36:22 +00:00
|
|
|
this.defaultItems=null;
|
2024-05-07 04:53:57 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
// 给个随机id 判断是否clickoutside
|
|
|
|
|
this.createdId = String(new Date().getTime())
|
|
|
|
|
},
|
|
|
|
|
created() {
|
2024-05-25 14:22:10 +00:00
|
|
|
if(this.value!=null && this.isInit){
|
|
|
|
|
this.svalue=this.value;
|
|
|
|
|
this.queryData(null,this.svalue);
|
2024-05-25 09:36:22 +00:00
|
|
|
}
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
|
|
|
|
methods: {
|
2024-05-25 14:22:10 +00:00
|
|
|
onClick(){
|
|
|
|
|
this.isInit=false;
|
2024-05-25 09:36:22 +00:00
|
|
|
// 第一次点击时需要初始化
|
|
|
|
|
if(!this.defaultItems){
|
|
|
|
|
this.queryParams.pageNum=1;
|
|
|
|
|
this.queryData(null,null);
|
|
|
|
|
}else{
|
|
|
|
|
this.total = this.defaultTotal;
|
|
|
|
|
this.optionItems = [...this.defaultItems];
|
|
|
|
|
}
|
|
|
|
|
// this.$refs.popoverRef.doShow();
|
|
|
|
|
},
|
2024-05-25 14:22:10 +00:00
|
|
|
onInput(val) {
|
2024-05-25 09:36:22 +00:00
|
|
|
if(val == null ) return;
|
2024-05-16 22:28:20 +00:00
|
|
|
|
2024-05-25 09:36:22 +00:00
|
|
|
this.isInputing = true;
|
2024-05-07 04:53:57 +00:00
|
|
|
this.slable = val;
|
|
|
|
|
this.queryParams.pageNum = 1
|
2024-05-25 09:36:22 +00:00
|
|
|
this.queryData(val,null)
|
2024-05-07 04:53:57 +00:00
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onRowClick(row, column, event) {
|
|
|
|
|
this.svalue=row.empCode;
|
2024-05-25 09:36:22 +00:00
|
|
|
this.slable=row.empName;
|
2024-05-07 04:53:57 +00:00
|
|
|
|
2024-05-25 09:36:22 +00:00
|
|
|
this.isInputing = false;
|
2024-05-07 04:53:57 +00:00
|
|
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
this.$emit("onChange",row);
|
|
|
|
|
this.$refs.popoverRef.doClose();
|
|
|
|
|
},
|
2024-05-25 09:36:22 +00:00
|
|
|
isRed({ row }) {
|
|
|
|
|
if (row.empCode == this.svalue) {
|
|
|
|
|
return {
|
|
|
|
|
"color": "red",
|
|
|
|
|
"font-weight": "bold",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onClear(el){
|
2024-05-07 04:53:57 +00:00
|
|
|
this.slable = null;
|
|
|
|
|
this.svalue = null;
|
|
|
|
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
this.dispatch('ElFormItem', 'el.form.blur', [this.svalue]);
|
|
|
|
|
},
|
2024-05-25 09:36:22 +00:00
|
|
|
onBlur(el) {
|
|
|
|
|
// 如果编辑没有选择则清关历史记录
|
|
|
|
|
if( this.isInputing ){
|
|
|
|
|
this.svalue = null;
|
|
|
|
|
this.slable = null;
|
2024-05-07 04:53:57 +00:00
|
|
|
}
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
this.dispatch('ElFormItem', 'el.form.blur', [this.svalue]);
|
|
|
|
|
},
|
2024-05-25 14:22:10 +00:00
|
|
|
changePage(cur) {
|
|
|
|
|
this.queryParams.pageNum = cur
|
|
|
|
|
this.queryData()
|
|
|
|
|
},
|
2024-05-25 09:36:22 +00:00
|
|
|
queryData(val,key) {
|
2024-05-07 04:53:57 +00:00
|
|
|
this.loading = true;
|
2024-05-16 22:28:20 +00:00
|
|
|
|
2024-05-25 09:36:22 +00:00
|
|
|
this.queryParams.searchValue = val;
|
|
|
|
|
this.queryParams.empCode = key;
|
|
|
|
|
|
2024-05-07 04:53:57 +00:00
|
|
|
getStaffList(this.queryParams).then(response => {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.total = response.total;
|
2024-05-25 09:36:22 +00:00
|
|
|
this.optionItems = response.rows;
|
|
|
|
|
|
|
|
|
|
// 初始值存储
|
|
|
|
|
if(key==null && val==null){
|
|
|
|
|
this.defaultTotal = this.total+0;
|
|
|
|
|
this.defaultItems=[...this.optionItems]
|
2024-05-16 22:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
2024-05-25 09:36:22 +00:00
|
|
|
if(!this.isInputing ){
|
|
|
|
|
let selectItem = response.rows.find(item => item.empCode == this.svalue);
|
|
|
|
|
if(selectItem){
|
|
|
|
|
this.slable = selectItem.empName;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-13 04:36:25 +00:00
|
|
|
|
2024-05-25 09:36:22 +00:00
|
|
|
|
|
|
|
|
});
|
2024-05-07 04:53:57 +00:00
|
|
|
},
|
|
|
|
|
getIndex($index) {
|
|
|
|
|
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|