Commit f922cace authored by tianhongyang's avatar tianhongyang

fix bug

parent 0c9d398e
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
</template> </template>
<!-- 图片类型 --> <!-- 图片类型 -->
<dsk-photo-input v-model="comCustomItem.componentAttribute.value" v-if="comCustomItem.comType == 'photo'" <dsk-photo-input v-model="comCustomItem.componentAttribute.value" v-if="comCustomItem.comType == 'photo'"
:limit="comCustomItem.formAttribute.limit" :disabled="!isModify"></dsk-photo-input> :limit="comCustomItem.formAttribute.limit" :disabled="!isModify" @change="fileChange"></dsk-photo-input>
<!-- 文件类型 --> <!-- 文件类型 -->
<dsk-file-input v-model="comCustomItem.componentAttribute.value" v-if="comCustomItem.comType == 'file'" <dsk-file-input v-model="comCustomItem.componentAttribute.value" v-if="comCustomItem.comType == 'file'"
:limit="comCustomItem.formAttribute.limit" :disabled="!isModify"></dsk-file-input> :limit="comCustomItem.formAttribute.limit" :disabled="!isModify" @change="fileChange"></dsk-file-input>
<!-- 详情模式下 --> <!-- 详情模式下 -->
<template v-if="!isModify && detailTypes.includes(comCustomItem.comType)"> <template v-if="!isModify && detailTypes.includes(comCustomItem.comType)">
...@@ -54,6 +54,7 @@ import DskEmailInput from "@/components/DskEmailInput"; ...@@ -54,6 +54,7 @@ import DskEmailInput from "@/components/DskEmailInput";
import DskPhotoInput from "@/components/DskPhotoInput"; import DskPhotoInput from "@/components/DskPhotoInput";
import DskFileInput from "@/components/DskFileInput"; import DskFileInput from "@/components/DskFileInput";
import DskTextOverFlowTip from "@/components/DskTextOverFlowTip"; import DskTextOverFlowTip from "@/components/DskTextOverFlowTip";
import { cloneDeep } from 'lodash-es';
export default { export default {
name: "dskCustomItemRender", name: "dskCustomItemRender",
components: { components: {
...@@ -112,7 +113,11 @@ export default { ...@@ -112,7 +113,11 @@ export default {
comCustomRowIndex: this.customRowIndex, comCustomRowIndex: this.customRowIndex,
comCustomItemIndex: this.customItemIndex, comCustomItemIndex: this.customItemIndex,
comIsModify: this.isModify, comIsModify: this.isModify,
detailTypes: ["text", "textarea", "select", "date", "phone", "email"] detailTypes: ["text", "textarea", "select", "date", "phone", "email"],
validatorMap: {
"email": [/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, "邮箱"],
"phone": [/^1[3-9]\d{9}$/, "电话号码"]
}
}; };
}, },
//可访问data属性 //可访问data属性
...@@ -130,14 +135,31 @@ export default { ...@@ -130,14 +135,31 @@ export default {
methods: { methods: {
// 验证规则 // 验证规则
validatorRules(item) { validatorRules(item) {
let type = Object.prototype.toString.call(item.componentAttribute.value).split(" ")[1].replace("]", "").toLowerCase(); const _item = cloneDeep(item);
if (!item.formAttribute) return { required: false, type }; const itemLabel = _item.formAttribute.label;
if (item.formAttribute.required) { let type = Object.prototype.toString.call(_item.componentAttribute.value).split(" ")[1].replace("]", "").toLowerCase();
if (item.formAttribute.requiredRules) return item.formAttribute.requiredRules; if (!_item.formAttribute) return { required: false, type };
return { required: true, type, message: `${item.formAttribute.label}不能为空` }; if (_item.formAttribute.required) {
if (item.formAttribute.requiredRules) {
if (_item.formAttribute.requiredRules.validator) {
let validatorRule = cloneDeep(this.validatorMap[_item.comType]);
_item.formAttribute.requiredRules.validator = (rule, value, callback) => {
const reg = validatorRule[0];
if (!value && !value?.toString()?.trim()) {
return callback(new Error(itemLabel ? `请输入${itemLabel}` : `请输入${validatorRule[1]}`));
}
if (!reg.test(value)) {
return callback(new Error(itemLabel ? `请输入正确的${itemLabel}` : `请输入正确的${validatorRule[1]}`));
}
return callback();
};
}
return _item.formAttribute.requiredRules;
};
return { required: true, type, message: `${itemLabel}不能为空` };
} }
if (Object.keys(item.formAttribute.rules).length) { if (Object.keys(_item.formAttribute.rules).length) {
return item.formAttribute.rules; return _item.formAttribute.rules;
} else { } else {
return { required: false, type }; return { required: false, type };
}; };
...@@ -153,6 +175,9 @@ export default { ...@@ -153,6 +175,9 @@ export default {
const valueType = Object.prototype.toString.call(value); const valueType = Object.prototype.toString.call(value);
if (valueType === "[object String]") return value || value == "0" ? value : "-"; if (valueType === "[object String]") return value || value == "0" ? value : "-";
if (valueType === "[object Array]") return value?.length ? value.join(",") : "-"; if (valueType === "[object Array]") return value?.length ? value.join(",") : "-";
},
fileChange(isRemove, fileList) {
this.$emit("fileChange", isRemove, fileList, this.comCustomItem);
} }
}, },
} }
...@@ -194,11 +219,8 @@ export default { ...@@ -194,11 +219,8 @@ export default {
} }
} }
::v-deep &.custom-render-item-textarea { &.custom-render-item-textarea {
.dsk-custom-form-render-item { min-height: 73px;
.dsk-cutom-form-render-detail-item {
}
}
} }
} }
</style> </style>
...@@ -139,7 +139,7 @@ export default { ...@@ -139,7 +139,7 @@ export default {
id: result.data.ossId, id: result.data.ossId,
fileName: result.data.fileName fileName: result.data.fileName
}); });
this.$emit("update:fileList", this.comFileList); this.eventChange();
this.$message.success("上传成功"); this.$message.success("上传成功");
} }
} catch (error) { } catch (error) {
...@@ -155,7 +155,7 @@ export default { ...@@ -155,7 +155,7 @@ export default {
id: `${new Date().getTime()}${generateRandomLowerCaseLetter()}`, id: `${new Date().getTime()}${generateRandomLowerCaseLetter()}`,
fileName: file.name fileName: file.name
}); });
this.$emit("update:fileList", this.comFileList); this.eventChange();
this.$message.success("上传成功"); this.$message.success("上传成功");
} catch (error) { } catch (error) {
console.log(error); console.log(error);
...@@ -188,7 +188,7 @@ export default { ...@@ -188,7 +188,7 @@ export default {
const removeResult = await removeFileFromOssApi(row.id); const removeResult = await removeFileFromOssApi(row.id);
if (removeResult.code == 200) { if (removeResult.code == 200) {
this.comFileList.splice(index, 1); this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList); this.eventChange(true);
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
...@@ -204,12 +204,16 @@ export default { ...@@ -204,12 +204,16 @@ export default {
const url = this.comFileList[index].url; const url = this.comFileList[index].url;
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
this.comFileList.splice(index, 1); this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList); this.eventChange(true);
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}); });
} }
},
eventChange(isRemove = false) {
this.$emit("update:fileList", this.comFileList);
this.$emit("change", isRemove, this.comFileList);
} }
}, },
} }
......
...@@ -148,7 +148,7 @@ export default { ...@@ -148,7 +148,7 @@ export default {
id: result.data.ossId, id: result.data.ossId,
fileName: result.data.fileName fileName: result.data.fileName
}); });
this.$emit("update:fileList", this.comFileList); this.eventChange();
this.$message.success("上传成功"); this.$message.success("上传成功");
} }
} catch (error) { } catch (error) {
...@@ -164,7 +164,7 @@ export default { ...@@ -164,7 +164,7 @@ export default {
id: `${new Date().getTime()}${generateRandomLowerCaseLetter()}`, id: `${new Date().getTime()}${generateRandomLowerCaseLetter()}`,
fileName: file.name fileName: file.name
}); });
this.$emit("update:fileList", this.comFileList); this.eventChange();
this.$message.success("上传成功"); this.$message.success("上传成功");
} catch (error) { } catch (error) {
console.log(error); console.log(error);
...@@ -201,7 +201,7 @@ export default { ...@@ -201,7 +201,7 @@ export default {
const removeResult = await removeFileFromOssApi(row.id); const removeResult = await removeFileFromOssApi(row.id);
if (removeResult.code == 200) { if (removeResult.code == 200) {
this.comFileList.splice(index, 1); this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList); this.eventChange(true);
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
...@@ -217,12 +217,16 @@ export default { ...@@ -217,12 +217,16 @@ export default {
const url = this.comFileList[index].url; const url = this.comFileList[index].url;
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
this.comFileList.splice(index, 1); this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList); this.eventChange(true);
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}); });
} }
},
eventChange(isRemove = false) {
this.$emit("update:fileList", this.comFileList);
this.$emit("change", isRemove, this.comFileList);
} }
}, },
} }
......
...@@ -224,7 +224,6 @@ export const defaultComOptions = [ ...@@ -224,7 +224,6 @@ export const defaultComOptions = [
rules: { rules: {
trigger: ["blur"], trigger: ["blur"],
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
// console.log("value", value);
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (value && !reg.test(value)) { if (value && !reg.test(value)) {
return callback(new Error(`请输入正确的电子邮箱`)); return callback(new Error(`请输入正确的电子邮箱`));
...@@ -237,10 +236,10 @@ export const defaultComOptions = [ ...@@ -237,10 +236,10 @@ export const defaultComOptions = [
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!value && !value?.toString()?.trim()) { if (!value && !value?.toString()?.trim()) {
return callback(new Error(`请输入电子邮箱`)); return callback(new Error("请输入邮箱"));
} }
if (!reg.test(value)) { if (!reg.test(value)) {
return callback(new Error(`请输入正确的电子邮箱`)); return callback(new Error("请输入正确的邮箱"));
} }
return callback(); return callback();
} }
......
...@@ -216,7 +216,7 @@ export default { ...@@ -216,7 +216,7 @@ export default {
}); });
} catch (error) { } catch (error) {
if (error?.errors?.length) { if (error?.errors?.length) {
console.dir(error); // console.dir(error);
const { errors, fields } = error; const { errors, fields } = error;
this.errorHandle(errors); this.errorHandle(errors);
} }
...@@ -429,10 +429,10 @@ export default { ...@@ -429,10 +429,10 @@ export default {
} }
}, },
// 编辑模块名称结束 // 编辑模块名称结束
editFinish(module) { editFinish(module, moduleName) {
const index = this.subfieldModuleForm.subfieldModuleList.findIndex(item => item.uid == module.uid); const index = this.subfieldModuleForm.subfieldModuleList.findIndex(item => item.uid == module.uid);
if (index > -1) { if (index > -1) {
this.subfieldModuleForm.subfieldModuleList.splice(index, 1, { ...module, ...this.subfieldModuleForm.subfieldModuleList[index].children }); this.subfieldModuleForm.subfieldModuleList.splice(index, 1, { ...module, children: [...this.subfieldModuleForm.subfieldModuleList[index].children] });
} }
}, },
// 命中的模块 // 命中的模块
......
...@@ -91,7 +91,7 @@ export default { ...@@ -91,7 +91,7 @@ export default {
this.comModuleInfo.edit = false; this.comModuleInfo.edit = false;
this.comModuleInfo.defaultSubfieldModuleName = this.comModuleInfo.subfieldModuleName; this.comModuleInfo.defaultSubfieldModuleName = this.comModuleInfo.subfieldModuleName;
this.oldComModuleName = this.comModuleInfo.subfieldModuleName; this.oldComModuleName = this.comModuleInfo.subfieldModuleName;
this.$emit("editFinish", this.comModuleInfo); this.$emit("editFinish", this.comModuleInfo, this.subfieldModuleComName);
} }
}, },
} }
......
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<!-- 组件容器 --> <!-- 组件容器 -->
<div class="custom-item-com-box"> <div class="custom-item-com-box">
<dsk-custom-item-render :custom-item="column" :custom-module-index="index" :custom-row-index="rowIndex" <dsk-custom-item-render :custom-item="column" :custom-module-index="index" :custom-row-index="rowIndex"
:custom-item-index="columnIndex" :isModify="comIsModify"></dsk-custom-item-render> :custom-item-index="columnIndex" :isModify="comIsModify" @fileChange="fileChange"></dsk-custom-item-render>
</div> </div>
</div> </div>
</div> </div>
...@@ -249,6 +249,20 @@ export default { ...@@ -249,6 +249,20 @@ export default {
}, },
//方法集 //方法集
methods: { methods: {
fileChange(isRemove, fileList, comCustomItem) {
const uid = comCustomItem.uid;
const pid = comCustomItem.pid;
const moduleIndex = this.form.subfieldModuleList.findIndex(item => item.uid == pid);
if (moduleIndex > -1) {
const _temp = cloneDeep(this.form.subfieldModuleList[moduleIndex]);
const index = _temp.children.findIndex(child => child.uid == uid);
if (index > -1) {
_temp.children[index].componentAttribute.value = cloneDeep(fileList);
this.form.subfieldModuleList.splice(moduleIndex, 1, _temp);
this.oldSubfieldModuleList = cloneDeep(this.form.subfieldModuleList);
}
}
},
itemStyles(item, index, selfIndex) { itemStyles(item, index, selfIndex) {
const styles = { const styles = {
width: `${item.formAttribute.width}%` width: `${item.formAttribute.width}%`
...@@ -394,10 +408,15 @@ export default { ...@@ -394,10 +408,15 @@ export default {
} }
}, },
async cancelModify() {
try {
await this.$nextTick();
this.$refs["customDesignFormTemplate"].clearValidate();
this.comProjectDetailInfo = cloneDeep(this.oldComProjectDetailInfo);
this.$set(this.form, "subfieldModuleList", cloneDeep(this.oldSubfieldModuleList));
} catch (error) {
cancelModify() { }
this.comProjectDetailInfo = JSON.parse(JSON.stringify(this.oldComProjectDetailInfo));
this.$set(this.form, "subfieldModuleList", cloneDeep(this.oldSubfieldModuleList));
}, },
async searchConsulting(keywords) { async searchConsulting(keywords) {
try { try {
...@@ -608,10 +627,9 @@ export default { ...@@ -608,10 +627,9 @@ export default {
&.is-error { &.is-error {
.el-form-item__content { .el-form-item__content {
.el-input { .el-textarea__inner,
.el-input__inner { .el-input__inner {
border-color: #ff4949; border-color: #ff4949 !important;
}
} }
} }
} }
...@@ -769,6 +787,7 @@ export default { ...@@ -769,6 +787,7 @@ export default {
display: flex; display: flex;
border: 1px solid #e6eaf1; border: 1px solid #e6eaf1;
box-sizing: border-box; box-sizing: border-box;
align-self: flex-end;
.custom-item-key { .custom-item-key {
width: 180px; width: 180px;
min-height: 40px; min-height: 40px;
......
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