目前我的视图组件是“嵌入视图”,我在数据中心的该视图的操作列写了click事件,当点击时获取行的Jobid列调用接口获取返回数据,然后把值赋给表单上的组件:
[JavaScript] 纯文本查看 复制代码 var _this = this
console.log('this.target.row.data',this.target.row.data.data.JobId)
var job = this.target.row.data.data.JobId
var action = this.Actions.load("x_processplatform_assemble_surface");
action.DataAction.getWithJob(//平台封装好的方法
job,//uri的参数
function( json ){ //服务调用成功的回调函数, json为服务传回的数据
data = json.data; //为变量data赋值
console.log('返回业务数据',data)
// 需要提取的字段列表(已去除前缀)
const fields = [
"顾客单位或编码",
"联系人",
"地址",
"电话",
"产品名称",
"数量",
"评审内容",
"其他说明",
"特殊要求",
"评审部门",
"补充说明",
"交货期",
"评审结果其他",
"产品版本",
"发货单号",
"备注"
];
// 用于存储格式化结果
let result = [];
// 遍历字段列表
fields.forEach(field => {
// 构造原始字段名(带前缀)
const elInputKey = `elinput_${field}`;
const elCheckboxKey = `elcheckbox_${field}`;
const calendarKey = `calendar_${field}`;
// 从 data 中获取值
let value;
if (data.hasOwnProperty(elInputKey)) {
value = data[elInputKey];
} else if (data.hasOwnProperty(elCheckboxKey)) {
value = data[elCheckboxKey].join("、"); // 数组转为逗号分隔
} else if (data.hasOwnProperty(calendarKey)) {
value = data[calendarKey];
} else {
value = "无"; // 字段不存在时的默认值
}
// 格式化字符串
result.push(`${field}:“${value}”`);
});
// 最终结果(每行换行)
const formattedResult = result.join("\n");
console.log(formattedResult);
[font=quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, sans-serif][color=#000000]_this.data['elinput_1_1'] = formattedResult[/color][/font]
}.bind(this),
function( json ){ //服务调用失败的回调函数, json为服务传回的数据
data = json.data; //为变量data赋值
}.bind(this)
);
我想把formattedResult的值赋值给流程表单上的elinput_1_1组件,但是
现在console.log(formattedResult);是能正常打印出值的,问题出在这行:[JavaScript] 纯文本查看 复制代码 _this.data['elinput_1_1'] = formattedResult 会报错:
Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'elinput_1_1')
at MWF.xScript.ViewEnvironment.<anonymous> (<anonymous>:68:27)
at Object.onSuccess (<anonymous>:1:50037)
at i.extend.$owner (mootools-1.6.0_all.js:1399:1)
at Object._runCallback [as runCallback] (o2.js:353:1)
at o2.js:2227:1
然后我换成[JavaScript] 纯文本查看 复制代码 _this.form.get("elinput_1_1").setData(formattedResult); 也报错:
报错:Uncaught (in promise) TypeError: _this.form.get is not a function
at MWF.xScript.ViewEnvironment.<anonymous> (<anonymous>:68:38)
at Object.onSuccess (<anonymous>:1:50037)
at i.extend.$owner (mootools-1.6.0_all.js:1399:1)
at Object._runCallback [as runCallback] (o2.js:353:1)
at o2.js:2227:1
请问我该如何将嵌入视图的视图列获取到的处理后的某个值赋值给该视图放置的表单上的组件?
|