123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880 |
- //查看指定文件,,判断是否保存或者覆盖,包括创建邀请协作人员,创建编辑历史,创建生成链接.创建热门模板。加载当前word文档的内容。创建光标,监控键盘输入等。这里是iframe中的word起始点。
- //监控输入输出,
- //添加成员,共同编辑。
- Namespace.register("U.MD.O.W");
- document.oncontextmenu = U.UF.EV.stopDefault; //禁止右键菜单
- //由于当前文档的js是加载在ifame里面的,获取不到外部的文档(www.1473.cn)信息。所以通过传递参数设置全局变量的形式保存当前文档信息。
- //id是word文档id,PID是文档归属的目录id,fileinfo是文档的实体信息fileinfo,OL初始化回调函数,userid是当前文档创建者的id。 historyid就是最新历史记录的id
- U.MD.O.W = {
- "fileinfo": null, //文档的信息
- "userinfo": null, //文档用户的信息
- "historyid": US.EMPTYGUID, //历史记录更新的id
- "permission": { //权限设置
- "edit": true,
- "web": true
- },
- "init": false
- };
- US = parent.US;
- //#region 初始化区域
- //------------------------------------------------------------------------------初始化Word----------------------------------------------------------------------------
- //查看指定文件,,判断是否保存或者覆盖,包括创建邀请协作人员,创建编辑历史,创建生成链接.创建热门模板。加载当前word文档的内容。创建光标,监控键盘输入等。这里是iframe中的word起始点。
- /**
- * word初始化的处理
- *
- * @param {object} 文档信息
- * @param {object} 登录用户信息
- * @return {object} 返回当前窗体
- */
- // U.MD.O.W.load = async function (fileid, userinfo) {
- 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 (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); //初始化全局变量
- U.MD.O.W.setPermission(); //获取权限
- U.MD.O.W.setEvent(); //设置事件
- U.MD.O.W.E.createSelection(); //创建下拉框
- U.MD.O.W.E.toolsbind(); //初始化工具栏
- U.MD.O.W.loadContent(fileinfo); //加载内容
- //加载功能
- U.MD.O.W.Panel.loadlink(fileinfo); //加载链接窗体
- //U.MD.O.W.Panel.loadHotTemplates(); //加载热门模板
- //U.MD.O.W.Panel.loadOfficeHistory(fileinfo); //加载历史记录
- // U.MD.O.W.Panel.loadPlayUser(fileinfo); //加载协助人员窗体
- // //如果是协作文档,加载协作窗体
- // if (U.MD.O.W.permission.web) {
- // U.MD.O.W.Panel.loadPlayUser(fileinfo); //加载协助人员窗体
- // }
- // //如果不是协同文档,那么协同文档的窗体不显示,那么热门和链接窗体向上移
- // else {
- // $("#LoadOfficeHistory")[0].style.top = "140px";
- // $("#LoadHotTemplates")[0].style.top = "434px";
- // }
- }
- /**
- * 根据cookie获取用户
- *
- */
- U.MD.O.W.getuser = async function () {
- return new Promise((resolve, reject) => {
- U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
- if (res.value && res.value[0] && res.value[0][0]) {
- var _user = res.value[0][0];
- U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
- if (res.value && res.value[0] && res.value[0][0]) {
- US.userInfo = res.value[0][0];
- U.A.Request(US.Config.pbl + "selectUser?userid=" + _user.userid, [], function (res) { //US.userInfo.userid
- if (res.value == null || res.value[0].length == 0) {
- US.userInfo.userid = _user.userid;
- resolve(US.userInfo); //记录用户数据
- } else {
- US.userInfo = res.value[0][0];
- US.userInfo.userid = _user.userid;
- resolve(res.value[0][0]); //记录用户数据
- }
- }, [], { "type": "GET", "withCredentials": true });
- }
- }, [], { "type": "GET", "withCredentials": true });
- }
- }, [], { "type": "GET", "withCredentials": true });
- });
- }
- U.MD.O.W.getMyfile = function () {
- return {
- UserDirectoryExtendType: "uw", //默认导航模式
- UsOffice: US.data,
- UserDirectoryID: Guid.newGuid(),
- newfile: US.roomid ? false : true,
- };
- }
- /**
- * 根据文件id获取文件
- *
- */
- U.MD.O.W.getfile = function (fileid) {
- return {
- UserDirectoryExtendType: "uw", //默认导航模式
- UsOffice: '',
- //UsOffice: '<div id="e4c133031-1982-c72b-525a-32a2ffb5bd4c" style="text-align: center;" name="U_MD_O_W_Font_Heading1"><span style="font-family: 微软雅黑; font-size: 48px; font-weight: bold;">什么是互联办公?</span></div><div id="e3412c1ae-730c-f87e-494c-c5df81a459e0" style="line-height: 2;"><span style="font-family: 微软雅黑; font-size: 16px;"> 为了提高办公效率,解决现有word不能多人协同办公的问题,解决在外地旅游、出差不能办公的问题,我们提出了互联办公的概念。</span></div><div id="ecf866d78-6644-f14f-74f9-c31eaa0097a0" style="line-height: 2;"><span style="font-family: 微软雅黑; font-size: 16px;"> 互联办公云平台是一款可以多端操作、多人协同、以网页形式编辑、以网站形式展示的互联网办公平台。互联办公云平台可以在ipad、手机、电脑以及其他支持浏览器的终端设备上进行操作;可以多人共同编辑同一份文档,实现文档的自动整合以及实时更新;可以在主流浏览器上进行文档的编辑修改,也可以输入好网站内容,一键发布完成专业化的企业网站。</span></div><div id="e8901ef2d-0b82-138f-91b0-e5697edfd6ca" style="line-height: 2;"><span style="font-family: 微软雅黑; font-size: 16px;"> 互联办公云平台前端采用html+css技术实现, 后端使用java,Net,Nodejs予以实现,web服务器采用分布式集群部署,支持多人同时在线。</span><br></div><div id="e9c0df904-ebab-1392-7364-4ccab9862a9c" style="line-height: 2;"><br></div><div id="ebdb59933-5920-b5ae-1568-27fc769aeb3b" style="font-family: 微软雅黑; font-weight: bold; font-size: 16pt;" name="U_MD_O_W_Font_Heading2"><span style=""></span><span>1.实现随时随地办公</span></div><div id="ebd1bf28a-4f62-4ec1-346a-bb388c2191cd" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;">当需要紧急修改文件时,即使你在外地,在旅游,在出差,拿出手机即可修改文件,修改好的文件会即时呈现在领导面前,解决了用户出门在外不能同步办公的难题。</span></div><div id="e9a9993df-f28c-461b-0880-2848f1c2ccdc" style="line-height: 2;"><br></div><div id="e117f341a-f3c4-3d44-9145-57b86e09765c" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;"></span></div><div id="eb878bcdc-91a8-cd5c-d7bd-0e506fc83d0b" style="font-family: 微软雅黑; font-weight: bold; font-size: 16pt; line-height: 2;" name="U_MD_O_W_Font_Heading2"><span>2.解决了现有word不能多人协同办公的问题</span></div><div id="ec9514631-09c8-8329-a9de-106f7d88594f" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;">互联办公云平台把Word互联网化,允许多人编辑同一份文件,效果即时呈现,适合收集用户资料场景,提高办公效率。</span></div><div id="ecb60e99a-6e75-0c84-8b41-f5aa6b130d05" style="line-height: 2;"><br></div><div id="e99e0c9dd-506c-3d63-07cd-ff4a46f232b5" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;"></span></div><div id="e7f202d5b-8e90-a816-1ce8-5c12fde78637" style="font-family: 微软雅黑; font-weight: bold; font-size: 16pt; line-height: 2;" name="U_MD_O_W_Font_Heading2"><span>3.提高办公效率</span></div><div id="e2fdfea7a-38fb-b8bb-7ee5-a96644677f14" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;">解决了人们需分工合作以及整合文档需耗费大量时间的难题,当你需要收集公司各成员的个人信心档案时,只需要一个链接邀请大家编辑,成百上千个人就会在一份文档里面填写资料,以此解决用户需分工合作,整合文档工作量过大的问题。</span></div><div id="ea863ad74-d055-e53b-c23d-d1c76cbc5ee4" style="line-height: 2;"><br></div><div id="edb122ca1-ec53-5040-28f7-b0e2790869ee" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;"></span></div><div id="e332557aa-d8d2-45c9-d2e5-147fb7d8bf2c" style="font-family: 微软雅黑; font-weight: bold; font-size: 16pt; line-height: 2;" name="U_MD_O_W_Font_Heading2"><span>4.Word直接生成企业网站</span></div><div id="e22923078-2bcf-06a2-566f-ab1ed876afa5" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;">互联办公云平台为企业办公人员提供导航模式,用户无需了解前后台代码,以所见即所得的方式,编辑网站内容,一键发布即可生成专业化的企业网站,为企业解决需找专业代码人员耗费大量时间及耗费大量资金的问题。</span></div><div id="e08ee9567-3e92-999b-ba7e-815db2e29477" style="line-height: 2;"><br></div><div id="e50a05822-32af-439f-85bd-186f5358a6ba" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;"></span></div><div id="e9169080d-5ce2-c385-519d-952aea83d3f2" style="font-family: 微软雅黑; font-weight: bold; font-size: 16pt; line-height: 2;" name="U_MD_O_W_Font_Heading2"><span>5.解决用户文件丢失的问题</span></div><div id="e4a9be289-9b20-9131-4986-e530367a1d04" style="line-height: 2;"><span style="font-size: 18px; font-family: 微软雅黑;">互联办公云平台为用户提供所有文件支持云端存储,可上传任何格式的文件的功能用户不需要安装应用,只需要在网页上输入网址即可找到自己的文件。云端网盘采用树目录分类,方便用户查找文件,以此解决文件容易丢失的问题。</span><span style="font-size: 18px;"></span><span style=""></span><br></div>',
- UserDirectoryID: Guid.newGuid(),
- newfile: fileid ? false : true
- };
- }
- /**
- * 初始化全局变量
- * @param {object} 文档信息
- * @param {object} 登录用户信息
- *
- */
- U.MD.O.W.variable = function (fileinfo, userinfo) {
- //如果已经有全局变量 说明该文档已经是加载过了,不需要重复设置
- if (!U.MD.O.W.fileinfo) {
- U.MD.O.W.fileinfo = fileinfo //文档信息
- }
- //设置用户信息,为什么上面的不需要重复设置下面的需要呢,因为用户可能会注销
- U.MD.O.W.userInfo = userinfo; //用户信息
- }
- /**
- * 编辑器权限函数
- * @return 返回用户权限json
- */
- U.MD.O.W.setPermission = function () {
- U.MD.O.W.permission.web = true; //互联办公的权限
- U.MD.O.W.permission.edit = true; //就给其编辑权限
- // var _iseditor, _isgroup; //是否可编辑 //群用户
- // //权限主要包含了是否可编辑,是否互联办公文档查看
- // //判断文件是否是用户的群文档 US.friend.group这个变量需要独立
- // if (U.MD.O.W.fileinfo.GroupID && US.friend.group) {
- // _isgroup = U.Json.select(US.friend.group, { "GroupManageID": U.MD.O.W.fileinfo.GroupID });
- // if (_isgroup) {
- // U.MD.O.W.permission.web = true; //互联办公的权限
- // U.MD.O.W.permission.edit = true; //就给其编辑权限
- // }
- // }
- // //如果是共享文档,那么谁都可以编辑,如果是自己的文档那么也可以编辑
- // else if (((U.MD.O.W.fileinfo.GroupID && U.MD.O.W.fileinfo.GroupID == U.MD.O.W.userInfo.userid) || U.MD.O.W.fileinfo.UserId == US.userInfo.userid)) {//判断是否是有编辑权限
- // U.MD.O.W.permission.edit = true; //就给其编辑权限
- // if (U.MD.O.W.fileinfo.UserId == US.userInfo.userid) {
- // U.MD.O.W.permission.web = true;//互联办公的权限
- // }
- // }
- }
- /**
- * 设置事件
- *
- */
- U.MD.O.W.setEvent = function () {
- //un文件设置事件
- if (U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un') {
- //设置保存事件
- $('#U_MD_O_H_save')[0].onclick = function () {
- U.MD.O.W.T.N.saveNav(function () {
- U.MD.O.W.T.N.savePage(null, true);
- });
- }
- $('body').addClass('U_MD_O_W_Nav');
- }
- //uw文件设置事件
- else {
- //设置保存事件
- $('#U_MD_O_H_save')[0].onclick = function () {
- U.MD.O.W.save()
- }
- $('body').removeClass('U_MD_O_W_Nav');
- }
- //设置新建事件
- $('#U_MD_O_H_new')[0].onclick = function () {
- U.MD.O.W.newdocument();
- }
- //下载处理
- $("#U_MD_O_H_Area_Down")[0].onclick = function () {
- top.U.MD.C.D.downloadFileOrDir([U.MD.O.W.fileinfo], "true"); //下载文档
- }
- //添加Ctrl+S快捷保存事件
- $('body')[0].onkeydown = function (e) {
- var currKey = 0;
- e = e || event || window.event;
- currKey = e.keyCode;
- if (currKey == 83 && (e.ctrlKey || e.metaKey)) {
- $('#U_MD_O_H_save')[0].onclick();
- U.UF.EV.stopDefault();
- U.UF.EV.stopBubble();
- }
- };
- }
- /**
- * 加载Word编辑区域的内容
- * @param {string} 文档信息
- */
- U.MD.O.W.loadContent = function (fileinfo) {
- var _defaultnav,
- _permission = U.MD.O.W.permission, //获取权限
- _fileid = fileinfo.UserDirectoryID; //文档id
- //新建文件的处理
- if (fileinfo.newfile) {
- //un新建文件的处理
- if (U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un') {
- //默认导航的处理
- try {
- _defaultnav = JSON.parse(U.MD.O.W.fileinfo.UsOffice);
- } catch (e) {
- _defaultnav = { logo: "", nav: [{ pageId: Guid.newGuid(), name: "初始页面" }] };
- }
- //创建默认导航文档
- U.MD.O.W.T.N.form(_defaultnav);
- }
- //uw文件新建处理
- else {
- //初始化编辑器
- U.MD.O.W.E.initEditor();
- }
- //清楚文件新建的属性,说明文件不是新建
- delete fileinfo.newfile;
- }
- //互联办公文档获取数据
- else if (_permission.web) {
- parent.U.A.Request(US.SCOKET, [U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un' ? 'getNav' : "getWord", _fileid, US.pageId, U.MD.O.W.userInfo.userid], U.MD.O.W.asynLoad, [$("#U_MD_O_H_wordEditor")[0], fileinfo, _permission.web]); //获取office内容
- }
- //普通文档在数据库里面获取数据
- else {
- parent.U.A.Request(US.DISK, ["GetFileContent", _fileid], U.MD.O.W.asynLoad, [$("#U_MD_O_H_wordEditor")[0], fileinfo, _permission.web]);
- }
- }
- /**
- * 异步获取Word编辑区域的数据
- *
- */
- U.MD.O.W.asynLoad = function (r) { //object 值
- var _permission,
- _fileinfo = U.MD.O.W.fileinfo,
- _context = r.context, //获取array值
- _fileinfo = _context[1], //获取文件信息
- _synergy = _context[2]; //互联权限
- //获取后台返回的值,第一个是直接从数据库获取的,所以必须要从UsOffice获取值
- if (r.value && r.value.UsOffice !== undefined) {
- r = r.value.UsOffice;
- } else {
- r = r.value;
- }
- //un文件 导航文件处理
- if (U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un') {
- //因为导航文件默认是json格式的,如果这里从后台获取的值不是json那么进行转化
- if (typeof r != 'object') {
- try {
- r = JSON.parse(r);
- } catch (e) {
- r = { logo: "", nav: [{ pageId: Guid.newGuid(), name: "初始页面" }] };;
- }
- }
- //加载导航和内容
- U.MD.O.W.T.N.form(r);
- }
- //word文件处理
- else {
- //如果数据库里面有内容或者不是服务器文件,直接加载内容
- if (r || !_fileinfo.UserFilesServerName) {
- _fileinfo.UsOffice = (r || "").unEscapeQuotes(); //word内容
- //加载编辑器和内容
- U.MD.O.W.E.initEditor(_synergy); //初始化编辑器
- }
- //如果是office文件第一次初始化的处理
- else {
- //微软的office上传打开的方式
- U.A.Request("http://office.1473.cn/Officetohtml.ashx", ["Open", _fileinfo.UserDirectoryExtendType, _fileinfo.UserFilesServerName], function (r) {
- if (r.value && r.value.value != undefined) {
- r = r.value;
- _fileinfo.UsOffice = r.value.getBodyHtml().replace(/src=[\'\"]?([^\'\"]*)[\'\"]?/ig, function (str1, str2) {
- return "src=\"http://office.1473.cn/usoffice/" + str2 + "\"";
- });
- }
- U.MD.O.W.E.initEditor(_synergy); //初始化编辑器
- }, [""]);
- }
- }
- }
- //#endregion
- //#region 保存区域
- U.MD.O.W.updateEditorLine = function (wordInfo) {
- $("#U_MD_O_H_wordEditor")[0].innerHTML = wordInfo.data;
- }
- /**
- * 判断当前文件是否保存
- *
- * @param {function} 保存回调函数
- */
- U.MD.O.W.isSave = function () {
- var _fileinfo = U.MD.O.W.fileinfo, //word文件
- _fileid = _fileinfo.UserDirectoryID; //文件id
- return ((_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName) && U.MD.O.W.permission.edit); //判断文档是否是已经保存到数据库的文档(判断的依据在于这个文件除了有文件id还有文件名和创建者id)
- }
- U.MD.O.W.updateSocket = function (wordInfo) {
- U.A.Request(US.SCOKET, ["send", JSON.stringify(wordInfo)], function (r) {
- console.log(r);
- });
- }
- U.MD.O.W.updateFileData = function (wordInfo) {
- U.A.Request("http://localhost:7003/api/pbl/" + "updateFileData", [wordInfo.messageInfo.data, wordInfo.receiveId], function (res) { //US.userInfo.userid
- U.Alert("保存成功");
- setTimeout(() => {
- U.MD.O.W.wordDirectory();
- }, 100)
- console.log(res);
- }, [], { "type": "GET", "withCredentials": true });
- }
- U.MD.O.W.wordInfo = function (type, content, navid, userid, roomid) {
- var _data = {
- "us.word": [{
- sendId: userid, //发送人id
- receiveId: roomid, //文件id
- type: navid, //消息类型
- messageInfo: {
- type: type, //类型
- data: content, //内容
- docId: roomid, //文档id
- // pageId: US.pageId, //当前页面id
- },
- },],
- };
- return _data;
- }
- /**
- * 保存Word
- *
- * @param {function} 保存回调函数
- */
- U.MD.O.W.save = function () {
- // var _islogin = top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; });
- // //判断用户是否登录,只有登录用户才能保存信息
- // var _isftp,
- // _isgroupuser,
- // _r, //返回值
- // _uid = U.MD.O.W.userInfo.userid,
- // _el = $("#U_MD_O_H_wordEditor")[0], //word编辑区域
- // _fileinfo = U.MD.O.W.fileinfo, //文件信息
- // _fileid = _fileinfo.UserDirectoryID, //文件ID
- // _name = top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value, //文件名
- // _html = _el.innerHTML.escapeQuotes(); //内容
- // if (top.window.location.href.split("/")[2] != "www.1473.cn") {
- // U.MD.O.W.saveFileOther();
- // } else {
- // //判断文档是否是已经保存到数据库的文档
- // // U.A.Request(US.CD, [US.DB, "UseStudio_Disk", _fileid, "FB1CB716-E42E-4DEA-9A66-F14F0771826F"], function (r) { _r = r.value });
- // //if (_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) {
- // if (_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
- // U.MD.O.W.Panel.InsertOfficeHistory(_fileinfo, _html, _name, _el); //插入历史记录
- //保存到数据库
- //保存到数据库
- // top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.userid, _fileid, _html, _name, "uw"], function (r) {
- // U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
- let wordInfo = U.MD.O.W.wordInfo(
- "update",
- $("#U_MD_O_H_wordEditor")[0].innerHTML.escapeQuotes(),
- "us.word",
- top.US.userInfo.userid,
- top.US.wordRoomInfo.id,
- );
- U.MD.O.W.updateSocket(wordInfo);
- U.MD.O.W.updateFileData(wordInfo['us.word'][0]);
- // }, (['', _el])); //保存到数据库
- // }
- // //如果文件没有保存,那么直接新建文件
- // else {
- // //调用word新建文档的处理
- // top.U.MD.DK.VW.chosenSaveFile('uw', _fileid, _name, function (fileinfo) {
- // U.MD.O.W.fileinfo = fileinfo; //文档信息
- // top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value = fileinfo.UserDirectoryName; //文件名设置
- // U.MD.O.W.setPermission(); //新建的文件设置权限,根据新建的位置
- // //如果是互联办公文档的处理(第一次新建的文件需要从保存到redis全局变量中,第二次之后都是直接从redis初始化的)
- // if (U.MD.O.W.permission.web) {
- // top.U.A.Request(US.SCOKET, ["newWordSave", _fileid, _html, fileinfo.UserDirectoryName, US.userInfo.userid, US.pageId], function (r) {
- // U.MD.O.W.Panel.loadPlayUser(fileinfo); //加载协助人员窗体
- // U.Alert("保存成功");
- // U.MD.O.W.fileinfo.UsOffice = _el.innerHTML;
- // //设置互联办公编辑回调的事件,这样设置不合理
- // $('#U_MD_O_H_wordEditor')[0].editor.operaNotice = U.MD.O.W.E.operationNotice;
- // });
- // }
- // //如果是普通文档的处理
- // else {
- // //保存到数据库
- // top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.userid, _fileid, _html, fileinfo.UserDirectoryName, "uw"], function (r) {
- // U.Alert("保存成功");
- // U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
- // }, (['', _el])); //保存到数据库
- // }
- // });
- // }
- // }
- }
- /**
- * 修改文件名处理
- *
- * @param {function} 保存回调函数
- */
- U.MD.O.W.updateName = function () {
- var _islogin = top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; }); //判断是否登录
- if (!_islogin) {
- var _fileinfo = U.MD.O.W.fileinfo, //文件信息
- _userinfo = U.MD.O.W.userInfo,
- _type = U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un' ? 'nav' : 'word',
- _fileid = _fileinfo.UserDirectoryID, //文件ID
- _name = top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value;
- //文件名必须本人才能修改
- if (_userinfo.UserId == _fileinfo.UserId) {
- //判断文档是否是已经保存到数据库的文档(判断的依据在于这个文件除了有文件id还有文件名和创建者id)
- if ((_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName) && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
- //如果是互联办公文档的操作
- if (U.MD.O.W.permission.web) {
- top.U.A.Request(US.SCOKET, ["updateName", _type, _fileid, _name, US.userInfo.userid, US.pageId], function (r) {
- if (r.value == "updateNameSuccess") {
- _fileinfo.UserallDirectoryName = _name; //文件全写的名字
- _fileinfo.UserDirectoryName = _name.addEllipsis(20); //文件的缩略名
- }
- });
- }
- //普通文档修改信息
- else {
- top.U.A.Request(US.DISK, ["UpdateFileInfo", _fileid, _name], function (r) {
- if (r.value) {
- _fileinfo.UserallDirectoryName = _name; //文件全写的名字
- _fileinfo.UserDirectoryName = _name.addEllipsis(20); //文件的缩略名
- }
- });
- }
- }
- }
- //其他用户不允许修改文件名
- else {
- top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value = _fileinfo.UserallDirectoryName;
- U.alert('非本人操作,修改失败!');
- }
- }
- }
- //#endregion
- //#region 新建文档
- /**
- * 新建文档的处理
- *
- */
- U.MD.O.W.newdocument = function () {
- var _divel = $$("div", { "className": "U_MD_O_newBtn" });
- $$("button", {
- "className": "U_MD_O_newDoc",
- "innerHTML": "普通word",
- "onclick": function () {
- parent.U.MD.O.W.openApplication("word", { "userid": US.userInfo.userid, "directoryid": US.FTPFOLDERID }); //打开文档处理
- $('#U_MD_O_Set')[0].style.display = "none";
- }
- }, _divel);
- $$("button", {
- "className": "U_MD_O_newNav",
- "innerHTML": "导航模板",
- "onclick": function () {
- parent.U.MD.O.W.openApplication("word", { UserDirectoryExtendType: "un" }); //新建导航文档
- $('#U_MD_O_Set')[0].style.display = "none";
- }
- }, _divel);
- new U.UF.UI.form("新建", _divel, { "id": "U_MD_O_Set", "style": { "width": "300px", "height": "150px" } }, { isenlarge: false, isstretching: false }).form;
- }
- //#endregion
- //#region 文档转化
- /**
- * 导航文件转化成普通文件
- */
- U.MD.O.W.newDocSwitch = function () {
- var _fileinfo = U.MD.O.W.fileinfo,
- _fileid = _fileinfo.UserDirectoryID;
- if (_fileinfo.UserDirectoryExtendType == "un") {
- $("#U_MD_O_H_Nav")[0].style.display = "none";
- $("#U_MD_O_W_N").Parent({ usform: "true" }).style.display = "none";
- }
- //获取文件内容异步
- U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileContent", "d17a2910-11ba-df39-cd8a-5cac851c2148"]), function (r) {
- _fileinfo.UserDirectoryExtendType = 'uw'; //设置格式为uw
- _fileinfo.UsOffice = r.value[0].UsOffice.unEscapeQuotes(); //获取值
- _fileinfo.newfile = true; //设置为新建文件
- U.MD.O.W.load(_fileinfo, U.MD.O.W.userInfo); //初始化
- });
- }
- /** * 普通文件转化成导航文件
- */
- U.MD.O.W.newNavSwitch = function () {
- var _fileinfo = U.MD.O.W.fileinfo,
- _fileid = _fileinfo.UserDirectoryID;
- //获取文件内容异步,此为获取默认的宣传文档
- U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileContent", "6a8a235a-41c4-c3d2-8dd5-b6ee851e1967"]), function (r) {
- _fileinfo.UserDirectoryExtendType = 'un'; //设置格式为un
- _fileinfo.UsOffice = r.value[0].UsOffice.unEscapeQuotes(); //获取值
- _fileinfo.newfile = true; //设置为新建文件
- U.MD.O.W.load(_fileinfo, U.MD.O.W.userInfo); //初始化
- });
- }
- window.addEventListener('message', function (e) { // 监听 message 事件
- // alert(e.data.type);
- if (e.data.num && e.data.num != "0") { //项目管理传入
- U.MD.O.W.goRoom(e.data.num);
- } else if (e.data.num && e.data.num == "0") {
- U.MD.O.W.checkNum(e.data.num);
- }
- });
- U.MD.O.W.isRoom = function () {
- U.A.Request(US.Config.pbl + "selectRoomByFile?uid=" + US.userInfo.userid, [], function (res) {
- if (res.value == null || res.value[0].length == 0) {
- U.MD.O.W.openRoomConfirm();
- } else {
- US.numNum = res.value[0][0].num;
- U.MD.O.W.getWork(res.value[0][0].id);
- U.MD.O.W.isOpenRoomConfirm();
- }
- }, [], { "type": "GET", "withCredentials": true });
- }
- U.MD.O.W.MathRand = function () {
- var Num = "";
- for (var i = 0; i < 6; i++) {
- Num += Math.floor(Math.random() * 10);
- }
- return Num;
- }
- U.MD.O.W.checkNum = function () {
- var numNum = U.MD.O.W.MathRand();
- U.A.Request(US.Config.pbl + "checkRoomNumByFile?num=" + numNum, [], function (res) {
- if (res.value == null || res.value[0].length == 0) {
- U.MD.O.W.addRoom(numNum);
- } else {
- U.MD.O.W.checkNum();
- }
- }, [], { "type": "GET", "withCredentials": true });
- }
- U.MD.O.W.addRoom = function (numNum) {
- U.MD.O.W.fileinfo.UsOffice = "";
- U.MD.O.W.E.initEditor(true); //初始化编辑器
- var data = $("#U_MD_O_H_wordEditor")[0].innerHTML.escapeQuotes();
- U.A.Request(US.Config.pbl + "insertRoomByFile", [US.userInfo.userid, numNum, data], function (res) {
- if (res.value == 1) {
- U.alert("创建成功");
- if ($("#add_room")[0]) {
- $("#add_room")[0].close(); //关闭登陆
- }
- U.MD.O.W.isRoom();
- } else {
- U.alert("创建失败");
- }
- }, [], { "type": "GET", "withCredentials": true });
- }
- U.MD.O.W.goRoom = function (number) {
- U.A.Request(US.Config.pbl + "selectRoomByFile?uid=" + number, [], function (res) {
- if (res.value[0].length > 0) {
- U.alert("加入成功");
- if ($("#add_room")[0]) {
- $("#add_room")[0].close();
- }
- U.MD.O.W.getWork(res.value[0][0].id);
- } else {
- U.alert("此房间不存在或已被解散");
- }
- }, [], { "type": "GET", "withCredentials": true });
- }
- U.MD.O.W.copyText = function (target) {
- var div = $(".form_delete-main-room")[0].innerText;
- var clipboard = new ClipboardJS('.copy-message', {
- text: function () {
- return div;
- }
- });
- clipboard.on('success', function (e) {
- console.log(e);
- e.clearSelection();
- U.alert("复制成功");
- });
- clipboard.on('error', function (e) {
- console.log(e);
- U.alert("复制失败");
- });
- }
- U.MD.O.W.getWork = async function (cid, s, task, t, uid) {
- return new Promise((resolve, reject) => {
- U.A.Request(US.Config.pbl + "selectWord?uid=" + uid + "&cid=" + cid + "&s=" + s + "&task=" + task + "&t=" + t, [], function (res) {
- if (res.value[0].length > 0) {
- US.wordRoomInfo = res.value[0][0];
- // U.A.Request(US.SCOKET, ["getWord", rid, US.pageId, US.userInfo.userid], function(r) {
- // U.MD.O.W.fileinfo.UsOffice = US.wordRoomInfo.text;
- // U.MD.O.W.fileinfo.UserDirectoryID = rid;
- // });
- // return res.value[0][0].text
- let a = {
- UserDirectoryExtendType: "uw", //默认导航模式
- UsOffice: res.value[0][0].text,
- UserDirectoryID: Guid.newGuid(),
- newfile: true
- }
- resolve(a);
- // setTimeout(() => {
- // U.MD.O.W.wordDirectory();
- // }, 100)
- } else {
- resolve(U.MD.O.W.getfile())
- }
- }, [], { "type": "GET", "withCredentials": true });
- });
- }
- 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);
- } else {
- resolve(U.MD.O.W.getfile())
- }
- }, [], { "type": "GET", "withCredentials": true });
- });
- }
- /**
- * 创建目录的窗体
- *
- * @param fileinfo {object} 文件信息
- */
- U.MD.O.W.wordDirectory = function (fileinfo) {
- var _coopwindow, _frienddiv, _example, _shareLink, _cBox;
- //如果不存在团队成员窗口,则创建一个团队成员窗口。
- if (!$("#U_MD_O_H_body_left_book")[0]) {
- //创建邀请协助人员窗口
- _coopwindow = $("#U_MD_O_H_body_left")[0];
- _cBox = $$("div");
- // _shareLink = $$("div", {
- // className: 'U_MD_O_H_body_left_invite_linkTxt', "onclick": function () {
- // U.MD.O.W.Panel.isSynergy(U.MD.O.W.Panel.shareLink);
- // }, "innerText": "第三方链接邀请"
- // }, _cBox);
- _frienddiv = $$("div", { "className": "U_MD_O_H_body_left_book", "id": "U_MD_O_H_body_left_book" }, _cBox); //目录内容
- _example = $$("div", {
- "className": "U_MD_O_H_body_left_book_a",
- }, _frienddiv); //默认邀请按钮
- var span = $("div[name=U_MD_O_W_Font_Heading1]");
- if (span.length > 0) {
- for (var i = 0; i < span.length; i++) {
- var a = $$("div", { "className": "isMulu" }, _example)
- a.innerHTML = span[i].children[0].innerHTML;
- }
- } else {
- var b = $$("div", { "className": "noMulu" }, _example)
- b.innerHTML = "暂无目录"
- }
- // $$("div", { "innerHTML": "一、项目概述" }, _example);
- // $$("div", { "innerHTML": "二、业务流程" }, _example);
- // $$("div", { "innerHTML": "三、系统角色" }, _example);
- // $$("div", { "innerHTML": "四、产品功能场景描述" }, _example);
- // $$("div", { "innerHTML": "五、功能模块" }, _example);
- // $$("div", { "className": "U_MD_O_H_body_left_book_a_img" }, _example);
- // $$("div", { "className": "U_MD_O_H_body_left_book_a_div", "innerHTML": "邀请" }, _example);
- new U.UF.UI.form("目录", _cBox, { id: "wordDirectory", style: { border: "none", position: "absolute", width: "300px", "min-width": "200px", height: "250px", top: "50px", left: "auto", "box-shadow": "none" } }, { isenlarge: false, isnarrow: false }, { style: { height: "40px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#f1f1f1" } }, null, null, _coopwindow);
- }
- }
- U.MD.O.W.addPerson = function () {
- var BOX = $$("div", {});
- var form_main = $$('div', { "className": "form-main" }, BOX);
- var form_content = $$('div', { "className": "form-content" }, form_main);
- var form_delete_main = $$('div', { "className": "form_delete-main-room" }, form_content);
- var form_delete_main_body = $$('div', { "className": "form_delete-main-body" }, form_delete_main);
- var searchPerson = $$('div', { "className": "searchPerson" }, form_delete_main_body);
- $$("input", { "className": "inputSearch", "type": "text", "placeholder": "搜索成员" }, searchPerson);
- $$("div", { "className": "searchImg", }, searchPerson);
- var a = [];
- var r = [{ "userid": "1", "title": "李华" }, { "userid": "2", "title": "李雷" }, { "userid": "3", "title": "莉莉" }, { "userid": "4", "title": "李磊" }, { "userid": "5", "title": "李莉" }]
- var checkboxPerson = $$('div', { "className": "checkboxPerson" }, form_delete_main_body);
- for (let i = 0; i < r.length; i++) {
- var person = $$("div", { "className": "person", }, checkboxPerson);
- let abc = $$('input', { "type": "checkbox", "id": r[i].userid }, person);
- $$('div', { "className": "personAvatar", }, person);
- $$('span', { "className": "thirdSpan", "innerHTML": r[i].title }, person);
- if (a.indexOf(r[i].userid) != -1) {
- abc.checked = true
- }
- person.onclick = function (e) {
- var el = e.currentTarget
- el.getElementsByTagName("input")[0].click();
- }
- abc.onclick = function (e) {
- e.stopPropagation();
- if (a.indexOf(e.target.id) !== -1) {
- a.splice(a.indexOf(e.target.id), 1);
- } else {
- a.push(e.target.id);
- }
- }
- }
- var btnBox = $$('div', { "className": "copy-btn" }, form_main);
- var confirm = $$('button', { "className": "copy-message", "innerHTML": `${"移出成员"}` }, btnBox);
- new U.UF.UI.form(`${"管理成员"}`, BOX, {
- id: 'invite_members',
- style: {
- "background": "#fffefe",
- "width": "350px",
- "height": "500px",
- "z-index": "99",
- }
- }, {
- isenlarge: false,
- isnarrow: false
- }, {
- style: {
- "height": "40px",
- "text-align": "center",
- "line-height": "40px",
- "text-indent": "25px",
- "background-repeat": "no-repeat",
- "font-size": "14px",
- "background-color": "#494949",
- "display": "flex",
- }
- });
- // confirm.onclick = function () {
- // U.MD.O.W.copyText();
- // }
- }
- U.MD.O.W.isOpenRoomConfirm = function () {
- var BOX = $$("div", {});
- var form_main = $$('div', { "className": "form-main" }, BOX);
- var form_content = $$('div', { "className": "form-content" }, form_main);
- var form_delete_main = $$('div', { "className": "form_delete-main-room" }, form_content);
- var form_delete_main_body = $$('div', { "className": "form_delete-main-body" }, form_delete_main);
- $$("div", { "className": "remark", "innerHTML": US.userInfo.username + "邀请您参与协同文档", }, form_delete_main_body)
- $$("div", {
- "class": "clickNav",
- "innerHTML": "点击链接加入房间",
- }, form_delete_main_body)
- $$("div", { "class": "link", "innerHTML": "http://cocorobo.wg.com/dm/EOGyBbFiCwam", }, form_delete_main_body)
- var room_number = $$('div', { "className": "room_number" }, form_delete_main_body);
- $$("div", { "class": "link", "innerHTML": "房间号:", }, room_number)
- $$("div", { "class": "roomNumber", "innerHTML": US.numNum, }, room_number)
- $$("div", { "className": "link", "innerHTML": "复制房间号信息,打开协同文档输入即可加入。", }, form_delete_main_body)
- // $$("input", { "className": "text", "type": "text" }, form_delete_main_body);
- var btnBox = $$('div', { "className": "copy-btn" }, form_main);
- var confirm = $$('button', { "className": "copy-message", "innerHTML": `${"一键复制信息"}` }, btnBox);
- new U.UF.UI.form(`${"邀请成员"}`, BOX, {
- id: 'invite_members',
- style: {
- "background": "#fffefe",
- "width": "350px",
- "height": "500px",
- "z-index": "99",
- }
- }, {
- isenlarge: false,
- isnarrow: false
- }, {
- style: {
- "height": "40px",
- "text-align": "center",
- "line-height": "40px",
- "text-indent": "25px",
- "background-repeat": "no-repeat",
- "font-size": "14px",
- "background-color": "#494949",
- "display": "flex",
- }
- });
- confirm.onclick = function () {
- U.MD.O.W.copyText();
- }
- }
- U.MD.O.W.openRoomConfirm = function () {
- var BOX = $$("div", {});
- var form_main = $$('div', { "className": "form-main" }, BOX);
- var form_content = $$('div', { "className": "form-content" }, form_main);
- var form_delete_main = $$('div', { "className": "form_delete-main" }, form_content);
- $$("input", { "className": "form_delete-main_box", "placeholder": `${"请输入要加入的房间号"}` }, form_delete_main);
- $$("div", { "className": "remark", "innerHTML": "备注:输入房间号点击加入房间或点击创建房间直接创建房间", }, form_delete_main)
- var btnBox = $$('div', { "className": "form-btn" }, form_delete_main);
- var cencal = $$('button', { "className": "form-cencal", "innerHTML": `${"加入房间"}` }, btnBox);
- var confirm = $$('button', { "className": "form-confirm", "innerHTML": `${"创建房间"}` }, btnBox);
- new U.UF.UI.form(`${"创建/加入房间"}`, BOX, {
- id: 'add_room',
- style: {
- "background": "#fffefe",
- "width": "400px",
- "height": "281px",
- "z-index": "99 !important",
- }
- }, {
- isenlarge: false,
- isnarrow: false
- }, {
- style: {
- "height": "40px",
- "text-align": "center",
- "line-height": "40px",
- "text-indent": "25px",
- "background-repeat": "no-repeat",
- "font-size": "16px",
- "background-color": "#32455B",
- "display": "flex",
- }
- });
- confirm.onclick = function () {
- U.MD.O.W.checkNum();
- }
- cencal.onclick = function () {
- U.MD.O.W.goRoom($(".form_delete-main_box")[0].value);
- }
- }
- //#endregion
|