Commit c378175feced2c40e4a59b30828a2c48c4628453
1 parent
d918d635
fix: DEFECT-853 ota list not exist edit button
Showing
4 changed files
with
44 additions
and
18 deletions
... | ... | @@ -23,31 +23,40 @@ |
23 | 23 | |
24 | 24 | const loading = ref(false); |
25 | 25 | |
26 | + const isUpdate = ref(false); | |
27 | + | |
26 | 28 | const otaRecord = ref<OtaRecordDatum>({} as unknown as OtaRecordDatum); |
27 | 29 | |
28 | 30 | const deviceProfileInfo = ref<DeviceProfileRecord>({} as unknown as DeviceProfileRecord); |
29 | 31 | |
30 | 32 | const { createConfirm, createMessage } = useMessage(); |
31 | 33 | |
32 | - const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({ | |
34 | + const [registerForm, { setFieldsValue, getFieldsValue, updateSchema }] = useForm({ | |
33 | 35 | schemas: formSchema, |
34 | 36 | showActionButtonGroup: false, |
35 | 37 | disabled: true, |
36 | 38 | }); |
37 | 39 | |
38 | - const [register, { closeDrawer, changeLoading }] = useDrawerInner(async (id: string) => { | |
39 | - try { | |
40 | - const record = await getOtaPackageInfo(id); | |
41 | - const deviceInfo = await getDeviceProfileInfoById(record.deviceProfileId.id); | |
42 | - setFieldsValue({ | |
43 | - ...record, | |
44 | - [PackageField.DESCRIPTION]: record.additionalInfo.description, | |
45 | - [PackageField.DEVICE_PROFILE_INFO]: deviceInfo.name, | |
46 | - }); | |
47 | - deviceProfileInfo.value = deviceInfo; | |
48 | - otaRecord.value = record; | |
49 | - } catch (error) {} | |
50 | - }); | |
40 | + const [register, { closeDrawer, changeLoading }] = useDrawerInner( | |
41 | + async (params: { id: string; isUpdate: boolean }) => { | |
42 | + try { | |
43 | + const { id, isUpdate: flag } = params; | |
44 | + isUpdate.value = flag; | |
45 | + const record = await getOtaPackageInfo(id); | |
46 | + const deviceInfo = await getDeviceProfileInfoById(record.deviceProfileId.id); | |
47 | + setFieldsValue({ | |
48 | + ...record, | |
49 | + [PackageField.DESCRIPTION]: record.additionalInfo.description, | |
50 | + [PackageField.DEVICE_PROFILE_INFO]: deviceInfo.name, | |
51 | + }); | |
52 | + deviceProfileInfo.value = deviceInfo; | |
53 | + otaRecord.value = record; | |
54 | + if (unref(isUpdate)) { | |
55 | + updateSchema({ field: PackageField.DESCRIPTION, dynamicDisabled: false }); | |
56 | + } | |
57 | + } catch (error) {} | |
58 | + } | |
59 | + ); | |
51 | 60 | |
52 | 61 | // const [registerTBDrawer, TBDrawerMethod] = useDrawer(); |
53 | 62 | |
... | ... | @@ -146,7 +155,9 @@ |
146 | 155 | > |
147 | 156 | <Button class="mr-2" @click="closeDrawer">取消</Button> |
148 | 157 | <Authority :value="OtaPermissionKey.UPDATE"> |
149 | - <Button type="primary" :loading="loading" @click="handleSubmit">保存</Button> | |
158 | + <Button v-if="isUpdate" type="primary" :loading="loading" @click="handleSubmit"> | |
159 | + 保存 | |
160 | + </Button> | |
150 | 161 | </Authority> |
151 | 162 | </div> |
152 | 163 | </template> | ... | ... |
... | ... | @@ -13,6 +13,7 @@ export enum OtaPermissionKey { |
13 | 13 | UPDATE = 'api:operation:ota:update', |
14 | 14 | DELETE = 'api:operation:ota:delete', |
15 | 15 | DOWNLOAD = 'api:operation:ota:download', |
16 | + DETAIL = 'api:operation:ota:detail', | |
16 | 17 | } |
17 | 18 | |
18 | 19 | export const columns: BasicColumn[] = [ |
... | ... | @@ -80,6 +81,7 @@ export const columns: BasicColumn[] = [ |
80 | 81 | dataIndex: 'action', |
81 | 82 | flag: 'ACTION', |
82 | 83 | fixed: 'right', |
84 | + width: 200, | |
83 | 85 | slots: { |
84 | 86 | customRender: 'action', |
85 | 87 | }, | ... | ... |
... | ... | @@ -57,8 +57,8 @@ |
57 | 57 | openModal(true, { isUpdate: false } as ModalPassRecord); |
58 | 58 | }; |
59 | 59 | |
60 | - const handleOpenDetailDrawer = (record: OtaRecordDatum) => { | |
61 | - openDrawer(true, record.id.id); | |
60 | + const handleOpenDetailDrawer = (record: OtaRecordDatum, isUpdate: boolean) => { | |
61 | + openDrawer(true, { id: record.id.id, isUpdate }); | |
62 | 62 | }; |
63 | 63 | |
64 | 64 | const downloadFile = async (record: OtaRecordDatum) => { |
... | ... | @@ -117,6 +117,20 @@ |
117 | 117 | @click.stop |
118 | 118 | :actions="[ |
119 | 119 | { |
120 | + label: '详情', | |
121 | + icon: 'ant-design:eye-outlined', | |
122 | + auth: OtaPermissionKey.DETAIL, | |
123 | + onClick: handleOpenDetailDrawer.bind(null, record, false), | |
124 | + }, | |
125 | + { | |
126 | + label: '编辑', | |
127 | + icon: 'clarity:note-edit-line', | |
128 | + auth: OtaPermissionKey.UPDATE, | |
129 | + onClick: handleOpenDetailDrawer.bind(null, record, true), | |
130 | + }, | |
131 | + ]" | |
132 | + :drop-down-actions="[ | |
133 | + { | |
120 | 134 | label: '下载', |
121 | 135 | icon: 'ant-design:download-outlined', |
122 | 136 | auth: OtaPermissionKey.DOWNLOAD, | ... | ... |