WordPanel.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. //此处放置iframe中的word中的功能面板,包括包括创建邀请协作人员,创建编辑历史,创建生成链接.创建热门模板。
  2. Namespace.register("U.MD.O.W.Panel");
  3. //协作统一命名为Collaborative,但牵涉的地方太多,暂时还是用Synergy
  4. //#region 本地转协同文档及新建保存为协同文档操作
  5. /**
  6. * 本地转协同文档及新建保存为协同文档操作,此函数逻辑不清,需要改写!
  7. *
  8. * @param fun {element} 回调函数
  9. */
  10. U.MD.O.W.Panel.isSynergy = function (fun) {
  11. //判断是登录
  12. if (!top.U.MD.U.L.isLogin()) {
  13. var _fileinfo = U.MD.O.W.fileinfo, //文件信息
  14. ////或者是什么意思?不严谨
  15. _filegroupid = _fileinfo.GroupID; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
  16. //判断是否为互联办公文档,此处有问题。互联办公的权限有问题。
  17. if (U.MD.O.W.permission.web) {
  18. if (U.UF.C.isFunction(fun)) {//判断是否有点击事件的方法,如果有,运行它
  19. fun(_fileinfo);
  20. }
  21. return true;
  22. }
  23. else {
  24. var _filename = top.$('#UD_Word' + _fileinfo.UserDirectoryID + ' .U_MD_O_H_head_navigation_Title')[0]; //获取文件名
  25. //判断文档是否是保持文档,是否是可编辑文档
  26. if (U.MD.O.W.isSave() && U.MD.O.W.permission.edit) {
  27. //如果是保持的文档,那么直接提示是否转成系统文档
  28. new U.UF.UI.confirm("是否将此文档转成互联办公文档", function () {
  29. //保存到群里
  30. top.U.MD.DK.VW.saveSynergy(_fileinfo.UserDirectoryExtendType || "uw", _fileinfo, _filename.value, 'move', function (fileinfo) {
  31. U.MD.O.W.Panel.isSynergy.async(fileinfo, fun);
  32. });
  33. });
  34. }
  35. //新建保存为协同
  36. else {
  37. //否则是新建文档
  38. top.U.MD.DK.VW.saveSynergy(_fileinfo.UserDirectoryExtendType || "uw", _fileinfo, _filename.value, 'new', function (fileinfo) {
  39. U.MD.O.W.Panel.isSynergy.async(fileinfo, fun);
  40. });
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. /**
  47. * 本地转协同文档及新建保存为协同文档操作
  48. *
  49. * @param fileinfo {object} 文件信息
  50. * @param fun {element} 回调函数
  51. */
  52. U.MD.O.W.Panel.isSynergy.async = function (fileinfo, fun) {
  53. U.MD.O.W.fileinfo = fileinfo; //设置文件信息
  54. U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员
  55. var _eidtorel = $('#U_MD_O_H_wordEditor')[0]; //获取编辑器
  56. //导航文件转成互联
  57. if (fileinfo.UserDirectoryExtendType == 'un') {
  58. //保存文件到后台
  59. U.MD.O.W.T.N.saveAllPage(function () {
  60. U.MD.O.W.T.N.saveNav.asyn(true, fileinfo, _eidtorel);
  61. }, 0, true, _eidtorel.innerHTML);
  62. }
  63. else {
  64. //保存文件到后台
  65. U.A.Request(US.SCOKET, ["newWordSave", fileinfo.UserDirectoryID, _eidtorel.innerHTML.escapeQuotes(), fileinfo.UserDirectoryName, US.userInfo.UserId, top.US.pageId], U.MD.O.W.Panel.isSynergy.saveAsync, [null, fileinfo, _eidtorel]);
  66. }
  67. if (U.UF.C.isFunction(fun)) {//判断是否有点击事件的方法,如果有,运行它
  68. fun(fileinfo);
  69. }
  70. }
  71. U.MD.O.W.Panel.isSynergy.saveAsync = function (r) {
  72. var _fileinfo = r.context[1];
  73. var _eidtorel = r.context[2];
  74. U.MD.O.W.permission.edit = true;
  75. U.MD.O.W.permission.web = true;
  76. top.$('#UD_Word' + _fileinfo.UserDirectoryID + ' .U_MD_O_H_head_navigation_Title')[0].value = _fileinfo.UserDirectoryName; //设置文件名
  77. U.Alert("保存成功"); //提示保存成功
  78. U.MD.O.W.fileinfo.UsOffice = _eidtorel.innerHTML; //设置内容
  79. _eidtorel.editor.operaNotice = U.MD.O.W.E.operationNotice; //设置协同监听回调
  80. }
  81. //#endregion
  82. //#region 团队成员
  83. /**
  84. * 创建团队成员的窗体
  85. *
  86. * @param fileinfo {object} 文件信息
  87. */
  88. U.MD.O.W.Panel.loadPlayUser = function (fileinfo) {
  89. var _coopwindow, _frienddiv, _example, _shareLink, _cBox;
  90. //如果不存在团队成员窗口,则创建一个团队成员窗口。
  91. if (!$("#U_MD_O_H_body_left_invite_user")[0]) {
  92. //创建邀请协助人员窗口
  93. _coopwindow = $("#U_MD_O_H_body_left")[0];
  94. _cBox = $$("div", {});
  95. _shareLink = $$("div", {
  96. className: 'U_MD_O_H_body_left_invite_linkTxt', "onclick": function () {
  97. U.MD.O.W.Panel.isSynergy(U.MD.O.W.Panel.shareLink);
  98. }, "innerText": "第三方链接邀请"
  99. }, _cBox);
  100. _frienddiv = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_user" }, _cBox); //好友内容区域
  101. _example = $$("div", {
  102. "className": "U_MD_O_H_body_left_invite_user_a", "onclick": function () {
  103. U.MD.O.W.Panel.displayInsertUser();
  104. }
  105. }, _frienddiv); //默认邀请按钮
  106. $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_img" }, _example);
  107. $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_div", "innerHTML": "邀请" }, _example);
  108. new U.UF.UI.form("邀请协作人员", _cBox, { id: "LoadPlayUser", style: { border: "none", position: "absolute", width: "300px", "min-width": "200px", height: "250px", top: "140px", left: "auto", "box-shadow": "none" } },
  109. { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff" } }, null, null, _coopwindow);
  110. }
  111. U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员
  112. }
  113. /**
  114. * 初始化查看团队成员
  115. *
  116. * @param fileinfo {object} 文件信息
  117. */
  118. U.MD.O.W.Panel.disPlayUser = function (fileinfo, el) {
  119. el = $("#U_MD_O_H_body_left_invite_user")[0]; //获取团队成员初始化的位置
  120. var _elchild = el.children[0] //获取元素的子元素;
  121. el.innerHTML = ""//清空内容
  122. $(el).append(_elchild);
  123. if (fileinfo) {//判断是否有文件信息
  124. var _userinfo = [];// U.Json.select(US.friend.groupusers, { "GroupManageID": fileinfo.GroupID }); //获取所有在群里的成员
  125. if (_userinfo) {//判断是否拥有群成员
  126. for (i = 0; i < _userinfo.length; i++) {//循环打印所有的群成员
  127. U.MD.O.W.Panel.createUser(_userinfo[i], el);
  128. }
  129. }
  130. }
  131. }
  132. /**
  133. * 打印团队编辑成员
  134. *
  135. * @param fileinfo {object} 文件信息
  136. */
  137. U.MD.O.W.Panel.createUser = function (userinfo, el) {
  138. var _elparent = $$("div", {
  139. "className": "U_MD_O_H_body_left_invite_user_a", "onclick": U.UF.C.closure(function (userid) {
  140. top.U.MD.U.V.ViewOtherUserInfo(userid);
  141. }, [userinfo.UserId])
  142. }, el); //好友头像父级元素
  143. var _elcontant = $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_user", "style": { "background": "" } }, _elparent); //好友头像元素
  144. $$("img", { "onerror": U.MD.C.imgError, "src": top.U.MD.C.getHeadImage(userinfo.UserThumbnailImageHead) }, _elcontant); //好友头像图片
  145. $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_div", "innerHTML": userinfo.UserNickName }, _elparent); //好友名称
  146. }
  147. /**
  148. * 单击邀请时,从普通文档转换为协同文档的过程!
  149. * 判断是否是已经新建过 弹出添加成员 异步回调
  150. *
  151. * @param {element} Wrod信息数组
  152. */
  153. U.MD.O.W.Panel.displayInsertUser = function () {
  154. //判断是否是协同文档
  155. if (U.MD.O.W.Panel.isSynergy()) {
  156. var _fileinfo = U.MD.O.W["fileinfo"];
  157. top.U.MD.F.J.selectFriendForm(function (groupid) {
  158. //或者是什么意思?不严谨
  159. var _filegroupid = _fileinfo.GroupID; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
  160. var _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": _filegroupid })[0]; //群信息
  161. var _needuser = top.U.MD.F.J.selectUserInfo.NeedUser; //选中好友集合
  162. var _groupname = _groupinfo.GroupManageName; // 群名
  163. var _groupdesc = _groupinfo.GroupManageDescript; //群描述
  164. var _selectfriend = U.Json.select(US.friend.groupusers, { "GroupManageID": _filegroupid }); //选择的好友信息
  165. //已经在群里的就不添加了
  166. var i;
  167. for (i = 0; i < _selectfriend.length; i++) {
  168. U.Json.del(_needuser, { "UserId": _selectfriend[i].UserId }); //删除所有在群里的用户id
  169. }
  170. //创建及添加群处理
  171. top.U.MD.F.J.determineCreateGroupAndAddGroupUser(_filegroupid, null, null, false, _groupname, _groupdesc, function (groupid, groupinfo) {
  172. var i, _userids = "";
  173. //U.MD.O.W.Panel.disPlayUser(_fileinfo);
  174. for (i = 0; i < _needuser.length; i++) {//循环打印所有的群成员
  175. _userids += _needuser[i].UserId + (i < _needuser.length - 1 ? "," : "");
  176. U.MD.O.W.Panel.createUser(_needuser[i]);
  177. }
  178. U.MD.O.W.Panel.addUser(_userids);
  179. });
  180. }, null, _fileinfo); //调用打印函数
  181. }
  182. }
  183. U.MD.O.W.Panel.addUser = function (userids) {
  184. var _type = U.MD.O.W["fileinfo"].UserDirectoryExtendType == "un" ? "nav" : "word";
  185. top.U.A.Request(US.SCOKET, ["addUser", _type, U.MD.O.W["fileinfo"].UserDirectoryID, userids, US.userInfo.UserId, top.US.pageId], function () { });
  186. }
  187. U.MD.O.W.Panel.syncAddUser = function (userids, senduserid) {
  188. userids = userids.split(",");
  189. var i, _userinfo;
  190. for (i = 0; i < userids.length; i++) {
  191. _userinfo = U.Json.selectOne(US.friend.groupusers, { UserId: userids[i] });
  192. if (!_userinfo) {
  193. top.U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", userids[i]], function (r) {
  194. _userinfo = r.value[0];
  195. U.MD.O.W.Panel.createUser(_userinfo);
  196. })
  197. }
  198. }
  199. }
  200. //#endregion
  201. //#region 分享文档链接
  202. /**
  203. * ----------------------------添加团队成员
  204. *
  205. * @param {object} 文件信息
  206. * @param {string} 文件提交到哪个群的id
  207. * @param {array} 用户id的数组
  208. */
  209. //U.MD.O.W.Panel.insertUser = function (fileinfo, groupid) {
  210. // // if (!fileinfo.UserId && !fileinfo.UserallDirectoryName) {
  211. // // fileinfo.GroupId = fileinfo.UserDirectoryEncrypt = groupid;
  212. // // var _groupuserid = U.Json.select(US.friend.group, { 'GroupManageID': groupid })[0].GroupManageUserID;
  213. // // var _dirinfo, _dirid, _diskinfo = US.disk.Disks[US.userInfo.UserId];
  214. // // if (_groupuserid == US.userInfo.UserId) {
  215. // // _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { 'UserDirectoryName': "我的协同" })[0];
  216. // // } else {
  217. // // _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { 'UserDirectoryName': "他人邀请" })[0];
  218. // // }
  219. // // var _dirchild = top.$('#L' + _dirinfo.UserDirectoryID).Child();
  220. // // !_dirchild[1] && _dirchild[0].onclick()
  221. // // top.$('#L' + groupid).Child()[0].onclick();
  222. // // } else if ((fileinfo.UserDirectoryEncrypt || fileinfo.GroupID) == US.userInfo.UserId) { //如果是新创建的文件,同时文件不在群里 就把文件拷贝到群里进行处理
  223. // // var _userid = fileinfo.UserId,
  224. // // _diskinfo = US.disk.Disks[US.userInfo.UserId],
  225. // // _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { "UserDirectoryID": groupid }, 1)[0]; //当前目录的信息
  226. // // var _pastecontent = US.disk.Disks[_userid].pasteDirOrFile = {
  227. // // "type": "shear", //复制或者剪切 "copy" || "shear"
  228. // // "UserDirectoryID": groupid, //在哪个目录复制或者剪切
  229. // // "dirorfile": fileinfo, //复制的内容
  230. // // "userid": _userid //用户id
  231. // // }
  232. // // top.U.A.Request(US.AUTH, ["CutAndPasteFiles", fileinfo.UserId, groupid, fileinfo.UserDirectoryID, groupid, groupid],
  233. // // top.U.MD.DK.RE.asynPaste, ["", _dirinfo, groupid, _pastecontent, _diskinfo]
  234. // // );
  235. // // fileinfo.GroupId = fileinfo.UserDirectoryEncrypt = groupid;
  236. // // }
  237. // // U.MD.O.W.Panel.disPlayUser(fileinfo);
  238. //}
  239. /**
  240. * 分享文档链接
  241. *
  242. * @param fileinfo {object} 文件信息
  243. */
  244. U.MD.O.W.Panel.shareLink = function (fileinfo) {
  245. var _template = U.MD.O.W.Panel.shareLinkTemplate(fileinfo); //生成窗体内容
  246. new U.UF.UI.form("邀请协助链接", _template, { id: "U_MD_O_W_Panel_InviteForm", style: { cssText: "width:600px; height:450px;" } }); //创建窗体
  247. }
  248. /**
  249. * 创建分享链接窗体内容模板
  250. *
  251. * @param {fileinfo} 文件信息
  252. */
  253. U.MD.O.W.Panel.shareLinkTemplate = function (fileinfo) {
  254. var _cBox = $$('div', { className: "U_MD_O_H_body_left_invite_form" }), //创建最外层元素
  255. _shareLinkEl = $$('div', { className: "U_MD_O_H_body_left_invite_formShare" }, _cBox), //分享链接盒子元素
  256. _QRCodeEl = $$('div', { className: "U_MD_O_H_body_left_invite_formQRCode" }, _cBox); //二维码元素
  257. $$('p', { innerText: "通过链接邀请:", style: { cssText: "font-size:18px; font-weight: bold;" } }, _shareLinkEl) //文字提示
  258. var _shareLinkInpBlock = $$('div', { className: "U_MD_O_H_body_left_invite_shareInpMargin" }, _shareLinkEl); //分享链接文本框
  259. $$('p', { style: { cssText: "margin-top: 8px;" }, innerText: "将下面的邀请链接通过QQ或微信发送给需要邀请的人" }, _shareLinkInpBlock); //文字提示
  260. var _fileType; //文档类型
  261. switch (fileinfo.UserDirectoryExtendType.toLowerCase()) { //字符串转换
  262. case 'uw':
  263. _fileType = 'word'; break;
  264. case 'ue':
  265. _fileType = 'execl'; break;
  266. case 'un':
  267. _fileType = 'word'; break;
  268. default:
  269. _fileType = false; break;
  270. }
  271. var _shareLinkInpBlockShow = $$('input', { style: { cssText: "margin-top: 5px;" }, className: "U_MD_O_H_body_left_invite_shareInp", value: "http://www.1473.cn/#" + _fileType + '/join/' + fileinfo.UserDirectoryID, disabled: "disabled" }, _shareLinkInpBlock), //输出
  272. _shareLinkInpBlockBtn = $$('div', {
  273. style: { cssText: "margin-top: 5px;" }, className: "U_MD_O_H_body_left_invite_shareBtn", innerText: "复制", onclick: function () { //复制按钮
  274. var _inp = $$('input', { value: _shareLinkInpBlockShow.value }, $('body')[0]); //创建复制文本框
  275. _inp.select(); //选中
  276. document.execCommand("Copy"); //复制
  277. $(_inp).remove();
  278. U.Alert('复制成功,赶紧分享给小伙伴吧!'); //提示
  279. }
  280. }, _shareLinkInpBlock)
  281. $$('p', { innerText: "通过二维码邀请:", style: { cssText: "font-size:18px; font-weight: bold;" } }, _QRCodeEl); //文字
  282. var _QRCodeImg = $$('div', { style: { cssText: "margin-left:40px;margin-top: 20px;position:absolute;" } }, _QRCodeEl);
  283. $$('div', { innerHTML: "<span style='font-size:16px'>通过扫码,邀请好友</span><br>扫描二维码获取邀请函,转发给微信好友/群,<br/>即可邀请他们加入你的文档", style: { cssText: "margin-left: 270px;margin-top:40px;line-height:30px;" } }, _QRCodeEl);
  284. top.U.UF.QR.generate("150", "150", "black", "white", _shareLinkInpBlockShow.value, _QRCodeImg); //调用生成二维码函数
  285. return _cBox; //返回最外层元素
  286. }
  287. //#endregion
  288. //#region 热门模板
  289. /**
  290. * 创建热门模板窗体
  291. *
  292. * @param {element} 换页元素
  293. */
  294. U.MD.O.W.Panel.loadHotTemplates = function (fileinfo) {
  295. var _leftel, _el;
  296. //判断是否加载热门模板
  297. if (!$("#U_MD_O_H_body_left_template_hot")[0]) {
  298. _leftel = $("#U_MD_O_H_body_left")[0];
  299. //创建热门模板窗体
  300. _el = $$("div", { "className": "U_MD_O_H_body_left_template_user", id: "U_MD_O_H_body_left_template_hot" });
  301. new U.UF.UI.form("热门模板提供", _el, { id: "LoadHotTemplates", style: { border: "none", width: "300px", height: "477px", position: "absolute", top: "695px", left: "auto", "box-shadow": "none" } }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff" } }, null, null, _leftel);
  302. }
  303. U.MD.O.W.Panel.getHotTemplates("00000000-0000-0000-0000-000000000000", 1, 10); //热门模板
  304. }
  305. /**
  306. * 初始化加载模板
  307. *
  308. * @param {element} 换页元素
  309. */
  310. U.MD.O.W.Panel.getHotTemplates = function (hid, start, end) {
  311. var _el = $("#U_MD_O_H_body_left_template_hot")[0];
  312. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectHotTemplate", hid, start, end], U.MD.O.W.Panel.asynGetHotTemplates, [null, _el]);
  313. }
  314. /**
  315. * 获取热门模板
  316. *
  317. * @param {element} 换页元素
  318. */
  319. U.MD.O.W.Panel.asynGetHotTemplates = function (r) {
  320. var i, _el,
  321. _frag = $$("frag"),
  322. _hel = r.context[1];
  323. r = r.value;
  324. //循环答应热门模板
  325. for (i = 0; i < r.length; i++) {
  326. _el = $$("div", {
  327. "className": "U_MD_O_H_body_left_template_user_m",
  328. "onclick": U.UF.C.closure(function (info) {
  329. parent.U.A.Request(US.DISK, ["GetFileContent", info.FileId], function (r) {
  330. //获取到内容
  331. if (r.value && r.value.UsOffice !== undefined) {
  332. r = r.value.UsOffice;
  333. }
  334. //打开新的word处理
  335. top.U.MD.O.word(US.userInfo, { UserDirectoryID: Guid.newGuid(), UsOffice: r || "" });
  336. });
  337. }, [r[i]])
  338. }, _frag);
  339. $$("div", { "className": "U_MD_O_H_body_left_template_user_m_s", "style": { "background-image": "url(" + (r[i].UseFilesServerThumbnailName || "http://www.1473.cn/Boomyun/img/pc/NImg.png") + ")" } }, _el);
  340. $$("div", { "className": "U_MD_O_H_body_left_template_user_m_x", "innerHTML": r[i]["UserFilesName"] }, _el);
  341. }
  342. $(_hel).append(_frag);
  343. }
  344. //#endregion
  345. //#region 链接查看
  346. /**
  347. *
  348. * 加载,生成连接区域
  349. *
  350. * @param wordinfo {object} 当前文档信息
  351. */
  352. U.MD.O.W.Panel.loadlink = function (wordinfo) {
  353. var _linkareael = $("#U_MD_O_H_body_left_href_pay_a")[0];
  354. //如果不存在添加链接区域,则创建。
  355. if (!_linkareael || (_linkareael && _linkareael.innerHTML == "")) {
  356. U.MD.O.W.Panel.formloadlink([]); //加载链接,这里有可能没有设置过短连接
  357. //加载word文件的短链接
  358. // U.A.Request('http://cd.1473.cn/php', ["db.1473.cn", "UseStudio_DNS", 'GetDnsInfoByFileId', wordinfo.UserDirectoryID], function (r) {
  359. // var _date = r.value; //获取短连接信息
  360. // U.MD.O.W.Panel.formloadlink(_date); //加载链接,这里有可能没有设置过短连接
  361. // });
  362. }
  363. }
  364. /**
  365. *
  366. * 加载,生成连接区域
  367. *
  368. * @param wordinfo {object} 当前文档信息
  369. */
  370. U.MD.O.W.Panel.formloadlink = function (date) {
  371. var _url,
  372. _linkdiv,
  373. _wordinfo = U.MD.O.W.fileinfo,
  374. _rightwindow = $("#U_MD_O_H_body_left")[0], //右边功能区
  375. _linkareael = $("#U_MD_O_H_body_left_href_pay_a")[0]
  376. ;
  377. //设置过域名的加载
  378. if (date.length) {
  379. _url = date[0].AppId + ".1473.cn/" + date[0].Domain
  380. _linkdiv = $$("div", { "className": "U_MD_O_H_body_left_href_pay_a", id: "U_MD_O_H_body_left_href_pay_a" });
  381. $$("a", { className: "U_MD_O_H_body_left_href_pay_aText", href: "//" + _url, innerText: _url, target: "_Blank" }, _linkdiv);
  382. //只有编辑权限才显示修改和分享按钮
  383. if (U.MD.O.W.permission.edit) {
  384. $$('div', {
  385. innerText: '分享', className: "U_MD_O_H_body_left_href_pay_Btn", onclick: function () {
  386. //判断是否保持文档
  387. if (U.MD.O.W.isSave()) {
  388. var _iframe = $$('iframe', { src: '//domain.1473.cn/DomainSystem.aspx/?fileId=' + _wordinfo.UserDirectoryID + '&type=word&mode=share', frameborder: "0", style: { cssText: "width:100%;height:100%;border:0px" } });
  389. new U.UF.UI.form("域名管理", _iframe, { id: "U_MD_DS_DomainShare", style: { "width": "370px", "height": "390px" } });
  390. }
  391. //点击保存处理
  392. else {
  393. $('#U_MD_O_H_save')[0].onclick();
  394. }
  395. }
  396. }, _linkdiv);
  397. $$("div", {
  398. innerText: '修改', className: "U_MD_O_H_body_left_href_pay_Btn", onclick: function () {
  399. //判断是否保持文档
  400. if (U.MD.O.W.isSave()) {
  401. var _iframe = $$('iframe', { src: '//domain.1473.cn/DomainSystem.aspx/?fileId=' + _wordinfo.UserDirectoryID + '&type=word&mode=base', frameborder: "0", style: { cssText: "width:100%;height:100%;border:0px" } });
  402. new U.UF.UI.form("域名管理", _iframe, { id: "U_MD_DS_DomainManage", style: { cssText: 'width: 1040px; height: 555px' } });
  403. }
  404. //点击保存处理
  405. else {
  406. $('#U_MD_O_H_save')[0].onclick();
  407. }
  408. }
  409. }, _linkdiv);
  410. }
  411. }
  412. //未设置过的
  413. else {
  414. _linkdiv = $$("div", {
  415. "className": "U_MD_O_H_body_left_href_pay_a", id: "U_MD_O_H_body_left_href_pay_a", "innerHTML": "将此站点生成链接", "onclick": function () { //生成链接
  416. //判断文件是否保存,此判断未成功
  417. if (U.MD.O.W.isSave()) { //如果保存的文档,点击直接弹出网页
  418. //得到编辑器
  419. var _wordContent = document.getElementById("U_MD_O_H_wordEditor");
  420. //如果文件变量中的word内容存在,编辑器内容不同于文件变量中的内容,则保存内容,否则,返回true
  421. if (_wordinfo.UsOffice && _wordinfo.UsOffice != _wordContent.innerHTML) {
  422. //保存到数据库
  423. top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _wordinfo.UserDirectoryID, _wordContent.innerHTML.escapeQuotes(), _wordinfo.UserallDirectoryName, "uw"], function (r) {
  424. //跳转新页面显示word内容
  425. window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
  426. }, ([''])); //保存到数据库
  427. }
  428. else {
  429. //先判断数据库是否存在该文件
  430. parent.U.A.Request(US.DISK, ["GetFileContent", _wordinfo.UserDirectoryID], function (r) {
  431. //能够获取到内容
  432. if (r.value && r.value.UsOffice !== null) {
  433. //跳转新页面显示word内容
  434. window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
  435. }
  436. else {
  437. //保存到数据库
  438. top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _wordinfo.UserDirectoryID, _wordContent.innerHTML.escapeQuotes(), _wordinfo.UserallDirectoryName, "uw"], function (r) {
  439. //跳转新页面显示word内容
  440. window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
  441. }, ([''])); //保存到数据库
  442. }
  443. });
  444. }
  445. }
  446. else { //未保存的文档查看站点,触发保存事件
  447. $('#U_MD_O_H_save')[0].onclick();
  448. }
  449. }
  450. });
  451. }
  452. //如果已经创建
  453. if (_linkareael && _linkareael.innerHTML == "") {
  454. _linkareael.appendChild(_linkdiv);
  455. }
  456. //如果生成链接的处理
  457. else {
  458. new U.UF.UI.form("生成链接", _linkdiv, { style: { border: "none", position: "absolute", width: "300px", height: "70px", top: "60px", left: "auto", "box-shadow": "none" } }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff" } }, null, null, _rightwindow);
  459. }
  460. }
  461. //#endregion
  462. //#region 历史记录
  463. /**
  464. * 初始化历史记录
  465. *
  466. * @param
  467. */
  468. U.MD.O.W.Panel.loadOfficeHistory = function (fileinfo) {
  469. var _el, _leftel;
  470. //判断是否有历史记录
  471. if (!$("#U_MD_O_H_body_left_invite_history")[0]) {
  472. _leftel = $("#U_MD_O_H_body_left")[0];
  473. //编辑历史
  474. _el = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_history" });
  475. new U.UF.UI.form("编辑历史", _el, { id: "LoadOfficeHistory", style: { width: "300px", height: "284px", position: "absolute", top: "400px", left: "auto", "border-radius": "0px", border: "none", "box-shadow": "none", "border-radius": "5px" } }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff" } }, null, null, _leftel);
  476. }
  477. //判断文件是否保持的文件,如果保持的文件则有历史记录,未保存的没有
  478. if (U.MD.O.W.isSave()) {
  479. U.MD.O.W.Panel.viewEditHistory(fileinfo.UserDirectoryID, U.MD.O.W.historyid, 1, 100); //历史记录
  480. }
  481. //没有历史记录
  482. else {
  483. $$("div", { "innerHTML": "暂无历史", "style": { "text-align": "center", "margin-top": "50px" } }, _el);
  484. }
  485. }
  486. /**
  487. * 查看编辑历史
  488. *
  489. * @param {element} 换页元素
  490. * 创始人id 文件id 空的id 选取开始 选取长度 获取编辑历史的框
  491. */
  492. U.MD.O.W.Panel.viewEditHistory = function (id, hid, start, end) {
  493. var _el = $("#U_MD_O_H_body_left_invite_history")[0];
  494. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectOfficeHistory", id, hid, start, end], U.MD.O.W.Panel.asynViewEditHistory, [null, _el]);
  495. }
  496. /**
  497. * 查看编辑历史异步
  498. *
  499. * @param {element} 换页元素
  500. */
  501. U.MD.O.W.Panel.asynViewEditHistory = function (r) {
  502. $('#U_MD_O_H_body_left_invite_history')[0].innerHTML = '';
  503. var _value = r.value,
  504. _el = $('#U_MD_O_H_body_left_invite_history')[0]
  505. for (var i = 0; i < _value.length; i++) {
  506. _el.appendChild(U.MD.O.W.Panel.createHis(_value[i]))
  507. }
  508. }
  509. /**
  510. * 添加详细历史记录布局
  511. *
  512. * @param {object} data 数据
  513. */
  514. U.MD.O.W.Panel.createHis = function (data) {
  515. var _hisel, _imgel, _infoel, _textel, _btnel;
  516. _hisel = $$('div', { style: { cssText: 'min-height: 85px; border-bottom: 1px solid silver; margin: 0 3px' } });
  517. _imgel = $$('div', { style: { margin: '22px 12px 0', float: 'left' } }, _hisel);
  518. $$('img', { "onerror": U.MD.C.imgError, style: { cssText: 'width:40px; height: 40px;' }, src: top.U.MD.C.getHeadImage(data.UserThumbnailImageHead) }, _imgel);
  519. _infoel = $$('div', { style: { cssText: 'margin-left: 62px;' } }, _hisel);
  520. _textel = $$('div', { style: { 'padding-top': '25px', 'white-space': 'nowrap' } }, _infoel);
  521. $$('span', { innerText: data.UserName }, _textel);
  522. $$('span', { innerText: U.UF.D.getDateInterval(data.CreateTime) + '保存一次', style: { 'padding-left': '10px' } }, _textel);
  523. _btnel = $$('div', { style: { 'margin-top': '10px', 'white-space': 'nowrap' } }, _infoel);
  524. //判断是否是自己编辑历史记录,是则不打印对话
  525. if (data.UserId != U.MD.O.W.userinfo.UserId) {
  526. $$('button', {
  527. innerText: '对话', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; cursor: pointer;' }, onclick: function () {
  528. //这里有问题,这样获取不一定能获取用户数据,同时数据没有分离
  529. var _friendel = U.Json.select(US.friend.friends, { UserId: data.UserId });
  530. //如果未添加好友,则弹出添加好友框,否则直接弹出聊天窗口
  531. if (_friendel.length == 0) {
  532. top.U.MD.U.V.ViewOtherUserInfo(data.UserId);
  533. } else {
  534. _data = !_friendel.length ? U.Json.select(US.friend.recentcontacts, { UserId: data.UserId }) : _friendel;
  535. top.U.MD.F.W.popupFriendsForm(_data[0], this);
  536. }
  537. }
  538. }, _btnel);
  539. }
  540. $$('button', {
  541. innerText: '详细', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; margin-left: 4px;cursor: pointer;' },
  542. onclick: function () {
  543. U.MD.O.W.Panel.EditHistory(data)
  544. }
  545. }, _btnel);
  546. //返回最外的元素
  547. return _hisel
  548. }
  549. /**
  550. * 插入历史
  551. *
  552. * @param _fileinfo {string} 文件信息
  553. * @param {string} 历史记录内容
  554. *
  555. */
  556. U.MD.O.W.Panel.InsertOfficeHistory = function (fileinfo, html, name, contentel) {
  557. var _fileid = fileinfo.UserDirectoryID; //文件ID
  558. if (U.MD.O.W.permission.web) {
  559. //html,
  560. top.U.A.Request(US.SCOKET, ["insertModifyRecord", "word", _fileid, name, html, US.userInfo.UserId, US.pageId], function (r) {
  561. if (r.value) {
  562. var _historyid = r.value;
  563. U.MD.O.W.Panel.syncHistory(US.userInfo.UserId, _historyid);
  564. U.MD.O.W.fileinfo.UsOffice = contentel.innerHTML;
  565. U.Alert("保存成功");
  566. } else {
  567. U.Alert("系统有误,请稍后重试..");
  568. }
  569. });
  570. } else {
  571. //插入历史
  572. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "InsertDocumentModifyRecord", US.userInfo.UserId, _fileid, html, name], function (r) {
  573. if (r.value[0]) {
  574. U.MD.O.W.Panel.syncHistory(US.userInfo.UserId, r.value[0].historyid);
  575. U.MD.O.W.fileinfo.UsOffice = contentel.innerHTML;
  576. U.Alert("保存成功");
  577. } else {
  578. U.Alert("系统有误,请稍后重试..");
  579. }
  580. });
  581. }
  582. }
  583. U.MD.O.W.Panel.syncHistory = function (userid, historyid, isbool) {
  584. if (!isbool) {
  585. var _data, _fileinfo = U.MD.O.W.fileinfo;
  586. _fileinfo.HistoryId = historyid; //记录历史ID
  587. if (userid == US.userInfo.UserId) {
  588. _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead, historyid, US.userInfo.UserId);
  589. } else {
  590. var _userinfo = U.Json.select(US.friend.groupusers, { UserId: userid })[0];
  591. _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, _userinfo.UserName, _userinfo.UserThumbnailImageHead, historyid, _userinfo);
  592. }
  593. var _el = U.MD.O.W.Panel.createHis(_data), //创建历史记录
  594. _addel = $('#U_MD_O_H_body_left_invite_history')[0]; //历史记录区域
  595. $(_el).appendTo(_addel, 0, _addel.firstElementChild); //置顶插入
  596. }
  597. }
  598. /**
  599. * 历史数据结构
  600. *
  601. * @param creattime {string} 创建时间
  602. * @param username {string} 用户名
  603. * @param userbgimg {string} 用户头像
  604. * @param historyid {string} 历史ID
  605. * @param userid {string} 用户ID
  606. *
  607. */
  608. U.MD.O.W.dataStructure = function (creattime, username, userbgimg, historyid, userid) {
  609. return {
  610. CreateTime: creattime || U.UF.D.toTimeStamp(new Date()), //创建时间
  611. UserName: username, //用户名
  612. UserThumbnailImageHead: userbgimg, //用户头像
  613. HistoryId: historyid, //历史ID
  614. UserId: userid //用户ID
  615. }
  616. }
  617. /**
  618. * 添加详细历史记录
  619. *
  620. * @param {element} e 子元素
  621. * @param {element} el 父亲元素
  622. * @param {object} data 数据
  623. */
  624. U.MD.O.W.Panel.AddDetailedHis = function (e, el, data) {
  625. var _conEl = e.lastElementChild,
  626. _hisInfoDate = $$('span', {
  627. innerText: U.UF.D.getDateInterval(new Date(parseInt(data.CreateTime.replace(/[^0-9]/ig, "")))) + '修改了一次',
  628. style: { 'padding-left': '10px' }
  629. }, _conEl.firstElementChild),
  630. _conText = $$('div', { innerHTML: data.OfficeContent }, _conEl)
  631. el.appendChild(e);
  632. }
  633. /**
  634. * 编辑历史弹出全部
  635. *
  636. */
  637. U.MD.O.W.Panel.EditHistoryc = function (UDE) {//此参数为历史记录的信息
  638. var _el = $$("div"),
  639. // _UCT = new U.UF.UI.form("<div _el='U_MD_F_S_TI'>历史记录</div>",_el,{"className": "Bjlsall", "style": {"width": "950px", "height": "550px","overflow": "hidden"} },{isdrag: false,isenlarge: false, isnarrow: false }, null, null, null, _UDTD);
  640. _UCT = new U.UF.UI.form("历史记录", _el, { className: 'Bjlsall', style: { width: "950px", height: "550px", overflow: "hidden" } }, { isdrag: false, isenlarge: false, isnarrow: false }, null, null, null);
  641. var i, _UDBD, _UDTD, _UDSD;
  642. for (var a = 0; a < UDE.length; a++) {//循环历史记录的长度 用来显示多个历史记录在"显示按钮"的打开的窗体上
  643. _UDBD = $$("div", { "className": "U_MD_O_W_History_all", "id": UDE[a].HistoryId + "-" + a }, _el);
  644. _UDTD = $$("div", { "className": "U_MD_O_W_History_Head" }, _UDBD);
  645. _UDBB = $$("div", {
  646. "className": "U_MD_O_H_body_btn",
  647. "innerHTML": "展开",
  648. "onclick": U.MD.O.W.Panel.btn
  649. },
  650. _UDBD);
  651. $$("div", { "className": "U_MD_O_H_body_btn_img1" }, _UDBB);
  652. $$("img",
  653. {
  654. "src": U.MD.C.getHeadImage(UDE[a].UserThumbnailImageHead),
  655. "onerror": U.MD.C.imgError,
  656. "alt": UDE[a].UserName,
  657. "title": UDE[a].UserName
  658. },
  659. _UDTD);
  660. $$("div", { "innerHTML": (UDE[a].UserNickName) + " " + U.UF.D.getDateInterval(UDE[a].CreateTime) + " 更改了以下内容" }, _UDTD);
  661. $$("div", { "className": "U_MD_O_H_body_right_user_o_r_all_nr", "innerHTML": UDE[a].OfficeContent }, _UDTD);
  662. }
  663. }
  664. /**
  665. * 点击显示全部
  666. *
  667. */
  668. U.MD.O.W.Panel.EditHistoryonc = function () {
  669. var _wordinfo = U.MD.O.W; //word全局变量 包含了uw文件的文件信息 等
  670. var _fileinfo = _wordinfo["fileinfo"]; //uw文件的文件信息
  671. var _fileid = _fileinfo.UserDirectoryID;
  672. var UDOD = $("#U_MD_O_H_body_left_invite_history")[0]; //历史记录框
  673. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectOfficeHistory", _fileid, "00000000-0000-0000-0000-000000000000", 1, 10], U.MD.O.W.Panel.OnDisplayD, [null, UDOD]); //
  674. }
  675. /**
  676. * 更新历史弹出全部
  677. *
  678. */
  679. U.MD.O.W.Panel.OnDisplayD = function (r) {
  680. if ($(".U_MD_O_H_body_right_user_o_r_all")) {//如果存在则删除
  681. $(".U_MD_O_H_body_right_user_o_r_all").remove();
  682. }
  683. divall = $$("div", { "className": "U_MD_O_H_body_right_user_o_r_all" }, r.context[1].parentNode.parentNode);
  684. $$("div",
  685. {
  686. "className": "U_MD_O_H_body_right_user_o_r_all_a",
  687. "innerHTML": "显示全部",
  688. "onclick": [U.MD.O.W.Panel.EditHistoryonc]
  689. },
  690. divall);
  691. U.MD.O.W.Panel.EditHistoryc(r.value);
  692. }
  693. /**
  694. * 编辑历史的展开与关闭
  695. *
  696. */
  697. U.MD.O.W.Panel.btn = function () {//编辑历史记录底端的显示全部的展开与关闭
  698. if (this.parentNode.children[0].lastChild.children[0].scrollHeight > 100) {//根据内容的高度来判断
  699. if (this.innerText == "展开") {
  700. this.innerHTML = "收起<div class='U_MD_O_H_body_btn_img2'></div>";
  701. this.parentNode.style.cssText = "height:100%;min-height:100px;overflow:visible;float:left;width:95%;"
  702. this.style.cssText = "margin-right:-7px;"
  703. }
  704. else if (this.innerText == "收起") {
  705. this.innerHTML = "展开<div class='U_MD_O_H_body_btn_img1'></div>";
  706. this.parentNode.style.cssText = "height:100px;overflow:hidden;float:none;width:none";
  707. this.style.cssText = "margin-right: 0px; "
  708. }
  709. } else {
  710. if (this.innerText == "展开") {
  711. this.innerHTML = "收起<div class='U_MD_O_H_body_btn_img2'></div>";
  712. this.parentNode.style.cssText = "height:100%;min-height:100px;overflow:visible;float:left;width:95%;"
  713. this.style.cssText = "margin-right:-7px;"
  714. }
  715. else if (this.innerText == "收起") {
  716. this.innerHTML = "展开<div class='U_MD_O_H_body_btn_img1'></div>";
  717. this.parentNode.style.cssText = "height:100px;overflow:hidden;";
  718. this.style.cssText = "margin-right: 0px;"
  719. }
  720. }
  721. }
  722. /**
  723. * 编辑历史弹出
  724. *
  725. */
  726. U.MD.O.W.Panel.EditHistory = function (UDE) {//此参数为历史记录的信息
  727. var _el = $$("div", { style: { cssText: "padding: 0 10px;" } }),
  728. _UCT = new U.UF.UI.form("历史记录", _el, { id: "Bjls", style: { width: "680px", height: "550px", overflow: "hidden", 'box-shadow': 'rgb(180, 180, 180) 1px 1px 5px 2px', 'border-radius': '0', 'border': 'none' } }, { isdrag: false, isenlarge: false, isnarrow: false }, { style: { 'background-color': '#3c475b', 'padding': '4px' } });
  729. if (UDE.OfficeContent == undefined) {
  730. U.A.Request(US.CD, [US.DB, "Usestudio_Office", "SelectHistoryDetails", UDE.HistoryId], function (r) {
  731. UDE.OfficeContent = r.value[0].OfficeContent.unEscapeQuotes().unEscapeQuotes();
  732. U.MD.O.W.Panel.AsynEditHistory(UDE, _el);
  733. }, [_el]);
  734. } else {
  735. U.MD.O.W.Panel.AsynEditHistory(UDE, _el);
  736. }
  737. }
  738. /**
  739. * 编辑历史弹出异步
  740. *
  741. */
  742. U.MD.O.W.Panel.AsynEditHistory = function (docinfo, element) {
  743. var _UDBD = $$("div", { "class": "U_MD_O_W_History" }, element);
  744. var _UDTD = $$("div", { "class": "U_MD_O_W_History_Head" }, element);
  745. $$("img",
  746. {
  747. "onerror": U.MD.C.imgError,
  748. "src": (top.U.MD.C.getHeadImage(docinfo.UserThumbnailImageHead) || 'http://www.1473.cn/img/UserHead/UseHead.jpg'),
  749. "alt": docinfo.UserNickName || docinfo.UserName,
  750. "title": docinfo.UserNickName || docinfo.UserName
  751. },
  752. _UDTD);
  753. $$("div", { "innerHTML": (docinfo.UserNickName || docinfo.UserName) + " " + U.UF.D.getDateInterval(docinfo.CreateTime || new Date()) + " 更改了以下内容", style: { cssText: "display: inline-block; margin-left:10px" } }, _UDTD);
  754. $$("div", { "className": "U_MD_O_H_body_right_user_o_r_nr", "innerHTML": docinfo.OfficeContent }, _UDTD);
  755. }
  756. //#endregion