gaoluyang
昨天 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 
import { handleTree } from '@vben/utils';
 
import { getDeptList } from '#/api/system/dept';
 
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'name',
      label: '状态组名',
      component: 'Input',
      rules: 'required',
      componentProps: {
        placeholder: '请输入状态组名',
      },
    },
    {
      fieldName: 'deptIds',
      label: '应用部门',
      component: 'ApiTreeSelect',
      componentProps: {
        api: async () => {
          const data = await getDeptList();
          return handleTree(data);
        },
        multiple: true,
        fieldNames: { label: 'name', value: 'id', children: 'children' },
        placeholder: '请选择应用部门',
        treeDefaultExpandAll: true,
      },
      help: '不选择部门时,默认全公司生效',
    },
    {
      fieldName: 'statuses',
      label: '阶段设置',
      component: 'Input',
      rules: 'required',
    },
  ];
}
 
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'name',
      title: '状态组名',
    },
    {
      field: 'deptNames',
      title: '应用部门',
      formatter: ({ cellValue }) =>
        cellValue?.length > 0 ? cellValue.join(' ') : '全公司',
    },
    {
      field: 'creator',
      title: '创建人',
    },
    {
      field: 'createTime',
      title: '创建时间',
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 160,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
 
/** 商机状态阶段列表列配置 */
export function useFormColumns(): VxeTableGridOptions['columns'] {
  return [
    {
      type: 'seq',
      title: '序号',
      width: 60,
    },
    {
      field: 'name',
      title: '阶段名称',
      minWidth: 100,
      slots: { default: 'name' },
    },
    {
      field: 'percent',
      title: '赢单率(%)',
      minWidth: 100,
      slots: { default: 'percent' },
    },
    {
      title: '操作',
      width: 130,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}