云
5 天以前 a241b66efcc41e973290a6722fb7a4d79b833ea1
src/views/erp/sale/order/data.ts
@@ -5,10 +5,10 @@
import { z } from '#/adapter/form';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getItemPage } from '#/api/mdm/item';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { getRangePickerDefaultProps, withoutFixedColumns } from '#/utils';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { markRaw } from 'vue';
@@ -36,14 +36,43 @@
      },
    },
    {
      fieldName: 'productionStatus',
      label: '生产状态',
      component: 'Input',
      dependencies: {
        triggerFields: ['needProduction', 'productionStatus'],
        show: (values) => {
          return formType === 'detail' && values.needProduction === 1;
        },
      },
      componentProps: {
        disabled: true,
      },
      slots: { default: 'productionStatus' },
    },
    {
      fieldName: 'productionFinishTime',
      label: '生产完成时间',
      component: 'Input',
      dependencies: {
        triggerFields: ['productionStatus'],
        show: (values) => {
          return formType === 'detail' && values.productionStatus === 1;
        },
      },
      componentProps: {
        disabled: true,
      },
    },
    {
      fieldName: 'orderTime',
      label: '订单时间',
      component: 'DatePicker',
      componentProps: {
        placeholder: '选择订单时间',
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
        showTime: false,
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
      },
      rules: 'required',
    },
@@ -82,23 +111,13 @@
      formItemClass: 'col-span-2',
    },
    {
      fieldName: 'fileUrl',
      fieldName: 'blobIds',
      label: '附件',
      component: 'FileUpload',
      componentProps: {
        maxNumber: 1,
        maxSize: 10,
        accept: [
          'pdf',
          'doc',
          'docx',
          'xls',
          'xlsx',
          'txt',
          'jpg',
          'jpeg',
          'png',
        ],
        valueKey: 'id',
        maxNumber: 10,
        multiple: true,
        showDescription: formType !== 'detail',
        disabled: formType === 'detail',
      },
@@ -162,14 +181,27 @@
    },
    {
      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(),
    },
  ];
@@ -179,7 +211,7 @@
export function useFormItemColumns(
  disabled: boolean,
): VxeTableGridOptions['columns'] {
  return [
  const columns: VxeTableGridOptions['columns'] = [
    { type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
    {
      field: 'productId',
@@ -197,11 +229,7 @@
      title: '库存',
      minWidth: 80,
      formatter: 'formatAmount3',
    },
    {
      field: 'productBarCode',
      title: '条码',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'productUnitName',
@@ -212,11 +240,13 @@
      field: 'productUnitName2',
      title: '辅单位1',
      minWidth: 80,
      visible: false,
    },
    {
      field: 'productUnitName3',
      title: '辅单位2',
      minWidth: 80,
      visible: false,
    },
    {
      field: 'needProduction',
@@ -229,6 +259,7 @@
      title: '备注',
      minWidth: 150,
      slots: { default: 'remark' },
      visible: false,
    },
    {
      field: 'count',
@@ -274,12 +305,14 @@
    },
    {
      title: '操作',
      width: 320,
      width: 80,
      fixed: 'right',
      slots: { default: 'actions' },
      visible: !disabled,
    },
  ];
  // 查看审批明细(只读)时取消固定列,避免窄弹窗里挤掉产品名称、单位、备注等列
  return disabled ? withoutFixedColumns(columns) : columns;
}
/** 列表的搜索表单 */
@@ -297,17 +330,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: async () => {
          const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
          return res.list || [];
        },
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
@@ -316,6 +341,8 @@
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        showTime: false,
        format: 'YYYY-MM-DD',
        allowClear: true,
      },
    },
@@ -347,8 +374,10 @@
      component: 'Select',
      componentProps: {
        options: [
          { label: '未审核', value: 10 },
          { label: '未提交', value: 0 },
          { label: '审批中', value: 15 },
          { label: '已审核', value: 20 },
          { label: '已驳回', value: 35 },
          { label: '已作废', value: 30 },
        ],
        placeholder: '请选择状态',
@@ -371,24 +400,25 @@
      componentProps: {
        options: [
          { label: '未出库', value: 0 },
          { label: '部分出库', value: 1 },
          { label: '全部出库', value: 2 },
          { label: '已预留', value: 1 },
          { label: '部分出库', value: 2 },
          { label: '全部出库', value: 3 },
        ],
        placeholder: '请选择出库状态',
        allowClear: true,
      },
    },
    {
      fieldName: 'returnStatus',
      label: '退货状态',
      fieldName: 'productionStatus',
      label: '生产状态',
      component: 'Select',
      componentProps: {
        options: [
          { label: '未退货', value: 0 },
          { label: '部分退货', value: 1 },
          { label: '全部退货', value: 2 },
          { label: '无需生产', value: -1 },
          { label: '未完成', value: 0 },
          { label: '已完成', value: 1 },
        ],
        placeholder: '请选择退货状态',
        placeholder: '请选择生产状态',
        allowClear: true,
      },
    },
@@ -445,18 +475,6 @@
      minWidth: 120,
    },
    {
      field: 'outCount',
      title: '出库数量',
      formatter: 'formatAmount3',
      minWidth: 120,
    },
    {
      field: 'returnCount',
      title: '退货数量',
      formatter: 'formatAmount3',
      minWidth: 120,
    },
    {
      field: 'totalProductPrice',
      title: '金额合计',
      formatter: 'formatAmount2',
@@ -475,6 +493,20 @@
      minWidth: 120,
    },
    {
      field: 'outStatus',
      title: '出库状态',
      minWidth: 100,
      fixed: 'right',
      slots: { default: 'outStatus' },
    },
    {
      field: 'productionStatus',
      title: '生产状态',
      minWidth: 100,
      fixed: 'right',
      slots: { default: 'productionStatus' },
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 100,