3.10 工程代码同步master
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
* version: 2.3.2
|
||||
*
|
||||
* 2020.07.10版本 跟随 招商银行股份有限公司20200730 产品发送
|
||||
* 2021.04.29版本 增加兼容Edge浏览器的判断逻辑 zhoujianlong
|
||||
*/
|
||||
"use strict";
|
||||
var varNtkoGUID = Math.random().toString(36);
|
||||
@ -20,6 +21,7 @@ var userAgent = navigator.userAgent,
|
||||
rSafari = /version\/([\w.]+).*(safari)/;
|
||||
var browser;
|
||||
var version;
|
||||
var ntkoextensionmainifest;
|
||||
var ua = userAgent.toLowerCase();
|
||||
function uaMatch(ua) {
|
||||
var match = rMsie.exec(ua);
|
||||
@ -143,13 +145,13 @@ ExtensionInstalled:function()
|
||||
localStorage.clear();
|
||||
}
|
||||
return (bChromeExtensionInstalled);
|
||||
} else if("edg" === browserMatch.browser){
|
||||
if(localStorage["ntkoweb"]==="ntkoExtensionInstalled"){
|
||||
bChromeExtensionInstalled=true;
|
||||
localStorage.clear();
|
||||
}
|
||||
return( bChromeExtensionInstalled );
|
||||
}
|
||||
}else if("edg" === browserMatch.browser){
|
||||
if(( typeof ntkoextensionmainifest != 'undefined' ) && ( ( null != ntkoextensionmainifest ) && ( "" != ntkoextensionmainifest ))){
|
||||
return true;
|
||||
}else{
|
||||
return( bChromeExtensionInstalled );
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -186,6 +188,8 @@ openWindow:function( strURL,IsShowOnExtendMonitor,ProductCaption, ntkoBrowserPro
|
||||
jsonValue += varNtkoGUID;
|
||||
jsonValue += '","URLMD5":"';
|
||||
jsonValue +=b64_md5(strURL);
|
||||
jsonValue += '","ntkobrowserMatch":"';
|
||||
jsonValue +=browserMatch.browser;
|
||||
jsonValue += '","IsShowOnExtendMonitor":"';
|
||||
jsonValue += IsShowOnExtendMonitor;
|
||||
jsonValue += '"';
|
||||
@ -390,7 +394,10 @@ NtkoWidthAndHeightWinScr:function(ntkowidth,ntkoheight){
|
||||
}
|
||||
},
|
||||
AboutWebOfficeDOCType:"",
|
||||
AboutWebOfficePDFType:""
|
||||
AboutWebOfficePDFType:"",
|
||||
AboutWebOfficeHTMLType:"",
|
||||
thisNTKOGUID:varNtkoGUID,
|
||||
|
||||
};
|
||||
|
||||
if(browser!="IE")
|
||||
@ -435,6 +442,10 @@ if(browser!="IE")
|
||||
}
|
||||
}
|
||||
}
|
||||
if(event.data.type && (event.data.type == "FROM_NTKO_MANIFEST")){
|
||||
var ntkojsontext = JSON.parse( event.data.text );
|
||||
ntkoextensionmainifest=ntkojsontext['ntkoversion'];
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
function ieattachEventntko(data,varFunctionAgrvs)
|
||||
@ -653,5 +664,10 @@ function DOCData(param){
|
||||
function PDFData(param){
|
||||
ntkoBrowser.AboutWebOfficePDFType=param;
|
||||
}
|
||||
|
||||
function HTMLData(param){
|
||||
ntkoBrowser.AboutWebOfficePDFType=param;
|
||||
}
|
||||
function NTKOPostMessage(param){
|
||||
window.postMessage(param, "*")
|
||||
}
|
||||
|
||||
|
@ -6,5 +6,7 @@ export async function getFileCode() {
|
||||
}
|
||||
export async function selectFile(param:any) {
|
||||
return request("/api/core-service-ebtp-updownload/v1/attachment/find",{method:"post",data:{"bidList":[param]}})
|
||||
|
||||
}
|
||||
export async function selectFileS(param:any) {
|
||||
return request("/api/core-service-ebtp-updownload/v1/attachment/find",{method:"post",data:{"bidList":param}})
|
||||
}
|
||||
|
668
src/pages/webOffice/test/ntkobackground.min.js
vendored
Normal file
668
src/pages/webOffice/test/ntkobackground.min.js
vendored
Normal file
@ -0,0 +1,668 @@
|
||||
/**
|
||||
* version: 2.3.2
|
||||
*
|
||||
* 2020.07.10版本 跟随 招商银行股份有限公司20200730 产品发送
|
||||
* 2021.04.29版本 增加兼容Edge浏览器的判断逻辑 zhoujianlong
|
||||
*/
|
||||
"use strict";
|
||||
var varNtkoGUID = Math.random().toString(36);
|
||||
var ntkoWinOpen;
|
||||
var ntkoJsonIe;
|
||||
var timer;
|
||||
var ntkoSendDataToChildStrUrl;
|
||||
var ntkoSendDataToChildSData;
|
||||
var ntkowin;
|
||||
var userAgent = navigator.userAgent,
|
||||
rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
|
||||
rFirefox = /(firefox)\/([\w.]+)/,
|
||||
rOpera = /(opera).+versi1on\/([\w.]+)/,
|
||||
rChrome = /(chrome)\/([\w.]+)/,
|
||||
rEdge = /(edg)\/([\w.]+)/,
|
||||
rSafari = /version\/([\w.]+).*(safari)/;
|
||||
var browser;
|
||||
var version;
|
||||
var ntkoextensionmainifest;
|
||||
var ua = userAgent.toLowerCase();
|
||||
function uaMatch(ua) {
|
||||
var match = rMsie.exec(ua);
|
||||
if (match != null) {
|
||||
return { browser : "IE", version : match[2] || "0" };
|
||||
}
|
||||
var match = rFirefox.exec(ua);
|
||||
if (match != null) {
|
||||
return { browser : match[1] || "", version : match[2] || "0" };
|
||||
}
|
||||
var match = rOpera.exec(ua);
|
||||
if (match != null) {
|
||||
return { browser : match[1] || "", version : match[2] || "0" };
|
||||
}
|
||||
var match = rChrome.exec(ua);
|
||||
if (match != null) {
|
||||
var matchedge= rEdge.exec(ua);
|
||||
if(matchedge!=null){
|
||||
return { browser : matchedge[1] || "", version : matchedge[2] || "0" };
|
||||
}else{
|
||||
return { browser : match[1] || "", version : match[2] || "0" };
|
||||
}
|
||||
}
|
||||
var match = rSafari.exec(ua);
|
||||
if (match != null) {
|
||||
return { browser : match[2] || "", version : match[1] || "0" };
|
||||
}
|
||||
if (match != null) {
|
||||
return { browser : "", version : "0" };
|
||||
}
|
||||
}
|
||||
var browserMatch = uaMatch(userAgent.toLowerCase());
|
||||
if (browserMatch.browser) {
|
||||
browser = browserMatch.browser;
|
||||
version = browserMatch.version;
|
||||
}
|
||||
var mimeTypes = navigator.mimeTypes;
|
||||
var bChromeExtensionInstalled = false;
|
||||
|
||||
if( "chrome" === browserMatch.browser && version>="45")
|
||||
{
|
||||
|
||||
var img;
|
||||
img = new Image();
|
||||
img.src = "chrome-extension://lppkeogbkjlmmbjenbogdndlgmpiddda/icons/ntko.png";
|
||||
img.onload = function() {
|
||||
bChromeExtensionInstalled = true;
|
||||
};
|
||||
img.onerror = function() {
|
||||
bChromeExtensionInstalled = false;
|
||||
};
|
||||
}
|
||||
if("edg"===browserMatch.browser){
|
||||
|
||||
var img;
|
||||
img = new Image();
|
||||
img.src = "chrome-extension://nldmejlecnngjgcfpinfkdhkfakjeail/icons/ntko.png";
|
||||
img.onload = function() {
|
||||
bChromeExtensionInstalled = true;
|
||||
};
|
||||
img.onload = function() {
|
||||
bChromeExtensionInstalled = true;
|
||||
};
|
||||
}
|
||||
|
||||
var ntkoBrowser = {
|
||||
ntkoSendDataToChild:function( strURL, data)
|
||||
{
|
||||
if ( typeof data === 'undefined' ){
|
||||
return;
|
||||
}
|
||||
var strURL=ntkoBrowser.NtkoStrURL(strURL);
|
||||
var jsonValue = '{"SendDataToChild":1,"GUID":"';
|
||||
jsonValue += varNtkoGUID;
|
||||
jsonValue += '","URLMD5":"';
|
||||
jsonValue += b64_md5(strURL);
|
||||
jsonValue += '","ChildValue":"';
|
||||
jsonValue += data;
|
||||
jsonValue += '"}';
|
||||
var ntkobr=ntkoBrowser.NtkoBrower();
|
||||
if(ntkobr){
|
||||
window.postMessage({ type: "FROM_NTKO_PAGE", text: jsonValue }, "*");
|
||||
}else{
|
||||
ntkoWinOpen.ntkoGetParentData(data);
|
||||
}
|
||||
},
|
||||
ExtensionInstalled:function()
|
||||
{
|
||||
var ntkobr=ntkoBrowser.NtkoBrower();
|
||||
if(!ntkobr){
|
||||
if(browser=="IE"){
|
||||
return true;
|
||||
}else{
|
||||
var mimetype=navigator.mimeTypes["application/ntko-plug"];
|
||||
if(mimetype){
|
||||
var plugin=mimetype.enabledPlugin;
|
||||
if(plugin){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( "firefox" === browserMatch.browser )
|
||||
{
|
||||
var bInstalled = false;
|
||||
if( "undefined" === typeof FirefoxInstalled )
|
||||
return ( bInstalled );
|
||||
else
|
||||
return( window.FirefoxInstalled());
|
||||
}
|
||||
else if( "chrome" === browserMatch.browser )
|
||||
{
|
||||
if(localStorage["ntkoweb"]==="ntkoExtensionInstalled"){
|
||||
bChromeExtensionInstalled=true;
|
||||
localStorage.clear();
|
||||
}
|
||||
return (bChromeExtensionInstalled);
|
||||
}else if("edg" === browserMatch.browser){
|
||||
if(( typeof ntkoextensionmainifest != 'undefined' ) && ( ( null != ntkoextensionmainifest ) && ( "" != ntkoextensionmainifest ))){
|
||||
return true;
|
||||
}else{
|
||||
return( bChromeExtensionInstalled );
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ntkoClose:function( strURL )
|
||||
{
|
||||
var strURL=ntkoBrowser.NtkoStrURL(strURL);
|
||||
var jsonValue = '{"Close":1,"GUID":"';
|
||||
jsonValue += varNtkoGUID;
|
||||
jsonValue += '","URLMD5":"';
|
||||
jsonValue += b64_md5(strURL);
|
||||
jsonValue += '"}';
|
||||
var ntkobr=ntkoBrowser.NtkoBrower();
|
||||
if(ntkobr){
|
||||
window.postMessage({ type: "FROM_NTKO_PAGE", text: jsonValue }, "*");
|
||||
}else{
|
||||
ntkoWinOpen.close();
|
||||
}
|
||||
},
|
||||
openWindow:function( strURL,IsShowOnExtendMonitor,ProductCaption, ntkoBrowserProductKey, ntkoBrowserNoExpireKey, ntkoBrowserOptions,varUrlData,ntkowidth,ntkoheight )
|
||||
{
|
||||
|
||||
if(varUrlData!=null&&varUrlData!=""){
|
||||
ntkoSendDataToChildSData=varUrlData;
|
||||
}
|
||||
var ntkowinscr= ntkoBrowser.NtkoWidthAndHeightWinScr(ntkowidth,ntkoheight);
|
||||
if(!ntkowinscr){
|
||||
alert("设置窗口大小格式不正确");
|
||||
return;
|
||||
}
|
||||
var strURL=ntkoBrowser.NtkoStrURL(strURL);
|
||||
var jsonValue = '{"OpenWindow":1,"URL":"';
|
||||
jsonValue += strURL;
|
||||
jsonValue += '","GUID":"';
|
||||
jsonValue += varNtkoGUID;
|
||||
jsonValue += '","URLMD5":"';
|
||||
jsonValue +=b64_md5(strURL);
|
||||
jsonValue += '","ntkobrowserMatch":"';
|
||||
jsonValue +=browserMatch.browser;
|
||||
jsonValue += '","IsShowOnExtendMonitor":"';
|
||||
jsonValue += IsShowOnExtendMonitor;
|
||||
jsonValue += '"';
|
||||
if( ( typeof ProductCaption != 'undefined' ) && ( ( null != ProductCaption ) && ( "" != ProductCaption ) ) )
|
||||
{
|
||||
jsonValue += ',"ProductCaption":"';
|
||||
jsonValue += ProductCaption;
|
||||
jsonValue += '"';
|
||||
}
|
||||
|
||||
if( ( typeof ntkoBrowserProductKey != 'undefined' ) && ( ( null != ntkoBrowserProductKey ) && ( "" != ntkoBrowserProductKey ) ) )
|
||||
{
|
||||
jsonValue += ',"ProductKey":"';
|
||||
jsonValue += ntkoBrowserProductKey;
|
||||
jsonValue += '"';
|
||||
}
|
||||
|
||||
if( ( typeof ntkoBrowserNoExpireKey != 'undefined' ) && ( ( null != ntkoBrowserNoExpireKey ) &&( "" != ntkoBrowserNoExpireKey ) ) )
|
||||
{
|
||||
jsonValue += ',"NoExpireKey":"';
|
||||
jsonValue += ntkoBrowserNoExpireKey;
|
||||
jsonValue += '"';
|
||||
}
|
||||
|
||||
if( typeof ntkoBrowserOptions != 'undefined' && ( ( null != ntkoBrowserOptions ) && ( "" != ntkoBrowserOptions ) ) )
|
||||
{
|
||||
jsonValue += ',"Options":"';
|
||||
jsonValue += ntkoBrowserOptions;
|
||||
jsonValue += '"';
|
||||
}
|
||||
var LocalStorge = window.localStorage;
|
||||
if( typeof LocalStorge != 'undefined' && ( 0 != LocalStorge.length ) )
|
||||
{
|
||||
var varLocalDataList = [];
|
||||
for( var i = 0; i < LocalStorge.length; i++ )
|
||||
{
|
||||
var varLocalData = {};
|
||||
varLocalData["StorageKey"] = LocalStorge.key(i);
|
||||
varLocalData["StorageValue"] = LocalStorge.getItem(LocalStorge.key(i));
|
||||
varLocalDataList[i] = varLocalData;
|
||||
}
|
||||
jsonValue += ',"LocalStorge":';
|
||||
jsonValue += JSON.stringify(varLocalDataList);;
|
||||
jsonValue += '';
|
||||
}
|
||||
|
||||
var SessionStorge = window.sessionStorage;
|
||||
if( typeof SessionStorge != 'undefined' && ( 0 != SessionStorge.length ) )
|
||||
{
|
||||
var varSessionDataList = [];
|
||||
for( var i = 0; i < SessionStorge.length; i++ )
|
||||
{
|
||||
var varSessionData = {};
|
||||
varSessionData["StorageKey"] = SessionStorge.key(i);
|
||||
varSessionData["StorageValue"] = SessionStorge.getItem(SessionStorge.key(i));
|
||||
varSessionDataList[i] = varSessionData;
|
||||
}
|
||||
|
||||
jsonValue += ',"SessionStorge":';
|
||||
jsonValue += JSON.stringify(varSessionDataList);
|
||||
jsonValue += '';
|
||||
}
|
||||
if( typeof ntkowidth != 'undefined' && ( ( null != ntkowidth ) && ( "" != ntkowidth ) ) )
|
||||
{
|
||||
jsonValue += ',"NtkoWidth":';
|
||||
jsonValue += ntkowidth;
|
||||
jsonValue += '';
|
||||
}
|
||||
|
||||
if( typeof ntkoheight != 'undefined' && ( ( null != ntkoheight ) && ( "" != ntkoheight ) ) )
|
||||
{
|
||||
jsonValue += ',"NtkoHeight":';
|
||||
jsonValue += ntkoheight;
|
||||
jsonValue += '';
|
||||
}
|
||||
|
||||
|
||||
jsonValue += '}';
|
||||
var ntkobr=ntkoBrowser.NtkoBrower();
|
||||
if(ntkobr){
|
||||
window.postMessage({type: "FROM_NTKO_PAGE", text: jsonValue}, "*");
|
||||
}else{
|
||||
ntkowin=b64_md5(strURL);
|
||||
if(ntkowidth==null||ntkowidth=="" ||ntkowidth=="undefined"){
|
||||
ntkowidth=window.screen.width;
|
||||
}
|
||||
if(ntkoheight==null||ntkoheight==""||ntkoheight=="undefined"){
|
||||
ntkoheight=window.screen.height;
|
||||
}
|
||||
ntkoWinOpen=window.open(strURL,ntkowin,"height="+ntkoheight+", width="+ntkowidth+", top=0,left=0,titlebar=no,toolbar =no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no");
|
||||
ntkoWinOpen.resizeTo(ntkowidth,ntkoheight);
|
||||
ntkoWinOpen.focus();
|
||||
}
|
||||
},
|
||||
NtkoWShell:function(){
|
||||
|
||||
},
|
||||
NtkoiTop:function(){
|
||||
return (window.screen.height-30-300)/2;
|
||||
},
|
||||
NtkoiLeft:function(){
|
||||
return (window.screen.width-10-400)/2;
|
||||
},
|
||||
NtkoBrower:function(){
|
||||
if(browser=="IE"){
|
||||
return false;
|
||||
}
|
||||
if(browser=="firefox"){
|
||||
if(userAgent.indexOf("Windows NT 5.1") > -1){
|
||||
return false;
|
||||
}
|
||||
if(version>="50"){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(browser=="chrome"){
|
||||
if(userAgent.indexOf("Windows NT 5.1") > -1){
|
||||
return false;
|
||||
}
|
||||
if(version>="45"){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(browser=="edg"){
|
||||
return true;
|
||||
}
|
||||
},
|
||||
NtkoStrURL:function(strURL){
|
||||
var testurl =window.location.search;
|
||||
var docUrl=document.location.toString();
|
||||
var wpathname= window.document.location.pathname;
|
||||
var pos=docUrl.indexOf(wpathname);
|
||||
var relUrl= docUrl.substring(0,pos);
|
||||
if( ( null === strURL ) || ( "" === strURL ) )
|
||||
{
|
||||
alert("打开路径的url为null");
|
||||
return;
|
||||
}
|
||||
var strLowser = strURL.toLowerCase();
|
||||
if( '/' != strURL.charAt(0) )
|
||||
{
|
||||
if( ( "http://" === strLowser.substr(0,7) ) || ( "https://" === strLowser.substr(0,8) ) )
|
||||
{}
|
||||
else
|
||||
{
|
||||
if(strURL.indexOf("../")==-1)
|
||||
{
|
||||
var pathName = window.location.href;
|
||||
var varLength = pathName.lastIndexOf("/");
|
||||
strURL = pathName.substr( 0, varLength + 1 ) + strURL;
|
||||
}
|
||||
else
|
||||
{
|
||||
var strURLlen=strURL.length;
|
||||
strURL=strURL.substring(2,strURLlen);
|
||||
strURL = relUrl +strURL;
|
||||
}
|
||||
if(strURL.indexOf(testurl)==-1)
|
||||
{
|
||||
if(strURL.indexOf("?")==-1)
|
||||
{
|
||||
strURL=strURL+testurl
|
||||
}
|
||||
else
|
||||
{
|
||||
var docof= strURL.indexOf("?");
|
||||
var docend=strURL.length;
|
||||
var docs=strURL.substring(0,docof);
|
||||
var docsurl=strURL.substring(docof+1,docend);
|
||||
strURL=docs+testurl+"&"+docsurl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var strURLlen=strURL.length;
|
||||
strURL=strURL.substring(0,strURLlen);
|
||||
strURL = relUrl+ strURL;
|
||||
}
|
||||
return strURL;
|
||||
},
|
||||
NtkoWidthAndHeightWinScr:function(ntkowidth,ntkoheight){
|
||||
|
||||
var regNtko=/^\s*$/;
|
||||
if(typeof(ntkowidth)=="undefined"&&typeof(ntkoheight)=="undefined"){
|
||||
return true;
|
||||
}else{
|
||||
if(regNtko.test(ntkowidth)||typeof(ntkowidth)!="number"){
|
||||
return false;
|
||||
}else{
|
||||
if(regNtko.test(ntkoheight)||typeof(ntkoheight)!="number"){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
thisNTKOGUID:varNtkoGUID,
|
||||
};
|
||||
|
||||
if(browser!="IE")
|
||||
{
|
||||
window.addEventListener("message", function(event)
|
||||
{
|
||||
if ( event.source != window )
|
||||
return;
|
||||
if (event.data.type && (event.data.type == "FROM_NTKO_CONTEXT_PAGE"))
|
||||
{
|
||||
var vJsonData = JSON.parse( event.data.text );
|
||||
var jsonData = vJsonData["ntkoData"];
|
||||
if( typeof jsonData !== "undefined" )
|
||||
{
|
||||
if( varNtkoGUID === jsonData["ntkoGUID"] )
|
||||
{
|
||||
if( "ntkoClose" === jsonData["functionName"] )
|
||||
{
|
||||
// 调用关闭事件
|
||||
try
|
||||
{
|
||||
eval('ntkoCloseEvent()');
|
||||
}
|
||||
catch(e)
|
||||
{}
|
||||
}
|
||||
else if( "ntkoReturnValueToParentPage" === jsonData["functionName"] )
|
||||
{
|
||||
// 调用返回值事件,解析值
|
||||
var varFunctionName = jsonData["parentExecutionFunction"]; // 要执行的函数名
|
||||
if( typeof varFunctionName != 'undefined' && ( ( null != varFunctionName ) && ( "" != varFunctionName ) ) )
|
||||
{
|
||||
var varFunctionAgrvs = jsonData["FunctionArgs"]; // 传递过来的参数值
|
||||
if( typeof varFunctionAgrvs != 'undefined' && ( ( null != varFunctionAgrvs ) && ( "" != varFunctionAgrvs ) ) )
|
||||
{
|
||||
// 调用eval执行函数
|
||||
eval( varFunctionName + "( varFunctionAgrvs[0], varFunctionAgrvs[1], varFunctionAgrvs[2], varFunctionAgrvs[3]," +
|
||||
"varFunctionAgrvs[4],varFunctionAgrvs[5],varFunctionAgrvs[6],varFunctionAgrvs[7],varFunctionAgrvs[8]);" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(event.data.type && (event.data.type == "FROM_NTKO_MANIFEST")){
|
||||
var ntkojsontext = JSON.parse( event.data.text );
|
||||
ntkoextensionmainifest=ntkojsontext['ntkoversion'];
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
function ieattachEventntko(data,varFunctionAgrvs)
|
||||
{
|
||||
if( typeof data !== "undefined" )
|
||||
{
|
||||
if( typeof varFunctionAgrvs != 'undefined' && ( ( null != varFunctionAgrvs ) && ( "" != varFunctionAgrvs ) ) )
|
||||
{
|
||||
eval( data + "( varFunctionAgrvs[0], varFunctionAgrvs[1], varFunctionAgrvs[2], varFunctionAgrvs[3]," +
|
||||
"varFunctionAgrvs[4],varFunctionAgrvs[5],varFunctionAgrvs[6],varFunctionAgrvs[7],varFunctionAgrvs[8]);" );
|
||||
}
|
||||
}
|
||||
}
|
||||
function ntkoSendDataToChildtext(ntkoDataSendUrl)
|
||||
{
|
||||
if(ntkoSendDataToChildSData!=null&&ntkoSendDataToChildSData!="")
|
||||
{
|
||||
ntkoBrowser.ntkoSendDataToChild(ntkoDataSendUrl,ntkoSendDataToChildSData);
|
||||
}
|
||||
}
|
||||
/*___md5___*/
|
||||
|
||||
var hexcase = 0;
|
||||
var b64pad = "";
|
||||
var chrsz = 8;
|
||||
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
|
||||
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
|
||||
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
|
||||
function md5_vm_test()
|
||||
{
|
||||
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
|
||||
}
|
||||
function core_md5(x, len)
|
||||
{
|
||||
x[len >> 5] |= 0x80 << ((len) % 32);
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
|
||||
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
|
||||
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
|
||||
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
|
||||
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
|
||||
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
|
||||
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
|
||||
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
|
||||
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
|
||||
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
|
||||
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
|
||||
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
|
||||
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
|
||||
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
|
||||
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
|
||||
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
|
||||
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
|
||||
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
|
||||
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
|
||||
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
|
||||
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
|
||||
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
|
||||
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
|
||||
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
|
||||
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
|
||||
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
|
||||
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
|
||||
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
|
||||
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
|
||||
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
|
||||
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
|
||||
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
|
||||
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
|
||||
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
|
||||
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
|
||||
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
|
||||
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
|
||||
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
|
||||
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
|
||||
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
|
||||
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
|
||||
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
|
||||
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
|
||||
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
|
||||
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
|
||||
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
|
||||
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
|
||||
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
|
||||
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
|
||||
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
|
||||
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
|
||||
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
|
||||
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
|
||||
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
|
||||
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
|
||||
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
|
||||
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
|
||||
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
|
||||
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
|
||||
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
|
||||
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
|
||||
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
|
||||
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
|
||||
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
}
|
||||
return Array(a, b, c, d);
|
||||
}
|
||||
function md5_cmn(q, a, b, x, s, t)
|
||||
{
|
||||
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
|
||||
}
|
||||
function md5_ff(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
||||
}
|
||||
function md5_gg(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
||||
}
|
||||
function md5_hh(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
function md5_ii(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
|
||||
}
|
||||
|
||||
function core_hmac_md5(key, data)
|
||||
{
|
||||
var bkey = str2binl(key);
|
||||
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
|
||||
return core_md5(opad.concat(hash), 512 + 128);
|
||||
}
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
function bit_rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
function str2binl(str)
|
||||
{
|
||||
var bin = Array();
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < str.length * chrsz; i += chrsz)
|
||||
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
|
||||
return bin;
|
||||
}
|
||||
function binl2str(bin)
|
||||
{
|
||||
var str = "";
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < bin.length * 32; i += chrsz)
|
||||
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
|
||||
return str;
|
||||
}
|
||||
function binl2hex(binarray)
|
||||
{
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i++)
|
||||
{
|
||||
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
|
||||
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function binl2b64(binarray)
|
||||
{
|
||||
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i += 3)
|
||||
{
|
||||
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
|
||||
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
|
||||
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
|
||||
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
export default ntkoBrowser;
|
||||
/*接收 子页面数据*/
|
||||
function NTKOPostMessage(param){
|
||||
window.postMessage(param, "*")
|
||||
}
|
||||
function NTKO_DOC_PostMessage(param){
|
||||
window.postMessage({type: 'FROM_RETURN_DOC',text: param}, "*")
|
||||
}
|
||||
function NTKO_PDF_PostMessage(param){
|
||||
window.postMessage({type: 'FROM_RETURN_PDF',text: param}, "*")
|
||||
}
|
||||
function NTKO_HTML_PostMessage(param){
|
||||
window.postMessage({type: 'FROM_RETURN_HTML',text: param}, "*")
|
||||
}
|
@ -1,195 +1,238 @@
|
||||
import {Button, message, Modal} from "antd"
|
||||
import {Button, Drawer, Input, message, Modal, Popconfirm, Spin} from "antd"
|
||||
import React from "react"
|
||||
// import './components/ntkoStyle.css';
|
||||
import ntkoBrowser from './components/ntkobackground.min.js';
|
||||
import {getFileCode, selectFile} from './service'
|
||||
|
||||
import {getFileCode, selectFile, selectFileS} from './service'
|
||||
import {SnowflakeID} from "@/services/untilService";
|
||||
|
||||
|
||||
export default class weboffice extends React.Component {
|
||||
|
||||
uninitialized = true;// true :未初始化 false:初始化 可用此参数判断文件是否编辑
|
||||
|
||||
windowType = false;//窗口状态 false不存在 不允许保存按钮 true存在 允许保存
|
||||
|
||||
current_browser: any;//浏览器
|
||||
DocfileCode: any;//word 文件id
|
||||
PDFfileCode: any;//PDF 文件id
|
||||
DocfileCode = "";//word 文件id
|
||||
PDFfileCode = "";//PDF 文件id
|
||||
HTMLfileCode = "";//HTML 文件id
|
||||
|
||||
readonly: any;//文件是否可编辑
|
||||
uploadDOCType = "";//word上传状态
|
||||
uploadPDFType = "";//word上传状态
|
||||
uploadHTMLType = "";//word上传状态
|
||||
|
||||
btnStyle = "none";//按钮是否隐藏
|
||||
btnName = "保存";//按钮名字
|
||||
memberBtnName = "编辑/查看";//非ie按钮文字
|
||||
savePDF = "0";//是否保存pdf 0不保存 1保存
|
||||
saveHTML = "0";//是否保存HTML 0不保存 1保存
|
||||
|
||||
divType=false;
|
||||
loadIng: any;
|
||||
|
||||
DownUrl = "/api/core-service-ebtp-updownload/v1/attachment/download/bid/";//下载地址
|
||||
UpUrl = "/api/core-service-ebtp-updownload/v1/attachment/upload";//上传地址
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.props.onRef(this);
|
||||
this.state = {
|
||||
Tips: ""
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
componentDidMount() {
|
||||
if (!ntkoBrowser.ExtensionInstalled()) {
|
||||
this.divType=true;
|
||||
Modal.info({
|
||||
title: "您尚未安装文档控件,请您下载并安装后,重新访问当前页面",
|
||||
content: (
|
||||
<div style={{padding: "12%"}}><Button
|
||||
onClick={() => location.href = '/officecontrol/NTKO控件安装程序-联通数字科技有限公司.exe'}>下载</Button></div>
|
||||
)
|
||||
})
|
||||
}
|
||||
// 监听message事件
|
||||
window.addEventListener("message", this.receiveMessage, false);
|
||||
this.getRelevantCode();
|
||||
}
|
||||
|
||||
receiveMessage = async (event?: any) => {
|
||||
if (event !== undefined && event.data) {
|
||||
|
||||
/*文件保存状态*/
|
||||
if (event?.data != null && event?.data != undefined) {
|
||||
let FileMsg = event?.data;
|
||||
if (FileMsg == this.DocfileCode) {
|
||||
// alert("doc上传成功")
|
||||
this.uploadDOCType = "success";
|
||||
}
|
||||
if (FileMsg == this.PDFfileCode) {
|
||||
// alert("pdf上传成功")
|
||||
this.uploadPDFType = "success";
|
||||
}
|
||||
if (FileMsg == this.HTMLfileCode) {
|
||||
// alert("html上传成功")
|
||||
this.uploadHTMLType = "success";
|
||||
}
|
||||
}
|
||||
/*office关闭事件*/
|
||||
if (event?.data?.text != null && event?.data?.text != undefined) {
|
||||
let text = JSON.parse(event?.data?.text);
|
||||
if (text?.ntkoData?.functionName == "ntkoClose" && text?.ntkoData?.ntkoGUID == ntkoBrowser.thisNTKOGUID) {
|
||||
Modal.destroyAll();
|
||||
if (this.uploadDOCType == "success") {
|
||||
if (this.savePDF == "1") {
|
||||
if (this.uploadPDFType == "success") {
|
||||
if (this.saveHTML == "1") {
|
||||
if (this.uploadHTMLType == "success") {
|
||||
this.memberBtnName = "编辑";
|
||||
this.setState({Tips: "已保存正文内容,点击"});
|
||||
}
|
||||
}else{
|
||||
this.memberBtnName = "编辑";
|
||||
this.setState({Tips: "已保存正文内容,点击"});
|
||||
}
|
||||
}
|
||||
}else {
|
||||
this.memberBtnName = "编辑";
|
||||
this.setState({Tips: "已保存正文内容,点击"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ModalRamove() {
|
||||
ntkoBrowser.ntkoClose("/webofficeChromeEvolution.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&HTMLfileCode=" + this.HTMLfileCode + "&savePDF=" + this.savePDF + "&saveHTML=" + this.saveHTML)
|
||||
}
|
||||
|
||||
editLoading() {
|
||||
Modal.info({
|
||||
title: '文本编辑器打开中,请在弹出窗口编辑正文',
|
||||
okText: <></>,
|
||||
okButtonProps: {disabled: true},
|
||||
cancelButtonProps: {disabled: true}
|
||||
});
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
getFileCode() {
|
||||
let code = "";
|
||||
getFileCode().then(res => {
|
||||
code = res.id;
|
||||
this.DocfileCode = code;
|
||||
});
|
||||
return code;
|
||||
}
|
||||
|
||||
async getRelevantCode() {
|
||||
|
||||
/*提交方法 doc*/
|
||||
Submit() {
|
||||
if (this.uninitialized) {
|
||||
message.warn("您还未进行编辑");
|
||||
return;
|
||||
}
|
||||
let msg = "";
|
||||
/*ie 直接嗲用相关方法 进行保存 但是由于ie为内嵌方式 所以不管理窗口状态*/
|
||||
if (this.current_browser == "ie") {
|
||||
const ntko = document.getElementById("TANGER_OCX");
|
||||
/*url&文件类型(file)&其它参数&文件名&其它 */
|
||||
let DOCmsg = ntko.SaveToURL(this.UpUrl, "file", "businessId=" + this.DocfileCode + "&file=" + this.DocfileCode, this.DocfileCode + ".doc", "");
|
||||
if (JSON.parse(DOCmsg).success) {
|
||||
this.uploadDOCType = "success";
|
||||
if (this.props.DocfileCode == undefined || this.props.DocfileCode == "") {
|
||||
|
||||
if (this.props.readonly == "true") {
|
||||
this.memberBtnName = "查看";
|
||||
} else {
|
||||
this.uploadDOCType = "error";
|
||||
}
|
||||
if (this.PDFfileCode != "" && this.savePDF == "1") {
|
||||
ntko.PublishAsPDFToURL("/api/core-service-ebtp-updownload/v1/attachment/upload/", "file", "businessId=" + this.PDFfileCode + "&file=" + this.PDFfileCode, this.PDFfileCode + ".pdf")
|
||||
console.log(ntko.AfterPublishAsPDFToURL = selectFile(this.PDFfileCode).then(res => {
|
||||
if (res[this.DocfileCode].length > 0) {
|
||||
this.uploadDOCType = "success";
|
||||
} else {
|
||||
this.uploadDOCType = "error";
|
||||
}
|
||||
}));
|
||||
this.memberBtnName = "新建";
|
||||
}
|
||||
await SnowflakeID().then(res => {
|
||||
this.DocfileCode = res.id;
|
||||
})
|
||||
this.setState({Tips: "无正文内容,点击"});
|
||||
} else {
|
||||
this.DocfileCode = this.props.DocfileCode;
|
||||
|
||||
} /*非ie浏览器 由于是弹出窗口方式 所以用命令方式操作组件*/
|
||||
else {
|
||||
var url = "/weboffice.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&savePDF=" + this.savePDF;
|
||||
if (this.savePDF == "1") {
|
||||
ntkoBrowser.ntkoSendDataToChild(url, "SavePDF");//发送自定义参数 Save 为保存指令
|
||||
if (this.props.readonly == "true") {
|
||||
this.memberBtnName = "查看";
|
||||
} else {
|
||||
this.memberBtnName = "编辑";
|
||||
}
|
||||
ntkoBrowser.ntkoSendDataToChild(url, "Save");//发送自定义参数 Save 为保存指令
|
||||
/*等待2秒 判断子页面回传数据是否为成功,若成功则关闭插件窗口 */
|
||||
let timer_num = 0;
|
||||
let timer = setInterval(() => {
|
||||
timer_num++;
|
||||
this.uploadDOCType = ntkoBrowser.AboutWebOfficeDOCType;
|
||||
this.uploadPDFType = ntkoBrowser.AboutWebOfficePDFType;
|
||||
if (ntkoBrowser.AboutWebOfficeDOCType == "success") {
|
||||
if (this.savePDF != "1" && ntkoBrowser.AboutWebOfficeDOCType == "success") {
|
||||
ntkoBrowser.ntkoClose(url);
|
||||
}
|
||||
if (this.savePDF == "1" && ntkoBrowser.AboutWebOfficeDOCType == "success" && ntkoBrowser.AboutWebOfficePDFType == "success") {
|
||||
ntkoBrowser.ntkoClose(url);
|
||||
}
|
||||
clearInterval(timer);
|
||||
}
|
||||
/*大于 20秒左右 或者 获取到上传失败结果 关闭定时器 上传失败 */
|
||||
if (timer_num > 20 || ntkoBrowser.AboutWebOfficeDOCType == "error") {
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
this.setState({Tips: "已保存正文内容,点击"});
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
/*加载/判断ie还是其它浏览器 并且加载相应标签*/
|
||||
initWebOffice() {
|
||||
/*判断savePDF状态 以及生成or获取PDFfileCode */
|
||||
if (this.props.savePDF != undefined && this.props.savePDF == "1") {
|
||||
this.savePDF = "1";
|
||||
if (this.props.PDFfileCode != undefined && this.props.PDFfileCode != "") {
|
||||
this.PDFfileCode = this.props.PDFfileCode;
|
||||
} else {
|
||||
SnowflakeID().then(res => {
|
||||
await SnowflakeID().then(res => {
|
||||
this.PDFfileCode = res.id;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (this.props.btnStyle != undefined && this.props.btnStyle != "") {
|
||||
this.btnStyle = this.props.btnStyle;
|
||||
}
|
||||
if (this.props.btnName != undefined && this.props.btnName != "") {
|
||||
this.btnName = this.props.btnName;
|
||||
}
|
||||
if (this.props.memberBtnName != undefined && this.props.memberBtnName != "") {
|
||||
this.memberBtnName = this.props.memberBtnName;
|
||||
}
|
||||
this.readonly = this.props.readonly;//是否可以编辑
|
||||
if (this.props.DocfileCode == undefined || this.props.DocfileCode == "") {
|
||||
this.getFileCode();
|
||||
} else {
|
||||
this.DocfileCode = this.props.DocfileCode;
|
||||
}
|
||||
// @ts-ignore
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window || navigator.userAgent.indexOf("Edge") > -1) { // 判断是否是ie浏览器
|
||||
this.current_browser = "ie";
|
||||
setTimeout(() => {
|
||||
const ntko = document.getElementById("TANGER_OCX");
|
||||
// @ts-ignore
|
||||
selectFile(this.DocfileCode).then(res => {
|
||||
if (res[this.DocfileCode].length > 0) {
|
||||
// @ts-ignore
|
||||
ntko.BeginOpenFromURL("/api/core-service-ebtp-updownload/v1/attachment/download/bid/" + this.DocfileCode);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
ntko.CreateNew("Word.Document");
|
||||
}
|
||||
// @ts-ignore
|
||||
ntko.IsUseOfficeConvertDocToPDF = true;
|
||||
/*判断saveHTML状态 以及生成or获取HTMLfileCode */
|
||||
if (this.props.saveHTML != undefined && this.props.saveHTML == "1") {
|
||||
this.saveHTML = "1";
|
||||
if (this.props.HTMLfileCode != undefined && this.props.HTMLfileCode != "") {
|
||||
this.HTMLfileCode = this.props.HTMLfileCode;
|
||||
} else {
|
||||
await SnowflakeID().then(res => {
|
||||
this.HTMLfileCode = res.id;
|
||||
})
|
||||
if (this.readonly != "false") {
|
||||
// @ts-ignore
|
||||
ntko.SetReadOnly(true);//只读
|
||||
} else {
|
||||
// @ts-ignore
|
||||
ntko.SetReadOnly(false);//可编辑
|
||||
}
|
||||
this.uninitialized = false;
|
||||
}, 2000);
|
||||
|
||||
return (
|
||||
// @ts-ignore
|
||||
<object width={"100%"} height={"100%"} id="TANGER_OCX" classID="clsid:A64E3073-2016-4baf-A89D-FFE1FAA10ED1"
|
||||
codebase="/ofctnewclsid.cab#version=6.0.1.0">
|
||||
<param name="MakerCaption" value="联通系统集成有限公司"/>
|
||||
{/*买断授权标题栏名称和密钥,标志着唯一的授权。正式版本用户请参考发布包中的使用说明*/}
|
||||
<param name="MakerKey" value="D130003CD231496EBD17D6DAC22DEFC6BD8F4E17"/>
|
||||
<param name="ProductCaption" value="联通系统集成有限公司"/>
|
||||
{/*标题栏名称和密钥,标志着唯一的授权。正式版本用户请参考发布包中的使用说明。*/}
|
||||
<param name="ProductKey" value="F6C911699ECD29CC0D2E47822CF1775B3A80C13F"/>
|
||||
<param name="NoExpireKey" value="'+NoExpireKey+'"/>
|
||||
<param name="IsUseUTF8URL" value="-1"/>
|
||||
{/*读取/设置是否使用UTF-8传输URL,缺省值:TRUE*/}
|
||||
<param name="IsUseUTF8Data" value="-1"/>
|
||||
{/*UTF-8在智能提交中传输网页数据;缺省值:FALSE。*/}
|
||||
{/*<param name="Caption" value="NTKO OFFICE文档控件示例演示 http://www.ntko.com"/>*/}
|
||||
</object>
|
||||
)
|
||||
} else {
|
||||
this.current_browser = "not_ie";
|
||||
return (<Button
|
||||
onClick={() => {
|
||||
this.uninitialized = false;
|
||||
(ntkoBrowser.openWindow("/weboffice.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&savePDF=" + this.savePDF))
|
||||
}}>{this.memberBtnName}</Button>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*加载/判断ie还是其它浏览器 并且加载相应标签*/
|
||||
initWebOffice() {
|
||||
|
||||
this.readonly = this.props.readonly;//是否可以编辑
|
||||
// @ts-ignore
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window || navigator.userAgent.indexOf("Edge") > -1) { // 判断是否是ie浏览器
|
||||
this.current_browser = "ie";
|
||||
this.uninitialized = false;
|
||||
setTimeout(() => {
|
||||
}, 2000)
|
||||
|
||||
if(this.DocfileCode==""){
|
||||
message.error("获取文档id失败,请您稍后重试")
|
||||
return (<></>)
|
||||
}else{
|
||||
return (<>
|
||||
<div style={{width:"100%"}}>
|
||||
<iframe width={"100%"} height={600}
|
||||
src={"/webofficeIeEvolution.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&HTMLfileCode=" + this.HTMLfileCode + "&savePDF=" + this.savePDF + "&saveHTML=" + this.saveHTML}/>
|
||||
</div>
|
||||
</>);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.current_browser = "not_ie";
|
||||
return (
|
||||
<>
|
||||
<span>{this.state.Tips}</span>
|
||||
<Button size={"small"}
|
||||
onClick={() => {
|
||||
this.uninitialized = false;
|
||||
this.windowType = true;
|
||||
this.editLoading();
|
||||
(ntkoBrowser.openWindow("/webofficeChromeEvolution.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&HTMLfileCode=" + this.HTMLfileCode + "&savePDF=" + this.savePDF + "&saveHTML=" + this.saveHTML));
|
||||
}
|
||||
}>{this.memberBtnName}</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
testBut() {
|
||||
|
||||
}
|
||||
|
||||
testBut2() {
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
let div;
|
||||
div = this.initWebOffice();
|
||||
return (
|
||||
<>
|
||||
{div}
|
||||
<Button style={{"display": this.props.btnStyle}} onClick={() => this.Submit()}>{this.props.btnName}</Button>
|
||||
<div hidden={this.divType}>
|
||||
{this.initWebOffice()}
|
||||
</div>
|
||||
|
||||
</>
|
||||
)
|
||||
|
298
src/pages/webOffice/weboffice0609.tsx
Normal file
298
src/pages/webOffice/weboffice0609.tsx
Normal file
@ -0,0 +1,298 @@
|
||||
/*
|
||||
* @Author: zhoujianlong
|
||||
* @Date: 2021-06-09 15:29:07
|
||||
* @Last Modified by: zhoujianlong
|
||||
* @Last Modified time: 2021-08-16 16:09:49
|
||||
*/
|
||||
import { getFileBidList, SnowflakeID } from '@/services/untilService';
|
||||
import { Button, Modal } from 'antd';
|
||||
import { LoadingOutlined } from '@ant-design/icons';
|
||||
import React, { useEffect, useState, useImperativeHandle } from 'react';
|
||||
|
||||
interface WebOfficeProps {
|
||||
DOCFileCode?: string; //word 文件id *必填*
|
||||
PDFFileCode?: string; //PDF 文件id
|
||||
HTMLFileCode?: string; //HTML 文件id
|
||||
savePDF?: boolean; //是否保存为PDF true-保存 false-不保存 可以不传默认为false
|
||||
saveHTML?: boolean; //是否保存为HTML true-保存 false-不保存 可以不传默认为false
|
||||
readOnly?: boolean; //只读 true-查看 false-可编辑 *必填*
|
||||
webOfficeRef?: React.MutableRefObject<WebOfficeRefProps | undefined>; //父组件传入的ref参数 用于实时调取子组件内部参数 *必填*
|
||||
afterSaveFunc?: () => void //weboffice保存成功后执行的方法
|
||||
}
|
||||
|
||||
export interface WebOfficeRefProps {
|
||||
DocFileCode: string;
|
||||
PDFFileCode: string;
|
||||
HTMLFileCode: string;
|
||||
uploadDocType: boolean;
|
||||
uploadPDFType: boolean;
|
||||
uploadHTMLType: boolean;
|
||||
}
|
||||
|
||||
const WebOffice0609: React.FC<WebOfficeProps> = (props) => {
|
||||
const { DOCFileCode, PDFFileCode, HTMLFileCode, savePDF, saveHTML, readOnly, webOfficeRef, afterSaveFunc } = {
|
||||
DOCFileCode: '',
|
||||
PDFFileCode: '',
|
||||
HTMLFileCode: '',
|
||||
savePDF: false,
|
||||
saveHTML: false,
|
||||
readOnly: false,
|
||||
afterSaveFunc: () => {},
|
||||
...props,
|
||||
};
|
||||
|
||||
//存储weboffice渲染状态
|
||||
const [renderCode, setRenderCode] = useState<number>(-1);
|
||||
//按钮显示文字
|
||||
const [btnName, setBtnName] = useState<string>('');
|
||||
//按钮前提示文字
|
||||
const [beforeBtnText, setBeforeBtnText] = useState<string>('');
|
||||
//存储docFileCode
|
||||
const [docFileCode_, setDocFileCode_] = useState<string>(DOCFileCode);
|
||||
//存储pdfFileCode
|
||||
const [pdfFileCode_, setPdfFileCode_] = useState<string>(PDFFileCode);
|
||||
//存储htmlFileCode
|
||||
const [htmlFileCode_, setHtmlFileCode_] = useState<string>(HTMLFileCode);
|
||||
//word上传状态
|
||||
const [uploadDocType_, setUploadDocType_] = useState<boolean>(false);
|
||||
//pdf上传状态
|
||||
const [uploadPDFType_, setUploadPDFType_] = useState<boolean>(false);
|
||||
//html上传状态
|
||||
const [uploadHTMLType_, setUploadHTMLType_] = useState<boolean>(false);
|
||||
|
||||
//选择暴露给父组件的参数或方法
|
||||
useImperativeHandle(
|
||||
webOfficeRef,
|
||||
() => ({
|
||||
DocFileCode: uploadDocType_ ? docFileCode_ : '',
|
||||
PDFFileCode: uploadPDFType_ ? pdfFileCode_ : '',
|
||||
HTMLFileCode: uploadHTMLType_ ? htmlFileCode_ : '',
|
||||
uploadDocType: uploadDocType_,
|
||||
uploadPDFType: uploadPDFType_,
|
||||
uploadHTMLType: uploadHTMLType_,
|
||||
}),
|
||||
[docFileCode_, pdfFileCode_, htmlFileCode_, uploadDocType_, uploadPDFType_, uploadHTMLType_],
|
||||
);
|
||||
useEffect(() => {
|
||||
updateWebOffice();
|
||||
}, [DOCFileCode]);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('message', receiveMessage, false); // 监听message事件,用于接收从子页面返回的参数
|
||||
return () => window.removeEventListener('message', receiveMessage);
|
||||
}, [docFileCode_, pdfFileCode_, htmlFileCode_]);
|
||||
|
||||
//获取雪花id方法(新建状态的文档id)
|
||||
const getSnowflakeId = async () => {
|
||||
let id: string = '';
|
||||
let status: number = 0; //与父级的状态码参数一致
|
||||
await SnowflakeID()
|
||||
.then((res) => {
|
||||
id = res?.id;
|
||||
})
|
||||
.catch((item) => {
|
||||
status = 3;
|
||||
});
|
||||
return {
|
||||
id: id,
|
||||
status: status,
|
||||
};
|
||||
};
|
||||
|
||||
//点击按钮后的弹窗遮罩
|
||||
const editLoading = () => {
|
||||
let text = '编辑';
|
||||
text = readOnly ? '查看' : '编辑';
|
||||
Modal.info({
|
||||
title: `文档编辑器打开中,请在弹出窗口${text}正文`,
|
||||
okText: <></>,
|
||||
okButtonProps: { hidden: true },
|
||||
cancelButtonProps: { hidden: true },
|
||||
centered: true,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 文字显示初始化和fileCode存储
|
||||
*/
|
||||
const updateWebOffice = async () => {
|
||||
let errorStatus = 0; //错误状态码参数 0-正常 1-未安装控件提示下载 2-状态为查看但未获取到docFileCode 3-获取雪花id接口报错
|
||||
//判断安装环境
|
||||
if (!window.ntkoBrowser.ExtensionInstalled()) {
|
||||
setRenderCode(1); //错误类型为1,即未安装控件
|
||||
return;
|
||||
}
|
||||
//WORD文档部分
|
||||
if (
|
||||
DOCFileCode == '' ||
|
||||
DOCFileCode == null ||
|
||||
DOCFileCode == undefined ||
|
||||
DOCFileCode == 'null' ||
|
||||
DOCFileCode == 'undefined'
|
||||
) {
|
||||
if (readOnly) {
|
||||
setBtnName('查看');
|
||||
setRenderCode(2); //错误类型为2,即状态为查看但未获取到docFileCode
|
||||
return;
|
||||
} else {
|
||||
setBtnName('新建');
|
||||
setBeforeBtnText('无正文内容,点击');
|
||||
//无doc文档id,获取雪花id
|
||||
await getSnowflakeId().then((res) => {
|
||||
setDocFileCode_(res?.id);
|
||||
errorStatus = res?.status;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
let name = readOnly ? '查看' : '编辑';
|
||||
setBtnName(name);
|
||||
setBeforeBtnText('已保存正文内容,点击');
|
||||
//doc状态更新
|
||||
await getFileBidList(DOCFileCode).then((res) => {
|
||||
if (res?.length > 0) {
|
||||
setUploadDocType_(true);
|
||||
} else {
|
||||
setUploadDocType_(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
//PDF文档部分
|
||||
if (savePDF) {
|
||||
if (
|
||||
PDFFileCode == '' ||
|
||||
PDFFileCode == null ||
|
||||
PDFFileCode == undefined ||
|
||||
PDFFileCode == 'null' ||
|
||||
PDFFileCode == 'undefined'
|
||||
) {
|
||||
//无pdf文档id,获取雪花id
|
||||
await getSnowflakeId().then((res) => {
|
||||
setPdfFileCode_(res?.id);
|
||||
errorStatus = res?.status;
|
||||
});
|
||||
} else {
|
||||
//pdf状态更新
|
||||
await getFileBidList(PDFFileCode).then((res) => {
|
||||
if (res?.length > 0) {
|
||||
setUploadPDFType_(true);
|
||||
} else {
|
||||
setUploadPDFType_(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//HTML文档部分
|
||||
if (saveHTML) {
|
||||
if (
|
||||
HTMLFileCode == '' ||
|
||||
HTMLFileCode == null ||
|
||||
HTMLFileCode == undefined ||
|
||||
HTMLFileCode == 'null' ||
|
||||
HTMLFileCode == 'undefined'
|
||||
) {
|
||||
//无html文档id,获取雪花id
|
||||
await getSnowflakeId().then((res) => {
|
||||
setHtmlFileCode_(res?.id);
|
||||
errorStatus = res?.status;
|
||||
});
|
||||
} else {
|
||||
//pdf状态更新
|
||||
await getFileBidList(HTMLFileCode).then((res) => {
|
||||
if (res?.length > 0) {
|
||||
setUploadHTMLType_(true);
|
||||
} else {
|
||||
setUploadHTMLType_(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//最终渲染规则
|
||||
setRenderCode(errorStatus);
|
||||
};
|
||||
|
||||
//接收子页面返回参数方法
|
||||
const receiveMessage = async (event: any) => {
|
||||
if (event !== undefined && event?.data) {
|
||||
/*文件保存状态*/
|
||||
if (event?.data != null && event?.data != undefined) {
|
||||
let FileMsg = event?.data;
|
||||
if (FileMsg?.type == 'FROM_RETURN_DOC' && FileMsg?.text == docFileCode_) {
|
||||
//回调参数DOC专用标记
|
||||
setUploadDocType_(true);
|
||||
//调用回调方法(可能没有)
|
||||
afterSaveFunc();
|
||||
setBeforeBtnText('已保存正文内容,点击');
|
||||
setBtnName('编辑');
|
||||
} else if (FileMsg?.type == 'FROM_RETURN_HTML' && FileMsg?.text == htmlFileCode_) {
|
||||
//回调参数HTML专用标记
|
||||
setUploadHTMLType_(true);
|
||||
} else if (FileMsg?.type == 'FROM_RETURN_PDF' && FileMsg?.text == pdfFileCode_) {
|
||||
//回调参数PDF专用标记
|
||||
setUploadPDFType_(true);
|
||||
} else if (
|
||||
FileMsg?.type == 'FROM_NTKO_CLOSE' &&
|
||||
FileMsg?.text == window.ntkoBrowser.thisNTKOGUID
|
||||
) {
|
||||
Modal.destroyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{renderCode == 0 ? (
|
||||
<>
|
||||
<span>{beforeBtnText}</span>
|
||||
<Button
|
||||
size="small"
|
||||
key="openWebOffice"
|
||||
onClick={() => {
|
||||
editLoading();
|
||||
let openUrl = '/webofficeIeComponent';
|
||||
if (window.ntkoBrowser.NtkoBrower()) {
|
||||
//判断浏览器
|
||||
openUrl = '/webofficeComponent';
|
||||
}
|
||||
openUrl += `.html?readonly=${readOnly}&DocfileCode=${docFileCode_}&PDFfileCode=${pdfFileCode_}&HTMLfileCode=${htmlFileCode_}&savePDF=${savePDF}&saveHTML=${saveHTML}`;
|
||||
window.ntkoBrowser.openWindow(openUrl);
|
||||
}}
|
||||
>
|
||||
{btnName}
|
||||
</Button>
|
||||
</>
|
||||
) : renderCode == 1 ? (
|
||||
<div>
|
||||
<span>
|
||||
您尚未安装文档控件,请您点击
|
||||
<Button
|
||||
key="download"
|
||||
size="small"
|
||||
onClick={() =>
|
||||
(window.location.href = '/officecontrol/NTKO控件安装程序-联通数字科技有限公司.exe')
|
||||
}
|
||||
>
|
||||
下载
|
||||
</Button>
|
||||
并安装后,重新访问当前页面
|
||||
</span>
|
||||
</div>
|
||||
) : renderCode == 2 ? (
|
||||
<div>
|
||||
<span>无正文内容</span>
|
||||
</div>
|
||||
) : renderCode == 3 ? (
|
||||
<div>
|
||||
<span>新建正文内容参数获取失败,请联系管理员</span>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ height: '24px' }}>
|
||||
<LoadingOutlined />
|
||||
文档控件加载中,请稍等···
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WebOffice0609;
|
67
src/pages/webOffice/weboffice4Path.tsx
Normal file
67
src/pages/webOffice/weboffice4Path.tsx
Normal file
@ -0,0 +1,67 @@
|
||||
import React, {useState} from "react";
|
||||
import ntkoBrowser from './components/ntkobackground.min.js';
|
||||
import {Button, message, Modal} from "antd";
|
||||
import {selectFile} from "@/pages/webOffice/service";
|
||||
|
||||
interface weboffice4PathData {
|
||||
path?: string;//文件路由
|
||||
edit?: string;//文件方式
|
||||
btn?: string;//按钮名称
|
||||
}
|
||||
|
||||
const Weboffice4Path: React.FC<weboffice4PathData> = (props) => {
|
||||
const {path, edit, btn} = {path:"",edit: "read", btn: "查看", ...props};
|
||||
const [pageContent, setPageContent] = useState<any>("");
|
||||
if (()=>ntkoBrowser.ExtensionInstalled()) {
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window || navigator.userAgent.indexOf("Edge") > -1) {//========ie
|
||||
setTimeout(() => {
|
||||
const ntko = document.getElementById("TANGER_OCX");
|
||||
// @ts-ignore
|
||||
if (path!="") {
|
||||
// @ts-ignore
|
||||
ntko.BeginOpenFromURL(path);
|
||||
} else {
|
||||
message.error("未获取到文件路径,请您联系相关客服人员!")
|
||||
}
|
||||
// @ts-ignore
|
||||
ntko.SetReadOnly(true);//只读
|
||||
}, 2000);
|
||||
return(
|
||||
<object width={"100%"} height={"100%"} id="TANGER_OCX" classID="clsid:A64E3073-2016-4baf-A89D-FFE1FAA10ED1"
|
||||
codebase="/officecontrol/ofctnewclsid.cab#version=6,0,1,0">
|
||||
<param name="MakerCaption" value="联通数字科技有限公司"/>
|
||||
{/*买断授权标题栏名称和密钥,标志着唯一的授权。正式版本用户请参考发布包中的使用说明*/}
|
||||
<param name="MakerKey" value="C1AB790358ECC36C0F26DB985E43769912D15699"/>
|
||||
<param name="ProductCaption" value="联通数字科技有限公司---用户"/>
|
||||
{/*标题栏名称和密钥,标志着唯一的授权。正式版本用户请参考发布包中的使用说明。*/}
|
||||
<param name="ProductKey" value="E714270401FE1F799797DD27B134CDA12EB8D942"/>
|
||||
<param name="NoExpireKey" value="'+NoExpireKey+'"/>
|
||||
<param name="IsUseUTF8URL" value="-1"/>
|
||||
{/*读取/设置是否使用UTF-8传输URL,缺省值:TRUE*/}
|
||||
<param name="IsUseUTF8Data" value="-1"/>
|
||||
{/*UTF-8在智能提交中传输网页数据;缺省值:FALSE。*/}
|
||||
{/*<param name="Caption" value="NTKO OFFICE文档控件示例演示 http://www.ntko.com"/>*/}
|
||||
</object>
|
||||
)
|
||||
|
||||
} else {
|
||||
//========其它
|
||||
return(
|
||||
<
|
||||
Button
|
||||
onClick={() => {
|
||||
ntkoBrowser.openWindow("/Weboffice4Path.html?path="+encodeURIComponent(path))
|
||||
}}>{btn}</Button>
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Modal.info({
|
||||
title: "您尚未安装文档控件,请您下载并安装后,重新访问当前页面",
|
||||
content: (
|
||||
<div style={{padding:"12%"}}><Button onClick={() => location.href = '/officecontrol/NTKO控件安装程序-联通数字科技有限公司.exe'}>下载</Button></div>
|
||||
)
|
||||
})
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export default Weboffice4Path
|
200
src/pages/webOffice/webofficeEvolutiont.tsx
Normal file
200
src/pages/webOffice/webofficeEvolutiont.tsx
Normal file
@ -0,0 +1,200 @@
|
||||
import {Button, Drawer, Input, message, Modal, Popconfirm, Spin} from "antd"
|
||||
import React from "react"
|
||||
// import './components/ntkoStyle.css';
|
||||
import ntkoBrowser from './components/ntkobackground.min.js';
|
||||
|
||||
import {getFileCode, selectFile, selectFileS} from './service'
|
||||
import {SnowflakeID} from "@/services/untilService";
|
||||
|
||||
|
||||
export default class weboffice extends React.Component {
|
||||
|
||||
uninitialized = true;// true :未初始化 false:初始化 可用此参数判断文件是否编辑
|
||||
|
||||
windowType=false;//窗口状态 false不存在 不允许保存按钮 true存在 允许保存
|
||||
|
||||
current_browser: any;//浏览器
|
||||
DocfileCode = "";//word 文件id
|
||||
PDFfileCode = "";//PDF 文件id
|
||||
HTMLfileCode = "";//HTML 文件id
|
||||
|
||||
readonly: any;//文件是否可编辑
|
||||
uploadDOCType = "";//word上传状态
|
||||
uploadPDFType = "";//word上传状态
|
||||
uploadHTMLType = "";//word上传状态
|
||||
|
||||
btnStyle = "none";//按钮是否隐藏
|
||||
btnName = "保存";//按钮名字
|
||||
memberBtnName = "编辑/查看";//非ie按钮文字
|
||||
savePDF = "0";//是否保存pdf 0不保存 1保存
|
||||
saveHTML = "0";//是否保存HTML 0不保存 1保存
|
||||
|
||||
Tips = "";
|
||||
|
||||
|
||||
loadIng: any;
|
||||
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.props.onRef(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// 监听message事件
|
||||
window.addEventListener("message", this.receiveMessage, false);
|
||||
this.getRelevantCode();
|
||||
}
|
||||
receiveMessage = async ( event?:any ) => {
|
||||
if(event!==undefined &&event.data){
|
||||
/*office关闭事件*/
|
||||
if(event?.data?.text!=null&&event?.data?.text!=undefined){
|
||||
let text =JSON.parse(event?.data?.text);
|
||||
if(text?.ntkoData?.functionName=="ntkoClose"&&text?.ntkoData?.ntkoGUID==ntkoBrowser.thisNTKOGUID){
|
||||
Modal.destroyAll();
|
||||
}
|
||||
}
|
||||
/*文件保存状态*/
|
||||
if(event?.data!=null&&event?.data!=undefined){
|
||||
let FileMsg=event?.data;
|
||||
if(FileMsg==this.DocfileCode){
|
||||
// alert("doc上传成功")
|
||||
this.uploadDOCType="success";
|
||||
}
|
||||
if(FileMsg==this.PDFfileCode){
|
||||
// alert("pdf上传成功")
|
||||
this.uploadPDFType="success";
|
||||
}
|
||||
if(FileMsg==this.HTMLfileCode){
|
||||
// alert("html上传成功")
|
||||
this.uploadHTMLType="success";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
ModalRamove (){
|
||||
ntkoBrowser.ntkoClose("/webofficeChromeEvolution.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&HTMLfileCode=" + this.HTMLfileCode + "&savePDF=" + this.savePDF + "&saveHTML=" + this.saveHTML)
|
||||
}
|
||||
|
||||
editLoading () {
|
||||
Modal.info({
|
||||
title: '文件编辑中',
|
||||
okText:<></>,
|
||||
okButtonProps: {disabled: true},
|
||||
cancelButtonProps: {disabled: true}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
getFileCode() {
|
||||
let code = "";
|
||||
getFileCode().then(res => {
|
||||
code = res.id;
|
||||
});
|
||||
return code;
|
||||
}
|
||||
|
||||
getRelevantCode(){
|
||||
if (this.props.DocfileCode == undefined || this.props.DocfileCode == "") {
|
||||
this.Tips="无正文内容,点击";
|
||||
if(this.props?.readonly=="true"){
|
||||
this.memberBtnName="查看";
|
||||
} else {
|
||||
this.memberBtnName="新建";
|
||||
}
|
||||
SnowflakeID().then(res => {
|
||||
this.DocfileCode = res.id;
|
||||
})
|
||||
} else {
|
||||
this.DocfileCode = this.props.DocfileCode;
|
||||
this.Tips="已保存正文内容,点击";
|
||||
if(this.props?.readonly=="true"){
|
||||
this.memberBtnName="查看";
|
||||
} else {
|
||||
this.memberBtnName="编辑";
|
||||
}
|
||||
}
|
||||
if (this.props.savePDF != undefined && this.props.savePDF == "1") {
|
||||
this.savePDF = "1";
|
||||
if (this.props.PDFfileCode != undefined && this.props.PDFfileCode != "") {
|
||||
this.PDFfileCode = this.props.PDFfileCode;
|
||||
} else {
|
||||
SnowflakeID().then(res => {
|
||||
this.PDFfileCode = res.id;
|
||||
})
|
||||
}
|
||||
}
|
||||
/*判断saveHTML状态 以及生成or获取HTMLfileCode */
|
||||
if (this.props.saveHTML != undefined && this.props.saveHTML == "1") {
|
||||
this.saveHTML = "1";
|
||||
if (this.props.HTMLfileCode != undefined && this.props.HTMLfileCode != "") {
|
||||
this.HTMLfileCode = this.props.HTMLfileCode;
|
||||
} else {
|
||||
SnowflakeID().then(res => {
|
||||
this.HTMLfileCode = res.id;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*加载/判断ie还是其它浏览器 并且加载相应标签*/
|
||||
initWebOffice() {
|
||||
if (()=>ntkoBrowser.ExtensionInstalled()) {
|
||||
this.readonly = this.props.readonly;//是否可以编辑
|
||||
// @ts-ignore
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window || navigator.userAgent.indexOf("Edge") > -1) { // 判断是否是ie浏览器
|
||||
this.current_browser = "ie";
|
||||
this.uninitialized = false;
|
||||
setTimeout(()=>{},2000)
|
||||
return(<>
|
||||
<div>
|
||||
<iframe width={"100%"} height={600} src={"/webofficeIeEvolution.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&HTMLfileCode=" + this.HTMLfileCode + "&savePDF=" + this.savePDF + "&saveHTML=" + this.saveHTML}/>
|
||||
</div>
|
||||
</>);
|
||||
|
||||
} else {
|
||||
this.current_browser = "not_ie";
|
||||
return (
|
||||
<>
|
||||
<p>{this.Tips}</p>
|
||||
<Button
|
||||
onClick={() => {
|
||||
this.uninitialized = false;
|
||||
this.windowType=true;
|
||||
this.editLoading();
|
||||
(ntkoBrowser.openWindow("/webofficeChromeEvolution.html?readonly=" + this.readonly + "&DocfileCode=" + this.DocfileCode + "&PDFfileCode=" + this.PDFfileCode + "&HTMLfileCode=" + this.HTMLfileCode + "&savePDF=" + this.savePDF + "&saveHTML=" + this.saveHTML));
|
||||
}
|
||||
}>{this.memberBtnName}</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Modal.info({
|
||||
title: "您尚未安装文档控件,请您下载并安装后,重新访问当前页面",
|
||||
content: (
|
||||
<div style={{padding:"12%"}}><Button onClick={() => location.href = '/officecontrol/NTKO控件安装程序-联通数字科技有限公司.exe'}>下载</Button></div>
|
||||
)
|
||||
})
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testBut(){
|
||||
}
|
||||
testBut2(){
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
{/*<Button onClick={()=>this.testBut()}>测试按钮1</Button>*/}
|
||||
{/*<Button onClick={()=>this.testBut2()}>测试按钮2</Button>*/}
|
||||
{this.initWebOffice()}
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user