QueryPage.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. <template>
  2. <div
  3. class="flex-container" :class="{
  4. 'flex-container-modal': isSearchWidget == true,
  5. 'flex-container': isSearchWidget == null || isSearchWidget == false,
  6. }"
  7. >
  8. <div class="flex-header">
  9. <div>
  10. <div>
  11. <InfoHeader
  12. :html-help-url="infoWindowDto.htmlHelpUrl"
  13. :info-grid-fields="infoGridFieldsInstance.infoGridFields"
  14. :header-name="Language.getNameTrl($i18n.locale, infoWindowDto)"
  15. :sub-header-name="Language.getHelpTrl($i18n.locale, infoWindowDto)" :info-filter-fields="infoFilterFields"
  16. :info-window-no="infoWindowDto.no" :show-back="isSearchWidget == null || isSearchWidget == false"
  17. @filter-field-property-changed="filterFieldPropertyChanged($event)"
  18. @grid-field-property-changed="gridFieldPropertyChanged($event)"
  19. />
  20. </div>
  21. <div>
  22. <a-flex justify="space-between" align="center">
  23. <QueryCondition
  24. ref="queryCondition" :info-filter-fields="infoFilterFields"
  25. :info-buttons="infoWindowDto.infoButtons" :is-search-widget="isSearchWidget"
  26. :info-window-no="infoWindowDto.no" :search-condition-instance="searchConditionInstance"
  27. @simple-search="simpleSearch" @complex-search="complexSearch"
  28. />
  29. <div>
  30. <a-pagination
  31. v-model:current="pagination.current_page" v-model:pageSize="pagination.per_page"
  32. show-quick-jumper size="small" :total="pagination.total" :page-size-options="pageSizeOptions"
  33. @change="handlePageChange" @show-size-change="handleShowSizeChange"
  34. />
  35. </div>
  36. </a-flex>
  37. </div>
  38. </div>
  39. <div v-if="!isSearchWidget" style="display: inline-block">
  40. <QueryPageButton
  41. :info-buttons="infoWindowDto.infoButtons" :info-window-no="infoWindowDto.no" :select-info-data="selectInfoData" :class-name="className"
  42. @refresh-datas="pageSearch" @execute-export="executeExport" @execute-process="executeProcess"
  43. />
  44. </div>
  45. <a-segmented v-model:value="selectedView" :options="views" class="m-segmented" size="small">
  46. <template #label="{ value: val, payload = {} }">
  47. <div style="padding: 2px 2px">
  48. <a-tooltip :title="payload.name" placement="top">
  49. <a-avatar
  50. :src="payload.src" :style="payload.icon ? payload.style : null" :alt="val" size="small"
  51. shape="square"
  52. >
  53. <template #icon>
  54. <component :is="payload.icon" style="font-size: 22px; color: #1677ff; background: #f5f5f5" />
  55. </template>
  56. {{ payload.content }}
  57. </a-avatar>
  58. </a-tooltip>
  59. </div>
  60. </template>
  61. </a-segmented>
  62. </div>
  63. <!-- xx -->
  64. <div
  65. style="
  66. padding: 0;
  67. border-bottom: solid 1px #d1cfcf;
  68. margin-top: 5px;
  69. margin-bottom: 5px;
  70. "
  71. />
  72. <div class="flex-content">
  73. <component
  74. :is="selectedView" v-if="
  75. selectedView != null &&
  76. selectedView != '' &&
  77. componentLoadedCount == views.length
  78. " :info-grid-fields-instance="infoGridFieldsInstance" :sort-instance="sortInstance"
  79. :info-window-data-instance="infoWindowDataInstance" :pagination="pagination" :multiple="multiple"
  80. :call-out-js-url="infoWindowDto.callOutJsUrl" @data-selected="$emit('dataSelected', $event)"
  81. @info-selected="infoSelected" @delete-selected="$emit('deleteSelected', $event)"
  82. />
  83. </div>
  84. <div class="flex-footer" style="margin-top: 10px">
  85. <div class="pull-left">
  86. <!-- <span>{{ $t("lang.QueryPage.the") }}
  87. {{ (pagination.current_page - 1) * pagination.per_page + 1 }}
  88. -
  89. {{ pagination.current_page * pagination.per_page }}
  90. {{ $t("lang.QueryPage.strip") }}
  91. ,
  92. {{ $t("lang.QueryPage.total") }}
  93. {{ pagination.total }}
  94. {{ $t("lang.QueryPage.strip") }}
  95. ,
  96. {{ $t("lang.QueryPage.displayOnEachPage") }}
  97. </span>
  98. <PageSizeSelect :size="pagination.per_page" @page-size-changed="gridSizeSelect" />
  99. <span>{{ $t("lang.QueryPage.strip") }}</span> -->
  100. </div>
  101. <div class="pull-right">
  102. <!-- <Pagination :pagination="pagination" :callback="pageSearch" /> -->
  103. </div>
  104. </div>
  105. <Loading v-if="loading" />
  106. <a-modal v-model:open="modal" :title="$t('lang.QueryPage.resultsOfEnforcement')" @ok="modal = false">
  107. <ProcessReportResult :process-report-result="processReportResult" :pdf-only="pdfOnly" :excel-only="excelOnly" />
  108. </a-modal>
  109. </div>
  110. <!-- <component :is="modal1Component" v-model:open="modal1Open" :model-data="selectInfoData" @refresh-data="pageSearch" /> -->
  111. </template>
  112. <script>
  113. import Common from '../../common/Common.js';
  114. import { defineAsyncComponent, reactive, createVNode } from 'vue';
  115. import PageSizeSelect from '../../page-size-select/src/PageSizeSelect.vue';
  116. // import Pagination from '../../vue-bootstrap-pagination/src/vue-bootstrap-pagination.vue';
  117. import QueryCondition from './QueryCondition.vue';
  118. import InfoHeader from './InfoHeader.vue';
  119. import InfoUtil from './InfoUtil.js';
  120. import Notify from '../../common/Notify.js';
  121. import Loading from '../../loading/src/Loading.vue';
  122. import ProcessReportResult from '../../process/src/ProcessReportResult.vue';
  123. import Uuid from '../../common/Uuid.js';
  124. import DownloadService from '../../common/DownloadService.js';
  125. import HtmlWindowResource from '../../html-window/src/api/HtmlWindowResource.js';
  126. import CustomerWindowResource from '../../customer-window/src/api/CustomerWindowResource.js';
  127. import ProcessReportResource from '../../process/src/api/ProcessReportResource.js';
  128. import UserStorageResource from '../../common/UserStorageResource.js';
  129. import Language from '../../common/Language.js';
  130. import dayjs from 'dayjs';
  131. import QueryPageTable from './QueryPageTable.vue';
  132. import QueryPageDashboard from './QueryPageDashboard.vue';
  133. import { Modal } from 'ant-design-vue';
  134. import QueryPageButton from './QueryPageButton.vue';
  135. import {
  136. useSort,
  137. useInfoGridFields,
  138. useInfoWindowData,
  139. useSearchCondition,
  140. } from './InfoWindowState.js';
  141. import {
  142. SyncOutlined,
  143. DownloadOutlined,
  144. TableOutlined,
  145. ExclamationCircleOutlined,
  146. } from '@ant-design/icons-vue';
  147. import CssUtil from '../../common/CssUtil.js';
  148. import { Spin as ASpin, Empty as AEmpty, message } from 'ant-design-vue';
  149. export default {
  150. name: 'QueryPage',
  151. components: {
  152. // Pagination,
  153. QueryCondition,
  154. Modal,
  155. InfoHeader,
  156. Loading,
  157. ProcessReportResult,
  158. PageSizeSelect,
  159. QueryPageTable,
  160. QueryPageDashboard,
  161. SyncOutlined,
  162. DownloadOutlined,
  163. QueryPageButton,
  164. ExclamationCircleOutlined,
  165. },
  166. props: {
  167. whereClauseSource: {
  168. type: Object,
  169. default() {
  170. return null;
  171. },
  172. },
  173. isSearchWidget: {
  174. type: Boolean,
  175. default: false,
  176. },
  177. parentModelData: {
  178. type: Object,
  179. default() {
  180. return null;
  181. },
  182. },
  183. modelData: {
  184. type: Object,
  185. default() {
  186. return null;
  187. },
  188. },
  189. fieldValue: {
  190. type: Object,
  191. default() {
  192. return null;
  193. },
  194. },
  195. /**
  196. * 查询窗口编号
  197. */
  198. windowNo: {
  199. type: String,
  200. default: null,
  201. },
  202. // icon前缀地址
  203. iconSrc: {
  204. type: String,
  205. default: '',
  206. },
  207. /**
  208. * 是否多选
  209. */
  210. multiple: {
  211. type: Boolean,
  212. default: false,
  213. },
  214. },
  215. emits: ['dataSelected', 'deleteSelected'],
  216. data: function () {
  217. this.Language = Language;
  218. return {
  219. infoWindowDto: {},
  220. queryResult: {},
  221. pagination: {
  222. total: 0,
  223. per_page: Common.pageSize, // required
  224. current_page: 1, // required
  225. last_page: 10, // required
  226. },
  227. infoQueryParam: [],
  228. processReportResult: [],
  229. uuid: Uuid.createUUID(),
  230. currentIsSimpleSearch: true,
  231. startX: '',
  232. startWidth: '',
  233. processReportDto: '',
  234. pdfOnly: '',
  235. excelOnly: '',
  236. infoFilterFields: [],
  237. loading: false,
  238. modal: false,
  239. searchType: 'simple',
  240. sortInstance: useSort(),
  241. infoButtons: [],
  242. modal1Component: null,
  243. modal1Open: false,
  244. selectInfoData: null,
  245. searchConditionInstance: useSearchCondition(),
  246. infoGridFieldsInstance: useInfoGridFields(),
  247. infoWindowDataInstance: useInfoWindowData(),
  248. views: [
  249. {
  250. value: 'QueryPageTable',
  251. payload: {
  252. name: '表格视图',
  253. icon: TableOutlined,
  254. style: {
  255. backgroundColor: '#ffffff',
  256. },
  257. },
  258. },
  259. ],
  260. selectedView: 'QueryPageTable', // 选中的视图
  261. componentLoadedCount: 1,
  262. pageSizeOptions: ['20', '50', '100', '200', '1000'],
  263. };
  264. },
  265. watch: {
  266. 'sortInstance.sortSetting': {
  267. handler(newValue, oldValue) {
  268. this.infoQueryParam.sortClause = this.sortInstance.getSortString();
  269. if (this.currentIsSimpleSearch) {
  270. this.queryInfoWindowDataSimple();
  271. } else {
  272. this.queryInfoWindowDataComplex();
  273. }
  274. },
  275. deep: true,
  276. },
  277. selectedView: function (newValue, oldValue) {
  278. console.log(newValue);
  279. console.log(oldValue);
  280. },
  281. },
  282. created: function () {
  283. const infoPageSize = localStorage.getItem(
  284. `InfoWindowPageSize${this.windowNo}`,
  285. );
  286. if (infoPageSize) {
  287. this.pagination.per_page = infoPageSize;
  288. }
  289. },
  290. mounted: function () { },
  291. methods: {
  292. /**
  293. * 页面显示数量改变
  294. * @param newPageSize
  295. */
  296. gridSizeSelect: function (newPageSize) {
  297. this.pagination.current_page = 1;
  298. this.pagination.per_page = newPageSize;
  299. localStorage.setItem(`InfoWindowPageSize${this.windowNo}`, newPageSize);
  300. },
  301. // 初始化数据
  302. initWidget: function (data) {
  303. var _self = this;
  304. if (data == undefined) {
  305. return;
  306. }
  307. _self.infoWindowDto = data;
  308. _self.infoFilterFields = data.infoFilterFields;
  309. _self.infoGridFieldsInstance.init(
  310. _self.infoWindowDto.no,
  311. data.infoGridFields,
  312. );
  313. _self.infoFilterFields.forEach(function (item) {
  314. item.value = {
  315. infoFilterFieldId: item.id,
  316. value1: '',
  317. value2: '',
  318. };
  319. });
  320. InfoUtil.restoreInfoFilterFields(
  321. _self.infoWindowDto.no,
  322. _self.infoFilterFields,
  323. );
  324. _self.simpleSearch();
  325. _self.dynamicInitViews();
  326. },
  327. /**
  328. * 高级查询
  329. * @param value
  330. */
  331. complexSearch: function (value) {
  332. var _self = this;
  333. _self.searchType = value;
  334. _self.pagination.current_page = 1;
  335. var infoQueryParam = {
  336. infoWindowNo: _self.infoWindowDto.no,
  337. start: (_self.pagination.current_page - 1) * _self.pagination.per_page,
  338. length: _self.pagination.per_page,
  339. sortClause: '',
  340. infoFilterFieldValues: _self.$refs.queryCondition.getQueryCondition(),
  341. whereClauseSource: _self.whereClauseSource,
  342. parentModelData: _self.parentModelData,
  343. modelData: _self.modelData,
  344. isSearchWidget: _self.isSearchWidget,
  345. };
  346. _self.infoQueryParam = infoQueryParam;
  347. _self.currentIsSimpleSearch = false;
  348. _self.queryInfoWindowDataComplex();
  349. },
  350. /**
  351. * 分页查询
  352. */
  353. pageSearch: function () {
  354. var _self = this;
  355. _self.infoQueryParam.start =
  356. (_self.pagination.current_page - 1) * _self.pagination.per_page;
  357. _self.infoQueryParam.length = _self.pagination.per_page;
  358. _self.infoQueryParam.infoFilterFieldValues =
  359. _self.$refs.queryCondition.getQueryCondition();
  360. if (_self.searchType === 'complex') {
  361. _self.queryInfoWindowDataComplex();
  362. } else {
  363. _self.queryInfoWindowDataSimple();
  364. }
  365. },
  366. /**
  367. * 简单查询
  368. * @return {void}
  369. */
  370. simpleSearch: function (value) {
  371. var _self = this;
  372. _self.searchType = value;
  373. _self.pagination.current_page = 1;
  374. var infoQueryParam = {
  375. infoWindowNo: _self.infoWindowDto.no,
  376. start: (_self.pagination.current_page - 1) * _self.pagination.per_page,
  377. length: _self.pagination.per_page,
  378. sortClause: '',
  379. infoFilterFieldValues: _self.$refs.queryCondition.getQueryCondition(),
  380. whereClauseSource: _self.whereClauseSource,
  381. parentModelData: _self.parentModelData,
  382. modelData: _self.modelData,
  383. isSearchWidget: _self.isSearchWidget,
  384. };
  385. _self.infoQueryParam = infoQueryParam;
  386. _self.currentIsSimpleSearch = true;
  387. _self.queryInfoWindowDataSimple();
  388. },
  389. /**
  390. * 调用后端高级查询的接口
  391. */
  392. queryInfoWindowDataComplex: function () {
  393. var _self = this;
  394. _self.loading = true;
  395. $.ajax({
  396. url: Common.getApiURL('InfoWindowResource/queryInfoWindowDataComplex'),
  397. type: 'post',
  398. dataType: 'json',
  399. beforeSend: function (request) {
  400. Common.addTokenToRequest(request);
  401. },
  402. contentType: 'application/json',
  403. data: JSON.stringify(_self.infoQueryParam),
  404. success: function (data) {
  405. _self.loading = false;
  406. _self.setSelectedFlag(data);
  407. _self.infoWindowDataInstance.init(data.dataList);
  408. _self.pagination.total = data.totalSize;
  409. _self.pagination.last_page = Math.ceil(
  410. data.totalSize / data.range.length,
  411. );
  412. },
  413. error: function (XMLHttpRequest, textStatus, errorThrown) {
  414. _self.loading = false;
  415. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  416. },
  417. });
  418. },
  419. /**
  420. * 设置数据是否被已经被选中。
  421. */
  422. setSelectedFlag: function (data) {
  423. let _self = this;
  424. let selectedIds = null;
  425. let selectedId = null;
  426. if (_self.fieldValue != null) {
  427. selectedIds = _self.fieldValue.ids;
  428. selectedId = _self.fieldValue.id;
  429. }
  430. data.dataList.forEach(function (item) {
  431. if (selectedIds != null && selectedIds.indexOf(item.id) >= 0) {
  432. item.select = true;
  433. } else if (selectedId != null && selectedId == item.id) {
  434. item.select = true;
  435. } else {
  436. item.select = false;
  437. }
  438. });
  439. },
  440. /**
  441. * 调用后端简单查询接口
  442. */
  443. queryInfoWindowDataSimple: function () {
  444. var _self = this;
  445. _self.loading = true;
  446. _self.infoQueryParam.whereClauseSource = _self.whereClauseSource;
  447. $.ajax({
  448. url: Common.getApiURL('InfoWindowResource/queryInfoWindowDataSimple'),
  449. type: 'post',
  450. dataType: 'json',
  451. beforeSend: function (request) {
  452. Common.addTokenToRequest(request);
  453. },
  454. contentType: 'application/json',
  455. data: JSON.stringify(_self.infoQueryParam),
  456. success: function (data) {
  457. _self.loading = false;
  458. _self.setSelectedFlag(data);
  459. _self.infoWindowDataInstance.init(data.dataList);
  460. _self.pagination.total = data.totalSize;
  461. _self.pagination.last_page = Math.ceil(
  462. data.totalSize / data.range.length,
  463. );
  464. },
  465. error: function (XMLHttpRequest, textStatus, errorThrown) {
  466. _self.loading = false;
  467. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  468. },
  469. });
  470. },
  471. /**
  472. * 获取选择的数据
  473. */
  474. getSelectedModelDatas: function () {
  475. return this.infoWindowDataInstance.getSelected();
  476. },
  477. /**
  478. * 条件字段属性发生改变
  479. */
  480. filterFieldPropertyChanged: function (infoFilterFieldsClone) {
  481. let _self = this;
  482. InfoUtil.saveInfoFilterFields(
  483. _self.infoWindowDto.no,
  484. infoFilterFieldsClone,
  485. ).then(
  486. successData => {
  487. InfoUtil.restoreInfoFilterFields(
  488. _self.infoWindowDto.no,
  489. _self.infoFilterFields,
  490. );
  491. },
  492. errorData => {
  493. console.log(errorData);
  494. },
  495. );
  496. },
  497. /**
  498. * 表格字段属性发生改变
  499. */
  500. gridFieldPropertyChanged: function (infoGridFieldsClone) {
  501. let _self = this;
  502. _self.infoGridFieldsInstance.saveInfoGridFields(
  503. _self.infoWindowDto.no,
  504. infoGridFieldsClone,
  505. );
  506. },
  507. /**
  508. * 执行流程
  509. * @param {Object} infoButton
  510. * @return {void}
  511. */
  512. executeProcess: function (infoButton) {
  513. var _self = this;
  514. if (infoButton == null) {
  515. return;
  516. }
  517. let tempSelectedModelDatas = _self.getSelectedModelDatas();
  518. if (
  519. infoButton.htmlWindowNo != null &&
  520. infoButton.htmlWindowNo.length > 0
  521. ) {
  522. HtmlWindowResource.uniqueByNo(infoButton.htmlWindowNo).then(
  523. htmlWindowDto => {
  524. if (htmlWindowDto != undefined) {
  525. var htmlWindowUrl = htmlWindowDto.htmlFileName;
  526. var autoCloseInterval = htmlWindowDto.autoCloseInterval;
  527. var regExp = new RegExp('[{].*?[}]', 'g');
  528. var result = htmlWindowUrl.match(regExp);
  529. if (htmlWindowUrl != undefined && htmlWindowUrl != '') {
  530. for (var index = 0, len = result.length; index < len; index++) {
  531. var tempResult = result[index];
  532. console.log('{' + tempResult + '}匹配');
  533. if (tempResult == '{URL}') {
  534. htmlWindowUrl = htmlWindowUrl.replace(
  535. '{URL}',
  536. Common.getRedirectUrl(''),
  537. );
  538. console.log('{' + htmlWindowUrl + '}地址');
  539. } else if (tempResult == '{RecordId}') {
  540. if (tempSelectedModelDatas.length == 0) {
  541. Notify.error('错误', '未选择可操作的数据', true);
  542. return;
  543. }
  544. htmlWindowUrl = htmlWindowUrl.replace(
  545. '{RecordId}',
  546. _self.getFirstSelectRecordId(),
  547. );
  548. } else if (tempResult == '{RecordIds}') {
  549. if (tempSelectedModelDatas.length == 0) {
  550. Notify.error('错误', '未选择可操作的数据', true);
  551. return;
  552. }
  553. htmlWindowUrl = htmlWindowUrl.replace(
  554. '{RecordIds}',
  555. _self.getSelectedRecordIds(),
  556. );
  557. } else if (tempResult == '{Token}') {
  558. htmlWindowUrl = htmlWindowUrl.replace(
  559. '{Token}',
  560. Common.getToken(),
  561. );
  562. } else if (tempResult == '{infoWindowNo}') {
  563. htmlWindowUrl = htmlWindowUrl.replace(
  564. '{infoWindowNo}',
  565. _self.infoWindowDto.no,
  566. );
  567. } else {
  568. if (tempSelectedModelDatas.length == 0) {
  569. Notify.error('错误', '未选择可操作的数据', true);
  570. return;
  571. } else if (tempSelectedModelDatas.length > 1) {
  572. Notify.error('错误', '请选择一条数据', true);
  573. return;
  574. }
  575. var tempResult1 = tempResult
  576. .replace('{', '')
  577. .replace('}', '');
  578. htmlWindowUrl = htmlWindowUrl.replace(
  579. tempResult,
  580. _self.getFirstSelectModelDataFieldValue(tempResult1),
  581. );
  582. }
  583. }
  584. var openWindow = window.open(htmlWindowUrl);
  585. // 自动关闭
  586. if (autoCloseInterval != undefined) {
  587. setTimeout(function () {
  588. openWindow.close();
  589. openWindow = undefined;
  590. }, autoCloseInterval * 1000);
  591. }
  592. }
  593. }
  594. },
  595. errorData => {
  596. Common.processException(errorData);
  597. },
  598. );
  599. } else if (
  600. infoButton.customerWindowNo != null &&
  601. infoButton.customerWindowNo.length > 0
  602. ) {
  603. CustomerWindowResource.uniqueByNo(infoButton.customerWindowNo).then(
  604. customerWindowDto => {
  605. var customerWindowRouteUrl = customerWindowDto.routeUrl;
  606. if (
  607. customerWindowRouteUrl != undefined &&
  608. customerWindowRouteUrl != ''
  609. ) {
  610. if (customerWindowRouteUrl == 'exportInfoData') {
  611. var downloadUrl =
  612. Common.getApiURL('exportResource/exportInfoDataComplex') +
  613. '?infoWindowNo=' +
  614. _self.infoWindowDto.no +
  615. '&recordIds=' +
  616. _self.getSelectedRecordIds().join(',') +
  617. '&token=' +
  618. Common.getToken();
  619. window.open(downloadUrl);
  620. } else {
  621. if (tempSelectedModelDatas.length > 0) {
  622. let userStorageDtos = [
  623. {
  624. key: _self.uuid,
  625. value: JSON.stringify(tempSelectedModelDatas),
  626. },
  627. ];
  628. // 组装查询条件,然后放到后台数据库当中
  629. UserStorageResource.uploadUserStorage(userStorageDtos).then(
  630. successData => {
  631. _self.$router.push({
  632. path: customerWindowRouteUrl,
  633. query: {
  634. uuid: _self.uuid,
  635. },
  636. });
  637. },
  638. errorData => {
  639. Common.processException(errorData);
  640. },
  641. );
  642. } else {
  643. _self.$router.push({
  644. path: customerWindowRouteUrl,
  645. query: {
  646. uuid: _self.uuid,
  647. },
  648. });
  649. }
  650. }
  651. }
  652. },
  653. errorData => {
  654. Common.processException(errorData);
  655. },
  656. );
  657. } else if (
  658. infoButton.processReportNo != null &&
  659. infoButton.processReportNo.length > 0
  660. ) {
  661. var processReportNo = infoButton.processReportNo;
  662. if (processReportNo != undefined && processReportNo != '') {
  663. const tipsTitle = infoButton.tipsTitle;
  664. const tipsContent = infoButton.tipsContent;
  665. const notNeedSelectData = infoButton.notNeedSelectData;
  666. var ids = _self.getSelectedRecordIds();
  667. if (notNeedSelectData !== true && ids.length < 1) {
  668. Notify.error('错误', '未选择可操作的数据', true);
  669. return;
  670. }
  671. const executeProcess = function () {
  672. _self.loading = true;
  673. ProcessReportResource.uniqueByNo(infoButton.processReportNo).then(
  674. successData => {
  675. _self.processReportDto = successData;
  676. if (successData) {
  677. _self.pdfOnly = successData.pdfOnly;
  678. _self.excelOnly = successData.excelOnly;
  679. }
  680. ProcessReportResource.runProcessByIds(
  681. infoButton.processReportNo,
  682. ids,
  683. ).then(
  684. successData => {
  685. _self.modal = true;
  686. _self.loading = false;
  687. _self.processReportResult = successData;
  688. _self.$emit('processExecuteFinish');
  689. // 流程执行完毕,调用刷新的按钮
  690. _self.pageSearch();
  691. },
  692. errorData => {
  693. _self.loading = false;
  694. Common.processException(errorData);
  695. },
  696. );
  697. },
  698. errorData => {
  699. _self.loading = false;
  700. Common.processException(errorData);
  701. },
  702. );
  703. };
  704. if (tipsTitle != null && tipsTitle.length > 0 && tipsContent != null && tipsContent.length > 0) {
  705. Modal.confirm({
  706. title: tipsTitle,
  707. icon: createVNode(ExclamationCircleOutlined),
  708. content: tipsContent,
  709. okText: '确认',
  710. cancelText: '取消',
  711. onOk() {
  712. executeProcess();
  713. },
  714. onCancel() {
  715. console.log('Cancel');
  716. },
  717. });
  718. } else {
  719. executeProcess();
  720. }
  721. }
  722. } else if (
  723. infoButton.curdWindowNo != null &&
  724. infoButton.curdWindowNo.length > 0
  725. ) {
  726. _self.$router.push(
  727. '/desktop/window/' + infoButton.curdWindowNo + '?uuid=' + _self.uuid,
  728. );
  729. }
  730. },
  731. /**
  732. * 执行导出
  733. * @return {void}
  734. */
  735. executeExport: function () {
  736. var _self = this;
  737. if (this.searchConditionInstance.state.isComplex == false) {
  738. let condition = _self.$refs.queryCondition.getQueryCondition();
  739. let downloadUrl =
  740. Common.getApiURL('exportResource/exportInfoDataSimple') +
  741. '?infoWindowNo=' +
  742. _self.infoWindowDto.no +
  743. '&recordIds=' +
  744. _self.getSelectedRecordIds().join(',') +
  745. '&infoFilterFieldValues=' +
  746. _self.uuid +
  747. '&condition=' +
  748. condition;
  749. let timeStr = dayjs().format('_YYYYMMDD_hhmmss');
  750. let fileName =
  751. _self.infoWindowDto == null
  752. ? '导出数据' + timeStr + '.xlsx'
  753. : _self.infoWindowDto.name + timeStr + '.xlsx';
  754. DownloadService.downloadFile(downloadUrl, fileName);
  755. } else {
  756. let infoFilterFieldValues =
  757. _self.$refs.queryCondition.getQueryCondition();
  758. let infoFilterFieldValueStrs = JSON.stringify(infoFilterFieldValues);
  759. let downloadUrl =
  760. Common.getApiURL('exportResource/exportInfoDataComplex') +
  761. '?infoWindowNo=' +
  762. _self.infoWindowDto.no +
  763. '&recordIds=' +
  764. _self.getSelectedRecordIds().join(',') +
  765. '&infoFilterFieldValues=' +
  766. _self.uuid;
  767. let timeStr = dayjs().format('_YYYYMMDD_hhmmss');
  768. let fileName =
  769. _self.infoWindowDto == null
  770. ? '导出数据' + timeStr + '.xlsx'
  771. : _self.infoWindowDto.name + timeStr + '.xlsx';
  772. let userStorageDtos = [
  773. {
  774. key: _self.uuid,
  775. value: infoFilterFieldValueStrs,
  776. },
  777. ];
  778. // 组装查询条件,然后放到后台数据库当中
  779. UserStorageResource.uploadUserStorage(userStorageDtos).then(
  780. successData => {
  781. DownloadService.downloadFile(downloadUrl, fileName);
  782. },
  783. errorData => {
  784. Common.processException(errorData);
  785. },
  786. );
  787. }
  788. },
  789. /**
  790. * 获取选择数据的Id集合
  791. */
  792. getSelectedRecordIds: function () {
  793. return this.infoWindowDataInstance.getSelectedRecordIds();
  794. },
  795. /**
  796. * 获取选中的第一个数据的Id
  797. */
  798. getFirstSelectRecordId: function () {
  799. var _self = this;
  800. let recordIds = _self.getSelectedRecordIds();
  801. if (recordIds.length > 0) {
  802. return recordIds[0];
  803. }
  804. return undefined;
  805. },
  806. /**
  807. * 获取选中的第一个数据的FieldValue
  808. */
  809. getFirstSelectModelDataFieldValue: function (name) {
  810. const firstData = this.infoWindowDataInstance.getFirstSelected();
  811. if (firstData == null) {
  812. return null;
  813. } else {
  814. if (firstData.data[name] != null) {
  815. return firstData.data[name].displayValue[0];
  816. }
  817. }
  818. return null;
  819. },
  820. dynamicInitViews: function () {
  821. let _self = this;
  822. let infoWindowDashbaords = _self.infoWindowDto.infoWindowDashbaords;
  823. if (infoWindowDashbaords != null && infoWindowDashbaords.length > 0) {
  824. for (let i = 0, length = infoWindowDashbaords.length; i < length; i++) {
  825. let infoWindowDashbaord = infoWindowDashbaords[i];
  826. console.log(infoWindowDashbaord);
  827. _self.dynamicInitView(infoWindowDashbaord);
  828. }
  829. }
  830. },
  831. /**
  832. * 初始化Dashbaord界面
  833. */
  834. dynamicInitView: function (infoWindowDashbaord) {
  835. // TODO: 添加测试文件
  836. //infoWindowDashbaord.cssUrl = '/content/DictionaryAsset/InfoWindow/EAM/20240922_095937_AssetDashboard.css';
  837. //infoWindowDashbaord.jsUrl = '/content/DictionaryAsset/InfoWindow/EAM/20240922_095937_AssetDashboard.js';
  838. let _self = this;
  839. const componentName = infoWindowDashbaord.componentName;
  840. // 如果是默认视图的话,进行加载
  841. if (infoWindowDashbaord.isDefault === true) {
  842. _self.selectedView = infoWindowDashbaord.componentName;
  843. }
  844. _self.views.push({
  845. value: componentName,
  846. payload: {
  847. name: infoWindowDashbaord.name,
  848. src: _self.iconSrc + infoWindowDashbaord.icon,
  849. style: {
  850. backgroundColor: '#f56a00',
  851. },
  852. },
  853. });
  854. const cssUrl = infoWindowDashbaord.cssUrl;
  855. if (cssUrl != null && cssUrl != undefined) {
  856. CssUtil.dynamicLoadCss(cssUrl, componentName);
  857. }
  858. const jsUrl = infoWindowDashbaord.jsUrl;
  859. if (jsUrl != null && jsUrl != undefined) {
  860. let promise = new Promise((resolve, reject) => {
  861. import(/* webpackIgnore: true */ jsUrl)
  862. .then(remoteComponent => {
  863. resolve(remoteComponent);
  864. })
  865. .catch(error => {
  866. reject(error);
  867. });
  868. });
  869. promise.then(
  870. remoteComponent => {
  871. console.log('remoteComponent:' + remoteComponent.default.name);
  872. if (componentName !== remoteComponent.default.name) {
  873. let errorMessage =
  874. '数据字典-查询窗口自定义组件部件名称定义的是' +
  875. componentName +
  876. ',但是程序中name定义的是' +
  877. remoteComponent.default.name +
  878. ',两者必须相同。';
  879. console.error(errorMessage);
  880. Notify.error('查询窗口自定义组件定义错误', errorMessage, false);
  881. }
  882. window.app.component(componentName, remoteComponent.default);
  883. _self.componentLoadedCount++;
  884. },
  885. errorData => {
  886. console.error(errorData);
  887. },
  888. );
  889. }
  890. },
  891. /**
  892. * 页数改变
  893. * @param page
  894. */
  895. handlePageChange: function (page) {
  896. this.pagination.current_page = page;
  897. setTimeout(() => {
  898. this.pageSearch();
  899. }, 100);
  900. },
  901. /**
  902. * 每页条数改变
  903. * @param current
  904. * @param size
  905. */
  906. handleShowSizeChange: function (current, size) {
  907. setTimeout(() => {
  908. this.pagination.current_page = 1;
  909. });
  910. this.pagination.per_page = size;
  911. localStorage.setItem(`InfoWindowPageSize${this.windowNo}`, size);
  912. },
  913. // 获取表格选择的数据
  914. infoSelected: function (selected) {
  915. this.selectInfoData = selected;
  916. },
  917. },
  918. };
  919. </script>
  920. <style scoped>
  921. .sort-button {
  922. float: left;
  923. }
  924. .btn-process {
  925. float: right;
  926. margin-left: 15px;
  927. }
  928. .mulitiple-select {
  929. background-color: #6699cc !important;
  930. }
  931. .flex-container {
  932. display: flex;
  933. /* 垂直*/
  934. flex-direction: column;
  935. width: 100%;
  936. /*视口被均分为100单位的vh 占据整个窗口*/
  937. height: calc(100vh - 75px);
  938. }
  939. .flex-container-modal {
  940. display: flex;
  941. /* 垂直*/
  942. flex-direction: column;
  943. width: 100%;
  944. /*视口被均分为100单位的vh 占据整个窗口*/
  945. height: calc(100vh - 215px);
  946. }
  947. .flex-header {
  948. /*放大缩小比例为0 占据垂直方向80px*/
  949. height: 400px;
  950. flex: 0 0 100px;
  951. }
  952. .flex-footer {
  953. height: 40px;
  954. flex: 0 0 40px;
  955. }
  956. .flex-content {
  957. display: flex;
  958. flex: 1;
  959. height: 0;
  960. }
  961. </style>
  962. <style scoped>
  963. /** 修复分页的样式 By YangZhiJie 2021-07-06 11:23 */
  964. nav>>>ul.pagination {
  965. margin: 0 !important;
  966. }
  967. </style>
  968. <style scoped>
  969. .warning {
  970. background-color: #fcf8e3 !important;
  971. }
  972. .text-center {
  973. text-align: center !important;
  974. }
  975. .m-segmented {
  976. float: right;
  977. margin-top: 4px;
  978. }
  979. .m-segmented>>>.ant-segmented-item {
  980. margin-bottom: 0px;
  981. }
  982. </style>