Commit 9ed244e0147d3f7557923964baaeeef19c625f85
1 parent
d15d96df
fix: 修复启用模版再选择模版,对应的产品会回显,但是再点开关,选择模版,产品未回显
Showing
3 changed files
with
40 additions
and
29 deletions
| @@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
| 26 | v-if="model['templateId']" | 26 | v-if="model['templateId']" |
| 27 | ref="selectDeviceProfileRef" | 27 | ref="selectDeviceProfileRef" |
| 28 | :selectOptions="selectOptions" | 28 | :selectOptions="selectOptions" |
| 29 | - :organizationId="model['organizationId']" | 29 | + :organizationId="model?.['organizationId']" |
| 30 | /> | 30 | /> |
| 31 | </template> | 31 | </template> |
| 32 | </BasicForm> | 32 | </BasicForm> |
| @@ -71,12 +71,21 @@ | @@ -71,12 +71,21 @@ | ||
| 71 | }); | 71 | }); |
| 72 | await updateSchema({ | 72 | await updateSchema({ |
| 73 | field: 'enableTemplate', | 73 | field: 'enableTemplate', |
| 74 | - componentProps: { | ||
| 75 | - disabled, | ||
| 76 | - checkedValue: 1, | ||
| 77 | - unCheckedValue: 0, | ||
| 78 | - checkedChildren: '开', | ||
| 79 | - unCheckedChildren: '关', | 74 | + componentProps: ({ formActionType }) => { |
| 75 | + return { | ||
| 76 | + disabled, | ||
| 77 | + checkedValue: 1, | ||
| 78 | + unCheckedValue: 0, | ||
| 79 | + checkedChildren: '开', | ||
| 80 | + unCheckedChildren: '关', | ||
| 81 | + onChange: () => { | ||
| 82 | + formActionType.setFieldsValue({ | ||
| 83 | + productIds: [], | ||
| 84 | + templateId: null, | ||
| 85 | + productId: undefined, | ||
| 86 | + }); | ||
| 87 | + }, | ||
| 88 | + }; | ||
| 80 | }, | 89 | }, |
| 81 | }); | 90 | }); |
| 82 | }; | 91 | }; |
| @@ -139,20 +148,22 @@ | @@ -139,20 +148,22 @@ | ||
| 139 | value: item.id, | 148 | value: item.id, |
| 140 | })); | 149 | })); |
| 141 | }; | 150 | }; |
| 142 | - | ||
| 143 | const selectOptions: Ref<any[]> = ref([]); | 151 | const selectOptions: Ref<any[]> = ref([]); |
| 144 | 152 | ||
| 145 | const handleTemplateChange = async (_, option) => { | 153 | const handleTemplateChange = async (_, option) => { |
| 146 | const { productAndDevice } = option; | 154 | const { productAndDevice } = option; |
| 147 | - if (!productAndDevice) return; | ||
| 148 | - selectOptions.value = productAndDevice.map((item) => ({ | ||
| 149 | - label: item.name, | ||
| 150 | - value: item.profileId, | ||
| 151 | - })); | 155 | + // if (!productAndDevice) return; |
| 156 | + // selectOptions.value = productAndDevice?.map((item) => ({ | ||
| 157 | + // label: item.profileName || item.name, | ||
| 158 | + // value: item.profileId, | ||
| 159 | + // })); | ||
| 152 | await nextTick(); | 160 | await nextTick(); |
| 153 | // 赋值 | 161 | // 赋值 |
| 154 | selectDeviceProfileRef.value?.setFieldsValue( | 162 | selectDeviceProfileRef.value?.setFieldsValue( |
| 155 | - productAndDevice.map((item) => ({ label: item.name, value: item.profileId })) | 163 | + productAndDevice?.map((item) => ({ |
| 164 | + label: item.profileName || item.name, | ||
| 165 | + value: item.profileId, | ||
| 166 | + })) | ||
| 156 | ); | 167 | ); |
| 157 | }; | 168 | }; |
| 158 | // | 169 | // |
| @@ -153,14 +153,17 @@ export const formSchema: FormSchema[] = [ | @@ -153,14 +153,17 @@ export const formSchema: FormSchema[] = [ | ||
| 153 | defaultValue: 0, | 153 | defaultValue: 0, |
| 154 | componentProps: ({ formActionType }) => { | 154 | componentProps: ({ formActionType }) => { |
| 155 | const { setFieldsValue } = formActionType; | 155 | const { setFieldsValue } = formActionType; |
| 156 | + | ||
| 156 | return { | 157 | return { |
| 157 | checkedValue: 1, | 158 | checkedValue: 1, |
| 158 | unCheckedValue: 0, | 159 | unCheckedValue: 0, |
| 159 | checkedChildren: '开', | 160 | checkedChildren: '开', |
| 160 | unCheckedChildren: '关', | 161 | unCheckedChildren: '关', |
| 161 | - onChange() { | 162 | + onChange: () => { |
| 162 | setFieldsValue({ | 163 | setFieldsValue({ |
| 163 | productIds: [], | 164 | productIds: [], |
| 165 | + templateId: null, | ||
| 166 | + productId: undefined, | ||
| 164 | }); | 167 | }); |
| 165 | }, | 168 | }, |
| 166 | }; | 169 | }; |
| @@ -181,6 +184,7 @@ export const formSchema: FormSchema[] = [ | @@ -181,6 +184,7 @@ export const formSchema: FormSchema[] = [ | ||
| 181 | field: 'templateId', //暂且使用插槽形式 | 184 | field: 'templateId', //暂且使用插槽形式 |
| 182 | label: '模板', | 185 | label: '模板', |
| 183 | component: 'Input', | 186 | component: 'Input', |
| 187 | + required: true, | ||
| 184 | slot: 'templateId', | 188 | slot: 'templateId', |
| 185 | colProps: { span: 24 }, | 189 | colProps: { span: 24 }, |
| 186 | ifShow: ({ values }) => values['enableTemplate'] === 1, | 190 | ifShow: ({ values }) => values['enableTemplate'] === 1, |
| @@ -193,14 +197,14 @@ export const formSchema: FormSchema[] = [ | @@ -193,14 +197,14 @@ export const formSchema: FormSchema[] = [ | ||
| 193 | colProps: { span: 24 }, | 197 | colProps: { span: 24 }, |
| 194 | ifShow: ({ values }) => values['enableTemplate'] === 1 && values['templateId'], | 198 | ifShow: ({ values }) => values['enableTemplate'] === 1 && values['templateId'], |
| 195 | }, | 199 | }, |
| 196 | - { | ||
| 197 | - field: 'deviceIds', //暂且使用插槽形式 | ||
| 198 | - label: '设备', | ||
| 199 | - component: 'Input', | ||
| 200 | - slot: 'deviceIds', | ||
| 201 | - colProps: { span: 24 }, | ||
| 202 | - ifShow: ({ values }) => values['enableTemplate'] === 1 && values['templateId'], | ||
| 203 | - }, | 200 | + // { |
| 201 | + // field: 'deviceIds', //暂且使用插槽形式 | ||
| 202 | + // label: '设备', | ||
| 203 | + // component: 'Input', | ||
| 204 | + // slot: 'deviceIds', | ||
| 205 | + // colProps: { span: 24 }, | ||
| 206 | + // ifShow: ({ values }) => values['enableTemplate'] === 1 && values['templateId'], | ||
| 207 | + // }, | ||
| 204 | { | 208 | { |
| 205 | field: 'productId', | 209 | field: 'productId', |
| 206 | label: '产品', | 210 | label: '产品', |
| @@ -56,12 +56,8 @@ | @@ -56,12 +56,8 @@ | ||
| 56 | 56 | ||
| 57 | const setFieldsValue = async (productIds) => { | 57 | const setFieldsValue = async (productIds) => { |
| 58 | await nextTick(); | 58 | await nextTick(); |
| 59 | - if (!productIds && !productIds.length) { | ||
| 60 | - return; | ||
| 61 | - } | ||
| 62 | - selectValue.value = productIds; | ||
| 63 | - | ||
| 64 | - profileList.value = productIds; | 59 | + selectValue.value = productIds || []; |
| 60 | + profileList.value = productIds || []; | ||
| 65 | }; | 61 | }; |
| 66 | 62 | ||
| 67 | const setValue = (value: any) => { | 63 | const setValue = (value: any) => { |