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 24c4d6497..e955e0c76 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 @@ -1,3 +1,4 @@ +import { conforms, reject } from 'lodash' import get from 'lodash/get' import omit from 'lodash/omit' import moment from 'moment' @@ -30,12 +31,13 @@ export default { methods: { // 获取表单默认值 async getDefaultForm() { + const result = {} for (const [tableName, tableItem] of Object.entries(this.scheme)) { 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 +47,7 @@ export default { }, // 获取单条表单项的默认值 - async getDefaultValue(path, schemeItem) { + async getDefaultValue(path, schemeItem,tableName,fieldName) { switch (schemeItem.type) { case 'keyValue': return this.processId @@ -91,6 +93,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': @@ -103,6 +118,7 @@ export default { // 验证表单项输入是否正确,返回一个包含所有错误信息的数组 verifyForm() { + console.log(this.scheme) const result = [] Object.entries(this.scheme).forEach(([tableName, tableItem]) => { if ('__GIRDTABLE__' in tableItem) { @@ -149,7 +165,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 +175,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 +187,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,37 +215,51 @@ 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(',') + // let uploadUid = [] + // console.log(val) + // for (const entity of val) { + // if (entity.uid) { + // uploadUid.push(entity.uid) + // continue + // } else { + + // const fileId = await this.HTTP_UPLOAD(entity) + // console.log(fileId) + // if (fileId) { + // uploadUid.push(fileId) + // } + // } + + // } + // console.log(uploadUid.join(',')) + // reject() + // return uploadUid.join(',') + 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 + // uploadUid = item.uid continue } - - const fileId = await this.HTTP_UPLOAD(item.path || item, undefined, guid || '') + + const fileId = await this.HTTP_UPLOAD(item.path || item, undefined, uploadUid) if (fileId) { uploadUid = fileId; } } - return uploadUid; default: @@ -243,13 +281,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) } } } @@ -258,7 +296,7 @@ export default { }, // 将单项表单数据格式化(拉取时使用) - async convertToFormValue(scheme, val, dataSource) { + async convertToFormValue(scheme, val, dataSource,tableName,fieldName) { switch (scheme.type) { case 'upload': // if (!val) { return [] } @@ -277,6 +315,20 @@ export default { // 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 [] } diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/PersonnelManagement/MeetingManagement/list.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/PersonnelManagement/MeetingManagement/list.vue index aae48d1d6..e50677873 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/PersonnelManagement/MeetingManagement/list.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/PersonnelManagement/MeetingManagement/list.vue @@ -1,4 +1,4 @@ -