Commit c378175feced2c40e4a59b30828a2c48c4628453

Authored by ww
1 parent d918d635

fix: DEFECT-853 ota list not exist edit button

@@ -23,31 +23,40 @@ @@ -23,31 +23,40 @@
23 23
24 const loading = ref(false); 24 const loading = ref(false);
25 25
  26 + const isUpdate = ref(false);
  27 +
26 const otaRecord = ref<OtaRecordDatum>({} as unknown as OtaRecordDatum); 28 const otaRecord = ref<OtaRecordDatum>({} as unknown as OtaRecordDatum);
27 29
28 const deviceProfileInfo = ref<DeviceProfileRecord>({} as unknown as DeviceProfileRecord); 30 const deviceProfileInfo = ref<DeviceProfileRecord>({} as unknown as DeviceProfileRecord);
29 31
30 const { createConfirm, createMessage } = useMessage(); 32 const { createConfirm, createMessage } = useMessage();
31 33
32 - const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({ 34 + const [registerForm, { setFieldsValue, getFieldsValue, updateSchema }] = useForm({
33 schemas: formSchema, 35 schemas: formSchema,
34 showActionButtonGroup: false, 36 showActionButtonGroup: false,
35 disabled: true, 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 // const [registerTBDrawer, TBDrawerMethod] = useDrawer(); 61 // const [registerTBDrawer, TBDrawerMethod] = useDrawer();
53 62
@@ -146,7 +155,9 @@ @@ -146,7 +155,9 @@
146 > 155 >
147 <Button class="mr-2" @click="closeDrawer">取消</Button> 156 <Button class="mr-2" @click="closeDrawer">取消</Button>
148 <Authority :value="OtaPermissionKey.UPDATE"> 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 </Authority> 161 </Authority>
151 </div> 162 </div>
152 </template> 163 </template>
@@ -13,6 +13,7 @@ export enum OtaPermissionKey { @@ -13,6 +13,7 @@ export enum OtaPermissionKey {
13 UPDATE = 'api:operation:ota:update', 13 UPDATE = 'api:operation:ota:update',
14 DELETE = 'api:operation:ota:delete', 14 DELETE = 'api:operation:ota:delete',
15 DOWNLOAD = 'api:operation:ota:download', 15 DOWNLOAD = 'api:operation:ota:download',
  16 + DETAIL = 'api:operation:ota:detail',
16 } 17 }
17 18
18 export const columns: BasicColumn[] = [ 19 export const columns: BasicColumn[] = [
@@ -80,6 +81,7 @@ export const columns: BasicColumn[] = [ @@ -80,6 +81,7 @@ export const columns: BasicColumn[] = [
80 dataIndex: 'action', 81 dataIndex: 'action',
81 flag: 'ACTION', 82 flag: 'ACTION',
82 fixed: 'right', 83 fixed: 'right',
  84 + width: 200,
83 slots: { 85 slots: {
84 customRender: 'action', 86 customRender: 'action',
85 }, 87 },
@@ -113,6 +113,5 @@ export const formSchema: FormSchema[] = [ @@ -113,6 +113,5 @@ export const formSchema: FormSchema[] = [
113 field: PackageField.DESCRIPTION, 113 field: PackageField.DESCRIPTION,
114 label: '描述', 114 label: '描述',
115 component: 'Input', 115 component: 'Input',
116 - dynamicDisabled: false,  
117 }, 116 },
118 ]; 117 ];
@@ -57,8 +57,8 @@ @@ -57,8 +57,8 @@
57 openModal(true, { isUpdate: false } as ModalPassRecord); 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 const downloadFile = async (record: OtaRecordDatum) => { 64 const downloadFile = async (record: OtaRecordDatum) => {
@@ -117,6 +117,20 @@ @@ -117,6 +117,20 @@
117 @click.stop 117 @click.stop
118 :actions="[ 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 label: '下载', 134 label: '下载',
121 icon: 'ant-design:download-outlined', 135 icon: 'ant-design:download-outlined',
122 auth: OtaPermissionKey.DOWNLOAD, 136 auth: OtaPermissionKey.DOWNLOAD,