Initial commit
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div id="nav">
|
||||
<router-link to="/">Home</router-link> |
|
||||
<router-link to="/about">About</router-link>
|
||||
</div>
|
||||
<router-view/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less">
|
||||
#app {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-align: center;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
#nav {
|
||||
padding: 30px;
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
color: #2c3e50;
|
||||
|
||||
&.router-link-exact-active {
|
||||
color: #42b983;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<h1>{{ msg }}</h1>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br>
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
||||
</p>
|
||||
<h3>Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
|
||||
</ul>
|
||||
<h3>Essential Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
|
||||
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
|
||||
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
|
||||
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
|
||||
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
|
||||
</ul>
|
||||
<h3>Ecosystem</h3>
|
||||
<ul>
|
||||
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
|
||||
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
|
||||
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
|
||||
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'HelloWorld',
|
||||
props: {
|
||||
msg: String,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped lang="less">
|
||||
h3 {
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @description: 系统配置文件
|
||||
* @author: chenxiaoxi
|
||||
* @date: 2021-08-18 17:47:46
|
||||
*/
|
||||
const interfaceUrl = window._CONFIG.interfaceUrl + '/api/' //本地
|
||||
// const interfaceUrl = 'https://srms.foton.com.cn/api/' //线上
|
||||
|
||||
const uploadFilePath = 'api/att/attFile/uploadNew'
|
||||
|
||||
const staticFilePath = window._CONFIG.interfaceUrl + '/api/att/attFile/downloadFileForSarNew' //本地
|
||||
// const staticFilePath = 'https://srms.foton.com.cn/api/att/attFile/downloadFile' //线上
|
||||
module.exports = {
|
||||
interfaceUrl,
|
||||
uploadFilePath,
|
||||
staticFilePath
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
// base library
|
||||
import {
|
||||
ConfigProvider,
|
||||
Layout,
|
||||
Input,
|
||||
InputNumber,
|
||||
Button,
|
||||
Switch,
|
||||
Radio,
|
||||
Checkbox,
|
||||
Select,
|
||||
Card,
|
||||
Form,
|
||||
FormModel,
|
||||
Row,
|
||||
Col,
|
||||
Modal,
|
||||
Table,
|
||||
Tabs,
|
||||
Icon,
|
||||
Badge,
|
||||
Popover,
|
||||
Dropdown,
|
||||
List,
|
||||
Avatar,
|
||||
Breadcrumb,
|
||||
Steps,
|
||||
Spin,
|
||||
Menu,
|
||||
Drawer,
|
||||
Tooltip,
|
||||
Alert,
|
||||
Tag,
|
||||
Divider,
|
||||
DatePicker,
|
||||
TimePicker,
|
||||
Upload,
|
||||
Progress,
|
||||
Skeleton,
|
||||
Popconfirm,
|
||||
PageHeader,
|
||||
Result,
|
||||
Statistic,
|
||||
Descriptions,
|
||||
Space,
|
||||
message,
|
||||
notification
|
||||
} from 'ant-design-vue'
|
||||
// import Viser from 'viser-vue'
|
||||
|
||||
// ext library
|
||||
// import VueCropper from 'vue-cropper'
|
||||
// import Dialog from '@/components/Dialog'
|
||||
// import MultiTab from '@/components/MultiTab'
|
||||
// import PageLoading from '@/components/PageLoading'
|
||||
// import PermissionHelper from '@/core/permission/permission'
|
||||
// import './directives/action'
|
||||
|
||||
Vue.use(ConfigProvider)
|
||||
Vue.use(Layout)
|
||||
Vue.use(Input)
|
||||
Vue.use(InputNumber)
|
||||
Vue.use(Button)
|
||||
Vue.use(Switch)
|
||||
Vue.use(Radio)
|
||||
Vue.use(Checkbox)
|
||||
Vue.use(Select)
|
||||
Vue.use(Card)
|
||||
Vue.use(Form)
|
||||
Vue.use(FormModel)
|
||||
Vue.use(Row)
|
||||
Vue.use(Col)
|
||||
Vue.use(Modal)
|
||||
Vue.use(Table)
|
||||
Vue.use(Tabs)
|
||||
Vue.use(Icon)
|
||||
Vue.use(Badge)
|
||||
Vue.use(Popover)
|
||||
Vue.use(Dropdown)
|
||||
Vue.use(List)
|
||||
Vue.use(Avatar)
|
||||
Vue.use(Breadcrumb)
|
||||
Vue.use(Steps)
|
||||
Vue.use(Spin)
|
||||
Vue.use(Menu)
|
||||
Vue.use(Drawer)
|
||||
Vue.use(Tooltip)
|
||||
Vue.use(Alert)
|
||||
Vue.use(Tag)
|
||||
Vue.use(Divider)
|
||||
Vue.use(DatePicker)
|
||||
Vue.use(TimePicker)
|
||||
Vue.use(Upload)
|
||||
Vue.use(Progress)
|
||||
Vue.use(Skeleton)
|
||||
Vue.use(Popconfirm)
|
||||
Vue.use(PageHeader)
|
||||
Vue.use(Result)
|
||||
Vue.use(Statistic)
|
||||
Vue.use(Descriptions)
|
||||
Vue.use(Space)
|
||||
|
||||
Vue.prototype.$confirm = Modal.confirm
|
||||
Vue.prototype.$message = message
|
||||
Vue.prototype.$notification = notification
|
||||
Vue.prototype.$info = Modal.info
|
||||
Vue.prototype.$success = Modal.success
|
||||
Vue.prototype.$error = Modal.error
|
||||
Vue.prototype.$warning = Modal.warning
|
||||
|
||||
// Vue.use(Viser)
|
||||
// Vue.use(Dialog) // this.$dialog func
|
||||
// Vue.use(MultiTab)
|
||||
// Vue.use(PageLoading)
|
||||
// Vue.use(PermissionHelper)
|
||||
// Vue.use(VueCropper)
|
||||
|
||||
// process.env.NODE_ENV !== 'production' && console.warn('[antd-pro] NOTICE: Antd use lazy-load.')
|
||||
Binary file not shown.
+11
@@ -0,0 +1,11 @@
|
||||
import Vue from 'vue'
|
||||
import './plugins/axios'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
render: (h) => h(App),
|
||||
}).$mount('#app')
|
||||
Binary file not shown.
@@ -0,0 +1,333 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<!-- <template v-for="item in data">
|
||||
<insert-text :title="item.title" :key="item.title" :list="item.list" />
|
||||
</template> -->
|
||||
<!-- <div class="app-header">-->
|
||||
<!-- <a-button @click="save" class="app-header-button">保存</a-button>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- <div class="ant-drawer-index" v-if="isDisplay">-->
|
||||
<!-- 数据保存中;请勿关闭页面 <span class="ant-drawer-text">{{num}}</span>-->
|
||||
<!-- </div>-->
|
||||
<template v-for="item in data">
|
||||
<insert-guide-text
|
||||
:title="item.title"
|
||||
:key="`insert-guide-text${item.title}`"
|
||||
:list="item.list"
|
||||
:separatorText="item.separatorText"
|
||||
/>
|
||||
</template>
|
||||
<a-divider>初始化</a-divider>
|
||||
<Init/>
|
||||
<a-divider>正文</a-divider>
|
||||
<chapterData/>
|
||||
<first-level-listing/>
|
||||
<SaicFunc/>
|
||||
<!-- <a-divider>正文</a-divider>-->
|
||||
<!-- <contentOne />-->
|
||||
<!-- <a-divider>列项</a-divider>-->
|
||||
<!-- <a-divider>函数</a-divider>-->
|
||||
<a-divider>表格、图片</a-divider>
|
||||
<SaicTable/>
|
||||
<SaicImg/>
|
||||
<!-- <a-divider>图</a-divider>-->
|
||||
<!-- <SaicImg/>-->
|
||||
<!-- <insert-image />-->
|
||||
<a-divider>脚注、注、示例</a-divider>
|
||||
<add-footnote/>
|
||||
<SaicExample/>
|
||||
<!-- <InsertNotes />-->
|
||||
<!-- <a-divider>示例</a-divider>-->
|
||||
<!-- <SaicExample/>-->
|
||||
<!-- <a-divider>上传</a-divider>-->
|
||||
<!-- <SaicFile />-->
|
||||
<!-- <a-divider>修订信息</a-divider>-->
|
||||
<!-- <RevisInformation />-->
|
||||
<a-divider>附录</a-divider>
|
||||
<Appendix/>
|
||||
<!-- <insert-table-row />-->
|
||||
<!-- <hello-world />-->
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
import {SEPARATOR_TYPE} from '@/pages/page1/common/utils'
|
||||
import InsertTableRow from './components/InsertTableRow.vue'
|
||||
import InsertGuideText from './components/InsertGuideText.vue'
|
||||
import FirstLevelListing from './components/FirstLevelListing.vue'
|
||||
import AddFootnote from './components/AddFootnote.vue'
|
||||
import InsertImage from './components/InsertImage.vue'
|
||||
import HelloWorld from './components/HelloWorld.vue'
|
||||
import Init from './saicComponents/Init'
|
||||
import contentOne from "./saicComponents/Content";
|
||||
import SaicFunc from "./saicComponents/SaicFunc";
|
||||
import SaicTable from "./saicComponents/SaicTable";
|
||||
import SaicImg from "./components/InsertImage";
|
||||
import InsertNotes from "./saicComponents/InsertNotes";
|
||||
import SaicExample from "./saicComponents/SaicExample";
|
||||
import SaicFile from "./saicComponents/SaicFile";
|
||||
import RevisInformation from "./saicComponents/RevisInformation";
|
||||
import Appendix from "./saicComponents/Appendix";
|
||||
import chapterData from "./saicComponents/chapterData";
|
||||
import Chapter from "./saicComponents/Chapter";
|
||||
import _axios from "@/plugins/axios2";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
InsertTableRow,
|
||||
InsertGuideText,
|
||||
FirstLevelListing,
|
||||
AddFootnote,
|
||||
InsertImage,
|
||||
HelloWorld,
|
||||
Init,
|
||||
contentOne,
|
||||
SaicFunc,
|
||||
SaicTable,
|
||||
SaicImg,
|
||||
InsertNotes,
|
||||
SaicExample,
|
||||
SaicFile,
|
||||
RevisInformation,
|
||||
Appendix,
|
||||
chapterData,
|
||||
Chapter
|
||||
},
|
||||
data() {
|
||||
let Ps
|
||||
|
||||
function updateScroll() {
|
||||
Ps.update()
|
||||
}
|
||||
|
||||
return {
|
||||
// SEPARATOR_TYPE,
|
||||
data: [
|
||||
{
|
||||
title: '术语和定义',
|
||||
list: [
|
||||
'下列术语和定义适用于本文件。',
|
||||
'......界定的术语和定义适用于本文件。',
|
||||
'......界定的以及下列术语和定义适用于本文件。',
|
||||
'本文件没有需要界定的术语和定义。'
|
||||
],
|
||||
separatorText: SEPARATOR_TYPE.STRIKETHROUGH
|
||||
},
|
||||
{
|
||||
title: '符号、代号和缩略语',
|
||||
list: [
|
||||
'下列代号适用于本文件。',
|
||||
'下列符号适用于本文件。',
|
||||
'下列缩略语适用于本文件。',
|
||||
'下列代号和缩略语适用于本文件。',
|
||||
],
|
||||
separatorText: SEPARATOR_TYPE.COLON
|
||||
},
|
||||
],
|
||||
isDisplay: false,
|
||||
num: 0,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
window.Asc.plugin.init = function () {
|
||||
Vue.prototype.ctx = this
|
||||
// console.log(this)
|
||||
const container = document.getElementById('app')
|
||||
// eslint-disable-next-line no-undef
|
||||
Ps = new PerfectScrollbar(`#${container.id}`, {})
|
||||
this.callCommand(() => {
|
||||
try {
|
||||
|
||||
var oDocument = Api.GetDocument();
|
||||
|
||||
const oHeading1Style6 = oDocument.CreateStyle("Normal");
|
||||
const oTextPr7 = oHeading1Style6.GetTextPr();
|
||||
oTextPr7.SetFontFamily("宋体");
|
||||
oTextPr7.SetColor(0, 0, 0);
|
||||
oTextPr7.SetFontSize(21)
|
||||
const oTextPr9 = oHeading1Style6.GetParaPr();
|
||||
oTextPr9.SetSpacingAfter(10)
|
||||
|
||||
// var oHeading1Style = oDocument.CreateStyle("Heading 1");
|
||||
// const oTextPr = oHeading1Style.GetTextPr();
|
||||
// oTextPr.SetFontFamily("黑体");
|
||||
// oTextPr.SetColor(0, 0, 0);
|
||||
//
|
||||
//
|
||||
// var oHeading1Style1 = oDocument.CreateStyle("Heading 2");
|
||||
// const oTextPr1 = oHeading1Style1.GetTextPr();
|
||||
// oTextPr1.SetFontFamily("黑体");
|
||||
// oTextPr1.SetColor(0, 0, 0);
|
||||
//
|
||||
//
|
||||
// var oHeading1Style2 = oDocument.CreateStyle("Heading 3");
|
||||
// const oTextPr2 = oHeading1Style2.GetTextPr();
|
||||
// oTextPr2.SetFontFamily("黑体");
|
||||
// oTextPr2.SetColor(0, 0, 0);
|
||||
//
|
||||
//
|
||||
// var oHeading1Style3 = oDocument.CreateStyle("Heading 4");
|
||||
// const oTextPr3 = oHeading1Style3.GetTextPr();
|
||||
// oTextPr3.SetFontFamily("黑体");
|
||||
// oTextPr3.SetColor(0, 0, 0);
|
||||
//
|
||||
//
|
||||
// var oHeading1Style4 = oDocument.CreateStyle("Heading 5");
|
||||
// const oTextPr4 = oHeading1Style4.GetTextPr();
|
||||
// oTextPr4.SetFontFamily("黑体");
|
||||
// oTextPr4.SetColor(0, 0, 0);
|
||||
//
|
||||
// var oHeading1Style5 = oDocument.CreateStyle("Heading 6");
|
||||
// const oTextPr5 = oHeading1Style5.GetTextPr();
|
||||
// oTextPr5.SetFontFamily("黑体");
|
||||
// oTextPr5.SetColor(0, 0, 0);
|
||||
|
||||
|
||||
var oNormalStyle = oDocument.GetDefaultStyle("numbering");
|
||||
const oTextPr6 = oNormalStyle.GetTextPr();
|
||||
oTextPr6.SetFontFamily("黑体");
|
||||
|
||||
const oParagraph = Api.CreateParagraph();
|
||||
oParagraph.SetStyle(oNormalStyle);
|
||||
Api.HeadersAndFooters_DifferentOddandEvenPage(true)
|
||||
// Api.HeadersAndFooters_DifferentFirstPage(true)
|
||||
} catch (e) {
|
||||
console.log('init err:', e)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
window.addEventListener('message', (e) => {
|
||||
// console.log(e)
|
||||
}, false)
|
||||
|
||||
window.Asc.plugin.button = function (id) {
|
||||
// console.log('wx2', id)
|
||||
if (id === -1) this.executeCommand('close', '')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
param2Obj(url) {
|
||||
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
|
||||
if (!search) {
|
||||
return {}
|
||||
}
|
||||
const obj = {}
|
||||
const searchArr = search.split('&')
|
||||
searchArr.forEach(v => {
|
||||
const index = v.indexOf('=')
|
||||
if (index !== -1) {
|
||||
const name = v.substring(0, index)
|
||||
let val = v.substring(index + 1, v.length)
|
||||
if (val == 'undefined' || !val) {
|
||||
val = ''
|
||||
}
|
||||
obj[name] = val
|
||||
}
|
||||
})
|
||||
return obj
|
||||
},
|
||||
save() {
|
||||
|
||||
let documentCallbackUrl = window.Asc.plugin.info.documentCallbackUrl
|
||||
let query = this.param2Obj(documentCallbackUrl)
|
||||
let formData = (data) => {
|
||||
let _formData = new FormData()
|
||||
for (let i in data) {
|
||||
_formData.append(i, data[i])
|
||||
}
|
||||
return _formData
|
||||
}
|
||||
this.num = 10
|
||||
this.isDisplay = true
|
||||
_axios({
|
||||
url: 'api/lawss/activiti/recieveFile',
|
||||
method: 'post',
|
||||
data: formData(query)
|
||||
}).then(res => {
|
||||
}).catch(e => {
|
||||
})
|
||||
this.setIntervalOne = setInterval(() => {
|
||||
this.num--
|
||||
if (this.num == 0) {
|
||||
clearInterval(this.setIntervalOne)
|
||||
this.isDisplay = false
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
#app {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-align: left;
|
||||
color: #2c3e50;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#app {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
* {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
color: rgba(0, 0, 0, .85);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC,
|
||||
Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif,
|
||||
Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
|
||||
font-variant: tabular-nums;
|
||||
}
|
||||
</style>
|
||||
<style scoped>
|
||||
.ant-drawer-index {
|
||||
width: 210px;
|
||||
height: 40px;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
background: #000;
|
||||
color: #fff;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
border-radius: 6px;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.ant-drawer-text {
|
||||
width: 10px;
|
||||
display: inline-block;
|
||||
color: #ffff00;
|
||||
}
|
||||
.app-header{
|
||||
width: 100%;
|
||||
height: 46px;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
padding-left: 10px;
|
||||
line-height: 46px;
|
||||
text-align: left;
|
||||
background: #f1f1f1;
|
||||
z-index: 100;
|
||||
border-bottom: 1px #e8e8e8 solid;
|
||||
}
|
||||
.app-header-button{
|
||||
background: #66b1ff;
|
||||
border-color: #66b1ff;
|
||||
color: #FFF;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,25 @@
|
||||
// px转mm
|
||||
|
||||
const conversion_getDPI = () => {
|
||||
var arrDPI = new Array;
|
||||
if (window.screen.deviceXDPI) {
|
||||
arrDPI[0] = window.screen.deviceXDPI
|
||||
arrDPI[1] = window.screen.deviceYDPI
|
||||
} else {
|
||||
var tmpNode = document.createElement('DIV');
|
||||
tmpNode.style.cssText = "width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden"
|
||||
document.body.appendChild(tmpNode)
|
||||
arrDPI[0] = parseInt(tmpNode.offsetWidth)
|
||||
arrDPI[1] = parseInt(tmpNode.offsetHeight)
|
||||
tmpNode.parentNode.removeChild(tmpNode)
|
||||
}
|
||||
return arrDPI;
|
||||
}
|
||||
|
||||
const pxConversionMm = (val) => {
|
||||
var inch = val / conversion_getDPI()[0]
|
||||
var c_value = inch * 25.4;
|
||||
return c_value
|
||||
}
|
||||
|
||||
export default pxConversionMm
|
||||
@@ -0,0 +1,8 @@
|
||||
export const SEPARATOR_TYPE = {
|
||||
STRIKETHROUGH: '——',
|
||||
COLON: ':'
|
||||
}
|
||||
|
||||
export default {
|
||||
SEPARATOR_TYPE
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-button-group style="margin-bottom: 10px;display: block">
|
||||
<a-button @click="handleClick">添加脚注</a-button>
|
||||
</a-button-group>
|
||||
<a-button-group style="margin-bottom: 10px;">
|
||||
<a-button @click="handleInsertNoteOne('CN')">注</a-button>
|
||||
<a-button @click="handleInsertMultNotTwo('CN')">注X</a-button>
|
||||
<a-button @click="handleInsertMultNoteThe('CN')">首注</a-button>
|
||||
</a-button-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
/**
|
||||
* 需求是括号结尾,参考word并没有脚注加括号的情况,需确认
|
||||
* 时间过长以后研究
|
||||
*/
|
||||
handleClick() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
// Api.asc_AddFootnote()
|
||||
const oDocument = Api.GetDocument()
|
||||
oDocument.AddFootnote();
|
||||
var aFootnotesFirstParagraphs = oDocument.GetFootnotesFirstParagraphs();
|
||||
for (let i = 0; i < aFootnotesFirstParagraphs.length; i++) {
|
||||
aFootnotesFirstParagraphs[i].SetVertAlign('baseline')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClick2() {
|
||||
this.ctx.executeMethod('InputText', ['wx', 'wx2'])
|
||||
},
|
||||
|
||||
handleInsertNoteOne() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimalZero', "注: ", "right")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
var textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetIndLeft(860);
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertMultNotTwo() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
for (let index = 0; index < allElement; index++) {
|
||||
const element = oDocument.GetElement(index)
|
||||
if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingBefore()
|
||||
if (text == 50) {
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
const sFormatString = '注%1:';
|
||||
numbering.SetCustomType("decimal", sFormatString, "right");
|
||||
numbering.SetSuff("space");
|
||||
}
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
// oParagraph.SetSpacingLine(400, "auto");
|
||||
var oParaPr = numbering.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
var textPr = numbering.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetJc("left");
|
||||
oParagraph.SetIndLeft(860);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertMultNoteThe() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimal', "注%1:", "right")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
var textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oParagraph.SetIndLeft(860);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,337 @@
|
||||
<template>
|
||||
<div class="button-group__wrap">
|
||||
<a-button-group style="margin-bottom: 10px">
|
||||
<a-button @click="paragraphClick">段</a-button>
|
||||
<a-button @click="handleClickOne()">项一</a-button>
|
||||
<a-button @click="handleClickTwo1()">项二</a-button>
|
||||
<a-button @click="handleClick('space')">字母列项</a-button>
|
||||
<a-button @click="handleClickTwo">数字列项</a-button>
|
||||
<!-- <a-button @click="handleClick('tab')">插入一级列项('tab')</a-button>-->
|
||||
<!-- <a-button @click="handleClick('none')">插入一级列项('none')</a-button>-->
|
||||
</a-button-group>
|
||||
<!-- <a-button-group>-->
|
||||
<!-- <a-button @click="handleClickEn">插入一级列项(英)</a-button>-->
|
||||
<!-- </a-button-group>-->
|
||||
<!-- <a-button-group>-->
|
||||
<!-- <a-button @click="handleTestChapter">添加章节测试</a-button>-->
|
||||
<!-- </a-button-group>-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
handleClickOne() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimalZero', "——", "right")
|
||||
oNumLvl.SetSuff("tab");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
oParaPr.SetSpacingLine(280, "auto");
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oParagraph.SetIndLeft(840);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(10.5)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
paragraphClick(){
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
// let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
// const oNumLvl = oNumbering.GetLevel(0)
|
||||
// oNumLvl.SetCustomType('decimalZero', " ", "left")
|
||||
// oNumLvl.SetSuff("space");
|
||||
// var oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
// oParaPr.SetIndFirstLine(-500);
|
||||
// // oParaPr.SetIndLeft(366)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
// oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oParagraph.SetIndFirstLine(420);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(10.5)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClickTwo1() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('bullet')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetSuff('tab')
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetIndRight(80)
|
||||
// oParaPr.SetIndFirstLine(120);
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetIndLeft(1270);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(10.5)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClick(suffType) {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
// const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
// let currentNumbering = null
|
||||
// for (let index = 0; index < allElement; index++) {
|
||||
// const element = oDocument.GetElement(index)
|
||||
// if ("paragraph" === element.GetClassType()) {
|
||||
// const getNumbering = element.GetNumbering()
|
||||
// const text = element.GetSpacingBefore()
|
||||
// if (getNumbering !== null) {
|
||||
// if (text == 1) {
|
||||
// currentNumbering = getNumbering
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!numbering) {
|
||||
// if (currentNumbering) {
|
||||
// numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
// } else {
|
||||
// let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
// numbering = oNumbering.GetLevel(0)
|
||||
// numbering.SetTemplateType('a)')
|
||||
// }
|
||||
// }
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
numbering.SetTemplateType('a)')
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
// oParagraph.SetSpacingLine(400, "auto");
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
var oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetSpacingLine(290, "auto");
|
||||
oParaPr.SetJc("tab");
|
||||
// oParaPr.SetIndFirstLine(0);
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(1)
|
||||
oParagraph.SetIndLeft(840);
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(10.5)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClickTwo() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
// for (let index = 0; index < allElement; index++) {
|
||||
// const element = oDocument.GetElement(index)
|
||||
// if ("paragraph" === element.GetClassType()) {
|
||||
// const getNumbering = element.GetNumbering()
|
||||
// const text = element.GetSpacingBefore()
|
||||
// if (getNumbering !== null) {
|
||||
// if (text == 2) {
|
||||
// currentNumbering = getNumbering;
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
// numbering.SetTemplateType('1)')
|
||||
numbering.SetCustomType('decimal', "%1)", "left")
|
||||
// numbering.SetSuff('tab')
|
||||
}
|
||||
}
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
const oParaPr = numbering.GetParaPr();
|
||||
// oParaPr.SetIndLeft(1310)
|
||||
oParaPr.SetJc("left");
|
||||
oParaPr.SetSpacingLine(290, "auto");
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(2)
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetIndLeft(1270);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(10.5)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClickEn() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetTemplateType('a)')
|
||||
oNumLvl.SetSuff('space')
|
||||
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.AddText('Custom numbered')
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('Arial')
|
||||
oParagraph.SetFontSize(21)
|
||||
oDocument.InsertContent([oParagraph])
|
||||
oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClick2() {
|
||||
this.ctx.executeMethod('InputText', ['wx', 'wx2'])
|
||||
},
|
||||
|
||||
handleTestChapter() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allParagraph = oDocument.Document.GetAllNumberedParagraphs()
|
||||
console.log(allParagraph)
|
||||
let oNumbering
|
||||
if (allParagraph.length > 0) {
|
||||
// oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const currentParagraph = allParagraph[0]
|
||||
console.log(currentParagraph)
|
||||
oNumbering = currentParagraph.GetCurrentParagraph()
|
||||
console.log(oNumbering)
|
||||
} else {
|
||||
oNumbering = oDocument.CreateNumbering('numbered')
|
||||
console.log('创建的:', oNumbering)
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
|
||||
oNumLvl = oNumbering.GetLevel(oNumbering.GetLevel(0).GetLevelIndex());
|
||||
oNumLvl.SetRestart(false)
|
||||
oParagraph.AddText('Custom numbered')
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(10.5)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<div id="helloWorld">
|
||||
<a-button-group>
|
||||
<a-button @click="handleDeleteBlockLVlSdt">cxx-删除全部BlockLVlSdt</a-button>
|
||||
<a-button @click="handleDuanluo">cxx-插入段落编号</a-button>
|
||||
</a-button-group>
|
||||
<a-button-group>
|
||||
<a-button @click="handleHelloWorld">cxx-插入文本</a-button>
|
||||
<a-button @click="handleDuanluo">cxx-插入段落编号</a-button>
|
||||
</a-button-group>
|
||||
<a-button-group>
|
||||
<a-button @click="handleReadOnlyBlock">cxx-插入只读文本</a-button>
|
||||
<a-button @click="handleSetting">cxx-设置文字样式</a-button>
|
||||
</a-button-group>
|
||||
<a-button-group>
|
||||
<a-button @click="handleLiexiang">cxx-插入列项</a-button>
|
||||
<a-button @click="handleTest1">cxx-固定格式区域</a-button>
|
||||
</a-button-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
name: 'HelloWorld',
|
||||
methods: {
|
||||
handleDeleteBlockLVlSdt() {
|
||||
this.ctx.callCommand(() => {
|
||||
oDocument = Api.GetDocument();
|
||||
oParagraph = oDocument.GetElement(0);
|
||||
oContentControls = oDocument.GetAllContentControls();
|
||||
console.log(oContentControls)
|
||||
for (let i = 0; i < oContentControls.length; i++) {
|
||||
try {
|
||||
oContentControls[0].Delete();
|
||||
} catch(e) {
|
||||
console.log('del err:', e)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleHelloWorld() {
|
||||
const text = 'Hello world!'
|
||||
window.Asc.scope.text = text // export variable to plugin scope
|
||||
this.ctx.callCommand(() => {
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.AddText(Asc.scope.text)
|
||||
oDocument.InsertContent([oParagraph])
|
||||
}, false)
|
||||
},
|
||||
|
||||
handleDuanluo() {
|
||||
this.ctx.callCommand(() => {
|
||||
const oDocument = Api.GetDocument();
|
||||
const oNumbering = oDocument.CreateNumbering("test");
|
||||
for (nLvl = 0 ; nLvl < 5 ; ++nLvl) {
|
||||
oNumLvl = oNumbering.GetLevel(nLvl);
|
||||
oParagraph = Api.CreateParagraph();
|
||||
oParagraph.AddText( "这是带项目符号的示例" + (nLvl + 1 ));
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oDocument.Push(oParagraph);
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
handleReadOnlyBlock() {
|
||||
window.Asc.scope.text = `当前时间是: ${moment(new Date()).format('YYYY-MM-DD HH:mm:ss')}`
|
||||
this.ctx.callCommand(() => {
|
||||
const oDocument = Api.GetDocument();
|
||||
const oBlockLvlSdt = Api.CreateBlockLvlSdt();
|
||||
oBlockLvlSdt.GetContent().GetElement(0).AddText(Asc.scope.text);
|
||||
oBlockLvlSdt.SetLock( "sdtLocked" );
|
||||
oDocument.AddElement( 0 , oBlockLvlSdt);
|
||||
})
|
||||
},
|
||||
|
||||
handleSetting() {
|
||||
this.ctx.callCommand(() => {
|
||||
const oDocument = Api.GetDocument();
|
||||
const oBlockLvlSdt = Api.CreateBlockLvlSdt();
|
||||
oBlockLvlSdt.GetContent().GetElement( 0 ).AddText( "这是一个块文本内容控件,字体大小设置为30,字体粗细设置为粗体。" );
|
||||
oDocument.AddElement( 0 , oBlockLvlSdt);
|
||||
oTextPr = oDocument.GetDefaultTextPr();
|
||||
oTextPr.SetFontSize( 30 );
|
||||
oTextPr.SetBold( true );
|
||||
// oTextPr.SetCaps(true);
|
||||
oBlockLvlSdt.SetTextPr(oTextPr);
|
||||
})
|
||||
},
|
||||
|
||||
handleLiexiang() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
oDocument = Api.GetDocument();
|
||||
oParagraph = Api.CreateParagraph()
|
||||
oParagraph.AddText("We create a 3x3 table and set the bold font weight to the text in cell #1:");
|
||||
oDocument.AddElement(oParagraph)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleTest1() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
oDocument = Api.GetDocument();
|
||||
oBlockLvlSdt = Api.CreateBlockLvlSdt();
|
||||
oBlockLvlSdt.GetContent().GetElement(0)
|
||||
.AddText("This is a block text content control with the content lock set to it.")
|
||||
.SetBold(false)
|
||||
.SetColor(0, 0, 255,false);
|
||||
oBlockLvlSdt.SetLock("sdtLocked");
|
||||
oDocument.AddElement(0, oBlockLvlSdt);
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
#helloWorld {
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<!-- style="margin-top:43px"-->
|
||||
<div>
|
||||
<h3 :style="{ margin: '16px 0' }" v-show="!!title">
|
||||
{{ title }}
|
||||
</h3>
|
||||
<a-list size="small" bordered :data-source="list">
|
||||
<a-list-item slot="renderItem" slot-scope="item, index">
|
||||
<span style="cursor: pointer;" @click="handleClick(item, index)">
|
||||
{{ item }}
|
||||
</span>
|
||||
</a-list-item>
|
||||
</a-list>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
import { SEPARATOR_TYPE } from '@/pages/page1/common/utils'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
// ctx: {
|
||||
// type: Object,
|
||||
// required: true
|
||||
// }
|
||||
title: {
|
||||
type: String,
|
||||
required: false
|
||||
},
|
||||
list: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
separatorText: {
|
||||
type: [Number, String],
|
||||
default: ' '
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
data: [
|
||||
'下列术语和定义适用于本标准',
|
||||
'××××××(标准编号)中确立的以及下列术语和定义适用于本标准'
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick(item, index) {
|
||||
window.Asc.scope.text = item // export variable to plugin scope
|
||||
window.Asc.scope.separatorText = this.separatorText // export variable to plugin scope
|
||||
// window.Asc.plugin.init = function () {
|
||||
// eslint-disable-next-line func-names
|
||||
// eslint-disable-next-line prefer-arrow-callback
|
||||
this.ctx.callCommand(function () {
|
||||
try {
|
||||
// eslint-disable-next-line no-undef
|
||||
const oDocument = Api.GetDocument()
|
||||
// eslint-disable-next-line no-undef
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
oParagraph.AddText(Asc.scope.text) // or oParagraph.AddText(scope.text);
|
||||
// const oRun = oParagraph.AddLineBreak()
|
||||
// oRun.AddText(`xxxxxx${Asc.scope.separatorText}xxxxxx`)
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,651 @@
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<a-button-group>
|
||||
<!-- <a-button @click="handleClick">插入图</a-button>-->
|
||||
<!-- <a-button @click="handleCaptionClick">插入图题注</a-button>-->
|
||||
<a-button @click="openImageName">图题</a-button>
|
||||
<a-button @click="openImageDialog">插入图片</a-button>
|
||||
<a-button @click="openImageNoteFou">图片脚注</a-button>
|
||||
</a-button-group>
|
||||
<!-- <a-button-group>-->
|
||||
<!-- <a-button @click="handleTest">测试</a-button>-->
|
||||
<!-- </a-button-group>-->
|
||||
|
||||
<a-modal v-model="visible" title="插入图片" @ok="handleOk">
|
||||
<a-form-model
|
||||
id="components-form-demo-validate-other"
|
||||
:model="form"
|
||||
v-bind="formItemLayout"
|
||||
@submit="handleSubmit"
|
||||
>
|
||||
<!-- <a-form-item label="标题">-->
|
||||
<!-- <a-input-->
|
||||
<!-- v-model="form.title"-->
|
||||
<!-- placeholder="请输入标题"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="图片">
|
||||
<a-upload
|
||||
ref="upload"
|
||||
name="file"
|
||||
list-type="picture-card"
|
||||
class="avatar-uploader"
|
||||
:show-upload-list="false"
|
||||
action="api/att/attFile/upload"
|
||||
:before-upload="beforeUpload"
|
||||
:customRequest="uploadFile"
|
||||
@change="handleChange"
|
||||
v-decorator="[
|
||||
'file',
|
||||
{
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请上传图片',
|
||||
},
|
||||
],
|
||||
},
|
||||
]"
|
||||
>
|
||||
<img ref="myImg" v-if="imageUrl" :src="imageUrl" style="width: 300px; height: 300px;"/>
|
||||
<div v-else>
|
||||
<a-icon :type="loading ? 'loading' : 'plus'"/>
|
||||
<div class="ant-upload-text">
|
||||
Upload
|
||||
</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="图片大小">
|
||||
<a-radio-group :options="plainOptions" v-model="form.size"/>
|
||||
</a-form-item>
|
||||
</a-form-model>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _axios from '@/plugins/axios2'
|
||||
import pxConversionMm from '../common/unitConversion'
|
||||
|
||||
function getBase64(img, callback) {
|
||||
console.log(img);
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener('load', () => callback(reader.result));
|
||||
reader.readAsDataURL(img);
|
||||
}
|
||||
|
||||
const plainOptions = ['原图', '小', '中', '大'];
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
formItemLayout: {
|
||||
labelCol: {span: 6},
|
||||
wrapperCol: {span: 14},
|
||||
},
|
||||
loading: false,
|
||||
imageUrl: '',
|
||||
plainOptions,
|
||||
form: {
|
||||
title: '',
|
||||
size: '中'
|
||||
},
|
||||
numData: {
|
||||
1: 'A',
|
||||
2: 'B',
|
||||
3: 'C',
|
||||
4: 'D',
|
||||
5: 'E',
|
||||
6: 'F',
|
||||
7: 'G',
|
||||
8: 'H',
|
||||
9: 'I',
|
||||
10: 'J',
|
||||
11: 'K',
|
||||
12: 'L',
|
||||
13: 'M',
|
||||
14: 'N',
|
||||
15: 'O',
|
||||
16: 'P',
|
||||
17: 'Q',
|
||||
18: 'R',
|
||||
19: 'S',
|
||||
20: 'T',
|
||||
21: 'U',
|
||||
22: 'V',
|
||||
23: 'W',
|
||||
24: 'X',
|
||||
25: 'Y',
|
||||
26: 'Z'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
// console.log(window.Asc.plugin.info)
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
this.ctx.callCommand(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
// console.log(document.getElementById(`iframe_${Asc.scope.guid}`))
|
||||
try {
|
||||
// setTimeout(() => {
|
||||
// Api.asc_addImage()
|
||||
console.log(Api)
|
||||
Api.AddImage()
|
||||
// const cb = (type, id) => {
|
||||
// eslint-disable-next-line max-len
|
||||
// // this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
|
||||
// // c_oAscAsyncActionType.BlockInteraction: 1
|
||||
// // c_oAscAsyncAction.LoadImage: 8
|
||||
// if (type === 1 && id === 8) {
|
||||
// // 图片加载完成
|
||||
// console.log('图片加载完成')
|
||||
// const props = new window.Asc.CAscCaptionProperties()
|
||||
// props.put_Before(false)
|
||||
// props.put_Label('图')
|
||||
// props.put_ExcludeLabel(false)
|
||||
// props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
// props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// // props.put_HeadingLvl(this.cmbChapter.getValue()) // 章节的风格,不包括章节号时不用填
|
||||
// // props.put_Separator(this.cmbSeparator.getValue()) // 分隔符,不包括章节号时不用填
|
||||
// props.updateName()
|
||||
// // eslint-disable-next-line no-undef
|
||||
// DE.controllers.Viewport.api.asc_AddObjectCaption(props)
|
||||
// Api.asc_unregisterCallback('asc_onEndAction', cb)
|
||||
// }
|
||||
// // console.log(rest)
|
||||
// }
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(false)
|
||||
props.put_Label('图')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// Api.asc_registerCallback('asc_onEndAction', cb)
|
||||
// }, 1)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
// window.postMessage()
|
||||
// document.getElementById(`iframe_${Asc.scope.guid}`).
|
||||
// contentWindow.postMessage({ m: 'Wx Success' }, '*')
|
||||
}, false)
|
||||
},
|
||||
handleCaptionClick() {
|
||||
// console.log(window.Asc.plugin.info)
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
this.ctx.callCommand(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
// console.log(document.getElementById(`iframe_${Asc.scope.guid}`))
|
||||
try {
|
||||
// setTimeout(() => {
|
||||
// Api.asc_addImage()
|
||||
Api.AddImage()
|
||||
const cb = (type, id) => {
|
||||
// eslint-disable-next-line max-len
|
||||
// this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
|
||||
// c_oAscAsyncActionType.BlockInteraction: 1
|
||||
// c_oAscAsyncAction.LoadImage: 8
|
||||
if (type === 1 && id === 8) {
|
||||
// 图片加载完成
|
||||
console.log('图片加载完成')
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(false)
|
||||
props.put_Label('图')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// props.put_HeadingLvl(this.cmbChapter.getValue()) // 章节的风格,不包括章节号时不用填
|
||||
// props.put_Separator(this.cmbSeparator.getValue()) // 分隔符,不包括章节号时不用填
|
||||
props.updateName()
|
||||
// eslint-disable-next-line no-undef
|
||||
DE.controllers.Viewport.api.asc_AddObjectCaption(props)
|
||||
Api.asc_unregisterCallback('asc_onEndAction', cb)
|
||||
}
|
||||
// console.log(rest)
|
||||
}
|
||||
Api.asc_registerCallback('asc_onEndAction', cb)
|
||||
// }, 1)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
// window.postMessage()
|
||||
// document.getElementById(`iframe_${Asc.scope.guid}`).
|
||||
// contentWindow.postMessage({ m: 'Wx Success' }, '*')
|
||||
}, false)
|
||||
},
|
||||
handleCaptionClick2() {
|
||||
// _api.init(oWordControl);
|
||||
// this.ctx.callCommand(function () {
|
||||
// try {
|
||||
// // eslint-disable-next-line new-cap
|
||||
// // const _api = new window.Asc.asc_docs_api()
|
||||
// console.log(this.DE.controllers.Viewport.api.asc_AddObjectCaption)
|
||||
// } catch (error) {
|
||||
// console.error(error)
|
||||
// }
|
||||
// })
|
||||
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(false)
|
||||
props.put_Label('图')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// props.put_HeadingLvl(this.cmbChapter.getValue()) // 章节的风格,不包括章节号时不用填
|
||||
// props.put_Separator(this.cmbSeparator.getValue()) // 分隔符,不包括章节号时不用填
|
||||
props.updateName()
|
||||
|
||||
// console.log(props)
|
||||
// console.log(window)
|
||||
// const oDocument = Api.GetDocument()
|
||||
// const oParagraph = oDocument.GetElement(0)
|
||||
// const oImage = Api.CreateImage('https://www.onlyoffice.com/blog/wp-content/uploads/2021/05/Blog_docs_63.jpg', 60 * 36000, 35 * 36000)
|
||||
// oParagraph.AddDrawing(oImage)
|
||||
// console.log(oImage)
|
||||
// eslint-disable-next-line no-undef
|
||||
DE.controllers.Viewport.api.asc_AddObjectCaption(props)
|
||||
// oDocument.Push(oImage)
|
||||
// window.Asc.asc_docs_api.asc_AddObjectCaption(props)
|
||||
// console.log(window.Asc.asc_docs_api.prototype.asc_AddObjectCaption(props))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
openImageDialog() {
|
||||
this.visible = true
|
||||
},
|
||||
openImageNoteFou() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let GetPrevious = oParagraph.GetPrevious()
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
const getNumbering = GetPrevious.GetNumbering()
|
||||
const text = GetPrevious.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 32) {
|
||||
currentNumbering = getNumbering
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
}
|
||||
const sFormatString = "%1";
|
||||
oNumLvl.SetCustomType("lowerLetter", sFormatString, "left");
|
||||
oNumLvl.SetSuff("space");
|
||||
const textPr = oNumLvl.GetTextPr()
|
||||
textPr.SetFontSize(18);
|
||||
textPr.SetFontFamily('黑体')
|
||||
textPr.SetSmallCaps(true);
|
||||
textPr.SetVertAlign("superscript");
|
||||
const paraPr = oNumLvl.GetParaPr()
|
||||
paraPr.SetSpacingBefore(0);
|
||||
paraPr.SetJc("left");
|
||||
paraPr.SetIndFirstLine(-150);
|
||||
const oParagraph1 = Api.CreateParagraph()
|
||||
oParagraph1.SetIndLeft(574);
|
||||
oParagraph1.SetNumbering(oNumLvl)
|
||||
oParagraph1.SetSpacingAfter(32)
|
||||
oParagraph1.SetFontSize(18)
|
||||
oDocument.InsertContent([oParagraph1])
|
||||
let GetNext = oParagraph1.GetNext()
|
||||
GetNext.Delete()
|
||||
oParagraph.Delete();
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
openImageName(){
|
||||
Asc.scope.numData = this.numData
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
let table
|
||||
let SpacingBefore
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 34) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
if (table){
|
||||
let number = table.GetCell(0, 0).GetContent().GetElement(1);
|
||||
SpacingBefore = number.GetSpacingBefore();
|
||||
}
|
||||
if (SpacingBefore){
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 34) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = "图"+Asc.scope.numData[SpacingBefore]+".%1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 34) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = "图 %1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
}
|
||||
}
|
||||
const oNewDocumentStyle = oDocument.GetStyle("List Paragraph");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
const textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(21)
|
||||
// const CNParagraph = Api.CreateParagraph();
|
||||
oParagraph.SetJc("center");
|
||||
// oParagraph.AddText("图片");
|
||||
oParagraph.SetFontSize(21);
|
||||
oParagraph.SetStyle(oNewDocumentStyle);
|
||||
oParagraph.SetFontFamily("黑体");
|
||||
oParagraph.SetSpacingAfter(34,false)
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oParagraph.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleOk() {
|
||||
this.visible = false
|
||||
window.Asc.scope.imageUrl = this.imageUrl
|
||||
window.Asc.scope.title = this.form.title
|
||||
window.Asc.scope.imgSize = this.form.size
|
||||
const width = pxConversionMm(this.imgOrigin.width)
|
||||
const height = pxConversionMm(this.imgOrigin.height)
|
||||
window.Asc.scope.imgOrigin = {
|
||||
width,
|
||||
height
|
||||
}
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const imgOParagraph = Api.CreateParagraph()
|
||||
let imgSize = {
|
||||
width: 0,
|
||||
height: 0
|
||||
}
|
||||
switch (Asc.scope.imgSize) {
|
||||
case '原图':
|
||||
imgSize.width = Asc.scope.imgOrigin.width
|
||||
imgSize.height = Asc.scope.imgOrigin.height
|
||||
break
|
||||
case '小':
|
||||
imgSize.width = 165 / 3
|
||||
imgSize.height = 89.3 / 3
|
||||
break
|
||||
case '中':
|
||||
imgSize.width = 165 / 2
|
||||
imgSize.height = 89.3 / 2
|
||||
break
|
||||
case '大':
|
||||
imgSize.width = 165
|
||||
imgSize.height = 89.3
|
||||
break
|
||||
}
|
||||
const oDrawing = Api.CreateImage(Asc.scope.imageUrl, imgSize.width * 36000, imgSize.height * 36000);
|
||||
imgOParagraph.AddDrawing(oDrawing);
|
||||
// const allElement = oDocument.GetElementsCount()
|
||||
// let numbering = null
|
||||
// let currentNumbering = null
|
||||
// for (let index = 0; index < allElement; index++) {
|
||||
// const element = oDocument.GetElement(index)
|
||||
// if ("paragraph" === element.GetClassType()) {
|
||||
// const text = element.GetSpacingBefore()
|
||||
// const getNumbering = element.GetNumbering()
|
||||
// if (getNumbering !== null) {
|
||||
// if (text == 10) {
|
||||
// currentNumbering = getNumbering;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!numbering) {
|
||||
// if (currentNumbering) {
|
||||
// numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
// } else {
|
||||
// let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
// numbering = oNumbering.GetLevel(0)
|
||||
// const sFormatString = '图 %1';
|
||||
// numbering.SetCustomType("decimal", sFormatString, "right");
|
||||
// }
|
||||
// }
|
||||
// const imgText = Api.CreateParagraph();
|
||||
// var textPr = numbering.GetTextPr();
|
||||
// textPr.SetFontFamily("黑体");
|
||||
// textPr.SetFontSize(21)
|
||||
// imgText.SetNumbering(numbering);
|
||||
// imgText.AddText(`${Asc.scope.title}`);
|
||||
// imgText.SetFontSize(21)
|
||||
// imgText.SetFontFamily("黑体");
|
||||
// imgText.SetBold(false)
|
||||
// imgText.SetContextualSpacing(true);
|
||||
// imgText.SetJc("center");
|
||||
// imgText.SetSpacingBefore(10)
|
||||
// imgText.SetSmallCaps(true);
|
||||
imgOParagraph.SetJc("center");
|
||||
imgOParagraph.SetSmallCaps(true);
|
||||
const breakLine = Api.CreateParagraph()
|
||||
breakLine.SetJc('left')
|
||||
oDocument.InsertContent([imgOParagraph]);
|
||||
|
||||
// oDocument.InsertContent([imgText]);
|
||||
// 创建表格 包裹文字和列项
|
||||
// oDocument.InsertContent([breakLine]);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.form = {}
|
||||
this.imageUrl = ''
|
||||
}, 200)
|
||||
|
||||
},
|
||||
|
||||
handleChange(info) {
|
||||
if (info.file.status === 'uploading') {
|
||||
this.loading = true;
|
||||
return;
|
||||
}
|
||||
if (info.file.status === 'done') {
|
||||
// Get this url from response in real world.
|
||||
getBase64(info.file.originFileObj, imageUrl => {
|
||||
console.log(imageUrl);
|
||||
this.imageUrl = imageUrl;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
beforeUpload(file) {
|
||||
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
||||
if (!isJpgOrPng) {
|
||||
this.$message.error('You can only upload JPG file!');
|
||||
}
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
if (!isLt2M) {
|
||||
this.$message.error('Image must smaller than 2MB!');
|
||||
}
|
||||
return isJpgOrPng && isLt2M;
|
||||
},
|
||||
|
||||
uploadFile(fileObj) {
|
||||
let {file} = fileObj
|
||||
const _data = new FormData()
|
||||
var renameReportFile = new File([file], '新名称.jpg', {type: file.type});
|
||||
_data.append('file', renameReportFile)
|
||||
_axios({
|
||||
url: this.uploadFilePath,
|
||||
method: 'post',
|
||||
data: _data
|
||||
}).then(res => {
|
||||
this.loading = false
|
||||
console.log(res);
|
||||
this.imageUrl = this.staticFilePath + '?fileId=' + res.data.id
|
||||
const img = new Image()
|
||||
img.src = this.staticFilePath + '?fileId=' + res.data.id
|
||||
if (img.complete) {
|
||||
this.imgOrigin = {
|
||||
width: img.width,
|
||||
height: img.height
|
||||
}
|
||||
} else {
|
||||
img.onload = () => {
|
||||
console.log(12);
|
||||
this.imgOrigin = {
|
||||
width: img.width,
|
||||
height: img.height
|
||||
}
|
||||
console.log(this.imgOrigin);
|
||||
}
|
||||
}
|
||||
}).catch(e => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
handleSubmit() {
|
||||
this.visible = false
|
||||
},
|
||||
|
||||
handleTest() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
window.imgNumOParagraph = window.imgNumOParagraph || null
|
||||
var oNumbering, oNumLvl
|
||||
oDocument = Api.GetDocument();
|
||||
// 未创建图片列项
|
||||
if (window.imgNumOParagraph) {
|
||||
oNumbering = window.imgNumOParagraph
|
||||
} else {
|
||||
// 图片
|
||||
oNumbering = oDocument.CreateNumbering("numbered");
|
||||
window.imgNumOParagraph = oNumbering
|
||||
}
|
||||
oNumLvl = oNumbering.GetLevel(oNumbering.GetLevel(0).GetLevelIndex());
|
||||
// console.log('this', this)
|
||||
var num = oNumLvl.GetNumbering()
|
||||
// console.log(oDocument.GetNumbering())
|
||||
// console.log(Api.GetDocument())
|
||||
// console.log(Api.GetNumbering())
|
||||
oNumLvl.SetRestart(false)
|
||||
// title = '图' + oNumLvl.GetNumbering()
|
||||
// oNumLvl.SetCustomType('lowerRoman', oNumLvl.GetNumbering(), 'left')
|
||||
oParagraph = Api.CreateParagraph();
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oParagraph.AddText("测试段落");
|
||||
oParagraph.SetContextualSpacing(true);
|
||||
oDocument.Push(oParagraph);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
computed: {},
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.avatar-uploader > .ant-upload {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
}
|
||||
|
||||
.ant-upload-select-picture-card i {
|
||||
font-size: 32px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.ant-upload-select-picture-card .ant-upload-text {
|
||||
margin-top: 8px;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,487 @@
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<a-button-group>
|
||||
<!-- <a-button @click="handleClick">插入图</a-button>-->
|
||||
<!-- <a-button @click="handleCaptionClick">插入图题注</a-button>-->
|
||||
<a-button @click="openImageDialog">插入图片</a-button>
|
||||
</a-button-group>
|
||||
<!-- <a-button-group>-->
|
||||
<!-- <a-button @click="handleTest">测试</a-button>-->
|
||||
<!-- </a-button-group>-->
|
||||
|
||||
<a-modal v-model="visible" title="插入图片" @ok="handleOk">
|
||||
<a-form-model
|
||||
id="components-form-demo-validate-other"
|
||||
:model="form"
|
||||
v-bind="formItemLayout"
|
||||
@submit="handleSubmit"
|
||||
>
|
||||
<a-form-item label="标题">
|
||||
<a-input
|
||||
v-model="form.title"
|
||||
placeholder="请输入标题"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="图片">
|
||||
<a-upload
|
||||
ref="upload"
|
||||
name="file"
|
||||
list-type="picture-card"
|
||||
class="avatar-uploader"
|
||||
:show-upload-list="false"
|
||||
action="api/att/attFile/upload"
|
||||
:before-upload="beforeUpload"
|
||||
:customRequest="uploadFile"
|
||||
@change="handleChange"
|
||||
v-decorator="[
|
||||
'file',
|
||||
{
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请上传图片',
|
||||
},
|
||||
],
|
||||
},
|
||||
]"
|
||||
>
|
||||
<img ref="myImg" v-if="imageUrl" :src="imageUrl" style="width: 300px; height: 300px;"/>
|
||||
<div v-else>
|
||||
<a-icon :type="loading ? 'loading' : 'plus'"/>
|
||||
<div class="ant-upload-text">
|
||||
Upload
|
||||
</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="图片大小">
|
||||
<a-radio-group :options="plainOptions" v-model="form.size"/>
|
||||
</a-form-item>
|
||||
</a-form-model>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _axios from '@/plugins/axios2'
|
||||
import pxConversionMm from '../common/unitConversion'
|
||||
|
||||
function getBase64(img, callback) {
|
||||
console.log(img);
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener('load', () => callback(reader.result));
|
||||
reader.readAsDataURL(img);
|
||||
}
|
||||
|
||||
const plainOptions = ['原图', '小', '中', '大'];
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
formItemLayout: {
|
||||
labelCol: {span: 6},
|
||||
wrapperCol: {span: 14},
|
||||
},
|
||||
loading: false,
|
||||
imageUrl: '',
|
||||
plainOptions,
|
||||
form: {
|
||||
title: '',
|
||||
size: '中'
|
||||
},
|
||||
numData: {
|
||||
1: 'A',
|
||||
2: 'B',
|
||||
3: 'C',
|
||||
4: 'D',
|
||||
5: 'E',
|
||||
6: 'F',
|
||||
7: 'G',
|
||||
8: 'H',
|
||||
9: 'I',
|
||||
10: 'J',
|
||||
11: 'K',
|
||||
12: 'L',
|
||||
13: 'M',
|
||||
14: 'N',
|
||||
15: 'O',
|
||||
16: 'P',
|
||||
17: 'Q',
|
||||
18: 'R',
|
||||
19: 'S',
|
||||
20: 'T',
|
||||
21: 'U',
|
||||
22: 'V',
|
||||
23: 'W',
|
||||
24: 'X',
|
||||
25: 'Y',
|
||||
26: 'Z'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
// console.log(window.Asc.plugin.info)
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
this.ctx.callCommand(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
// console.log(document.getElementById(`iframe_${Asc.scope.guid}`))
|
||||
try {
|
||||
// setTimeout(() => {
|
||||
// Api.asc_addImage()
|
||||
console.log(Api)
|
||||
Api.AddImage()
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(false)
|
||||
props.put_Label('图')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// Api.asc_registerCallback('asc_onEndAction', cb)
|
||||
// }, 1)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
// window.postMessage()
|
||||
// document.getElementById(`iframe_${Asc.scope.guid}`).
|
||||
// contentWindow.postMessage({ m: 'Wx Success' }, '*')
|
||||
}, false)
|
||||
},
|
||||
handleCaptionClick() {
|
||||
// console.log(window.Asc.plugin.info)
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
this.ctx.callCommand(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
// console.log(document.getElementById(`iframe_${Asc.scope.guid}`))
|
||||
try {
|
||||
// setTimeout(() => {
|
||||
// Api.asc_addImage()
|
||||
Api.AddImage()
|
||||
const cb = (type, id) => {
|
||||
// eslint-disable-next-line max-len
|
||||
// this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
|
||||
// c_oAscAsyncActionType.BlockInteraction: 1
|
||||
// c_oAscAsyncAction.LoadImage: 8
|
||||
if (type === 1 && id === 8) {
|
||||
// 图片加载完成
|
||||
console.log('图片加载完成')
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(false)
|
||||
props.put_Label('图')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// props.put_HeadingLvl(this.cmbChapter.getValue()) // 章节的风格,不包括章节号时不用填
|
||||
// props.put_Separator(this.cmbSeparator.getValue()) // 分隔符,不包括章节号时不用填
|
||||
props.updateName()
|
||||
// eslint-disable-next-line no-undef
|
||||
DE.controllers.Viewport.api.asc_AddObjectCaption(props)
|
||||
Api.asc_unregisterCallback('asc_onEndAction', cb)
|
||||
}
|
||||
// console.log(rest)
|
||||
}
|
||||
Api.asc_registerCallback('asc_onEndAction', cb)
|
||||
// }, 1)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
// window.postMessage()
|
||||
// document.getElementById(`iframe_${Asc.scope.guid}`).
|
||||
// contentWindow.postMessage({ m: 'Wx Success' }, '*')
|
||||
}, false)
|
||||
},
|
||||
handleCaptionClick2() {
|
||||
// _api.init(oWordControl);
|
||||
// this.ctx.callCommand(function () {
|
||||
// try {
|
||||
// // eslint-disable-next-line new-cap
|
||||
// // const _api = new window.Asc.asc_docs_api()
|
||||
// console.log(this.DE.controllers.Viewport.api.asc_AddObjectCaption)
|
||||
// } catch (error) {
|
||||
// console.error(error)
|
||||
// }
|
||||
// })
|
||||
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(false)
|
||||
props.put_Label('图')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// props.put_HeadingLvl(this.cmbChapter.getValue()) // 章节的风格,不包括章节号时不用填
|
||||
// props.put_Separator(this.cmbSeparator.getValue()) // 分隔符,不包括章节号时不用填
|
||||
props.updateName()
|
||||
|
||||
// console.log(props)
|
||||
// console.log(window)
|
||||
// const oDocument = Api.GetDocument()
|
||||
// const oParagraph = oDocument.GetElement(0)
|
||||
// const oImage = Api.CreateImage('https://www.onlyoffice.com/blog/wp-content/uploads/2021/05/Blog_docs_63.jpg', 60 * 36000, 35 * 36000)
|
||||
// oParagraph.AddDrawing(oImage)
|
||||
// console.log(oImage)
|
||||
// eslint-disable-next-line no-undef
|
||||
DE.controllers.Viewport.api.asc_AddObjectCaption(props)
|
||||
// oDocument.Push(oImage)
|
||||
// window.Asc.asc_docs_api.asc_AddObjectCaption(props)
|
||||
// console.log(window.Asc.asc_docs_api.prototype.asc_AddObjectCaption(props))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
openImageDialog() {
|
||||
this.visible = true
|
||||
},
|
||||
|
||||
handleOk() {
|
||||
this.visible = false
|
||||
window.Asc.scope.imageUrl = this.imageUrl
|
||||
window.Asc.scope.title = this.form.title
|
||||
window.Asc.scope.imgSize = this.form.size
|
||||
const width = pxConversionMm(this.imgOrigin.width)
|
||||
const height = pxConversionMm(this.imgOrigin.height)
|
||||
window.Asc.scope.imgOrigin = {
|
||||
width,
|
||||
height
|
||||
}
|
||||
Asc.scope.numData = this.numData;
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const imgOParagraph = Api.CreateParagraph()
|
||||
let imgSize = {
|
||||
width: 0,
|
||||
height: 0
|
||||
}
|
||||
switch (Asc.scope.imgSize) {
|
||||
case '原图':
|
||||
imgSize.width = Asc.scope.imgOrigin.width
|
||||
imgSize.height = Asc.scope.imgOrigin.height
|
||||
break
|
||||
case '小':
|
||||
imgSize.width = 165 / 3
|
||||
imgSize.height = 89.3 / 3
|
||||
break
|
||||
case '中':
|
||||
imgSize.width = 165 / 2
|
||||
imgSize.height = 89.3 / 2
|
||||
break
|
||||
case '大':
|
||||
imgSize.width = 165
|
||||
imgSize.height = 89.3
|
||||
break
|
||||
}
|
||||
const oDrawing = Api.CreateImage(Asc.scope.imageUrl, imgSize.width * 36000, imgSize.height * 36000);
|
||||
imgOParagraph.AddDrawing(oDrawing);
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
const CreateParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([CreateParagraph])
|
||||
let GetPrevious = CreateParagraph.GetPrevious()
|
||||
let numIndex
|
||||
for (let index = 0; index < 1000000000; index++) {
|
||||
let ContentControls = GetPrevious.GetParaPr().GetStyle()
|
||||
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
|
||||
numIndex = GetPrevious.GetSpacingBefore()
|
||||
break;
|
||||
} else if (GetPrevious.GetSpacingBefore() == 30) {
|
||||
const getNumbering = GetPrevious.GetNumbering()
|
||||
currentNumbering = getNumbering;
|
||||
break;
|
||||
} else {
|
||||
GetPrevious = GetPrevious.GetPrevious()
|
||||
}
|
||||
}
|
||||
CreateParagraph.Delete()
|
||||
|
||||
// for (let index = 0; index < allElement; index++) {
|
||||
// const element = oDocument.GetElement(index)
|
||||
// if ("paragraph" === element.GetClassType()) {
|
||||
// const getNumbering = element.GetNumbering()
|
||||
// if (getNumbering !== null) {
|
||||
// const text = element.GetSpacingBefore()
|
||||
// if (GetPrevious.GetSpacingBefore() == 1) {
|
||||
// if (text == 10) {
|
||||
// currentNumbering = getNumbering;
|
||||
// break;
|
||||
// }
|
||||
// } else if (GetPrevious.GetSpacingBefore() == 2) {
|
||||
// if (text == 11) {
|
||||
// currentNumbering = getNumbering;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
let sFormatString = '图'+Asc.scope.numData[numIndex]+'.%1';
|
||||
numbering.SetCustomType("decimal", sFormatString, "right");
|
||||
}
|
||||
}
|
||||
const imgText = Api.CreateParagraph();
|
||||
var textPr = numbering.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(21)
|
||||
imgText.SetNumbering(numbering);
|
||||
imgText.AddText(`${Asc.scope.title}`);
|
||||
imgText.SetFontSize(21)
|
||||
imgText.SetFontFamily("黑体");
|
||||
imgText.SetBold(false)
|
||||
imgText.SetContextualSpacing(true);
|
||||
imgText.SetJc("center");
|
||||
imgText.SetSpacingBefore(30, true)
|
||||
imgText.SetSmallCaps(true);
|
||||
imgOParagraph.SetJc("center");
|
||||
imgOParagraph.SetSmallCaps(true);
|
||||
const breakLine = Api.CreateParagraph()
|
||||
breakLine.SetJc('left')
|
||||
oDocument.InsertContent([imgOParagraph]);
|
||||
|
||||
oDocument.InsertContent([imgText]);
|
||||
// 创建表格 包裹文字和列项
|
||||
oDocument.InsertContent([breakLine]);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.form = {}
|
||||
this.imageUrl = ''
|
||||
}, 200)
|
||||
|
||||
},
|
||||
|
||||
handleChange(info) {
|
||||
if (info.file.status === 'uploading') {
|
||||
this.loading = true;
|
||||
return;
|
||||
}
|
||||
if (info.file.status === 'done') {
|
||||
// Get this url from response in real world.
|
||||
getBase64(info.file.originFileObj, imageUrl => {
|
||||
console.log(imageUrl);
|
||||
this.imageUrl = imageUrl;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
beforeUpload(file) {
|
||||
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
||||
if (!isJpgOrPng) {
|
||||
this.$message.error('You can only upload JPG file!');
|
||||
}
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
if (!isLt2M) {
|
||||
this.$message.error('Image must smaller than 2MB!');
|
||||
}
|
||||
return isJpgOrPng && isLt2M;
|
||||
},
|
||||
|
||||
uploadFile(fileObj) {
|
||||
let {file} = fileObj
|
||||
const _data = new FormData()
|
||||
var renameReportFile = new File([file], '新名称.jpg', {type: file.type});
|
||||
_data.append('file', renameReportFile)
|
||||
_axios({
|
||||
url: this.uploadFilePath,
|
||||
method: 'post',
|
||||
data: _data
|
||||
}).then(res => {
|
||||
this.loading = false
|
||||
console.log(res);
|
||||
this.imageUrl = this.staticFilePath + '?fileId=' + res.data.id
|
||||
const img = new Image()
|
||||
img.src = this.staticFilePath + '?fileId=' + res.data.id
|
||||
if (img.complete) {
|
||||
this.imgOrigin = {
|
||||
width: img.width,
|
||||
height: img.height
|
||||
}
|
||||
} else {
|
||||
img.onload = () => {
|
||||
console.log(12);
|
||||
this.imgOrigin = {
|
||||
width: img.width,
|
||||
height: img.height
|
||||
}
|
||||
console.log(this.imgOrigin);
|
||||
}
|
||||
}
|
||||
}).catch(e => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
handleSubmit() {
|
||||
this.visible = false
|
||||
},
|
||||
|
||||
handleTest() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
window.imgNumOParagraph = window.imgNumOParagraph || null
|
||||
var oNumbering, oNumLvl
|
||||
oDocument = Api.GetDocument();
|
||||
// 未创建图片列项
|
||||
if (window.imgNumOParagraph) {
|
||||
oNumbering = window.imgNumOParagraph
|
||||
} else {
|
||||
// 图片
|
||||
oNumbering = oDocument.CreateNumbering("numbered");
|
||||
window.imgNumOParagraph = oNumbering
|
||||
}
|
||||
oNumLvl = oNumbering.GetLevel(oNumbering.GetLevel(0).GetLevelIndex());
|
||||
// console.log('this', this)
|
||||
var num = oNumLvl.GetNumbering()
|
||||
// console.log(oDocument.GetNumbering())
|
||||
// console.log(Api.GetDocument())
|
||||
// console.log(Api.GetNumbering())
|
||||
oNumLvl.SetRestart(false)
|
||||
// title = '图' + oNumLvl.GetNumbering()
|
||||
// oNumLvl.SetCustomType('lowerRoman', oNumLvl.GetNumbering(), 'left')
|
||||
oParagraph = Api.CreateParagraph();
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oParagraph.AddText("测试段落");
|
||||
oParagraph.SetContextualSpacing(true);
|
||||
oDocument.Push(oParagraph);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
computed: {},
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.avatar-uploader > .ant-upload {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
}
|
||||
|
||||
.ant-upload-select-picture-card i {
|
||||
font-size: 32px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.ant-upload-select-picture-card .ant-upload-text {
|
||||
margin-top: 8px;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,235 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-button @click="handleClick">插入表格</a-button>
|
||||
<a-button @click="handleClickCaption">插入表格题注</a-button>
|
||||
<a-button @click="handleClickTableAndCaption">插入表格含题注</a-button>
|
||||
<a-button @click="handleClickFenlan">cxx-插入分栏</a-button>
|
||||
<a-button @click="handleTest">cxx-测试按钮</a-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
function insertTableCommandFunction() {
|
||||
return `const oDocument = Api.GetDocument();
|
||||
const oTableStyle = oDocument.CreateStyle('CustomTableStyle', 'table');
|
||||
oTableStyle.SetBasedOn(oDocument.GetStyle('Bordered - Accent 5'));
|
||||
const oTable = Api.CreateTable(5, 5);oTable.SetWidth('percent', 100);
|
||||
oTable.SetStyle(oTableStyle);const oCell = oTable.MergeCells([oTable.GetRow(1).GetCell(1), oTable.GetRow(1).GetCell(2), oTable.GetRow(2).GetCell(1), oTable.GetRow(2).GetCell(2)]);
|
||||
oCell.GetContent().GetElement(0).AddText('Merged cell');
|
||||
oDocument.Push(oTable);`
|
||||
}
|
||||
|
||||
function createTextBlockLvlSdt(text) {
|
||||
const oBlockLvlSdt = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt.GetContent().GetElement(0).AddText('包含文字的BlockLvlSdt')
|
||||
return oBlockLvlSdt
|
||||
}
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
style: 'Table Grid'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
window.Asc.scope.text = this.style
|
||||
this.ctx.callCommand(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
const oDocument = Api.GetDocument()
|
||||
const oTableStyle = oDocument.CreateStyle('CustomTableStyle', 'table')
|
||||
oTableStyle.SetBasedOn(oDocument.GetStyle(Asc.scope.text))
|
||||
// eslint-disable-next-line no-undef
|
||||
const oTable = Api.CreateTable(4, 5)
|
||||
oTable.SetWidth('percent', 100)
|
||||
oTable.SetStyle(oTableStyle)
|
||||
|
||||
// 构建表头
|
||||
const btRow = oTable.GetRow(0)
|
||||
// 0
|
||||
const oBlockLvlSdt00 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt00.GetContent().GetElement(0).AddText('#')
|
||||
btRow.GetCell(0).AddElement(0, oBlockLvlSdt00)
|
||||
// 1
|
||||
const oBlockLvlSdt01 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt01.GetContent().GetElement(0).AddText('标准编号/Standard No.')
|
||||
btRow.GetCell(1).AddElement(0, oBlockLvlSdt01)
|
||||
// 2
|
||||
const oBlockLvlSdt02 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt02.GetContent().GetElement(0).AddText('起草人/Drafter')
|
||||
btRow.GetCell(2).AddElement(0, oBlockLvlSdt02)
|
||||
// 3
|
||||
const oBlockLvlSdt03 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt03.GetContent().GetElement(0).AddText('主要修订内容/Revision information 采用标准/Applicable Standard')
|
||||
btRow.GetCell(3).AddElement(0, oBlockLvlSdt03)
|
||||
|
||||
oDocument.InsertContent([oTable])
|
||||
console.log('插入完成')
|
||||
}, false)
|
||||
|
||||
// const command = insertTableCommandFunction()
|
||||
// this.ctx.executeCommand('command', command)
|
||||
},
|
||||
handleClickCaption() {
|
||||
// _api.init(oWordControl);
|
||||
// this.ctx.callCommand(function () {
|
||||
// try {
|
||||
// // eslint-disable-next-line new-cap
|
||||
// // const _api = new window.Asc.asc_docs_api()
|
||||
// console.log(this.DE.controllers.Viewport.api.asc_AddObjectCaption)
|
||||
// } catch (error) {
|
||||
// console.error(error)
|
||||
// }
|
||||
// })
|
||||
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(true)
|
||||
props.put_Label('表格')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// props.put_HeadingLvl(this.cmbChapter.getValue()) // 章节的风格,不包括章节号时不用填
|
||||
// props.put_Separator(this.cmbSeparator.getValue()) // 分隔符,不包括章节号时不用填
|
||||
props.updateName()
|
||||
|
||||
console.log(props)
|
||||
console.log(window)
|
||||
// const oDocument = Api.GetDocument()
|
||||
// const oParagraph = oDocument.GetElement(0)
|
||||
// const oImage = Api.CreateImage('https://www.onlyoffice.com/blog/wp-content/uploads/2021/05/Blog_docs_63.jpg', 60 * 36000, 35 * 36000)
|
||||
// oParagraph.AddDrawing(oImage)
|
||||
// console.log(oImage)
|
||||
// eslint-disable-next-line no-undef
|
||||
DE.controllers.Viewport.api.asc_AddObjectCaption(props)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClickTableAndCaption() {
|
||||
window.Asc.scope.text = this.style
|
||||
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const props = new window.Asc.CAscCaptionProperties()
|
||||
props.put_Before(true)
|
||||
props.put_Label('表格')
|
||||
props.put_ExcludeLabel(false)
|
||||
props.put_Format(window.Asc.c_oAscNumberingFormat.Decimal)
|
||||
props.put_IncludeChapterNumber(false) // 是否包括章节号,
|
||||
// props.put_HeadingLvl(this.cmbChapter.getValue()) // 章节的风格,不包括章节号时不用填
|
||||
// props.put_Separator(this.cmbSeparator.getValue()) // 分隔符,不包括章节号时不用填
|
||||
props.updateName()
|
||||
|
||||
console.log(props)
|
||||
console.log(window)
|
||||
// const oDocument = Api.GetDocument()
|
||||
// const oParagraph = oDocument.GetElement(0)
|
||||
// const oImage = Api.CreateImage('https://www.onlyoffice.com/blog/wp-content/uploads/2021/05/Blog_docs_63.jpg', 60 * 36000, 35 * 36000)
|
||||
// oParagraph.AddDrawing(oImage)
|
||||
// console.log(oImage)
|
||||
// eslint-disable-next-line no-undef
|
||||
DE.controllers.Viewport.api.asc_AddObjectCaption(props)
|
||||
// 插入表格
|
||||
const oDocument = Api.GetDocument()
|
||||
const oTableStyle = oDocument.CreateStyle('CustomTableStyle', 'table')
|
||||
oTableStyle.SetBasedOn(oDocument.GetStyle(Asc.scope.text))
|
||||
// eslint-disable-next-line no-undef
|
||||
const oTable = Api.CreateTable(4, 60)
|
||||
oTable.SetWidth('percent', 100)
|
||||
oTable.SetStyle(oTableStyle)
|
||||
// 设置重复表头
|
||||
console.log(oTable)
|
||||
const properties = new window.Asc.CTableProp()
|
||||
properties.put_RowsInHeader(true)
|
||||
// oTable.Table.eS(properties)
|
||||
oTable.Table.SetTableProps(properties)
|
||||
|
||||
// 构建表头
|
||||
const btRow = oTable.GetRow(0)
|
||||
// 0
|
||||
const oBlockLvlSdt00 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt00.GetContent().GetElement(0).AddText('#')
|
||||
btRow.GetCell(0).AddElement(0, oBlockLvlSdt00)
|
||||
// 1
|
||||
const oBlockLvlSdt01 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt01.GetContent().GetElement(0).AddText('标准编号/Standard No.')
|
||||
btRow.GetCell(1).AddElement(0, oBlockLvlSdt01)
|
||||
// 2
|
||||
const oBlockLvlSdt02 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt02.GetContent().GetElement(0).AddText('起草人/Drafter')
|
||||
btRow.GetCell(2).AddElement(0, oBlockLvlSdt02)
|
||||
// 3
|
||||
const oBlockLvlSdt03 = Api.CreateBlockLvlSdt()
|
||||
oBlockLvlSdt03.GetContent().GetElement(0).AddText('主要修订内容/Revision information 采用标准/Applicable Standard')
|
||||
btRow.GetCell(3).AddElement(0, oBlockLvlSdt03)
|
||||
|
||||
oDocument.InsertContent([oTable])
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 插入分栏
|
||||
handleClickFenlan() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const title = Api.CreateParagraph()
|
||||
title.AddText('分栏解决方案')
|
||||
title.SetJc('center')
|
||||
title.SetFontSize(18)
|
||||
oDocument.InsertContent([title])
|
||||
const oTableStyle = oDocument.CreateStyle('CustomTableStyle', 'table')
|
||||
oTableStyle.SetBasedOn(oDocument.GetStyle('Table Grid'))
|
||||
// eslint-disable-next-line no-undef
|
||||
const oTable = Api.CreateTable(3, 1)
|
||||
const btRow = oTable.GetRow(0)
|
||||
const oBlockLvlSdt00 = Api.CreateBlockLvlSdt()
|
||||
oTablePr = oTableStyle.GetTablePr();
|
||||
oTablePr.SetTableLayout("fixed");
|
||||
|
||||
const tableCell1 = btRow.GetCell(0)
|
||||
tableCell1.SetWidth('percent', 45)
|
||||
tableCell1.SetCellBorderRight('single', 1, 0, 255, 255, 255);
|
||||
// tableCell1.AddElement(0, oBlockLvlSdt00)
|
||||
|
||||
const tableCell2 = btRow.GetCell(1)
|
||||
tableCell2.SetWidth('percent', 10)
|
||||
tableCell2.SetCellBorderLeft('single', 1, 0, 255, 255, 255);
|
||||
tableCell2.SetCellBorderRight('single', 1, 0, 255, 255, 255);
|
||||
// tableCell2.AddElement(0, oBlockLvlSdt00)
|
||||
|
||||
const tableCell3 = btRow.GetCell(2)
|
||||
tableCell3.SetWidth('percent', 45)
|
||||
tableCell3.SetCellBorderLeft('single', 1, 0, 255, 255, 255);
|
||||
// tableCell3.AddElement(0, oBlockLvlSdt00)
|
||||
|
||||
oTable.SetTableBorderTop("single", 1, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderRight("single", 1, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderBottom("single", 1, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderLeft("single", 1, 0, 255, 255, 255);
|
||||
|
||||
oTable.SetStyle(oTableStyle)
|
||||
oDocument.Push(oTable)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleTest() {
|
||||
this.ctx.callCommand(() => {
|
||||
const oDocument = Api.GetDocument()
|
||||
console.log(oDocument.Document)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-input v-model="colNumber">请输入列数</a-input>
|
||||
<a-button @click="handleClick">InsertTableRow</a-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
colNumber: '1'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
window.Asc.plugin.onMethodReturn = function (...args) {
|
||||
const { plugin } = window.Asc
|
||||
console.log(args)
|
||||
// plugin.executeCommand('close', '')
|
||||
}
|
||||
// console.log(this.style)
|
||||
window.Asc.scope.colNumber = this.colNumber
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
// console.log(Api)
|
||||
const colNumber = 3
|
||||
const oDocument = Api.GetDocument()
|
||||
console.log(oDocument)
|
||||
// 获取当前Paragraph
|
||||
// GetCurrentParagraph => Cl
|
||||
const oParagraph = oDocument.Document.GetCurrentParagraph(undefined, undefined, { CheckDocContent: true })
|
||||
// 利用ApiParagraph获取Parent
|
||||
const newParagraph = Api.CreateParagraph()
|
||||
// newParagraph.Ma = oParagraph
|
||||
newParagraph.SetParagraphWx(oParagraph)
|
||||
const parentTable = newParagraph.GetParentTable()
|
||||
// console.log(parentTable)
|
||||
// if (!parentTable) return new Error('当前父元素ClassType不是Table')
|
||||
if (!parentTable) {
|
||||
// console.log(window.Asc)
|
||||
// Asc.plugin.info.data = '当前父元素ClassType不是Table'
|
||||
return '当前父元素ClassType不是Table'
|
||||
}
|
||||
|
||||
const parentTableCell = newParagraph.GetParentTableCell()
|
||||
const oTableRow = parentTable.AddRow(parentTableCell, false)
|
||||
const oCellsCount = oTableRow.GetCellsCount()
|
||||
if (oCellsCount !== 1) {
|
||||
oTableRow.MergeCells()
|
||||
}
|
||||
// 将这一行拆分为几行几列
|
||||
const cellTable = oTableRow.GetCell(0).Split(1, colNumber)
|
||||
cellTable.SetTableLayout('fixed')
|
||||
// 获取当前位置
|
||||
// Get_ParaContentPos => fh : oParagraph.Get_ParaContentPos(false, false)
|
||||
// oParagraph.fh(false, false)
|
||||
// console.log(oParagraph.fh(false, false))
|
||||
// oDocument.InsertContent([])
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
return 'Success'
|
||||
}, false)
|
||||
|
||||
// const command = insertTableCommandFunction()
|
||||
// this.ctx.executeCommand('command', command)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<a-button-group>
|
||||
<a-button @click="handleClick">插入二级列项</a-button>
|
||||
<a-button @click="handleClickEn">插入二级列项(英)</a-button>
|
||||
</a-button-group>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
handleClick() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(1)
|
||||
oNumLvl.SetTemplateType('1)')
|
||||
|
||||
oNumLvl.SetSuff('space')
|
||||
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.AddText('二级列项示例')
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetSpacing(10)
|
||||
oDocument.InsertContent([oParagraph])
|
||||
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClickEn() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(1)
|
||||
oNumLvl.SetTemplateType('1)')
|
||||
|
||||
oNumLvl.SetSuff('space')
|
||||
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.AddText('Custom numbered')
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(21)
|
||||
oDocument.InsertContent([oParagraph])
|
||||
oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleClick2() {
|
||||
this.ctx.executeMethod('InputText', ['wx', 'wx2'])
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name" : "自定义编辑器",
|
||||
"guid" : "asc.{0616AE85-5DBE-4B6B-A0A9-455C4F1503AD}",
|
||||
"baseUrl" : "",
|
||||
"group": {
|
||||
"name": "自定义编辑器",
|
||||
"rank": 2
|
||||
},
|
||||
"variations" : [
|
||||
{
|
||||
"description" : "hello world",
|
||||
"url" : "index.html",
|
||||
"icons" : ["../favicon.ico"],
|
||||
"isViewer" : false,
|
||||
"EditorsSupport" : ["word"],
|
||||
"isVisual" : true,
|
||||
"isModal" : false,
|
||||
"isInsideMode" : true,
|
||||
"initDataType" : "",
|
||||
"initData" : "",
|
||||
"isUpdateOleOnResize" : false,
|
||||
"buttons" : []
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
import App from './App.vue'
|
||||
import { interfaceUrl, uploadFilePath, staticFilePath } from '@/config'
|
||||
// eslint-disable-next-line import/extensions
|
||||
import '@/core/use.js'
|
||||
import axios from '../../plugins/axios2'
|
||||
import store from '@/store'
|
||||
|
||||
Vue.prototype.interfaceUrl = interfaceUrl
|
||||
Vue.prototype.uploadFilePath = uploadFilePath
|
||||
Vue.prototype.staticFilePath = staticFilePath
|
||||
Vue.prototype.$axios = axios
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
store,
|
||||
render: (h) => h(App),
|
||||
}).$mount('#app')
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,217 @@
|
||||
<template>
|
||||
<a-button-group>
|
||||
<a-button @click="handleClick(1)">插入章标题</a-button>
|
||||
<a-button @click="handleClick(2)">插入节标题</a-button>
|
||||
<a-button @click="handleClick(3)">插入段落标题</a-button>
|
||||
<a-button @click="handleClick(4)">测试查找内容控件</a-button>
|
||||
</a-button-group>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapMutations, mapGetters } from 'vuex'
|
||||
export default {
|
||||
methods: {
|
||||
handleClick(type) {
|
||||
switch(type) {
|
||||
case 1:
|
||||
this.handleCreateCapter()
|
||||
break
|
||||
case 2:
|
||||
this.handleCreateSection()
|
||||
break
|
||||
case 4:
|
||||
this.handlemodifyColltor()
|
||||
break
|
||||
}
|
||||
},
|
||||
|
||||
handleCreateCapter() {
|
||||
window.Asc.scope.chapterNumbering = this.chapterNumbering
|
||||
if (sessionStorage.getItem('chapterNumbering') !== undefined && sessionStorage.getItem('chapterNumbering') !== 'undefined') {
|
||||
window.chapterNumbering = JSON.parse(sessionStorage.getItem('chapterNumbering'))
|
||||
console.log(window.chapterNumbering)
|
||||
}
|
||||
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
|
||||
const parentTable = newParagraph.GetParentTable()
|
||||
if (!parentTable) {
|
||||
console.log(123);
|
||||
return '当前父元素ClassType不是Table'
|
||||
}
|
||||
// DE.controllers.Toolbar.api.put_ListType(2, 2)
|
||||
const parentTableCell = newParagraph.GetParentTableCell()
|
||||
// 在最后一个单元格之后插入一个新行
|
||||
const oTableRow = parentTable.AddRow(parentTableCell, false)
|
||||
// 插入新单元格的内容
|
||||
window.chapterNumbering = window.chapterNumbering || null
|
||||
// 未创建章节列项
|
||||
if (window.chapterNumbering) {
|
||||
const oNumbering = window.chapterNumbering
|
||||
} else {
|
||||
console.log('48执行')
|
||||
const oNumbering = oDocument.CreateNumbering("numbered");
|
||||
window.chapterNumbering = oNumbering
|
||||
// console.log(oNumbering)
|
||||
// // 声明cache变量,便于匹配是否有循环引用的情况
|
||||
// var cache = [];
|
||||
// var str = JSON.stringify(oNumbering, function(key, value) {
|
||||
// if (typeof value === 'object' && value !== null) {
|
||||
// if (cache.indexOf(value) !== -1) {
|
||||
// // 移除
|
||||
// return;
|
||||
// }
|
||||
// // 收集所有的值
|
||||
// cache.push(value);
|
||||
// }
|
||||
// return value;
|
||||
// });
|
||||
// cache = null; // 清空变量,便于垃圾回收机制回收
|
||||
// console.log('str:', str)
|
||||
|
||||
// function decycle (target) {
|
||||
// var map = new WeakMap()
|
||||
// function _cycle (obj) {
|
||||
// if (!map.has(obj)) {
|
||||
// map.set(obj, obj)
|
||||
// }
|
||||
// let keys = Object.keys(obj)
|
||||
// for (let i = 0, len = keys.length; i < len; i++) {
|
||||
// if (typeof obj[keys[i]] === 'object') {
|
||||
// if (map.has(obj[keys[i]])) {
|
||||
// obj[keys[i]] = '$'
|
||||
// continue
|
||||
// } else {
|
||||
// map.set(obj[keys[i]], obj[keys[i]])
|
||||
// }
|
||||
// _cycle(obj[keys[i]])
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// _cycle(target)
|
||||
// }
|
||||
// decycle(oNumbering)
|
||||
// console.log('oNumbering:', oNumbering)
|
||||
// sessionStorage.setItem('chapterNumbering', JSON.stringify(window.chapterNumbering))
|
||||
}
|
||||
const oNumLvl = oNumbering.GetLevel(oNumbering.GetLevel(0).GetLevelIndex());
|
||||
oNumLvl.SetRestart(false)
|
||||
const myParagraph = Api.CreateParagraph()
|
||||
myParagraph.SetNumbering(oNumLvl)
|
||||
|
||||
const cn = Api.CreateRun();
|
||||
cn.AddText('中文章标题 ')
|
||||
cn.SetBold(true)
|
||||
cn.SetFontSize(21)
|
||||
cn.SetFontFamily("SimHei")
|
||||
|
||||
const en = Api.CreateRun();
|
||||
en.AddText('English Chapter.')
|
||||
en.SetBold(false)
|
||||
en.SetFontSize(21)
|
||||
en.SetFontFamily("Arial")
|
||||
|
||||
myParagraph.Push(cn)
|
||||
myParagraph.Push(en)
|
||||
oTableRow.GetCell(0).AddElement(0, myParagraph)
|
||||
// myParagraph.SetSpacingBefore(540);
|
||||
// myParagraph.SetSpacingAfter(540);
|
||||
|
||||
// const oCellCN = oTableRow.GetCell(0).GetContent().GetElement(0)
|
||||
// oCellCN.AddText('中文章标题 ')
|
||||
// oCellCN.SetBold(true)
|
||||
// oCellCN.SetFontSize(21)
|
||||
// oCellCN.SetFontFamily("SimHei")
|
||||
|
||||
// const oCellEN = oTableRow.GetCell(0).GetContent().GetElement(0)
|
||||
// oCellEN.AddText('English Chapter.')
|
||||
// oCellEN.SetBold(false)
|
||||
// oCellEN.SetFontSize(21)
|
||||
// oCellEN.SetFontFamily("Arial")
|
||||
|
||||
oTableRow.GetCell(0).SetVerticalAlign("center")
|
||||
// 获取插入的行共有几列
|
||||
const oCellsCount = oTableRow.GetCellsCount()
|
||||
// 如果列数大于1 默认合并
|
||||
if (oCellsCount !== 1) {
|
||||
oTableRow.MergeCells()
|
||||
}
|
||||
// 将这一行拆分为几行几列
|
||||
const cellTable = oTableRow.GetCell(0).Split(1, 1)
|
||||
cellTable.SetTableLayout('fixed')
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleCreateSection() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement= oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
for(var index =0; index<allElement; index++){
|
||||
const element= oDocument.GetElement(index)
|
||||
if("paragraph" === element.GetClassType()){
|
||||
getNumbering = element.GetNumbering()
|
||||
if(getNumbering !==null){
|
||||
currentNumbering = getNumbering
|
||||
if(getNumbering.GetLevelIndex() === 1){
|
||||
numbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!numbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(1)
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.AddText('This is test section')
|
||||
oDocument.InsertContent([oParagraph])
|
||||
}catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
handlemodifyColltor() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allControls= oDocument.GetAllContentControls();
|
||||
console.log(allControls)
|
||||
const controlsCount = allControls.length
|
||||
for(var index =0; index<controlsCount; index++){
|
||||
const kj = allControls[index]
|
||||
if("PAGE1_NUMBER" ===kj.GetTag()){
|
||||
console.log(kj.GetAllParagraphs())
|
||||
const paragraphs = kj.GetAllParagraphs()[0]
|
||||
paragraphs.GetStyle();
|
||||
paragraphs.Delete()
|
||||
kj.AddText("SMTC 1111111111")
|
||||
}
|
||||
}
|
||||
}catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
...mapMutations(['updateChapterNumbering'])
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['chapterNumbering'])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<a-button-group>
|
||||
<a-button @click="handleCreateLevelOne">一级列项</a-button>
|
||||
<a-button @click="handleCreateLevelTwo">二级列项</a-button>
|
||||
</a-button-group>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { BORDER_DISABLE } from '@/config'
|
||||
export default {
|
||||
methods: {
|
||||
// 插入一级列项
|
||||
handleCreateLevelOne() {
|
||||
this.ctx.callCommand(() => {
|
||||
oDocument = Api.GetDocument();
|
||||
oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
oNumLvl.SetTemplateType("a)");
|
||||
oNumLvl.SetSuff('space');
|
||||
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
||||
const oParagraph = Api.CreateParagraph();
|
||||
oParagraph.AddText("字母列项");
|
||||
oParagraph.SetContextualSpacing(true);
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oParagraph.SetFontFamily("SimHei");
|
||||
oParagraph.SetFontSize(21);
|
||||
oDocument.InsertContent([oParagraph]);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 插入二级列项
|
||||
handleCreateLevelTwo() {
|
||||
this.ctx.callCommand(() => {
|
||||
oDocument = Api.GetDocument();
|
||||
oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(1);
|
||||
oNumLvl.SetTemplateType("1)");
|
||||
oNumLvl.SetSuff('space');
|
||||
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
||||
const oParagraph = Api.CreateParagraph();
|
||||
oParagraph.AddText("数字列项");
|
||||
oParagraph.SetContextualSpacing(true);
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oParagraph.SetFontFamily("SimHei");
|
||||
oParagraph.SetFontSize(21);
|
||||
oDocument.InsertContent([oParagraph]);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -0,0 +1,166 @@
|
||||
<template>
|
||||
<a-button-group>
|
||||
<a-button @click="handleClick(1)">插入正文</a-button>
|
||||
<!-- <a-button @click="handleClick(2)">序号测试</a-button>-->
|
||||
<!-- <a-button @click="handleClick(3)">新功能测试</a-button>-->
|
||||
<!-- <a-button @click="handleClick(4)">章功能测试</a-button>-->
|
||||
<!-- <a-button @click="handleClick(5)">节功能测试</a-button>-->
|
||||
</a-button-group>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
handleClick(type) {
|
||||
switch(type) {
|
||||
case 1:
|
||||
this.handleCreateContent()
|
||||
break
|
||||
case 2:
|
||||
this.handleNumberTest()
|
||||
break
|
||||
case 3:
|
||||
this.handleTest()
|
||||
break
|
||||
case 4:
|
||||
this.replaceTest()
|
||||
break
|
||||
case 5:
|
||||
this.handleNumberJie()
|
||||
break
|
||||
}
|
||||
},
|
||||
|
||||
handleNumberTest() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
// DE.controllers.Toolbar.onSelectBullets()
|
||||
DE.controllers.Toolbar.api.put_ListType(2, 2)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleTest() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
// DE.controllers.Toolbar.onSelectBullets()
|
||||
DE.controllers.Toolbar.api.put_ListType(2, 2)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleCreateContent() {
|
||||
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
|
||||
const parentTable = newParagraph.GetParentTable()
|
||||
console.log(parentTable);
|
||||
if (!parentTable) {
|
||||
console.log(123);
|
||||
return '当前父元素ClassType不是Table'
|
||||
}
|
||||
const parentTableCell = newParagraph.GetParentTableCell()
|
||||
// 在最后一个单元格之后插入一个新行
|
||||
const oTableRow = parentTable.AddRow(parentTableCell, false)
|
||||
// 获取插入的行共有几列
|
||||
const oCellsCount = oTableRow.GetCellsCount()
|
||||
// 如果列数大于1 默认合并
|
||||
if (oCellsCount !== 1) {
|
||||
oTableRow.MergeCells()
|
||||
}
|
||||
// 将这一行拆分为几行几列
|
||||
const cellTable = oTableRow.GetCell(0).Split(1, 3)
|
||||
cellTable.SetTableLayout('fixed')
|
||||
const CNCell = oTableRow.GetCell(0)
|
||||
CNCell.SetWidth('twips', 4762)
|
||||
const CNParagraph = Api.CreateParagraph()
|
||||
CNParagraph.AddText('这是中文的内容')
|
||||
CNCell.AddElement(0, CNParagraph)
|
||||
|
||||
console.log(cellTable)
|
||||
const MidCell = oTableRow.GetCell(1)
|
||||
MidCell.SetWidth('twips', 226)
|
||||
|
||||
const ENCell = oTableRow.GetCell(2)
|
||||
ENCell.SetWidth('twips', 4762)
|
||||
const ENParagraph = Api.CreateParagraph()
|
||||
ENParagraph.AddText('This is a new content')
|
||||
ENCell.AddElement(0, ENParagraph)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
replaceTest() {
|
||||
console.log('章节功能测试')
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement= oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
for(var index =0; index<allElement; index++){
|
||||
const element= oDocument.GetElement(index)
|
||||
if("paragraph" === element.GetClassType()){
|
||||
const getNumbering= element.GetNumbering()
|
||||
if(getNumbering !==null){
|
||||
if(getNumbering.GetLevelIndex() === 0){
|
||||
numbering = getNumbering
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
console.log('oNumbering:', numbering)
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.AddText('This is test text')
|
||||
oDocument.InsertContent([oParagraph])
|
||||
}catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
handleNumberJie(){
|
||||
console.log('节功能测试')
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement= oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
for(var index =0; index<allElement; index++){
|
||||
const element= oDocument.GetElement(index)
|
||||
if("paragraph" === element.GetClassType()){
|
||||
const getNumbering= element.GetNumbering()
|
||||
if(getNumbering !==null){
|
||||
if(getNumbering.GetLevelIndex() === 1){
|
||||
console.log(getNumbering)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// this.replaceTest()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,223 @@
|
||||
<template>
|
||||
<div class="note">
|
||||
<a-button-group style="margin-bottom: 10px;">
|
||||
<a-button @click="handleInsertNoteOne('CN')">注</a-button>
|
||||
<a-button @click="handleInsertMultNotTwo('CN')">注X</a-button>
|
||||
<a-button @click="handleInsertMultNoteThe('CN')">首注</a-button>
|
||||
</a-button-group>
|
||||
<!-- <a-button-group>-->
|
||||
<!-- <a-button @click="handleInsertNote('EN')">插入单个注(English)</a-button>-->
|
||||
<!-- <a-button @click="handleInsertMultNote('EN')">插入多个注(English)</a-button>-->
|
||||
<!-- </a-button-group>-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
// 插入单个注释
|
||||
handleInsertNote(lang) {
|
||||
window.Asc.scope.lang = lang
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const newParagraph = Api.CreateParagraph();
|
||||
const oTableCell = newParagraph.GetParentTableCell();
|
||||
const elementsCount = oTableCell.GetContent().GetElementsCount();
|
||||
let noteNumLevel = null;
|
||||
for (let i = 0; i < elementsCount; i++) {
|
||||
if (noteNumLevel) { break; }
|
||||
const ele = oTableCell.GetContent().GetElement(i);
|
||||
if (ele && ele.GetClassType() === 'paragraph' && ele.GetNumbering()) {
|
||||
const contentControls = ele.GetAllContentControls();
|
||||
for (let j = 0; j < contentControls.length; j++) {
|
||||
if (contentControls[j] && contentControls[j].GetAlias() === 'smtc.note') {
|
||||
noteNumLevel = ele.GetNumbering();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (noteNumLevel) {
|
||||
const sFormatString = Asc.scope.lang === 'CN' ? '注%1:' : 'Note%1:'
|
||||
noteNumLevel.SetCustomType('decimal', sFormatString, 'left')
|
||||
} else {
|
||||
const oNumbering = oDocument.CreateNumbering('numbered')
|
||||
noteNumLevel = oNumbering.GetLevel(0)
|
||||
const sFormatString = Asc.scope.lang === 'CN' ? '注:' : 'Note:'
|
||||
noteNumLevel.SetCustomType('decimal', sFormatString, 'left')
|
||||
noteNumLevel.SetSuff('space')
|
||||
}
|
||||
|
||||
const oParagraphNote = Api.CreateParagraph();
|
||||
const oInlineLvlSdtNote = Api.CreateInlineLvlSdt();
|
||||
oInlineLvlSdtNote.SetAlias("smtc.note");
|
||||
oParagraphNote.AddInlineLvlSdt(oInlineLvlSdtNote);
|
||||
oParagraphNote.AddText('XXX');
|
||||
oParagraphNote.SetNumbering(noteNumLevel);
|
||||
oParagraphNote.SetContextualSpacing(true);
|
||||
oParagraphNote.SetFontSize(18);
|
||||
if (Asc.scope.lang === 'CN') {
|
||||
oParagraphNote.SetFontFamily('Arial');
|
||||
} else {
|
||||
oParagraphNote.SetFontFamily('SimSun');
|
||||
}
|
||||
oParagraphNote.SetSpacingAfter(60);
|
||||
oTableCell.AddElement(oTableCell.GetContent().GetElementsCount() - 1, oParagraphNote);
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
// 插入多个注释
|
||||
handleInsertMultNote(lang) {
|
||||
window.Asc.scope.lang = lang
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
const sFormatString = Asc.scope.lang === 'CN' ? '注%1:' : 'Note%1:'
|
||||
oNumLvl.SetCustomType('decimal', sFormatString, 'left')
|
||||
oNumLvl.SetSuff('space')
|
||||
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
||||
const oParagraphNote = Api.CreateParagraph()
|
||||
const oInlineLvlSdt = Api.CreateInlineLvlSdt();
|
||||
oInlineLvlSdt.SetAlias("smtc.note");
|
||||
oParagraphNote.AddInlineLvlSdt(oInlineLvlSdt);
|
||||
if (Asc.scope.lang === 'CN') {
|
||||
oParagraphNote.AddText('XXXXXX')
|
||||
} else {
|
||||
oParagraphNote.AddText('XXXXXX.')
|
||||
}
|
||||
oParagraphNote.SetNumbering(oNumLvl)
|
||||
oParagraphNote.SetContextualSpacing(true)
|
||||
oParagraphNote.SetFontSize(18);
|
||||
if (Asc.scope.lang === 'CN') {
|
||||
oParagraphNote.SetFontFamily('Arial');
|
||||
} else {
|
||||
oParagraphNote.SetFontFamily('SimSun');
|
||||
}
|
||||
oParagraphNote.SetSpacingAfter(60);
|
||||
oDocument.InsertContent([oParagraphNote]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
handleInsertNoteOne(){
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimalZero', "注:", "left")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
oParaPr.SetSpacingLine(280, "auto");
|
||||
oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertMultNotTwo(){
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
for (let index = 0; index < allElement; index++) {
|
||||
const element = oDocument.GetElement(index)
|
||||
if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingBefore()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 50) {
|
||||
currentNumbering = getNumbering
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
const sFormatString = '注 %1:';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
}
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
// oParagraph.SetSpacingLine(400, "auto");
|
||||
var oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetSpacingLine(280, "auto");
|
||||
oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetJc("left");
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertMultNoteThe(){
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimal', "注 %1:", "left")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
oParaPr.SetSpacingLine(280, "auto");
|
||||
oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontSize(21)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,103 @@
|
||||
<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>
|
||||
@@ -0,0 +1,280 @@
|
||||
<template>
|
||||
<div class="example">
|
||||
<a-button-group style="margin-bottom: 10px;">
|
||||
<a-button @click="handleInsertExampleOne()">例</a-button>
|
||||
<a-button @click="handleInsertExampleTwo()">例X</a-button>
|
||||
<a-button @click="handleInsertExampleThe()">首例</a-button>
|
||||
<!-- <a-button @click="handleInsertExample('CN')">插入单个示例(中文)</a-button>-->
|
||||
<!-- <a-button @click="handleInsertMultExample('CN')">插入多个示例(中文)</a-button>-->
|
||||
</a-button-group>
|
||||
<a-button-group>
|
||||
<!-- <a-button @click="handleInsertExample('EN')">插入单个示例(English)</a-button>-->
|
||||
<!-- <a-button @click="handleInsertMultExample('EN')">插入多个示例(English)</a-button>-->
|
||||
</a-button-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
// 插入单个示例
|
||||
handleInsertExample(lang) {
|
||||
window.Asc.scope.lang = lang
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
// const oParagraph = oDocument.Document.GetCurrentParagraph(
|
||||
// undefined,
|
||||
// undefined,
|
||||
// { CheckDocContent: true }
|
||||
// );
|
||||
const newParagraph = Api.CreateParagraph();
|
||||
// newParagraph.SetParagraphWx(oParagraph);
|
||||
const oTableCell = newParagraph.GetParentTableCell();
|
||||
console.log(oTableCell);
|
||||
const elementsCount = oTableCell.GetContent().GetElementsCount();
|
||||
console.log(elementsCount);
|
||||
let exampleNumLevel = null;
|
||||
for (let i = 0; i < elementsCount; i++) {
|
||||
const ele = oTableCell.GetContent().GetElement(i);
|
||||
if (ele && ele.GetClassType() === 'paragraph' && ele.GetNumbering()) {
|
||||
const contentControls = ele.GetAllContentControls();
|
||||
if (contentControls && contentControls.length) {
|
||||
for (let j = 0; j < contentControls.length; j++) {
|
||||
if (contentControls[j] && contentControls[j].GetAlias() === 'smtc.example') {
|
||||
exampleNumLevel = ele.GetNumbering();
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exampleNumLevel) {
|
||||
const sFormatString = Asc.scope.lang === 'CN' ? '例%1:' : 'Example%1:'
|
||||
exampleNumLevel.SetCustomType('decimal', sFormatString, 'left')
|
||||
} else {
|
||||
const oNumbering = oDocument.CreateNumbering('numbered')
|
||||
exampleNumLevel = oNumbering.GetLevel(0)
|
||||
const sFormatString = Asc.scope.lang === 'CN' ? '例:' : 'Example:'
|
||||
exampleNumLevel.SetCustomType('decimal', sFormatString, 'left')
|
||||
exampleNumLevel.SetSuff('space')
|
||||
}
|
||||
|
||||
const oParagraphExample = Api.CreateParagraph();
|
||||
const oInlineLvlSdt = Api.CreateInlineLvlSdt();
|
||||
oInlineLvlSdt.SetAlias("smtc.example");
|
||||
oParagraphExample.AddInlineLvlSdt(oInlineLvlSdt);
|
||||
oParagraphExample.AddText('XXX');
|
||||
oParagraphExample.SetNumbering(exampleNumLevel);
|
||||
oParagraphExample.SetContextualSpacing(true);
|
||||
oParagraphExample.SetFontSize(18);
|
||||
if (Asc.scope.lang === 'CN') {
|
||||
oParagraphExample.SetFontFamily('Arial');
|
||||
} else {
|
||||
oParagraphExample.SetFontFamily('SimSun');
|
||||
}
|
||||
oParagraphExample.SetSpacingAfter(60);
|
||||
oTableCell.AddElement(oTableCell.GetContent().GetElementsCount() - 1, oParagraphExample);
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
// 插入多个示例
|
||||
handleInsertMultExample(lang) {
|
||||
window.Asc.scope.lang = lang
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
const sFormatString = Asc.scope.lang === 'CN' ? '例%1:' : 'Example%1:'
|
||||
oNumLvl.SetCustomType('decimal', sFormatString, 'left')
|
||||
oNumLvl.SetSuff('space')
|
||||
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
||||
const oParagraphExample = Api.CreateParagraph()
|
||||
const oInlineLvlSdt = Api.CreateInlineLvlSdt();
|
||||
oInlineLvlSdt.SetAlias("smtc.example");
|
||||
oParagraphExample.AddInlineLvlSdt(oInlineLvlSdt);
|
||||
if (Asc.scope.lang === 'CN') {
|
||||
oParagraphExample.AddText('XXXXXX')
|
||||
} else {
|
||||
oParagraphExample.AddText('XXXXXX.')
|
||||
}
|
||||
oParagraphExample.SetNumbering(oNumLvl)
|
||||
oParagraphExample.SetContextualSpacing(true)
|
||||
oParagraphExample.SetFontSize(18);
|
||||
if (Asc.scope.lang === 'CN') {
|
||||
oParagraphExample.SetFontFamily('Arial');
|
||||
} else {
|
||||
oParagraphExample.SetFontFamily('SimSun');
|
||||
}
|
||||
oParagraphExample.SetSpacingAfter(60);
|
||||
oDocument.InsertContent([oParagraphExample]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertExampleOne(){
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimalZero', "示例: ", "right")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
var textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
// oParaPr.SetJc("both");
|
||||
textPr.SetFontSize(18)
|
||||
textPr.SetBold(false)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetIndLeft(1040);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertExampleTwo(){
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
for (let index = 0; index < allElement; index++) {
|
||||
const element = oDocument.GetElement(index)
|
||||
if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingBefore()
|
||||
if (text == 51) {
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
const sFormatString = '示例%1:';
|
||||
numbering.SetCustomType("decimal", sFormatString, "right");
|
||||
numbering.SetSuff("space");
|
||||
}
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
// oParagraph.SetSpacingLine(400, "auto");
|
||||
var oParaPr = numbering.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("left");
|
||||
oParaPr.SetIndFirstLine(-86)
|
||||
var textPr = numbering.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
|
||||
oParagraph.SetSpacingBefore(51)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetJc("left");
|
||||
oParagraph.SetIndLeft(1040);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertExampleThe(){
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimal', "示例%1:", "right")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86)
|
||||
// oParaPr.SetIndFirstLine(0);
|
||||
var textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(51)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetIndLeft(1040);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<a-upload
|
||||
name="file"
|
||||
:customRequest="uploadFile"
|
||||
:showUploadList="false"
|
||||
>
|
||||
<a-button> <a-icon type="upload" /> 附件上传 </a-button>
|
||||
</a-upload>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _axios from "@/plugins/axios2";
|
||||
import pxConversionMm from "../common/unitConversion";
|
||||
export default {
|
||||
name: "SaicFile",
|
||||
methods: {
|
||||
uploadFile(fileObj) {
|
||||
let { file } = fileObj;
|
||||
const _data = new FormData();
|
||||
_data.append("file", file);
|
||||
_axios({
|
||||
url: this.uploadFilePath,
|
||||
method: "post",
|
||||
data: _data,
|
||||
})
|
||||
.then((res) => {
|
||||
this.loading = false;
|
||||
Asc.scope.fileName = res.data.oldFileName;
|
||||
Asc.scope.attId = res.data.attId;
|
||||
Asc.scope.fileSuffix = res.data.fileSuffix;
|
||||
Asc.scope.filePath = this.staticFilePath + res.data.filePath + res.data.fileName;
|
||||
window.Asc.scope.fileIcon = {
|
||||
width: pxConversionMm(128),
|
||||
height: pxConversionMm(171),
|
||||
};
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const oParagraph = oDocument.Document.GetCurrentParagraph(
|
||||
undefined,
|
||||
undefined,
|
||||
{ CheckDocContent: true }
|
||||
);
|
||||
const newParagraph = Api.CreateParagraph();
|
||||
newParagraph.SetParagraphWx(oParagraph);
|
||||
const oTableCell = newParagraph.GetParentTableCell();
|
||||
|
||||
const fileIconParagraph = Api.CreateParagraph();
|
||||
let standIcon = '';
|
||||
switch (Asc.scope.fileSuffix) {
|
||||
case 'xlsx':
|
||||
case 'xls':
|
||||
standIcon = 'excel'
|
||||
break
|
||||
case 'docx':
|
||||
case 'doc':
|
||||
standIcon = 'word'
|
||||
break
|
||||
case 'txt':
|
||||
standIcon = 'txt'
|
||||
break
|
||||
case 'pdf':
|
||||
standIcon = 'pdf'
|
||||
break
|
||||
case 'rar':
|
||||
case 'zip':
|
||||
standIcon = 'ziprar'
|
||||
break
|
||||
default:
|
||||
standIcon = 'video'
|
||||
break
|
||||
}
|
||||
const oDrawing = Api.CreateImage(
|
||||
`http://39.98.140.126:10005/uploadPath/standIcon/${standIcon}.png`,
|
||||
Asc.scope.fileIcon.width / 3 * 36000,
|
||||
Asc.scope.fileIcon.height / 3 * 36000
|
||||
);
|
||||
fileIconParagraph.AddDrawing(oDrawing);
|
||||
fileIconParagraph.SetJc("center");
|
||||
|
||||
const fileNameParagraph = Api.CreateParagraph();
|
||||
fileNameParagraph.SetJc("center");
|
||||
fileNameParagraph.AddText(Asc.scope.fileName);
|
||||
const filePath = `http://39.98.140.126:10005/api/att/attFile/downloadFileForSar?fileId=${Asc.scope.attId}`;
|
||||
fileNameParagraph.AddHyperlink(filePath, "附件下载");
|
||||
|
||||
oTableCell.AddElement(0, fileIconParagraph);
|
||||
oTableCell.AddElement(1, fileNameParagraph);
|
||||
} catch(e) {}
|
||||
})
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<a-button-group>
|
||||
<!-- <a-button @click="handleInsertEquation">插入方程式</a-button> -->
|
||||
<a-button @click="handleInsertSymbol">插入符号</a-button>
|
||||
<a-button @click="equationClick">方程式编号</a-button>
|
||||
</a-button-group>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SaicFunc',
|
||||
data(){
|
||||
return{
|
||||
numData: {
|
||||
1: 'A',
|
||||
2: 'B',
|
||||
3: 'C',
|
||||
4: 'D',
|
||||
5: 'E',
|
||||
6: 'F',
|
||||
7: 'G',
|
||||
8: 'H',
|
||||
9: 'I',
|
||||
10: 'J',
|
||||
11: 'K',
|
||||
12: 'L',
|
||||
13: 'M',
|
||||
14: 'N',
|
||||
15: 'O',
|
||||
16: 'P',
|
||||
17: 'Q',
|
||||
18: 'R',
|
||||
19: 'S',
|
||||
20: 'T',
|
||||
21: 'U',
|
||||
22: 'V',
|
||||
23: 'W',
|
||||
24: 'X',
|
||||
25: 'Y',
|
||||
26: 'Z'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 插入方程式
|
||||
handleInsertEquation() {
|
||||
this.ctx.callCommand(() => {
|
||||
console.log(DE.controllers.Toolbar)
|
||||
// DE.controllers.Toolbar.onInsertEquationClick();
|
||||
})
|
||||
},
|
||||
equationClick() {
|
||||
// this.isTrue = !this.isTrue
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const oParagraph = Api.CreateParagraph();
|
||||
oDocument.InsertContent([oParagraph]);
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
let table
|
||||
let SpacingBefore
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
} else if (element.GetTableDescription() == 'Empty table') {
|
||||
let number = element.GetCell(0, 1).GetContent().GetElement(0);
|
||||
const getNumbering = number.GetNumbering()
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
if (table) {
|
||||
let number = table.GetCell(0, 0).GetContent().GetElement(1);
|
||||
SpacingBefore = number.GetSpacingBefore();
|
||||
}
|
||||
let Previous = oParagraph.GetPrevious()
|
||||
// Previous.Delete()
|
||||
if (Previous) {
|
||||
Previous.SetJc('right')
|
||||
var oParagraph2 = Previous.Copy();
|
||||
const oTable = Api.CreateTable(2, 1);
|
||||
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", 0, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderBottom("single", 0, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderLeft("single", 0, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderRight("single", 0, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderInsideV("single", 0, 0, 255, 255, 255);
|
||||
oTable.SetTableBorderInsideH("single", 0, 0, 255, 255, 255);
|
||||
oTable.SetTableDescription("Empty table");
|
||||
oDocument.InsertContent([oTable]);
|
||||
const oCell = oTable.GetRow(0).GetCell(0);
|
||||
const oCell1 = oTable.GetRow(0).GetCell(1);
|
||||
const oParagraph1 = Api.CreateParagraph();
|
||||
if (SpacingBefore) {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
} else if (element.GetTableDescription() == 'Empty table') {
|
||||
let number = element.GetCell(0, 1).GetContent().GetElement(0);
|
||||
const getNumbering = number.GetNumbering()
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
oNumLvl = oNumbering.GetLevel(0)
|
||||
const sFormatString = "..................(" + Asc.scope.numData[SpacingBefore] + ".%1)";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "left");
|
||||
}
|
||||
} else {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
} else if (element.GetTableDescription() == 'Empty table') {
|
||||
let number = element.GetCell(0, 1).GetContent().GetElement(0);
|
||||
const getNumbering = number.GetNumbering()
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
oNumLvl = oNumbering.GetLevel(0)
|
||||
const sFormatString = "..................(%1)";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "left");
|
||||
}
|
||||
}
|
||||
const paraPr = oNumLvl.GetParaPr()
|
||||
paraPr.SetJc('right')
|
||||
const textPr = oNumLvl.GetTextPr()
|
||||
textPr.SetVertAlign('baseline')
|
||||
textPr.SetSmallCaps(false);
|
||||
textPr.SetFontSize(21);
|
||||
textPr.SetFontFamily("黑体");
|
||||
oParagraph1.SetNumbering(oNumLvl)
|
||||
oParagraph2.GetParaPr().SetJc('right')
|
||||
oParagraph2.AddText(' ')
|
||||
oParagraph2.SetSpacingAfter(10)
|
||||
oParagraph2.SetSpacingBefore(9)
|
||||
oCell.AddElement(0, oParagraph2)
|
||||
oCell1.AddElement(0, oParagraph1)
|
||||
oCell.GetContent().GetElement(0).GetParaPr().SetJc('right')
|
||||
oCell.GetContent().GetElement(0).GetParaPr().SetIndRight(800)
|
||||
// let text = oCell.GetContent().GetElement(0).GetText()
|
||||
// if (text){
|
||||
// let aSearch = oCell.GetContent().GetElement(0).Search(text);
|
||||
// if (aSearch && aSearch.length > 0){
|
||||
// aSearch[0].SetFontFamily('宋体')
|
||||
// aSearch[0].SetFontSize(10.5)
|
||||
// }
|
||||
// }
|
||||
oCell.SetWidth("percent", 130);
|
||||
oCell1.SetWidth("percent", 65);
|
||||
oCell.SetVerticalAlign("center");
|
||||
oCell1.SetVerticalAlign("center");
|
||||
oCell.GetContent().GetElement(1).Delete()
|
||||
oCell1.GetContent().GetElement(1).Delete()
|
||||
}
|
||||
Previous.Delete()
|
||||
oParagraph.Delete()
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
})
|
||||
},
|
||||
// 插入符号
|
||||
handleInsertSymbol() {
|
||||
this.ctx.callCommand(() => {
|
||||
DE.controllers.Toolbar.onInsertSymbolClick();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,323 @@
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<a-button-group>
|
||||
<a-button @click="openImageDialog">插入图片</a-button>
|
||||
</a-button-group>
|
||||
|
||||
<a-modal
|
||||
v-model="visible"
|
||||
title="插入图片"
|
||||
@ok="handleOk"
|
||||
class="img-dialog"
|
||||
>
|
||||
<a-form-model
|
||||
id="components-form-demo-validate-other"
|
||||
:model="form"
|
||||
v-bind="formItemLayout"
|
||||
@submit="handleSubmit"
|
||||
>
|
||||
<a-form-item label="标题">
|
||||
<a-input v-model="form.title" placeholder="请输入标题" />
|
||||
</a-form-item>
|
||||
<a-form-item label="图片大小">
|
||||
<a-radio-group :options="plainOptions" v-model="form.size" />
|
||||
</a-form-item>
|
||||
<a-form-item label="图片">
|
||||
<a-upload
|
||||
ref="upload"
|
||||
name="file"
|
||||
list-type="picture-card"
|
||||
class="avatar-uploader"
|
||||
:show-upload-list="false"
|
||||
action="api/att/attFile/upload"
|
||||
:before-upload="beforeUpload"
|
||||
:customRequest="uploadFile"
|
||||
@change="handleChange"
|
||||
v-decorator="[
|
||||
'file',
|
||||
{
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请上传图片',
|
||||
},
|
||||
],
|
||||
},
|
||||
]"
|
||||
>
|
||||
<img
|
||||
ref="myImg"
|
||||
v-if="imageUrl"
|
||||
:src="imageUrl"
|
||||
style="width: 300px; height: 300px"
|
||||
/>
|
||||
<div v-else>
|
||||
<a-icon :type="loading ? 'loading' : 'plus'" />
|
||||
<div class="ant-upload-text">Upload</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
</a-form-model>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _axios from "@/plugins/axios2";
|
||||
import pxConversionMm from "../common/unitConversion";
|
||||
const plainOptions = ["原图", "小", "中", "大"];
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
formItemLayout: {
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 14 },
|
||||
},
|
||||
plainOptions,
|
||||
loading: false,
|
||||
imageUrl: "",
|
||||
form: {
|
||||
title: "",
|
||||
size: "中",
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
openImageDialog() {
|
||||
this.visible = true;
|
||||
},
|
||||
|
||||
handleChange(info) {
|
||||
if (info.file.status === "uploading") {
|
||||
this.loading = true;
|
||||
return;
|
||||
}
|
||||
if (info.file.status === "done") {
|
||||
// Get this url from response in real world.
|
||||
getBase64(info.file.originFileObj, (imageUrl) => {
|
||||
this.imageUrl = imageUrl;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
beforeUpload(file) {
|
||||
const isJpgOrPng =
|
||||
file.type === "image/jpeg" || file.type === "image/png";
|
||||
if (!isJpgOrPng) {
|
||||
this.$message.error("You can only upload JPG file!");
|
||||
}
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
if (!isLt2M) {
|
||||
this.$message.error("Image must smaller than 2MB!");
|
||||
}
|
||||
return isJpgOrPng && isLt2M;
|
||||
},
|
||||
|
||||
uploadFile(fileObj) {
|
||||
let { file } = fileObj;
|
||||
const _data = new FormData();
|
||||
var renameReportFile = new File([file], "新名称.jpg", {
|
||||
type: file.type,
|
||||
});
|
||||
_data.append("file", renameReportFile);
|
||||
_axios({
|
||||
url: this.uploadFilePath,
|
||||
method: "post",
|
||||
data: _data,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
this.loading = false;
|
||||
this.imageUrl =
|
||||
this.staticFilePath + res.data.filePath + res.data.fileName;
|
||||
const img = new Image();
|
||||
img.src = this.staticFilePath + res.data.filePath + res.data.fileName;
|
||||
if (img.complete) {
|
||||
this.imgOrigin = {
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
};
|
||||
} else {
|
||||
img.onload = () => {
|
||||
this.imgOrigin = {
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
};
|
||||
};
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
handleSubmit() {
|
||||
this.visible = false;
|
||||
},
|
||||
|
||||
handleOk() {
|
||||
this.visible = false;
|
||||
window.Asc.scope.imageUrl = this.imageUrl;
|
||||
window.Asc.scope.title = this.form.title;
|
||||
window.Asc.scope.imgSize = this.form.size;
|
||||
const width = pxConversionMm(this.imgOrigin.width);
|
||||
const height = pxConversionMm(this.imgOrigin.height);
|
||||
window.Asc.scope.imgOrigin = {
|
||||
width,
|
||||
height,
|
||||
};
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
oDocument = Api.GetDocument();
|
||||
var oNumbering, oNumLvl;
|
||||
// const AllElementCount = oDocument.GetElementsCount();
|
||||
const AllImages = oDocument.GetAllImages();
|
||||
for (let i = 0; i < AllImages.length; i++) {
|
||||
const ParentCellContent = AllImages[i]
|
||||
.GetParentTableCell()
|
||||
.GetContent();
|
||||
for (let j = 0; j < ParentCellContent.GetElementsCount(); j++) {
|
||||
// 找到paragraph
|
||||
const Element = ParentCellContent.GetElement(j);
|
||||
if ("paragraph" === Element.GetClassType()) {
|
||||
if (Element.GetAllContentControls().length > 0) {
|
||||
for (
|
||||
let k = 0;
|
||||
k < Element.GetAllContentControls().length;
|
||||
k++
|
||||
) {
|
||||
if (
|
||||
Element.GetAllContentControls()[k].GetAlias() ===
|
||||
"smtc.img"
|
||||
) {
|
||||
const getNumbering = Element.GetNumbering();
|
||||
// 找到编号段落
|
||||
if (getNumbering) {
|
||||
// 无论有没有一级列项,都把numbering存起来,后边如果没有找到一级列项,就get一级
|
||||
oNumbering = getNumbering;
|
||||
// 找到一级列项
|
||||
if (getNumbering.GetLevelIndex() === 0) {
|
||||
oNumLvl = getNumbering;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imgOParagraph = Api.CreateParagraph();
|
||||
let imgSize = {
|
||||
width: 0,
|
||||
height: 0,
|
||||
};
|
||||
switch (Asc.scope.imgSize) {
|
||||
case "原图":
|
||||
imgSize.width = Asc.scope.imgOrigin.width;
|
||||
imgSize.height = Asc.scope.imgOrigin.height;
|
||||
break;
|
||||
case "小":
|
||||
imgSize.width = 165 / 3;
|
||||
imgSize.height = 89.3 / 3;
|
||||
break;
|
||||
case "中":
|
||||
imgSize.width = 165 / 2;
|
||||
imgSize.height = 89.3 / 2;
|
||||
break;
|
||||
case "大":
|
||||
imgSize.width = 165;
|
||||
imgSize.height = 89.3;
|
||||
break;
|
||||
}
|
||||
oDrawing = Api.CreateImage(
|
||||
Asc.scope.imageUrl,
|
||||
imgSize.width * 36000,
|
||||
imgSize.height * 36000
|
||||
);
|
||||
imgOParagraph.AddLineBreak();
|
||||
imgOParagraph.AddDrawing(oDrawing);
|
||||
if (!oNumbering) {
|
||||
oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
}
|
||||
imgText = Api.CreateParagraph();
|
||||
const sFormatString = "图%1.";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "left");
|
||||
oInlineLvlSdt = Api.CreateInlineLvlSdt();
|
||||
|
||||
imgText.SetNumbering(oNumLvl);
|
||||
imgText.AddText(`${Asc.scope.title}`);
|
||||
imgText.SetFontSize(21);
|
||||
imgText.SetFontFamily("SimHei");
|
||||
imgText.SetContextualSpacing(true);
|
||||
imgText.SetJc("center");
|
||||
|
||||
oInlineLvlSdt.SetAlias("smtc.img");
|
||||
imgText.AddInlineLvlSdt(oInlineLvlSdt);
|
||||
imgOParagraph.SetJc("center");
|
||||
imgOParagraph.SetSmallCaps(true);
|
||||
oDocument.InsertContent([imgOParagraph]);
|
||||
oDocument.InsertContent([imgText]);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.avatar-uploader > .ant-upload {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
}
|
||||
.ant-upload-select-picture-card i {
|
||||
font-size: 32px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.ant-upload-select-picture-card .ant-upload-text {
|
||||
margin-top: 8px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.upload-box {
|
||||
& > div {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
margin-right: 8px;
|
||||
margin-bottom: 8px;
|
||||
text-align: center;
|
||||
vertical-align: top;
|
||||
background-color: #fafafa;
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.3s ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
&:hover {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
.anticon-plus {
|
||||
font-size: 32px;
|
||||
color: #999 !important;
|
||||
display: inline-block;
|
||||
color: inherit;
|
||||
font-style: normal;
|
||||
line-height: 0;
|
||||
text-align: center;
|
||||
text-transform: none;
|
||||
vertical-align: -0.125em;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,791 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-button-group style="margin-bottom: 10px">
|
||||
<a-button @click="handleInsertName">表题</a-button>
|
||||
<a-button @click="handleInsertTableClick(1)">插入表格</a-button>
|
||||
<a-button @click="handleInsertNoteFou">表格脚注</a-button>
|
||||
</a-button-group>
|
||||
<a-button-group style="margin-bottom: 10px">
|
||||
<a-button @click="handleInsertNoteThe">表格注</a-button>
|
||||
<a-button @click="handleInsertNoteOne">表格注X</a-button>
|
||||
<a-button @click="handleInsertNoteTwo">表格首注</a-button>
|
||||
</a-button-group>
|
||||
<a-modal v-model="visible" title="插入表格" @ok="handleOk">
|
||||
<a-form-model
|
||||
id="components-form-demo-validate-other"
|
||||
:model="form"
|
||||
v-bind="formItemLayout"
|
||||
@submit="handleSubmit"
|
||||
>
|
||||
<a-form-item label="行数">
|
||||
<a-input
|
||||
v-model="form.rows"
|
||||
placeholder="请输入行数"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="列数">
|
||||
<a-input
|
||||
v-model="form.column"
|
||||
placeholder="请输入列数"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form-model>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "SaicTable",
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
formItemLayout: {
|
||||
labelCol: {span: 6},
|
||||
wrapperCol: {span: 14},
|
||||
},
|
||||
loading: false,
|
||||
imageUrl: '',
|
||||
form: {
|
||||
title: '',
|
||||
size: '中'
|
||||
},
|
||||
numData: {
|
||||
1: 'A',
|
||||
2: 'B',
|
||||
3: 'C',
|
||||
4: 'D',
|
||||
5: 'E',
|
||||
6: 'F',
|
||||
7: 'G',
|
||||
8: 'H',
|
||||
9: 'I',
|
||||
10: 'J',
|
||||
11: 'K',
|
||||
12: 'L',
|
||||
13: 'M',
|
||||
14: 'N',
|
||||
15: 'O',
|
||||
16: 'P',
|
||||
17: 'Q',
|
||||
18: 'R',
|
||||
19: 'S',
|
||||
20: 'T',
|
||||
21: 'U',
|
||||
22: 'V',
|
||||
23: 'W',
|
||||
24: 'X',
|
||||
25: 'Y',
|
||||
26: 'Z'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSubmit() {
|
||||
this.visible = false
|
||||
},
|
||||
handleOk() {
|
||||
this.handleInsertTable(this.form)
|
||||
},
|
||||
handleInsertTableClick(){
|
||||
this.visible = true
|
||||
this.form = {
|
||||
rows:7,
|
||||
column:4,
|
||||
}
|
||||
},
|
||||
// 插入表格含题注
|
||||
handleInsertTable(data) {
|
||||
Asc.scope.rows = data.rows
|
||||
Asc.scope.column = data.column
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const oTable = Api.CreateTable(Asc.scope.column,Asc.scope.rows);
|
||||
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", 9, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderLeft("single", 9, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderRight("single", 9, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderInsideV("single", 6, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderInsideH("single", 6, 0, 0, 0, 0);
|
||||
const oRowsCount = oTable.GetRowsCount();
|
||||
oTable.SetTableDescription("tableOp");
|
||||
oDocument.InsertContent([oTable]);
|
||||
for (let i = 0; i < oRowsCount; i++) {
|
||||
const oCellsCount = oTable.GetRow(i).GetCellsCount();
|
||||
for (let j = 0; j < oCellsCount; j++) {
|
||||
const cellEle = oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElement(0);
|
||||
cellEle.SetSpacingAfter(10)
|
||||
cellEle.SetFontSize(18)
|
||||
cellEle.SetColor(0, 0, 0);
|
||||
// if (i === 0) {
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderTop("single", 0, 0, 255, 255, 255);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderRight("single", 0, 0, 255, 255, 255);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderBottom("single", 0, 0, 255, 255, 255);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderLeft("single", 0, 0, 255, 255, 255);
|
||||
// // cellEle.SetFontFamily("宋体");
|
||||
// } else
|
||||
// 表头
|
||||
if (i === 0) {
|
||||
oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.SetCellBorderTop("single", 9, 0, 0, 0, 0);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderRight("single", 6, 0, 0, 0, 0);
|
||||
oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderLeft("single", 6, 0, 0, 0, 0);
|
||||
// cellEle.SetFontFamily("宋体");
|
||||
} else if (i === oRowsCount - 2) {
|
||||
oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
||||
} else {
|
||||
// cellEle.SetFontFamily("宋体");
|
||||
}
|
||||
cellEle.SetFontSize(18);
|
||||
}
|
||||
}
|
||||
|
||||
// const oParagraph = oDocument.Document.GetCurrentParagraph(
|
||||
// undefined,
|
||||
// undefined,
|
||||
// { CheckDocContent: true }
|
||||
// );
|
||||
// const newParagraph = Api.CreateParagraph();
|
||||
// newParagraph.SetParagraphWx(oParagraph);
|
||||
// var oRow = oTable.GetRow(0);
|
||||
// oRow.MergeCells();
|
||||
// const oCell = oTable.GetRow(0).GetCell(0);
|
||||
// const oInlineLvlSdt = Api.CreateInlineLvlSdt();
|
||||
// oInlineLvlSdt.SetAlias("smtc.table");
|
||||
|
||||
// let oNumbering = null,
|
||||
// oNumLvl = null;
|
||||
//
|
||||
// // 获取全部控件,找到smtc.table,从而得到编号
|
||||
// const AllControl = oDocument.GetAllContentControls();
|
||||
// for (let i = 0; i < AllControl.length; i++) {
|
||||
// if (AllControl[i].GetAlias() === "smtc.table") {
|
||||
// const tableContent = AllControl[i]
|
||||
// .GetElement(0)
|
||||
// .GetParentTableCell()
|
||||
// .GetContent();
|
||||
// const count = tableContent.GetElementsCount();
|
||||
// for (let j = 0; j < count; j++) {
|
||||
// const ele = tableContent.GetElement(j);
|
||||
// if (
|
||||
// ele &&
|
||||
// ele.GetClassType() === "paragraph" &&
|
||||
// ele.GetNumbering() &&
|
||||
// ele.GetNumbering().GetLevelIndex() === 0
|
||||
// ) {
|
||||
// oNumLvl = ele.GetNumbering();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!oNumLvl) {
|
||||
// oNumbering = oDocument.CreateNumbering("numbered");
|
||||
// oNumLvl = oNumbering.GetLevel(0);
|
||||
// const sFormatString = "表 %1 ";
|
||||
// oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
// }
|
||||
// var textPr = oNumLvl.GetTextPr();
|
||||
// textPr.SetFontFamily("黑体");
|
||||
// textPr.SetFontSize(21)
|
||||
// const CNParagraph = Api.CreateParagraph();
|
||||
// CNParagraph.SetJc("center");
|
||||
// CNParagraph.AddText("企业技术标准类别及代号");
|
||||
// CNParagraph.SetFontSize(21);
|
||||
// CNParagraph.SetFontFamily("黑体");
|
||||
// CNParagraph.SetSpacingAfter(0)
|
||||
// CNParagraph.AddInlineLvlSdt(oInlineLvlSdt);
|
||||
// CNParagraph.SetNumbering(oNumLvl);
|
||||
// oCell.AddElement(1, CNParagraph);
|
||||
// 获取编号文本
|
||||
// const tableNum = CNParagraph.Paragraph.GetNumberingText();
|
||||
|
||||
// const Unit = Api.CreateParagraph();
|
||||
// Unit.SetJc("right");
|
||||
// const UnitCN = Api.CreateRun();
|
||||
// UnitCN.AddText("单位为XXX");
|
||||
// UnitCN.SetFontSize(21);
|
||||
// UnitCN.SetFontFamily("SimHei");
|
||||
// Unit.AddElement(UnitCN);
|
||||
// oCell.AddElement(1, Unit);
|
||||
// oCell.AddElement(2, oTable);
|
||||
|
||||
// 表格注
|
||||
const oLastRow = oTable.GetRow(oTable.GetRowsCount() - 1);
|
||||
oLastRow.MergeCells();
|
||||
oLastRow.SetHeight("atLeast", 540);
|
||||
|
||||
// const noteNumbering = oDocument.CreateNumbering("numbered");
|
||||
// const noteNumLevel = noteNumbering.GetLevel(0);
|
||||
// const sFormatString = "注%1:";
|
||||
// noteNumLevel.SetCustomType("decimal", sFormatString, "center");
|
||||
// for (let i = 0; i < 3; i++) {
|
||||
// const noteParagraph = Api.CreateParagraph();
|
||||
// noteParagraph.SetNumbering(noteNumLevel);
|
||||
// noteParagraph.AddText("XXX");
|
||||
// noteParagraph.SetSpacingAfter(10);
|
||||
// noteParagraph.SetFontFamily('宋体')
|
||||
// noteParagraph.SetFontSize(23)
|
||||
// noteParagraph.SetColor(49, 36, 19);
|
||||
// if (i > 0) {
|
||||
// oLastRow.GetCell(0).AddElement(i * 2, noteParagraph);
|
||||
// } else {
|
||||
// oLastRow.GetCell(0).AddElement(0, noteParagraph);
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}, false);
|
||||
this.visible = false
|
||||
},
|
||||
|
||||
// 插入表格注
|
||||
handleInsertNote() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const newParagraph = Api.CreateParagraph();
|
||||
const oTableCell = newParagraph.GetParentTableCell();
|
||||
console.log(oTableCell);
|
||||
const elementsCount = oTableCell.GetContent().GetElementsCount();
|
||||
let noteNumLevel = null;
|
||||
for (let i = 0; i < elementsCount; i++) {
|
||||
const ele = oTableCell.GetContent().GetElement(i);
|
||||
if (
|
||||
ele &&
|
||||
ele.GetClassType() === "paragraph" &&
|
||||
ele.GetNumbering()
|
||||
) {
|
||||
noteNumLevel = ele.GetNumbering();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!noteNumLevel) {
|
||||
const noteNumbering = oDocument.CreateNumbering("numbered");
|
||||
noteNumLevel = noteNumbering.GetLevel(0);
|
||||
const sFormatString = "注%1:";
|
||||
noteNumLevel.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
|
||||
// 表格中文注
|
||||
var textPr = noteNumLevel.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const noteParagraph = Api.CreateParagraph();
|
||||
noteParagraph.SetNumbering(noteNumLevel);
|
||||
noteParagraph.AddText("XXX");
|
||||
noteParagraph.SetFontSize(18);
|
||||
noteParagraph.SetFontFamily("SimSun");
|
||||
|
||||
if (elementsCount > 0) {
|
||||
oTableCell.AddElement(elementsCount - 1, noteParagraph);
|
||||
} else {
|
||||
oTableCell.AddElement(0, noteParagraph);
|
||||
}
|
||||
|
||||
if (elementsCount > 0) {
|
||||
// oTableCell.AddElement(elementsCount, noteParagraphEN);
|
||||
} else {
|
||||
oTableCell.AddElement(1, noteParagraph);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handleInsertNoteThe() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimalZero', "注:", "right")
|
||||
oNumLvl.SetSuff("space");
|
||||
const oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
const textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetIndLeft(766);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
handleInsertNoteOne() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
for (let index = 0; index < allElement; index++) {
|
||||
const element = oDocument.GetElement(index)
|
||||
if ("table" === element.GetClassType()) {
|
||||
for (let i = 0; i < element.GetRowsCount(); i++) {
|
||||
if (element.GetCell(i, 0).GetContent().GetElement(0)) {
|
||||
const Count = element.GetCell(i, 0).GetContent().GetElementsCount();
|
||||
if (Count > 1) {
|
||||
for (let j = 0; j < Count; j++) {
|
||||
const getNumbering = element.GetCell(i, 0).GetContent().GetElement(j).GetNumbering()
|
||||
const text = element.GetCell(i, 0).GetContent().GetElement(j).GetSpacingBefore()
|
||||
if (text == 50) {
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
const sFormatString = '注%1:';
|
||||
numbering.SetCustomType("decimal", sFormatString, "right");
|
||||
numbering.SetSuff("space");
|
||||
}
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
// oParagraph.SetSpacingLine(400, "auto");
|
||||
const oParaPr = numbering.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
const textPr = numbering.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetIndLeft(856);
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
handleInsertNoteTwo() {
|
||||
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
||||
window.Asc.scope.suffType = ''
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
const oNumLvl = oNumbering.GetLevel(0)
|
||||
oNumLvl.SetCustomType('decimal', "注%1:", "right")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
var textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetIndLeft(856);
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetHighlight(255, 255, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let text = oParagraph.GetText()
|
||||
if (text){
|
||||
let aSearch = oParagraph.Search(text);
|
||||
if (aSearch && aSearch.length > 0){
|
||||
aSearch[0].SetFontFamily('宋体')
|
||||
aSearch[0].SetFontSize(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertName(){
|
||||
Asc.scope.numData = this.numData
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
let table
|
||||
let SpacingBefore
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 33) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
if (table){
|
||||
let number = table.GetCell(0, 0).GetContent().GetElement(1);
|
||||
SpacingBefore = number.GetSpacingBefore();
|
||||
}
|
||||
if (SpacingBefore){
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 33) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = "表"+Asc.scope.numData[SpacingBefore]+".%1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 33) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = "表 %1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
}
|
||||
}
|
||||
const oNewDocumentStyle = oDocument.GetStyle("List Paragraph");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
const textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(21)
|
||||
// const CNParagraph = Api.CreateParagraph();
|
||||
oParagraph.SetJc("center");
|
||||
// oParagraph.AddText("企业技术标准类别及代号");
|
||||
oParagraph.SetFontSize(21);
|
||||
oParagraph.SetStyle(oNewDocumentStyle);
|
||||
oParagraph.SetFontFamily("黑体");
|
||||
oParagraph.SetSpacingAfter(33,false)
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oParagraph.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertNoteFou() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
const parentTable = oParagraph.GetParentTable()
|
||||
if (!parentTable) {
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let table
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'tableOp') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 30) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (table) {
|
||||
const oRowsCount = table.GetRowsCount();
|
||||
for (let i = 0; i < oRowsCount; i++) {
|
||||
const oCellsCount = table.GetRow(i).GetCellsCount();
|
||||
if (i == 0) {
|
||||
|
||||
} else {
|
||||
for (let j = 0; j < oCellsCount; j++) {
|
||||
const cellEle = table
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElementsCount();
|
||||
for (let k = 0; k < cellEle; k++) {
|
||||
const cellEle1 = table
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElement(k);
|
||||
cellEle1.SetFontSize(18)
|
||||
let GetNumbering = cellEle1.GetNumbering()
|
||||
if (GetNumbering) {
|
||||
let spacingAfter = cellEle1.GetSpacingAfter()
|
||||
if (spacingAfter == 30) {
|
||||
currentNumbering = GetNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
}
|
||||
const sFormatString = "%1";
|
||||
oNumLvl.SetCustomType("lowerLetter", sFormatString, "left");
|
||||
oNumLvl.SetSuff("space");
|
||||
const textPr = oNumLvl.GetTextPr()
|
||||
textPr.SetFontSize(18);
|
||||
textPr.SetFontFamily('黑体')
|
||||
textPr.SetSmallCaps(true);
|
||||
textPr.SetVertAlign("superscript");
|
||||
const paraPr = oNumLvl.GetParaPr()
|
||||
paraPr.SetSpacingBefore(0);
|
||||
paraPr.SetJc("left");
|
||||
paraPr.SetIndFirstLine(-150);
|
||||
const oParagraph1 = Api.CreateParagraph()
|
||||
oParagraph1.SetIndLeft(574);
|
||||
oParagraph1.SetNumbering(oNumLvl)
|
||||
oParagraph1.SetSpacingAfter(30)
|
||||
oParagraph1.SetFontSize(18)
|
||||
oDocument.InsertContent([oParagraph1])
|
||||
} else {
|
||||
const oRowsCount = parentTable.GetRowsCount();
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
for (let i = 0; i < oRowsCount; i++) {
|
||||
const oCellsCount = parentTable.GetRow(i).GetCellsCount();
|
||||
if (i == 0) {
|
||||
|
||||
} else {
|
||||
for (let j = 0; j < oCellsCount; j++) {
|
||||
const cellEle = parentTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElementsCount();
|
||||
for (let k = 0; k < cellEle; k++) {
|
||||
const cellEle1 = parentTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElement(k);
|
||||
cellEle1.SetFontSize(18)
|
||||
let GetNumbering = cellEle1.GetNumbering()
|
||||
if (GetNumbering) {
|
||||
let spacingAfter = cellEle1.GetSpacingAfter()
|
||||
if (spacingAfter == 30) {
|
||||
currentNumbering = GetNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!currentNumbering) {
|
||||
let numIndex = parentTable.GetPosInParent();
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
for (let i = numIndex + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'tableOp') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 30) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
|
||||
}
|
||||
const sFormatString = "%1";
|
||||
oNumLvl.SetCustomType("lowerLetter", sFormatString, "left");
|
||||
oNumLvl.SetSuff("space");
|
||||
const textPr = oNumLvl.GetTextPr()
|
||||
textPr.SetFontSize(18);
|
||||
textPr.SetFontFamily('黑体')
|
||||
textPr.SetSmallCaps(true);
|
||||
textPr.SetVertAlign("superscript");
|
||||
const paraPr = oNumLvl.GetParaPr()
|
||||
paraPr.SetSpacingBefore(0);
|
||||
paraPr.SetJc("left");
|
||||
paraPr.SetIndFirstLine(-150);
|
||||
const oParagraph1 = Api.CreateParagraph()
|
||||
oParagraph1.SetIndLeft(586);
|
||||
oParagraph1.SetNumbering(oNumLvl)
|
||||
oParagraph1.SetSpacingAfter(30)
|
||||
oParagraph1.SetFontSize(18)
|
||||
oDocument.InsertContent([oParagraph1])
|
||||
let GetNext = oParagraph1.GetNext()
|
||||
GetNext.Delete()
|
||||
}
|
||||
oParagraph.Delete();
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,790 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-button-group style="margin-bottom: 10px">
|
||||
<a-button @click="insertChapter(0)">章</a-button>
|
||||
<a-button @click="insertBar(1,true)">条一</a-button>
|
||||
<a-button @click="insertBar(2,true)">条二</a-button>
|
||||
<a-button @click="insertBar(3,true)">条三</a-button>
|
||||
<a-button @click="insertBar(4,true)">条四</a-button>
|
||||
<a-button @click="insertBar(5,true)">条五</a-button>
|
||||
<!-- <a-dropdown>-->
|
||||
<!-- <a-menu slot="overlay" @click="insertBar">-->
|
||||
<!-- <a-menu-item key="1">插入一级条</a-menu-item>-->
|
||||
<!-- <a-menu-item key="2">插入二级条</a-menu-item>-->
|
||||
<!-- <a-menu-item key="3">插入三级条</a-menu-item>-->
|
||||
<!-- <a-menu-item key="4">插入四级条</a-menu-item>-->
|
||||
<!-- <a-menu-item key="5">插入五级条</a-menu-item>-->
|
||||
<!-- </a-menu>-->
|
||||
<!-- <a-button class="section-btn"-->
|
||||
<!-- >插入条-->
|
||||
<!-- <a-icon type="down"/>-->
|
||||
<!-- </a-button>-->
|
||||
<!-- </a-dropdown>-->
|
||||
<!-- <a-dropdown>-->
|
||||
<!-- <a-menu slot="overlay" @click="adjustTo">-->
|
||||
<!-- <a-menu-item key="0">章标题</a-menu-item>-->
|
||||
<!-- <a-menu-item key="1">一级条标题</a-menu-item>-->
|
||||
<!-- <a-menu-item key="2">二级条标题</a-menu-item>-->
|
||||
<!-- <a-menu-item key="3">三级条标题</a-menu-item>-->
|
||||
<!-- </a-menu>-->
|
||||
<!-- <a-button class="section-btn"-->
|
||||
<!-- >调整为-->
|
||||
<!-- <a-icon type="down"/>-->
|
||||
<!-- </a-button>-->
|
||||
<!-- </a-dropdown>-->
|
||||
</a-button-group>
|
||||
<a-button-group style="margin-bottom: 10px">
|
||||
<!-- <a-button @click="insertBarOne(1,false)">无题一</a-button>-->
|
||||
<a-button @click="insertBarOne(2,false)">无题二</a-button>
|
||||
<a-button @click="insertBarOne(3,false)">无题三</a-button>
|
||||
<a-button @click="insertBarOne(4,false)">无题四</a-button>
|
||||
<a-button @click="insertBarOne(5,false)">无题五</a-button>
|
||||
|
||||
</a-button-group>
|
||||
<!-- <div>-->
|
||||
<!-- <a-button-group>-->
|
||||
<!-- <a-button @click="demoteClick">降级</a-button>-->
|
||||
<!-- <a-button @click="upgradeClick">升级</a-button>-->
|
||||
<!-- </a-button-group>-->
|
||||
<!-- </div>-->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "chapterData",
|
||||
data() {
|
||||
return {
|
||||
num: 0,
|
||||
numData: {
|
||||
1: 'A',
|
||||
2: 'B',
|
||||
3: 'C',
|
||||
4: 'D',
|
||||
5: 'E',
|
||||
6: 'F',
|
||||
7: 'G',
|
||||
8: 'H',
|
||||
9: 'I',
|
||||
10: 'J',
|
||||
11: 'K',
|
||||
12: 'L',
|
||||
13: 'M',
|
||||
14: 'N',
|
||||
15: 'O',
|
||||
16: 'P',
|
||||
17: 'Q',
|
||||
18: 'R',
|
||||
19: 'S',
|
||||
20: 'T',
|
||||
21: 'U',
|
||||
22: 'V',
|
||||
23: 'W',
|
||||
24: 'X',
|
||||
25: 'Y',
|
||||
26: 'Z'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
insertChapter(val) {
|
||||
Asc.scope.alias = val;
|
||||
Asc.scope.numData = this.numData
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
// DE.controllers.Toolbar.api.put_ListType(2, 2)
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
let table
|
||||
let SpacingBefore
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
if (table) {
|
||||
let number = table.GetCell(0, 0).GetContent().GetElement(1);
|
||||
SpacingBefore = number.GetSpacingBefore();
|
||||
}
|
||||
if (SpacingBefore) {
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + ".%1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "left");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = "%1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "left");
|
||||
}
|
||||
}
|
||||
}
|
||||
// oParagraphOne.Delete()
|
||||
// const oParagraph = Api.CreateParagraph()
|
||||
let oTextPr = oNumLvl.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
let oParaPr = oNumLvl.GetParaPr();
|
||||
oNumLvl.SetSuff("space");
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
if (SpacingBefore) {
|
||||
oParagraph.SetIndLeft(20);
|
||||
oParaPr.SetIndFirstLine(20);
|
||||
} else {
|
||||
oParagraph.SetIndLeft(20);
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
}
|
||||
oParagraph.SetSpacingAfter(267)
|
||||
oParagraph.SetSpacingBefore(267)
|
||||
oParagraph.SetBold(false);
|
||||
const oNewDocumentStyle = oDocument.GetStyle("Heading 1");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetStyle(oNewDocumentStyle);
|
||||
oParagraph.SetFontSize(21);
|
||||
// oParagraph.SetJc("left");
|
||||
oParagraph.SetColor(0, 0, 0);
|
||||
oParagraph.SetFontFamily("黑体");
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
insertBar(val, isTrue) {
|
||||
Asc.scope.alias = val;
|
||||
Asc.scope.isTrue = isTrue;
|
||||
Asc.scope.numData = this.numData;
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let numbering
|
||||
let currentNumbering
|
||||
let table
|
||||
let SpacingBefore
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267 || text == 127) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
if (table) {
|
||||
let number = table.GetCell(0, 0).GetContent().GetElement(1);
|
||||
SpacingBefore = number.GetSpacingBefore();
|
||||
}
|
||||
if (SpacingBefore) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267 || text == 127) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
numbering = oNumbering.GetLevel(Asc.scope.alias);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267 || text == 127) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
numbering = oNumbering.GetLevel(Asc.scope.alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const oParagraph = Api.CreateParagraph()
|
||||
let oNewDocumentStyle = null
|
||||
if (SpacingBefore) {
|
||||
if (Asc.scope.alias == '1') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 2");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetFontFamily('黑体')
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '2') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 3");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '3') {
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3.%4';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 4");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetIndLeft(20);
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '4') {
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3.%4.%5';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 5");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetIndLeft(20);
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '5') {
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3.%4.%5.%6';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 6");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetIndLeft(20);
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
}
|
||||
} else {
|
||||
if (Asc.scope.alias == '1') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = '%1.%2';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 2");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetFontFamily('黑体')
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '2') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = '%1.%2.%3';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 3");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '3') {
|
||||
const sFormatString = '%1.%2.%3.%4';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 4");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetIndLeft(20);
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '4') {
|
||||
const sFormatString = '%1.%2.%3.%4.%5';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 5");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetIndLeft(20);
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
} else if (Asc.scope.alias == '5') {
|
||||
const sFormatString = '%1.%2.%3.%4.%5.%6';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Heading 6");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
oParagraph.SetIndLeft(20);
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
}
|
||||
}
|
||||
// oParagraphOne.Delete()
|
||||
const ParaPr = numbering.GetParaPr()
|
||||
ParaPr.SetStyle(oNewDocumentStyle)
|
||||
ParaPr.SetSpacingAfter(140)
|
||||
oParagraph.SetStyle(oNewDocumentStyle);
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetSpacingAfter(127)
|
||||
oParagraph.SetSpacingBefore(127)
|
||||
let isTrue = false
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("paragraph" === element.GetClassType()) {
|
||||
let ContentControls = element.GetParaPr().GetStyle()
|
||||
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
|
||||
if (element.GetText() == '术语和定义') {
|
||||
isTrue = true
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isTrue) {
|
||||
let text = oParagraph.GetText()
|
||||
oParagraph.RemoveAllElements()
|
||||
oParagraph.AddLineBreak();
|
||||
oParagraph.AddText(' '+text)
|
||||
}
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontFamily("黑体");
|
||||
oParagraph.SetFontSize(21);
|
||||
oParagraph.SetJc("both");
|
||||
oParagraph.SetColor(0, 0, 0);
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oDocument.InsertContent([oParagraph])
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
insertBarOne(val, isTrue) {
|
||||
Asc.scope.alias = val;
|
||||
Asc.scope.isTrue = isTrue;
|
||||
Asc.scope.numData = this.numData;
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let numbering
|
||||
let currentNumbering
|
||||
let table
|
||||
let SpacingBefore
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267 || text == 127) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
if (table) {
|
||||
let number = table.GetCell(0, 0).GetContent().GetElement(1);
|
||||
SpacingBefore = number.GetSpacingBefore();
|
||||
}
|
||||
if (SpacingBefore) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267 || text == 127) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
numbering = oNumbering.GetLevel(Asc.scope.alias);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 267 || text == 127) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
numbering = oNumbering.GetLevel(Asc.scope.alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const oParagraph = Api.CreateParagraph()
|
||||
let oNewDocumentStyle = null
|
||||
if (SpacingBefore) {
|
||||
if (Asc.scope.alias == '1') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
} else if (Asc.scope.alias == '2') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
} else if (Asc.scope.alias == '3') {
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3.%4';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
oParagraph.SetIndLeft(20);
|
||||
} else if (Asc.scope.alias == '4') {
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3.%4.%5';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
oParagraph.SetIndLeft(20);
|
||||
} else if (Asc.scope.alias == '5') {
|
||||
const sFormatString = Asc.scope.numData[SpacingBefore] + '.%1.%2.%3.%4.%5.%6';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(25);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
oParagraph.SetIndLeft(20);
|
||||
}
|
||||
} else {
|
||||
if (Asc.scope.alias == '1') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = '%1.%2';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
} else if (Asc.scope.alias == '2') {
|
||||
oParagraph.SetIndLeft(20);
|
||||
const sFormatString = '%1.%2.%3';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
} else if (Asc.scope.alias == '3') {
|
||||
const sFormatString = '%1.%2.%3.%4';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
oParagraph.SetIndLeft(20);
|
||||
} else if (Asc.scope.alias == '4') {
|
||||
const sFormatString = '%1.%2.%3.%4.%5';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
oParagraph.SetIndLeft(20);
|
||||
} else if (Asc.scope.alias == '5') {
|
||||
const sFormatString = '%1.%2.%3.%4.%5.%6';
|
||||
numbering.SetCustomType("decimal", sFormatString, "left");
|
||||
numbering.SetSuff("space");
|
||||
let oParaPr = numbering.GetParaPr();
|
||||
oParaPr.SetIndFirstLine(0);
|
||||
oNewDocumentStyle = oDocument.GetStyle("Normal");
|
||||
oParagraph.SetIndLeft(20);
|
||||
}
|
||||
}
|
||||
// oParagraphOne.Delete()
|
||||
let oTextPr = numbering.GetTextPr();
|
||||
oTextPr.SetFontFamily("黑体");
|
||||
const ParaPr = numbering.GetParaPr()
|
||||
ParaPr.SetStyle(oNewDocumentStyle)
|
||||
ParaPr.SetSpacingAfter(140)
|
||||
oParagraph.SetStyle(oNewDocumentStyle);
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetSpacingAfter(127)
|
||||
oParagraph.SetSpacingBefore(127)
|
||||
oParagraph.SetFontFamily("宋体");
|
||||
let isTrue = false
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("paragraph" === element.GetClassType()) {
|
||||
let ContentControls = element.GetParaPr().GetStyle()
|
||||
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
|
||||
if (element.GetText() == '术语和定义') {
|
||||
isTrue = true
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isTrue) {
|
||||
let text = oParagraph.GetText()
|
||||
oParagraph.RemoveAllElements()
|
||||
oParagraph.AddLineBreak();
|
||||
oParagraph.AddText(' '+text)
|
||||
}
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontSize(21);
|
||||
oParagraph.SetJc("left");
|
||||
oParagraph.SetColor(0, 0, 0);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
adjustTo(val) {
|
||||
Asc.scope.alias = val.key;
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
let numbering = null
|
||||
let currentNumbering = null
|
||||
for (let index = 0; index < allElement; index++) {
|
||||
const element = oDocument.GetElement(index)
|
||||
if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering
|
||||
} else {
|
||||
currentNumbering = element.CreateNumbering("numbered");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.alias)
|
||||
} else {
|
||||
const numberingIndex = oDocument.CreateNumbering("numbered");
|
||||
numbering = numberingIndex.GetLevel(0);
|
||||
}
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetIndLeft(360);
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontSize(21);
|
||||
oParagraph.SetFontFamily("黑体");
|
||||
oDocument.InsertContent([oParagraph])
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
demoteClick() {
|
||||
|
||||
},
|
||||
upgradeClick() {
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
<template></template>
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
test() {
|
||||
try {
|
||||
this.ctx.callCommand(() => {
|
||||
|
||||
})
|
||||
} catch(e) {}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
list: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
window.Asc.plugin.init = function () {
|
||||
// Vue.prototype.ctx = this
|
||||
this.callCommand(() => {
|
||||
// console.log(window, document)
|
||||
// const node = document.getElementById('header-logo').lastChild.cloneNode(true)
|
||||
// document.getElementById('header-logo').innerHTML = ''
|
||||
// document.getElementById('header-logo').appendChild(node)
|
||||
// const permissions = new window.AscCommon.xHd()
|
||||
// permissions.$Vd = 3
|
||||
// window.localStorage.setItem('de-license-warning', 0)
|
||||
// window.editor.sendEvent('asc_onLicenseChanged', permissions)
|
||||
})
|
||||
}
|
||||
|
||||
window.Asc.plugin.button = (id) => {
|
||||
console.log('wx2', id)
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
#app {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-align: center;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
#nav {
|
||||
padding: 30px;
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
color: #2c3e50;
|
||||
|
||||
&.router-link-exact-active {
|
||||
color: #42b983;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name" : "RemoveLogoClickEvent",
|
||||
"guid" : "asc.{7CC733B1-9B26-4977-926E-D212B13F2B70}",
|
||||
"baseUrl" : "",
|
||||
"variations" : [
|
||||
{
|
||||
"description" : "RemoveLogoClickEvent By WangXu",
|
||||
"url" : "index.html",
|
||||
"icons" : ["icon.png", "icon@2x.png", "icon2.png", "icon2@2x.png"],
|
||||
"isViewer" : false,
|
||||
"EditorsSupport" : ["word"],
|
||||
"isVisual" : false,
|
||||
"isSystem" : true,
|
||||
"isModal" : false,
|
||||
"isInsideMode" : false,
|
||||
"initDataType" : "none",
|
||||
"initData" : "",
|
||||
"isUpdateOleOnResize" : true,
|
||||
"buttons" : []
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<script type="text/javascript" src="./plugins.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
(function (window, undefined) {
|
||||
window.Asc.plugin.init = function()
|
||||
{
|
||||
this.callCommand(() => {
|
||||
this.callCommand(() => {
|
||||
// console.log(window, document)
|
||||
const node = document.getElementById('header-logo').lastChild.cloneNode(true)
|
||||
document.getElementById('header-logo').innerHTML = ''
|
||||
document.getElementById('header-logo').appendChild(node)
|
||||
})
|
||||
})
|
||||
};
|
||||
})(window, undefined);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
// import router from './router';
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
// router,
|
||||
render: (h) => h(App),
|
||||
}).$mount('#app')
|
||||
Binary file not shown.
@@ -0,0 +1,57 @@
|
||||
import Vue from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
// Full config: https://github.com/axios/axios#request-config
|
||||
// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
|
||||
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
||||
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
const config = {
|
||||
// baseURL: process.env.baseURL || process.env.apiUrl || ""
|
||||
// timeout: 60 * 1000, // Timeout
|
||||
// withCredentials: true, // Check cross-site Access-Control
|
||||
}
|
||||
|
||||
const _axios = axios.create(config)
|
||||
|
||||
_axios.interceptors.request.use(
|
||||
(config) =>
|
||||
// Do something before request is sent
|
||||
config,
|
||||
(error) =>
|
||||
// Do something with request error
|
||||
Promise.reject(error)
|
||||
|
||||
)
|
||||
|
||||
// Add a response interceptor
|
||||
_axios.interceptors.response.use(
|
||||
(response) =>
|
||||
// Do something with response data
|
||||
response,
|
||||
(error) =>
|
||||
// Do something with response error
|
||||
Promise.reject(error)
|
||||
|
||||
)
|
||||
|
||||
Plugin.install = function (Vue, options) {
|
||||
Vue.axios = _axios
|
||||
window.axios = _axios
|
||||
Object.defineProperties(Vue.prototype, {
|
||||
axios: {
|
||||
get() {
|
||||
return _axios
|
||||
}
|
||||
},
|
||||
$axios: {
|
||||
get() {
|
||||
return _axios
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Vue.use(Plugin)
|
||||
|
||||
export default Plugin
|
||||
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
import Vue from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
// Full config: https://github.com/axios/axios#request-config
|
||||
// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
|
||||
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
||||
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
const config = {
|
||||
// baseURL: '/'
|
||||
baseURL: window._CONFIG.interfaceUrl,//本地
|
||||
// baseURL: 'https://srms.foton.com.cn',//线上
|
||||
// timeout: 60 * 1000, // Timeout
|
||||
// withCredentials: true, // Check cross-site Access-Control
|
||||
}
|
||||
|
||||
const _axios = axios.create(config)
|
||||
|
||||
_axios.interceptors.request.use(
|
||||
(config) =>
|
||||
// Do something before request is sent
|
||||
config,
|
||||
(error) =>
|
||||
// Do something with request error
|
||||
Promise.reject(error)
|
||||
|
||||
)
|
||||
|
||||
// Add a response interceptor
|
||||
_axios.interceptors.response.use(
|
||||
(response) =>
|
||||
// Do something with response data
|
||||
response.data,
|
||||
(error) =>
|
||||
// Do something with response error
|
||||
Promise.reject(error)
|
||||
|
||||
)
|
||||
|
||||
export default _axios
|
||||
@@ -0,0 +1,14 @@
|
||||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
const routes = []
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
})
|
||||
|
||||
export default router
|
||||
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
chapterNumbering: sessionStorage.getItem('chapterNumbering') || null
|
||||
},
|
||||
getters: {
|
||||
chapterNumbering: state => {
|
||||
return state.chapterNumbering
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
||||
},
|
||||
mutations: {
|
||||
updateChapterNumbering(state, chapterNumbering) {
|
||||
state.chapterNumbering = chapterNumbering
|
||||
sessionStorage.setItem('chapterNumbering', chapterNumbering)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user