CellTextItem.vue 29 KB

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