Browse Source

update

pull/1/head
wanggang 1 year ago
parent
commit
dbd8a4aabd
  1. 2
      docs/demo/src/WTA/wwwroot/components/form/form-item.js
  2. 38
      docs/demo/src/WTA/wwwroot/components/list/index.js

2
docs/demo/src/WTA/wwwroot/components/form/form-item.js

@ -9,7 +9,7 @@ export default {
<template v-if="schema.type==='object'"></template> <template v-if="schema.type==='object'"></template>
<template v-else-if="schema.type!=='array'||schema.items.type!=='array'"> <template v-else-if="schema.type!=='array'||schema.items.type!=='array'">
<el-form-item <el-form-item
:title="schema.type" :title="prop"
:label="schema.title" :label="schema.title"
:prop="getProp(prop)" :prop="getProp(prop)"
:rules="getRules(parentSchema,schema,model)" :rules="getRules(parentSchema,schema,model)"

38
docs/demo/src/WTA/wwwroot/components/list/index.js

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

Loading…
Cancel
Save