-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bugs in menu tree generating
- Loading branch information
Showing
20 changed files
with
879 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { defHttp } from '/@/utils/http/axios'; | ||
import { ErrorMessageMode } from '/#/axios'; | ||
import { BaseIdReq, BasePageReq, BaseResp } from '/@/api/model/baseModel'; | ||
import { | ||
DictionaryDetailInfo, | ||
DictionaryDetailListResp, | ||
DictionaryInfo, | ||
DictionaryListResp, | ||
} from './model/dictionaryModel'; | ||
|
||
enum Api { | ||
GetDictionaryList = '/sys-api/dict/list', | ||
CreateOrUpdateOrDeleteDictionary = '/sys-api/dict', | ||
GetDictionaryDetailList = '/sys-api/dict/detail/list', | ||
CreateOrUpdateOrDeleteDictionaryDetail = '/sys-api/dict/detail', | ||
} | ||
|
||
/** | ||
* @description: Get dictionary list | ||
*/ | ||
|
||
export const getDictionaryList = (params: BasePageReq) => { | ||
return defHttp.post<DictionaryListResp>({ url: Api.GetDictionaryList, params }); | ||
}; | ||
|
||
/** | ||
* author: ryan | ||
* @description: create a new dictionary | ||
*/ | ||
export const createOrUpdateDictionary = ( | ||
params: DictionaryInfo, | ||
mode: ErrorMessageMode = 'modal', | ||
) => { | ||
return defHttp.post<BaseResp>( | ||
{ url: Api.CreateOrUpdateOrDeleteDictionary, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; | ||
|
||
/** | ||
* author: Ryan Su | ||
* @description: delete dictionary | ||
*/ | ||
export const deleteDictionary = (params: BaseIdReq, mode: ErrorMessageMode = 'modal') => { | ||
return defHttp.delete<BaseResp>( | ||
{ url: Api.CreateOrUpdateOrDeleteDictionary, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; | ||
|
||
/** | ||
* @description: Get dictionary detail list | ||
*/ | ||
|
||
export const getDictionaryDetailList = (params: BasePageReq) => { | ||
return defHttp.post<DictionaryDetailListResp>({ url: Api.GetDictionaryDetailList, params }); | ||
}; | ||
|
||
/** | ||
* author: ryan | ||
* @description: create a new dictionary detail | ||
*/ | ||
export const createOrUpdateDictionaryDetail = ( | ||
params: DictionaryDetailInfo, | ||
mode: ErrorMessageMode = 'modal', | ||
) => { | ||
return defHttp.post<BaseResp>( | ||
{ url: Api.CreateOrUpdateOrDeleteDictionaryDetail, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; | ||
|
||
/** | ||
* author: Ryan Su | ||
* @description: delete dictionary detail | ||
*/ | ||
export const deleteDictionaryDetail = (params: BaseIdReq, mode: ErrorMessageMode = 'modal') => { | ||
return defHttp.delete<BaseResp>( | ||
{ url: Api.CreateOrUpdateOrDeleteDictionaryDetail, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { BaseListResp } from '../../model/baseModel'; | ||
|
||
/** | ||
* author: Ryan Su | ||
* @description: dictionary info response | ||
*/ | ||
export interface DictionaryInfo { | ||
id: number; | ||
createAt?: number; | ||
name: string; | ||
title: string; | ||
description: string; | ||
status: boolean; | ||
} | ||
|
||
/** | ||
* author: Ryan Su | ||
* @description: dictionary list response | ||
*/ | ||
|
||
export type DictionaryListResp = BaseListResp<DictionaryInfo>; | ||
|
||
/** | ||
* author: Ryan Su | ||
* @description: dictionary detail info response | ||
*/ | ||
export interface DictionaryDetailInfo { | ||
id: number; | ||
createAt?: number; | ||
title: string; | ||
key: string; | ||
value: string; | ||
status: boolean; | ||
parentId: number; | ||
} | ||
|
||
/** | ||
* author: Ryan Su | ||
* @description: dictionary detail list response | ||
*/ | ||
|
||
export type DictionaryDetailListResp = BaseListResp<DictionaryDetailInfo>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<template> | ||
<div> | ||
<BasicTable @register="registerTable"> | ||
<template #toolbar> | ||
<a-button type="primary" @click="handleCreate"> | ||
{{ t('sys.dictionary.addDictionaryDetail') }} | ||
</a-button> | ||
</template> | ||
<template #bodyCell="{ column, record }"> | ||
<template v-if="column.key === 'action'"> | ||
<TableAction | ||
:actions="[ | ||
{ | ||
icon: 'clarity:note-edit-line', | ||
onClick: handleEdit.bind(null, record), | ||
}, | ||
{ | ||
icon: 'ant-design:delete-outlined', | ||
color: 'error', | ||
popConfirm: { | ||
title: t('common.deleteConfirm'), | ||
placement: 'left', | ||
confirm: handleDelete.bind(null, record), | ||
}, | ||
}, | ||
]" | ||
/> | ||
</template> | ||
</template> | ||
</BasicTable> | ||
<DictionaryDrawer @register="registerDrawer" @success="handleSuccess" /> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
import { useDrawer } from '/@/components/Drawer'; | ||
import DictionaryDrawer from './detailDrawer.vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import { useMessage } from '/@/hooks/web/useMessage'; | ||
import { columns } from './dictionary.data'; | ||
import { deleteDictionary, getDictionaryDetailList } from '/@/api/sys/dictionary'; | ||
export default defineComponent({ | ||
name: 'DictionaryDetail', | ||
components: { BasicTable, DictionaryDrawer, TableAction }, | ||
setup() { | ||
const { t } = useI18n(); | ||
const [registerDrawer, { openDrawer }] = useDrawer(); | ||
const { notification } = useMessage(); | ||
const { currentRoute } = useRouter(); | ||
const [registerTable, { reload }] = useTable({ | ||
title: t('sys.dictionary.dictionaryDetailList'), | ||
api: getDictionaryDetailList, | ||
columns, | ||
formConfig: { | ||
labelWidth: 120, | ||
schemas: [ | ||
{ | ||
field: 'name', | ||
label: t('sys.dictionary.name'), | ||
defaultValue: currentRoute.value.query.name, | ||
component: 'Input', | ||
colProps: { span: 8 }, | ||
rules: [{ max: 10 }], | ||
}, | ||
], | ||
}, | ||
useSearchForm: true, | ||
showTableSetting: true, | ||
bordered: true, | ||
showIndexColumn: false, | ||
actionColumn: { | ||
width: 30, | ||
title: t('common.action'), | ||
dataIndex: 'action', | ||
fixed: undefined, | ||
}, | ||
}); | ||
function handleCreate() { | ||
openDrawer(true, { | ||
isUpdate: false, | ||
}); | ||
} | ||
function handleEdit(record: Recordable) { | ||
openDrawer(true, { | ||
record, | ||
isUpdate: true, | ||
}); | ||
} | ||
async function handleDelete(record: Recordable) { | ||
const result = await deleteDictionary({ id: record.id }, 'modal'); | ||
notification.success({ | ||
message: t('common.successful'), | ||
description: t(result.msg), | ||
duration: 3, | ||
}); | ||
reload(); | ||
} | ||
function handleSuccess() { | ||
reload(); | ||
} | ||
return { | ||
t, | ||
registerTable, | ||
registerDrawer, | ||
handleCreate, | ||
handleEdit, | ||
handleDelete, | ||
handleSuccess, | ||
}; | ||
}, | ||
}); | ||
</script> |
Oops, something went wrong.