Commit 1ec03a6fff0ee426b5774ab3ad21448c802a1821
1 parent
bd15971a
fix:DEFECT-585 修复登录超管账号,点击租户配置,选择一行编辑,报400,前端未传入任何数据,再点一次编辑,成功
Showing
1 changed file
with
110 additions
and
116 deletions
1 | <template> | 1 | <template> |
2 | <div class="drawer-class"> | 2 | <div class="drawer-class"> |
3 | - <BasicDrawer | ||
4 | - v-bind="$attrs" | ||
5 | - @register="registerDrawer" | ||
6 | - showFooter | ||
7 | - :title="getTitle" | ||
8 | - width="700px" | ||
9 | - @ok="handleSubmit" | ||
10 | - > | 3 | + <BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="700px" |
4 | + @ok="handleSubmit"> | ||
11 | <BasicForm @register="registerForm" /> | 5 | <BasicForm @register="registerForm" /> |
12 | <CpnsTenantSet ref="getChildData" :parentData="parentSetData" /> | 6 | <CpnsTenantSet ref="getChildData" :parentData="parentSetData" /> |
13 | </BasicDrawer> | 7 | </BasicDrawer> |
14 | </div> | 8 | </div> |
15 | </template> | 9 | </template> |
16 | <script lang="ts"> | 10 | <script lang="ts"> |
17 | - import { defineComponent, ref, computed, unref, getCurrentInstance, reactive } from 'vue'; | ||
18 | - import { BasicForm, useForm } from '/@/components/Form'; | ||
19 | - import { formSchema } from './config'; | ||
20 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
21 | - import CpnsTenantSet from './cpns/index.vue'; | ||
22 | - import { saveTenantProfileApi } from '/@/api/tenant/tenantApi'; | ||
23 | - import { useMessage } from '/@/hooks/web/useMessage'; | 11 | +import { defineComponent, ref, computed, unref, getCurrentInstance, reactive } from 'vue'; |
12 | +import { BasicForm, useForm } from '/@/components/Form'; | ||
13 | +import { formSchema } from './config'; | ||
14 | +import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
15 | +import CpnsTenantSet from './cpns/index.vue'; | ||
16 | +import { saveTenantProfileApi } from '/@/api/tenant/tenantApi'; | ||
17 | +import { useMessage } from '/@/hooks/web/useMessage'; | ||
24 | 18 | ||
25 | - export default defineComponent({ | ||
26 | - name: 'ConfigDrawer', | ||
27 | - components: { BasicDrawer, BasicForm, CpnsTenantSet }, | ||
28 | - emits: ['success', 'register'], | ||
29 | - setup(_, { emit }) { | ||
30 | - const { createMessage } = useMessage(); | ||
31 | - const isUpdate = ref(true); | ||
32 | - let postAllData: any = reactive({}); | ||
33 | - const parentSetData: any = ref(null); | ||
34 | - let getValuesFormData: any = reactive({}); | ||
35 | - const { proxy } = getCurrentInstance() as any; | ||
36 | - const getChildData = ref(null); | ||
37 | - const editGetId: any = ref(''); | ||
38 | - const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | ||
39 | - schemas: formSchema, | ||
40 | - showActionButtonGroup: false, | ||
41 | - }); | ||
42 | - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
43 | - //清除表单值 | ||
44 | - proxy.$refs.getChildData.funcResetFields(); | ||
45 | - await resetFields(); | ||
46 | - setDrawerProps({ confirmLoading: false }); | ||
47 | - isUpdate.value = !!data?.isUpdate; | ||
48 | - if (!unref(isUpdate)) { | ||
49 | - editGetId.value = ''; | ||
50 | - } | ||
51 | - //编辑 | ||
52 | - if (unref(isUpdate)) { | ||
53 | - parentSetData.value = { ...data.record.profileData.configuration }; | ||
54 | - proxy.$refs.getChildData.setFieldsValueFunc(parentSetData.value); | ||
55 | - editGetId.value = data.record.id; | ||
56 | - await setFieldsValue({ | ||
57 | - ...data.record, | ||
58 | - }); | ||
59 | - } | ||
60 | - }); | ||
61 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); | ||
62 | - | ||
63 | - const getAllFieldsFunc = async () => { | ||
64 | - getValuesFormData = await validate(); | ||
65 | - if (!getValuesFormData) return; | ||
66 | - let getChildValues = proxy.$refs.getChildData.getAllFields(); | ||
67 | - let profileData1 = { | ||
68 | - configuration: getChildValues, | ||
69 | - }; | ||
70 | - const id: any = { | ||
71 | - id: unref(isUpdate) ? editGetId.value : '', | ||
72 | - }; | 19 | +export default defineComponent({ |
20 | + name: 'ConfigDrawer', | ||
21 | + components: { BasicDrawer, BasicForm, CpnsTenantSet }, | ||
22 | + emits: ['success', 'register'], | ||
23 | + setup(_, { emit }) { | ||
24 | + const { createMessage } = useMessage(); | ||
25 | + const isUpdate = ref(true); | ||
26 | + let postAllData: any = reactive({}); | ||
27 | + const parentSetData: any = ref(null); | ||
28 | + let getValuesFormData: any = reactive({}); | ||
29 | + const { proxy } = getCurrentInstance() as any; | ||
30 | + const getChildData = ref(null); | ||
31 | + const editGetId: any = ref(''); | ||
32 | + const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | ||
33 | + schemas: formSchema, | ||
34 | + showActionButtonGroup: false, | ||
35 | + }); | ||
36 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
37 | + //清除表单值 | ||
38 | + proxy.$refs.getChildData.funcResetFields(); | ||
39 | + await resetFields(); | ||
40 | + setDrawerProps({ confirmLoading: false }); | ||
41 | + isUpdate.value = !!data?.isUpdate; | ||
42 | + if (!unref(isUpdate)) { | ||
43 | + editGetId.value = ''; | ||
44 | + } | ||
45 | + //编辑 | ||
46 | + if (unref(isUpdate)) { | ||
47 | + parentSetData.value = { ...data.record.profileData.configuration }; | ||
48 | + proxy.$refs.getChildData.setFieldsValueFunc(parentSetData.value); | ||
49 | + editGetId.value = data.record.id; | ||
50 | + await setFieldsValue({ | ||
51 | + ...data.record, | ||
52 | + }); | ||
53 | + } | ||
54 | + }); | ||
55 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); | ||
73 | 56 | ||
74 | - const createTime = { | ||
75 | - createdTime: Date.now(), | ||
76 | - }; | 57 | + const getAllFieldsFunc = async () => { |
58 | + getValuesFormData = await validate(); | ||
59 | + if (!getValuesFormData) return; | ||
60 | + let getChildValues = proxy.$refs.getChildData.getAllFields(); | ||
61 | + let profileData1 = { | ||
62 | + configuration: getChildValues, | ||
63 | + }; | ||
64 | + const id: any = { | ||
65 | + id: unref(isUpdate) ? editGetId.value : '', | ||
66 | + }; | ||
77 | 67 | ||
78 | - Object.assign( | ||
79 | - postAllData, | ||
80 | - { | ||
81 | - profileData: profileData1, | ||
82 | - }, | ||
83 | - getValuesFormData, | ||
84 | - id, | ||
85 | - createTime | ||
86 | - ); | ||
87 | - if (!unref(isUpdate)) { | ||
88 | - delete postAllData.id; | ||
89 | - } | 68 | + const createTime = { |
69 | + createdTime: Date.now(), | ||
90 | }; | 70 | }; |
91 | 71 | ||
92 | - async function handleSubmit() { | ||
93 | - setDrawerProps({ confirmLoading: true }); | ||
94 | - try { | ||
95 | - if (!unref(isUpdate)) { | ||
96 | - getAllFieldsFunc(); | ||
97 | - await saveTenantProfileApi(postAllData); | ||
98 | - createMessage.success('租户配置新增成功'); | ||
99 | - closeDrawer(); | ||
100 | - emit('success'); | ||
101 | - resetFields(); | ||
102 | - } else { | ||
103 | - getAllFieldsFunc(); | ||
104 | - await saveTenantProfileApi(postAllData); | ||
105 | - createMessage.success('租户配置编辑成功'); | ||
106 | - closeDrawer(); | ||
107 | - emit('success'); | ||
108 | - } | ||
109 | - } catch (e) { | ||
110 | - } finally { | ||
111 | - setTimeout(() => { | ||
112 | - setDrawerProps({ confirmLoading: false }); | ||
113 | - }, 300); | 72 | + Object.assign( |
73 | + postAllData, | ||
74 | + { | ||
75 | + profileData: profileData1, | ||
76 | + }, | ||
77 | + getValuesFormData, | ||
78 | + id, | ||
79 | + createTime | ||
80 | + ); | ||
81 | + if (!unref(isUpdate)) { | ||
82 | + delete postAllData.id; | ||
83 | + } | ||
84 | + }; | ||
85 | + | ||
86 | + async function handleSubmit() { | ||
87 | + setDrawerProps({ confirmLoading: true }); | ||
88 | + try { | ||
89 | + if (!unref(isUpdate)) { | ||
90 | + await getAllFieldsFunc(); | ||
91 | + await saveTenantProfileApi(postAllData); | ||
92 | + createMessage.success('租户配置新增成功'); | ||
93 | + closeDrawer(); | ||
94 | + emit('success'); | ||
95 | + resetFields(); | ||
96 | + } else { | ||
97 | + await getAllFieldsFunc(); | ||
98 | + await saveTenantProfileApi(postAllData); | ||
99 | + createMessage.success('租户配置编辑成功'); | ||
100 | + closeDrawer(); | ||
101 | + emit('success'); | ||
114 | } | 102 | } |
103 | + } catch (e) { | ||
104 | + } finally { | ||
105 | + setTimeout(() => { | ||
106 | + setDrawerProps({ confirmLoading: false }); | ||
107 | + }, 300); | ||
115 | } | 108 | } |
116 | - return { | ||
117 | - parentSetData, | ||
118 | - getChildData, | ||
119 | - registerDrawer, | ||
120 | - registerForm, | ||
121 | - getTitle, | ||
122 | - handleSubmit, | ||
123 | - }; | ||
124 | - }, | ||
125 | - }); | 109 | + } |
110 | + return { | ||
111 | + parentSetData, | ||
112 | + getChildData, | ||
113 | + registerDrawer, | ||
114 | + registerForm, | ||
115 | + getTitle, | ||
116 | + handleSubmit, | ||
117 | + }; | ||
118 | + }, | ||
119 | +}); | ||
126 | </script> | 120 | </script> |
127 | 121 | ||
128 | <style lang="less"> | 122 | <style lang="less"> |
129 | - .drawer-class { | ||
130 | - .ant-row { | ||
131 | - .ant-col { | ||
132 | - :deep .ant-input-number { | ||
133 | - width: 34vw !important; | ||
134 | - } | 123 | +.drawer-class { |
124 | + .ant-row { | ||
125 | + .ant-col { | ||
126 | + :deep .ant-input-number { | ||
127 | + width: 34vw !important; | ||
135 | } | 128 | } |
136 | } | 129 | } |
137 | } | 130 | } |
131 | +} | ||
138 | </style> | 132 | </style> |