22
schangxiang@126.com
2025-05-20 5b189017d143be6366f56ffcdd3c3699a381e034
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import {
  ref,
  onMounted,
  reactive,
  computed,
  Ref,
  watch,
  readonly,
  h,
} from 'vue'
import { Language } from '@/libs/Language/Language'
import { FormItem } from 'vxe-table'
 
interface DrawerType {}
 
export const useDrawer = (props: any, ctx: any) => {
  const _t = props._t
  /**
   * 用来对比的初始化数据
   */
  const formData = reactive<Record<string, any>>({
    count: 1,
  })
 
  const formRef = ref()
 
  const visible = computed({
    get() {
      return props.modelValue
    },
    set(val) {
      ctx.emit('update:modelValue', val)
    },
  })
 
  const onClose = (done: () => void) => {
    visible.value = false
    done && done()
  }
  /**
   * 保存
   */
  const onConfirm = async () => {
    formRef.value?.validate()
  }
  /**
   * 弹窗打开获取详情
   */
  const onOpen = async () => {
    const res: any = {}
    Object.assign(formData, {
      flowDefinitions: res.flowDefinitions,
      code: res.code,
      id: res.id,
      isDisabled: res.isDisabled,
      name: res.name,
      remark: res.remark,
      segment: res?.segment?.id,
      sectionType: res.sectionType?.value,
      sort: res.sort,
      segmentData: res.segment,
    })
  }
 
  return {
    formData,
    visible,
    formRef,
    onOpen,
    onClose,
    onConfirm,
  }
}