fix: 修复明细表删除行时,会删除第一页数据的bug

This commit is contained in:
gaoyunqi
2024-07-08 20:44:05 +08:00
parent 10cea57723
commit 4e00feddb0
2 changed files with 37 additions and 5 deletions

View File

@ -0,0 +1,31 @@
# 如何在二开中只修改脚本不修改模版
可以在继承SimpleFormSetup时不指定模版
```vue
<script>
// 注意这里继承的是SimpleFormSetup使用script setup写法的组件无法继承必须使用特别的版本
import SimpleFormSetup from '/@/components/SimpleForm/src/SimpleFormSetup.vue';
export default {
mixins: [SimpleFormSetup],
setup(props, ctx) {
const ret = SimpleFormSetup.setup(props, ctx);
return {
...ret
};
},
watch: {
formModel: {
handler: function(oldVal, newVal){
console.log('表单被改了!' + Math.random());
this.formModel.zheDie17153 = this.formModel.zhaGe15916 + this.formModel.zhaGe22645
},
deep: true
}
}
};
</script>
```
这里可以通过对formModel的监控和修改完成计算、赋值操作。

View File

@ -1,6 +1,5 @@
<template>
<div>
<a-table :bordered="showFormBorder" :columns="headColums.length > 0 ? headColums : columns" :data-source="addDataKey(data)" :pagination="showPagination ? { defaultPageSize: 10 } : false" :scroll="{ x: 'max-content' }">
<template #summary>
<a-table-summary-row v-if="columns.some((x) => x.componentProps?.subTotal)">
@ -54,11 +53,11 @@
<template v-else-if="column.key !== 'index'">
<component
:is="componentMap.get(column.componentType)"
:key="column.dataIndex + record['_key_']"
v-model:value="record[column.dataIndex]"
:bordered="showComponentBorder"
:index="index"
:mainKey="mainKey"
:key="column.dataIndex + record['_key_']"
:row="record"
v-bind="getComponentsProps(column.componentProps, column.dataIndex, record, index)"
@blur="onFieldBlur(column, record, index)"
@ -68,7 +67,7 @@
</FormItem>
</template>
<template v-if="column.key === 'action' && !disabled">
<MinusCircleOutlined style="padding-bottom: 20px" @click="remove(index)" />
<MinusCircleOutlined style="padding-bottom: 20px" @click="remove(record)" />
</template>
</template>
</a-table>
@ -113,6 +112,7 @@
import { getDicDetailList } from '/@/api/system/dic';
import { useI18n } from '/@/hooks/web/useI18n';
import { MutipleHeadInfo } from '/@/components/Designer';
import { buildUUID } from '/@/utils/uuid';
const { t } = useI18n();
// 用于包裹弹窗的form组件 因为一个FormItem 只能收集一个表单组件 所以弹窗的form 必须排除
@ -237,7 +237,7 @@
function addDataKey(rows) {
rows.forEach((row) => {
if (!row['_key_']) {
row['_key_'] = Math.random();
row['_key_'] = buildUUID();
}
});
return rows;
@ -375,7 +375,8 @@
}
};
const remove = (index) => {
const remove = (record) => {
const index = data.value.findIndex((r) => r._key_ === record._key_);
data.value.splice(index, 1);
emit('change', unref(data));
emit('update:value', unref(data));