Browse Source

feat:上传文件修改参数

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

14
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,13 +50,10 @@ 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')
const blobData = responseData.body;
request.post(crawapi+'/firmwareupgrade') request.post(crawapi+'/firmwareupgrade')
// .set('Content-Type','application/octet-stream') // .set('Content-Type','application/octet-stream')
.attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name) // .attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name)
.field('filePath',removeFlag?fileUrl:recordRow?recordRow.filepath:fileUrl) .field('filePath',removeFlag?`${apiRoot}/attachments/`+fileUrl:recordRow?`${apiRoot}/attachments/`+recordRow.filepath:`${apiRoot}/attachments/`+fileUrl)
.field('userId', userId||'') .field('userId', userId||'')
.field('firmwareName', res?.firmwareName||'') .field('firmwareName', res?.firmwareName||'')
.field('comment',res?.remark||'') .field('comment',res?.remark||'')
@ -81,6 +78,9 @@ const AddFirmwareModal = (props) => {
}) })
} }
@ -114,6 +114,8 @@ 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={`/file/uploadLocal&token=` + user.token}
// action={`/file/uploadLocal&token=` + user.token}
action={`${apiRoot}/attachments/p`} action={`${apiRoot}/attachments/p`}
field='files' label='文件上传' field='files' label='文件上传'
rules={[{ required: true, message: '文件上传必填' }]} rules={[{ required: true, message: '文件上传必填' }]}

Loading…
Cancel
Save