src/views/aftersales/ticket/data.ts
@@ -12,10 +12,11 @@
import { z } from '#/adapter/form';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components';
import { MdItemSelect } from '#/views/mes/md/item/components';
import { WmBatchSelect } from '#/views/wls/batch/components';
import { UserSelect } from '#/views/system/user/components';
import { getDeptList } from '#/api/system/dept';
import { handleTree } from '#/packages/utils/src';
/** 表单类型 */
export type TicketFormType = 'create' | 'detail' | 'update';
@@ -40,11 +41,7 @@
}
/** 工单表单 */
export function useTicketFormSchema(
  formType: TicketFormType,
  formApi?: VbenFormApi,
  onSaleOrderChange?: (order: Record<string, unknown> | undefined) => void,
): VbenFormSchema[] {
export function useTicketFormSchema(formType: TicketFormType): VbenFormSchema[] {
  const readonly = isHeaderReadonly(formType);
  return [
    {
@@ -71,32 +68,6 @@
        placeholder: '请输入工单主题',
      },
      rules: 'required',
    },
    {
      fieldName: 'saleOrderId',
      label: '销售订单号',
      component: markRaw(ErpSaleOrderSelect),
      componentProps: {
        placeholder: '请选择销售订单',
        outStatus: 3,
        onChange: (item: Record<string, unknown> | undefined) => {
          if (formApi) {
            formApi.setFieldValue('saleOrderNo', item?.no ?? '');
            if (item?.customerId) {
              formApi.setFieldValue('customerId', item.customerId);
            }
          }
          onSaleOrderChange?.(item);
        },
      },
    },
    {
      fieldName: 'saleOrderNo',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'customerId',
@@ -269,11 +240,6 @@
      minWidth: 150,
    },
    {
      field: 'saleOrderNo',
      title: '销售订单号',
      minWidth: 150,
    },
    {
      field: 'issueType',
      title: '问题类型',
      width: 100,
@@ -322,6 +288,11 @@
): VxeTableGridOptions<AftersalesTicketApi.TicketItem>['columns'] {
  return [
    {
      field: 'itemNo',
      title: '明细单号',
      minWidth: 170,
    },
    {
      field: 'itemCode',
      title: '物料编码',
      minWidth: 120,
@@ -357,6 +328,22 @@
      title: '需要退货',
      width: 90,
      slots: { default: 'needReturn' },
    },
    {
      field: 'deptName',
      title: '部门',
      minWidth: 120,
    },
    {
      field: 'reasonType',
      title: '原因类型',
      width: 120,
      slots: { default: 'reasonType' },
    },
    {
      field: 'reason',
      title: '具体原因',
      minWidth: 160,
    },
    ...(editable
      ? [
@@ -488,6 +475,40 @@
      rules: z.boolean().default(false),
    },
    {
      fieldName: 'deptId',
      label: '部门',
      component: 'ApiTreeSelect',
      componentProps: {
        api: async () => handleTree(await getDeptList()),
        labelField: 'name',
        valueField: 'id',
        childrenField: 'children',
        placeholder: '请选择部门',
        treeDefaultExpandAll: true,
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'reasonType',
      label: '原因类型',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.AFTERSALE_REASON_TYPE, 'number'),
        placeholder: '请选择原因类型',
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'reason',
      label: '具体原因',
      component: 'Textarea',
      formItemClass: 'col-span-3',
      componentProps: {
        placeholder: '请输入具体原因',
        rows: 2,
      },
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Textarea',