Compare commits

..

No commits in common. "9c3de1ec85e534c7e0f2f458f63238c6b6e40446" and "297e10d70c8c3972cc10dcff09e1a87a03d9ac70" have entirely different histories.

4 changed files with 123 additions and 88 deletions

View File

@ -1,18 +1,23 @@
<template> <template>
<el-input <el-input
class="ag_input" class="ag_input"
size="small" size="small"
ref="apinputref" :style="{ width }"
:style="{ width }" v-on="Listeners"
v-bind="$attrs" v-bind="attrs"
v-on="$listeners"
> >
<slot v-for="(_,name) in $slots" :name="name" :slot="name"> </slot> <slot name="append" slot="append" />
<slot name="prefix" slot="prefix" />
<slot name="suffix" slot="suffix" />
<slot name="prepend" slot="prepend" />
</el-input> </el-input>
</template> </template>
<script> <script>
/**
* WInput
* @desc 处理输入的输入框(转大写不能有中文空格等)
*/
export default { export default {
name: "agInput", name: "agInput",
props: { props: {
@ -25,22 +30,42 @@ export default {
default: false, default: false,
}, },
}, },
computed: {
watch:{ attrs() {
$attrs:function(val){ return {
console.log(val,'attrsattrs'); size: "small",
clearable: true, //
...this.$attrs,
};
},
//
Listeners() {
return Object.assign(
{},
//
this.$listeners,
//
//
{
// `v-model`
input: (value) => {
this.$emit("change", this.toUpperCase ? value.toUpperCase() : value);
},
blur: (e) => {
let value = e.target.value
.trim()
.replace(/\s/g, (match) =>
match.charCodeAt(0) === 12288 ? String.fromCharCode(32) : match
);
//
this.$emit("change", value);
},
}
);
}, },
}, },
mounted() {},
mounted(){
if(this.$refs.apinputref){
for(const key in this.$refs.apinputref){
if(!this[key]&&key!='value'){
this[key]=this.$refs.apinputref[key];
}
}
}
},
}; };
</script> </script>

View File

