Commit a3b5c1bc authored by tianhongyang's avatar tianhongyang

上传文件file编码

parent 4a344f20
......@@ -121,3 +121,14 @@ export const uploadFileToOssApi = (data) => request({
method: "post",
data
});
/**
* 根据ossId 删除资源
* @param {*} ossId
* @returns
*/
export const removeFileFromOssApi = (ossId) => request({
url: `/system/oss/${ossId}`,
method: "delete",
params: {}
});
......@@ -35,7 +35,7 @@
</div>
</template>
<script>
import { uploadFileToOssApi } from "@/api/consultingOrgManagement";
import { uploadFileToOssApi, removeFileFromOssApi } from "@/api/consultingOrgManagement";
import { elementMessageSingleton } from "@/utils";
export default {
name: "dskFileInput",
......@@ -93,7 +93,7 @@ export default {
return this.$message.warning(`只支持上传${this.allowTypes.join(" , ")}类型文件`);
}
// 验证通过进行上传
await this.uploadHandle(file.raw, fileType);
await this.uploadHandle(new File([file.raw], encodeURIComponent(fileName)), fileType);
this.$message.success("上传成功");
} catch (error) {
console.log(error);
......@@ -144,15 +144,18 @@ export default {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
}).then(async () => {
const index = this.comFileList.findIndex(item => item.id == row.id);
if (index > -1) {
this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList);
this.$message({
type: 'success',
message: '删除成功!'
});
const removeResult = await removeFileFromOssApi(row.id);
if (removeResult.code == 200) {
this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList);
this.$message({
type: 'success',
message: '删除成功!'
});
}
}
}).catch(() => { });
}
......
......@@ -41,7 +41,7 @@
</div>
</template>
<script>
import { uploadFileToOssApi } from "@/api/consultingOrgManagement";
import { uploadFileToOssApi, removeFileFromOssApi } from "@/api/consultingOrgManagement";
import { elementMessageSingleton } from "@/utils";
export default {
name: "dskPhotoInput",
......@@ -101,7 +101,7 @@ export default {
return this.$message.warning(`只支持上传${this.allowTypes.join(" , ")}类型图片`);
}
// 验证通过进行上传
await this.uploadHandle(file.raw, fileType);
await this.uploadHandle(new File([file.raw], encodeURIComponent(fileName)), fileType);
this.$message.success("上传成功");
} catch (error) {
console.log(error);
......@@ -156,15 +156,18 @@ export default {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
}).then(async () => {
const index = this.comFileList.findIndex(item => item.id == row.id);
if (index > -1) {
this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList);
this.$message({
type: 'success',
message: '删除成功!'
});
const removeResult = await removeFileFromOssApi(row.id);
if (removeResult.code == 200) {
this.comFileList.splice(index, 1);
this.$emit("update:fileList", this.comFileList);
this.$message({
type: 'success',
message: '删除成功!'
});
}
}
}).catch(() => { });
}
......
......@@ -316,18 +316,19 @@ export default {
hasCustomFormDataHandle(formTemplate, formData) {
// console.log(formTemplate);
// console.log(formData);
formData.forEach(item => {
this.interComTemplateParent(formTemplate, item);
formTemplate.forEach(item => {
this.interComTemplateParent(formData, item);
});
return cloneDeep(formTemplate);
},
interComTemplateParent(formTemplate, comItem) {
const module = formTemplate.find(item => item.uid === comItem.pid);
if (module) {
const index = module.children.findIndex(child => child.uid === comItem.uid);
interComTemplateParent(formData, module) {
const hasTemplateModule = formData.find(item => item.pid === module.uid);
// 数据能找到关联模块
if (hasTemplateModule) {
const index = module.children.findIndex(child => child.uid === hasTemplateModule.uid);
// 找到模板 插入数据
if (index > -1) {
module.children[index].componentAttribute.value = comItem.componentAttribute.value;
module.children[index].componentAttribute.value = hasTemplateModule.componentAttribute.value;
}
}
},
......
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