Commit 968f104e by 乔延琦

Merge branch 'develop-zhouyi' into 'develop'

fix(@gms/gms-plugin-billexpand): 公式applyTemplateString

See merge request GFP/RBC/rbc-frontend!109
parents 18d1af9d d11a979e
// 子表根据基础数据带出基础数据
export default {
execute: function () {
const GLOBAL_PARAM_KEY = 'applyTemplateStringData'
if (arguments && arguments[0] && arguments[1]) {
const context = arguments[1]
if (!context.getGlobalParam(GLOBAL_PARAM_KEY)) {
context.setGlobalParam(GLOBAL_PARAM_KEY, {})
}
const originField = arguments[0][0]
const targetField = arguments[0][1]
let templateString = arguments[0][2].StaticValue
......@@ -12,6 +17,18 @@ export default {
const argList = args.split(',')
const originTableType = context.getTableType(originField.FieldTableCode)
const originTableObject = context.getSubData(originTableType.title)
const oldValue = context.getGlobalParam(GLOBAL_PARAM_KEY)[originTableType.title]
if (originTableObject instanceof Array) {
const newValue = originTableObject
.map((o) => o.getValue(originField.FieldCode))
.filter((o) => o && o.code)
.map((o) => o.code)
.join(',')
if (oldValue != newValue) {
context.getGlobalParam(GLOBAL_PARAM_KEY)[originTableType.title] = newValue
}
else return
}
const requestParam = {
pagination: false,
searchKey: "",
......@@ -19,11 +36,7 @@ export default {
stopflag: -1,
authType: "NONE"
}
const replaceMap = new Map()
const replaceTemplatePart = templateString.match(/{{.+?}}/g)
replaceTemplatePart.forEach((part) => {
replaceMap.set(part, [])
})
const getBaseDataList = (originFieldValue) => {
const promistList = []
for (let i = 0; i < argList.length; i += 2) {
......@@ -63,12 +76,17 @@ export default {
return templateString
}
if (originTableObject instanceof Array) {
const replaceMap = new Map()
const replaceTemplatePart = templateString.match(/{{.+?}}/g)
replaceTemplatePart.forEach((part) => {
replaceMap.set(part, [])
})
const getBasedataPromiseList = []
let count = 0
for (let i = 0; i < originTableObject.length; ++i) {
const originObject = originTableObject[i]
const curOriginFieldValue = originObject.getValue(originField.FieldCode)
if (!curOriginFieldValue || !curOriginFieldValue.objectcode) {
if (!curOriginFieldValue || !curOriginFieldValue.code) {
continue
}
getBasedataPromiseList.push(getBaseDataList(curOriginFieldValue).then((basedataObjectList) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment