index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="dynamicModel-v">
  3. <Form v-if="webType == 1" :config="config" :modelId="modelId" :isPreview="isPreview" />
  4. <List v-if="webType == 2 || webType == 4" :config="config" :modelId="modelId" :isPreview="isPreview"
  5. :title="title" :menuId="menuId" ref="List" />
  6. </view>
  7. </template>
  8. <script>
  9. import Form from "./components/form/index.vue";
  10. import List from "./components/list/index.vue";
  11. import {
  12. getFlowStartFormId
  13. } from "@/api/workFlow/flowEngine";
  14. import {
  15. getConfigData
  16. } from "@/api/apply/visualDev";
  17. import {
  18. useBaseStore
  19. } from '@/store/modules/base'
  20. const baseStore = useBaseStore()
  21. export default {
  22. name: "dynamicModel",
  23. components: {
  24. Form,
  25. List,
  26. },
  27. data() {
  28. return {
  29. webType: "",
  30. showPage: false,
  31. isPreview: false,
  32. modelId: "",
  33. menuId: "",
  34. title: "",
  35. config: {},
  36. preview: false,
  37. flowId: '',
  38. enableFlow: 0,
  39. };
  40. },
  41. onLoad(obj) {
  42. baseStore.getDictionaryDataAll()
  43. this.config = JSON.parse(this.jnpf.base64.decode(obj.config)) || {};
  44. this.isPreview = this.config.isPreview || false;
  45. this.enableFlow = this.config.type === 9 ? 1 : 0;
  46. this.title = this.config.fullName || "";
  47. this.menuId = this.config.id || "";
  48. uni.setNavigationBarTitle({
  49. title: this.title,
  50. });
  51. if (!this.enableFlow) return this.getConfigData();
  52. this.flowId = this.config.moduleId
  53. this.getModelId()
  54. },
  55. methods: {
  56. // 获取流程版本ID和发起节点表单ID
  57. getModelId() {
  58. getFlowStartFormId(this.flowId).then(res => {
  59. if (!res.data || !res.data.formId) return;
  60. this.config.moduleId = res.data.formId
  61. this.getConfigData();
  62. })
  63. },
  64. getConfigData() {
  65. getConfigData(this.config.moduleId, undefined).then((res) => {
  66. if (res.code !== 200 || !res.data) return this.handleError('暂无此页面')
  67. if (this.enableFlow && res.data.webType == 1) return this.jump();
  68. this.config = {
  69. ...res.data,
  70. ...this.config,
  71. enableFlow: this.enableFlow,
  72. flowId: this.flowId
  73. };
  74. this.showPage = true;
  75. this.isPreview = !!this.config.isPreview;
  76. this.modelId = this.config.moduleId;
  77. this.webType = this.config.webType;
  78. });
  79. },
  80. jump() {
  81. const config = {
  82. id: "",
  83. flowId: this.flowId,
  84. opType: "-1",
  85. hideCancelBtn: true,
  86. hideSaveBtn: true
  87. };
  88. uni.redirectTo({
  89. url: "/pages/workFlow/flowBefore/index?config=" +
  90. this.jnpf.base64.encode(JSON.stringify(config)),
  91. fail: () => {
  92. this.$u.toast("暂无此页面");
  93. },
  94. });
  95. },
  96. handleError(msg) {
  97. this.$u.toast(msg);
  98. setTimeout(() => {
  99. uni.navigateBack();
  100. }, 1500);
  101. }
  102. },
  103. };
  104. </script>
  105. <style lang="scss">
  106. page {
  107. background-color: #f0f2f6;
  108. }
  109. .dynamicModel-v {
  110. height: 100%;
  111. }
  112. </style>