diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js index df9ea04a2..151baa403 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js @@ -35,7 +35,7 @@ export default { const itemData = {} for (const [fieldName, scheme] of Object.entries(tableItem)) { if (fieldName !== '__GIRDTABLE__') { - itemData[fieldName] = await this.getDefaultValue(`${tableName}.${fieldName}`, scheme) + itemData[fieldName] = await this.getDefaultValue(`${tableName}.${fieldName}`, scheme,tableName,fieldName) } } result[tableName] = '__GIRDTABLE__' in tableItem ? [itemData] : itemData @@ -45,7 +45,7 @@ export default { }, // 获取单条表单项的默认值 - async getDefaultValue(path, schemeItem) { + async getDefaultValue(path, schemeItem,tableName,fieldName) { switch (schemeItem.type) { case 'keyValue': return this.processId @@ -91,6 +91,19 @@ export default { return result || '' case 'upload': + let folderIds = {} + let getstData = uni.getStorageSync('folderIds'); + if(getstData){ + folderIds = JSON.parse(getstData) + } + if(folderIds[tableName]){ + folderIds[tableName][fieldName] = '' + }else{ + let obj = {} + obj[fieldName] = '' + folderIds[tableName] = obj + } + uni.setStorageSync('folderIds',JSON.stringify(folderIds)); return [] case 'guid': @@ -149,7 +162,7 @@ export default { const tableObj = {} for (const [fieldName, scheme] of Object.entries(tableItem)) { if (fieldName === '__GIRDTABLE__') { continue } - tableObj[fieldName] = await this.convertToPostData(scheme, tableValue[fieldName]) + tableObj[fieldName] = await this.convertToPostData(scheme, tableValue[fieldName],tableName,fieldName) } tableArray.push(tableObj) } @@ -159,7 +172,7 @@ export default { // 主表 const strEntity = {} for (const [fieldName, scheme] of Object.entries(tableItem)) { - strEntity[fieldName] = await this.convertToPostData(scheme, this.current[tableName][fieldName]) + strEntity[fieldName] = await this.convertToPostData(scheme, this.current[tableName][fieldName],tableName,fieldName) } result['strEntity'] = JSON.stringify(strEntity) } @@ -171,9 +184,17 @@ export default { return result }, + + newguid() { + return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random() * 16 | 0, + v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + }, // 将单项表单数据转为 post 数据(提交时使用) - async convertToPostData(scheme, val) { + async convertToPostData(scheme, val,tableName,fieldName) { switch (scheme.type) { case 'checkbox': return val ? val.join(',') : '' @@ -191,21 +212,46 @@ export default { return val ? moment(val).format('YYYY-MM-DD HH:mm') : '' case 'upload': - const uploadUid = [] - for (const entity of val) { - if (entity.uid) { - uploadUid.push(entity.uid) - continue - } else { - const fileId = await this.HTTP_UPLOAD(entity) - if (fileId) { - uploadUid.push(fileId) - } - } - - } - - return uploadUid.join(',') + // const uploadUid = [] + // for (const entity of val) { + // if (entity.uid) { + // uploadUid.push(entity.uid) + // continue + // } else { + // const fileId = await this.HTTP_UPLOAD(entity) + // if (fileId) { + // uploadUid.push(fileId) + // } + // } + + // } + + var uploadUid = ''; + + let folderIds = uni.getStorageSync('folderIds'); + if(folderIds){ + folderIds = JSON.parse(folderIds) + if(folderIds[tableName]&&folderIds[tableName][fieldName]){ + uploadUid = folderIds[tableName][fieldName] + } + } + if(!uploadUid){ + uploadUid = this.newguid() + } + + for (const item of val) { + if (item.uid) { + uploadUid = item.uid + continue + } + + const fileId = await this.HTTP_UPLOAD(item.path || item, undefined, uploadUid) + if (fileId) { + uploadUid = fileId; + } + } + + return uploadUid; default: return val || '' @@ -226,13 +272,13 @@ export default { for (const [fieldName, scheme] of Object.entries(schemeItem)) { if (fieldName === '__GIRDTABLE__') { continue } const dataSource = get(this.dataSource, `${tableName}.${fieldName}`) - tableValue[fieldName] = await this.convertToFormValue(scheme, tableValue[fieldName], dataSource) + tableValue[fieldName] = await this.convertToFormValue(scheme, tableValue[fieldName], dataSource,tableName,fieldName) } } } else { for (const [fieldName, scheme] of Object.entries(schemeItem)) { const dataSource = get(this.dataSource, `${tableName}.${fieldName}`) - data[tableName][fieldName] = await this.convertToFormValue(scheme, data[tableName][fieldName], dataSource) + data[tableName][fieldName] = await this.convertToFormValue(scheme, data[tableName][fieldName], dataSource,tableName,fieldName) } } } @@ -241,26 +287,66 @@ export default { }, // 将单项表单数据格式化(拉取时使用) - async convertToFormValue(scheme, val, dataSource) { + async convertToFormValue(scheme, val, dataSource,tableName,fieldName) { switch (scheme.type) { case 'upload': - if (!val) { return [] } - const uidList = val.split(',') - const fileList = [] - - for (const uid of uidList || []) { - const fileInfo = await this.FETCH_FILEINFO(uid) - if (!fileInfo) { continue } - - const fileType = fileInfo.F_FileType - const fileSize = fileInfo.F_FileSize + // if (!val) { return [] } + // const uidList = val.split(',') + // const fileList = [] + + // for (const uid of uidList || []) { + // const fileInfo = await this.FETCH_FILEINFO(uid) + // if (!fileInfo) { continue } + + // const fileType = fileInfo.F_FileType + // const fileSize = fileInfo.F_FileSize + // const fileName = fileInfo.F_FileName + + // const path = this.API + '/annexes/wxdown?' + this.URL_QUERY(uid, true) + + // fileList.push({ path, type: fileType, uid, size: fileSize, name:fileName }) + // } + // return fileList + let folderIds = {} + let getstData = uni.getStorageSync('folderIds'); + if(getstData){ + folderIds = JSON.parse(getstData) + } + if(folderIds[tableName]){ + folderIds[tableName][fieldName] = val + }else{ + let obj = {} + obj[fieldName] = val + folderIds[tableName] = obj + } + uni.setStorageSync('folderIds',JSON.stringify(folderIds)); + if (!val) { + return [] + } + const uidList = val; + const fileList = [] + const wxlist = await this.FETCH_FILEList(uidList); + for (const wxfile of wxlist) { + const fileInfo = await this.FETCH_FILEINFO(wxfile.F_Id) + if (!fileInfo) { + continue + } + + const fileType = fileInfo.F_FileType + const fileSize = fileInfo.F_FileSize const fileName = fileInfo.F_FileName - - const path = this.API + '/annexes/wxdown?' + this.URL_QUERY(uid, true) - - fileList.push({ path, type: fileType, uid, size: fileSize, name:fileName }) - } - return fileList + + const path = this.API + '/learun/adms/annexes/wxdown?' + this.URL_QUERY(wxfile.F_Id, true) + fileList.push({ + path, + type: fileType, + uid:wxfile.F_Id, + folderId:wxfile.F_FolderId, + size: fileSize, + name:fileName + }) + } + return fileList case 'radio': case 'select': diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue index 5e35cd49e..eab555db1 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue @@ -101,7 +101,7 @@ export default { // #endif // #ifndef MP-DINGTALK - uni.chooseImage({ + uni.chooseFile({ count: Number(this.number), sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'],