222
schangxiang@126.com
2025-05-21 f41aacbe60e10d1b47123fe31c779410e312de9d
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
74
75
76
77
78
import { ref, onMounted, reactive, computed, watch } from 'vue'
import { _t } from '@/libs/Language/Language'
 
export const useSelectDialog = (props: any, ctx: any) => {
  const visible = computed({
    get() {
      return props.modelValue
    },
    set(val) {
      ctx.emit('update:modelValue', val)
    },
  })
 
  const dataSource = ref<any[]>([])
 
  const innerValue = ref('')
 
  const tableRef = ref()
 
  const checkedList = ref<any[]>([])
 
  const columns = computed(() => [
    {
      title: _t('序号'),
      type: 'seq',
      width: '60',
    },
    {
      field: 'name',
      title: _t('工序名称'),
    },
 
    {
      field: 'remark',
      title: _t('备注'),
    },
  ])
 
  const onClose = () => {
    visible.value = false
  }
 
  const onConfirm = async () => {
    ctx.emit('confirm', checkedList.value)
  }
 
  const onSearch = () => {
    tableRef.value?.getList()
  }
 
  const onCheck = (list: any) => {
    checkedList.value = list
  }
 
  const selections = computed(() => {
    const data = props.data?.map((item: any) => item.id) ?? []
    return data.filter((item: any) => item)
  })
 
  const onOpen = () => {
    checkedList.value = []
    // console.log(dataSource.value, selections, props.data)
  }
 
  return {
    selections,
    dataSource,
    columns,
    tableRef,
    innerValue,
    visible,
    onSearch,
    onOpen,
    onCheck,
    onClose,
    onConfirm,
  }
}