Showing
5 changed files
with
62 additions
and
43 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,24 @@ | @@ -139,20 +148,24 @@ | ||
| 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 | + transportType: item?.transportType, | ||
| 167 | + deviceType: item?.deviceType, | ||
| 168 | + })) | ||
| 156 | ); | 169 | ); |
| 157 | }; | 170 | }; |
| 158 | // | 171 | // |
| @@ -170,7 +183,12 @@ | @@ -170,7 +183,12 @@ | ||
| 170 | const getCurrentAllProduct = async (products: string[]) => { | 183 | const getCurrentAllProduct = async (products: string[]) => { |
| 171 | const resp = (await getDeviceProfile()) as any; | 184 | const resp = (await getDeviceProfile()) as any; |
| 172 | if (!resp) return; | 185 | if (!resp) return; |
| 173 | - const values = resp?.map((item) => ({ name: item.name, profileId: item.id })); | 186 | + const values = resp?.map((item) => ({ |
| 187 | + name: item.name, | ||
| 188 | + profileId: item.id, | ||
| 189 | + deviceType: item.deviceType, | ||
| 190 | + transportType: item.transportType, | ||
| 191 | + })); | ||
| 174 | return values.filter((item) => products?.includes(item.profileId)); | 192 | return values.filter((item) => products?.includes(item.profileId)); |
| 175 | }; | 193 | }; |
| 176 | 194 |
| @@ -5,6 +5,7 @@ import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter | @@ -5,6 +5,7 @@ import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter | ||
| 5 | import { useComponentRegister } from '/@/components/Form'; | 5 | import { useComponentRegister } from '/@/components/Form'; |
| 6 | import { OrgTreeSelect } from '../../common/OrgTreeSelect'; | 6 | import { OrgTreeSelect } from '../../common/OrgTreeSelect'; |
| 7 | import { getDeviceProfile } from '/@/api/alarm/position'; | 7 | import { getDeviceProfile } from '/@/api/alarm/position'; |
| 8 | +import { buildUUID } from '/@/utils/uuid'; | ||
| 8 | 9 | ||
| 9 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); | 10 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); |
| 10 | export enum Platform { | 11 | export enum Platform { |
| @@ -22,11 +23,9 @@ export enum ConfigurationPermission { | @@ -22,11 +23,9 @@ export enum ConfigurationPermission { | ||
| 22 | UN_SHARE = 'api:yt:configuration:center:monopoly', | 23 | UN_SHARE = 'api:yt:configuration:center:monopoly', |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | -export const PC_DEFAULT_CONTENT = | ||
| 26 | - '<mxfile><diagram>dZHBDsIgDIafhvuEzOh5Tr142sEzGXWQsHVhmKFP7xbAidMT5fv/UtoSVrTuZHgvLyhAE5oJR9iBUMrybT4dM3l4stnTzJPGKBHYAir1hACj7a4EDInRImqr+hTW2HVQ24RxY3BMbTfUadWeN7ACVc31ml6VsPK7jVk4g2pkLJ3tgtLy6A5gkFzg+IFYSVhhEK2PWleAnscXB+Pzjn/U988MdPZHwhQsb0+XZEesfAE=</diagram></mxfile>'; | 26 | +export const PC_DEFAULT_CONTENT = `<mxfile><diagram id="${buildUUID()}">dZHBDsIgDIafhvuEzOh5Tr142sEzGXWQsHVhmKFP7xbAidMT5fv/UtoSVrTuZHgvLyhAE5oJR9iBUMrybT4dM3l4stnTzJPGKBHYAir1hACj7a4EDInRImqr+hTW2HVQ24RxY3BMbTfUadWeN7ACVc31ml6VsPK7jVk4g2pkLJ3tgtLy6A5gkFzg+IFYSVhhEK2PWleAnscXB+Pzjn/U988MdPZHwhQsb0+XZEesfAE=</diagram></mxfile>`; |
| 27 | 27 | ||
| 28 | -export const PHONE_DEFAULT_CONTENT = | ||
| 29 | - '<mxfile><diagram>dZHBEoIgEEC/hru6lXU2q0snD50Z2YQZdB2k0fr6dMCMsU4sb9+ysDDI6uFseCuvJFCzJBIDgyNLkjjdw7hM5OnIYRc5UBklvLSAQr3Qw1l7KIFdIFoibVUbwpKaBksbMG4M9aF2Jx12bXmFK1CUXK/pTQkrHd3E24VfUFXSd04hdYmaz65/SCe5oP4LQc4gM0TWRfWQoZ5mN4/F1Z3+ZD/3MtjYHwVjsJw9boIPgvwN</diagram></mxfile>'; | 28 | +export const PHONE_DEFAULT_CONTENT = `<mxfile><diagram id="${buildUUID()}">dZHBEoIgEEC/hru6lXU2q0snD50Z2YQZdB2k0fr6dMCMsU4sb9+ysDDI6uFseCuvJFCzJBIDgyNLkjjdw7hM5OnIYRc5UBklvLSAQr3Qw1l7KIFdIFoibVUbwpKaBksbMG4M9aF2Jx12bXmFK1CUXK/pTQkrHd3E24VfUFXSd04hdYmaz65/SCe5oP4LQc4gM0TWRfWQoZ5mN4/F1Z3+ZD/3MtjYHwVjsJw9boIPgvwN</diagram></mxfile>`; |
| 30 | // 表格列数据 | 29 | // 表格列数据 |
| 31 | export const columns: BasicColumn[] = [ | 30 | export const columns: BasicColumn[] = [ |
| 32 | { | 31 | { |
| @@ -153,14 +152,17 @@ export const formSchema: FormSchema[] = [ | @@ -153,14 +152,17 @@ export const formSchema: FormSchema[] = [ | ||
| 153 | defaultValue: 0, | 152 | defaultValue: 0, |
| 154 | componentProps: ({ formActionType }) => { | 153 | componentProps: ({ formActionType }) => { |
| 155 | const { setFieldsValue } = formActionType; | 154 | const { setFieldsValue } = formActionType; |
| 155 | + | ||
| 156 | return { | 156 | return { |
| 157 | checkedValue: 1, | 157 | checkedValue: 1, |
| 158 | unCheckedValue: 0, | 158 | unCheckedValue: 0, |
| 159 | checkedChildren: '开', | 159 | checkedChildren: '开', |
| 160 | unCheckedChildren: '关', | 160 | unCheckedChildren: '关', |
| 161 | - onChange() { | 161 | + onChange: () => { |
| 162 | setFieldsValue({ | 162 | setFieldsValue({ |
| 163 | productIds: [], | 163 | productIds: [], |
| 164 | + templateId: null, | ||
| 165 | + productId: undefined, | ||
| 164 | }); | 166 | }); |
| 165 | }, | 167 | }, |
| 166 | }; | 168 | }; |
| @@ -181,6 +183,7 @@ export const formSchema: FormSchema[] = [ | @@ -181,6 +183,7 @@ export const formSchema: FormSchema[] = [ | ||
| 181 | field: 'templateId', //暂且使用插槽形式 | 183 | field: 'templateId', //暂且使用插槽形式 |
| 182 | label: '模板', | 184 | label: '模板', |
| 183 | component: 'Input', | 185 | component: 'Input', |
| 186 | + required: true, | ||
| 184 | slot: 'templateId', | 187 | slot: 'templateId', |
| 185 | colProps: { span: 24 }, | 188 | colProps: { span: 24 }, |
| 186 | ifShow: ({ values }) => values['enableTemplate'] === 1, | 189 | ifShow: ({ values }) => values['enableTemplate'] === 1, |
| @@ -194,14 +197,6 @@ export const formSchema: FormSchema[] = [ | @@ -194,14 +197,6 @@ export const formSchema: FormSchema[] = [ | ||
| 194 | ifShow: ({ values }) => values['enableTemplate'] === 1 && values['templateId'], | 197 | ifShow: ({ values }) => values['enableTemplate'] === 1 && values['templateId'], |
| 195 | }, | 198 | }, |
| 196 | { | 199 | { |
| 197 | - field: 'deviceIds', //暂且使用插槽形式 | ||
| 198 | - label: '设备', | ||
| 199 | - component: 'Input', | ||
| 200 | - slot: 'deviceIds', | ||
| 201 | - colProps: { span: 24 }, | ||
| 202 | - ifShow: ({ values }) => values['enableTemplate'] === 1 && values['templateId'], | ||
| 203 | - }, | ||
| 204 | - { | ||
| 205 | field: 'productId', | 200 | field: 'productId', |
| 206 | label: '产品', | 201 | label: '产品', |
| 207 | component: 'ApiSelect', | 202 | component: 'ApiSelect', |
| @@ -53,6 +53,8 @@ | @@ -53,6 +53,8 @@ | ||
| 53 | dynamicInput.params.push({ | 53 | dynamicInput.params.push({ |
| 54 | name: props.value.label, | 54 | name: props.value.label, |
| 55 | profileId: props.value.value, | 55 | profileId: props.value.value, |
| 56 | + deviceType: props.value?.deviceType, | ||
| 57 | + transportType: props.value?.transportType, | ||
| 56 | deviceList: props.value.deviceList?.filter(Boolean)?.map((item) => item.deviceId), | 58 | deviceList: props.value.deviceList?.filter(Boolean)?.map((item) => item.deviceId), |
| 57 | }); | 59 | }); |
| 58 | } | 60 | } |
| @@ -67,17 +69,20 @@ | @@ -67,17 +69,20 @@ | ||
| 67 | 69 | ||
| 68 | //chang改变 | 70 | //chang改变 |
| 69 | const emitChange = () => { | 71 | const emitChange = () => { |
| 70 | - const findDeviceDict = selectOptions.value.map((item) => { | ||
| 71 | - if (dynamicInput.params[0].deviceList?.includes(item.value)) { | ||
| 72 | - return { | ||
| 73 | - name: item.label, | ||
| 74 | - deviceId: item.value, | ||
| 75 | - }; | ||
| 76 | - } | 72 | + const tempDeviceList: Recordable[] = []; // fix: 修改选择设备顺序问题 |
| 73 | + dynamicInput.params[0].deviceList?.forEach((item) => { | ||
| 74 | + selectOptions.value?.forEach((newItem) => { | ||
| 75 | + if (item === newItem.value) { | ||
| 76 | + tempDeviceList.push({ | ||
| 77 | + name: newItem.label, | ||
| 78 | + deviceId: newItem.value, | ||
| 79 | + }); | ||
| 80 | + } | ||
| 81 | + }); | ||
| 77 | }); | 82 | }); |
| 78 | return { | 83 | return { |
| 79 | ...dynamicInput.params[0], | 84 | ...dynamicInput.params[0], |
| 80 | - deviceList: findDeviceDict.filter(Boolean), | 85 | + deviceList: tempDeviceList.filter(Boolean), // 过滤假值 |
| 81 | }; | 86 | }; |
| 82 | }; | 87 | }; |
| 83 | defineExpose({ | 88 | defineExpose({ |
| @@ -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) => { |
| @@ -71,7 +71,12 @@ | @@ -71,7 +71,12 @@ | ||
| 71 | const getCurrentAllProduct = async (products: string[]) => { | 71 | const getCurrentAllProduct = async (products: string[]) => { |
| 72 | const resp = (await getDeviceProfile()) as any; | 72 | const resp = (await getDeviceProfile()) as any; |
| 73 | if (!resp) return; | 73 | if (!resp) return; |
| 74 | - const values = resp.map((item) => ({ name: item.name, profileId: item.id })); | 74 | + const values = resp.map((item) => ({ |
| 75 | + name: item.name, | ||
| 76 | + profileId: item.id, | ||
| 77 | + deviceType: item.deviceType, | ||
| 78 | + transportType: item.transportType, | ||
| 79 | + })); | ||
| 75 | return values.filter((item) => products.includes(item.profileId)); | 80 | return values.filter((item) => products.includes(item.profileId)); |
| 76 | }; | 81 | }; |
| 77 | 82 |