From aa449658c09dda6729194f5343920f78d1084daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Mon, 4 Dec 2023 13:37:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/addFirmwareModal.jsx | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx index c62bab2..f932f3f 100644 --- a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx +++ b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx @@ -6,7 +6,7 @@ import { IconUpload,IconVigoLogo } from '@douyinfe/semi-icons'; import request from 'superagent'; const AddFirmwareModal = (props) => { - const {modalVis,onCancel,crawapi,recordRow,actions,dispatch,qiniu,apiRoot} =props + const {modalVis,onCancel,crawapi,recordRow,actions,dispatch,qiniu,apiRoot,user} =props const api = useRef(); const {domain}=qiniu //七牛服务器地址 const {firmwareUpgrade}=actions @@ -50,36 +50,36 @@ const AddFirmwareModal = (props) => { // } // dispatch(firmwareUpgrade.upgradeFirmware(query,body)).then(res=>{ // }) - const responseData=await request.get(qiniu+'/'+fileUrl).responseType('arraybuffer') - const blobData = responseData.body; - - request.post(crawapi+'/firmwareupgrade') - // .set('Content-Type','application/octet-stream') - .attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name) - .field('filePath',removeFlag?fileUrl:recordRow?recordRow.filepath:fileUrl) - .field('userId', userId||'') - .field('firmwareName', res?.firmwareName||'') - .field('comment',res?.remark||'') - .field('device_meta_name', options?.find(item=>item.value===res?.deviceName)?.label||'') - .query({ version:res?.versionNo,device_meta_id: res?.deviceName,token:'22767e1f-db8d-4a1d-87d4-56347cf21247'}) - .end((err, response) => { - if(response?.ok){ - Notification.success({ title: recordRow?'编辑固件包':'新增固件包', - content: recordRow?'编辑成功':'新增成功', - duration: 3, - }) - setRemoveFlag(false) - onCancel() - }else{ - console.error('Superagent request failed:'); - Notification.error({ title: recordRow?'编辑固件包':'新增固件包', - content: recordRow?'编辑失败':'新增失败', - duration: 3, - }) - } - }) + request.post(crawapi+'/firmwareupgrade') + // .set('Content-Type','application/octet-stream') + // .attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name) + .field('filePath',removeFlag?`${apiRoot}/attachments/`+fileUrl:recordRow?`${apiRoot}/attachments/`+recordRow.filepath:`${apiRoot}/attachments/`+fileUrl) + .field('userId', userId||'') + .field('firmwareName', res?.firmwareName||'') + .field('comment',res?.remark||'') + .field('device_meta_name', options?.find(item=>item.value===res?.deviceName)?.label||'') + .query({ version:res?.versionNo,device_meta_id: res?.deviceName,token:'22767e1f-db8d-4a1d-87d4-56347cf21247'}) + .end((err, response) => { + if(response?.ok){ + Notification.success({ title: recordRow?'编辑固件包':'新增固件包', + content: recordRow?'编辑成功':'新增成功', + duration: 3, + }) + setRemoveFlag(false) + onCancel() + }else{ + console.error('Superagent request failed:'); + Notification.error({ title: recordRow?'编辑固件包':'新增固件包', + content: recordRow?'编辑失败':'新增失败', + duration: 3, + }) + } + }) + + + }) } @@ -114,8 +114,10 @@ const AddFirmwareModal = (props) => { { setUploadData({})