| | |
| | | }, |
| | | "js-md5": { |
| | | "version": "0.8.3", |
| | | "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.8.3.tgz", |
| | | "resolved": "https://registry.npmmirror.com/js-md5/-/js-md5-0.8.3.tgz", |
| | | "integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==" |
| | | }, |
| | | "js-tokens": { |
| | |
| | | <!--index.vue--> |
| | | <template> |
| | | <div> |
| | | |
| | | </div> |
| | | <div /> |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | </style> |
| | | </style> |
| | |
| | | const uploadUrl = 'pc/requirement!ajaxAddRequirement' |
| | | |
| | | export default { |
| | | // 文件上传路径 |
| | | uploadUrl, |
| | | // 文件上传方法 |
| | | uploadFile (content) { |
| | | var formData = new FormData() |
| | | formData.append(content.filename, content.file) |
| | | Axios({ |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, |
| | | url: content.action, |
| | | data: formData |
| | | }).then((res)=>{ |
| | | console.log('文件上传完成', res) |
| | | content.onSuccess(res.data, content) |
| | | }).catch((res)=>{ |
| | | if (res.response) { |
| | | content.onError('上传文件失败' + res.response.status + ',' + res.response.data, res) |
| | | } else if (res.request) { |
| | | content.onError('上传文件失败,服务器端无响应') |
| | | } else { |
| | | content.onError('上传文件失败,请求封装失败') |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | // 文件上传路径 |
| | | uploadUrl, |
| | | // 文件上传方法 |
| | | uploadFile(content) { |
| | | var formData = new FormData() |
| | | formData.append(content.filename, content.file) |
| | | Axios({ |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, |
| | | url: content.action, |
| | | data: formData |
| | | }).then((res) => { |
| | | console.log('文件上传完成', res) |
| | | content.onSuccess(res.data, content) |
| | | }).catch((res) => { |
| | | if (res.response) { |
| | | content.onError('上传文件失败' + res.response.status + ',' + res.response.data, res) |
| | | } else if (res.request) { |
| | | content.onError('上传文件失败,服务器端无响应') |
| | | } else { |
| | | content.onError('上传文件失败,请求封装失败') |
| | | } |
| | | }) |
| | | } |
| | | } |