云
昨天 346a988f537228ae44731cd31007f1412b482e83
src/views/mes/pro/batch/data.ts
@@ -23,11 +23,16 @@
  itemCode?: string;
}
export type TonBagOption = PalletOption;
/** 新增/修改的表单 */
export function useFormSchema(
  formType: FormType,
  palletOptions: PalletOption[] = [],
  onPalletChange?: (ids: number[]) => void,
  tonBagOptions: TonBagOption[] = [],
  onTonBagChange?: (ids: number[]) => void,
  existingBinding?: 'pallet' | 'tonBag',
): VbenFormSchema[] {
  const disabled = formType === 'detail';
  return [
@@ -141,11 +146,11 @@
    },
    {
      fieldName: 'itemName', label: '品种名称', component: 'Input',
      componentProps: { disabled: true, placeholder: '选择托盘后自动带入' },
      componentProps: { disabled: true, placeholder: '选择托盘或吨袋后自动带入' },
    },
    {
      fieldName: 'itemCode', label: '品种编码', component: 'Input',
      componentProps: { disabled: true, placeholder: '选择托盘后自动带入' },
      componentProps: { disabled: true, placeholder: '选择托盘或吨袋后自动带入' },
    },
    {
      fieldName: 'palletIds',
@@ -165,17 +170,47 @@
        showSearch: true,
      },
      dependencies: {
        triggerFields: ['itemId'],
        triggerFields: ['itemId', 'tonBagIds'],
        show: () => formType !== 'detail',
        componentProps: (values) => ({
          options: palletOptions.map(option => ({ ...option,
            disabled: !option.itemId || (!!values.itemId && option.itemId !== values.itemId),
            disabled: existingBinding === 'tonBag' || !!values.tonBagIds?.length || !option.itemId || (!!values.itemId && option.itemId !== values.itemId),
          })),
          disabled: disabled || existingBinding === 'tonBag' || !!values.tonBagIds?.length,
        }),
      },
      help: '只能绑定相同品种的托盘,品种信息自动带入;缺少品种的托盘请先装袋。绑定后批次直接进入生产中:托盘生成正式托盘码,托盘下未录批次的袋码自动级联录入本批次(袋码品种须一致);编辑时仅需勾选新增托盘,已绑定的不可解绑',
    },
    {
      fieldName: 'tonBagIds',
      label: '绑定吨袋',
      component: 'Select',
      componentProps: {
        allowClear: true,
        disabled,
        maxTagCount: 3,
        dropdownMatchSelectWidth: false,
        dropdownStyle: { minWidth: '380px', maxWidth: 'calc(100vw - 32px)' },
        mode: 'multiple',
        optionFilterProp: 'label',
        options: tonBagOptions,
        onChange: onTonBagChange,
        placeholder: '请选择相同品种的吨袋',
        showSearch: true,
      },
      dependencies: {
        triggerFields: ['itemId', 'palletIds'],
        show: () => formType !== 'detail',
        componentProps: (values) => ({
          options: tonBagOptions.map(option => ({ ...option,
            disabled: existingBinding === 'pallet' || !!values.palletIds?.length || (!!values.itemId && option.itemId !== values.itemId),
          })),
          disabled: disabled || existingBinding === 'pallet' || !!values.palletIds?.length,
        }),
      },
      help: '仅可绑定计量单位为吨、无托盘且未录入批次的袋码;与绑定托盘互斥。编辑时仅选择新增吨袋,已绑定的不可解绑',
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Textarea',