Skip to content

Commit

Permalink
[Bug]: 对象启用“树状结构”显示后,无法在列表页快速编辑
Browse files Browse the repository at this point in the history
  • Loading branch information
tujiajun committed Dec 25, 2023
1 parent ac6d698 commit d6c0b23
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ async function getQuickEditSchema(field, options){
{
"actionType": "custom",
"script": `
var _display = _.cloneDeep(event.data._display);
${displayField}
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
Expand Down Expand Up @@ -483,7 +484,9 @@ export async function getTableColumns(fields, options){
if(!options.isLookup && !options.isInputTable){
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
if(!options.enable_tree){
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
}
}
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;

Expand Down Expand Up @@ -1336,14 +1339,29 @@ export async function getTableApi(mainObject, fields, options){
if(enable_tree){
const records = payload.data.rows || [];
const getTreeOptions = SteedosUI.getTreeOptions
const getTreeOptions = SteedosUI.getTreeOptions;
const assignIndexToTreeRecords = function(tree, parentIndex) {
tree.forEach(function (node, index) {
// 构建当前节点的 _index
var currentIndex = parentIndex ? parentIndex + '-' + (index + 1) : '' + (index + 1);
// 赋值给节点
node._index = currentIndex;
// 如果有子节点,递归调用函数
if (node.children && node.children.length > 0) {
assignIndexToTreeRecords(node.children, currentIndex);
}
});
};
let isTreeOptionsComputed = false;
if(records.length === 1 && records[0].children){
isTreeOptionsComputed = true;
}
if(!isTreeOptionsComputed){
// 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
assignIndexToTreeRecords(payload.data.rows, '');
}
try{
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export async function getObjectCRUD(objectSchema, fields, options){
let tableOptions = Object.assign({
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,
crudId: listSchema.id || id
crudId: listSchema.id || id, enable_tree: objectSchema.enable_tree
}, options);
tableOptions.amisData = createObject(options.amisData || {}, {});
const table = await getTableSchema(fields, tableOptions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
@media (min-width: 767px) {
/* 列表快速编辑功能样式 */
.steedos-object-table {
//隐藏为批量编辑而加的_display列
//有数据的普通列表隐藏第二列,_display列
thead tr th:nth-child(2){
display: none;
}

&.is-steedos-tree-table {
//有数据的树结构列表隐藏第三列,_display列
thead tr th:nth-child(3){
display: none;
}
thead tr th:nth-child(2){
display: table-cell;
}
//无数据的树结构列表隐藏第一列,_display列
.is-steedos-crud-data-empty{
thead tr th:nth-child(2),thead tr th:nth-child(3){
display: table-cell;
}
thead tr th:nth-child(1){
display: none;
}
}
}

//无数据的普通列表隐藏第二列,_display列
.is-steedos-crud-data-empty {
thead tr th:nth-child(3){
display: table-cell;
Expand Down

0 comments on commit d6c0b23

Please sign in to comment.