Commit 5738efe0 authored by tyn's avatar tyn

fix

parent 3962b1f6
<template>
<div class="dsk-email-input-container">
<el-autocomplete :popper-class="popperClass" v-model="comEmailValue" :clearable="clearable" :fetch-suggestions="searchQuery"
:placeholder="placeholder" @select="handleSelect">
:placeholder="placeholder" @select="handleSelect" @input="valueChange">
<template slot-scope="{ item }">
<slot :optionData="item">
<div class="email-type-option">
<div class="email-type-inner">
<div class="email-icon-box"></div>
<div class="email-content-box">{{item.value}}</div>
</div>
<div class="email-vfx-box"></div>
</div>
</slot>
</template>
......@@ -107,8 +111,12 @@ export default {
},
//方法集
methods: {
handleSelect() {
handleSelect(item) {
this.$emit("select", item);
this.$emit("update:emailValue", item.value);
},
valueChange(value) {
this.$emit("update:emailValue", value);
},
searchQuery(keywords, callback) {
// 空值不联想
......@@ -151,6 +159,10 @@ export default {
height: 32px;
width: 100%;
position: relative;
::v-deep .el-autocomplete {
width: 100%;
}
}
</style>
<style lang="scss">
......@@ -160,6 +172,16 @@ export default {
& > [id*="el-autocomplete"] {
padding: 0px 0px;
line-height: 32px;
&:hover {
background: unset;
background-image: linear-gradient(
135deg,
rgba(0, 128, 255, 0.3),
#f5f7fa,
rgba(242, 242, 242, 0.473)
);
}
}
.email-type-option {
display: flex;
......@@ -168,6 +190,40 @@ export default {
height: 32px;
padding: 0 16px;
box-sizing: border-box;
position: relative;
overflow: hidden;
.email-type-inner {
width: 100%;
height: 100%;
display: flex;
align-items: center;
position: relative;
z-index: 9;
}
&:hover {
.email-vfx-box {
width: 100%;
height: 32px;
}
}
.email-icon-box {
width: 24px;
height: 24px;
min-width: 24px;
}
.email-content-box {
width: calc(100% - 40px);
height: 100%;
display: flex;
align-items: center;
box-sizing: border-box;
margin-left: 16px;
color: rgba(35, 35, 35, 0.8);
}
}
}
}
......
......@@ -34,6 +34,7 @@ export const defaultComOptions = [
formAttribute: {
// 验证规则
rules: {},
designRules: {},
// 是否必填
required: false,
// 字段名称
......@@ -64,6 +65,7 @@ export const defaultComOptions = [
formAttribute: {
// 验证规则
rules: {},
designRules: {},
// 是否必填
required: false,
// 字段名称
......@@ -98,6 +100,7 @@ export const defaultComOptions = [
message: "请输入选项值",
trigger: ["change", "blur"]
},
designRules: {},
// 是否必填
required: false,
// 字段名称
......@@ -131,6 +134,7 @@ export const defaultComOptions = [
formAttribute: {
// 验证规则
rules: {},
designRules: {},
// 是否必填
required: false,
// 字段名称
......@@ -183,6 +187,16 @@ export const defaultComOptions = [
return callback();
}
},
designRules: {
trigger: ["blur"],
validator: (rule, value, callback) => {
const phoneReg = /^1[3-9]\d{9}$/;
if (value && !phoneReg.test(value)) {
return callback(`请输入正确的联系电话`);
}
return callback();
}
},
// 是否必填
required: false,
// 字段名称
......@@ -222,6 +236,16 @@ export const defaultComOptions = [
return callback();
}
},
designRules: {
trigger: ["blur"],
validator: (rule, value, callback) => {
console.log("value", value);
if (value && !validEmail(value)) {
return callback(`请输入正确的电子邮箱`);
}
return callback();
}
},
requiredRules: {
trigger: ["blur"],
validator: (rule, value, callback) => {
......
......@@ -62,6 +62,7 @@ export default {
handler(newValue) {
console.log(this.comActiveUid !== this.comChildModuleInfo?.uid, "是否不是更改的当前元素");
if (this.comActiveUid !== this.comChildModuleInfo?.uid) return;
this.checkValidator(newValue);
this.$mitt.emit("subfieldItemChange", newValue);
},
deep: true
......@@ -122,6 +123,20 @@ export default {
},
//方法集
methods: {
// 验证
async checkValidator(item) {
try {
const { formAttribute, componentAttribute } = item;
const validator = new Schema({
value: formAttribute.designRules
});
console.log(validator);
const flag = await validator.validate({ value: componentAttribute.value }, { first: true });
console.log(flag);
} catch (error) {
console.log(error);
}
},
// 根据命中的id 来添加发布订阅
addSubscription(newValue) {
if (newValue === this.comChildModuleInfo.uid) return this.$mitt.on("fieldOptionChange", this.setFieldOption);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment