192 lines
4.5 KiB
Vue
192 lines
4.5 KiB
Vue
<template>
|
|
<div :id="createdId">
|
|
<el-popover
|
|
placement="bottom"
|
|
trigger="click"
|
|
ref="popoverRef"
|
|
: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.goodsCode"
|
|
stripe
|
|
size="mini"
|
|
:row-style="isRed"
|
|
element-loading-text="Loading"
|
|
>
|
|
<el-table-column label="序号" align="center" width="60">
|
|
<template slot-scope="scope">
|
|
<span v-text="getIndex(scope.$index)"> </span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="货物名称" align="left" prop="goodsName" width="150" />
|
|
</el-table>
|
|
</div>
|
|
|
|
<el-input
|
|
slot="reference"
|
|
ref="inputValue"
|
|
:value="svalue"
|
|
:placeholder="placeholder"
|
|
@input="onInput"
|
|
@blur="onBlur"
|
|
@clear="onClear"
|
|
clearable
|
|
readonly=""
|
|
>
|
|
|
|
</el-input>
|
|
|
|
</el-popover>
|
|
|
|
</div>
|
|
</template>
|
|
<script>
|
|
|
|
import emitter from 'element-ui/src/mixins/emitter';
|
|
import { debounce } from 'throttle-debounce'
|
|
|
|
export default {
|
|
name: "TaxInput",
|
|
mixins: [emitter],
|
|
props: {
|
|
value: {
|
|
type: String,
|
|
required: false
|
|
},
|
|
placeholder:{
|
|
type: String,
|
|
required: false
|
|
},
|
|
disabled:{
|
|
type: [Boolean,String],
|
|
required: false
|
|
},
|
|
pagination: {
|
|
type: Boolean, default: true
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
createdId: '0',
|
|
loading:false,
|
|
|
|
total:0,
|
|
optionItems: [],
|
|
|
|
svalue: this.value,
|
|
|
|
queryParams:{
|
|
pageNum:1,
|
|
pageSize:5,
|
|
goodsName:null,
|
|
searchValue:null,
|
|
}
|
|
};
|
|
},
|
|
watch: {
|
|
value(newVal,oldVal) {
|
|
this.svalue=this.value;
|
|
},
|
|
|
|
},
|
|
mounted() {
|
|
// 给个随机id 判断是否clickoutside
|
|
this.createdId = String(new Date().getTime())
|
|
},
|
|
created() {
|
|
this.svalue=this.value;
|
|
this.optionItems=[
|
|
{
|
|
"goodsName": "代理报关费",
|
|
"goodsCode": "304080202",
|
|
"specType": "次",
|
|
"unit": "次",
|
|
"price": "1",
|
|
"num": "1",
|
|
"taxRate": "0.06",
|
|
"withTaxFlag": "1"
|
|
},
|
|
{
|
|
"goodsName": "国际代理运输",
|
|
"goodsCode": "30408020102",
|
|
"specType": "次",
|
|
"unit": "次",
|
|
"price": "1",
|
|
"num": "1",
|
|
"taxRate": "0.00",
|
|
"withTaxFlag": "1"
|
|
},
|
|
{
|
|
"goodsName": "派送费",
|
|
"goodsCode": "304040903",
|
|
"specType": "次",
|
|
"unit": "次",
|
|
"price": "1",
|
|
"num": "1",
|
|
"taxRate": "0.06",
|
|
"withTaxFlag": "1"
|
|
},
|
|
{
|
|
"goodsName": "代理运输费",
|
|
"goodsCode": "30105020202",
|
|
"specType": "次",
|
|
"unit": "次",
|
|
"price": "1",
|
|
"num": "1",
|
|
"taxRate": "0.09",
|
|
"withTaxFlag": "1"
|
|
}
|
|
];
|
|
},
|
|
methods: {
|
|
onInput(val) {
|
|
this.svalue = val;
|
|
this.queryParams.pageNum = 1
|
|
this.queryParams.goodsName=val;
|
|
debounce(250, this.queryData() );
|
|
},
|
|
onRowClick(row, column, event) {
|
|
this.svalue=row.goodsName;
|
|
|
|
this.$emit("input", this.svalue);
|
|
this.$emit("onChange",row);
|
|
this.$refs.popoverRef.doClose();
|
|
},
|
|
isRed({ row }) {
|
|
if (row.goodsName == this.svalue) {
|
|
return {
|
|
"color": "red",
|
|
"font-weight": "bold",
|
|
};
|
|
}
|
|
},
|
|
onClear(el){
|
|
this.svalue = null;
|
|
|
|
this.$emit("input", this.svalue);
|
|
this.dispatch('ElFormItem', 'el.form.blur', this.svalue);
|
|
},
|
|
onBlur(el) {
|
|
this.$emit("input", this.svalue);
|
|
this.dispatch('ElFormItem', 'el.form.blur', this.svalue);
|
|
},
|
|
changePage(cur) {
|
|
this.queryParams.pageNum = cur
|
|
this.queryData()
|
|
},
|
|
queryData() {
|
|
|
|
},
|
|
getIndex($index) {
|
|
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
|
|
},
|
|
}
|
|
};
|
|
</script>
|