Commit f922cace authored by tianhongyang's avatar tianhongyang

fix bug

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