Skip to content

Commit

Permalink
修正查找到的单元格内容
Browse files Browse the repository at this point in the history
  • Loading branch information
etchnight committed Jan 10, 2024
1 parent 9a01dab commit 0d9f8c3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/components/TableColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
:href="`siyuan://blocks/` + scope.row[props.child.value]"
:icon="Link"
/>
<protyle :id="scope.row[props.child.value]"></protyle>
</div>
<protyle :id="scope.row[props.child.value]"></protyle>
</template>
</el-table-column>
<el-table-column
Expand All @@ -34,11 +34,8 @@
import protyle from "./protyle.vue";
import { Link } from "@element-plus/icons-vue";
import { Head } from "./Table.vue";
import { onMounted } from "vue";
const props = defineProps<{
child: Head;
}>();
onMounted(() => {
console.log(props.child);
});
</script>
34 changes: 27 additions & 7 deletions src/components/TableData_Tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
queryBlocksByTag,
queryDescendantBlocks,
} from "../../lib/siyuanPlugin-common/siyuan-api/query";
//import { getParentNextChildID } from "../../lib/siyuanPlugin-common/siyuan-api/block";
import { Block } from "../../lib/siyuanPlugin-common/types/siyuan-api";
import { Data, Head } from "./Table.vue";
import Table from "./Table.vue";
Expand Down Expand Up @@ -65,7 +66,6 @@ watch(props, async (newProps) => {
};
recurList2Tree(tagTree, columnProps);
tableHead.value = tagTree;
console.log(tagTree);
/*构建表格主体
第一列为名称,值为tag所在block的content
其余列根据tag表示的属性,分别从后代block中查找*/
Expand All @@ -77,16 +77,36 @@ watch(props, async (newProps) => {
name: block.content.replace("#" + tag + "#", ""),
};
const childBlocks = await queryDescendantBlocks(block);
const childBlocksReverse = childBlocks.toReversed();
for (let prop of columnProps) {
let propBlock = childBlocks.find((e) => {
return (
e.content.indexOf(prop.value) > -1 && e.layer !== 0 && e.type != "l"
);
/*查找到的block需满足以下条件
- 如果不是段落,直接满足
- 如果是段落,则必须是父级的第一个子块,并且父级content是含有标签的块
*/
let propBlock = childBlocksReverse.find((e) => {
return e.content.indexOf(prop.value) > -1;
});
if (propBlock) {
data[prop.value] = propBlock.id;
if (!propBlock) {
continue;
}
if (propBlock.type == "p") {
let parentBlock = childBlocksReverse.find((e) => {
return e.id == propBlock.parent_id;
});
//let firstChildId = await getParentNextChildID(propBlock.id);
//console.log(parentBlock.type, firstChildId, propBlock.id);
if (
parentBlock.content.indexOf(prop.value) > -1
//&& firstChildId.id == propBlock.id
) {
propBlock = parentBlock;
}
}
data[prop.value] = propBlock.id;
}
return data;
})
);
Expand Down

0 comments on commit 0d9f8c3

Please sign in to comment.