Browse Source

提交文件上传相关问题

dev
long 2 years ago
parent
commit
ceba6da737
  1. 37
      src/api/manage.js
  2. 90
      src/components/jeecg/JUpload.vue
  3. 2
      src/components/jeecg/index.js
  4. 24
      src/views/activiti/form/ProcessUdgetPlanForm.vue
  5. 13
      src/views/processmaterials/modules/ProcessUdgetPlanForm.vue

37
src/api/manage.js

@ -202,3 +202,40 @@ export function getCurrentTime() {
let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
return yy+'-'+mm+'-'+dd+' '+hh+':'+mf+':'+ss;
}
/**
* 获取文件id
* @param arry
* @returns {string|null}
*/
export function getStringArry(arry) {
if (!arry || arry == '') return null;
if (arry.length > 0) {
var uuid = ''
var arr = []
for (var i = 0; i < arry.length; i++) {
arr.push(arry[i].id)
}
uuid = arr.join(',')
return uuid
}
}
export function getRecord(data) {
let newFileList = []
if (data.fileId != null && data.id != '') {
var text = data.ossFileList
for (var i = 0; i < text.length; i++) {
var name = text[i].filename
var fileJson = {
name: text[i].fileName,
url: text[i].url,
size: text[i].fileSize,
id: text[i].id,
fileType: text[i].fileType
}
newFileList.push(fileJson)
}
}
data.fileId = newFileList
return data
}

90
src/components/jeecg/JUpload.vue

