Commit d11a979e by Joey

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

- 进入单据编辑状态时字段被清空
- 对比子表前后变化避免多次执行
parent 18d1af9d
// 子表根据基础数据带出基础数据 // 子表根据基础数据带出基础数据
export default { export default {
execute: function () { execute: function () {
const GLOBAL_PARAM_KEY = 'applyTemplateStringData'
if (arguments && arguments[0] && arguments[1]) { if (arguments && arguments[0] && arguments[1]) {
const context = arguments[1] const context = arguments[1]
if (!context.getGlobalParam(GLOBAL_PARAM_KEY)) {
context.setGlobalParam(GLOBAL_PARAM_KEY, {})
}
const originField = arguments[0][0] const originField = arguments[0][0]
const targetField = arguments[0][1] const targetField = arguments[0][1]
let templateString = arguments[0][2].StaticValue let templateString = arguments[0][2].StaticValue
...@@ -12,6 +17,18 @@ export default { ...@@ -12,6 +17,18 @@ export default {
const argList = args.split(',') const argList = args.split(',')
const originTableType = context.getTableType(originField.FieldTableCode) const originTableType = context.getTableType(originField.FieldTableCode)
const originTableObject = context.getSubData(originTableType.title) 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 = { const requestParam = {
pagination: false, pagination: false,
searchKey: "", searchKey: "",
...@@ -19,11 +36,7 @@ export default { ...@@ -19,11 +36,7 @@ export default {
stopflag: -1, stopflag: -1,
authType: "NONE" authType: "NONE"
} }
const replaceMap = new Map()
const replaceTemplatePart = templateString.match(/{{.+?}}/g)
replaceTemplatePart.forEach((part) => {
replaceMap.set(part, [])
})
const getBaseDataList = (originFieldValue) => { const getBaseDataList = (originFieldValue) => {
const promistList = [] const promistList = []
for (let i = 0; i < argList.length; i += 2) { for (let i = 0; i < argList.length; i += 2) {
...@@ -63,12 +76,17 @@ export default { ...@@ -63,12 +76,17 @@ export default {
return templateString return templateString
} }
if (originTableObject instanceof Array) { if (originTableObject instanceof Array) {
const replaceMap = new Map()
const replaceTemplatePart = templateString.match(/{{.+?}}/g)
replaceTemplatePart.forEach((part) => {
replaceMap.set(part, [])
})
const getBasedataPromiseList = [] const getBasedataPromiseList = []
let count = 0 let count = 0
for (let i = 0; i < originTableObject.length; ++i) { for (let i = 0; i < originTableObject.length; ++i) {
const originObject = originTableObject[i] const originObject = originTableObject[i]
const curOriginFieldValue = originObject.getValue(originField.FieldCode) const curOriginFieldValue = originObject.getValue(originField.FieldCode)
if (!curOriginFieldValue || !curOriginFieldValue.objectcode) { if (!curOriginFieldValue || !curOriginFieldValue.code) {
continue continue
} }
getBasedataPromiseList.push(getBaseDataList(curOriginFieldValue).then((basedataObjectList) => { 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