| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- /**
- * 表单 Schema 注册(P2 写入能力)
- * - entity 形态模块:字段清单驱动通用表单
- * - bill 形态模块:通用单据表单(表头 + 明细行,对齐 DepotBillSaveDTO)
- * 未登记 schema 的模块隐藏新增入口,仅保留列表/详情只读能力。
- */
- import type { DictKind } from '@/api/modules/dict'
- export type FieldType = 'input' | 'number' | 'select' | 'date' | 'textarea' | 'switch'
- export interface FieldDef {
- /** 提交字段名 */
- key: string
- label: string
- type: FieldType
- required?: boolean
- placeholder?: string
- /** select 类型:字典来源 */
- dictKind?: DictKind
- /** select 类型:静态选项 */
- options?: { label: string; value: any }[]
- /** 默认值 */
- defaultValue?: any
- }
- /** entity 模块 schema(基础资料 + 商品资料) */
- export const ENTITY_SCHEMAS: Record<string, FieldDef[]> = {
- supplier: [
- { key: 'name', label: '供应商名称', type: 'input', required: true },
- { key: 'contacts', label: '联系人', type: 'input' },
- { key: 'phoneNum', label: '电话', type: 'input' },
- { key: 'telephone', label: '手机', type: 'input' },
- { key: 'email', label: '邮箱', type: 'input' },
- { key: 'address', label: '地址', type: 'textarea' },
- { key: 'taxNum', label: '税号', type: 'input' },
- { key: 'bankName', label: '开户行', type: 'input' },
- { key: 'accountNumber', label: '账号', type: 'input' },
- { key: 'taxRate', label: '税率(%)', type: 'number' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- customer: [
- { key: 'name', label: '客户名称', type: 'input', required: true },
- { key: 'contacts', label: '联系人', type: 'input' },
- { key: 'phoneNum', label: '电话', type: 'input' },
- { key: 'address', label: '地址', type: 'textarea' },
- { key: 'taxNum', label: '税号', type: 'input' },
- { key: 'taxRate', label: '税率(%)', type: 'number' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- member: [
- { key: 'name', label: '会员名称', type: 'input', required: true },
- { key: 'phoneNum', label: '手机号', type: 'input' },
- { key: 'address', label: '地址', type: 'textarea' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- depot: [
- { key: 'name', label: '仓库名称', type: 'input', required: true },
- {
- key: 'depotType', label: '仓库类型', type: 'select', required: true,
- options: [
- { label: '自有库', value: '自有库' },
- { label: '三方库', value: '三方库' }
- ]
- },
- { key: 'address', label: '地址', type: 'input' },
- { key: 'principal', label: '负责人', type: 'input' },
- { key: 'warehousing', label: '入库费', type: 'number' },
- { key: 'truckage', label: '运费', type: 'number' },
- { key: 'isDefault', label: '默认仓库', type: 'switch', defaultValue: 0 },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- account: [
- { key: 'name', label: '账户名称', type: 'input', required: true },
- { key: 'serialNo', label: '编号', type: 'input' },
- { key: 'initialAmount', label: '期初金额', type: 'number' },
- { key: 'isDefault', label: '默认账户', type: 'switch', defaultValue: 0 },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- person: [
- { key: 'name', label: '姓名', type: 'input', required: true },
- { key: 'type', label: '类型', type: 'input' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- inoutItem: [
- { key: 'name', label: '项目名称', type: 'input', required: true },
- { key: 'type', label: '类型(收入/支出)', type: 'input' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- category: [
- { key: 'name', label: '类别名称', type: 'input', required: true },
- { key: 'serialNo', label: '编号', type: 'input' },
- { key: 'sort', label: '排序', type: 'number' },
- { key: 'remark', label: '备注', type: 'textarea' }
- ],
- material: [
- { key: 'name', label: '商品名称', type: 'input', required: true },
- { key: 'barCode', label: '条码', type: 'input' },
- { key: 'categoryId', label: '商品类别', type: 'select', dictKind: 'category' },
- { key: 'unitId', label: '单位', type: 'select', dictKind: 'unit' },
- { key: 'standard', label: '规格', type: 'input' },
- { key: 'remark', label: '备注', type: 'textarea' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- unit: [
- { key: 'name', label: '单位名称', type: 'input', required: true },
- { key: 'basicUnit', label: '基本单位', type: 'input' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- interestRate: [
- { key: 'name', label: '名称', type: 'input', required: true },
- { key: 'rate', label: '日利率(%)', type: 'number', required: true },
- { key: 'remark', label: '备注', type: 'textarea' }
- ],
- contract: [
- { key: 'contractNo', label: '合同号', type: 'input', required: true },
- { key: 'contractName', label: '合同名称', type: 'input' },
- {
- key: 'contractType', label: '合同类型', type: 'select', required: true,
- options: [
- { label: '采购', value: 'PURCHASE' },
- { label: '销售', value: 'SALES' }
- ]
- },
- { key: 'organName', label: '往来单位', type: 'input' },
- { key: 'signDate', label: '签订日期', type: 'date' },
- { key: 'totalMoney', label: '合同金额', type: 'number' },
- { key: 'remark', label: '备注', type: 'textarea' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ],
- vehicle: [
- { key: 'vehicleNo', label: '车牌号', type: 'input', required: true },
- { key: 'driverName', label: '司机姓名', type: 'input' },
- { key: 'driverPhone', label: '联系电话', type: 'input' },
- { key: 'vehicleType', label: '车型', type: 'input' },
- { key: 'loadWeight', label: '载重(吨)', type: 'number' },
- { key: 'remark', label: '备注', type: 'textarea' },
- { key: 'enabled', label: '启用', type: 'switch', defaultValue: 1 }
- ]
- }
- /** 通用单据表头 schema(进销存单据:采购/销售/零售/仓库域,对齐 DepotBillSaveDTO) */
- export const BILL_HEAD_FIELDS: FieldDef[] = [
- { key: 'organId', label: '往来单位', type: 'select', required: true },
- { key: 'accountId', label: '结算账户', type: 'select', dictKind: 'account' },
- { key: 'operTime', label: '单据日期', type: 'date', required: true },
- { key: 'discount', label: '折扣率(%)', type: 'number' },
- { key: 'otherMoney', label: '其它费用', type: 'number' },
- { key: 'remark', label: '备注', type: 'textarea' }
- ]
- /** 单据明细行字段(含钢材追溯字段:炉号/批号/合同号/规格 + 收发重量 + 运费) */
- export interface BillItemDraft {
- materialId?: string
- materialName?: string
- barCode?: string
- materialUnit?: string
- depotId?: string
- depotName?: string
- operNumber?: number
- unitPrice?: number
- allPrice?: number
- furnaceNo?: string
- batchNo?: string
- contractNo?: string
- standard?: string
- shipWeight?: number
- recvWeight?: number
- freightUnitPrice?: number
- freightFee?: number
- remark?: string
- }
- /** 需要明细行的单据模块(DepotBill 系) */
- export const BILL_ITEM_MODULES = new Set([
- 'purchaseApply', 'purchaseOrder', 'purchaseIn', 'purchaseBack',
- 'salesOrder', 'salesOut', 'salesBack',
- 'retailOut', 'retailBack',
- 'otherIn', 'otherOut', 'allocation', 'assemble', 'disassemble',
- 'produceIn', 'checkEnter', 'replay',
- 'productionOrder'
- ])
- export function getEntitySchema(moduleKey: string): FieldDef[] | undefined {
- return ENTITY_SCHEMAS[moduleKey]
- }
- /** 单据表头差异化扩展字段(在通用 BILL_HEAD_FIELDS 后追加;缺省模块回退空数组) */
- export const BILL_HEAD_EXT_FIELDS: Record<string, FieldDef[]> = {
- purchaseOrder: [
- { key: 'contractNo', label: '合同号', type: 'select', dictKind: 'contract' },
- { key: 'contractOrderNo', label: '合同订单号', type: 'input' }
- ],
- purchaseIn: [
- { key: 'contractNo', label: '合同号', type: 'select', dictKind: 'contract' },
- { key: 'contractOrderNo', label: '合同订单号', type: 'input' },
- { key: 'paybackDays', label: '回款天数', type: 'number' },
- { key: 'interest', label: '利息', type: 'number' },
- { key: 'storageUnitPrice', label: '仓储单价', type: 'number' },
- { key: 'storageFee', label: '仓储费', type: 'number' },
- { key: 'vehicleNo', label: '车牌号', type: 'select', dictKind: 'vehicle' },
- { key: 'driverName', label: '司机姓名', type: 'input' },
- { key: 'driverPhone', label: '联系电话', type: 'input' }
- ],
- salesOut: [
- { key: 'contractNo', label: '合同号', type: 'select', dictKind: 'contract' },
- { key: 'invoiceNo', label: '发票', type: 'input' },
- { key: 'paybackDate', label: '回款日期', type: 'date' },
- { key: 'paybackMoney', label: '回款金额', type: 'number' },
- { key: 'vehicleNo', label: '车牌号', type: 'select', dictKind: 'vehicle' },
- { key: 'driverName', label: '司机姓名', type: 'input' },
- { key: 'driverPhone', label: '联系电话', type: 'input' }
- ]
- }
- export function getBillHeadExtFields(moduleKey: string): FieldDef[] {
- return BILL_HEAD_EXT_FIELDS[moduleKey] || []
- }
|