CellTextItem.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <div class="table-cell-text">
  3. <div v-if="!fieldUtil.isManyToManySetType(gridFieldItem)
  4. && !fieldUtil.isImageType(gridFieldItem)
  5. && !fieldUtil.isImageListType(gridFieldItem)
  6. && !fieldUtil.isVideoType(gridFieldItem)
  7. && !fieldUtil.isFileType(gridFieldItem)
  8. && !fieldUtil.isEnumMultiType(gridFieldItem)
  9. && !fieldUtil.isEnumListType(gridFieldItem)
  10. && !fieldUtil.isTextAreaType(gridFieldItem)
  11. && !fieldUtil.isRichTextAreaEditor(gridFieldItem)
  12. && !fieldUtil.isCustomerRender(gridFieldItem)">
  13. {{ displayValue(modelData) }}
  14. </div>
  15. <p v-else-if="fieldUtil.isRichTextAreaEditor(gridFieldItem)">
  16. {{ displayValue(modelData) }}
  17. </p>
  18. <div v-else-if="fieldUtil.isTextAreaType(gridFieldItem)" class="table-cell-text-line">
  19. {{ displayValue(modelData) }}
  20. </div>
  21. <div v-else-if="fieldUtil.isEnumListType(gridFieldItem)">
  22. {{ getEnmuValue() === "编辑中" ? $t("lang.TabFormFieldView.editing") :
  23. getEnmuValue() === "审批中" ? $t("lang.TabFormFieldView.pendingApproval") :
  24. getEnmuValue() === "审批通过" ? $t("lang.TabFormFieldView.approved") :
  25. getEnmuValue() === "审批不通过" ? $t("lang.TabFormFieldView.rejected") :
  26. getEnmuValue() === "单据已撤回" ? $t("lang.TabFormFieldView.withdraw") :
  27. getEnmuValue() === "转移" ? $t("lang.TabFormFieldView.transfer") :
  28. getEnmuValue() === "报废" ? $t("lang.TabFormFieldView.disposal") :
  29. getEnmuValue() === "全盘" ? $t("lang.TabFormFieldView.overall") :
  30. getEnmuValue() === "抽盘" ? $t("lang.TabFormFieldView.randomInventory") : getEnmuValue()
  31. }}
  32. </div>
  33. <div v-else-if="fieldUtil.isEnumMultiType(gridFieldItem)">
  34. {{ getMultiEnmuValue() }}
  35. </div>
  36. <div v-else-if="fieldUtil.isManyToManySetType(gridFieldItem)">
  37. <span v-for="item, index in getManyToManyValues()" :key="index" class="selected-tag">
  38. {{ item }}
  39. </span>
  40. </div>
  41. <AuthImage v-else-if="fieldUtil.isImageType(gridFieldItem)" :auth-src="imageUrl" class="cell-image" />
  42. <span v-else-if="fieldUtil.isImageListType(gridFieldItem)">
  43. <AuthImage v-for="singleImageName in imageUrls" :key="singleImageName" :auth-src="singleImageName"
  44. class="cell-image-list" />
  45. </span>
  46. <VideoListCell v-else-if="fieldUtil.isVideoType(gridFieldItem)" :field="gridFieldItem" :field-value="fieldValue"
  47. :class-name="className" :readonly="true" />
  48. <ButtonCell v-else-if="fieldUtil.isButtonType(gridFieldItem)" :field="gridFieldItem" :field-value="fieldValue"
  49. :readonly="readOnly" @execute-callout="executeCallout" />
  50. <div v-else-if="fieldUtil.isFileType(gridFieldItem)" style="padding: 0px 10px">
  51. <FileListWidget :field="gridFieldItem" :field-value="fieldValue" :class-name="className" :readonly="true" />
  52. </div>
  53. <component :is="customerComponentName" v-else-if="fieldUtil.isCustomerRender(gridFieldItem)" :field="gridFieldItem"
  54. :field-value="fieldValue" :class-name="className" />
  55. <div v-if="fieldUtil.isGridButtonEditor(gridFieldItem)">
  56. <template v-for="(tabGridButtonItem, index) in gridFieldItem.tabGridButtonDtos" :key="tabGridButtonItem.name">
  57. <template v-if="visible[index]">
  58. <a-button
  59. v-if="tabGridButtonItem.action === 'CREATE' || tabGridButtonItem.action === 'SAVE' || tabGridButtonItem.action === 'RUN' || tabGridButtonItem.action === 'EXPORT' || tabGridButtonItem.action === 'NOTICE' || tabGridButtonItem.action === 'REFRESH'"
  60. type="link" @click="buttonClick">{{ tabGridButtonItem.name }}</a-button>
  61. <a-button v-if="tabGridButtonItem.action === 'DELETE'" type="link" danger @click="deleteRecord">{{
  62. tabGridButtonItem.name }}</a-button>
  63. <a-button v-if="tabGridButtonItem.action === 'EDIT'" type="link" @click="editRecord">{{ tabGridButtonItem.name
  64. }}</a-button>
  65. <a-button v-if="tabGridButtonItem.action === 'SEE'" type="link" @click="readRecord">{{ tabGridButtonItem.name
  66. }}</a-button>
  67. <a-button v-if="tabGridButtonItem.action === 'RUN_PROCESS_REPORT'" type="link"
  68. @click="execute(tabGridButtonItem)">{{ tabGridButtonItem.name }}</a-button>
  69. <a-button v-if="tabGridButtonItem.action === 'OPEN_CUSTOMER_WINDOW'" type="link"
  70. @click="execute(tabGridButtonItem)">{{ tabGridButtonItem.name }}</a-button>
  71. <a-button v-if="tabGridButtonItem.action === 'OPEN_HTML_WINDOW'" type="link"
  72. @click="execute(tabGridButtonItem)">{{ tabGridButtonItem.name }}</a-button>
  73. <a-button v-if="tabGridButtonItem.action === 'OPEN_REMOTE_COMPONENT_MODULE_IN_MODAL'" type="link"
  74. @click="openRemoteComponentModule(tabGridButtonItem)">{{ tabGridButtonItem.name }}</a-button>
  75. </template>
  76. </template>
  77. </div>
  78. </div>
  79. <Modal v-model:show="modal" :full="true">
  80. <ProcessReportResultPreview v-if="
  81. processReportResult != null &&
  82. (processReportResult.reportResults != null ||
  83. processReportResult.processResult != null)
  84. " :process-report-result="processReportResult" :pdf-only="false" :excel-only="false" />
  85. <template #header>
  86. {{ $t("lang.tabButton.executeResult") }}
  87. </template>
  88. </Modal>
  89. <Modal v-model:show="titleModal" :show-canel-button="false" :show-ok-button="false">
  90. <template #header>
  91. {{ tabButtonModel.tipsTitle }}
  92. </template>
  93. {{ tabButtonModel.tipsContent }}
  94. <template #footer>
  95. <button type="button" class="btn btn-default" @click="titleModalClose">
  96. {{ $t("lang.tabButton.cancel") }}
  97. </button>
  98. <button type="primary" class="btn btn-default" @click="executeProcess">
  99. 确认
  100. </button>
  101. </template>
  102. </Modal>
  103. <component :is="modal1Component" v-model:open="modal1Open" :model-data="modelData" @refresh-data="refreshDatas" />
  104. </template>
  105. <script>
  106. import {
  107. ref,
  108. defineAsyncComponent,
  109. } from 'vue';
  110. import { Notify, Uuid, CssUtil } from 'pc-component-v3';
  111. import { Spin as ASpin, Empty as AEmpty } from 'ant-design-vue';
  112. import FieldUtil from '../../resource/dictionary/FieldUtil.js';
  113. import Common from '../../common/Common.js';
  114. import VideoListCell from '../tabGridWidget/VideoListCell.vue';
  115. import FileListWidget from '../tabFormWidget/FileListWidget.vue';
  116. import ButtonCell from '../tabGridWidget/ButtonCell.vue';
  117. import AuthImage from '../../widget/AuthImage.vue';
  118. import { Spin as ASpin, Empty as AEmpty } from 'ant-design-vue';
  119. import { CssUtil } from 'pc-component-v3';
  120. import { defineAsyncComponent } from 'vue';
  121. import CustomerWindowResource from '../../api/dic/CustomerWindowResource.js';
  122. import HtmlWindowResource from '../../api/dic/HtmlWindowResource.js';
  123. import ProcessReportResource from '../../api/dic/ProcessReportResource.js';
  124. import JsUtil from '../../common/JsUtil.js';
  125. import Context from '../common/Context.js';
  126. export default {
  127. components: {
  128. VideoListCell, FileListWidget, ButtonCell, AuthImage,
  129. },
  130. props: {
  131. gridFieldItem: {
  132. type: Object,
  133. default: function () {
  134. return null;
  135. },
  136. },
  137. modelData: {
  138. type: Object,
  139. default: function () {
  140. return {};
  141. },
  142. },
  143. className: {
  144. type: String,
  145. default: null,
  146. },
  147. simpleFilterParams: {
  148. type: String,
  149. default: null,
  150. },
  151. complexFilterParams: {
  152. type: Array,
  153. default: () => {
  154. return [];
  155. },
  156. },
  157. modelDatas: {
  158. type: Array,
  159. default: () => {
  160. return [];
  161. },
  162. },
  163. jsUrl: {
  164. type: String,
  165. default: null,
  166. },
  167. },
  168. emits: ['executeCallout', 'deleteRecord', 'refreshDatas', 'editRecord', 'readRecord'],
  169. data: function () {
  170. this.Common = Common;
  171. return {
  172. fieldUtil: FieldUtil,
  173. customerComponentName: null,
  174. modal1Open: false,
  175. modal1Component: null,
  176. processReportResult: {},
  177. modal: false,
  178. titleModal: false,
  179. tabButtonModel: {},
  180. tabGridButtonDtos: [],
  181. visible: [],
  182. };
  183. },
  184. computed: {
  185. imageUrl: function () {
  186. var _self = this;
  187. var value = this.displayValue(this.modelData);
  188. if (value != undefined) {
  189. var tempImageUrl = _self.getImageUrl(value);
  190. return tempImageUrl;
  191. }
  192. return '';
  193. },
  194. imageUrls: function () {
  195. var _self = this;
  196. var value = this.displayValue(this.modelData);
  197. var images = [];
  198. if (value != undefined && value.length > 0) {
  199. var values = value.split(',');
  200. values.forEach(function (tempValue) {
  201. var tempImageUrl = _self.getImageUrl(tempValue);
  202. images.push(tempImageUrl);
  203. });
  204. }
  205. return images;
  206. },
  207. fieldValue: function () {
  208. var _self = this;
  209. var modelData = _self.modelData;
  210. var fieldValue = {};
  211. if (modelData.data[_self.gridFieldItem.fieldName] != undefined) {
  212. fieldValue = modelData.data[_self.gridFieldItem.fieldName];
  213. } else {
  214. fieldValue = {
  215. displayValue: [],
  216. fieldType: 'String',
  217. };
  218. }
  219. return fieldValue;
  220. },
  221. /**
  222. * 字段是否只读
  223. */
  224. readOnly: function () {
  225. if (this.gridFieldItem == undefined) {
  226. return true;
  227. }
  228. if (this.gridFieldItem != undefined && this.gridFieldItem.readOnly == true) {
  229. return true;
  230. }
  231. if (this.gridFieldItem != undefined && this.gridFieldItem.entityFieldIndex > 0) {
  232. return true;
  233. }
  234. if (this.modelData != undefined && this.modelData.id > 0 && (this.gridFieldItem.updatable == undefined || this.gridFieldItem.updatable == false)) {
  235. return true;
  236. }
  237. return this.gridFieldItem.readOnly;
  238. },
  239. },
  240. watch: {
  241. modelData: {
  242. deep: true,
  243. immediate: true,
  244. handler(curVal, oldVal) {
  245. console.log('cellTextItem监听');
  246. // this.cellTextItemTabGridButtonShowLogical();
  247. },
  248. },
  249. 'gridFieldItem.tabGridButtonDtos': {
  250. immediate: true,
  251. handler(curVal, oldVal) {
  252. const _self = this;
  253. this.visible.splice(0, this.visible.length);
  254. if (curVal != null) {
  255. curVal.forEach(item => {
  256. _self.visible.push(false);
  257. });
  258. }
  259. },
  260. },
  261. },
  262. mounted: function () {
  263. this.cellTextItemTabGridButtonShowLogical();
  264. },
  265. methods: {
  266. /**
  267. * 获取Context
  268. */
  269. getContext: Context,
  270. /**
  271. * 操作列设置显示逻辑
  272. */
  273. cellTextItemTabGridButtonShowLogical: function () {
  274. var _self = this;
  275. console.log('cellTextItemTabGridButtonShowLogical');
  276. if (_self.gridFieldItem.tabGridButtonDtos != null &&
  277. _self.gridFieldItem.tabGridButtonDtos != undefined && _self.gridFieldItem.tabGridButtonDtos.length > 0
  278. ) {
  279. for (let index = 0; index < _self.gridFieldItem.tabGridButtonDtos.length; index++) {
  280. const tabGridButtonItem = _self.gridFieldItem.tabGridButtonDtos[index];
  281. let oldTabGridButtonString = JSON.stringify(tabGridButtonItem);
  282. const showLogical = tabGridButtonItem.showLogical;
  283. if (showLogical != null && showLogical.length > 0) {
  284. let functionName = tabGridButtonItem.showLogical.replace('.', '_') + '_showLogical';
  285. let executeFunction = function () {
  286. let ctx = new _self.getContext(_self.modelData);
  287. try {
  288. _self.visible[index] = _self[functionName](ctx);
  289. } catch (e) {
  290. console.error('js代码 %s 执行异常 %o', showLogical, e);
  291. _self.visible[index] = true;
  292. }
  293. };
  294. if (_self[functionName] == null) {
  295. // 执行服务端的脚本
  296. const jsUrl = _self.jsUrl;
  297. if (jsUrl == null || jsUrl == undefined) {
  298. Notify.error('数据字典定义异常', '【' + tabGridButtonItem.name + '】列显示逻辑的JS文件不存在,请联系管理员检查数据字典是否JS文件。', false);
  299. return;
  300. }
  301. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, showLogical);
  302. promise.then(dynamicFunction => {
  303. let targetFunction = dynamicFunction;
  304. if (targetFunction == null) {
  305. Notify.error('数据字典定义异常', '【' + tabGridButtonItem.name + '】列显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  306. return;
  307. }
  308. _self[functionName] = targetFunction;
  309. executeFunction();
  310. }, errorData => {
  311. console.error(errorData);
  312. });
  313. } else {
  314. executeFunction();
  315. }
  316. } else {
  317. _self.visible[index] = true;
  318. }
  319. let newTabGridButtonString = JSON.stringify(tabGridButtonItem);
  320. // bug fixed by jack 2022-01-17
  321. // 只有当数据发生改变以后,才重新设置数据,解决当子表数据量很打的时候,输入卡顿的问题。
  322. if (oldTabGridButtonString != newTabGridButtonString) {
  323. _self.gridFieldItem.tabGridButtonDtos[index] = tabGridButtonItem;
  324. }
  325. }
  326. }
  327. },
  328. /**
  329. * 执行Callout
  330. */
  331. executeCallout: function (field) {
  332. this.$emit('executeCallout', field);
  333. },
  334. displayValue: function (modelData) {
  335. if (modelData == undefined) {
  336. return '';
  337. } else if (modelData.data == undefined) {
  338. return '';
  339. } else if (modelData.data[this.gridFieldItem.fieldName] == undefined) {
  340. return '';
  341. } else if (modelData.data[this.gridFieldItem.fieldName].displayValue == undefined) {
  342. return '';
  343. } else {
  344. var value = modelData.data[this.gridFieldItem.fieldName].displayValue[this.gridFieldItem.entityFieldIndex];
  345. if (FieldUtil.isCheckBoxType(this.gridFieldItem)) {
  346. if (value == 'true' || value == true) {
  347. return this.$t('lang.TabFormFieldView.yes');
  348. } else if (value == 'false' || value == false) {
  349. return this.$t('lang.TabFormFieldView.no');
  350. }
  351. } else if (FieldUtil.isRedGreenEditorType(this.gridFieldItem)) {
  352. if (value == 'true' || value == true) {
  353. return '红单';
  354. } else if (value == 'false' || value == false) {
  355. return '蓝单';
  356. }
  357. }
  358. return value;
  359. }
  360. },
  361. // 获取
  362. getImageUrl: function (name) {
  363. return Common.getThumbnailImageSrc(this.className, name);
  364. },
  365. /**
  366. * 获取枚举单选框的值
  367. */
  368. getEnmuValue: function () {
  369. var _self = this;
  370. var result;
  371. if (_self.fieldValue != undefined && _self.fieldValue.displayValue != undefined) {
  372. var value0 = _self.fieldValue.displayValue[0];
  373. if (_self.gridFieldItem != null && _self.gridFieldItem.keyValues != null) {
  374. _self.gridFieldItem.keyValues.forEach(function (item1) {
  375. if (value0 == item1.keyStr) {
  376. result = item1.value;
  377. }
  378. });
  379. }
  380. }
  381. return result;
  382. },
  383. /**
  384. * 获取枚举多选框的值
  385. */
  386. getMultiEnmuValue: function () {
  387. var _self = this;
  388. var fieldValue = (_self.modelData.data == undefined) ? [] : _self.modelData.data[_self.gridFieldItem.fieldName];
  389. var result = [];
  390. if (fieldValue != undefined && _self.fieldValue.displayValue != undefined) {
  391. var arr = fieldValue.displayValue[0].split(',');
  392. arr.forEach(function (item) {
  393. _self.gridFieldItem.keyValues.forEach(function (item1) {
  394. if (item == item1.keyStr) {
  395. result.push(item1.value + ' ');
  396. }
  397. });
  398. });
  399. }
  400. return result.join(',');
  401. },
  402. // 获取枚举多选框的值
  403. getManyToManyValues: function () {
  404. var modelData = this.modelData;
  405. if (modelData == undefined) {
  406. return [];
  407. } else if (modelData.data == undefined) {
  408. return [];
  409. } else if (modelData.data[this.gridFieldItem.fieldName] == undefined) {
  410. return [];
  411. } else if (modelData.data[this.gridFieldItem.fieldName].displayValue == undefined) {
  412. return [];
  413. } else {
  414. return modelData.data[this.gridFieldItem.fieldName].displayValue;
  415. }
  416. },
  417. buttonClick: function () {
  418. Notify.error('提示', '暂不支持该组件', false);
  419. },
  420. deleteRecord: function () {
  421. this.$emit('deleteRecord');
  422. },
  423. refreshDatas: function () {
  424. this.$emit('refreshDatas');
  425. },
  426. // 改变表格行元素的编辑状态
  427. editRecord: function () {
  428. this.$emit('editRecord');
  429. },
  430. readRecord: function () {
  431. this.$emit('readRecord');
  432. },
  433. /**
  434. * 远程加载ES VUE组件模块,并在模态框中打开。
  435. * @param jsUrl js路径
  436. * @param cssUrl css路径
  437. */
  438. openRemoteComponentModule: function (tabButton) {
  439. var _self = this;
  440. let jsUrl = tabButton.remoteComponentModuleJsUrl;
  441. let cssUrl = tabButton.remoteComponentModuleCssUrl;
  442. // 显示模态框
  443. // 异步的加载js组件
  444. //let jsUrl = './static/client-eam-module-v3/dist/AssetCheckCreate.js';
  445. //let cssUrl = './static/client-eam-module-v3/dist/AssetCheckCreate.css';
  446. if (cssUrl != null && cssUrl.length > 0) {
  447. let cssUrlHash = _self.getHash(cssUrl);
  448. CssUtil.dynamicLoadCss(cssUrl, cssUrlHash);
  449. }
  450. // webpackIgnore:设置为 true 时,禁用动态导入解析。
  451. // const testAsyncRemoteComponent = await import(/* webpackIgnore: true */ jsUrl);
  452. // console.log(testAsyncRemoteComponent);
  453. if (jsUrl != null && jsUrl.length > 0) {
  454. const testAsyncRemoteComponent = defineAsyncComponent({
  455. // 加载函数
  456. loader: () => {
  457. return import(/* webpackIgnore: true */ jsUrl);
  458. },
  459. // 加载异步组件时使用的组件
  460. loadingComponent: ASpin,
  461. // 展示加载组件前的延迟时间,默认为 200ms
  462. delay: 200,
  463. // 加载失败后展示的组件
  464. errorComponent: AEmpty,
  465. // 如果提供了一个 timeout 时间限制,并超时了
  466. // 也会显示这里配置的报错组件,默认值是:Infinity
  467. timeout: 10000,
  468. });
  469. _self.customerComponentName = testAsyncRemoteComponent;
  470. console.log(_self.customerComponentName);
  471. }
  472. },
  473. /**
  474. * 远程加载ES VUE组件模块。
  475. * @param jsUrl js路径
  476. * @param cssUrl css路径
  477. */
  478. renderRemoteComponentModule: async function () {
  479. const _self = this;
  480. let jsUrl = this.gridFieldItem.remoteComponentModuleJsUrl;
  481. let cssUrl = this.gridFieldItem.remoteComponentModuleCssUrl;
  482. _self.modal1Component = testAsyncRemoteComponent;
  483. _self.modal1Open = true;
  484. console.log(_self.modal1Component);
  485. }
  486. },
  487. //跳转或执行流程
  488. execute: function (tabButton) {
  489. var _self = this;
  490. _self.tabButtonModel = tabButton;
  491. if (tabButton.customerWindowNo != undefined && tabButton.customerWindowNo != '') {
  492. CustomerWindowResource.uniqueByNo(tabButton.customerWindowNo).then(
  493. successData => {
  494. tabButton.customerWindowRouteUrl = successData.routeUrl;
  495. if (tabButton.customerWindowNo == '20221101_151823') {
  496. localStorage.setItem('AssetInstance_ComplexFilterParams', JSON.stringify(_self.complexFilterParams));
  497. localStorage.setItem('AssetInstance_SimpleFilterParams', _self.simpleFilterParams);
  498. }
  499. //跳转到tabButton.routeUrl
  500. _self.switchFormRoute(tabButton);
  501. },
  502. errorData => {
  503. Common.processException(errorData);
  504. },
  505. );
  506. } else if (
  507. tabButton.processReportNo != undefined &&
  508. tabButton.processReportNo != ''
  509. ) {
  510. // 判断流程报表是否有参数
  511. // 如果有参数则直接跳转到流程和报表的界面。
  512. if (tabButton.routerRedirect == undefined || tabButton.routerRedirect == false) {
  513. if (tabButton.tipsTitle == undefined || tabButton.tipsTitle.length == 0) {
  514. _self.executeProcess();
  515. } else {
  516. _self.titleModal = true;
  517. }
  518. } else {
  519. this.$router.push({
  520. path: '/desktop/process-report/' + tabButton.processReportNo,
  521. });
  522. }
  523. } else if (tabButton.htmlWindowNo != undefined) {
  524. HtmlWindowResource.uniqueByNo(tabButton.htmlWindowNo).then(
  525. htmlWindowDto => {
  526. if (htmlWindowDto != undefined) {
  527. var htmlWindowUrl = htmlWindowDto.htmlFileName;
  528. var autoCloseInterval = htmlWindowDto.autoCloseInterval;
  529. var regExp = new RegExp('[{].*?[}]', 'g');
  530. var result = htmlWindowUrl.match(regExp);
  531. if (htmlWindowUrl != undefined && htmlWindowUrl != '') {
  532. for (var index = 0, len = result.length; index < len; index++) {
  533. var tempResult = result[index];
  534. console.log('{' + tempResult + '}匹配');
  535. if (tempResult == '{URL}') {
  536. htmlWindowUrl = htmlWindowUrl.replace(
  537. '{URL}',
  538. Common.getHostPageBaseURL(),
  539. );
  540. } else if (tempResult == '{RecordIds}') {
  541. var recordId = _self.modelData.id;
  542. htmlWindowUrl = htmlWindowUrl.replace('{RecordIds}', recordId);
  543. } else if (tempResult == '{Token}') {
  544. htmlWindowUrl = htmlWindowUrl.replace('{Token}', Common.getToken());
  545. } else {
  546. if (_self.selectedModelDatas.length == 0) {
  547. Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.tabButton.describe3'), true);
  548. return;
  549. } else if (_self.selectedModelDatas.length > 1) {
  550. Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.tabButton.describe2'), true);
  551. return;
  552. }
  553. var tempResult1 = tempResult.replace('{', '').replace('}', '');
  554. htmlWindowUrl = htmlWindowUrl.replace(
  555. tempResult,
  556. _self.getFirstSelectModelDataFieldValue(tempResult1),
  557. );
  558. }
  559. }
  560. var openWindow = window.open(htmlWindowUrl);
  561. // 自动关闭
  562. if (autoCloseInterval != undefined) {
  563. setTimeout(function () {
  564. openWindow.close();
  565. openWindow = undefined;
  566. }, autoCloseInterval * 1000);
  567. }
  568. }
  569. }
  570. },
  571. errorData => {
  572. Common.processException(errorData);
  573. },
  574. );
  575. }
  576. },
  577. // 切换到Form表单的路由
  578. switchFormRoute: function (tabButton) {
  579. const _self = this;
  580. var routeDate = {
  581. path: tabButton.customerWindowRouteUrl,
  582. params: {
  583. modelData: this.modelData,
  584. },
  585. };
  586. // 请勿修改,会影响生单的功能
  587. var uuid = _self.uuid;
  588. if (uuid != undefined) {
  589. routeDate.path = routeDate.path + '/' + uuid;
  590. }
  591. const frameUrl = Common.getRedirectUrl(
  592. '#' + routeDate.path,
  593. );
  594. // 供子页面iframe调用,修改modelData,(举例:生单界面修改参数)。
  595. // window.modelDataChanged = this.modelDataChanged;
  596. // window.getModelData = this.getModelData;
  597. let modelData = JSON.stringify(this.modelData);
  598. console.log(modelData);
  599. localStorage.setItem(_self.uuid + '#GenerateDocumentTool', modelData);
  600. var iWidth = 1280;//弹出窗口的宽度;
  601. var iHeight = 720; //弹出窗口的高度;
  602. var iTop = (window.screen.availHeight - 30 - iHeight) / 2;//获得窗口的垂直位置;
  603. var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
  604. window.open(frameUrl, '_blank', 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
  605. // window.open(frameUrl);
  606. },
  607. // 执行流程
  608. executeProcess: function () {
  609. var _self = this;
  610. var ids = [_self.modelData.id];
  611. ProcessReportResource.runProcessByIds(_self.tabButtonModel.processReportNo, ids).then(
  612. successData => {
  613. _self.modal = true;
  614. _self.processReportResult = successData;
  615. if (
  616. _self.processReportResult.reportResults != undefined &&
  617. _self.processReportResult.reportResults.length > 0
  618. ) {
  619. _self.processReportResult.reportResults.forEach(function (item, index) {
  620. if (item.reportDefinitionType !== 'ExcelReport') {
  621. item.previewIndex = 1;
  622. } else {
  623. item.previewIndex = 2;
  624. }
  625. if (index == 0) {
  626. item.showPreview = true;
  627. } else {
  628. item.showPreview = false;
  629. }
  630. });
  631. }
  632. _self.titleModal = false;
  633. },
  634. errorData => {
  635. _self.titleModal = false;
  636. Common.processException(errorData);
  637. },
  638. );
  639. _self.refreshDatas();
  640. // }
  641. },
  642. //关闭表头按钮提示框
  643. titleModalClose: function () {
  644. var _self = this;
  645. _self.titleModal = false;
  646. },
  647. }
  648. </script>
  649. <style scoped>
  650. .table-cell-text {
  651. overflow: hidden;
  652. text-overflow: ellipsis;
  653. white-space: nowrap;
  654. text-align: center;
  655. }
  656. .table-cell-text-line {
  657. word-break: break-all;
  658. white-space: pre-line;
  659. max-height: 4em;
  660. }
  661. .required-mark {
  662. color: red;
  663. }
  664. .cell-image {
  665. width: 80px;
  666. height: 80px;
  667. }
  668. .cell-image-list {
  669. width: 40px;
  670. height: 40px;
  671. margin-right: 5px;
  672. }
  673. .selected-tag {
  674. color: #333;
  675. background-color: #f0f0f0;
  676. border: 1px solid #ccc;
  677. border-radius: 4px;
  678. height: 26px;
  679. margin: 4px 4px 0px 0px;
  680. padding: 6px 0.25em;
  681. }
  682. </style>