edit.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. <template>
  2. <div class="w-main docs-edit">
  3. <v-title>{{$L('文档编辑')}}-{{$L('轻量级的团队在线协作')}}</v-title>
  4. <div class="edit-box">
  5. <div class="edit-header">
  6. <div class="header-menu active" @click="handleClick('back')"><Icon type="md-arrow-back" /></div>
  7. <Tooltip class="header-menu" :content="$L('知识库目录')">
  8. <div class="menu-container" @click="handleClick('menu')"><Icon type="md-menu" /></div>
  9. </Tooltip>
  10. <Tooltip class="header-menu" :content="$L('分享文档')">
  11. <div class="menu-container" @click="handleClick('share')"><Icon type="md-share" /></div>
  12. </Tooltip>
  13. <Tooltip class="header-menu" :content="$L('浏览文档')">
  14. <a class="menu-container" target="_blank" :href="handleClick('view')"><Icon type="md-eye" /></a>
  15. </Tooltip>
  16. <Tooltip class="header-menu" :content="$L('历史版本')">
  17. <div class="menu-container" @click="handleClick('history')"><Icon type="md-time" /></div>
  18. </Tooltip>
  19. <Poptip class="header-menu synch">
  20. <div class="menu-container">
  21. <Icon type="md-contacts" :title="$L('正在协作会员')"/><em v-if="synchUsers.length > 0">{{synchUsers.length}}</em>
  22. </div>
  23. <ul class="synch-lists" slot="content">
  24. <li class="title">{{$L('正在协作会员')}}:</li>
  25. <li v-for="(item, key) in synchUsersS" :key="key" @click="handleSynch(item.username)">
  26. <img class="synch-userimg" :src="item.userimg"/>
  27. <user-view class="synch-username" placement="right" :username="item.username"/>
  28. <span v-if="item.username==userInfo.username" class="synch-self">{{$L('自己')}}</span>
  29. </li>
  30. </ul>
  31. </Poptip>
  32. <Tooltip class="header-menu" :class="{lock:isLock}" max-width="500">
  33. <div slot="content" style="white-space:nowrap">
  34. <span v-if="isLock&&docDetail.lockname!=userInfo.username">【<UserView :username="docDetail.lockname"/>】{{$L('已锁定')}}</span>
  35. <span v-else>{{$L('锁定后其他会员将无法修改保存文档。')}}</span>
  36. </div>
  37. <div class="menu-container" @click="handleClick(isLock?'unlock':'lock')"><Icon :type="isLock?'md-lock':'md-unlock'" /></div>
  38. </Tooltip>
  39. <div class="header-title">{{docDetail.title}}</div>
  40. <div v-if="docDetail.type=='document'" class="header-hint">
  41. <ButtonGroup size="small" shape="circle">
  42. <Button :type="`${docContent.type!='md'?'primary':'default'}`" @click="$set(docContent, 'type', 'text')">{{$L('文本编辑器')}}</Button>
  43. <Button :type="`${docContent.type=='md'?'primary':'default'}`" @click="$set(docContent, 'type', 'md')">{{$L('MD编辑器')}}</Button>
  44. </ButtonGroup>
  45. </div>
  46. <div v-if="docDetail.type=='mind'" class="header-hint">
  47. {{$L('选中节点,按enter键添加同级节点,tab键添加子节点')}}
  48. </div>
  49. <Dropdown v-if="docDetail.type=='mind' || docDetail.type=='flow' || docDetail.type=='sheet'"
  50. trigger="click"
  51. class="header-hint"
  52. @on-click="exportMenu">
  53. <a href="javascript:void(0)">
  54. {{$L('导出')}}
  55. <Icon type="ios-arrow-down"></Icon>
  56. </a>
  57. <DropdownMenu v-if="docDetail.type=='sheet'" slot="list">
  58. <DropdownItem name="xlsx">{{$L('导出XLSX')}}</DropdownItem>
  59. <DropdownItem name="xlml">{{$L('导出XLS')}}</DropdownItem>
  60. <DropdownItem name="csv">{{$L('导出CSV')}}</DropdownItem>
  61. <DropdownItem name="txt">{{$L('导出TXT')}}</DropdownItem>
  62. </DropdownMenu>
  63. <DropdownMenu v-else slot="list">
  64. <DropdownItem name="png">{{$L('导出PNG图片')}}</DropdownItem>
  65. <DropdownItem name="pdf">{{$L('导出PDF文件')}}</DropdownItem>
  66. </DropdownMenu>
  67. </Dropdown>
  68. <Button :disabled="(disabledBtn || loadIng > 0) && hid == 0" class="header-button" size="small" type="primary" @click="handleClick('save')">{{$L('保存')}}</Button>
  69. </div>
  70. <div class="docs-body">
  71. <template v-if="docDetail.type=='document'">
  72. <MDEditor v-if="docContent.type=='md'" class="body-text" v-model="docContent.content" height="100%"></MDEditor>
  73. <TEditor v-else class="body-text" v-model="docContent.content" height="100%"></TEditor>
  74. </template>
  75. <minder v-else-if="docDetail.type=='mind'" ref="myMind" class="body-mind" v-model="docContent"></minder>
  76. <sheet v-else-if="docDetail.type=='sheet'" ref="mySheet" class="body-sheet" v-model="docContent.content"></sheet>
  77. <flow v-else-if="docDetail.type=='flow'" ref="myFlow" class="body-flow" v-model="docContent.content"></flow>
  78. </div>
  79. </div>
  80. <WDrawer v-model="docDrawerShow" maxWidth="450">
  81. <Tabs v-if="docDrawerShow" v-model="docDrawerTab">
  82. <TabPane :label="$L('知识库目录')" name="menu">
  83. <nested-draggable :lists="sectionLists" :readonly="true" :activeid="sid" @change="handleSection"></nested-draggable>
  84. <div v-if="sectionLists.length == 0" style="color:#888;padding:32px;text-align:center">{{sectionNoDataText}}</div>
  85. </TabPane>
  86. <TabPane :label="$L('文档历史版本')" name="history">
  87. <Table class="tableFill" :columns="historyColumns" :data="historyLists" :no-data-text="historyNoDataText" size="small" stripe></Table>
  88. </TabPane>
  89. </Tabs>
  90. </WDrawer>
  91. </div>
  92. </template>
  93. <style lang="scss">
  94. .docs-edit {
  95. .body-text {
  96. .mdeditor-box {
  97. position: relative;
  98. width: 100%;
  99. .markdown {
  100. position: absolute;
  101. top: 0;
  102. left: 0;
  103. bottom: 0;
  104. right: 0;
  105. overflow: auto;
  106. transform: translateZ(0);
  107. &.border {
  108. border: 0 !important;
  109. }
  110. }
  111. }
  112. .teditor-loadedstyle {
  113. .tox-tinymce {
  114. border: 0;
  115. border-radius: 0;
  116. }
  117. .tox-mbtn {
  118. height: 28px;
  119. }
  120. .tox-menubar,
  121. .tox-toolbar-overlord {
  122. padding: 0 12%;
  123. background: #f9f9f9;
  124. }
  125. .tox-toolbar__overflow,
  126. .tox-toolbar__primary {
  127. background: none !important;
  128. border-top: 1px solid #eaeaea !important;
  129. }
  130. .tox-toolbar-overlord {
  131. border-bottom: 1px solid #E9E9E9 !important;
  132. }
  133. .tox-toolbar__group:not(:last-of-type) {
  134. border-right: 1px solid #eaeaea !important;
  135. }
  136. .tox-sidebar-wrap {
  137. margin: 22px 12%;
  138. border: 1px solid #e8e8e8;
  139. border-radius: 2px;
  140. box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.08);
  141. .tox-edit-area {
  142. border-top: 0;
  143. }
  144. }
  145. .tox-statusbar {
  146. border-top: 1px solid #E9E9E9;
  147. .tox-statusbar__resize-handle {
  148. display: none;
  149. }
  150. }
  151. }
  152. }
  153. .body-sheet {
  154. box-sizing: content-box;
  155. * {
  156. box-sizing: content-box;
  157. }
  158. }
  159. }
  160. </style>
  161. <style lang="scss" scoped>
  162. .docs-edit {
  163. .edit-box {
  164. display: flex;
  165. flex-direction: column;
  166. position: absolute;
  167. width: 100%;
  168. height: 100%;
  169. .edit-header {
  170. display: flex;
  171. flex-direction: row;
  172. align-items: center;
  173. width: 100%;
  174. height: 38px;
  175. background-color: #ffffff;
  176. box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.1);
  177. position: relative;
  178. z-index: 99;
  179. .header-menu {
  180. width: 50px;
  181. height: 100%;
  182. text-align: center;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. margin-right: 3px;
  187. cursor: pointer;
  188. position: relative;
  189. .menu-container {
  190. display: inline-block;
  191. width: 50px;
  192. height: 38px;
  193. line-height: 38px;
  194. color: #777777;
  195. transition: color .2s ease;
  196. }
  197. .ivu-icon {
  198. font-size: 16px;
  199. }
  200. &.synch {
  201. .menu-container {
  202. em {
  203. padding-left: 2px;
  204. }
  205. }
  206. }
  207. &.lock {
  208. .menu-container {
  209. color: #059DFD;
  210. }
  211. }
  212. &:hover,
  213. &.active {
  214. color: #fff;
  215. background: #059DFD;
  216. .menu-container {
  217. color: #fff;
  218. }
  219. }
  220. .synch-lists {
  221. max-height: 500px;
  222. overflow: auto;
  223. li {
  224. display: flex;
  225. align-items: center;
  226. padding: 6px 0;
  227. border-bottom: 1px dashed #eeeeee;
  228. &.title {
  229. font-size: 14px;
  230. font-weight: 600;
  231. color: #333333;
  232. }
  233. .synch-userimg {
  234. width: 24px;
  235. height: 24px;
  236. border-radius: 50%;
  237. }
  238. .synch-self {
  239. padding: 1px 3px;
  240. margin-left: 5px;
  241. height: 18px;
  242. line-height: 16px;
  243. background-color: #FF5722;
  244. color: #ffffff;
  245. font-size: 12px;
  246. border-radius: 3px;
  247. transform: scale(0.95);
  248. }
  249. .synch-username {
  250. padding-left: 8px;
  251. font-size: 14px;
  252. color: #555555;
  253. }
  254. }
  255. }
  256. }
  257. .header-title {
  258. flex: 1;
  259. color: #333333;
  260. border-left: 1px solid #ddd;
  261. margin-left: 5px;
  262. padding-left: 24px;
  263. padding-right: 24px;
  264. font-size: 16px;
  265. white-space: nowrap;
  266. }
  267. .header-hint {
  268. padding-right: 22px;
  269. font-size: 12px;
  270. color: #666;
  271. white-space: nowrap;
  272. .ivu-btn {
  273. font-size: 12px;
  274. padding: 0 10px;
  275. }
  276. .ivu-dropdown-item {
  277. font-size: 12px !important;
  278. }
  279. }
  280. .header-button {
  281. font-size: 12px;
  282. margin-right: 12px;
  283. }
  284. }
  285. .docs-body {
  286. flex: 1;
  287. width: 100%;
  288. position: relative;
  289. .body-text {
  290. display: flex;
  291. width: 100%;
  292. height: 100%;
  293. .teditor-loadedstyle {
  294. height: 100%;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. </style>
  301. <script>
  302. import Vue from 'vue'
  303. import minder from '../../components/docs/minder'
  304. Vue.use(minder)
  305. const MDEditor = resolve => require(['../../components/MDEditor/index'], resolve);
  306. const TEditor = resolve => require(['../../components/TEditor'], resolve);
  307. const Sheet = resolve => require(['../../components/docs/sheet/index'], resolve);
  308. const Flow = resolve => require(['../../components/docs/flow/index'], resolve);
  309. const NestedDraggable = resolve => require(['../../components/docs/NestedDraggable'], resolve);
  310. const WDrawer = resolve => require(['../../components/iview/WDrawer'], resolve);
  311. export default {
  312. components: {WDrawer, Flow, Sheet, MDEditor, TEditor, NestedDraggable},
  313. data () {
  314. return {
  315. loadIng: 0,
  316. sid: 0,
  317. hid: 0,
  318. docDetail: { },
  319. docContent: { },
  320. bakContent: null,
  321. docDrawerShow: false,
  322. docDrawerTab: '',
  323. sectionLists: [],
  324. sectionNoDataText: "",
  325. historyColumns: [],
  326. historyLists: [],
  327. historyNoDataText: "",
  328. userInfo: {},
  329. routeName: '',
  330. synergyNum: 0,
  331. synchUsers: [],
  332. timeValue: Math.round(new Date().getTime() / 1000),
  333. }
  334. },
  335. created() {
  336. this.historyColumns = [{
  337. "title": this.$L("存档日期"),
  338. "minWidth": 160,
  339. "maxWidth": 200,
  340. render: (h, params) => {
  341. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  342. }
  343. }, {
  344. "title": this.$L("操作员"),
  345. "key": 'username',
  346. "minWidth": 80,
  347. "maxWidth": 130,
  348. render: (h, params) => {
  349. return h('UserView', {
  350. props: {
  351. username: params.row.username
  352. }
  353. });
  354. }
  355. }, {
  356. "title": " ",
  357. "key": 'action',
  358. "width": 80,
  359. "align": 'center',
  360. render: (h, params) => {
  361. if (this.hid == params.row.id || (this.hid == 0 && params.index == 0)) {
  362. return h('Icon', {
  363. props: { type: 'md-checkmark' },
  364. style: { marginRight: '6px', fontSize: '16px', color: '#FF5722' },
  365. });
  366. }
  367. return h('Button', {
  368. props: {
  369. type: 'text',
  370. size: 'small'
  371. },
  372. style: {
  373. fontSize: '12px'
  374. },
  375. on: {
  376. click: () => {
  377. let data = {sid: this.getSid() + "-" + params.row.id, other: this.$route.params.other}
  378. if (params.index == 0) {
  379. data.sid = this.getSid();
  380. }
  381. this.goForward({name: 'docs-edit', params: data }, true);
  382. this.refreshSid();
  383. this.docDrawerShow = false;
  384. }
  385. }
  386. }, this.$L('还原'));
  387. }
  388. }];
  389. },
  390. mounted() {
  391. this.routeName = this.$route.name;
  392. this.userInfo = $A.getUserInfo((res, isLogin) => {
  393. if (this.userInfo.id != res.id) {
  394. this.userInfo = res;
  395. }
  396. }, false);
  397. //
  398. setInterval(() => {
  399. this.timeValue = Math.round(new Date().getTime() / 1000);
  400. });
  401. //
  402. $A.WSOB.setOnMsgListener("chat/index", ['docs'], (msgDetail) => {
  403. if (this.routeName !== this.$route.name) {
  404. return;
  405. }
  406. let body = msgDetail.body;
  407. if (body.sid != this.sid) {
  408. return;
  409. }
  410. switch (body.type) {
  411. case 'users':
  412. this.synchUsers = body.lists;
  413. this.synchUsers.splice(this.synchUsers.length);
  414. break;
  415. case 'update':
  416. this.$Modal.confirm({
  417. title: this.$L("更新提示"),
  418. content: this.$L('团队成员(%)更新了内容,<br/>更新时间:%。<br/><br/>点击【确定】加载最新内容。', body.nickname, $A.formatDate("Y-m-d H:i:s", body.time)),
  419. onOk: () => {
  420. this.refreshDetail();
  421. }
  422. });
  423. break;
  424. case 'lock':
  425. case 'unlock':
  426. if (this.docDetail.lockname == body.lockname) {
  427. return;
  428. }
  429. this.$set(this.docDetail, 'lockname', body.lockname);
  430. this.$set(this.docDetail, 'lockdate', body.lockdate);
  431. this.$Notice.close('docs-lock')
  432. this.$Notice[body.type=='lock'?'warning':'info']({
  433. name: 'docs-lock',
  434. duration: 0,
  435. render: h => {
  436. return h('div', {
  437. style: {
  438. lineHeight: '18px'
  439. }
  440. }, [
  441. h('span', {
  442. style: {
  443. fontWeight: 500
  444. }
  445. }, body.nickname + ':'),
  446. h('span', {
  447. style: {
  448. paddingLeft: '6px'
  449. }
  450. }, this.$L(body.type == 'lock' ? '锁定文档' : '解锁文档'))
  451. ])
  452. }
  453. });
  454. break;
  455. }
  456. });
  457. },
  458. activated() {
  459. this.refreshSid();
  460. this.synergy(true);
  461. },
  462. deactivated() {
  463. if (this.isLock && this.docDetail.lockname == this.userInfo.username) {
  464. this.docDetail.lockname = '';
  465. this.handleClick('unlock');
  466. }
  467. this.$Notice.close('docs-lock');
  468. //
  469. this.synergy(false);
  470. this.docDrawerShow = false;
  471. if ($A.getToken() === false) {
  472. this.sid = 0;
  473. }
  474. },
  475. watch: {
  476. sid(val) {
  477. if (!val) {
  478. this.goBack();
  479. return;
  480. }
  481. this.hid = $A.runNum($A.strExists(val, '-') ? $A.getMiddle(val, "-", null) : 0);
  482. this.refreshDetail();
  483. },
  484. docDrawerTab(act) {
  485. switch (act) {
  486. case "menu":
  487. if (!this.sectionNoDataText) {
  488. this.sectionNoDataText = this.$L("数据加载中.....");
  489. let bookid = this.docDetail.bookid;
  490. $A.aAjax({
  491. url: 'docs/section/lists',
  492. data: {
  493. act: 'edit',
  494. bookid: bookid
  495. },
  496. error: () => {
  497. if (bookid != this.docDetail.bookid) {
  498. return;
  499. }
  500. this.sectionNoDataText = this.$L("数据加载失败!");
  501. },
  502. success: (res) => {
  503. if (bookid != this.docDetail.bookid) {
  504. return;
  505. }
  506. if (res.ret === 1) {
  507. this.sectionLists = res.data.tree;
  508. this.sectionNoDataText = this.$L("没有相关的数据");
  509. }else{
  510. this.sectionLists = [];
  511. this.sectionNoDataText = res.msg;
  512. }
  513. }
  514. });
  515. }
  516. break;
  517. case "history":
  518. if (!this.historyNoDataText) {
  519. this.historyNoDataText = this.$L("数据加载中.....");
  520. let sid = this.getSid();
  521. $A.aAjax({
  522. url: 'docs/section/history',
  523. data: {
  524. id: sid,
  525. pagesize: 50
  526. },
  527. error: () => {
  528. if (sid != this.getSid()) {
  529. return;
  530. }
  531. this.historyNoDataText = this.$L("数据加载失败!");
  532. },
  533. success: (res) => {
  534. if (sid != this.getSid()) {
  535. return;
  536. }
  537. if (res.ret === 1) {
  538. this.historyLists = res.data;
  539. this.historyNoDataText = this.$L("没有相关的数据");
  540. }else{
  541. this.historyLists = [];
  542. this.historyNoDataText = res.msg;
  543. }
  544. }
  545. });
  546. }
  547. break;
  548. }
  549. }
  550. },
  551. computed: {
  552. disabledBtn() {
  553. return this.bakContent == $A.jsonStringify(this.docContent);
  554. },
  555. synchUsersS() {
  556. return this.synchUsers.filter(item => {
  557. return item.indate + 10 > this.timeValue;
  558. });
  559. },
  560. isLock() {
  561. return !!(this.docDetail.lockname && this.docDetail.lockdate > this.timeValue - 60);
  562. }
  563. },
  564. methods: {
  565. synergy(enter) {
  566. if (enter === false) {
  567. $A.WSOB.sendTo('docs', {
  568. type: 'quit',
  569. sid: this.sid,
  570. username: this.userInfo.username,
  571. });
  572. } else {
  573. if (this.routeName !== this.$route.name) {
  574. let tmpNum = this.synergyNum;
  575. setTimeout(() => {
  576. if (tmpNum === this.synergyNum) {
  577. this.synergyNum++;
  578. this.synergy();
  579. }
  580. }, 10000);
  581. } else {
  582. $A.WSOB.sendTo('docs', null, {
  583. type: enter === true ? 'enter' : 'refresh',
  584. sid: this.sid,
  585. username: this.userInfo.username,
  586. userimg: this.userInfo.userimg,
  587. indate: Math.round(new Date().getTime() / 1000),
  588. }, (res) => {
  589. this.synchUsers = res.status === 1 ? res.message : [];
  590. let tmpNum = this.synergyNum;
  591. setTimeout(() => {
  592. if (tmpNum === this.synergyNum) {
  593. this.synergyNum++;
  594. this.synergy();
  595. }
  596. }, 10000);
  597. });
  598. }
  599. }
  600. },
  601. refreshSid() {
  602. this.sid = this.$route.params.sid;
  603. if (typeof this.$route.params.other === "object") {
  604. this.$set(this.docDetail, 'title', $A.getObject(this.$route.params.other, 'title'))
  605. }
  606. },
  607. getSid() {
  608. return $A.runNum($A.getMiddle(this.sid, null, '-'));
  609. },
  610. refreshDetail() {
  611. this.docDetail = { };
  612. this.docContent = { };
  613. this.bakContent = null;
  614. this.getDetail();
  615. },
  616. getDetail() {
  617. this.loadIng++;
  618. $A.aAjax({
  619. url: 'docs/section/content',
  620. data: {
  621. act: 'edit',
  622. id: this.sid,
  623. },
  624. complete: () => {
  625. this.loadIng--;
  626. },
  627. error: () => {
  628. this.goBack();
  629. alert(this.$L('网络繁忙,请稍后再试!'));
  630. },
  631. success: (res) => {
  632. if (res.ret === 1) {
  633. this.docDetail = res.data;
  634. this.docContent = $A.jsonParse(res.data.content);
  635. this.bakContent = $A.jsonStringify(this.docContent);
  636. this.continueLock(1000);
  637. } else {
  638. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  639. this.goBack();
  640. }
  641. }
  642. });
  643. },
  644. handleSection(act, detail) {
  645. if (act === 'open') {
  646. this.goForward({name: 'docs-edit', params: {sid: detail.id, other: detail || {}}}, true);
  647. this.refreshSid();
  648. this.docDrawerShow = false;
  649. }
  650. },
  651. handleSynch(username) {
  652. if (username == this.userInfo.username) {
  653. return;
  654. }
  655. if (typeof window.onChatOpenUserName === "function") {
  656. window.onChatOpenUserName(username);
  657. }
  658. },
  659. handleClick(act) {
  660. switch (act) {
  661. case "back":
  662. if (this.bakContent == $A.jsonStringify(this.docContent) && this.hid == 0) {
  663. this.goBack();
  664. return;
  665. }
  666. this.$Modal.confirm({
  667. title: this.$L('温馨提示'),
  668. content: this.$L('是否放弃修改的内容返回?'),
  669. loading: true,
  670. cancelText: this.$L('放弃保存'),
  671. onCancel: () => {
  672. this.goBack();
  673. },
  674. okText: this.$L('保存并返回'),
  675. onOk: () => {
  676. this.bakContent = $A.jsonStringify(this.docContent);
  677. $A.aAjax({
  678. url: 'docs/section/save?id=' + this.getSid(),
  679. method: 'post',
  680. data: {
  681. D: Object.assign(this.docDetail, {content: this.bakContent})
  682. },
  683. error: () => {
  684. this.$Modal.remove();
  685. alert(this.$L('网络繁忙,请稍后再试!'));
  686. },
  687. success: (res) => {
  688. this.$Modal.remove();
  689. this.goBack();
  690. setTimeout(() => {
  691. if (res.ret === 1) {
  692. this.$Message.success(res.msg);
  693. this.historyNoDataText = '';
  694. } else {
  695. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  696. }
  697. }, 350);
  698. }
  699. });
  700. }
  701. });
  702. break;
  703. case "save":
  704. this.bakContent = $A.jsonStringify(this.docContent);
  705. $A.aAjax({
  706. url: 'docs/section/save?id=' + this.getSid(),
  707. method: 'post',
  708. data: {
  709. D: Object.assign(this.docDetail, {content: this.bakContent})
  710. },
  711. error: () => {
  712. alert(this.$L('网络繁忙,保存失败!'));
  713. },
  714. success: (res) => {
  715. if (res.ret === 1) {
  716. this.$Message.success(res.msg);
  717. this.historyNoDataText = '';
  718. } else {
  719. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  720. this.bakContent = '';
  721. }
  722. }
  723. });
  724. break;
  725. case "menu":
  726. case "history":
  727. this.docDrawerTab = act;
  728. this.docDrawerShow = true
  729. break;
  730. case "share":
  731. this.$Modal.confirm({
  732. render: (h) => {
  733. return h('div', [
  734. h('div', {
  735. style: {
  736. fontSize: '16px',
  737. fontWeight: '500',
  738. marginBottom: '20px',
  739. }
  740. }, this.$L('文档链接')),
  741. h('Input', {
  742. props: {
  743. value: this.handleClick('view'),
  744. readonly: true,
  745. },
  746. })
  747. ])
  748. },
  749. });
  750. break;
  751. case "lock":
  752. case "unlock":
  753. $A.aAjax({
  754. url: 'docs/section/lock?id=' + this.getSid(),
  755. data: {
  756. act: act,
  757. },
  758. error: () => {
  759. alert(this.$L('网络繁忙,请稍后再试!'));
  760. },
  761. success: (res) => {
  762. if (res.ret === 1) {
  763. if (this.docDetail.lockname != res.data.lockname) {
  764. this.$Message.success(res.msg);
  765. }
  766. this.$set(this.docDetail, 'lockname', res.data.lockname);
  767. this.$set(this.docDetail, 'lockdate', res.data.lockdate);
  768. this.continueLock(20000);
  769. } else {
  770. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  771. }
  772. }
  773. });
  774. break;
  775. case "view":
  776. return $A.fillUrl('#/docs/view/' + this.docDetail.id);
  777. }
  778. },
  779. continueLock(time) {
  780. if (!this.isLock) {
  781. return;
  782. }
  783. if (this.docDetail.lockname != this.userInfo.username) {
  784. return;
  785. }
  786. this.__continueLock = $A.randomString(6);
  787. let tempString = this.__continueLock;
  788. setTimeout(() => {
  789. if (tempString != this.__continueLock) {
  790. return;
  791. }
  792. if (!this.isLock) {
  793. return;
  794. }
  795. if (this.docDetail.lockname != this.userInfo.username) {
  796. return;
  797. }
  798. this.handleClick('lock');
  799. }, time);
  800. },
  801. exportMenu(act) {
  802. switch (this.docDetail.type) {
  803. case 'mind':
  804. this.$refs.myMind.exportHandle(act == 'pdf' ? 1 : 0, this.docDetail.title);
  805. break;
  806. case 'flow':
  807. this.$refs.myFlow[act == 'pdf' ? 'exportPDF' : 'exportPNG'](this.docDetail.title, 1);
  808. break;
  809. case 'sheet':
  810. this.$refs.mySheet.exportExcel(this.docDetail.title, act);
  811. break;
  812. }
  813. }
  814. },
  815. }
  816. </script>