xiaoyi
3 天以前 07bb7e462ea911a698da03cf50e92103e6434e88
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesPdCtcReelApi } from '#/api/mes/pd/ctc-reel';
 
import { markRaw } from 'vue';
 
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
 
import { PdCtcSelect } from '#/views/mes/pd/ctc/components';
 
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'update';
 
/** 新增/修改盘具计算记录 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'ctcId',
      label: '换位导线产品',
      component: markRaw(PdCtcSelect),
      componentProps: {
        placeholder: '请选择换位导线产品',
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'reelType',
      label: '盘具类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_TYPE.PRODUCT_REEL_TYPE, 'string'),
        placeholder: '请选择盘具类型',
      },
    },
    {
      fieldName: 'reelOuterDiameter',
      label: '盘具外径(mm)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 0,
        placeholder: '请输入盘具外径 d1',
      },
    },
    {
      fieldName: 'reelInnerDiameter',
      label: '盘芯内径(mm)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 0,
        placeholder: '请输入盘芯内径 d2',
      },
    },
    {
      fieldName: 'reelWidth',
      label: '盘宽(mm)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 0,
        placeholder: '请输入盘宽 l2',
      },
    },
    {
      fieldName: 'maxCapacity',
      label: '最大容量(km)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 4,
        placeholder: '请输入最大容量',
      },
    },
    {
      fieldName: 'recommendedLength',
      label: '推荐每盘长度(km)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 2,
        placeholder: '请输入推荐每盘长度',
      },
    },
    {
      fieldName: 'netWeight',
      label: '净重(kg)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 2,
        placeholder: '请输入净重',
      },
    },
    {
      fieldName: 'grossWeight',
      label: '毛重(kg)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 2,
        placeholder: '请输入毛重',
      },
    },
    {
      fieldName: 'calcFormula',
      label: '计算公式',
      component: 'Textarea',
      formItemClass: 'col-span-3',
      componentProps: {
        placeholder: '((d1-60)+(d2+10))×INT(l2/(宽+1))×(d1-d2-70)/(高+0.2)/1274',
        rows: 2,
      },
      help: '容量计算:((d1-60)+(d2+10))×INT(l2/(CTC宽+1))×(d1-d2-70)/(CTC高+0.2)/1274',
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Textarea',
      formItemClass: 'col-span-3',
      componentProps: {
        placeholder: '请输入备注',
        rows: 2,
      },
    },
  ];
}
 
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'ctcId',
      label: '换位导线产品',
      component: markRaw(PdCtcSelect),
      componentProps: {
        allowClear: true,
        placeholder: '请选择换位导线产品',
      },
    },
    {
      fieldName: 'reelType',
      label: '盘具类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_TYPE.PRODUCT_REEL_TYPE, 'string'),
        placeholder: '请选择盘具类型',
      },
    },
  ];
}
 
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<MesPdCtcReelApi.CtcReel>['columns'] {
  return [
    { field: 'ctcOrderSpec', title: '换位导线规格', minWidth: 160 },
    {
      field: 'reelType',
      title: '盘具类型',
      width: 100,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.PRODUCT_REEL_TYPE },
      },
    },
    { field: 'reelOuterDiameter', title: '盘具外径(mm)', width: 110 },
    { field: 'reelInnerDiameter', title: '盘芯内径(mm)', width: 110 },
    { field: 'reelWidth', title: '盘宽(mm)', width: 100 },
    { field: 'maxCapacity', title: '最大容量(km)', width: 120 },
    { field: 'recommendedLength', title: '推荐长度(km)', width: 120 },
    { field: 'netWeight', title: '净重(kg)', width: 100 },
    { field: 'grossWeight', title: '毛重(kg)', width: 100 },
    {
      field: 'createTime',
      title: '创建时间',
      width: 170,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 220,
      fixed: 'right',
      slots: {
        default: 'actions',
      },
    },
  ];
}