feat(aftersales): 工单 客户/联系人/物料/批次 改为文本输入
- 新增工单:客户、联系人改为文本框(自由输入)
- 明细行:物料、批次改为文本框
| | |
| | | import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; |
| | | import type { VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { AftersalesTicketApi } from '#/api/aftersales/ticket'; |
| | | import type { ErpSaleOrderApi } from '#/api/erp/sale/order'; |
| | | |
| | | import { h, markRaw } from 'vue'; |
| | | |
| | |
| | | import { Button, Tag } from 'ant-design-vue'; |
| | | |
| | | import { z } from '#/adapter/form'; |
| | | import CrmCustomerSelect from '#/components/crm-customer-select.vue'; |
| | | 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'; |
| | |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'customerId', |
| | | fieldName: 'customerName', |
| | | label: '客户', |
| | | component: markRaw(CrmCustomerSelect), |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '请选择客户', |
| | | placeholder: '请输入客户', |
| | | }, |
| | | rules: 'selectRequired', |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'contactId', |
| | | fieldName: 'contactName', |
| | | label: '联系人', |
| | | component: 'Input', |
| | | componentProps: { |
| | |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'customerId', |
| | | fieldName: 'customerName', |
| | | label: '客户', |
| | | component: markRaw(CrmCustomerSelect), |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '请选择客户', |
| | | allowClear: true, |
| | | placeholder: '请输入客户', |
| | | }, |
| | | }, |
| | | { |
| | |
| | | } |
| | | |
| | | /** 工单明细行表单 */ |
| | | export function useTicketItemFormSchema( |
| | | clientId?: number, |
| | | salesOrderCode?: string, |
| | | orderItems?: ErpSaleOrderApi.SaleOrderItem[], |
| | | formApi?: VbenFormApi, |
| | | ): VbenFormSchema[] { |
| | | const hasOrderItems = orderItems && orderItems.length > 0; |
| | | export function useTicketItemFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '物料', |
| | | component: hasOrderItems ? 'Select' : markRaw(MdItemSelect), |
| | | componentProps: hasOrderItems |
| | | ? { |
| | | placeholder: '请选择物料', |
| | | options: orderItems!.map((oi) => ({ |
| | | label: `${oi.productName || ''} (${oi.productBarCode || oi.productId})`, |
| | | value: oi.productId, |
| | | })), |
| | | showSearch: true, |
| | | onChange: (value: number) => { |
| | | const oi = orderItems!.find((o) => o.productId === value); |
| | | if (oi && formApi) { |
| | | formApi.setValues({ |
| | | itemName: oi.productName, |
| | | itemCode: oi.productBarCode || '', |
| | | saleQuantity: oi.count, |
| | | batchCode: oi.batchCode || '', |
| | | }); |
| | | } |
| | | }, |
| | | } |
| | | : { |
| | | placeholder: '请选择物料', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'itemCode', |
| | | component: 'Input', |
| | | dependencies: { triggerFields: [''], show: () => false }, |
| | | }, |
| | | { |
| | | fieldName: 'itemName', |
| | | label: '物料', |
| | | component: 'Input', |
| | | dependencies: { triggerFields: [''], show: () => false }, |
| | | componentProps: { |
| | | placeholder: '请输入物料', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | ...(hasOrderItems |
| | | ? [ |
| | | { |
| | | fieldName: 'batchCode', |
| | | label: '批次', |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: true, |
| | | placeholder: '自动从订单带入', |
| | | }, |
| | | }, |
| | | ] |
| | | : [ |
| | | { |
| | | fieldName: 'batchId', |
| | | label: '批次', |
| | | component: markRaw(WmBatchSelect), |
| | | componentProps: { |
| | | clientId, |
| | | placeholder: '请选择批次', |
| | | salesOrderCode, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['itemId'], |
| | | componentProps: (values: Record<string, unknown>) => ({ |
| | | clientId, |
| | | itemId: values.itemId, |
| | | placeholder: '请选择批次', |
| | | salesOrderCode, |
| | | }), |
| | | }, |
| | | }, |
| | | ]), |
| | | { |
| | | fieldName: 'batchCode', |
| | | label: '批次', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '请输入批次', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'saleQuantity', |
| | | label: '销售数量', |
| | |
| | | onOpenChange(isOpen: boolean) { |
| | | if (!isOpen) { editingItemIndex.value = null; return; } |
| | | const d = itemModalApi.getData<AftersalesTicketApi.TicketItem | null>(); |
| | | itemFormApi.setState({ schema: useTicketItemFormSchema(formData.value?.customerId, undefined, [], itemFormApi) }); |
| | | itemFormApi.setState({ schema: useTicketItemFormSchema() }); |
| | | if (d) { itemFormApi.setValues(d as Record<string, unknown>); } else { itemFormApi.resetForm(); } |
| | | }, |
| | | }); |