feat(oaProject) fileUpload

approve-sys
bob 2 years ago
parent 1839fd3f8e
commit b70fdbba75

@ -29,22 +29,12 @@
<el-form-item label="图片上传" prop="remark"> <el-form-item label="图片上传" prop="remark">
<el-upload <el-upload
class="upload-demo" class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/" :action="uploadFileUrl"
:on-error="handleUploadError"
:on-preview="handlePreview" :on-preview="handlePreview"
:on-success="handleSuccess"
:on-remove="handleRemove" :on-remove="handleRemove"
:file-list="fileList"> :headers="headers"
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
</el-form-item>
<el-form-item label="文件上传" prop="remark">
<el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:on-preview="handlePreview"
:on-remove="handleRemove"
multiple
:limit="3"
:file-list="fileList"> :file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button> <el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div> <div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
@ -75,6 +65,7 @@ import Editor from '@/components/Editor';
import Parser from '@/components/parser/Parser' import Parser from '@/components/parser/Parser'
import {optionProject} from "@/api/system/project"; import {optionProject} from "@/api/system/project";
import {definitionStart, getLatestIdByKey} from "@/api/flowable/definition"; import {definitionStart, getLatestIdByKey} from "@/api/flowable/definition";
import {getToken} from "@/utils/auth";
export default { export default {
name: "Form", name: "Form",
@ -98,6 +89,7 @@ export default {
total: 0, total: 0,
// //
formList: [], formList: [],
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/attachment/upload", //
// //
title: "", title: "",
formConf: {}, // formConf: {}, //
@ -112,18 +104,17 @@ export default {
formName: null, formName: null,
formContent: null, formContent: null,
}, },
fileList: [{ headers: {
name: 'food.jpeg', Authorization: "Bearer " + getToken(),
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100' },
}, { fileList: [],
name: 'food2.jpeg', fileIdList: [],
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
}],
// //
form: { form: {
projectId: undefined, projectId: undefined,
workRecord: '', workRecord: '',
submitDate: '', submitDate: '',
attachmentIds: [],
issue: '', issue: '',
solution: '', solution: '',
}, },
@ -136,16 +127,22 @@ export default {
}, },
methods: { methods: {
init() { init() {
this.fileList = []
this.fileIdList = []
this.open = true this.open = true
this.optionList() this.optionList()
this.getLatestIdByKey() this.getLatestIdByKey()
}, },
/** 启动流程 */ /** 启动流程 */
startFlow(){ startFlow(){
if (this.fileIdList.length > 0) {
this.form.attachmentIds=this.fileIdList.map(e => e.id).join(',')
console.log("this.form.attachmentIds", this.form.attachmentIds);
}
definitionStart(this.oaProjectFlowId, JSON.stringify(this.form)).then(res => { definitionStart(this.oaProjectFlowId, JSON.stringify(this.form)).then(res => {
this.msgSuccess(res.msg); this.msgSuccess(res.msg);
this.$router.push('/task/process') this.$router.push('/task/process')
}) });
}, /** 获取最新流程id */ }, /** 获取最新流程id */
getLatestIdByKey(){ getLatestIdByKey(){
getLatestIdByKey(this.oaProjectFlowKey).then(res => { getLatestIdByKey(this.oaProjectFlowKey).then(res => {
@ -242,6 +239,7 @@ export default {
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}) })
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
@ -256,7 +254,29 @@ export default {
}) })
}, },
handleRemove(file, fileList) { handleRemove(file, fileList) {
// id
console.log(file, fileList); console.log(file, fileList);
for(var i = this.fileIdList.length -1; i >= 0 ; i--){
if(this.fileIdList[i].uid == file.uid){
// fileIdListid
this.fileIdList.splice(i, 1);
}
}
},
handleUploadError(err, file, fileList) {
this.$message.error("上传失败, 请重试");
},
handleSuccess(res, file, fileList) {
if (res.code !== 200) {
this.$message.error("上传失败, 请重试");
return
}
this.fileIdList.push({
id:res.data.id,
uid:file.uid // id
})
// id
}, },
handlePreview(file) { handlePreview(file) {
console.log(file); console.log(file);

@ -117,31 +117,32 @@ module.exports = {
}, },
// vue 兼容h5样式配置 // vue 兼容h5样式配置
css: { css: {
loaderOptions: { // loaderOptions: {
sass: { // sass: {
additionalData: `@import "~@/base.scss";` // additionalData: `@import "~@/base.scss";`
}, // },
postcss: { // postcss: {
plugins: [ // plugins: [
require('autoprefixer')({ overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8'] }), // require('autoprefixer')({ overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8'] }),
require('postcss-px-to-viewport')({ // require('postcss-px-to-viewport')({
unitToConvert: 'px', // unitToConvert: 'px',
viewportWidth: 7500, // viewportWidth: 7500,
unitPrecision: 5, // unitPrecision: 5,
propList: ['*', '!max-width'], // propList: ['*', '!max-width'],
viewportUnit: 'rem', // viewportUnit: 'rem',
fontViewportUnit: 'rem', // fontViewportUnit: 'rem',
selectorBlackList: ['html'], // selectorBlackList: ['html'],
minPixelValue: 1, // minPixelValue: 1,
mediaQuery: false, // mediaQuery: false,
replace: true, // replace: true,
exclude: [/node_modules/], // // exclude: [/node_modules/],
landscape: false, // include: [''],
landscapeUnit: 'vw', // landscape: false,
landscapeWidth: 568 // landscapeUnit: 'vw',
}) // landscapeWidth: 568
] // })
} // ]
} // }
// }
} }
} }

Loading…
Cancel
Save