Skip to content

Commit

Permalink
fix(projects): fix manage page drawer operate about data reset
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jun 6, 2024
1 parent e77bda1 commit 91dfa57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/hooks/common/table.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { computed, effectScope, onScopeDispose, reactive, ref, watch } from 'vue';
import type { Ref } from 'vue';
import type { TablePaginationConfig } from 'ant-design-vue';
import { cloneDeep } from 'lodash-es';
import { useBoolean, useHookTable } from '@sa/hooks';
import { useAppStore } from '@/store/modules/app';
import { $t } from '@/locales';
Expand Down Expand Up @@ -166,7 +167,8 @@ export function useTableOperate<T extends TableData = TableData>(data: Ref<T[]>,

function handleEdit(id: T['id']) {
operateType.value = 'edit';
editingData.value = data.value.find(item => item.id === id) || null;
const findItem = data.value.find(item => item.id === id) || null;
editingData.value = cloneDeep(findItem);

openDrawer();
}
Expand Down
9 changes: 3 additions & 6 deletions src/views/manage/role/modules/role-operate-drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ const roleId = computed(() => props.rowData?.id || -1);
const isEdit = computed(() => props.operateType === 'edit');
function handleUpdateModelWhenEdit() {
if (props.operateType === 'add') {
Object.assign(model, createDefaultModel());
return;
}
function handleInitModel() {
Object.assign(model, createDefaultModel());
if (props.operateType === 'edit' && props.rowData) {
Object.assign(model, props.rowData);
Expand All @@ -93,7 +90,7 @@ async function handleSubmit() {
watch(visible, () => {
if (visible.value) {
handleUpdateModelWhenEdit();
handleInitModel();
resetFields();
}
});
Expand Down

0 comments on commit 91dfa57

Please sign in to comment.