Commit 61b8125f authored by tianhongyang's avatar tianhongyang

fix

parent a3b5c1bc
...@@ -50,6 +50,11 @@ export default { ...@@ -50,6 +50,11 @@ export default {
fileList: { fileList: {
type: Array, type: Array,
default: () => [] default: () => []
},
// 是否是演示模式
presentationModel: {
type: Boolean,
default: false
} }
}, },
model: { model: {
...@@ -70,6 +75,15 @@ export default { ...@@ -70,6 +75,15 @@ export default {
//可访问data属性 //可访问data属性
created() { created() {
},
beforeDestroy() {
if (this.presentationModel) {
this.comFileList.forEach(item => {
if (item?.url?.indexOf("localhost") > -1) {
URL.revokeObjectURL(item.url);
}
});
}
}, },
//计算集 //计算集
computed: { computed: {
...@@ -92,9 +106,14 @@ export default { ...@@ -92,9 +106,14 @@ export default {
if (!this.allowTypes.includes(fileType.toLowerCase())) { if (!this.allowTypes.includes(fileType.toLowerCase())) {
return this.$message.warning(`只支持上传${this.allowTypes.join(" , ")}类型文件`); return this.$message.warning(`只支持上传${this.allowTypes.join(" , ")}类型文件`);
} }
// 是否是演示模式
if (this.presentationModel) {
await this.uploadHandleLocal(file, fileType);
} else {
// 验证通过进行上传 // 验证通过进行上传
await this.uploadHandle(new File([file.raw], encodeURIComponent(fileName)), fileType); await this.uploadHandle(new File([file.raw], encodeURIComponent(fileName)), fileType);
this.$message.success("上传成功"); }
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally { } finally {
...@@ -121,9 +140,25 @@ export default { ...@@ -121,9 +140,25 @@ export default {
fileName: result.data.fileName fileName: result.data.fileName
}); });
this.$emit("update:fileList", this.comFileList); this.$emit("update:fileList", this.comFileList);
this.$message.success("上传成功");
} }
} catch (error) { } catch (error) {
console.log(error);
}
},
async uploadHandleLocal(file, fileType) {
try {
const localUrl = URL.createObjectURL(file.raw);
this.comFileList.push({
url: localUrl,
type: fileType,
id: `${new Date().getTime()}${generateRandomLowerCaseLetter()}`,
fileName: file.name
});
this.$emit("update:fileList", this.comFileList);
this.$message.success("上传成功");
} catch (error) {
console.log(error);
} }
}, },
showFileListDialog() { showFileListDialog() {
...@@ -140,6 +175,9 @@ export default { ...@@ -140,6 +175,9 @@ export default {
}, },
removeImg(row) { removeImg(row) {
if (row.id) { if (row.id) {
if (this.presentationModel) {
return this.removeLocalImg(row.id);
}
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
...@@ -159,6 +197,19 @@ export default { ...@@ -159,6 +197,19 @@ export default {
} }
}).catch(() => { }); }).catch(() => { });
} }
},
removeLocalImg(id) {
const index = this.comFileList.findIndex(item => item.id == id);
if (index > -1) {
const url = this.comFileList[index].url;
URL.revokeObjectURL(url);
this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList);
this.$message({
type: 'success',
message: '删除成功!'
});
}
} }
}, },
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<script> <script>
import { uploadFileToOssApi, removeFileFromOssApi } from "@/api/consultingOrgManagement"; import { uploadFileToOssApi, removeFileFromOssApi } from "@/api/consultingOrgManagement";
import { elementMessageSingleton } from "@/utils"; import { elementMessageSingleton } from "@/utils";
import { generateRandomLowerCaseLetter } from "@/utils/";
export default { export default {
name: "dskPhotoInput", name: "dskPhotoInput",
props: { props: {
...@@ -56,6 +57,11 @@ export default { ...@@ -56,6 +57,11 @@ export default {
fileList: { fileList: {
type: Array, type: Array,
default: () => [] default: () => []
},
// 是否是演示模式
presentationModel: {
type: Boolean,
default: false
} }
}, },
model: { model: {
...@@ -78,6 +84,15 @@ export default { ...@@ -78,6 +84,15 @@ export default {
//可访问data属性 //可访问data属性
created() { created() {
},
beforeDestroy() {
if (this.presentationModel) {
this.comFileList.forEach(item => {
if (item?.url?.indexOf("localhost") > -1) {
URL.revokeObjectURL(item.url);
}
});
}
}, },
//计算集 //计算集
computed: { computed: {
...@@ -100,9 +115,14 @@ export default { ...@@ -100,9 +115,14 @@ export default {
if (!this.allowTypes.includes(fileType.toLowerCase())) { if (!this.allowTypes.includes(fileType.toLowerCase())) {
return this.$message.warning(`只支持上传${this.allowTypes.join(" , ")}类型图片`); return this.$message.warning(`只支持上传${this.allowTypes.join(" , ")}类型图片`);
} }
// 是否是演示模式
if (this.presentationModel) {
await this.uploadHandleLocal(file, fileType);
} else {
// 验证通过进行上传 // 验证通过进行上传
await this.uploadHandle(new File([file.raw], encodeURIComponent(fileName)), fileType); await this.uploadHandle(new File([file.raw], encodeURIComponent(fileName)), fileType);
this.$message.success("上传成功"); }
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally { } finally {
...@@ -129,11 +149,27 @@ export default { ...@@ -129,11 +149,27 @@ export default {
fileName: result.data.fileName fileName: result.data.fileName
}); });
this.$emit("update:fileList", this.comFileList); this.$emit("update:fileList", this.comFileList);
this.$message.success("上传成功");
} }
} catch (error) { } catch (error) {
} }
}, },
async uploadHandleLocal(file, fileType) {
try {
const localUrl = URL.createObjectURL(file.raw);
this.comFileList.push({
url: localUrl,
type: fileType,
id: `${new Date().getTime()}${generateRandomLowerCaseLetter()}`,
fileName: file.name
});
this.$emit("update:fileList", this.comFileList);
this.$message.success("上传成功");
} catch (error) {
console.log(error);
}
},
showFileListDialog() { showFileListDialog() {
this.fileListDialog = true; this.fileListDialog = true;
}, },
...@@ -152,6 +188,9 @@ export default { ...@@ -152,6 +188,9 @@ export default {
}, },
removeImg(row) { removeImg(row) {
if (row.id) { if (row.id) {
if (this.presentationModel) {
return this.removeLocalImg(row.id);
}
this.$confirm('此操作将永久删除该图片, 是否继续?', '提示', { this.$confirm('此操作将永久删除该图片, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
...@@ -171,6 +210,19 @@ export default { ...@@ -171,6 +210,19 @@ export default {
} }
}).catch(() => { }); }).catch(() => { });
} }
},
removeLocalImg(id) {
const index = this.comFileList.findIndex(item => item.id == id);
if (index > -1) {
const url = this.comFileList[index].url;
URL.revokeObjectURL(url);
this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList);
this.$message({
type: 'success',
message: '删除成功!'
});
}
} }
}, },
} }
......
...@@ -1020,3 +1020,13 @@ export function replaceDomTags(str) { ...@@ -1020,3 +1020,13 @@ export function replaceDomTags(str) {
const reg = /<[^>]*>/gmi; const reg = /<[^>]*>/gmi;
return str.replace(reg, ""); return str.replace(reg, "");
} }
/**
* 生成随机字母
* @returns
*/
export function generateRandomLowerCaseLetter() {
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
const randomIndex = Math.floor(Math.random() * alphabet.length);
return alphabet[randomIndex];
}
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
:clearable="true" :disabled="isDisabled" v-if="comChildModuleInfo.comType == 'email'"></dsk-email-input> :clearable="true" :disabled="isDisabled" v-if="comChildModuleInfo.comType == 'email'"></dsk-email-input>
<!-- 图片类型 --> <!-- 图片类型 -->
<dsk-photo-input v-model="comChildModuleInfo.componentAttribute.value" :disabled="isDisabled" v-if="comChildModuleInfo.comType == 'photo'" <dsk-photo-input v-model="comChildModuleInfo.componentAttribute.value" :disabled="isDisabled" v-if="comChildModuleInfo.comType == 'photo'"
:limit="comChildModuleInfo.formAttribute.limit"></dsk-photo-input> :limit="comChildModuleInfo.formAttribute.limit" :presentationModel="true"></dsk-photo-input>
<!-- 文件类型 --> <!-- 文件类型 -->
<dsk-file-input v-model="comChildModuleInfo.componentAttribute.value" :disabled="isDisabled" v-if="comChildModuleInfo.comType == 'file'" <dsk-file-input v-model="comChildModuleInfo.componentAttribute.value" :disabled="isDisabled" v-if="comChildModuleInfo.comType == 'file'"
:limit="comChildModuleInfo.formAttribute.limit"></dsk-file-input> :limit="comChildModuleInfo.formAttribute.limit" :presentationModel="true"></dsk-file-input>
</el-form-item> </el-form-item>
<img src="@/assets/images/consultingAgencyManagement/customForm/icon_delete@2x.png" alt="" class="remove-subfield-item-icon" <img src="@/assets/images/consultingAgencyManagement/customForm/icon_delete@2x.png" alt="" class="remove-subfield-item-icon"
......
...@@ -314,23 +314,25 @@ export default { ...@@ -314,23 +314,25 @@ export default {
} }
}, },
hasCustomFormDataHandle(formTemplate, formData) { hasCustomFormDataHandle(formTemplate, formData) {
// console.log(formTemplate); const _template = cloneDeep(formTemplate);
// console.log(formData); const _result = _template.map(moduleItem => {
formTemplate.forEach(item => { return this.interComTemplateParent(formData, moduleItem);
this.interComTemplateParent(formData, item);
}); });
return cloneDeep(formTemplate); return cloneDeep(_result);
}, },
interComTemplateParent(formData, module) { interComTemplateParent(formData, module) {
const hasTemplateModule = formData.find(item => item.pid === module.uid); const hasTemplateModuleArray = formData.filter(item => item.pid === module.uid);
// 数据能找到关联模块 // 找到当前模板下 关联的数据
if (hasTemplateModule) { if (hasTemplateModuleArray?.length) {
const index = module.children.findIndex(child => child.uid === hasTemplateModule.uid); hasTemplateModuleArray.forEach(dataItem => {
const index = module.children.findIndex(child => child.uid === dataItem.uid);
// 找到模板 插入数据 // 找到模板 插入数据
if (index > -1) { if (index > -1) {
module.children[index].componentAttribute.value = hasTemplateModule.componentAttribute.value; module.children[index].componentAttribute.value = dataItem.componentAttribute.value;
} }
});
} }
return module;
}, },
renderTemplate(template) { renderTemplate(template) {
const table = this.createTemplateTable(template); const table = this.createTemplateTable(template);
...@@ -678,6 +680,9 @@ export default { ...@@ -678,6 +680,9 @@ export default {
border-radius: unset; border-radius: unset;
border-color: transparent; border-color: transparent;
color: #232323; color: #232323;
font-size: 12px;
font-weight: 400;
font-family: Arial, Helvetica, sans-serif;
&:focus { &:focus {
border: 1px solid #0081ff; border: 1px solid #0081ff;
......
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