This commit is contained in:
ln1778 2024-09-12 17:08:07 +08:00
parent b631f64cbb
commit 3bbf8a51dc
3 changed files with 214 additions and 225 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ag-element-ui", "name": "ag-element-ui",
"version": "0.1.11", "version": "0.1.12",
"main": "packages/index.js", "main": "packages/index.js",
"scripts": { "scripts": {
"dev": "vue-cli-service serve", "dev": "vue-cli-service serve",

View File

@ -3,7 +3,8 @@
<ag-select <ag-select
v-bind="$attrs" v-bind="$attrs"
v-on="listeners" v-on="listeners"
:value="values&&values[0]" :options="$attrs.options||[]"
:value="value&&value[0]"
@change="onSelect" @change="onSelect"
class="ag_select_group" class="ag_select_group"
:style="{ width: `${swidth}px` }" :style="{ width: `${swidth}px` }"
@ -105,12 +106,6 @@ export default {
return [null, '']; return [null, ''];
}, },
}, },
options: {
type: Array,
default: () => {
return [];
},
},
showExtra: { showExtra: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -137,7 +132,7 @@ export default {
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.$attrs.options&&this.$attrs.options.find((f)=>f.value==newselectValue);
if(find){ if(find){
let fontwidth=this.getStringWidth(find.label); let fontwidth=this.getStringWidth(find.label);
this.swidth=fontwidth>165?165:fontwidth; this.swidth=fontwidth>165?165:fontwidth;

View File

@ -1,228 +1,222 @@
<template> <template>
<div class="ag-MultifunctionSearch"> <div class="ag-MultifunctionSearch">
<ag-select <ag-select
v-bind="$attrs" v-bind="$attrs"
v-on="listeners" v-on="listeners"
:value="values&&values[0]" :options="$attrs.options||[]"
@change="onSelect" :value="value&&value[0]"
class="ag_select_group" @change="onSelect"
:style="{ width: `${swidth}px` }" class="ag_select_group"
:style="{ width: `${swidth}px` }"
>
</ag-select>
<ag-date-picker
class="ag_input_group"
:placeholder="$attrs.placeholder||'请选择时间'"
:disabled="$attrs.disabled"
v-bind="$attrs"
v-on="listeners"
:value="value[1]"
@change="onInputChange"
> >
</ag-select> </ag-date-picker>
</div>
</template>
<ag-date-picker <script>
class="ag_input_group" import agSelect from "../../agSelect/src/index.vue";
:placeholder="$attrs.placeholder||'请选择时间'" import agDatePicker from "../../agDatePicker/src/index.vue";
:disabled="$attrs.disabled"
v-bind="$attrs"
v-on="listeners"
:value="value[1]"
@change="onInputChange"
>
</ag-date-picker>
</div>
</template>
<script> export default {
import agSelect from "../../agSelect/src/index.vue"; name: "agMultionDattePicker",
import agDatePicker from "../../agDatePicker/src/index.vue"; components: {
agSelect,
export default { agDatePicker,
name: "agMultionDattePicker", },
components: { props: {
agSelect, value: {
agDatePicker, default: () => {
}, return [null, []];
props: {
value: {
default: () => {
return [null, []];
},
},
options: {
type: Array,
default: () => {
return [];
},
}, },
}, },
data() { },
return { data() {
values: [null, []], return {
swidth:90, values: [null, []],
inputValue:"", swidth:90,
selectvalue:"", inputValue:"",
imeipopover:false, selectvalue:"",
listeners:{} imeipopover:false,
}; listeners:{}
}, };
model: { },
prop: 'value', // prop 'value' model: {
event: 'change' // value prop: 'value', // prop 'value'
}, event: 'change' // value
watch: { },
value: { watch: {
handler(newVal) { value: {
if (!Array.isArray(newVal)) { handler(newVal) {
throw new Error("请传入数组"); if (!Array.isArray(newVal)) {
} throw new Error("请传入数组");
let newselectValue=newVal[0]; }
const find=this.options.find((f)=>f.value==newselectValue); let newselectValue=newVal[0];
if(find){ const find=this.$attrs.options&&this.$attrs.options.find((f)=>f.value==newselectValue);
let fontwidth=this.getStringWidth(find.label); if(find){
this.swidth=fontwidth>165?165:fontwidth; let fontwidth=this.getStringWidth(find.label);
} this.swidth=fontwidth>165?165:fontwidth;
},
immediate: true,
},
},
mounted(){
let newlist=Object.assign({},this.$listeners);
delete newlist.change;
delete newlist.input;
this.listeners=newlist;
},
methods: {
onSelect(value){
if(this.$listeners.change){
this.$emit("change", [value, this.value[1]||[]]);
} }
}, },
onInputChange(val){ immediate: true,
if(this.$listeners.change){
this.$emit("change", [this.values[0] ||"",val]);
}
},
getStringWidth(text) {
let font = "13px";
//
let element = document.createElement('span');
element.style.visibility = 'hidden';
element.style.whiteSpace = 'nowrap';
element.style.font = font; //
element.textContent = text;
//
document.body.appendChild(element);
//
let width = element.offsetWidth;
//
document.body.removeChild(element);
return width+50;
},
imeiiconClick(){
this.imeipopover=!this.imeipopover;
},
imeiclose(){
this.imeipopover=false;
},
cleartext(){
this.value[1]=[];
this.$set(this.value,1,[]);
},
search(){
this.imeipopover=false;
if(this.$listeners.onSrarch){
this.$emit("onSrarch", this.value);
}
},
getAfterAgo(attr, prefix) {
const config = {};
for (const key in attr) {
if (attr.hasOwnProperty(key) && key.startsWith(prefix)) {
const newKey = key.substring(prefix.length);
config[newKey] = attr[key];
}
}
return config;
},
}, },
}; },
</script> mounted(){
<style lang="scss"> let newlist=Object.assign({},this.$listeners);
.popperOptions { delete newlist.change;
min-width: 200px !important; delete newlist.input;
padding: 0px !important; this.listeners=newlist;
},
methods: {
onSelect(value){
if(this.$listeners.change){
this.$emit("change", [value, this.value[1]||[]]);
}
},
onInputChange(val){
if(this.$listeners.change){
this.$emit("change", [this.values[0] ||"",val]);
}
},
getStringWidth(text) {
let font = "13px";
//
let element = document.createElement('span');
element.style.visibility = 'hidden';
element.style.whiteSpace = 'nowrap';
element.style.font = font; //
element.textContent = text;
//
document.body.appendChild(element);
//
let width = element.offsetWidth;
//
document.body.removeChild(element);
return width+50;
},
imeiiconClick(){
this.imeipopover=!this.imeipopover;
},
imeiclose(){
this.imeipopover=false;
},
cleartext(){
this.value[1]=[];
this.$set(this.value,1,[]);
},
search(){
this.imeipopover=false;
if(this.$listeners.onSrarch){
this.$emit("onSrarch", this.value);
}
},
getAfterAgo(attr, prefix) {
const config = {};
for (const key in attr) {
if (attr.hasOwnProperty(key) && key.startsWith(prefix)) {
const newKey = key.substring(prefix.length);
config[newKey] = attr[key];
}
}
return config;
},
},
};
</script>
<style lang="scss">
.popperOptions {
min-width: 200px !important;
padding: 0px !important;
}
</style>
<style scoped lang='scss'>
.ag-MultifunctionSearch {
display: flex;
align-items: center;
} }
</style> .imeiicondefault {
<style scoped lang='scss'> padding: 5px;
.ag-MultifunctionSearch { border-radius: 4px;
display: flex; background: #f0f2f5;
align-items: center; cursor: pointer;
} }
.imeiiconActive {
cursor: pointer;
color: #409eff;
background: #e9f1fc;
}
.divider {
margin: 0;
}
.imeiicondefault { .btnbox {
padding: 5px; padding: 5px;
border-radius: 4px; display: flex;
background: #f0f2f5; justify-content: space-between;
cursor: pointer;
} }
.imeiiconActive {
cursor: pointer;
color: #409eff;
background: #e9f1fc;
}
.divider {
margin: 0;
}
.btnbox { ::v-deep{
padding: 5px;
.ag_select_group{
.el-input__inner{
border:1px solid #e5e5e5;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
outline:none;
&:focus{
border-color:#e5e5e5;
}
}
}
.ag_input_group{
.el-input__inner{
border:1px solid #e5e5e5;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-left:none;
outline:none;
&:focus{
border-color:#e5e5e5;
}
}
}
.el-select{
.el-input{
&.is-focus{
.el-input__inner{
border-color:#e5e5e5;
}
}
}
&:hover{
.el-input__inner{
border-color:#e5e5e5;
}
}
}
.el-textarea__inner{
border:none;
}
.el-input__suffix-inner{
height:100%;
display: flex; display: flex;
justify-content: space-between; align-items: center;
justify-content: center;
} }
}
::v-deep{ </style>
.ag_select_group{
.el-input__inner{
border:1px solid #e5e5e5;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
outline:none;
&:focus{
border-color:#e5e5e5;
}
}
}
.ag_input_group{
.el-input__inner{
border:1px solid #e5e5e5;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-left:none;
outline:none;
&:focus{
border-color:#e5e5e5;
}
}
}
.el-select{
.el-input{
&.is-focus{
.el-input__inner{
border-color:#e5e5e5;
}
}
}
&:hover{
.el-input__inner{
border-color:#e5e5e5;
}
}
}
.el-textarea__inner{
border:none;
}
.el-input__suffix-inner{
height:100%;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>