Commit 5738efe0 authored by tyn's avatar tyn

fix

parent 3962b1f6
<template> <template>
<div class="dsk-email-input-container"> <div class="dsk-email-input-container">
<el-autocomplete :popper-class="popperClass" v-model="comEmailValue" :clearable="clearable" :fetch-suggestions="searchQuery" <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 }"> <template slot-scope="{ item }">
<slot :optionData="item"> <slot :optionData="item">
<div class="email-type-option"> <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> </div>
</slot> </slot>
</template> </template>
...@@ -107,8 +111,12 @@ export default { ...@@ -107,8 +111,12 @@ export default {
}, },
//方法集 //方法集
methods: { methods: {
handleSelect() { handleSelect(item) {
this.$emit("select", item);
this.$emit("update:emailValue", item.value);
},
valueChange(value) {
this.$emit("update:emailValue", value);
}, },
searchQuery(keywords, callback) { searchQuery(keywords, callback) {
// 空值不联想 // 空值不联想
...@@ -151,6 +159,10 @@ export default { ...@@ -151,6 +159,10 @@ export default {
height: 32px; height: 32px;
width: 100%; width: 100%;
position: relative; position: relative;
::v-deep .el-autocomplete {
width: 100%;
}
} }
</style> </style>
<style lang="scss"> <style lang="scss">
...@@ -160,6 +172,16 @@ export default { ...@@ -160,6 +172,16 @@ export default {
& > [id*="el-autocomplete"] { & > [id*="el-autocomplete"] {
padding: 0px 0px; padding: 0px 0px;
line-height: 32px; 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 { .email-type-option {
display: flex; display: flex;
...@@ -168,6 +190,40 @@ export default { ...@@ -168,6 +190,40 @@ export default {
height: 32px; height: 32px;
padding: 0 16px; padding: 0 16px;
box-sizing: border-box; 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 = [ ...@@ -34,6 +34,7 @@ export const defaultComOptions = [
formAttribute: { formAttribute: {
// 验证规则 // 验证规则
rules: {}, rules: {},
designRules: {},
// 是否必填 // 是否必填
required: false, required: false,
// 字段名称 // 字段名称
...@@ -64,6 +65,7 @@ export const defaultComOptions = [ ...@@ -64,6 +65,7 @@ export const defaultComOptions = [
formAttribute: { formAttribute: {
// 验证规则 // 验证规则
rules: {}, rules: {},
designRules: {},
// 是否必填 // 是否必填
required: false, required: false,
// 字段名称 // 字段名称
...@@ -98,6 +100,7 @@ export const defaultComOptions = [ ...@@ -98,6 +100,7 @@ export const defaultComOptions = [
message: "请输入选项值", message: "请输入选项值",
trigger: ["change", "blur"] trigger: ["change", "blur"]
}, },
designRules: {},
// 是否必填 // 是否必填
required: false, required: false,
// 字段名称 // 字段名称
...@@ -131,6 +134,7 @@ export const defaultComOptions = [ ...@@ -131,6 +134,7 @@ export const defaultComOptions = [
formAttribute: { formAttribute: {
// 验证规则 // 验证规则
rules: {}, rules: {},
designRules: {},
// 是否必填 // 是否必填
required: false, required: false,
// 字段名称 // 字段名称
...@@ -183,6 +187,16 @@ export const defaultComOptions = [ ...@@ -183,6 +187,16 @@ export const defaultComOptions = [
return callback(); 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, required: false,
// 字段名称 // 字段名称
...@@ -222,6 +236,16 @@ export const defaultComOptions = [ ...@@ -222,6 +236,16 @@ export const defaultComOptions = [
return callback(); return callback();
} }
}, },
designRules: {
trigger: ["blur"],
validator: (rule, value, callback) => {
console.log("value", value);
if (value && !validEmail(value)) {
return callback(`请输入正确的电子邮箱`);
}
return callback();
}
},
requiredRules: { requiredRules: {
trigger: ["blur"], trigger: ["blur"],
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
......
...@@ -62,6 +62,7 @@ export default { ...@@ -62,6 +62,7 @@ export default {
handler(newValue) { handler(newValue) {
console.log(this.comActiveUid !== this.comChildModuleInfo?.uid, "是否不是更改的当前元素"); console.log(this.comActiveUid !== this.comChildModuleInfo?.uid, "是否不是更改的当前元素");
if (this.comActiveUid !== this.comChildModuleInfo?.uid) return; if (this.comActiveUid !== this.comChildModuleInfo?.uid) return;
this.checkValidator(newValue);
this.$mitt.emit("subfieldItemChange", newValue); this.$mitt.emit("subfieldItemChange", newValue);
}, },
deep: true deep: true
...@@ -122,6 +123,20 @@ export default { ...@@ -122,6 +123,20 @@ export default {
}, },
//方法集 //方法集
methods: { 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 来添加发布订阅 // 根据命中的id 来添加发布订阅
addSubscription(newValue) { addSubscription(newValue) {
if (newValue === this.comChildModuleInfo.uid) return this.$mitt.on("fieldOptionChange", this.setFieldOption); 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