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'; import request from 'superagent';
const AddFirmwareModal = (props) => { 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 api = useRef();
const {domain}=qiniu // const {domain}=qiniu //
const {firmwareUpgrade}=actions const {firmwareUpgrade}=actions
@ -50,34 +50,34 @@ const AddFirmwareModal = (props) => {
// } // }
// dispatch(firmwareUpgrade.upgradeFirmware(query,body)).then(res=>{ // dispatch(firmwareUpgrade.upgradeFirmware(query,body)).then(res=>{
// }) // })
const responseData=await request.get(qiniu+'/'+fileUrl).responseType('arraybuffer') request.post(crawapi+'/firmwareupgrade')
const blobData = responseData.body; // .set('Content-Type','application/octet-stream')
// .attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name)
request.post(crawapi+'/firmwareupgrade') .field('filePath',removeFlag?`${apiRoot}/attachments/`+fileUrl:recordRow?`${apiRoot}/attachments/`+recordRow.filepath:`${apiRoot}/attachments/`+fileUrl)
// .set('Content-Type','application/octet-stream') .field('userId', userId||'')
.attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name) .field('firmwareName', res?.firmwareName||'')
.field('filePath',removeFlag?fileUrl:recordRow?recordRow.filepath:fileUrl) .field('comment',res?.remark||'')
.field('userId', userId||'') .field('device_meta_name', options?.find(item=>item.value===res?.deviceName)?.label||'')
.field('firmwareName', res?.firmwareName||'') .query({ version:res?.versionNo,device_meta_id: res?.deviceName,token:'22767e1f-db8d-4a1d-87d4-56347cf21247'})
.field('comment',res?.remark||'') .end((err, response) => {
.field('device_meta_name', options?.find(item=>item.value===res?.deviceName)?.label||'') if(response?.ok){
.query({ version:res?.versionNo,device_meta_id: res?.deviceName,token:'22767e1f-db8d-4a1d-87d4-56347cf21247'}) Notification.success({ title: recordRow?'编辑固件包':'新增固件包',
.end((err, response) => { content: recordRow?'编辑成功':'新增成功',
if(response?.ok){ duration: 3,
Notification.success({ title: recordRow?'编辑固件包':'新增固件包', })
content: recordRow?'编辑成功':'新增成功', setRemoveFlag(false)
duration: 3, onCancel()
}) }else{
setRemoveFlag(false) console.error('Superagent request failed:');
onCancel() Notification.error({ title: recordRow?'编辑固件包':'新增固件包',
}else{ content: recordRow?'编辑失败':'新增失败',
console.error('Superagent request failed:'); duration: 3,
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.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.Input disabled={recordRow?true:false} field='versionNo' label='版本号:' rules={[{ required: true, message: '版本号必填' }]}></Form.Input>
<Form.Upload limit={1} <Form.Upload limit={1}
action={`${apiRoot}/attachments/p`} // action={`/file/uploadLocal&token=` + user.token}
field='files' label='文件上传' // action={`/file/uploadLocal&token=` + user.token}
action={`${apiRoot}/attachments/p`}
field='files' label='文件上传'
rules={[{ required: true, message: '文件上传必填' }]} rules={[{ required: true, message: '文件上传必填' }]}
onRemove={() => { onRemove={() => {
setUploadData({}) setUploadData({})

Loading…
Cancel
Save