feat(erp): 增加采购与销售订单订金校验逻辑,限制不得超过优惠后总金额
- **采购订单 (`src/views/erp/purchase/order/data.ts`)**: 为 `depositPrice`(支付订金)字段增加双重校验,动态绑定 `max` 属性到 `totalPrice`,并添加动态表单 rules,超出时提示“订金不能大于优惠后金额”。
- **销售订单 (`src/views/erp/sale/order/data.ts`)**: 复用同等防错机制,限制 `depositPrice`(收取订金)输入不能超过优惠后金额,超过时给予相应报错提示。
| | |
| | | }, |
| | | { |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | componentProps: (values) => ({ |
| | | class: '!w-full', |
| | | placeholder: '请输入支付订金', |
| | | precision: 2, |
| | | min: 0, |
| | | }, |
| | | max: values.totalPrice ?? undefined, |
| | | }), |
| | | fieldName: 'depositPrice', |
| | | label: '支付订金', |
| | | dependencies: { |
| | | triggerFields: ['totalPrice'], |
| | | rules(values) { |
| | | if (values.totalPrice != null) { |
| | | return z |
| | | .number() |
| | | .min(0, '订金不能小于0') |
| | | .max(values.totalPrice, '订金不能大于优惠后金额'); |
| | | } |
| | | return z.number().min(0, '订金不能小于0'); |
| | | }, |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | componentProps: (values) => ({ |
| | | class: '!w-full', |
| | | placeholder: '请输入收取订金', |
| | | precision: 2, |
| | | min: 0, |
| | | }, |
| | | max: values.totalPrice ?? undefined, |
| | | }), |
| | | fieldName: 'depositPrice', |
| | | label: '收取订金', |
| | | dependencies: { |
| | | triggerFields: ['totalPrice'], |
| | | rules(values) { |
| | | if (values.totalPrice != null) { |
| | | return z |
| | | .number() |
| | | .min(0, '订金不能小于0') |
| | | .max(values.totalPrice, '收取订金不能大于优惠后金额'); |
| | | } |
| | | return z.number().min(0, '订金不能小于0').optional(); |
| | | }, |
| | | }, |
| | | rules: z.number().min(0).optional(), |
| | | }, |
| | | ]; |