Commit 467cf56d by 1377875331@qq.com

面函xml格式显示

parent 9ffa5e63
...@@ -345,8 +345,8 @@ export default { ...@@ -345,8 +345,8 @@ export default {
// let url = rtnmsg.data.trnmod_trndoc_smh_docpth; // let url = rtnmsg.data.trnmod_trndoc_smh_docpth;
this.title = "面函" this.title = "面函"
let viewurl = "/#/docpan/show"; let viewurl = "/#/docpan/show";
viewurl += "?model="+rtnmsg.data.litbenl1blk; var newXml = Utils.showXml(rtnmsg.data.litbenl1blk)
console.log(viewurl) window.sessionStorage.docXML = newXml;
window.open(viewurl, 'newwindow', 'height=1200,width=800,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no'); window.open(viewurl, 'newwindow', 'height=1200,width=800,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no');
} }
this.dialogOpen=true this.dialogOpen=true
......
...@@ -60,4 +60,85 @@ export default class Utils { ...@@ -60,4 +60,85 @@ export default class Utils {
} }
return target; return target;
} }
static showXml(str){
var text = str
//去掉多余的空格
text = '\n' + text.replace(/(<\w+)(\s.*?>)/g,function($0, name, props)
{
return name + ' ' + props.replace(/\s+(\w+=)/g," $1");
}).replace(/>\s*?</g,">\n<");
//把注释编码
text = text.replace(/\n/g,'\r').replace(/<!--(.+?)-->/g,function($0, text)
{
var ret = '<!--' + escape(text) + '-->';
return ret;
}).replace(/\r/g,'\n');
//调整格式
var rgx = /\n(<(([^\?]).+?)(?:\s|\s*?>|\s*?(\/)>)(?:.*?(?:(?:(\/)>)|(?:<(\/)\2>)))?)/mg;
var nodeStack = [];
var output = text.replace(rgx,function($0,all,name,isBegin,isCloseFull1,isCloseFull2 ,isFull1,isFull2){
var isClosed = (isCloseFull1 == '/') || (isCloseFull2 == '/' ) || (isFull1 == '/') || (isFull2 == '/');
var prefix = '';
if(isBegin == '!')
{
prefix = Utils.getPrefix(nodeStack.length);
}
else
{
if(isBegin != '/')
{
prefix = Utils.getPrefix(nodeStack.length);
if(!isClosed)
{
nodeStack.push(name);
}
}
else
{
nodeStack.pop();
prefix = Utils.getPrefix(nodeStack.length);
}
}
var ret = '\n' + prefix + all;
return ret;
});
var prefixSpace = -1;
var outputText = output.substring(1);
//把注释还原并解码,调格式
outputText = outputText.replace(/\n/g,'\r').replace(/(\s*)<!--(.+?)-->/g,function($0, prefix, text)
{
if(prefix.charAt(0) == '\r')
prefix = prefix.substring(1);
text = unescape(text).replace(/\r/g,'\n');
var ret = '\n' + prefix + '<!--' + text.replace(/^\s*/mg, prefix ) + '-->';
return ret;
});
//alert(outputText);
outputText= outputText.replace(/\s+$/g,'').replace(/\r/g,'\r\n');
return outputText
}
static getPrefix(prefixIndex)
{
var span = ' ';
var output = [];
for(var i = 0 ; i < prefixIndex; ++i)
{
output.push(span);
}
return output.join('');
}
} }
\ No newline at end of file
<template> <template>
<div> <div>
<div class="title">面函列表</div> <div class="title">面函列表</div>
<div> <div style="height:1000px;width:900px;overflow:auto">
<c-input <pre>
type="textarea" {{model.docXML}}
:autosize="{ minRows: 16}" </pre>
placeholder="请输入原因"
v-model="model">
</c-input>
</div> </div>
</div> </div>
</template> </template>
...@@ -19,12 +16,12 @@ import Utils from "~/utils" ...@@ -19,12 +16,12 @@ import Utils from "~/utils"
export default { export default {
data(){ data(){
return { return {
model: this.$route.query.model, model: {docXML:""},
} }
}, },
mounted() { mounted() {
console.log(this.$router); this.model.docXML = window.sessionStorage.docXML
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment