修复图片上传节点无法上传图片到子表的问题
This commit is contained in:
parent
82f00565fa
commit
3c2d21981d
@ -240,11 +240,9 @@ def execute(context=None, inputs=None, config=None, **kwargs):
|
||||
# 对于子表字段,attached_to_field保存了原始格式(如items[0].image)
|
||||
# 对于普通字段,attached_to_field是映射后的字段名
|
||||
if is_subtable_field and attached_to_field:
|
||||
# 检测是否为子表字段格式:只支持更新已有行(支持中文字段名)
|
||||
# 解析子表字段格式:fieldname[index].subfield
|
||||
subtable_match = re.match(r'^([\w\u4e00-\u9fa5]+)\[(\d+)\]\.([\w\u4e00-\u9fa5]+)$', attached_to_field)
|
||||
|
||||
if subtable_match:
|
||||
# 处理子表字段:更新指定行的字段值
|
||||
subtable_field, row_index_str, field_name = subtable_match.groups()
|
||||
row_index = int(row_index_str)
|
||||
|
||||
@ -258,27 +256,30 @@ def execute(context=None, inputs=None, config=None, **kwargs):
|
||||
attached_to_pagetype, attached_to_name, subtable_fieldname
|
||||
) or []
|
||||
|
||||
# 只更新已有行,不添加新行
|
||||
if 0 <= row_index < len(subtable_data):
|
||||
if not isinstance(subtable_data[row_index], dict):
|
||||
subtable_data[row_index] = {}
|
||||
subtable_data[row_index][field_fieldname] = file_url
|
||||
# 更新指定行的字段值
|
||||
if isinstance(subtable_data, list) and 0 <= row_index < len(subtable_data):
|
||||
if isinstance(subtable_data[row_index], dict):
|
||||
subtable_data[row_index][field_fieldname] = file_url
|
||||
|
||||
# 更新整个子表字段
|
||||
update_api_url = f"{Config.jingrow_server_url}/api/action/jingrow.client.set_value"
|
||||
headers = get_jingrow_api_headers()
|
||||
if headers:
|
||||
update_data = {
|
||||
'pagetype': attached_to_pagetype,
|
||||
'name': attached_to_name,
|
||||
'fieldname': subtable_fieldname,
|
||||
'value': json.dumps(subtable_data, ensure_ascii=False)
|
||||
}
|
||||
requests.post(update_api_url, json=update_data, headers=headers, timeout=10)
|
||||
# 更新整个子表字段
|
||||
update_api_url = f"{Config.jingrow_server_url}/api/action/jingrow.client.set_value"
|
||||
headers = get_jingrow_api_headers()
|
||||
if headers:
|
||||
requests.post(
|
||||
update_api_url,
|
||||
json={
|
||||
'pagetype': attached_to_pagetype,
|
||||
'name': attached_to_name,
|
||||
'fieldname': subtable_fieldname,
|
||||
'value': subtable_data
|
||||
},
|
||||
headers=headers,
|
||||
timeout=10
|
||||
)
|
||||
else:
|
||||
log_error(f"子表第 {row_index} 行数据格式错误")
|
||||
else:
|
||||
log_error(f"子表行索引 {row_index} 超出范围,请先创建子表行")
|
||||
else:
|
||||
log_error(f"子表字段格式解析失败: {attached_to_field}")
|
||||
log_error(f"子表行索引 {row_index} 超出范围")
|
||||
elif attached_to_field:
|
||||
# 普通字段更新
|
||||
update_api_url = f"{Config.jingrow_server_url}/api/action/jingrow.client.set_value"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user