|
@@ -6,7 +6,8 @@
|
|
|
<el-button type="primary" @click="formateXml(content)">格式化</el-button>
|
|
|
</div>
|
|
|
<div class="right">
|
|
|
- <el-button type="primary" @click="determine">确定修改</el-button>
|
|
|
+ <el-button type="primary" v-if="isExport" @click="exportFn">导出</el-button>
|
|
|
+ <el-button type="primary" v-if="isUpdate" @click="determine">确定修改</el-button>
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -26,11 +27,29 @@ export default {
|
|
|
components: {
|
|
|
codemirror,
|
|
|
},
|
|
|
- props:[ 'textContent','closeEditor','dataType'],
|
|
|
+ props: {
|
|
|
+ // 内容
|
|
|
+ textContent: {
|
|
|
+ type: String,
|
|
|
+ default: () => ''
|
|
|
+ },
|
|
|
+ dataType: {
|
|
|
+ type: String,
|
|
|
+ default: () => 'xml'
|
|
|
+ },
|
|
|
+ isUpdate: {
|
|
|
+ type: Boolean,
|
|
|
+ default: () => false
|
|
|
+ },
|
|
|
+ isExport: {
|
|
|
+ type: Boolean,
|
|
|
+ default: () => false
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
// 初始的 text 内容
|
|
|
- content: this.textContent,
|
|
|
+ content: this.textContent,
|
|
|
// 绑定的数据
|
|
|
bindContentData:this.textContent,
|
|
|
editorOptions: null,
|
|
@@ -63,6 +82,22 @@ export default {
|
|
|
// 在这里处理 XML 内容的变化
|
|
|
// console.log(textContent)
|
|
|
},
|
|
|
+ exportFn() {
|
|
|
+ // 创建Blob对象
|
|
|
+ const blob = new Blob([this.content], { type: "text/xml" });
|
|
|
+
|
|
|
+ // // 创建下载链接
|
|
|
+ const link = document.createElement("a");
|
|
|
+ link.href = window.URL.createObjectURL(blob);
|
|
|
+ link.download = "指令.xml";
|
|
|
+
|
|
|
+ // 将链接添加到文档中并模拟点击
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+
|
|
|
+ // 清理
|
|
|
+ document.body.removeChild(link);
|
|
|
+ },
|
|
|
// xml格式化
|
|
|
formateXml(xmlStr){
|
|
|
var that = this;
|
|
@@ -124,10 +159,10 @@ export default {
|
|
|
return result;
|
|
|
},
|
|
|
determine(){
|
|
|
- this.closeEditor(this.content)
|
|
|
+ this.$emit('closeEditor', this.content);
|
|
|
},
|
|
|
cancel(){
|
|
|
- this.closeEditor('no')
|
|
|
+ this.$emit('closeEditor', 'no');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -141,6 +176,6 @@ export default {
|
|
|
margin-top: 20px;
|
|
|
display: flex;
|
|
|
justify-content: space-around;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|