TabButton.vue 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. <template>
  2. <div>
  3. <a-space
  4. v-if="
  5. showTabDto != undefined &&
  6. showTabDto.tabGridView &&
  7. tabButtons != undefined
  8. "
  9. >
  10. <template v-for="item in tabButtons" :key="item.id">
  11. <a-button
  12. v-if="
  13. item.subMenu != true &&
  14. (viewType == 'Grid' ||
  15. (viewType == 'EditForm' && item.editMode == true) ||
  16. (viewType == 'Form' && item.editMode != true)) &&
  17. item.invisible == false
  18. "
  19. @click="execute(item)"
  20. >
  21. {{ Language.getNameTrl($i18n.locale, item) }}
  22. </a-button>
  23. </template>
  24. </a-space>
  25. <a-space>
  26. <a-button v-if="'EditForm' != viewType" @click="exportConfirm">
  27. <template #icon>
  28. <ExportOutlined />
  29. </template>
  30. {{ $t("lang.tabButton.export") }}
  31. </a-button>
  32. <a-button
  33. v-if="mWindow && mWindow.dataTemplateIds != undefined"
  34. @click="importData"
  35. >
  36. <template #icon>
  37. <ImportOutlined />
  38. </template>
  39. {{ $t("lang.tabButton.import") }}
  40. </a-button>
  41. <a-button
  42. v-if="'Form' == viewType || 'Grid' == viewType"
  43. @click="notify"
  44. >
  45. <template #icon>
  46. <MessageOutlined />
  47. </template>
  48. {{ $t("lang.tabButton.notice") }}
  49. </a-button>
  50. <a-button
  51. v-if="'EditForm' != viewType && isOpen"
  52. @click="documentOpen"
  53. >
  54. <template #icon>
  55. <FileDoneOutlined />
  56. </template>
  57. {{ $t("lang.tabButton.open") }}
  58. </a-button>
  59. <a-button
  60. v-if="'EditForm' != viewType && isClose"
  61. @click="documentClose"
  62. >
  63. <template #icon>
  64. <FileExcelOutlined />
  65. </template>
  66. {{ $t("lang.tabButton.close") }}
  67. </a-button>
  68. <template v-for="item in tabButtons" :key="item.id">
  69. <a-button
  70. v-if="
  71. showTabDto.tabGridView &&
  72. item.subMenu == true &&
  73. (viewType == 'Grid' ||
  74. (viewType == 'EditForm' && item.editMode == true) ||
  75. (viewType == 'Form' && item.editMode != true)) &&
  76. item.invisible == false
  77. "
  78. @click="execute(item)"
  79. >
  80. {{ Language.getNameTrl($i18n.locale, item) }}
  81. </a-button>
  82. </template>
  83. </a-space>
  84. <a-modal v-model:open="modal" width="100%" :title="$t('lang.tabButton.executeResult')">
  85. <ProcessReportResultPreview
  86. v-if="
  87. processReportResult != null &&
  88. (processReportResult.reportResults != null ||
  89. processReportResult.processResult != null)
  90. "
  91. :process-report-result="processReportResult"
  92. :pdf-only="false"
  93. :excel-only="false"
  94. />
  95. </a-modal>
  96. <a-modal
  97. v-model:show="notificationModal"
  98. :title="$t('lang.tabButton.sendNotice')"
  99. >
  100. <NotificationPanel ref="notificationPanel" />
  101. <template #footer>
  102. <a-button @click="sendNotification">
  103. {{ $t("lang.tabButton.send") }}
  104. </a-button>
  105. <a-button
  106. @click="cancelNotification"
  107. >
  108. {{ $t("lang.tabButton.cancel") }}
  109. </a-button>
  110. </template>
  111. </a-modal>
  112. <Loading v-if="loading" />
  113. </div>
  114. </template>
  115. <script>
  116. import Common from '../../common/Common.js';
  117. import DownloadService from '../../resource/file/DownloadService.js';
  118. import CustomerWindowResource from '../../api/dic/CustomerWindowResource.js';
  119. import HtmlWindowResource from '../../api/dic/HtmlWindowResource.js';
  120. import ProcessReportResource from '../../api/dic/ProcessReportResource.js';
  121. import UserStorageResource from '../../api/base/UserStorageResource.js';
  122. import Language from '../../common/Language.js';
  123. import { Notify, Uuid } from 'pc-component-v3';
  124. import dayjs from 'dayjs';
  125. import NotificationPanel from '../../customer/NotificationPanel.vue';
  126. import { IFrameUtil } from 'pc-component-v3';
  127. import { ExportOutlined, ImportOutlined, MessageOutlined, FileDoneOutlined, FileExcelOutlined } from '@ant-design/icons-vue';
  128. export default {
  129. components: {
  130. NotificationPanel,
  131. ExportOutlined,
  132. ImportOutlined,
  133. MessageOutlined,
  134. FileDoneOutlined,
  135. FileExcelOutlined,
  136. },
  137. props: {
  138. showTabDto: {
  139. type: Object,
  140. default: function () {
  141. return null;
  142. },
  143. },
  144. parentModelData: {
  145. type: Object,
  146. default: function () {
  147. return null;
  148. },
  149. },
  150. modelData: {
  151. type: Object,
  152. default: function () {
  153. return null;
  154. },
  155. },
  156. modelDatas: {
  157. type: Array,
  158. default: function () {
  159. return null;
  160. },
  161. },
  162. uuid: {
  163. type: String,
  164. default: null,
  165. },
  166. viewType: {
  167. type: String,
  168. default: null,
  169. },
  170. type: {
  171. type: String,
  172. default: null,
  173. },
  174. simpleFilterParams: {
  175. type: String,
  176. default: null,
  177. },
  178. complexFilterParams: {
  179. type: Array,
  180. default: () => {
  181. return [];
  182. },
  183. },
  184. mWindow: {
  185. type: Object,
  186. default: function () {
  187. return null;
  188. },
  189. },
  190. tabButtons: {
  191. type: Array,
  192. default: function () {
  193. return null;
  194. },
  195. },
  196. curdWindowFunctionAccess: {
  197. type: Object,
  198. default: function () {
  199. return null;
  200. },
  201. },
  202. },
  203. emits: ['saveView', 'processExecuteFinish', 'modelDataChanged'],
  204. data: function () {
  205. this.Language = Language;
  206. return {
  207. processReportResult: {},
  208. openWindow: null,
  209. loading: false,
  210. modal: false,
  211. notificationModal: false,
  212. };
  213. },
  214. computed: {
  215. isShow: function () {
  216. if (this.showTabDto == undefined) {
  217. return false;
  218. } else if (this.tabButtons == undefined) {
  219. return false;
  220. } else if (this.tabButtons.length == 0) {
  221. return false;
  222. }
  223. return true;
  224. },
  225. /**
  226. * 判断打开按钮是否显示(单据处于已审批状态且关闭时间不为空)
  227. * @author LeiGuoXian
  228. * @date 2021-09-26
  229. */
  230. isOpen: function () {
  231. var _self = this;
  232. if (_self.parentModelData != undefined) {
  233. if (
  234. _self.parentModelData.data != undefined &&
  235. _self.parentModelData.data.documentStatus != undefined &&
  236. _self.parentModelData.data.documentStatus.displayValue[0] ==
  237. 'APPROVED' &&
  238. _self.parentModelData.data.closeDate != undefined
  239. ) {
  240. return true;
  241. } else {
  242. return false;
  243. }
  244. } else {
  245. if (
  246. _self.modelData != undefined &&
  247. _self.modelData.data != undefined &&
  248. _self.modelData.data.documentStatus != undefined &&
  249. _self.modelData.data.documentStatus.displayValue[0] == 'APPROVED' &&
  250. _self.modelData.data.closeDate != undefined &&
  251. _self.modelData.data.closeDate.displayValue.length != 0
  252. ) {
  253. return true;
  254. } else {
  255. return false;
  256. }
  257. }
  258. },
  259. /**
  260. * 判断关闭按钮是否显示(单据处于已审批状态且关闭时间为空)
  261. * @author LeiGuoXian
  262. * @date 2021-09-26
  263. */
  264. isClose: function () {
  265. var _self = this;
  266. if (_self.parentModelData != undefined) {
  267. if (
  268. _self.parentModelData.data != undefined &&
  269. _self.parentModelData.data.documentStatus != undefined &&
  270. _self.parentModelData.data.documentStatus.displayValue[0] ==
  271. 'APPROVED' &&
  272. _self.parentModelData.data.closeDate != undefined
  273. ) {
  274. return true;
  275. } else {
  276. return false;
  277. }
  278. } else {
  279. if (
  280. _self.modelData != undefined &&
  281. _self.modelData.data != undefined &&
  282. _self.modelData.data.documentStatus != undefined &&
  283. _self.modelData.data.documentStatus.displayValue[0] == 'APPROVED' &&
  284. _self.modelData.data.closeDate != undefined &&
  285. _self.modelData.data.closeDate.displayValue.length == 0
  286. ) {
  287. return true;
  288. } else {
  289. return false;
  290. }
  291. }
  292. },
  293. },
  294. watch: {},
  295. methods: {
  296. /**
  297. * CURD单据关闭(关闭后不能被下流单据引用,已经生单的单据不受影响)
  298. *
  299. * @author LeiGuoXian
  300. * @date 2021-09-26
  301. */
  302. documentClose: function () {
  303. var _self = this;
  304. var windowNo = this.$route.params.windowNo;
  305. var tabIndex = _self.showTabDto.tabIndex;
  306. var recordId = null;
  307. var closeRecordIds = [];
  308. if (tabIndex == 0) {
  309. recordId = _self.modelData.id;
  310. } else if (tabIndex == 1) {
  311. recordId = _self.parentModelData.id;
  312. if (_self.modelDatas == undefined || _self.modelDatas.length == 0) {
  313. Notify.error(
  314. _self.$t('lang.Notify.error'),
  315. _self.$t('lang.tabButton.describe1'),
  316. false,
  317. );
  318. return;
  319. } else {
  320. _self.modelDatas.forEach(function (item) {
  321. if (item.select == true) {
  322. closeRecordIds.push(item.id);
  323. }
  324. });
  325. if (closeRecordIds.length == 0) {
  326. Notify.error(
  327. _self.$t('lang.Notify.error'),
  328. _self.$t('lang.tabButton.describe2'),
  329. false,
  330. );
  331. return;
  332. }
  333. }
  334. }
  335. var documentCloseRequest = {
  336. windowNo: windowNo,
  337. tabIndex: tabIndex,
  338. documentRecordId: recordId,
  339. closeRecordIds: closeRecordIds,
  340. };
  341. $.ajax({
  342. url: Common.getApiURL('documentResource/documentClose'),
  343. type: 'post',
  344. beforeSend: function (request) {
  345. Common.addTokenToRequest(request);
  346. },
  347. contentType: 'application/json',
  348. data: JSON.stringify(documentCloseRequest),
  349. success: function (data) {
  350. if (data.errcode == 0) {
  351. Notify.success(_self.$t('lang.Notify.success'), data.errmsg, false);
  352. } else {
  353. Notify.error(_self.$t('lang.Notify.prompt'), data.errmsg, false);
  354. }
  355. _self.$emit('processExecuteFinish');
  356. },
  357. error: function (XMLHttpRequest, textStatus, errorThrown) {
  358. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  359. },
  360. });
  361. },
  362. /**
  363. * CURD单据打开(打开后可以被下流单据引用)
  364. *
  365. * @author LeiGuoXian
  366. * @date 2021-09-26
  367. */
  368. documentOpen: function () {
  369. var _self = this;
  370. var windowNo = this.$route.params.windowNo;
  371. var tabIndex = _self.showTabDto.tabIndex;
  372. var recordId = null;
  373. var openRecordIds = [];
  374. if (tabIndex == 0) {
  375. recordId = _self.modelData.id;
  376. } else if (tabIndex == 1) {
  377. recordId = _self.parentModelData.id;
  378. if (_self.modelDatas == undefined || _self.modelDatas.length == 0) {
  379. Notify.error(
  380. _self.$t('lang.Notify.error'),
  381. _self.$t('lang.tabButton.describe1'),
  382. false,
  383. );
  384. return;
  385. } else {
  386. _self.modelDatas.forEach(function (item) {
  387. if (item.select == true) {
  388. openRecordIds.push(item.id);
  389. }
  390. });
  391. if (openRecordIds.length == 0) {
  392. Notify.error(
  393. _self.$t('lang.Notify.error'),
  394. _self.$t('lang.tabButton.describe2'),
  395. false,
  396. );
  397. return;
  398. }
  399. }
  400. }
  401. var documentOpenRequest = {
  402. windowNo: windowNo,
  403. tabIndex: tabIndex,
  404. documentRecordId: recordId,
  405. openRecordIds: openRecordIds,
  406. };
  407. $.ajax({
  408. url: Common.getApiURL('documentResource/documentOpen'),
  409. type: 'post',
  410. beforeSend: function (request) {
  411. Common.addTokenToRequest(request);
  412. },
  413. contentType: 'application/json',
  414. data: JSON.stringify(documentOpenRequest),
  415. success: function (data) {
  416. if (data.errcode == 0) {
  417. Notify.success(_self.$t('lang.Notify.success'), data.errmsg, false);
  418. } else {
  419. Notify.error(_self.$t('lang.Notify.prompt'), data.errmsg, false);
  420. }
  421. _self.$emit('processExecuteFinish');
  422. },
  423. error: function (XMLHttpRequest, textStatus, errorThrown) {
  424. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  425. },
  426. });
  427. },
  428. //跳转或执行流程
  429. execute: function (tabButton) {
  430. var _self = this;
  431. if (
  432. tabButton.customerWindowNo != undefined &&
  433. tabButton.customerWindowNo != ''
  434. ) {
  435. CustomerWindowResource.uniqueByNo(tabButton.customerWindowNo).then(
  436. successData => {
  437. tabButton.customerWindowRouteUrl = successData.routeUrl;
  438. if (tabButton.customerWindowNo == '20221101_151823') {
  439. localStorage.setItem(
  440. 'AssetInstance_ComplexFilterParams',
  441. JSON.stringify(_self.complexFilterParams),
  442. );
  443. localStorage.setItem(
  444. 'AssetInstance_SimpleFilterParams',
  445. _self.simpleFilterParams,
  446. );
  447. }
  448. //跳转到tabButton.routeUrl
  449. if (this.viewType == 'Form' || this.viewType == 'EditForm') {
  450. this.switchFormRoute(tabButton);
  451. } else if (this.viewType == 'Grid') {
  452. this.switchFormRoute(tabButton);
  453. }
  454. },
  455. errorData => {
  456. Common.processException(errorData);
  457. },
  458. );
  459. } else if (
  460. tabButton.processReportNo != undefined &&
  461. tabButton.processReportNo != ''
  462. ) {
  463. // 判断流程报表是否有参数
  464. // 如果有参数则直接跳转到流程和报表的界面。
  465. if (
  466. tabButton.routerRedirect == undefined ||
  467. tabButton.routerRedirect == false
  468. ) {
  469. this.executeProcess(tabButton);
  470. } else {
  471. this.$router.push({
  472. path: '/desktop/process-report/' + tabButton.processReportNo,
  473. });
  474. }
  475. } else if (tabButton.htmlWindowNo != undefined) {
  476. HtmlWindowResource.uniqueByNo(tabButton.htmlWindowNo).then(
  477. htmlWindowDto => {
  478. if (htmlWindowDto != undefined) {
  479. var htmlWindowUrl = htmlWindowDto.htmlFileName;
  480. var autoCloseInterval = htmlWindowDto.autoCloseInterval;
  481. var regExp = new RegExp('[{].*?[}]', 'g');
  482. var result = htmlWindowUrl.match(regExp);
  483. if (htmlWindowUrl != undefined && htmlWindowUrl != '') {
  484. for (var index = 0, len = result.length; index < len; index++) {
  485. var tempResult = result[index];
  486. console.log('{' + tempResult + '}匹配');
  487. if (tempResult == '{URL}') {
  488. htmlWindowUrl = htmlWindowUrl.replace(
  489. '{URL}',
  490. Common.getHostPageBaseURL(),
  491. );
  492. } else if (tempResult == '{RecordIds}') {
  493. if (this.viewType == 'Grid') {
  494. var recordIds = '';
  495. if (_self.modelDatas && _self.modelDatas.length > 0) {
  496. _self.modelDatas.forEach(function (item) {
  497. if (item.select) {
  498. recordIds += item.id + ',';
  499. }
  500. });
  501. }
  502. if (recordIds != null && recordIds.length > 0) {
  503. recordIds = recordIds.substring(
  504. 0,
  505. recordIds.length - 1,
  506. );
  507. } else {
  508. Notify.error(
  509. _self.$t('lang.Notify.error'),
  510. _self.$t('lang.tabButton.describe3'),
  511. true,
  512. );
  513. return;
  514. }
  515. htmlWindowUrl = htmlWindowUrl.replace(
  516. '{RecordIds}',
  517. recordIds,
  518. );
  519. } else {
  520. var recordId = _self.modelData.id;
  521. htmlWindowUrl = htmlWindowUrl.replace(
  522. '{RecordIds}',
  523. recordId,
  524. );
  525. }
  526. } else if (tempResult == '{Token}') {
  527. htmlWindowUrl = htmlWindowUrl.replace(
  528. '{Token}',
  529. Common.getToken(),
  530. );
  531. } else {
  532. if (_self.selectedModelDatas.length == 0) {
  533. Notify.error(
  534. _self.$t('lang.Notify.error'),
  535. _self.$t('lang.tabButton.describe3'),
  536. true,
  537. );
  538. return;
  539. } else if (_self.selectedModelDatas.length > 1) {
  540. Notify.error(
  541. _self.$t('lang.Notify.error'),
  542. _self.$t('lang.tabButton.describe2'),
  543. true,
  544. );
  545. return;
  546. }
  547. var tempResult1 = tempResult
  548. .replace('{', '')
  549. .replace('}', '');
  550. htmlWindowUrl = htmlWindowUrl.replace(
  551. tempResult,
  552. _self.getFirstSelectModelDataFieldValue(tempResult1),
  553. );
  554. }
  555. }
  556. var openWindow = window.open(htmlWindowUrl);
  557. // 自动关闭
  558. if (autoCloseInterval != undefined) {
  559. setTimeout(function () {
  560. openWindow.close();
  561. openWindow = undefined;
  562. }, autoCloseInterval * 1000);
  563. }
  564. }
  565. }
  566. },
  567. errorData => {
  568. Common.processException(errorData);
  569. },
  570. );
  571. }
  572. },
  573. autoCloseOpenWindow: function () {
  574. if (this.openWindow != null) {
  575. this.openWindow.close();
  576. this.openWindow = null;
  577. }
  578. },
  579. /**
  580. * 导出确认
  581. */
  582. exportConfirm: function () {
  583. var _self = this;
  584. if (
  585. _self.curdWindowFunctionAccess.canExport != null &&
  586. _self.curdWindowFunctionAccess.canExport === true
  587. ) {
  588. BootstrapDialog.show({
  589. title: _self.$t('lang.TabButton.dataExport'), //title
  590. message: _self.$t('lang.TabButton.DataExport'),
  591. buttons: [
  592. {
  593. label: _self.$t('lang.TabButton.exportMasterTableData'),
  594. action: function (dialog) {
  595. _self.exportData(false);
  596. dialog.close();
  597. },
  598. },
  599. {
  600. label: _self.$t('lang.TabButton.exportAllData'),
  601. action: function (dialog) {
  602. _self.exportData(true);
  603. dialog.close();
  604. },
  605. },
  606. {
  607. label: _self.$t('lang.TabButton.cancel'),
  608. action: function (dialog) {
  609. dialog.close();
  610. },
  611. },
  612. ],
  613. });
  614. } else {
  615. Notify.error(
  616. _self.$t('lang.tabButton.describe4'),
  617. _self.$t('lang.tabButton.describe5'),
  618. false,
  619. );
  620. }
  621. },
  622. /**
  623. * 导出数据
  624. * @param exportSubTabData 是否导出子页签数据
  625. */
  626. exportData: function (exportSubTabData) {
  627. var _self = this;
  628. var downloadUrl = null;
  629. var token = Common.getToken();
  630. var windowNo = this.$route.params.windowNo;
  631. var recordId = null;
  632. if (_self.modelData != undefined) {
  633. recordId = _self.modelData.id;
  634. }
  635. var uuid = _self.uuid;
  636. var obj = {
  637. windowNo: windowNo,
  638. tabIndex: _self.showTabDto.tabIndex,
  639. recordId: recordId,
  640. token: token,
  641. simpleFilterCondition: _self.simpleFilterParams,
  642. filterParams: _self.complexFilterParams,
  643. };
  644. let url = null;
  645. if (recordId == null) {
  646. url = Common.getApiURL('exportResource/exportWindowData');
  647. } else {
  648. url = Common.getApiURL('exportResource/exportSingleWindowData');
  649. }
  650. url += '?exportSubTabData=' + exportSubTabData;
  651. let formParameterName = 'exportQueryParamStr';
  652. let formParameterValue = JSON.stringify(obj);
  653. var data = formParameterName + '=' + formParameterValue;
  654. var timeStr = dayjs().format('_YYYYMMDD_hhmmss');
  655. var fileName =
  656. _self.showTabDto == null
  657. ? '导出数据' + timeStr + '.xlsx'
  658. : _self.showTabDto.name + timeStr + '.xlsx';
  659. DownloadService.postDownloadFile(url, data, fileName);
  660. },
  661. importData: function () {
  662. var _self = this;
  663. var uuid = _self.uuid;
  664. if (
  665. _self.mWindow != undefined &&
  666. _self.mWindow.dataTemplateIds != undefined
  667. ) {
  668. var data = JSON.stringify(_self.mWindow.dataTemplateIds);
  669. this.$router.push({
  670. path: '/desktop/data-import-panel',
  671. query: { dataTemplateIds: data },
  672. });
  673. }
  674. },
  675. // 切换到Form表单的路由
  676. switchFormRoute: function (tabButton) {
  677. const _self = this;
  678. var routeDate = {
  679. path: tabButton.customerWindowRouteUrl,
  680. params: {
  681. processReportId: tabButton.processReportId,
  682. modelData: this.modelData,
  683. },
  684. };
  685. // 请勿修改,会影响生单的功能
  686. var uuid = _self.uuid;
  687. if (uuid != undefined) {
  688. routeDate.path = routeDate.path + '/' + uuid;
  689. }
  690. this.$emit('saveView');
  691. const frameUrl = Common.getRedirectUrl(
  692. '#' + routeDate.path + '?processReportId=' + tabButton.processReportId,
  693. );
  694. // 供子页面iframe调用,修改modelData,(举例:生单界面修改参数)。
  695. window.modelDataChanged = this.modelDataChanged;
  696. window.getModelData = this.getModelData;
  697. let modelData = JSON.stringify(this.modelData);
  698. console.log(modelData);
  699. localStorage.setItem(_self.uuid + '#GenerateDocumentTool', modelData);
  700. var iWidth = 1280; //弹出窗口的宽度;
  701. var iHeight = 720; //弹出窗口的高度;
  702. var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的垂直位置;
  703. var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
  704. window.open(
  705. frameUrl,
  706. '_blank',
  707. 'height=' +
  708. iHeight +
  709. ',innerHeight=' +
  710. iHeight +
  711. ',width=' +
  712. iWidth +
  713. ',innerWidth=' +
  714. iWidth +
  715. ',top=' +
  716. iTop +
  717. ',left=' +
  718. iLeft +
  719. ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no',
  720. );
  721. // window.open(frameUrl);
  722. },
  723. modelDataChanged: function (newModelData) {
  724. const _self = this;
  725. _self.$emit('modelDataChanged', newModelData);
  726. },
  727. getModelData: function () {
  728. const _self = this;
  729. return _self.$parent.getModelData();
  730. },
  731. // 执行Form流程
  732. executeFormProcess: function (tabButton) {
  733. var _self = this;
  734. //执行流程
  735. if (_self.modelData.id == undefined) {
  736. Notify.error(
  737. _self.$t('lang.tabButton.describe6'),
  738. _self.$t('lang.tabButton.describe7'),
  739. false,
  740. );
  741. return;
  742. }
  743. //执行流程
  744. var processResultData = {
  745. processReportId: tabButton.processReportId,
  746. modelData: _self.modelData,
  747. };
  748. _self.loading = true;
  749. $.ajax({
  750. url: Common.getApiURL('ProcessReportResource/runProcess'),
  751. type: 'post',
  752. dataType: 'json',
  753. beforeSend: function (request) {
  754. Common.addTokenToRequest(request);
  755. },
  756. contentType: 'application/json',
  757. data: JSON.stringify(processResultData),
  758. success: function (successData) {
  759. if (successData.errorCode == 0) {
  760. _self.modal = true;
  761. _self.loading = false;
  762. _self.processReportResult = successData.data;
  763. if (
  764. _self.processReportResult.reportResults != undefined &&
  765. _self.processReportResult.reportResults.length > 0
  766. ) {
  767. _self.processReportResult.reportResults.forEach(function (
  768. item,
  769. index,
  770. ) {
  771. item.previewIndex = 1;
  772. if (index == 0) {
  773. item.showPreview = true;
  774. } else {
  775. item.showPreview = false;
  776. }
  777. });
  778. }
  779. _self.$emit('processExecuteFinish');
  780. }
  781. },
  782. error: function (XMLHttpRequest, textStatus, errorThrown) {
  783. _self.loading = false;
  784. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  785. },
  786. });
  787. },
  788. // 执行流程
  789. executeProcess: function (tabButton) {
  790. var _self = this;
  791. // if (_self.viewType == 'EditForm' || _self.viewType == 'Form') {
  792. // let processResultData = {
  793. // "processReportNo": tabButton.processReportNo,
  794. // "modelData": _self.modelData
  795. // }
  796. // _self.loading=true;
  797. // ProcessReportResource.runProcess(processResultData).then(successData => {
  798. // _self.modal = true;
  799. // _self.loading=false;
  800. // _self.processReportResult = successData;
  801. // _self.$emit("processExecuteFinish");
  802. // }, errorData => {
  803. // _self.loading=false;
  804. // Common.processException(errorData);
  805. // });
  806. // } else {
  807. var ids = [];
  808. if (_self.modelDatas) {
  809. _self.modelDatas.forEach(function (modelData) {
  810. if (modelData.select == true) {
  811. ids.push(modelData.id);
  812. }
  813. });
  814. } else if (_self.modelData) {
  815. ids.push(_self.modelData.id);
  816. }
  817. _self.loading = true;
  818. ProcessReportResource.runProcessByIds(
  819. tabButton.processReportNo,
  820. ids,
  821. ).then(
  822. successData => {
  823. _self.modal = true;
  824. _self.loading = false;
  825. _self.processReportResult = successData;
  826. if (
  827. _self.processReportResult.reportResults != undefined &&
  828. _self.processReportResult.reportResults.length > 0
  829. ) {
  830. _self.processReportResult.reportResults.forEach(function (
  831. item,
  832. index,
  833. ) {
  834. if (item.reportDefinitionType !== 'ExcelReport') {
  835. item.previewIndex = 1;
  836. } else {
  837. item.previewIndex = 2;
  838. }
  839. if (index == 0) {
  840. item.showPreview = true;
  841. } else {
  842. item.showPreview = false;
  843. }
  844. });
  845. }
  846. _self.$emit('processExecuteFinish');
  847. },
  848. errorData => {
  849. _self.loading = false;
  850. Common.processException(errorData);
  851. },
  852. );
  853. // }
  854. },
  855. // 通知
  856. notify: function () {
  857. var _self = this;
  858. _self.notificationModal = true;
  859. },
  860. // 发送通知
  861. sendNotification: function () {
  862. var _self = this;
  863. var notification = _self.$refs.notificationPanel.getNotification();
  864. var recordIds = [];
  865. if (_self.viewType == 'Grid') {
  866. if (_self.modelDatas && _self.modelDatas.length > 0) {
  867. _self.modelDatas.forEach(function (item) {
  868. if (item.select) {
  869. recordIds.push(item.id);
  870. }
  871. });
  872. }
  873. } else if (_self.viewType == 'Form') {
  874. recordIds.push(_self.$route.params.recordId);
  875. }
  876. if (recordIds.length == 0) {
  877. Notify.error(
  878. _self.$t('lang.Notify.error'),
  879. _self.$t('lang.tabButton.describe7'),
  880. true,
  881. );
  882. return;
  883. }
  884. if (notification.userIds == null || notification.userIds.length == 0) {
  885. Notify.error(
  886. _self.$t('lang.Notify.error'),
  887. _self.$t('lang.tabButton.describe8'),
  888. true,
  889. );
  890. return;
  891. }
  892. if (notification.theme == null || notification.theme.trim() == '') {
  893. Notify.error(
  894. _self.$t('lang.Notify.error'),
  895. _self.$t('lang.tabButton.describe9'),
  896. true,
  897. );
  898. return;
  899. }
  900. if (notification.content == null || notification.content.trim() == '') {
  901. Notify.error(
  902. _self.$t('lang.Notify.error'),
  903. _self.$t('lang.tabButton.describe10'),
  904. true,
  905. );
  906. return;
  907. }
  908. var windowNo = _self.$route.params.windowNo;
  909. var tabIndex = _self.showTabDto.tabIndex;
  910. notification.windowNo = windowNo;
  911. notification.tabIndex = tabIndex;
  912. notification.recordIds = recordIds;
  913. notification.className = _self.showTabDto.className;
  914. _self.loading = true;
  915. $.ajax({
  916. url: Common.getApiURL('notificationResource/send'),
  917. type: 'post',
  918. beforeSend: function (request) {
  919. Common.addTokenToRequest(request);
  920. },
  921. contentType: 'application/json',
  922. data: JSON.stringify(notification),
  923. success: function (data) {
  924. _self.loading = false;
  925. _self.notificationModal = false;
  926. Notify.success(
  927. _self.$t('lang.tabButton.describe11'),
  928. _self.$t('lang.tabButton.describe12'),
  929. true,
  930. );
  931. },
  932. error: function (XMLHttpRequest, textStatus, errorThrown) {
  933. _self.loading = false;
  934. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  935. },
  936. });
  937. },
  938. // 取消发送
  939. cancelNotification: function () {
  940. this.notificationModal = false;
  941. },
  942. },
  943. };
  944. </script>
  945. <style scoped>
  946. .floatTop {
  947. z-index: 1002;
  948. }
  949. :deep(.btn-group) {
  950. margin: -2px;
  951. }
  952. .tab_button {
  953. color: black;
  954. margin-left: 4px;
  955. }
  956. :deep(.ant-breadcrumb-link :first-child){
  957. color: #4ca4f7;
  958. }
  959. </style>