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",
"version": "0.1.11",
"version": "0.1.12",
"main": "packages/index.js",
"scripts": {
"dev": "vue-cli-service serve",

View File

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

View File

@ -1,228 +1,222 @@
<template>
<div class="ag-MultifunctionSearch">
<ag-select
v-bind="$attrs"
v-on="listeners"
:value="values&&values[0]"
@change="onSelect"
class="ag_select_group"
:style="{ width: `${swidth}px` }"
>
</ag-select>
<div class="ag-MultifunctionSearch">
<ag-select
v-bind="$attrs"
v-on="listeners"
:options="$attrs.options||[]"
:value="value&&value[0]"
@change="onSelect"
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-date-picker>
</div>
</template>
<script>
import agSelect from "../../agSelect/src/index.vue";
import agDatePicker from "../../agDatePicker/src/index.vue";
export default {
name: "agMultionDattePicker",
components: {
agSelect,
agDatePicker,
},
props: {
value: {
default: () => {
return [null, []];
},
<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-date-picker>
</div>
</template>
<script>
import agSelect from "../../agSelect/src/index.vue";
import agDatePicker from "../../agDatePicker/src/index.vue";
export default {
name: "agMultionDattePicker",
components: {
agSelect,
agDatePicker,
},
props: {
value: {
default: () => {
return [null, []];
},
options: {
type: Array,
default: () => {
return [];
},
},
},
data() {
return {
values: [null, []],
swidth:90,
inputValue:"",
selectvalue:"",
imeipopover:false,
listeners:{}
};
},
model: {
prop: 'value', // prop 'value'
event: 'change' // value
},
watch: {
value: {
handler(newVal) {
if (!Array.isArray(newVal)) {
throw new Error("请传入数组");
}
let newselectValue=newVal[0];
const find=this.options.find((f)=>f.value==newselectValue);
if(find){
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]||[]]);
},
data() {
return {
values: [null, []],
swidth:90,
inputValue:"",
selectvalue:"",
imeipopover:false,
listeners:{}
};
},
model: {
prop: 'value', // prop 'value'
event: 'change' // value
},
watch: {
value: {
handler(newVal) {
if (!Array.isArray(newVal)) {
throw new Error("请传入数组");
}
let newselectValue=newVal[0];
const find=this.$attrs.options&&this.$attrs.options.find((f)=>f.value==newselectValue);
if(find){
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){
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;
},
},
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;
},
imeiclose(){
this.imeipopover=false;
},
};
</script>
<style lang="scss">
.popperOptions {
min-width: 200px !important;
padding: 0px !important;
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;
}
.imeiicondefault {
padding: 5px;
border-radius: 4px;
background: #f0f2f5;
cursor: pointer;
}
.imeiiconActive {
cursor: pointer;
color: #409eff;
background: #e9f1fc;
}
.divider {
margin: 0;
}
</style>
<style scoped lang='scss'>
.ag-MultifunctionSearch {
display: flex;
align-items: center;
}
.imeiicondefault {
.btnbox {
padding: 5px;
border-radius: 4px;
background: #f0f2f5;
cursor: pointer;
}
.imeiiconActive {
cursor: pointer;
color: #409eff;
background: #e9f1fc;
}
.divider {
margin: 0;
display: flex;
justify-content: space-between;
}
::v-deep{
.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;
}
}
}
.btnbox {
padding: 5px;
.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;
justify-content: space-between;
align-items: center;
justify-content: center;
}
::v-deep{
.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>
}
</style>