Commit 512eff6b authored by mengzixuan's avatar mengzixuan

feat: (工程投资计划): 删除问题修复

parent 1eedb3ba
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<a-button type="primary" v-if="!disabled" @click="handleSubmit"> 提交 </a-button> <a-button type="primary" v-if="!disabled" @click="handleSubmit"> 提交 </a-button>
<a-button type="default" @click="router.back()"> 返回 </a-button> <a-button type="default" @click="router.back()"> 返回 </a-button>
</template> </template>
<template v-for="(item, index) in tabsFormSchema">
<PageCard v-for="(item, index) in tabsFormSchema" :key="index" :title="item.name"> <PageCard v-if="item.show" :key="index" :title="item.name">
<template #right> <template #right>
<a-button <a-button
type="text" type="text"
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
/> />
</div> </div>
</PageCard> </PageCard>
</template>
<a-button v-if="!disabled" type="dashed" @click="add" preIcon="ei:plus"> <a-button v-if="!disabled" type="dashed" @click="add" preIcon="ei:plus">
从项目库导入 从项目库导入
</a-button> </a-button>
...@@ -185,11 +186,12 @@ ...@@ -185,11 +186,12 @@
engineerId.value = id; engineerId.value = id;
isUpdate.value = true; isUpdate.value = true;
let res = await getItem({ id }); let res = await getItem({ id });
console.log('getItem', res); // console.log('getItem', res);
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
const item = { const item = {
name: '序号' + (i + 1), name: '序号' + (i + 1),
forceRender: true, forceRender: true,
show: true,
Form: useForm( Form: useForm(
Object.assign({ schemas: formSchema, disabled }, baseFormConfig) as FormProps, Object.assign({ schemas: formSchema, disabled }, baseFormConfig) as FormProps,
), ),
...@@ -217,7 +219,9 @@ ...@@ -217,7 +219,9 @@
id: info.id, id: info.id,
investmentId: info.investmentId, investmentId: info.investmentId,
}; };
if (formData.value.investmentPlan === undefined) {
formData.value.investmentPlan = []; formData.value.investmentPlan = [];
}
formData.value.investmentPlan.push(data); formData.value.investmentPlan.push(data);
console.log('info', info); console.log('info', info);
const { setTableData } = item.table[1]; const { setTableData } = item.table[1];
...@@ -254,6 +258,7 @@ ...@@ -254,6 +258,7 @@
type TabsFormType = { type TabsFormType = {
name: string; name: string;
forceRender?: boolean; forceRender?: boolean;
show?: boolean;
Form: UseFormReturnType; Form: UseFormReturnType;
table: any; table: any;
}; };
...@@ -263,7 +268,7 @@ ...@@ -263,7 +268,7 @@
layout: 'vertical', layout: 'vertical',
}; };
const tabsFormSchema = reactive<TabsFormType[]>([]); let tabsFormSchema = reactive<TabsFormType[]>([]);
async function add() { async function add() {
openModal(); openModal();
...@@ -283,6 +288,7 @@ ...@@ -283,6 +288,7 @@
const item = { const item = {
name: '序号' + (tabsFormSchema.length + 1), name: '序号' + (tabsFormSchema.length + 1),
forceRender: true, forceRender: true,
show: true,
Form: useForm(Object.assign({ schemas: formSchema }, baseFormConfig) as FormProps), Form: useForm(Object.assign({ schemas: formSchema }, baseFormConfig) as FormProps),
table: useTable({ table: useTable({
title: '表尾行合计示例', title: '表尾行合计示例',
...@@ -348,8 +354,9 @@ ...@@ -348,8 +354,9 @@
}); });
} }
async function deleteItem(index: any) { async function deleteItem(index: any) {
tabsFormSchema.splice(index, 1); tabsFormSchema[index].show = false;
formData.value.investmentPlan.splice(index, 1); // tabsFormSchema.splice(index, 1);
// formData.value.investmentPlan.splice(index, 1);
} }
async function handleAdd() { async function handleAdd() {
openDrawer(true, { openDrawer(true, {
...@@ -366,6 +373,7 @@ ...@@ -366,6 +373,7 @@
try { try {
for (let i = 0; i < tabsFormSchema.length; i++) { for (let i = 0; i < tabsFormSchema.length; i++) {
let item = tabsFormSchema[i]; let item = tabsFormSchema[i];
if (item.show) {
const { validate, getFieldsValue } = item.Form[1]; const { validate, getFieldsValue } = item.Form[1];
const { getDataSource } = item.table[1]; const { getDataSource } = item.table[1];
await validate(); await validate();
...@@ -390,6 +398,7 @@ ...@@ -390,6 +398,7 @@
); );
formData.value.id = engineerId.value; formData.value.id = engineerId.value;
} }
}
formData.value.proNumber = formData.value.investmentPlan.Length; formData.value.proNumber = formData.value.investmentPlan.Length;
console.log(' formData()', unref(formData)); console.log(' formData()', unref(formData));
// console.log(' setTableData()', setTableData); // console.log(' setTableData()', setTableData);
......
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