Browse Source

上传修改

dev
wenlele 2 years ago
parent
commit
824c234a86
  1. 9
      api/.vscode/launch.json
  2. 22
      api/app/lib/controllers/means/index.js
  3. 3
      api/app/lib/routes/means/index.js
  4. 8
      web/client/src/sections/means/containers/devOpsStandard.jsx
  5. 9
      web/client/src/sections/means/containers/faultInformation.jsx
  6. 8
      web/client/src/sections/means/containers/projectMeans.jsx
  7. 8
      web/client/src/sections/means/containers/repairFQA.jsx
  8. 16
      web/routes/attachment/index.js

9
api/.vscode/launch.json

@ -33,11 +33,12 @@
"--godUrl https://restapi.amap.com/v3", "--godUrl https://restapi.amap.com/v3",
"--godKey 21c2d970e1646bb9a795900dd00093ce", "--godKey 21c2d970e1646bb9a795900dd00093ce",
"--mqttVideoServer mqtt://10.8.30.71:30883", "--mqttVideoServer mqtt://10.8.30.71:30883",
"--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", "--qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu",
"--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", "--qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5",
"--qnbkt dev-operational-service", "--qnbkt anxinyun-test",
"--qndmn http://test.resources.anxinyun.cn",
// "--qndmn http://resources.anxinyun.cn", // "--qndmn http://resources.anxinyun.cn",
"--qndmn http://rhvqdivo5.hn-bkt.clouddn.com", // "--qndmn http://rhvqdivo5.hn-bkt.clouddn.com",
// click // click
// "--clickHouseUrl http://10.8.30.71", // "--clickHouseUrl http://10.8.30.71",
// click // click

22
api/app/lib/controllers/means/index.js

