NewTabButton.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. <template>
  2. <div class="button_list">
  3. <a-space v-if="leftTabButton && leftTabButton.length" size="small">
  4. <template v-for="(item, index) in leftTabButton" :key="index">
  5. <a-button
  6. v-if="item.action === 'CREATE'"
  7. :icon="h(PlusSquareTwoTone)"
  8. @click="create"
  9. >
  10. {{ item.name }}
  11. </a-button>
  12. <a-button v-else-if="item.action === 'EDIT'" :icon="h(EditTwoTone)">
  13. {{ item.name }}
  14. </a-button>
  15. <a-button
  16. v-else-if="item.action === 'DELETE'"
  17. :icon="h(DeleteTwoTone)"
  18. @click="deleteData"
  19. >
  20. {{ item.name }}
  21. </a-button>
  22. <a-button
  23. v-else-if="item.action === 'RUN_PROCESS_REPORT'"
  24. :icon="h(ControlTwoTone)"
  25. @click="execute(item)"
  26. >
  27. {{ item.name }}
  28. </a-button>
  29. <a-button
  30. v-else-if="item.action === 'OPEN_CUSTOMER_WINDOW'"
  31. :icon="h(BookTwoTone)"
  32. @click="execute(item)"
  33. >
  34. {{ item.name }}
  35. </a-button>
  36. <a-button
  37. v-else-if="item.action === 'OPEN_HTML_WINDOW'"
  38. :icon="h(ContainerTwoTone)"
  39. @click="execute(item)"
  40. >
  41. {{ item.name }}
  42. </a-button>
  43. <a-button
  44. v-else-if="item.action === 'EXPORT'"
  45. :icon="h(FileTextTwoTone)"
  46. @click="exportConfirm"
  47. >
  48. {{ item.name }}
  49. </a-button>
  50. <a-button
  51. v-else-if="item.action === 'REFRESH'"
  52. :icon="h(ReloadOutlined)"
  53. @click="refresh"
  54. >
  55. {{ item.name }}
  56. </a-button>
  57. <a-button v-else-if="item.action === 'NOTICE'" :icon="h(BellTwoTone)">
  58. {{ item.name }}
  59. </a-button>
  60. <a-button
  61. v-else-if="item.action === 'OPEN_REMOTE_COMPONENT_MODULE_IN_MODAL'"
  62. :icon="h(HddOutlined)"
  63. @click="openRemoteComponentModule(item)"
  64. >
  65. {{ item.name }}
  66. </a-button>
  67. <a-button v-else :icon="h(LayoutTwoTone)">{{ item.name }}</a-button>
  68. </template>
  69. </a-space>
  70. <div v-else />
  71. <a-space v-if="rightTabButton && rightTabButton.length" size="small">
  72. <template v-for="(item, index) in rightTabButton" :key="index">
  73. <a-button
  74. v-if="item.action === 'CREATE'"
  75. :icon="h(PlusSquareTwoTone)"
  76. @click="create"
  77. >
  78. {{ item.name }}
  79. </a-button>
  80. <a-button v-else-if="item.action === 'EDIT'" :icon="h(EditTwoTone)">
  81. {{ item.name }}
  82. </a-button>
  83. <a-button
  84. v-else-if="item.action === 'DELETE'"
  85. :icon="h(DeleteTwoTone)"
  86. @click="deleteData"
  87. >
  88. {{ item.name }}
  89. </a-button>
  90. <a-button
  91. v-else-if="item.action === 'RUN_PROCESS_REPORT'"
  92. :icon="h(ControlTwoTone)"
  93. >
  94. {{ item.name }}
  95. </a-button>
  96. <a-button
  97. v-else-if="item.action === 'OPEN_CUSTOMER_WINDOW'"
  98. :icon="h(BookTwoTone)"
  99. >
  100. {{ item.name }}
  101. </a-button>
  102. <a-button
  103. v-else-if="item.action === 'OPEN_HTML_WINDOW'"
  104. :icon="h(ContainerTwoTone)"
  105. >
  106. {{ item.name }}
  107. </a-button>
  108. <a-button
  109. v-else-if="item.action === 'EXPORT'"
  110. :icon="h(FileTextTwoTone)"
  111. @click="exportConfirm"
  112. >
  113. {{ item.name }}
  114. </a-button>
  115. <a-button
  116. v-else-if="item.action === 'REFRESH'"
  117. :icon="h(ReloadOutlined)"
  118. @click="refresh"
  119. >
  120. {{ item.name }}
  121. </a-button>
  122. <a-button v-else-if="item.action === 'NOTICE'" :icon="h(BellTwoTone)">
  123. {{ item.name }}
  124. </a-button>
  125. <a-button
  126. v-else-if="item.action === 'OPEN_REMOTE_COMPONENT_MODULE_IN_MODAL'"
  127. :icon="h(HddOutlined)"
  128. @click="openRemoteComponentModule(item)"
  129. >
  130. {{ item.name }}
  131. </a-button>
  132. <a-button v-else :icon="h(LayoutTwoTone)">{{ item.name }}</a-button>
  133. </template>
  134. </a-space>
  135. <div v-else />
  136. </div>
  137. <Modal v-model:show="modal" :full="true">
  138. <ProcessReportResultPreview
  139. v-if="
  140. processReportResult != null &&
  141. (processReportResult.reportResults != null ||
  142. processReportResult.processResult != null)
  143. "
  144. :process-report-result="processReportResult"
  145. :pdf-only="false"
  146. :excel-only="false"
  147. />
  148. <template #header>
  149. {{ $t("lang.tabButton.executeResult") }}
  150. </template>
  151. </Modal>
  152. <Modal
  153. v-model:show="notificationModal"
  154. :show-canel-button="false"
  155. :show-ok-button="false"
  156. >
  157. <template #header>
  158. {{ $t("lang.tabButton.sendNotice") }}
  159. </template>
  160. <NotificationPanel ref="notificationPanel" />
  161. <template #footer>
  162. <button type="button" class="btn btn-default" @click="executeProcess">
  163. {{ $t("lang.tabButton.send") }}
  164. </button>
  165. <button type="button" class="btn btn-default" @click="cancelNotification">
  166. {{ $t("lang.tabButton.cancel") }}
  167. </button>
  168. </template>
  169. </Modal>
  170. <component
  171. :is="modal1Component"
  172. v-model:open="modal1Open"
  173. :model-data="selectDatas"
  174. @refresh-data="refresh"
  175. />
  176. </template>
  177. <script setup>
  178. import {
  179. ref,
  180. defineProps,
  181. defineEmits,
  182. watch,
  183. getCurrentInstance,
  184. defineAsyncComponent,
  185. h,
  186. onMounted,
  187. } from 'vue';
  188. import Common from '../../common/Common';
  189. import DownloadService from '../../resource/file/DownloadService.js';
  190. import NotificationPanel from '../../customer/NotificationPanel.vue';
  191. import dayjs from 'dayjs';
  192. import GridColumnDefUtil from '../tabGridView/GridColumnDef.js';
  193. import GridColumnDef from '../tabGridView/GridColumnDef.vue';
  194. import CustomerWindowResource from '../../api/dic/CustomerWindowResource.js';
  195. import HtmlWindowResource from '../../api/dic/HtmlWindowResource.js';
  196. import ProcessReportResource from '../../api/dic/ProcessReportResource.js';
  197. import { Spin as ASpin, Empty as AEmpty } from 'ant-design-vue';
  198. import { CssUtil } from 'pc-component-v3';
  199. import {
  200. PlusSquareTwoTone,
  201. DeleteTwoTone,
  202. EditTwoTone,
  203. BookTwoTone,
  204. BellTwoTone,
  205. HddOutlined,
  206. FileTextTwoTone,
  207. ContainerTwoTone,
  208. ControlTwoTone,
  209. ReloadOutlined,
  210. LayoutTwoTone,
  211. } from '@ant-design/icons-vue';
  212. const props = defineProps({
  213. window: {
  214. type: Object,
  215. default: () => ({}),
  216. },
  217. nowTab: {
  218. type: String,
  219. default: '',
  220. },
  221. curdWindowFunctionAccess: {
  222. type: Object,
  223. default: function () {
  224. return null;
  225. },
  226. },
  227. modelDatas: {
  228. type: Object,
  229. default: function () {
  230. return null;
  231. },
  232. },
  233. selectModelDatas: {
  234. type: Array,
  235. default: function () {
  236. return null;
  237. },
  238. },
  239. showTabDto: {
  240. type: Object,
  241. default: function () {
  242. return null;
  243. },
  244. },
  245. simpleFilterParams: {
  246. type: String,
  247. default: null,
  248. },
  249. complexFilterParams: {
  250. type: Array,
  251. default: () => {
  252. return [];
  253. },
  254. },
  255. viewType: {
  256. type: String,
  257. default: null,
  258. },
  259. uuid: {
  260. type: String,
  261. default: null,
  262. },
  263. });
  264. const emit = defineEmits([
  265. 'createRecordInWindowEdit',
  266. 'deleteRecords',
  267. 'refreshDatas',
  268. 'judgeIsHaveButtons',
  269. ]);
  270. const selectDatas = ref([]);
  271. const tabButtons = ref([]);
  272. const leftTabButton = ref([]);
  273. const rightTabButton = ref([]);
  274. const notificationModal = ref(false);
  275. const processReportResult = ref(null);
  276. const modal = ref(false);
  277. //表头按钮提示模态框
  278. const titleModal = ref(false);
  279. const tabButtonModel = ref(null);
  280. const notificationPanel = ref(null);
  281. // 模态框的打开状态
  282. const modal1Open = ref(false);
  283. // 模态框的组件
  284. const modal1Component = ref(null);
  285. const { proxy } = getCurrentInstance(); //访问this
  286. // 新建数据
  287. const create = () => {
  288. emit('createRecordInWindowEdit');
  289. };
  290. // 删除数据
  291. const deleteData = () => {
  292. emit('deleteRecords');
  293. };
  294. // 刷新
  295. const refresh = () => {
  296. emit('refreshDatas', false);
  297. };
  298. watch(
  299. () => props.selectModelDatas,
  300. newV => {
  301. selectDatas.value = newV;
  302. },
  303. { immediate: true, deep: true },
  304. );
  305. /**
  306. * 导出确认
  307. */
  308. const exportConfirm = () => {
  309. if (
  310. props.curdWindowFunctionAccess.canExport != null &&
  311. props.curdWindowFunctionAccess.canExport === true
  312. ) {
  313. BootstrapDialog.show({
  314. title: proxy.$t('lang.TabButton.dataExport'), //title
  315. message: proxy.$t('lang.TabButton.DataExport'),
  316. buttons: [
  317. {
  318. label: proxy.$t('lang.TabButton.exportMasterTableData'),
  319. action: function (dialog) {
  320. exportData(false);
  321. dialog.close();
  322. },
  323. },
  324. {
  325. label: proxy.$t('lang.TabButton.exportAllData'),
  326. action: function (dialog) {
  327. exportData(true);
  328. dialog.close();
  329. },
  330. },
  331. {
  332. label: proxy.$t('lang.TabButton.cancel'),
  333. action: function (dialog) {
  334. dialog.close();
  335. },
  336. },
  337. ],
  338. });
  339. } else {
  340. Notify.error(
  341. proxy.$t('lang.tabButton.describe4'),
  342. proxy.$t('lang.tabButton.describe5'),
  343. false,
  344. );
  345. }
  346. };
  347. const exportData = exportSubTabData => {
  348. var token = localStorage.getItem('#token');
  349. var windowNo = props.window.no;
  350. var recordId = null;
  351. if (props.modelDatas != undefined) {
  352. recordId = props.modelDatas.id;
  353. }
  354. var obj = {
  355. windowNo: windowNo,
  356. tabIndex: props.showTabDto.tabIndex,
  357. recordId: recordId,
  358. token: token,
  359. simpleFilterCondition: props.simpleFilterParams,
  360. filterParams: props.complexFilterParams,
  361. };
  362. let url = null;
  363. if (recordId == null) {
  364. url = Common.getApiURL('exportResource/exportWindowData');
  365. } else {
  366. url = Common.getApiURL('exportResource/exportSingleWindowData');
  367. }
  368. url += '?exportSubTabData=' + exportSubTabData;
  369. let formParameterName = 'exportQueryParamStr';
  370. let formParameterValue = JSON.stringify(obj);
  371. var data = formParameterName + '=' + formParameterValue;
  372. var timeStr = dayjs().format('_YYYYMMDD_hhmmss');
  373. var fileName =
  374. props.showTabDto == null
  375. ? '导出数据' + timeStr + '.xlsx'
  376. : props.showTabDto.name + timeStr + '.xlsx';
  377. DownloadService.postDownloadFile(url, data, fileName);
  378. };
  379. // 发送通知
  380. const sendNotification = () => {
  381. var notification = notificationPanel.value.getNotification();
  382. var recordIds = [];
  383. if (props.viewType == 'Grid') {
  384. if (props.modelDatas && props.modelDatas.length > 0) {
  385. props.modelDatas.forEach(function (item) {
  386. if (item.select) {
  387. recordIds.push(item.id);
  388. }
  389. });
  390. }
  391. }
  392. if (recordIds.length == 0) {
  393. Notify.error(
  394. proxy.$t('lang.Notify.error'),
  395. proxy.$t('lang.tabButton.describe7'),
  396. true,
  397. );
  398. return;
  399. }
  400. if (notification.userIds == null || notification.userIds.length == 0) {
  401. Notify.error(
  402. proxy.$t('lang.Notify.error'),
  403. proxy.$t('lang.tabButton.describe8'),
  404. true,
  405. );
  406. return;
  407. }
  408. if (notification.theme == null || notification.theme.trim() == '') {
  409. Notify.error(
  410. proxy.$t('lang.Notify.error'),
  411. proxy.$t('lang.tabButton.describe9'),
  412. true,
  413. );
  414. return;
  415. }
  416. if (notification.content == null || notification.content.trim() == '') {
  417. Notify.error(
  418. proxy.$t('lang.Notify.error'),
  419. proxy.$t('lang.tabButton.describe10'),
  420. true,
  421. );
  422. return;
  423. }
  424. var windowNo = props.window.no;
  425. var tabIndex = props.showTabDto.tabIndex;
  426. notification.windowNo = windowNo;
  427. notification.tabIndex = tabIndex;
  428. notification.recordIds = recordIds;
  429. notification.className = props.showTabDto.className;
  430. $.ajax({
  431. url: Common.getApiURL('notificationResource/send'),
  432. type: 'post',
  433. beforeSend: function (request) {
  434. Common.addTokenToRequest(request);
  435. },
  436. contentType: 'application/json',
  437. data: JSON.stringify(notification),
  438. success: function (data) {
  439. notificationModal.value = false;
  440. Notify.success(
  441. proxy.$t('lang.tabButton.describe11'),
  442. proxy.$t('lang.tabButton.describe12'),
  443. true,
  444. );
  445. },
  446. error: function (XMLHttpRequest, textStatus, errorThrown) {
  447. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  448. },
  449. });
  450. };
  451. // 取消发送
  452. const cancelNotification = () => {
  453. notificationModal.value = false;
  454. };
  455. // 获取表头按钮分组值,如果没有分组则使用页签按钮
  456. watch(
  457. () => props.window,
  458. newVal => {
  459. if (newVal.tabs && newVal.tabs.length) {
  460. const mapTabButtonDtos = JSON.parse(
  461. JSON.stringify(newVal.tabs[0].tabGridView.mapTabButtonDtos),
  462. );
  463. if (isEmpty(mapTabButtonDtos)) {
  464. tabButtons.value = newVal.tabs[0].tabGridView.tabButtons;
  465. tabButtonsHandler();
  466. } else {
  467. tabButtons.value = newVal.tabs[0].tabGridView.mapTabButtonDtos;
  468. }
  469. }
  470. },
  471. { deep: true, immediate: true },
  472. );
  473. watch(
  474. () => props.nowTab,
  475. (newVal, oldVal) => {
  476. if (newVal !== oldVal) {
  477. let nowTabButtons;
  478. if (tabButtons.value) {
  479. for (let key in tabButtons.value) {
  480. if (key === newVal) {
  481. nowTabButtons = tabButtons.value[key];
  482. tabButtonsHandler(nowTabButtons);
  483. }
  484. }
  485. }
  486. }
  487. },
  488. { deep: true, immediate: true },
  489. );
  490. const tabButtonsHandler = nowTabButtons => {
  491. let buttons;
  492. if (nowTabButtons) {
  493. buttons = JSON.parse(JSON.stringify(nowTabButtons));
  494. } else {
  495. buttons = JSON.parse(JSON.stringify(tabButtons.value));
  496. }
  497. rightTabButton.value = [];
  498. leftTabButton.value = [];
  499. buttons.forEach(item => {
  500. if (item.buttonLocation === 'TABLE_HEADER_RIGHT') {
  501. rightTabButton.value.push(item);
  502. } else {
  503. leftTabButton.value.push(item);
  504. }
  505. });
  506. if (leftTabButton.value.length > 0 || rightTabButton.value.length > 0) {
  507. emit('judgeIsHaveButtons', true);
  508. }
  509. if (leftTabButton.value.length === 0 && rightTabButton.value.length === 0) {
  510. emit('judgeIsHaveButtons', false);
  511. }
  512. };
  513. // 用来判断分组的表头按钮是否有值
  514. const isEmpty = obj => {
  515. if (typeof obj !== 'object' || obj === null) {
  516. return true;
  517. }
  518. if (Object.keys(obj).length === 0) {
  519. return true;
  520. }
  521. };
  522. /**
  523. * 获取字符串的哈希值
  524. * @param input
  525. */
  526. const getHash = function (input) {
  527. let hash = 0;
  528. if (input.length === 0) {
  529. return hash;
  530. }
  531. for (let i = 0; i < input.length; i++) {
  532. const char = input.charCodeAt(i);
  533. hash = (hash << 5) - hash + char;
  534. hash = hash & hash; // 确保返回值是一个32位有符号整数
  535. }
  536. return Math.abs(hash).toString();
  537. };
  538. /**
  539. * 远程加载ES VUE组件模块,并在模态框中打开。
  540. * @param jsUrl js路径
  541. * @param cssUrl css路径
  542. */
  543. const openRemoteComponentModule = async function (tabButton) {
  544. let jsUrl = tabButton.remoteComponentModuleJsUrl;
  545. let cssUrl = tabButton.remoteComponentModuleCssUrl;
  546. // 显示模态框
  547. // 异步的加载js组件
  548. //let jsUrl = './static/client-eam-module-v3/dist/AssetCheckCreate.js';
  549. //let cssUrl = './static/client-eam-module-v3/dist/AssetCheckCreate.css';
  550. if (cssUrl != null && cssUrl.length > 0) {
  551. let cssUrlHash = getHash(cssUrl);
  552. CssUtil.dynamicLoadCss(cssUrl, cssUrlHash);
  553. }
  554. // webpackIgnore:设置为 true 时,禁用动态导入解析。
  555. // const testAsyncRemoteComponent = await import(/* webpackIgnore: true */ jsUrl);
  556. // console.log(testAsyncRemoteComponent);
  557. if (jsUrl != null && jsUrl.length > 0) {
  558. const testAsyncRemoteComponent = defineAsyncComponent({
  559. // 加载函数
  560. loader: () => {
  561. return import(/* webpackIgnore: true */ jsUrl);
  562. },
  563. // 加载异步组件时使用的组件
  564. loadingComponent: ASpin,
  565. // 展示加载组件前的延迟时间,默认为 200ms
  566. delay: 200,
  567. // 加载失败后展示的组件
  568. errorComponent: AEmpty,
  569. // 如果提供了一个 timeout 时间限制,并超时了
  570. // 也会显示这里配置的报错组件,默认值是:Infinity
  571. timeout: 10000,
  572. });
  573. modal1Component.value = testAsyncRemoteComponent;
  574. modal1Open.value = true;
  575. console.log(modal1Component.value);
  576. }
  577. };
  578. //跳转或执行流程
  579. const execute = async function (tabButton) {
  580. tabButtonModel.value = tabButton;
  581. if (
  582. tabButton.customerWindowNo != undefined &&
  583. tabButton.customerWindowNo != ''
  584. ) {
  585. CustomerWindowResource.uniqueByNo(tabButton.customerWindowNo).then(
  586. successData => {
  587. tabButton.customerWindowRouteUrl = successData.routeUrl;
  588. if (tabButton.customerWindowNo == '20221101_151823') {
  589. localStorage.setItem(
  590. 'AssetInstance_ComplexFilterParams',
  591. JSON.stringify(props.complexFilterParams),
  592. );
  593. localStorage.setItem(
  594. 'AssetInstance_SimpleFilterParams',
  595. props.simpleFilterParams,
  596. );
  597. }
  598. //跳转到tabButton.routeUrl
  599. if (props.viewType == 'Form' || props.viewType == 'EditForm') {
  600. switchFormRoute(tabButton);
  601. } else if (props.viewType == 'Grid') {
  602. switchFormRoute(tabButton);
  603. }
  604. },
  605. errorData => {
  606. Common.processException(errorData);
  607. },
  608. );
  609. } else if (
  610. tabButton.processReportNo != undefined &&
  611. tabButton.processReportNo != ''
  612. ) {
  613. // 判断流程报表是否有参数
  614. // 如果有参数则直接跳转到流程和报表的界面。
  615. if (
  616. tabButton.routerRedirect == undefined ||
  617. tabButton.routerRedirect == false
  618. ) {
  619. titleModal.value = true;
  620. if (tabButton.tipsTitle == undefined || tabButton.tipsTitle.length == 0) {
  621. executeProcess();
  622. } else {
  623. titleModal.value = true;
  624. }
  625. } else {
  626. this.$router.push({
  627. path: '/desktop/process-report/' + tabButton.processReportNo,
  628. });
  629. }
  630. } else if (tabButton.htmlWindowNo != undefined) {
  631. HtmlWindowResource.uniqueByNo(tabButton.htmlWindowNo).then(
  632. htmlWindowDto => {
  633. if (htmlWindowDto != undefined) {
  634. var htmlWindowUrl = htmlWindowDto.htmlFileName;
  635. var autoCloseInterval = htmlWindowDto.autoCloseInterval;
  636. var regExp = new RegExp('[{].*?[}]', 'g');
  637. var result = htmlWindowUrl.match(regExp);
  638. if (htmlWindowUrl != undefined && htmlWindowUrl != '') {
  639. for (var index = 0, len = result.length; index < len; index++) {
  640. var tempResult = result[index];
  641. console.log('{' + tempResult + '}匹配');
  642. if (tempResult == '{URL}') {
  643. htmlWindowUrl = htmlWindowUrl.replace(
  644. '{URL}',
  645. Common.getHostPageBaseURL(),
  646. );
  647. } else if (tempResult == '{RecordIds}') {
  648. if (props.viewType == 'Grid') {
  649. var recordIds = '';
  650. if (props.modelDatas && props.modelDatas.length > 0) {
  651. props.modelDatas.forEach(function (item) {
  652. if (item.select) {
  653. recordIds += item.id + ',';
  654. }
  655. });
  656. }
  657. if (recordIds != null && recordIds.length > 0) {
  658. recordIds = recordIds.substring(0, recordIds.length - 1);
  659. } else {
  660. Notify.error(
  661. proxy.$t('lang.Notify.error'),
  662. proxy.$t('lang.tabButton.describe3'),
  663. true,
  664. );
  665. return;
  666. }
  667. htmlWindowUrl = htmlWindowUrl.replace(
  668. '{RecordIds}',
  669. recordIds,
  670. );
  671. } else {
  672. var recordId = props.modelData.id;
  673. htmlWindowUrl = htmlWindowUrl.replace(
  674. '{RecordIds}',
  675. recordId,
  676. );
  677. }
  678. } else if (tempResult == '{Token}') {
  679. htmlWindowUrl = htmlWindowUrl.replace(
  680. '{Token}',
  681. Common.getToken(),
  682. );
  683. } else {
  684. if (props.selectedModelDatas.length == 0) {
  685. Notify.error(
  686. proxy.$t('lang.Notify.error'),
  687. proxy.$t('lang.tabButton.describe3'),
  688. true,
  689. );
  690. return;
  691. } else if (props.selectedModelDatas.length > 1) {
  692. Notify.error(
  693. proxy.$t('lang.Notify.error'),
  694. proxy.$t('lang.tabButton.describe2'),
  695. true,
  696. );
  697. return;
  698. }
  699. var tempResult1 = tempResult.replace('{', '').replace('}', '');
  700. htmlWindowUrl = htmlWindowUrl.replace(
  701. tempResult,
  702. props.getFirstSelectModelDataFieldValue(tempResult1),
  703. );
  704. }
  705. }
  706. var openWindow = window.open(htmlWindowUrl);
  707. // 自动关闭
  708. if (autoCloseInterval != undefined) {
  709. setTimeout(function () {
  710. openWindow.close();
  711. openWindow = undefined;
  712. }, autoCloseInterval * 1000);
  713. }
  714. }
  715. }
  716. },
  717. errorData => {
  718. Common.processException(errorData);
  719. },
  720. );
  721. }
  722. };
  723. // 切换到Form表单的路由
  724. const switchFormRoute = async function (tabButton) {
  725. var recordIds = '';
  726. if (props.modelDatas && props.modelDatas.length > 0) {
  727. props.modelDatas.forEach(function (item) {
  728. if (item.select) {
  729. recordIds += item.id + ',';
  730. }
  731. });
  732. }
  733. var routeDate = {
  734. path: tabButton.customerWindowRouteUrl,
  735. params: {
  736. recordIds: recordIds,
  737. },
  738. };
  739. // 请勿修改,会影响生单的功能
  740. var uuid = props.uuid;
  741. if (uuid != undefined) {
  742. routeDate.path = routeDate.path + '/' + uuid;
  743. }
  744. const frameUrl = Common.getRedirectUrl('#' + routeDate.path);
  745. // 供子页面iframe调用,修改modelData,(举例:生单界面修改参数)。
  746. // window.modelDataChanged = modelDataChanged;
  747. // window.getModelData = this.getModelData;
  748. // let modelData1 = JSON.stringify(modelData);
  749. // console.log(modelData1);
  750. // localStorage.setItem(props.uuid + '#GenerateDocumentTool', modelData1);
  751. var iWidth = 1280; //弹出窗口的宽度;
  752. var iHeight = 720; //弹出窗口的高度;
  753. var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的垂直位置;
  754. var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
  755. window.open(
  756. frameUrl,
  757. '_blank',
  758. 'height=' +
  759. iHeight +
  760. ',innerHeight=' +
  761. iHeight +
  762. ',width=' +
  763. iWidth +
  764. ',innerWidth=' +
  765. iWidth +
  766. ',top=' +
  767. iTop +
  768. ',left=' +
  769. iLeft +
  770. ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no',
  771. );
  772. // window.open(frameUrl);
  773. };
  774. // 执行流程
  775. const executeProcess = async function () {
  776. var ids = [];
  777. if (props.modelDatas) {
  778. props.modelDatas.forEach(function (modelData) {
  779. if (modelData.select == true) {
  780. ids.push(modelData.id);
  781. }
  782. });
  783. } else if (props.modelData) {
  784. ids.push(props.modelData.id);
  785. }
  786. // props.loading=true;
  787. ProcessReportResource.runProcessByIds(
  788. tabButtonModel.value.processReportNo,
  789. ids,
  790. ).then(
  791. successData => {
  792. modal.value = true;
  793. // _self.loading=false;
  794. processReportResult.value = successData;
  795. if (
  796. processReportResult.value.reportResults != undefined &&
  797. processReportResult.value.reportResults.length > 0
  798. ) {
  799. processReportResult.value.reportResults.forEach(function (item, index) {
  800. if (item.reportDefinitionType !== 'ExcelReport') {
  801. item.previewIndex = 1;
  802. } else {
  803. item.previewIndex = 2;
  804. }
  805. if (index == 0) {
  806. item.showPreview = true;
  807. } else {
  808. item.showPreview = false;
  809. }
  810. });
  811. }
  812. titleModal.value = false;
  813. },
  814. errorData => {
  815. titleModal.value = false;
  816. Common.processException(errorData);
  817. },
  818. );
  819. // }
  820. };
  821. //关闭表头按钮提示框
  822. const titleModalClose = async function () {
  823. titleModal.value = false;
  824. };
  825. </script>
  826. <style scoped>
  827. .button_list {
  828. display: flex;
  829. justify-content: space-between;
  830. align-items: center;
  831. margin-right: 6px;
  832. }
  833. .ant-btn {
  834. padding: 4px 10px;
  835. }
  836. </style>