@ -1,24 +1,24 @@
<template> <template>
<div class="ag-MultifunctionSearch"> <div class="ag-MultifunctionSearch">
<ag-select <ag-select
v-bind="$attrs" slot="prepend"
v-on="listeners" :clearable="false"
:value="values&&values[0]" placeholder="请选择"
:value="value[0]"
v-bind="config.select"
@change="onSelect" @change="onSelect"
class="ag_select_group" class="ag_select_group"
:style="{ width: `${swidth}px` }" :style="{ width: `${swidth}px` }"
> >
</ag-select> </ag-select>
<ag-input <ag-input
v-if="!showExtra" v-if="!showExtra"
class="ag_input_group" class="ag_input_group"
placeholder="请输入内容" placeholder="请输入内容"
:disabled="$attrs.disabled||imeipopover"
v-bind="$attrs"
v-on="listeners"
:value="value[1]" :value="value[1]"
@input="onInputChange" :disabled="config.input.disabled||imeipopover"
v-bind="config.input"
@change="onInputChange"
> >
</ag-input> </ag-input>
<el-popover <el-popover
@ -32,12 +32,11 @@
<template slot="reference"> <template slot="reference">
<ag-input <ag-input
class="ag_input_group" class="ag_input_group"
placeholder="请输入内容" placeholder="请输入内容"
:disabled="$attrs.disabled||imeipopover" :value="value[1]"
v-bind="$attrs" :disabled="config.input.disabled||imeipopover"
v-on="listeners" v-bind="config.input"
:value="value&&value[1]" @change="onInputChange"
@input="onInputChange"
> >
<template slot="suffix" v-if="showExtra"> <template slot="suffix" v-if="showExtra">
<i <i
@ -49,10 +48,10 @@
</template> </template>
</ag-input> </ag-input>
</template> </template>
<el-input <el-input
v-model="value[1]"
type="textarea" type="textarea"
:rows="12" :rows="12"
:value="value&&value[1]"
placeholder="一行一项最多支持200行" placeholder="一行一项最多支持200行"
resize="none" resize="none"
border="none" border="none"
@ -99,7 +98,7 @@ export default {
value: { value: {
type: Array, type: Array,
default: () => { default: () => {
return [null, '']; return [null, null];
}, },
}, },
options: { options: {
@ -115,21 +114,35 @@ export default {
}, },
data() { data() {
return { return {
values: [null, ""], values: [null, null],
swidth:90, swidth:90,
inputValue:"",
selectvalue:"", selectvalue:"",
imeipopover:false, imeipopover:false
listeners:{}
}; };
}, },
computed: {
config() {
const input = {
...this.$attrs
};
const select = {
...this.$attrs,
options:this.options
};
return {
input,
select,
};
},
},
watch: { watch: {
value: { value: {
handler(newVal) { handler(newVal) {
if (!Array.isArray(newVal)) { if (!Array.isArray(newVal)) {
throw new Error("请传入数组"); throw new Error("请传入数组");
} }
let newselectValue=newVal[0]; let newselectValue=newVal[0];
const find=this.options.find((f)=>f.value==newselectValue); const find=this.options.find((f)=>f.value==newselectValue);
if(find){ if(find){
let fontwidth=this.getStringWidth(find?.label); let fontwidth=this.getStringWidth(find?.label);
@ -140,18 +153,12 @@ export default {
immediate: true, immediate: true,
}, },
}, },
mounted(){
let newlist=Object.assign({},this.$listeners);
delete newlist.change;
delete newlist.input;
this.listeners=newlist;
},
methods: { methods: {
onSelect(value){ onSelect(value){
this.$emit("change", [value, this.value[1]||""]); this.$emit("change", [value, this.value[1]||""]);
}, },
onInputChange(val){ onInputChange(value){
this.$emit("change", [this.values[0] ||"",val]); this.$emit("change", [ this.value[0] ||"",value]);
}, },
getStringWidth(text) { getStringWidth(text) {
let font = "13px"; let font = "13px";

View File

@ -4,11 +4,12 @@
class="ag_select" class="ag_select"
:style="{ width: `100%` }" :style="{ width: `100%` }"
:value="selectValue" :value="selectValue"
ref="apselectref" v-bind="attrs"
v-bind="$attrs"
v-on="$listeners" v-on="$listeners"
> >
<slot v-for="(_,name) in $slots" :name="name" :slot="name"> </slot> <slot />
<slot name="prefix" slot="prefix" />
<slot name="empty" slot="empty" />
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item.value" :key="item.value"
@ -42,15 +43,6 @@ export default {
selectValue:"" selectValue:""
}; };
}, },
mounted(){
if(this.$refs.apselectref){
for(const key in this.$refs.apselectref){
if(!this[key]&&key!='value'){
this[key]=this.$refs.apselectref[key];
}
}
}
},
watch: { watch: {
value: { value: {
handler(newVal) { handler(newVal) {
@ -64,7 +56,17 @@ export default {
}, },
immediate: true, immediate: true,
}, },
}, },
computed: {
attrs() {
return {
size: "small",
clearable: true,
filterable: true,
...this.$attrs,
};
},
},
methods: { methods: {
}, },
}; };

View File

@ -4,9 +4,13 @@
<ag-dialog :visible.sync="abb"> </ag-dialog> <ag-dialog :visible.sync="abb"> </ag-dialog>
<ag-datePicker v-model="date_value" :showTime="true" :range="true" @change="onPicker"> <ag-datePicker v-model="date_value" :showTime="true" :range="true" @change="onPicker">
</ag-datePicker> </ag-datePicker>
<ag-input v-model="inputValue" placeholder="请输入" @change="onInputChange" ref="aginputref"> <ag-input value="value"> </ag-input>
</ag-input> <ag-select :options="a_options" v-model="value">
<ag-select :options="a_options" v-model="value"> <!-- <template slot="prefix">
{{
(a_options.find((e) => e.value == value) || {}).label
}}
</template> -->
</ag-select> </ag-select>
<ag-NumberRange v-model="values"> </ag-NumberRange> <ag-NumberRange v-model="values"> </ag-NumberRange>
<el-form <el-form
@ -35,7 +39,7 @@
:clearable="true" :clearable="true"
:options="a_options" :options="a_options"
@change="onInputinput" @change="onInputinput"
@blur="onblur"
> >
</ag-MultifunctionSearch> </ag-MultifunctionSearch>
<agQuery :inputs="inputs" @onSearch="onSearch"/> <agQuery :inputs="inputs" @onSearch="onSearch"/>
@ -101,7 +105,6 @@ export default {
rules: { rules: {
pass: [{ validator: validatePass, trigger: "blur" }], pass: [{ validator: validatePass, trigger: "blur" }],
}, },
inputValue:"",
date_value:null, date_value:null,
value: "选项1", value: "选项1",
a_value: "59584", a_value: "59584",
@ -332,18 +335,16 @@ export default {
], ],
}; };
}, },
watch: {
mounted(){ values: {
this.$refs.aginputref.value=123; handler(val) {
console.log(val, 238);
},
deep: true,
immediate: true,
},
}, },
methods: { methods: {
onblur(val,elem){
console.log("onblur",val,elem,this);
},
onInputChange(value){
console.log(value,"onSearch");
},
onPicker(value){ onPicker(value){
this.date_value=value; this.date_value=value;
}, },
@ -351,7 +352,7 @@ export default {
console.log(values,"onSearch"); console.log(values,"onSearch");
}, },
onInputinput(value){ onInputinput(value){
console.log(value,"oninput222"); console.log(value,"oninput");
this.values=value; this.values=value;
}, },
change() { change() {