@ -65,10 +65,11 @@
name: 'JUpload',
data(){
return {
uploadAction:window._CONFIG['domianURL']+"/sys/upload/uploadMinio",
uploadAction:window._CONFIG['domianURL']+"/sys/upload",
headers:{},
fileList: [],
newFileList: [],
result: '',
uploadGoOn:true,
previewVisible: false,
//---------------------------- begin -------------------------------------
@ -101,7 +102,7 @@
default:"temp"
},
value:{
type:[String,Array],
type:[Object, Array, String, Number],
required:false
},
// update-begin- --- author:wangshuai ------ date:20190929 ---- for:Jupload
@ -145,7 +146,8 @@
let val = this.value
if (val instanceof Array) {
if(this.returnUrl){
this.initFileList(val.join(','))
this.initFileListArr(val);
// this.initFileList(val.join(','))
}else{
this.initFileListArr(val);
}
@ -172,26 +174,33 @@
},
methods:{
initFileListArr(val){
if(!val || val.length==0){
this.fileList = [];
return;
initFileListArr(val) {
console.log('999999',val)
if (!val || val.length == 0) {
this.fileList = []
return
}
let fileList = [];
for(var a=0;a<val.length;a++){
let url = getFileAccessHttpUrl(val[a].filePath);
let fileList = []
for (var a = 0; a < val.length; a++) {
fileList.push({
uid:uidGenerator(),
name:val[a].fileName,
uid: uidGenerator(),
name: val[a].name,
id: val[a].id,
status: 'done',
url: url,
response:{
status:"history",
message:val[a].filePath
url: val[a].url,
response: {
result: {
uid: uidGenerator(),
name: val[a].name,
id: val[a].id,
status: 'done',
url: val[a].url
}
}
})
}
this.fileList = fileList
},
initFileList(paths){
if(!paths || paths.length==0){
@ -254,11 +263,12 @@
return true
},
handleChange(info) {
console.log("--文件列表改变--")
console.log("--文件列表改变--",info)
if(!info.file.status && this.uploadGoOn === false){
info.fileList.pop();
}
let fileList = info.fileList
let fileList = info
if(info.file.status==='done'){
if(this.number>0){
fileList = fileList.slice(-this.number);
@ -266,8 +276,13 @@
if(info.file.response.success){
fileList = fileList.map((file) => {
if (file.response) {
let reUrl = file.response.message;
file.url = getFileAccessHttpUrl(reUrl);
let reUrl
if (file.response.message == '') {
reUrl = file.response.result.url
} else {
reUrl = file.response.message
}
file.url = getFileAccessHttpUrl(reUrl)
}
return file;
});
@ -280,28 +295,25 @@
}
this.fileList = fileList
if(info.file.status==='done' || info.file.status === 'removed'){
//returnUrltrue
if(this.returnUrl){
this.handlePathChange()
}else{
//returnUrlfalse
this.newFileList = [];
for(var a=0;a<fileList.length;a++){
// update-begin-author:lvdandan date:20200603 for:TESTA-514issue
if(fileList[a].status === 'done' ) {
var fileJson = {
fileName:fileList[a].name,
filePath:fileList[a].response.message,
fileSize:fileList[a].size
};
this.newFileList.push(fileJson);
}else{
return;
this.newFileList = []
for (var a = 0; a < fileList.length; a++) {
if (fileList[a].status === 'done') {
var fileJson = {
fileName: fileList[a].response.result.fileName,
url: fileList[a].response.result.url,
size: fileList[a].response.result.size,
id: fileList[a].response.result.id,
fileType: fileList[a].type
}
// update-end-author:lvdandan date:20200603 for:TESTA-514issue
this.newFileList.push(fileJson)
} else {
return
}
this.$emit('change', this.newFileList);
}
console.log('2222222222222',this.newFileList)
this.initFileListArr(this.newFileList)
this.$emit('change', this.newFileList)
}
},
handleDelete(file){

2
src/components/jeecg/index.js

@ -12,6 +12,7 @@ import JEditableTable from './JEditableTable.vue'
import JAreaLinkage from './JAreaLinkage.vue'
import JSuperQuery from './JSuperQuery.vue'
import JUpload from './JUpload.vue'
import FileList from './FileList'
import JTreeSelect from './JTreeSelect.vue'
import JCategorySelect from './JCategorySelect.vue'
import JImageUpload from './JImageUpload.vue'
@ -65,5 +66,6 @@ export default {
Vue.component('JTreeSelect', JTreeSelect)
Vue.component('JTreeTable', JTreeTable)
Vue.component('JUpload', JUpload)
Vue.component('FileList', FileList)
}
}

24
src/views/activiti/form/ProcessUdgetPlanForm.vue

@ -58,6 +58,11 @@
<j-upload v-decorator="['fileId']" :trigger-change="true"></j-upload>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-model-item label="文件" :labelCol="labelCol" :wrapperCol="wrapperCol" v-show="false">
<FileList v-decorator="['ossFileList']"></FileList>
</a-form-model-item>
</a-col>
</a-row>
</a-form>
</j-form-container>
@ -106,12 +111,13 @@
const VALIDATE_NO_PASSED = Symbol()
import pick from 'lodash.pick'
import { getAction,httpAction,getCurrentTime } from '@/api/manage'
import { getAction,httpAction,getCurrentTime,getStringArry,getRecord } from '@/api/manage'
import { FormTypes, getRefPromise,validateFormAndTables } from '@/utils/JEditableTableUtil'
import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
import JFormContainer from '@/components/jeecg/JFormContainer'
import JDate from '@/components/jeecg/JDate'
import JUpload from '@/components/jeecg/JUpload'
import FileList from '@/components/jeecg/FileList'
import JSelectCompany from '@/components/jeecgbiz/JSelectCompany'
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
@ -126,6 +132,7 @@
JFormContainer,
JDate,
JUpload,
FileList,
JSelectDepart,
JSelectUserByDep,
JDictSelectTag,
@ -336,10 +343,9 @@
]
},
url: {
getForm:'/actBusiness/getForm',
add: '/hy/processUdgetPlan/add',
edit: '/hy/processUdgetPlan/edit',
queryById: '/hy/processUdgetPlan/queryById',
getForm: '/hy/processUdgetPlan/queryById',
selectdeparment:'/sys/selectByUser',
descriptionRake: "/description/processDescription/descriptionName",
merchandiseNewsList: "/merchandisenews/processMerchandiseNews/merchandiseNewsList",
@ -589,8 +595,7 @@
this.btndisabled = true;
var r = this.processData;
this.getAction(this.url.getForm,{
tableId:r.tableId,
tableName:r.tableName,
id:r.tableId
}).then((res)=>{
if (res.success){
let formData = res.result;
@ -631,6 +636,13 @@
/** 调用完edit()方法之后会自动调用此方法 */
editAfter() {
console.log("这是编辑回显数据",this.data)
if (this.data.id != null && this.data.id != '' && this.data.id != undefined && this.data.fileId != null && this.data.fileId != '') {
//1
console.log('++++++++++++++>',getRecord(this.data))
this.data = getRecord(this.data)
}
console.log('+++++++++898989+++++>',this.data)
let fieldval = pick(this.data, 'id','company', 'createTime', 'sysOrgCode', 'createBy', 'materialType', 'processPlan', 'needTime', 'orderNumber', 'fileId')
this.$nextTick(() => {
this.form.setFieldsValue(fieldval)
@ -691,7 +703,7 @@
throw this.throwNotFunction('classifyIntoFormData')
}
let formData = this.classifyIntoFormData(allValues)
formData.fileId = getStringArry(formData.fileId)
if (new Date(formData.createTime).getTime()/100>new Date(formData.needTime).getTime()/100){
this.$message.error("需求时间不能小于当前流程发起时间")
return;

13
src/views/processmaterials/modules/ProcessUdgetPlanForm.vue

@ -49,6 +49,11 @@
<j-upload v-decorator="['fileId']" :trigger-change="true" ></j-upload>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-model-item label="文件" :labelCol="labelCol" :wrapperCol="wrapperCol" v-show="false">
<FileList v-decorator="['ossFileList']"></FileList>
</a-form-model-item>
</a-col>
</a-row>
</a-form>
</j-form-container>
@ -73,7 +78,7 @@
<script>
import pick from 'lodash.pick'
import { getAction } from '@/api/manage'
import { getAction,httpAction,getCurrentTime,getStringArry,getRecord } from '@/api/manage'
import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
import JFormContainer from '@/components/jeecg/JFormContainer'
@ -373,6 +378,12 @@
},
/** 调用完edit()方法之后会自动调用此方法 */
editAfter() {
if (this.model.id != null && this.model.id != '' && this.model.id != undefined && this.model.fileId != null && this.model.fileId != '') {
//1
console.log(this.model)
this.model = getRecord(this.model)
console.log(this.model)
}
let fieldval = pick(this.model,'company','createTime','sysOrgCode','createBy','materialType','processPlan','needTime','orderNumber','fileId')
this.$nextTick(() => {
this.form.setFieldsValue(fieldval)

Loading…
Cancel
Save