|
@@ -238,7 +238,8 @@ import {
|
|
|
getCurrentInstance,
|
|
|
ComponentInternalInstance,
|
|
|
toRefs,
|
|
|
- nextTick
|
|
|
+ nextTick,
|
|
|
+ inject, onUnmounted, onBeforeUnmount
|
|
|
} from 'vue'
|
|
|
import {useStore} from 'vuex'
|
|
|
import {useRouter, useRoute} from 'vue-router'
|
|
@@ -258,6 +259,7 @@ import DeptCom from './cus-form-link/dept.vue'
|
|
|
import UploadCom from './cus-form-link/upload.vue'
|
|
|
import NumberCom from './cus-form-link/number.vue'
|
|
|
import TreeSelectCom from './cus-form-link/tree-select.vue'
|
|
|
+import { v4 } from "uuid";
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'CusFormColumn',
|
|
@@ -304,7 +306,8 @@ export default defineComponent({
|
|
|
const route = useRoute();
|
|
|
const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
|
|
|
const state = reactive({
|
|
|
- errorMessage: null
|
|
|
+ errorMessage: null,
|
|
|
+ uuid: ''
|
|
|
})
|
|
|
const ref_cusFormColumn: any = ref(null)
|
|
|
const isValue = (val: any) => {
|
|
@@ -364,15 +367,9 @@ export default defineComponent({
|
|
|
}
|
|
|
return state.errorMessage
|
|
|
}
|
|
|
+ const handleEnterFunc = inject('handle-enter', () => {})
|
|
|
const handleEnter = () => {
|
|
|
- const find = (itemVue: any) => {
|
|
|
- if (itemVue?.type.name === "CusForm") {
|
|
|
- itemVue.setupState.handleEnter()
|
|
|
- } else {
|
|
|
- find(itemVue.parent)
|
|
|
- }
|
|
|
- }
|
|
|
- find(ref_cusFormColumn?.value?.$el?.__vueParentComponent)
|
|
|
+ handleEnterFunc?.()
|
|
|
}
|
|
|
const reset = () => {
|
|
|
state.errorMessage = null
|
|
@@ -390,6 +387,27 @@ export default defineComponent({
|
|
|
p.style.marginBottom = '18px'
|
|
|
}
|
|
|
})
|
|
|
+ onMounted(() => {
|
|
|
+ state.uuid = v4()
|
|
|
+ const formChildrenMap: any = inject('cus-form-children-map', new Map())
|
|
|
+ let flag = true
|
|
|
+ const deep = (dom) => {
|
|
|
+ if (dom.className === 'hidden-columns') {
|
|
|
+ flag = false
|
|
|
+ }
|
|
|
+ if (dom.parentElement) {
|
|
|
+ deep(dom.parentElement)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ deep(ref_cusFormColumn.value.$parent.$el)
|
|
|
+ if (flag) {
|
|
|
+ formChildrenMap.set(state.uuid, ref_cusFormColumn.value.$parent)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ onBeforeUnmount(() => {
|
|
|
+ const formChildrenMap: any = inject('cus-form-children-map', new Map())
|
|
|
+ formChildrenMap.delete(state.uuid)
|
|
|
+ })
|
|
|
return {
|
|
|
...toRefs(state),
|
|
|
handleValidate,
|