Skip to content

Commit

Permalink
[Bug]: 附件型字段,在只读页面点击后显示未找到记录,编辑页面可正常下载文件
Browse files Browse the repository at this point in the history
  • Loading branch information
tujiajun committed Aug 28, 2024
1 parent ba522a8 commit bc62144
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ function getScriptForRewriteValueForFileFields(fields){
if(fileFields[item].multiple){
if(fileFieldDisplayValue instanceof Array){
data[item] = fileFieldDisplayValue.map((item, index)=>{
item.value = fileFieldValue[index];
return {
value: fileFieldValue[index],
name: item.name,
Expand All @@ -240,6 +241,7 @@ function getScriptForRewriteValueForFileFields(fields){
});
}
}else{
fileFieldDisplayValue.value = fileFieldValue;
data[item] = [{
value: fileFieldValue,
name: fileFieldDisplayValue.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function getLookupLinkOnClick(field, options) {
const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });

const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
"recordId": `\${${field.name}}`,
"recordId": field.type == "file" ? "${value}":`\${${field.name}}`,
"data": {
...recordPage.schema.data,
"_inDrawer": true, // 用于判断是否在抽屉中
Expand All @@ -39,7 +39,7 @@ async function getLookupLinkOnClick(field, options) {
}) : {
"type": "steedos-record-detail",
"objectApiName": options.objectName,
"recordId": `\${${field.name}}`,
"recordId": field.type == "file" ? "${value}":`\${${field.name}}`,
"showBackButton": false,
"showButtons": true,
"data": {
Expand Down Expand Up @@ -135,17 +135,18 @@ export const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
// <a href='<%= item.url %>' target='_self' class='block'><%= item.name %></a>
// <% });} %>`
"type": "control",
"name": "",//control若存在name,内部each组件的source则会获取不到内容
"body": {
type: 'each',
placeholder: "",
// className: `steedos-field-lookup-each flex flex-wrap gap-2`,
className: steedosField.multiple ? `flex flex-col` : '',
source: `\${_display.${steedosField.name}|asArray}`,
items: {
type: 'static',
labelClassName: "hidden",
label: false,
className: 'm-0',
tpl: `<a href="/app/-/cfs_files_filerecord/view/\${${steedosField.name}}" ${lookupATagClick}>\${name}</a>`,
tpl: `<a href="/app/-/cfs_files_filerecord/view/\${value}" ${lookupATagClick}>\${name}</a>`,
// tpl: "<%= item.name >",
// onEvent: window.innerWidth < 768 ? null : REFERENCE_VALUE_ITEM_ONCLICK
onEvent: window.innerWidth < 768 ? null : await getLookupLinkOnClick(steedosField, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ async function getQuickEditSchema(object, columnField, options){
_display["${field.name}"].push({
"name": event.data.result.name,
"url": event.data.result.url,
"value": event.data.result.value,
"_id": event.data.result.value,
"type": event.data.item.type,
"size": event.data.item.size
});
Expand All @@ -232,6 +234,8 @@ async function getQuickEditSchema(object, columnField, options){
_display["${field.name}"] = {
"name": event.data.result.name,
"url": event.data.result.url,
"value": event.data.result.value,
"_id": event.data.result.value,
"type": event.data.item.type,
"size": event.data.item.size
};
Expand Down Expand Up @@ -679,7 +683,7 @@ export async function getTableColumns(object, fields, options){
static: true,
className,
...await getAmisFileReadonlySchema(field)
}, fieldAmis, {name: field.name});
}, fieldAmis);
}
else if(field.type === 'select'){
const map = Tpl.getSelectMap(field.options);
Expand Down Expand Up @@ -1492,7 +1496,8 @@ export async function getTableApi(mainObject, fields, options){
// PC客户端附件子表列表点击标题预览附件功能依赖了_id,所以这里拼出来
let itemKeyValue = item[key];
item[key] = value.map(function(item, index){
item._id = itemKeyValue[index];
item._id = typeof itemKeyValue == 'string' ? itemKeyValue : itemKeyValue[index];
item.value = typeof itemKeyValue == 'string' ? itemKeyValue : itemKeyValue[index];
return item;
});
}else{
Expand Down

0 comments on commit bc62144

Please sign in to comment.