@@ -200,23 +200,51 @@ export default { | |||
async convertToFormValue(item, val) { | |||
switch (item.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 | |||
const fileName = fileInfo.F_FileName | |||
const path = this.API + 'learun/adms/annexes/wxdown?' + this.URL_QUERY(uid, true) | |||
fileList.push({ path, type: fileType, uid, size: fileSize, name:fileName }) | |||
} | |||
return fileList | |||
// 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 + 'learun/adms/annexes/wxdown?' + this.URL_QUERY(uid, true) | |||
// fileList.push({ path, type: fileType, uid, size: fileSize, name:fileName }) | |||
// } | |||
// return fileList | |||
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 + '/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 'select': | |||
case 'radio': | |||
@@ -256,7 +284,7 @@ export default { | |||
* upload: 依次上传文件,将返回的文件 ID 使用符号「,」逗号拼接成字符串 | |||
* 其他类型: 保留原值 | |||
*/ | |||
async convertToPostData(item, val, formValue, scheme) { | |||
async convertToPostData(item, val, formValue, scheme,guid) { | |||
switch (item.type) { | |||
case 'checkbox': | |||
return val ? val.join(',') : '' | |||
@@ -274,26 +302,43 @@ export default { | |||
return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '' | |||
case 'upload': | |||
const valArray = val.map(item=>{ | |||
return { | |||
uid:item.uid, | |||
path:item.path===undefined?item:item.path | |||
} | |||
}) | |||
const uploadUid = [] | |||
for (const { path, uid } of valArray) { | |||
if (uid) { | |||
uploadUid.push(uid) | |||
continue | |||
} | |||
const fileId = await this.HTTP_UPLOAD(path) | |||
if (fileId) { | |||
uploadUid.push(fileId) | |||
} | |||
} | |||
return uploadUid.join(',') | |||
// const valArray = val.map(item=>{ | |||
// return { | |||
// uid:item.uid, | |||
// path:item.path===undefined?item:item.path | |||
// } | |||
// }) | |||
// const uploadUid = [] | |||
// for (const { path, uid } of valArray) { | |||
// if (uid) { | |||
// uploadUid.push(uid) | |||
// continue | |||
// } | |||
// const fileId = await this.HTTP_UPLOAD(path) | |||
// if (fileId) { | |||
// uploadUid.push(fileId) | |||
// } | |||
// } | |||
// return uploadUid.join(',') | |||
var uploadUid = ''; | |||
for (const item of val) { | |||
if (item.folderId) { | |||
uploadUid = item.folderId | |||
continue | |||
} | |||
const fileId = await this.HTTP_UPLOAD(item.path || item, undefined, guid || '') | |||
if (fileId) { | |||
uploadUid = fileId; | |||
} | |||
} | |||
return uploadUid; | |||
default: | |||
return val || '' | |||
@@ -26,7 +26,7 @@ | |||
<l-icon type="text" /> | |||
</view> | |||
<view v-if="!readonly" @click.stop="delFile(index)" class="cu-tag bg-red" style="height: 24px; width: 24px;"> | |||
<view v-if="!readonly" @click.stop="delFile(index,file.uid)" class="cu-tag bg-red" style="height: 24px; width: 24px;"> | |||
<l-icon type="close" color="white" style="width: 18px; height: 24px; font-size: 24px;" /> | |||
</view> | |||
@@ -75,7 +75,7 @@ export default { | |||
return true | |||
}, | |||
async delFile(index) { | |||
async delFile(index,fileId) { | |||
if (!(await this.CONFIRM('删除文件', '确定要删除该文件吗?', true))) { | |||
return | |||
} | |||
@@ -84,6 +84,8 @@ export default { | |||
this.$emit('input', newList) | |||
this.$emit('change') | |||
this.$emit('del') | |||
//物理删除 | |||
this.DELETE_FILE(fileId); | |||
}, | |||
chooseFile() { | |||
@@ -119,6 +119,9 @@ export default { | |||
} | |||
} | |||
//2022-02-14修改end | |||
const fetchFolderkeyData=await this.fetchFolderkeyData(this.currentNode , this.processId); | |||
uni.setStorageSync('guids',JSON.stringify(fetchFolderkeyData)); | |||
// 处理移动端本地表单(也就是系统表单)的情况,直接跳转过去 | |||
//const appSysPage = wfForms.find(t => t.appurl) | |||
@@ -110,6 +110,10 @@ export default { | |||
this.needTitle = this.type !== 'again' && Number(currentNode.isTitle) === 1 | |||
const formData = await this.fetchFormData(currentNode, processId) | |||
const schemeData = await this.fetchSchemeData(currentNode) | |||
const fetchFolderkeyData=await this.fetchFolderkeyData(currentNode, processId); | |||
uni.setStorageSync('guids',JSON.stringify(fetchFolderkeyData)); | |||
const { formValue, scheme, rel } = await this.getCustomForm({ | |||
schemeData, | |||
processId, | |||
@@ -211,7 +211,13 @@ export default { | |||
return { scheme, formValue, rel } | |||
}, | |||
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 的数据 | |||
* 参数:formValue, scheme | |||
@@ -220,37 +226,51 @@ export default { | |||
* 遍历 formValue,将其中的表单值依次使用 convertToPostData 这个方法转化为提交值 | |||
*/ | |||
async getPostData(originFormValue, scheme) { | |||
console.log(originFormValue, scheme) | |||
const formValue = this.COPY(originFormValue) | |||
// 依次按照 scheme 项目遍历 | |||
for (const item of scheme) { | |||
if (item.field) { | |||
// 不是表格的情况 | |||
const path = item.__valuePath__ | |||
const val = get(formValue, path) | |||
const result = await this.convertToPostData(item, val, originFormValue, scheme) | |||
set(formValue, path, result) | |||
} else if (item.table && item.fieldsData) { | |||
// 是表格的情况 | |||
const tableValue = get(formValue, item.__valuePath__, []) | |||
for (let valueIndex = 0; valueIndex < tableValue.length; ++valueIndex) { | |||
for (const schemeItem of item.fieldsData) { | |||
const path = `${item.__valuePath__}.${valueIndex}.${schemeItem.field}` | |||
const val = get(formValue, path) | |||
const result = await this.convertToPostData(schemeItem, val, originFormValue, scheme) | |||
set(formValue, path, result) | |||
} | |||
} | |||
} | |||
} | |||
formValue.formreq.forEach(t => { t.formData = JSON.stringify(t.formData) }) | |||
formValue.formreq = JSON.stringify(formValue.formreq) | |||
return formValue | |||
}, | |||
const formValue = this.COPY(originFormValue) | |||
// 依次按照 scheme 项目遍历 | |||
for (const item of scheme) { | |||
if (item.field) { | |||
// 不是表格的情况 | |||
const path = item.__valuePath__ | |||
const val = get(formValue, path) | |||
var guid = undefined | |||
if (item.type == 'upload') { | |||
// 先生成一个guid | |||
guid = this.newguid(); | |||
// 取出当前列对应的labelId | |||
var labeId = item.id | |||
// 从缓存取出当前审批流程所有的guid | |||
var guids = JSON.parse(uni.getStorageSync('guids')) | |||
if (guids&&JSON.stringify(guids)!=='{}'&&guids[labeId]) { | |||
guid = guids[labeId] | |||
} | |||
} | |||
const result = await this.convertToPostData(item, val, originFormValue, scheme, guid) | |||
set(formValue, path, result) | |||
} else if (item.table && item.fieldsData) { | |||
// 是表格的情况 | |||
const tableValue = get(formValue, item.__valuePath__, []) | |||
for (let valueIndex = 0; valueIndex < tableValue.length; ++valueIndex) { | |||
for (const schemeItem of item.fieldsData) { | |||
const path = `${item.__valuePath__}.${valueIndex}.${schemeItem.field}` | |||
const val = get(formValue, path) | |||
const result = await this.convertToPostData(schemeItem, val, originFormValue, scheme, | |||
guid) | |||
set(formValue, path, result) | |||
} | |||
} | |||
} | |||
} | |||
formValue.formreq.forEach(t => { | |||
t.formData = JSON.stringify(t.formData) | |||
}) | |||
formValue.formreq = JSON.stringify(formValue.formreq) | |||
return formValue | |||
}, | |||
/** | |||
* 获取流程信息 | |||
@@ -325,6 +345,23 @@ export default { | |||
const formData = await this.HTTP_GET('learun/adms/form/data', reqData) | |||
return formData || {} | |||
} | |||
}, | |||
async fetchFolderkeyData(currentNode, keyValue) { | |||
const { | |||
wfForms | |||
} = currentNode | |||
const reqData = wfForms | |||
.filter(t => t.formId) | |||
.map(t => ({ | |||
id: t.formId, | |||
ver: '', | |||
schemeInfoId: t.formId, | |||
processIdName: t.field, | |||
keyValue | |||
})) | |||
const folderkeyData = await this.HTTP_GET('learun/adms/form/folderkey', reqData) | |||
return folderkeyData || {} | |||
}, | |||
} | |||
} |