Commit f7d66b4e5a9799ee4cf3aab633134a1c6b32757d
Merge branch 'perf/ota/06-28' into 'main_dev'
perf: 云端环境中,OTA升级包新增时,产品总共18条,pagesize为10只显示了10条,应该显示所有的产品 See merge request yunteng/thingskit-front!1395
Showing
2 changed files
with
21 additions
and
23 deletions
... | ... | @@ -3,7 +3,12 @@ |
3 | 3 | import { BasicForm, useForm } from '/@/components/Form'; |
4 | 4 | import { ALG, formSchema, PackageField } from '../config/packageDetail.config'; |
5 | 5 | import { ref } from 'vue'; |
6 | - import { createOtaPackage, uploadOtaPackages, deleteOtaPackage } from '/@/api/ota'; | |
6 | + import { | |
7 | + createOtaPackage, | |
8 | + uploadOtaPackages, | |
9 | + deleteOtaPackage, | |
10 | + getDeviceProfileInfo, | |
11 | + } from '/@/api/ota'; | |
7 | 12 | import { CreateOtaPackageParams } from '/@/api/ota/model'; |
8 | 13 | |
9 | 14 | interface FieldsValue extends CreateOtaPackageParams { |
... | ... | @@ -14,6 +19,8 @@ |
14 | 19 | |
15 | 20 | const emit = defineEmits(['register', 'update:list']); |
16 | 21 | |
22 | + const defaultDeviceProfile = 'default'; | |
23 | + | |
17 | 24 | const loading = ref(false); |
18 | 25 | |
19 | 26 | const [registerModal, { changeLoading, closeModal }] = useModalInner(); |
... | ... | @@ -72,6 +79,10 @@ |
72 | 79 | try { |
73 | 80 | await validate(); |
74 | 81 | const value = getFieldsValue(); |
82 | + if (value[PackageField.DEVICE_PROFILE_INFO] === defaultDeviceProfile) { | |
83 | + const data = await getDeviceProfileInfo(defaultDeviceProfile); | |
84 | + value[PackageField.DEVICE_PROFILE_INFO] = data.id.id; | |
85 | + } | |
75 | 86 | value[PackageField.DEVICE_PROFILE_INFO] = { |
76 | 87 | id: value[PackageField.DEVICE_PROFILE_INFO], |
77 | 88 | entityType: 'DEVICE_PROFILE', | ... | ... |
1 | -import { getDeviceProfileInfo, getDeviceProfileInfos } from '/@/api/ota'; | |
1 | +import { getDeviceProfileInfos } from '/@/api/ota'; | |
2 | 2 | |
3 | 3 | import { FormSchema } from '/@/components/Form'; |
4 | 4 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; |
5 | +import { createPickerSearch } from '/@/utils/pickerSearch'; | |
5 | 6 | |
6 | 7 | export enum PackageField { |
7 | 8 | TITLE = 'title', |
... | ... | @@ -107,39 +108,25 @@ export const formSchema: FormSchema[] = [ |
107 | 108 | { |
108 | 109 | field: PackageField.DEVICE_PROFILE_INFO, |
109 | 110 | label: '所属产品', |
110 | - component: 'ApiSearchSelect', | |
111 | + component: 'ApiSelectScrollLoad', | |
111 | 112 | helpMessage: ['上传的包仅适用于具有所选配置文件的设备'], |
112 | 113 | rules: [{ required: true, message: '所属产品为必填项' }], |
113 | 114 | defaultValue: 'default', |
114 | - componentProps: ({ formModel, formActionType }) => { | |
115 | + componentProps: () => { | |
115 | 116 | return { |
116 | 117 | placeholder: '请选择所属产品', |
117 | - showSearch: true, | |
118 | 118 | labelField: 'name', |
119 | 119 | valueField: 'id', |
120 | + pagination: { page: 0, pageSize: 10 }, | |
120 | 121 | api: async (params: Recordable) => { |
121 | - const data = await getDeviceProfileInfos(params); | |
122 | - return data.data.map((item) => ({ | |
122 | + const { totalElements, data } = await getDeviceProfileInfos(params); | |
123 | + const dataList = data.map((item) => ({ | |
123 | 124 | ...item, |
124 | 125 | id: item.id.id, |
125 | 126 | })); |
127 | + return { items: dataList, total: totalElements }; | |
126 | 128 | }, |
127 | - params: (textSearch: string) => { | |
128 | - return { | |
129 | - page: 0, | |
130 | - pageSize: 10, | |
131 | - textSearch, | |
132 | - }; | |
133 | - }, | |
134 | - queryApi: async (id = 'default') => { | |
135 | - const data = await getDeviceProfileInfo(id); | |
136 | - | |
137 | - if (formModel[PackageField.DEVICE_PROFILE_INFO] === 'default' && id === 'default') { | |
138 | - formActionType.setFieldsValue({ [PackageField.DEVICE_PROFILE_INFO]: data.id.id }); | |
139 | - } | |
140 | - | |
141 | - return { ...data, id: data.id.id }; | |
142 | - }, | |
129 | + ...createPickerSearch(), | |
143 | 130 | }; |
144 | 131 | }, |
145 | 132 | }, | ... | ... |