Commit f16db0c70671dfa592e31ca07aa2a3b08f493217
1 parent
25d1a1ec
fix: fix bug DEFECT-394
修复消息模板类型对应配置问题
Showing
4 changed files
with
45 additions
and
10 deletions
@@ -15,8 +15,7 @@ enum MessageConfigApi { | @@ -15,8 +15,7 @@ enum MessageConfigApi { | ||
15 | * 获取当前租户下的所有配置 | 15 | * 获取当前租户下的所有配置 |
16 | */ | 16 | */ |
17 | export const findMessageConfig = (params: MessageParams) => { | 17 | export const findMessageConfig = (params: MessageParams) => { |
18 | - console.log(params, 'params'); | ||
19 | - return defHttp.post<MessageConfigResult>({ | 18 | + return defHttp.post<MessageConfigResult[]>({ |
20 | url: MessageConfigApi.CONFIG_URL + '/find', | 19 | url: MessageConfigApi.CONFIG_URL + '/find', |
21 | params, | 20 | params, |
22 | }); | 21 | }); |
@@ -18,6 +18,7 @@ | @@ -18,6 +18,7 @@ | ||
18 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 18 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
19 | import { saveOrEditMessageTemplate } from '/@/api/message/template'; | 19 | import { saveOrEditMessageTemplate } from '/@/api/message/template'; |
20 | import { useMessage } from '/@/hooks/web/useMessage'; | 20 | import { useMessage } from '/@/hooks/web/useMessage'; |
21 | + import { findMessageConfig } from '/@/api/message/config'; | ||
21 | export default defineComponent({ | 22 | export default defineComponent({ |
22 | name: 'TemplateDrawer', | 23 | name: 'TemplateDrawer', |
23 | components: { BasicDrawer, BasicForm }, | 24 | components: { BasicDrawer, BasicForm }, |
@@ -40,6 +41,20 @@ | @@ -40,6 +41,20 @@ | ||
40 | Reflect.set(data.record, key + '', config[key]); | 41 | Reflect.set(data.record, key + '', config[key]); |
41 | } | 42 | } |
42 | await setFieldsValue(data.record); | 43 | await setFieldsValue(data.record); |
44 | + const res = await findMessageConfig({}); | ||
45 | + const options = res.map((item) => { | ||
46 | + return { | ||
47 | + disabled: item.messageType !== data.record.messageType, | ||
48 | + label: item.configName, | ||
49 | + value: item.id, | ||
50 | + }; | ||
51 | + }); | ||
52 | + await updateSchema({ | ||
53 | + field: 'messageConfigId', | ||
54 | + componentProps: { | ||
55 | + options, | ||
56 | + }, | ||
57 | + }); | ||
43 | if (data.record.templatePurpose === 'FOR_LOGIN') { | 58 | if (data.record.templatePurpose === 'FOR_LOGIN') { |
44 | updateSchema({ | 59 | updateSchema({ |
45 | field: 'templatePurpose', | 60 | field: 'templatePurpose', |
@@ -120,13 +120,34 @@ export const formSchema: FormSchema[] = [ | @@ -120,13 +120,34 @@ export const formSchema: FormSchema[] = [ | ||
120 | label: '消息类型', | 120 | label: '消息类型', |
121 | required: true, | 121 | required: true, |
122 | component: 'ApiSelect', | 122 | component: 'ApiSelect', |
123 | - componentProps: { | ||
124 | - api: findDictItemByCode, | ||
125 | - params: { | ||
126 | - dictCode: 'message_type', | ||
127 | - }, | ||
128 | - labelField: 'itemText', | ||
129 | - valueField: 'itemValue', | 123 | + componentProps({ formActionType }) { |
124 | + return { | ||
125 | + api: findDictItemByCode, | ||
126 | + params: { | ||
127 | + dictCode: 'message_type', | ||
128 | + }, | ||
129 | + labelField: 'itemText', | ||
130 | + valueField: 'itemValue', | ||
131 | + onChange: async (value) => { | ||
132 | + const res = await findMessageConfig({}); | ||
133 | + let typeId: Nullable<string> = null; | ||
134 | + const options = res.map((item) => { | ||
135 | + if (item.messageType === value) typeId = item.id; | ||
136 | + return { | ||
137 | + disabled: item.messageType !== value, | ||
138 | + label: item.configName, | ||
139 | + value: item.id, | ||
140 | + }; | ||
141 | + }); | ||
142 | + await formActionType.setFieldsValue({ messageConfigId: typeId }); | ||
143 | + await formActionType.updateSchema({ | ||
144 | + field: 'messageConfigId', | ||
145 | + componentProps: { | ||
146 | + options, | ||
147 | + }, | ||
148 | + }); | ||
149 | + }, | ||
150 | + }; | ||
130 | }, | 151 | }, |
131 | }, | 152 | }, |
132 | { | 153 | { |