Commit a3b5c1bc authored by tianhongyang's avatar tianhongyang

上传文件file编码

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