|
|
@ -28,6 +28,7 @@ export default { |
|
|
|
@submit="load" |
|
|
|
:hideButton="true" |
|
|
|
:isQueryForm="true" |
|
|
|
v-if="queryFromSchema" |
|
|
|
/> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
@ -215,7 +216,7 @@ export default { |
|
|
|
.el-overlay { |
|
|
|
} |
|
|
|
</style>`, |
|
|
|
props: ["modelValue", "controller", "buttons"], |
|
|
|
props: ["modelValue", "schema", "controller", "query", "buttons"], |
|
|
|
emits: ["command"], |
|
|
|
async setup(props, context) { |
|
|
|
const treeProps = reactive({ |
|
|
@ -237,7 +238,8 @@ export default { |
|
|
|
const indexUrl = `${baseUrl}/index`; |
|
|
|
const data = ref({}); |
|
|
|
const sortColumns = ref(new Map()); |
|
|
|
const queryFromSchema = ref({}); |
|
|
|
const schema = ref(props.schema); |
|
|
|
const queryFromSchema = ref(null); |
|
|
|
const tableSchema = ref({}); |
|
|
|
const tableData = ref([]); |
|
|
|
const editFormRef = ref(null); |
|
|
@ -299,14 +301,13 @@ export default { |
|
|
|
tableLoading.value = true; |
|
|
|
try { |
|
|
|
const postData = JSON.parse(JSON.stringify(data.value)); |
|
|
|
// delete postData["Id"];
|
|
|
|
// delete postData["items"];
|
|
|
|
delete postData.query["items"]; |
|
|
|
delete postData.query["id"]; |
|
|
|
const listData = (await post(url, postData)).data; |
|
|
|
if (tableSchema.value.isTree) { |
|
|
|
listData.items = listToTree(listData.items); |
|
|
|
} |
|
|
|
tableData.value = listData.items; |
|
|
|
delete listData["items"]; |
|
|
|
data.value = listData; |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
@ -325,25 +326,25 @@ export default { |
|
|
|
} else if (item.path === "details") { |
|
|
|
//details
|
|
|
|
const detailsUrl = `${baseUrl}/${item.path}?${qs.stringify({ id: rows[0].id })}`; |
|
|
|
Object.assign(editFormSchema, schema.properties.items.items); |
|
|
|
Object.assign(editFormSchema, schema.value.properties.items.items); |
|
|
|
Object.assign(editFormModel, (await post(detailsUrl)).data); |
|
|
|
editFormTitle.value = `${t("details")}${schema.title}`; |
|
|
|
editFormTitle.value = `${t("details")}${schema.value?.title}`; |
|
|
|
dialogVisible.value = true; |
|
|
|
} else if (item.path === "create") { |
|
|
|
//create
|
|
|
|
const url = `${baseUrl}/${item.path}`; |
|
|
|
const vm = (await get(url)).data; |
|
|
|
Object.assign(editFormSchema, vm.schema); |
|
|
|
Object.assign(editFormSchema, schema.value); |
|
|
|
Object.assign(editFormModel, vm.model); |
|
|
|
editFormTitle.value = `${t("create")}${schema.title}`; |
|
|
|
editFormTitle.value = `${t("create")}${schema.value?.title}`; |
|
|
|
dialogVisible.value = true; |
|
|
|
} else if (item.path === "update") { |
|
|
|
//update
|
|
|
|
const url = `${baseUrl}/${item.path}`; |
|
|
|
const vm = (await get(url, { id: rows[0].id })).data; |
|
|
|
Object.assign(editFormSchema, vm.schema); |
|
|
|
Object.assign(editFormSchema, schema.value); |
|
|
|
Object.assign(editFormModel, vm.model); |
|
|
|
editFormTitle.value = `${t("update")}${schema.title}`; |
|
|
|
editFormTitle.value = `${t("update")}${schema.value?.title}`; |
|
|
|
dialogVisible.value = true; |
|
|
|
} else if (item.path === "delete") { |
|
|
|
//delete
|
|
|
@ -364,7 +365,7 @@ export default { |
|
|
|
} else if (item.path === "import") { |
|
|
|
//import
|
|
|
|
const url = `${baseUrl}/${item.path}`; |
|
|
|
editFormTitle.value = `${t("import")}${schema.title}`; |
|
|
|
editFormTitle.value = `${t("import")}${schema.value?.title}`; |
|
|
|
dialogVisible.value = true; |
|
|
|
} |
|
|
|
}; |
|
|
@ -419,12 +420,15 @@ export default { |
|
|
|
}; |
|
|
|
onMounted(async () => { |
|
|
|
const vm = (await get(indexUrl)).data; |
|
|
|
const schema = vm.schema; |
|
|
|
queryFromSchema.value = schema.properties.query; |
|
|
|
tableSchema.value = schema.properties.items.items; |
|
|
|
data.value = vm.model ?? schemaToModel(schema); |
|
|
|
schema.value = vm.schema; |
|
|
|
queryFromSchema.value = vm.schema.properties.query; |
|
|
|
tableSchema.value = vm.schema.properties.items.items; |
|
|
|
data.value = vm.model ?? schemaToModel(vm.schema); |
|
|
|
if (props.query) { |
|
|
|
Object.assign(data.value.query, props.query); |
|
|
|
} |
|
|
|
getSortModel(data.value); |
|
|
|
getColumns(schema.properties.query); |
|
|
|
getColumns(vm.schema.properties.query); |
|
|
|
await load(indexUrl); |
|
|
|
}); |
|
|
|
return { |
|
|
|