104 lines
4.2 KiB
Vue
104 lines
4.2 KiB
Vue
<template>
|
|
<a-button-group>
|
|
<a-button @click="handleCreateRevisInformation">插入修订信息</a-button>
|
|
</a-button-group>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "RevisInformation",
|
|
methods: {
|
|
handleCreateRevisInformation() {
|
|
this.ctx.callCommand(() => {
|
|
try {
|
|
const oDocument = Api.GetDocument();
|
|
// const oParagraph = oDocument.Document.GetCurrentParagraph(
|
|
// undefined,
|
|
// undefined,
|
|
// { CheckDocContent: true }
|
|
// );
|
|
const newParagraph = Api.CreateParagraph();
|
|
// newParagraph.SetParagraphWx(oParagraph);
|
|
// 获取到父Table
|
|
let parentTable = newParagraph.GetParentTable();
|
|
let parentTableCell = newParagraph.GetParentTableCell();
|
|
// if (!parentTable) {
|
|
// return "当前父元素ClassType不是Table";
|
|
// }
|
|
const oTable = Api.CreateTable(4, 5);
|
|
oTable.SetWidth("percent", 100);
|
|
oTable.SetTableLayout('fixed');
|
|
|
|
oTable.SetTableCellMarginRight(0.2 * (1440 / 2.54));
|
|
oTable.SetTableCellMarginTop(0.2 * (1440 / 2.54));
|
|
oTable.SetTableCellMarginLeft(0.2 * (1440 / 2.54));
|
|
oTable.SetTableCellMarginBottom(0.2 * (1440 / 2.54));
|
|
|
|
oTable.SetTableBorderTop("single", 9, 0, 0, 0, 0);
|
|
oTable.SetTableBorderBottom("single", 6, 0, 0, 0, 0);
|
|
oTable.SetTableBorderLeft("single", 6, 0, 0, 0, 0);
|
|
oTable.SetTableBorderRight("single", 6, 0, 0, 0, 0);
|
|
|
|
oTable.SetTableBorderInsideV("single", 6, 0, 0, 0, 0);
|
|
oTable.SetTableBorderInsideH("single", 6, 0, 0, 0, 0);
|
|
oDocument.Push(oTable);
|
|
// 构建表头
|
|
const btRow = oTable.GetRow(0);
|
|
// 0
|
|
// const oBlockLvlSdt00 = Api.CreateBlockLvlSdt();
|
|
// oBlockLvlSdt00.GetContent().GetElement(0).AddText("No.");
|
|
btRow.GetCell(0).SetWidth("percent", 5);
|
|
btRow.GetCell(0).GetContent().GetElement(0).AddText("No.");
|
|
btRow.GetCell(0).SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
|
// btRow.GetCell(0).AddElement(0, oBlockLvlSdt00);
|
|
// 1
|
|
// const oBlockLvlSdt01 = Api.CreateBlockLvlSdt();
|
|
// oBlockLvlSdt01
|
|
// .GetContent()
|
|
// .GetElement(0)
|
|
// .AddText("标准编号/Standard No.");
|
|
// btRow.GetCell(1).AddElement(0, oBlockLvlSdt01);
|
|
btRow.GetCell(1).SetWidth("percent", 30);
|
|
btRow.GetCell(1).GetContent().GetElement(0).AddText("标准编号/Standard No.");
|
|
btRow.GetCell(1).SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
|
// 2
|
|
// const oBlockLvlSdt02 = Api.CreateBlockLvlSdt();
|
|
// oBlockLvlSdt02.GetContent().GetElement(0).AddText("起草人/Drafter");
|
|
// btRow.GetCell(2).AddElement(0, oBlockLvlSdt02);
|
|
btRow.GetCell(2).SetWidth("percent", 20);
|
|
btRow.GetCell(2).GetContent().GetElement(0).AddText("起草人/Drafter");
|
|
btRow.GetCell(2).SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
|
// 3
|
|
// const oBlockLvlSdt03 = Api.CreateBlockLvlSdt();
|
|
// oBlockLvlSdt03
|
|
// .GetContent()
|
|
// .GetElement(0)
|
|
// .AddText(
|
|
// "主要修订内容/Revision information"
|
|
// );
|
|
// btRow.GetCell(3).AddElement(0, oBlockLvlSdt03);
|
|
btRow.GetCell(3).SetWidth("percent", 40);
|
|
btRow.GetCell(3).GetContent().GetElement(0).SetJc("center");
|
|
btRow.GetCell(3).GetContent().GetElement(0).AddText("主要修订内容/Revision information");
|
|
btRow.GetCell(3).SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
|
|
|
for (let i = 0; i < oTable.GetRowsCount(); i++) {
|
|
for (let j = 0; j < oTable.GetRow(i).GetCellsCount(); j++) {
|
|
const oParagraph = oTable.GetCell(i, j).GetContent().GetElement(0);
|
|
if (i > 0) {
|
|
oParagraph.SetColor(0, 0, 255);
|
|
}
|
|
oParagraph.SetJc("center");
|
|
}
|
|
}
|
|
|
|
parentTableCell.AddElement(0, oTable);
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|