lsc 2 years ago
parent
commit
b5ff2c124a
2 changed files with 357 additions and 5 deletions
  1. 326 0
      js/Desktop/DeskTop.js
  2. 31 5
      js/Office/Word/Word.js

+ 326 - 0
js/Desktop/DeskTop.js

@@ -887,6 +887,12 @@ window.addEventListener('message', function (e) { // 监听 message 事件
         U.MD.D.I.openInApplication("hanUrl", '', '', '')
     } else if (e.data.tools && e.data.tools == "46") {
         U.MD.D.I.openApplication("project")
+    } else if (e.data.tools && e.data.tools == "1s") {
+        U.MD.D.I.openApplicationJieS("whiteboard", e.data.cid, e.data.stage, e.data.task, e.data.tool)
+    } else if (e.data.tools && e.data.tools == "3s") {
+        U.MD.D.I.openApplicationJieS("mind", e.data.cid, e.data.stage, e.data.task, e.data.tool)
+    } else if (e.data.tools && e.data.tools == "6s") {
+        U.MD.D.I.openApplicationJieS("doc", e.data.cid, e.data.stage, e.data.task, e.data.tool)
     }
 
 });
@@ -2924,4 +2930,324 @@ U.MD.D.I.getContent = function (cid, s, task, t, uid, type, iframe) {
     xmlhttp.open("GET", US.Config.pbl + "selectWord2?uid=" + uid + "&cid=" + cid + "&s=" + s + "&task=" + task + "&t=" + t + "&type=" + type, true);
     xmlhttp.send();
 
+}
+
+
+U.MD.D.I.openApplicationJieS = function (str, cid, stage, task, tool) {
+    var _taskbar, //_taskbar 作为任务栏显示的元素,包含图标和名字
+        _formdiv, //创建任务栏时同时弹出的窗体元素。
+        _userinfo = US.userInfo, //登录用户信息
+        _userid = US.userInfo.userid //登录用户id
+    let _iframe;
+    let _cid = cid,
+        _stage = stage,
+        _task = task,
+        _tool = tool;
+    var _jie = $$("div", {
+        "style": {
+            "position": "absolute",
+            "bottom": "50px",
+            "right": "50px",
+            "zIndex": "9999",
+            "backgroundColor": "#2268bc",
+            "color": "#fff",
+            "padding": "12px 20px",
+            "cursor": "pointer",
+            "borderRadius": "4px",
+        },
+        "innerHTML": "提交作业"
+    })
+    let aTool = ''
+    let _loading = document.createElement('div')
+    _loading.style = "width:100%;height:100%;background:#00000000;position:absolute;top:0;left:0;z-index:99999999999999;display: none;justify-content: center;align-items: center;"
+    //  _loading.id = "";
+    let _lchild = document.createElement('div')
+    let _limg = document.createElement('img')
+    _limg.src = 'https://pbl.cocorobo.cn/pbl-student-table/dist/js/loading.gif'
+    _limg.style = "width: 26px;margin-right: 10px;"
+    _lchild.appendChild(_limg)
+    let _lspan = document.createElement('span')
+    _lspan.innerHTML = "上传中..."
+    _lchild.appendChild(_lspan)
+    _lchild.style = "color: #fff;padding: 15px;background: #00000070;border-radius: 5px;font-size: 18px;display:flex;align-items:center;"
+    _loading.appendChild(_lchild)
+
+    var _box = $$('div', {
+        "style": {
+            "position": "relative",
+            "width": "100%",
+            "height": "100%",
+        },
+    })
+    _box.appendChild(_loading)
+    _box.id = str + '_loadLi'
+    switch (str) {
+        case "whiteboard":
+            aTool = 1;
+            _iframe = $$("iframe", {
+                "frameborder": "no",
+                "border": "0",
+                "scrolling ": "no",
+                "style": {
+                    "cssText": "border:0;width:100%;height:100%"
+                },
+                "src": "https://iwb.cocorobo.cn/"
+            })
+            _box.appendChild(_iframe);
+            _box.appendChild(_jie);
+            _formdiv = new U.UF.UI.form(
+                "电子白板",
+                _box, {
+                "id": "whiteboards",
+                "style": {
+                    "width": "90%",
+                    "height": "90%",
+                    "overflow": 'hidden'
+                },
+                "onresize": function () { }
+            }, {
+                closecallback: function () { }
+            }, {
+                "style": {
+                    "height": "36px"
+                }
+            }).form; //创建窗体
+            _taskbar = {
+                "id": str + _formdiv.id,
+                "style": {
+                    "backgroundImage": "url(/img/icon/whiteBoard.png)"
+                },
+                "name": "电子白板",
+                "forms": _formdiv,
+                "click": function () {
+                    U.MD.D.I.openApplication(str, obj, info);
+                }
+            }
+            break;
+        case "mind":
+            aTool = 3;
+            _iframe = $$("iframe", {
+                "frameborder": "no",
+                "border": "0",
+                "scrolling ": "no",
+                "style": {
+                    "cssText": "border:0;width:100%;height:100%"
+                },
+                "src": "/kityminder-editor/dist/index.html"
+            })
+            _box.appendChild(_iframe);
+            _box.appendChild(_jie);
+            _formdiv = new U.UF.UI.form(
+                "思维导图",
+                _box, { //"/jsmind/example/demo.html" 
+                "id": "minds",
+                "style": {
+                    "width": "90%",
+                    "height": "90%",
+                    "overflow": 'hidden'
+                },
+                "onresize": function () { }
+            }, {
+                closecallback: function () { }
+            }, {
+                "style": {
+                    "height": "36px"
+                }
+            }).form; //创建窗体
+            _taskbar = {
+                "id": str + _formdiv.id,
+                "style": {
+                    "backgroundImage": "url(/img/icon/mindMapping.png)"
+                },
+                "name": "思维导图",
+                "forms": _formdiv,
+                "click": function () {
+                    U.MD.D.I.openApplication(str, obj, info);
+                }
+            }
+            break;
+        case "doc":
+            aTool = 6;
+            _iframe = $$("iframe", {
+                "frameborder": "no",
+                "border": "0",
+                "scrolling ": "no",
+                "style": {
+                    "cssText": "border:0;width:100%;height:100%"
+                },
+                "src": "/Office/Word/WordEditArea.htm"
+            })
+            _box.appendChild(_iframe);
+            _box.appendChild(_jie);
+            _formdiv = new U.UF.UI.form(
+                "协同文档",
+                _box, {
+                "id": "docs",
+                "style": {
+                    "width": "90%",
+                    "height": "90%",
+                    "overflow": 'hidden'
+                },
+                "onresize": function () { }
+            }, {
+                closecallback: function () { }
+            }, {
+                "style": {
+                    "height": "36px"
+                }
+            }).form; //创建窗体
+
+            U.UF.DL.iframeLoad($("iframe", _formdiv)[0], function () {
+                $("iframe", _formdiv)[0].contentWindow.U.MD.O.W.load(cid, stage, task, tool, '2');
+            })
+            _taskbar = {
+                "id": str + _formdiv.id,
+                "style": {
+                    "backgroundImage": "url(/img/icon/doc.png)"
+                },
+                "name": "协同文档",
+                "forms": _formdiv,
+                "click": function () {
+                    U.MD.D.I.openApplication(str, obj, info);
+                }
+            }
+            break;
+    }
+    const script1 = document.createElement("script");
+    script1.type = "text/javascript";
+    script1.src =
+        "https://pbl.cocorobo.cn/pbl-student-table/dist/js/jquery-3.6.0.min.js";
+    const script2 = document.createElement("script");
+    script2.type = "text/javascript";
+    script2.src =
+        "https://pbl.cocorobo.cn/pbl-student-table/dist/js/aws-sdk-2.235.1.min.js";
+    const script3 = document.createElement("script");
+    script3.type = "text/javascript";
+    script3.charset = "UTF-8";
+    script3.src = "https://cloud.cocorobo.cn/js/Common/html2canvas.min.js";
+    const script4 = document.createElement("script");
+    script4.type = "text/javascript";
+    script4.src = "https://pbl.cocorobo.cn/pbl-student-table/dist/js/jietu4.js";
+
+    if (_iframe) {
+        if (str == 'doc') {
+            U.UF.DL.iframeLoad(_iframe, function () {
+                _iframe.contentWindow.U.MD.O.W.load(cid, stage, task, tool);
+                _iframe.contentWindow.document.body.appendChild(script1);
+                _iframe.contentWindow.document.body.appendChild(script2);
+                // _iframe.contentWindow.document.body.appendChild(script3);
+                _iframe.contentWindow.document.body.appendChild(script4);
+            })
+        } else if (str == 'mind') {
+            U.UF.DL.iframeLoad(_iframe, function () {
+                // 
+                _iframe.contentWindow.document.body.appendChild(script1);
+                _iframe.contentWindow.document.body.appendChild(script2);
+                _iframe.contentWindow.document.body.appendChild(script4);
+                U.MD.D.I.getContents(cid, stage, task, tool, _userid, '2', _iframe)
+            })
+        } else {
+            _iframe.onload = () => {
+                _iframe.contentWindow.document.body.appendChild(script1);
+                _iframe.contentWindow.document.body.appendChild(script2);
+                // _iframe.contentWindow.document.body.appendChild(script3);
+                _iframe.contentWindow.document.body.appendChild(script4);
+            };
+        }
+        _jie.onclick = async () => {
+            let text = ''
+            if (aTool == 6) {
+                text = _iframe.contentWindow.$("#U_MD_O_H_wordEditor")[0].innerHTML.escapeQuotes()
+            } else if (aTool == 3) {
+                text = await U.MD.D.I.getEditorContent(_iframe);
+            }
+            _loading.style.display = 'flex'
+            console.log(_loading);
+            var _ajs = _iframe.contentWindow.document.createElement("script");
+            _ajs.type = "text/javascript";
+            _ajs.innerHTML =
+                // 'console.log(' + _loading + ');\n' +
+                'var _js = document.createElement("script");\n' +
+                '_js.type="text/javascript";\n' +
+                '_js.charset="UTF-8";\n' +
+                '_js.src="https://cloud.cocorobo.cn/js/Common/html2canvas.min.js";\n' +
+                "_js.onload = function(){\n" +
+                ' var a = document.getElementsByTagName("img")\n' +
+                ' for(var i = 0;i<a.length;i++){a[i].crossOrigin="anonymous"}\n' +
+                " html2canvas(document.body,{allowTaint: true,useCORS: true}).then(canvas => {\n" +
+                '  var base64Url = canvas.toDataURL("image/png");\n' +
+                'var base64 = "<img src=" + base64Url + " />"\n' +
+                'var file = dataURLtoFile_shishi(base64Url, "截图")\n' +
+                "beforeUpload_shishi(file," +
+                "'" +
+                _userid +
+                "'" +
+                ", " +
+                "'" +
+                _cid +
+                "'" +
+                ", " +
+                "'" +
+                _stage +
+                "'" +
+                ", " +
+                "'" +
+                _task +
+                "'" +
+                ", " +
+                "'" +
+                _tool +
+                "'" +
+                ", " +
+                "'" +
+                str + '_loadLi' +
+                "'" +
+                ", " +
+                "'" +
+                aTool +
+                "'" +
+                ", " +
+                "`" +
+                text +
+                "`" +
+                ")\n" +
+                " });\n" +
+                "}\n" +
+                "document.head.appendChild(_js);\n";
+            _iframe.contentWindow.document.head.appendChild(_ajs);
+        }
+    }
+
+    //U.MD.D.I.openClick(str);
+    //如果有任务栏信息
+    if (_taskbar) {
+        U.MD.D.T.taskbar(_taskbar); //创建任务处理
+    }
+
+}
+
+U.MD.D.I.getContents = function (cid, s, task, t, uid, type, iframe) {
+    var xmlhttp;
+    var Mac, Sn, DeviceId
+    if (window.XMLHttpRequest) {
+        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
+        xmlhttp = new XMLHttpRequest();
+    }
+    else {
+        // IE6, IE5 浏览器执行代码
+        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+    }
+    xmlhttp.onreadystatechange = function () {
+        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
+            if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
+                // resolve(res.value[0][0].text);
+                iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text).then(function (data) {
+                    $(fileInput).val('');
+                });
+            }
+        }
+    }
+    xmlhttp.open("GET", US.Config.pbl + "selectWords?uid=" + uid + "&cid=" + cid + "&s=" + s + "&task=" + task + "&t=" + t + "&type=" + type, true);
+    xmlhttp.send();
+
 }

