Skip to content

Commit

Permalink
perf(projects): perf page manage_role, useTable
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jan 27, 2024
1 parent 0e9e2e1 commit 39aa7aa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/hooks/common/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ export function useNaiveForm() {
await formRef.value?.validate();
}

async function restoreValidation() {
formRef.value?.restoreValidation();
}

return {
formRef,
validate
validate,
restoreValidation
};
}
4 changes: 3 additions & 1 deletion src/hooks/common/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { DataTableBaseColumn, DataTableExpandColumn, DataTableSelectionColu
import type { TableColumnGroup } from 'naive-ui/es/data-table/src/interface';
import { useBoolean, useLoading } from '@sa/hooks';
import { useAppStore } from '@/store/modules/app';
import { $t } from '@/locales';

type BaseData = Record<string, unknown>;

Expand Down Expand Up @@ -174,6 +175,7 @@ function useTableColumn<TableData extends BaseData, CustomColumnKey = never>(

function reloadColumns() {
allColumns.value = factory();
filteredColumns.value = getFilteredColumns(factory());
}

function getFilteredColumns(aColumns: TableColumn<TableData, CustomColumnKey>[]) {
Expand All @@ -191,7 +193,7 @@ function useTableColumn<TableData extends BaseData, CustomColumnKey = never>(
if (column.type === 'selection') {
cols.push({
key: SELECTION_KEY,
title: '勾选',
title: $t('common.check'),
checked: true
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/locales/langs/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const local: App.I18n.Schema = {
},
common: {
action: '操作',
add: '添加',
add: '新增',
addSuccess: '添加成功',
backToHome: '返回首页',
batchDelete: '批量删除',
Expand Down Expand Up @@ -265,7 +265,7 @@ const local: App.I18n.Schema = {
roleCode: '角色编码',
roleStatus: '角色状态',
roleDesc: '角色描述',
addRole: '添加角色',
addRole: '新增角色',
editRole: '编辑角色',
status: {
enable: '启用',
Expand Down
3 changes: 2 additions & 1 deletion src/views/manage/role/operate-role-drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const visible = defineModel<boolean>('visible', {
default: false
});
const { formRef, validate } = useNaiveForm();
const { formRef, validate, restoreValidation } = useNaiveForm();
const { defaultRequiredRule } = useFormRules();
const title = computed(() => {
Expand Down Expand Up @@ -94,6 +94,7 @@ async function handleSubmit() {
watch(visible, () => {
if (visible.value) {
handleUpdateModelWhenEdit();
restoreValidation();
}
});
</script>
Expand Down

1 comment on commit 39aa7aa

@vercel
Copy link

@vercel vercel bot commented on 39aa7aa Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

soybean-admin – ./

soybean-admin-eta.vercel.app
soybean-admin-git-main-soybeanjs.vercel.app
soybean-admin-soybeanjs.vercel.app

Please sign in to comment.