Commit 5287edff by Joey

feat(@gms/gms-plugin-billexpand): 调整公式

parent 816a25d2
......@@ -4844,6 +4844,38 @@ export default {
"discard": false,
"path": "通用",
"extends": {
"info": {
"param": [],
"name": "SetSubValueToMaster",
"description": "1.子表字段,2.赋值的主表字段",
"title": "从子表一个字段选一个值赋值到主表",
"return": 0
}
},
"description": "1.子表字段,2.赋值的主表字段",
"title": "从子表一个字段选一个值赋值到主表",
"value": "SetSubValueToMaster"
},
{
"discard": false,
"path": "通用",
"extends": {
"info": {
"param": [],
"name": "UnsafeApplyFunction",
"description": "1.context,2.其它参数",
"title": "执行js函数",
"return": 0
}
},
"description": "1.context,2.其它参数",
"title": "执行js函数",
"value": "UnsafeApplyFunction"
},
{
"discard": false,
"path": "通用",
"extends": {
"info": {
"param": [
......
export default {
execute: async function ([originField, targetField, triggerFormula], context) {
console.log("主表字段赋值");
const subTable = context.getSubData(context.getTableType(originField.FieldTableCode).title)
triggerFormula = triggerFormula && triggerFormula.StaticValue
let originData = ''
if (subTable instanceof Array && subTable.length) {
originData = subTable[0].getValue(originField.FieldCode)
}
context.getMasterData().setValue(
targetField.FieldTableCode + '.' + targetField.FieldCode,
originData,
null,
triggerFormula ? 'all' : 'none'
)
return originData
},
getResultType: function () {
return FMR.ConstDataTypes.General;
}
}
\ No newline at end of file
......@@ -8,6 +8,10 @@ export default {
let context = arguments[1]
let targetSubField = arguments[0][0]
let sourceValueField = arguments[0][1]
let triggerFormula = false
if (arguments[0][2] && arguments[0][2].StaticValue) {
triggerFormula = true
}
if (sourceValueField instanceof FunctionNode) {
let funcResult = sourceValueField.getResult()
if(funcResult instanceof AbstractData) {
......@@ -26,8 +30,12 @@ export default {
}
let subTableObject = context.getTableType(targetSubField.FieldTableCode)
let oldIndex = context.getSubFocus()
let focusData = context.getAllSubData()[subTableObject.title][oldIndex].getData()
focusData[targetSubField.FieldCode]._field_old_value_ = focusData[targetSubField.FieldCode].value = result
context.getAllSubData()[subTableObject.title][oldIndex].setValue(
targetSubField.FieldTableCode + '.' + targetSubField.FieldCode,
result,
null,
triggerFormula ? 'all' : 'none'
)
context.refreshSubDataRow(subTableObject.title);
}
return result
......
import * as util from './util'
export default {
execute: function ([functionString, ...args], context) {
return Function('"use strict";return (' + functionString.StaticValue + ')')()(
{ context, util }, ...args
)
},
getResultType: function () {
return FMR.ConstDataTypes.General;
}
}
......@@ -169,6 +169,8 @@ import SetSubFieldsByBaseData from "./formula/SetSubFieldsByBaseData";
import SubTableSetData from "./formula/SubTableSetData";
import GetOwnProperty from "./formula/GetOwnProperty";
import GetMDByObjectcode from "./formula/GetMDByObjectcode";
import SetSubValueToMaster from "./formula/SetSubValueToMaster";
import UnsafeApplyFunction from "./formula/UnsafeApplyFunction";
export default {
actions: {
updateFieldAction,
......@@ -338,6 +340,8 @@ export default {
SubTableSetData,
GetMDByObjectcode,
GetOwnProperty,
SetSubValueToMaster,
UnsafeApplyFunction,
...GeneralImportFile,
},
routes : {
......
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