+ 31 - 5
js/Office/Word/Word.js

@@ -32,15 +32,23 @@ US = parent.US;
  * @return  {object}    返回当前窗体 
  */
 // U.MD.O.W.load = async function (fileid, userinfo) {
-U.MD.O.W.load = async function (cid, stage, task, tool) {
+U.MD.O.W.load = async function (cid, stage, task, tool,type) {
     //U.MD.O.W.openRoomConfirm();
     // var fileinfo = U.MD.O.W.getfile(),
     var fileinfo, userinfo;
     userinfo = await U.MD.O.W.getuser();
-    if (cid && (stage || stage == 0) && (task || task == 0) && (tool || tool == 0)) {
-        fileinfo = await U.MD.O.W.getWork(cid, stage, task, tool, userinfo.userid);
-    } else {
-        fileinfo = U.MD.O.W.getfile()
+    if(type == '2'){
+        if (cid && (stage || stage == 0) && (task || task == 0) && (tool || tool == 0)) {
+            fileinfo = await U.MD.O.W.getWorkS(cid, stage, task, tool, userinfo.userid);
+        } else {
+            fileinfo = U.MD.O.W.getfile()
+        }
+    }else{
+        if (cid && (stage || stage == 0) && (task || task == 0) && (tool || tool == 0)) {
+            fileinfo = await U.MD.O.W.getWork(cid, stage, task, tool, userinfo.userid);
+        } else {
+            fileinfo = U.MD.O.W.getfile()
+        }
     }
 
     U.MD.O.W.variable(fileinfo, userinfo); //初始化全局变量
@@ -653,6 +661,24 @@ U.MD.O.W.getWork = async function (cid, s, task, t, uid) {
     });
 }
 
+U.MD.O.W.getWorkS = async function (cid, s, task, t, uid) {
+    return new Promise((resolve, reject) => {
+        U.A.Request(US.Config.pbl + "selectWords?uid=" + uid + "&cid=" + cid + "&s=" + s + "&task=" + task + "&t=" + t + "&type=1", [], function (res) {
+            if (res.value[0].length > 0) {
+                US.wordRoomInfo = res.value[0][0];
+                let a = {
+                    UserDirectoryExtendType: "uw", //默认导航模式
+                    UsOffice: res.value[0][0].text,
+                    UserDirectoryID: Guid.newGuid(),
+                    newfile: true
+                }
+                resolve(a);
+            }
+        }, [], { "type": "GET", "withCredentials": true });
+    });
+}
+
+
 /**
  * 创建目录的窗体
  *