From 1c110cc232228583422fd60274c040bc92c8e4a6 Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 11 May 2023 17:37:09 +0800 Subject: [PATCH] refactor: vben dict --- src/components/DictTag/src/DictTag.vue | 11 ++-------- .../Form/src/components/ApiSelect.vue | 9 +++++++- src/components/Table/src/hooks/useRender.ts | 9 ++++---- src/utils/dict.ts | 22 ++++++++++++++----- src/views/bpm/form/form.data.ts | 4 ++-- src/views/bpm/group/group.data.ts | 6 ++--- src/views/bpm/model/model.data.ts | 10 ++++----- src/views/bpm/oa/leave/leave.data.ts | 6 ++--- .../infra/apiAccessLog/apiAccessLog.data.ts | 4 ++-- .../infra/apiErrorLog/apiErrorLog.data.ts | 6 ++--- src/views/infra/codegen/codegen.data.ts | 4 ++-- src/views/infra/codegen/components/data.ts | 8 +++---- src/views/infra/config/config.data.ts | 4 ++-- .../infra/fileConfig/ficleConfig.data.ts | 6 ++--- src/views/infra/job/job.data.ts | 4 ++-- src/views/infra/job/logger/jobLog.data.ts | 4 ++-- src/views/mp/message/message.data.ts | 4 ++-- src/views/pay/app/app.data.ts | 6 ++--- src/views/pay/demo/demo.data.ts | 4 ++-- src/views/pay/merchant/merchant.data.ts | 6 ++--- src/views/pay/order/order.data.ts | 10 ++++----- src/views/pay/refund/refund.data.ts | 10 ++++----- src/views/pay/submit/index.vue | 4 ++-- src/views/system/dept/dept.data.ts | 6 ++--- src/views/system/dict/dict.data.ts | 6 ++--- src/views/system/dict/dict.type.ts | 6 ++--- src/views/system/errorCode/errorCode.data.ts | 4 ++-- src/views/system/mail/account/account.data.ts | 4 ++-- src/views/system/mail/log/mailLog.data.ts | 6 ++--- .../system/mail/template/template.data.ts | 6 ++--- src/views/system/menu/menu.data.ts | 8 +++---- src/views/system/notice/notice.data.ts | 8 +++---- .../system/notify/message/message.data.ts | 4 ++-- src/views/system/notify/my/my.data.ts | 8 +++---- .../system/notify/template/template.data.ts | 8 +++---- src/views/system/oauth2/client/client.data.ts | 8 +++---- src/views/system/oauth2/token/token.data.ts | 4 ++-- .../system/operatelog/operateLog.data.ts | 4 ++-- src/views/system/post/post.data.ts | 6 ++--- src/views/system/role/role.data.ts | 8 +++---- .../sensitiveWord/sensitiveWord.data.ts | 6 ++--- .../system/sms/channel/smsChannel.data.ts | 8 +++---- src/views/system/sms/log/smsLog.data.ts | 6 ++--- .../system/sms/template/smsTemplate.data.ts | 12 +++++----- src/views/system/tenant/tenant.data.ts | 6 ++--- .../tenantPackage/tenantPackage.data.ts | 6 ++--- src/views/system/user/user.data.ts | 8 +++---- 47 files changed, 164 insertions(+), 153 deletions(-) diff --git a/src/components/DictTag/src/DictTag.vue b/src/components/DictTag/src/DictTag.vue index ed535d9..1f6bc24 100644 --- a/src/components/DictTag/src/DictTag.vue +++ b/src/components/DictTag/src/DictTag.vue @@ -2,7 +2,7 @@ import { defineComponent, PropType, ref } from 'vue' import { isHexColor } from '@/utils/color' import { Tag } from 'ant-design-vue' -import { DictDataType, getBoolDictOptions, getDictOptions, getStrDictOptions } from '@/utils/dict' +import { DictDataType, getDictOpts } from '@/utils/dict' import { propTypes } from '@/utils/propTypes' export default defineComponent({ @@ -13,20 +13,13 @@ export default defineComponent({ required: true }, value: propTypes.oneOfType([propTypes.string, propTypes.number, propTypes.bool]), - dictType: propTypes.oneOf(['string', 'boolean', 'number']).def('number'), icon: { type: String } }, setup(props) { const dictData = ref() const getDictObj = (dictType: string, value: string) => { let dictOptions: DictDataType[] = [] - if (props.dictType && props.dictType === 'boolean') { - dictOptions = getBoolDictOptions(dictType) - } else if (props.dictType && props.dictType === 'string') { - dictOptions = getStrDictOptions(dictType) - } else { - dictOptions = getDictOptions(dictType) - } + dictOptions = getDictOpts(dictType) if (dictOptions && dictOptions.length === 0) { return } diff --git a/src/components/Form/src/components/ApiSelect.vue b/src/components/Form/src/components/ApiSelect.vue index d1c2200..5eb242a 100644 --- a/src/components/Form/src/components/ApiSelect.vue +++ b/src/components/Form/src/components/ApiSelect.vue @@ -1,5 +1,12 @@