|
@@ -31,14 +31,14 @@
|
|
|
<el-button v-show="!isView" type="primary" @click="submitHandler">发布</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="create-approval-main">
|
|
|
+ <div v-loading="loading" class="create-approval-main">
|
|
|
<component :is="item.component" v-for="(item, idx) in componentsArr" v-show="item.value === activeTab" ref="compRefs" :key="idx" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script setup name="flow_create">
|
|
|
-import { computed, nextTick, ref } from 'vue'
|
|
|
+<script setup name="flow_create_index">
|
|
|
+import { computed, nextTick, ref, onActivated } from 'vue'
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
import useFlowStore from '@/store/modules/flow'
|
|
|
import BasicInfoTab from './components/BasicInfo.vue'
|
|
@@ -54,6 +54,7 @@ const { tagsView } = useStore()
|
|
|
const router = useRouter()
|
|
|
const route = useRoute()
|
|
|
const flowStore = useFlowStore()
|
|
|
+const loading = ref(false)
|
|
|
const { categoryId, processId, processIcon, processKey, processName, remark, modelContent, processForm, processSetting, processPermissionList } =
|
|
|
storeToRefs(flowStore)
|
|
|
const compRefs = ref() // 实例化子组件
|
|
@@ -187,40 +188,66 @@ const queryObj = computed(() => route.query)
|
|
|
const isView = computed(() => {
|
|
|
return queryObj.value?.view === '1'
|
|
|
})
|
|
|
-const getCurrentProcessDetailEv = () => {
|
|
|
- flowStore.setProcessType('main')
|
|
|
+
|
|
|
+const lastId = ref()
|
|
|
+const getCurrentProcessDetailEv = async () => {
|
|
|
let _id = queryObj.value.id
|
|
|
- if (_id) {
|
|
|
- cache_components.value = {}
|
|
|
- process.processDetailApi(_id).then(res => {
|
|
|
- processId.value = res.processId
|
|
|
- categoryId.value = res.categoryId
|
|
|
- processIcon.value = res.processIcon
|
|
|
- processKey.value = res.processKey
|
|
|
- processName.value = res.processName
|
|
|
- remark.value = res.remark
|
|
|
- let nodeConfig = JSON.parse(res.modelContent).nodeConfig
|
|
|
- modelContent.value = JSON.stringify(nodeConfig)
|
|
|
- processForm.value = res.processForm
|
|
|
- flowStore.setProcessSetting(res.processSetting)
|
|
|
- processPermissionList.value = (res.processPermissionList || []).map(i => ({
|
|
|
- ...i,
|
|
|
- id: i.userId,
|
|
|
- name: i.userName
|
|
|
- }))
|
|
|
- // 默认执行一次保存
|
|
|
- const _refs = compRefs.value
|
|
|
- for (let i = 0; i < _refs.length; i++) {
|
|
|
- const updateCompInfo = compRefs.value[i]?.updateCompInfo
|
|
|
- if (updateCompInfo) {
|
|
|
- updateCompInfo()
|
|
|
+ if (lastId.value !== _id) {
|
|
|
+ activeTab.value = '基础信息'
|
|
|
+ lastId.value = _id
|
|
|
+ flowStore.$reset()
|
|
|
+ flowStore.setProcessType('main')
|
|
|
+ if (_id) {
|
|
|
+ loading.value = true
|
|
|
+ cache_components.value = {}
|
|
|
+ process
|
|
|
+ .processDetailApi(_id)
|
|
|
+ .then(res => {
|
|
|
+ processId.value = res.processId
|
|
|
+ categoryId.value = res.categoryId
|
|
|
+ processIcon.value = res.processIcon
|
|
|
+ processKey.value = res.processKey
|
|
|
+ processName.value = res.processName
|
|
|
+ remark.value = res.remark
|
|
|
+ let nodeConfig = JSON.parse(res.modelContent).nodeConfig
|
|
|
+ modelContent.value = JSON.stringify(nodeConfig)
|
|
|
+ processForm.value = res.processForm
|
|
|
+ flowStore.setProcessSetting(res.processSetting)
|
|
|
+ processPermissionList.value = (res.processPermissionList || []).map(i => ({
|
|
|
+ ...i,
|
|
|
+ id: i.userId,
|
|
|
+ name: i.userName
|
|
|
+ }))
|
|
|
+ // 默认执行一次保存
|
|
|
+ const _refs = compRefs.value
|
|
|
+ for (let i = 0; i < _refs.length; i++) {
|
|
|
+ const updateCompInfo = compRefs.value[i]?.updateCompInfo
|
|
|
+ if (updateCompInfo) {
|
|
|
+ updateCompInfo()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ nextTick(() => {
|
|
|
+ // 默认执行一次保存
|
|
|
+ const _refs = compRefs.value
|
|
|
+ for (let i = 0; i < _refs.length; i++) {
|
|
|
+ const updateCompInfo = compRefs.value[i]?.updateCompInfo
|
|
|
+ if (updateCompInfo) {
|
|
|
+ updateCompInfo()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
getCurrentProcessDetailEv()
|
|
|
+onActivated(() => {
|
|
|
+ getCurrentProcessDetailEv()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|