@ -154,6 +154,25 @@ async function delfolderFile (ctx, next) {
} }
} }
} }
async function upload (ctx, next) {
let fkey = null;
try {
const { files } = await parse(ctx.req);
const file = files[0];
const fileInfo = await ctx.app.fs.attachment.upload(file);
fkey = fileInfo.key;
ctx.status = 200;
ctx.body = { uploaded: fkey };
} catch (err) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`)
ctx.status = 400;
ctx.body = {
"message": '上传失败'
}
}
}
module.exports = { module.exports = {
@ -162,5 +181,6 @@ module.exports = {
delFile, delFile,
addFile, addFile,
folderFileList, folderFileList,
delfolderFile delfolderFile,
upload
} }

3
api/app/lib/routes/means/index.js

@ -21,4 +21,7 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['DEL/file/:id'] = { content: '删除文件夹', visible: true }; app.fs.api.logAttr['DEL/file/:id'] = { content: '删除文件夹', visible: true };
router.del('/file/:id', means.delfolderFile); router.del('/file/:id', means.delfolderFile);
app.fs.api.logAttr['POSTattachments/:p'] = { content: '上传文件', visible: true };
router.post('/attachments/:p', means.upload);
}; };

8
web/client/src/sections/means/containers/devOpsStandard.jsx

@ -10,7 +10,7 @@ import './style.less'
const Rest = (props) => { const Rest = (props) => {
const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId, apiRoot } = props
const { install, means } = actions const { install, means } = actions
const [pomsList, setPomsList] = useState([]); // const [pomsList, setPomsList] = useState([]); //
const [showPomsList, setShowPomsList] = useState([]); // const [showPomsList, setShowPomsList] = useState([]); //
@ -392,7 +392,7 @@ const Rest = (props) => {
<div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div> <div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div>
<Upload <Upload
style={{ display: 'inline-block' }} style={{ display: 'inline-block' }}
action="/_upload/attachments" action={`${apiRoot}/attachments/p`}
accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'} accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'}
limit={1} limit={1}
maxSize={51200} maxSize={51200}
@ -400,7 +400,6 @@ const Rest = (props) => {
setUploadData({}) setUploadData({})
}} }}
onSuccess={(responseBody, file) => { onSuccess={(responseBody, file) => {
setUploadData({ setUploadData({
name: file.name, name: file.name,
size: file.size, size: file.size,
@ -559,7 +558,8 @@ function mapStateToProps (state) {
overallProjectId: global.pepProjectId, overallProjectId: global.pepProjectId,
// socket: webSocket.socket // socket: webSocket.socket
clientHeight: global.clientHeight, clientHeight: global.clientHeight,
qiniu: global.qiniu?.domain qiniu: global.qiniu?.domain,
apiRoot: global.apiRoot
}; };
} }

9
web/client/src/sections/means/containers/faultInformation.jsx

@ -10,7 +10,7 @@ import './style.less'
const Rest = (props) => { const Rest = (props) => {
const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId ,apiRoot} = props
const { install, means } = actions const { install, means } = actions
const [pomsList, setPomsList] = useState([]); // const [pomsList, setPomsList] = useState([]); //
const [showPomsList, setShowPomsList] = useState([]); // const [showPomsList, setShowPomsList] = useState([]); //
@ -86,6 +86,7 @@ const Rest = (props) => {
}, [fileId]) }, [fileId])
const fileList = (id) => { const fileList = (id) => {
dispatch(means.fileList({ projectId: id, type: 3 })).then((res => { dispatch(means.fileList({ projectId: id, type: 3 })).then((res => {
if (res.success) { if (res.success) {
let data = res.payload.data let data = res.payload.data
@ -391,7 +392,7 @@ const Rest = (props) => {
<div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div> <div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div>
<Upload <Upload
style={{ display: 'inline-block' }} style={{ display: 'inline-block' }}
action="/_upload/attachments" action={`${apiRoot}/attachments/p`}
accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'} accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'}
limit={1} limit={1}
maxSize={51200} maxSize={51200}
@ -399,7 +400,6 @@ const Rest = (props) => {
setUploadData({}) setUploadData({})
}} }}
onSuccess={(responseBody, file) => { onSuccess={(responseBody, file) => {
setUploadData({ setUploadData({
name: file.name, name: file.name,
size: file.size, size: file.size,
@ -558,7 +558,8 @@ function mapStateToProps (state) {
overallProjectId: global.pepProjectId, overallProjectId: global.pepProjectId,
// socket: webSocket.socket // socket: webSocket.socket
clientHeight: global.clientHeight, clientHeight: global.clientHeight,
qiniu: global.qiniu?.domain qiniu: global.qiniu?.domain,
apiRoot:global.apiRoot
}; };
} }

8
web/client/src/sections/means/containers/projectMeans.jsx

@ -10,7 +10,7 @@ import './style.less'
const Rest = (props) => { const Rest = (props) => {
const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId ,apiRoot} = props
const { install, means } = actions const { install, means } = actions
const [pomsList, setPomsList] = useState([]); // const [pomsList, setPomsList] = useState([]); //
const [showPomsList, setShowPomsList] = useState([]); // const [showPomsList, setShowPomsList] = useState([]); //
@ -392,7 +392,7 @@ const Rest = (props) => {
<div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div> <div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div>
<Upload <Upload
style={{ display: 'inline-block' }} style={{ display: 'inline-block' }}
action="/_upload/attachments" action={`${apiRoot}/attachments/p`}
accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'} accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'}
limit={1} limit={1}
maxSize={51200} maxSize={51200}
@ -400,7 +400,6 @@ const Rest = (props) => {
setUploadData({}) setUploadData({})
}} }}
onSuccess={(responseBody, file) => { onSuccess={(responseBody, file) => {
setUploadData({ setUploadData({
name: file.name, name: file.name,
size: file.size, size: file.size,
@ -559,7 +558,8 @@ function mapStateToProps (state) {
overallProjectId: global.pepProjectId, overallProjectId: global.pepProjectId,
// socket: webSocket.socket // socket: webSocket.socket
clientHeight: global.clientHeight, clientHeight: global.clientHeight,
qiniu: global.qiniu?.domain qiniu: global.qiniu?.domain,
apiRoot:global.apiRoot
}; };
} }

8
web/client/src/sections/means/containers/repairFQA.jsx

@ -10,7 +10,7 @@ import './style.less'
const Rest = (props) => { const Rest = (props) => {
const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId ,apiRoot} = props
const { install, means } = actions const { install, means } = actions
const [pomsList, setPomsList] = useState([]); // const [pomsList, setPomsList] = useState([]); //
const [showPomsList, setShowPomsList] = useState([]); // const [showPomsList, setShowPomsList] = useState([]); //
@ -392,7 +392,7 @@ const Rest = (props) => {
<div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div> <div style={{ marginTop: 6 }}>文件<span style={{ color: 'red' }}>*</span></div>
<Upload <Upload
style={{ display: 'inline-block' }} style={{ display: 'inline-block' }}
action="/_upload/attachments" action={`${apiRoot}/attachments/p`}
accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'} accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'}
limit={1} limit={1}
maxSize={51200} maxSize={51200}
@ -400,7 +400,6 @@ const Rest = (props) => {
setUploadData({}) setUploadData({})
}} }}
onSuccess={(responseBody, file) => { onSuccess={(responseBody, file) => {
setUploadData({ setUploadData({
name: file.name, name: file.name,
size: file.size, size: file.size,
@ -559,7 +558,8 @@ function mapStateToProps (state) {
overallProjectId: global.pepProjectId, overallProjectId: global.pepProjectId,
// socket: webSocket.socket // socket: webSocket.socket
clientHeight: global.clientHeight, clientHeight: global.clientHeight,
qiniu: global.qiniu?.domain qiniu: global.qiniu?.domain,
apiRoot:global.apiRoot
}; };
} }

16
web/routes/attachment/index.js

@ -53,26 +53,12 @@ module.exports = {
let upload_ = async function (ctx, next) { let upload_ = async function (ctx, next) {
let fkey = null; let fkey = null;
try { try {
// const { p } = ctx.params;
console.log(111,ctx);
const { files } = await parse(ctx.req); const { files } = await parse(ctx.req);
// console.log(files);
const file = files[0]; const file = files[0];
// const extname = path.extname(file.filename).toLowerCase();
// if (!UploadPath[p]) {
// ctx.status = 400;
// ctx.body = JSON.stringify({ error: '附件存放的文件夹名称无效' });
// return;
// } else if (UploadPath[p].indexOf(extname) < 0) {
// ctx.status = 400;
// ctx.body = JSON.stringify({ error: '文件格式无效' });
// return;
// } else {
const fileInfo = await ctx.app.fs.attachment.upload(file); const fileInfo = await ctx.app.fs.attachment.upload(file);
fkey = fileInfo.key; fkey = fileInfo.key;
console.log(11,fileInfo);
ctx.body = { uploaded: fkey }; ctx.body = { uploaded: fkey };
// }
} catch (err) { } catch (err) {
ctx.status = 500; ctx.status = 500;
ctx.fs.logger.error(err); ctx.fs.logger.error(err);

Loading…
Cancel
Save