|
|
@ -263,25 +263,15 @@ export default { |
|
|
|
</template> |
|
|
|
<template v-else-if="editFormMode==='import'"> |
|
|
|
<app-form |
|
|
|
mode="import" |
|
|
|
ref="importFormRef" |
|
|
|
mode="update" |
|
|
|
label-position="left" |
|
|
|
:schema="config.import?.schema" |
|
|
|
v-model="importModel" |
|
|
|
:hideButton="true" |
|
|
|
:isQueryForm="true" |
|
|
|
style="height:100%;" |
|
|
|
> |
|
|
|
<el-form-item :label="$t('文件')" label-width="80px"> |
|
|
|
<el-upload |
|
|
|
ref="uploadRef" |
|
|
|
class="upload" |
|
|
|
drag |
|
|
|
accept=".xlsx" |
|
|
|
:auto-upload="false" |
|
|
|
:on-change="handleChange" |
|
|
|
> |
|
|
|
<el-icon class="el-icon--upload"><ep-upload-filled /></el-icon> |
|
|
|
</el-upload> |
|
|
|
</el-form-item> |
|
|
|
</app-form> |
|
|
|
</template> |
|
|
|
<template v-else-if="editFormMode==='filter'"> |
|
|
@ -408,6 +398,7 @@ export default { |
|
|
|
const tableSchema = ref({}); |
|
|
|
const tableData = ref([]); |
|
|
|
const editFormRef = ref(null); |
|
|
|
const importFormRef = ref(null); |
|
|
|
const editFormloading = ref(false); |
|
|
|
const editFormMode = ref(null); |
|
|
|
const editFormTitle = ref(""); |
|
|
@ -424,11 +415,26 @@ export default { |
|
|
|
businessType: route.meta.businessType, |
|
|
|
}; |
|
|
|
const exportModel = ref(defaultExportModel); |
|
|
|
const defaultImportModel = config.import?.schema ? schemaToModel(config.import.schema) : {}; |
|
|
|
const importModel = ref(defaultImportModel); |
|
|
|
const factories = ref([]); |
|
|
|
//
|
|
|
|
config.import ??= { schema: { type: "object", properties: {} } }; |
|
|
|
config.import.schema.properties.files ??= { |
|
|
|
title: "文件", |
|
|
|
type: "array", |
|
|
|
multiple: true, |
|
|
|
input: "file", |
|
|
|
accept: ".xlsx", |
|
|
|
default: [], |
|
|
|
limit: 3, |
|
|
|
rules: [ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
trigger: "change", |
|
|
|
}, |
|
|
|
], |
|
|
|
}; |
|
|
|
const defaultImportModel = schemaToModel(config.import.schema); |
|
|
|
const importModel = ref(null); |
|
|
|
const versions = ref([]); |
|
|
|
const fileList = ref([]); |
|
|
|
const getSortModel = (model) => { |
|
|
|
(model.sorting ?? "") |
|
|
|
.split(",") |
|
|
@ -575,10 +581,6 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// await post(
|
|
|
|
// url,
|
|
|
|
// rows.map((o) => o.id)
|
|
|
|
// );
|
|
|
|
await load(); |
|
|
|
} else if (item.path === "export") { |
|
|
|
//export
|
|
|
@ -609,20 +611,7 @@ export default { |
|
|
|
importModel.value = Object.assign({}, defaultImportModel); |
|
|
|
editFormloading.value = true; |
|
|
|
editFormTitle.value = `${t(item.path)}${config.query.schema.title}`; |
|
|
|
fileList.value = []; |
|
|
|
dialogVisible.value = true; |
|
|
|
// versions.value = (
|
|
|
|
// await request("settleaccount/centralized-control/get-all", null, { method: "POST" })
|
|
|
|
// ).data.items.map((o) => ({
|
|
|
|
// value: o.version,
|
|
|
|
// label: o.version,
|
|
|
|
// }));
|
|
|
|
// factories.value = (
|
|
|
|
// await request("settleaccount/code-setting/get-all", null, { method: "POST" })
|
|
|
|
// ).data.items.map((o) => ({
|
|
|
|
// value: o.project,
|
|
|
|
// label: o.project,
|
|
|
|
// }));
|
|
|
|
} catch (e) { |
|
|
|
console.log(e); |
|
|
|
} finally { |
|
|
@ -667,38 +656,47 @@ export default { |
|
|
|
dialogVisible.value = false; |
|
|
|
editFormMode.value = null; |
|
|
|
} else if (editFormMode.value === "compare") { |
|
|
|
// const postData = JSON.parse(JSON.stringify(queryModel.value));
|
|
|
|
// postData.filters = filterList.value.filter((o) => o.property && o.value);
|
|
|
|
// delete postData.query["items"];
|
|
|
|
// delete postData.query["id"];
|
|
|
|
// const url = `${baseUrl}/${editFormMode.value}?${qs.stringify(exportModel)}`;
|
|
|
|
// const response = await post(url, postData);
|
|
|
|
// download(response);
|
|
|
|
const url = config.edit.compareUrl; |
|
|
|
await request(url, exportModel.value, { method: config.edit.compareMethod }); |
|
|
|
dialogVisible.value = false; |
|
|
|
} else if (editFormMode.value === "import") { |
|
|
|
try { |
|
|
|
const valid = await importFormRef.value.validate(); |
|
|
|
if (valid) { |
|
|
|
editFormloading.value = true; |
|
|
|
const url = config.edit.importUrl; |
|
|
|
const formData = new FormData(); |
|
|
|
// formData.append("version", importModel.value.version);
|
|
|
|
// // formData.append("factory", importModel.value.factory);
|
|
|
|
// Object.keys(importModel.value).forEach((q) => {if(importModel.value)
|
|
|
|
Object.keys(importModel.value).forEach((q) => { |
|
|
|
if (importModel.value[q]) { |
|
|
|
formData.append(q, importModel.value[q]); |
|
|
|
} |
|
|
|
}); |
|
|
|
//
|
|
|
|
if (config.query.schema.properties.businessType?.default) { |
|
|
|
formData.append("businessType", config.query.schema.properties.businessType.default); |
|
|
|
} |
|
|
|
for (let i = 0; i < fileList.value.length; i++) { |
|
|
|
formData.append(`files`, fileList.value[i].raw); |
|
|
|
Object.keys(importModel.value).forEach((propertyName) => { |
|
|
|
if (importModel.value[propertyName]) { |
|
|
|
const schema = config.import.schema.properties[propertyName]; |
|
|
|
const value = importModel.value[propertyName]; |
|
|
|
if (schema?.type === "array") { |
|
|
|
importModel.value[propertyName].forEach((item) => { |
|
|
|
formData.append(propertyName, schema.input === "file" ? item.raw : item); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
formData.append(propertyName, schema.input === "file" ? value.raw : value); |
|
|
|
} |
|
|
|
} |
|
|
|
await post(url, formData); |
|
|
|
}); |
|
|
|
const result = await request(url, formData); |
|
|
|
if (result.data?.code === 200) { |
|
|
|
editFormloading.value = false; |
|
|
|
dialogVisible.value = false; |
|
|
|
await load(); |
|
|
|
} else if (result.data?.code === 400 && result.data.fileName) { |
|
|
|
window.open(getUrl(`settleaccount/getblobfile/download/${result.data.fileName}`)); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
} finally { |
|
|
|
editFormloading.value = false; |
|
|
|
} |
|
|
|
} else if (editFormMode.value === "filter") { |
|
|
|
await load(); |
|
|
|
dialogVisible.value = false; |
|
|
@ -728,9 +726,6 @@ export default { |
|
|
|
const response = await get(url); |
|
|
|
download(url, response.filename); |
|
|
|
}; |
|
|
|
const handleChange = (uploadFile, uploadFiles) => { |
|
|
|
fileList.value = uploadFiles; |
|
|
|
}; |
|
|
|
const getButtonDisabled = async (src, row) => { |
|
|
|
if (src) { |
|
|
|
const method = await importFunction(src); |
|
|
@ -887,6 +882,7 @@ export default { |
|
|
|
sortChange, |
|
|
|
getProp, |
|
|
|
getImportTemplate, |
|
|
|
importFormRef, |
|
|
|
editFormRef, |
|
|
|
editFormloading, |
|
|
|
editFormMode, |
|
|
@ -903,10 +899,7 @@ export default { |
|
|
|
submit, |
|
|
|
showList, |
|
|
|
subListQuery, |
|
|
|
fileList, |
|
|
|
handleChange, |
|
|
|
getButtonDisabled, |
|
|
|
factories, |
|
|
|
versions, |
|
|
|
pushfilterList, |
|
|
|
getOperators, |
|
|
|