Browse Source

feat:上传文件修改参数

dev
zhaobing’ 1 year ago
parent
commit
aa449658c0
  1. 64
      web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx

64
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) => {
<Form.Select disabled={recordRow?true:false} field='deviceName' label='设备型号:' placeholder='请选择设备型号' optionList={options} rules={[{ required: true, message: '设备型号必填' }]}></Form.Select>
<Form.Input disabled={recordRow?true:false} field='versionNo' label='版本号:' rules={[{ required: true, message: '版本号必填' }]}></Form.Input>
<Form.Upload limit={1}
action={`${apiRoot}/attachments/p`}
field='files' label='文件上传'
// action={`/file/uploadLocal&token=` + user.token}
// action={`/file/uploadLocal&token=` + user.token}
action={`${apiRoot}/attachments/p`}
field='files' label='文件上传'
rules={[{ required: true, message: '文件上传必填' }]}
onRemove={() => {
setUploadData({})

Loading…
Cancel
Save