|
@@ -8,6 +8,9 @@ import type { DictKind } from '@/api/modules/dict'
|
|
|
/** 页面形态:bill=单据(头+明细行) / entity=基础资料 / report=只读报表 */
|
|
/** 页面形态:bill=单据(头+明细行) / entity=基础资料 / report=只读报表 */
|
|
|
export type ModuleShape = 'bill' | 'entity' | 'report'
|
|
export type ModuleShape = 'bill' | 'entity' | 'report'
|
|
|
|
|
|
|
|
|
|
+/** 单据状态机:审核流 / 草稿定稿 / 生产单三态 */
|
|
|
|
|
+export type StatusModel = 'audit' | 'draftConfirm' | 'production'
|
|
|
|
|
+
|
|
|
export interface ModuleConfig {
|
|
export interface ModuleConfig {
|
|
|
/** 唯一 key(页面 ?module= 参数) */
|
|
/** 唯一 key(页面 ?module= 参数) */
|
|
|
key: string
|
|
key: string
|
|
@@ -30,6 +33,10 @@ export interface ModuleConfig {
|
|
|
hasItems?: boolean
|
|
hasItems?: boolean
|
|
|
/** 仅列表无详情(报表默认 true;serialNumber 等按模块声明) */
|
|
/** 仅列表无详情(报表默认 true;serialNumber 等按模块声明) */
|
|
|
listOnly?: boolean
|
|
listOnly?: boolean
|
|
|
|
|
+ /** 单据状态机;缺省按审核流 */
|
|
|
|
|
+ statusModel?: StatusModel
|
|
|
|
|
+ /** 定稿通过保存 status=1(采购入库/销售出库),否则走 POST confirm/{id} */
|
|
|
|
|
+ finalizeViaSave?: boolean
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const MODULES: ModuleConfig[] = [
|
|
export const MODULES: ModuleConfig[] = [
|
|
@@ -44,7 +51,7 @@ export const MODULES: ModuleConfig[] = [
|
|
|
|
|
|
|
|
// ================= 商品资料 packageMaterial(7) =================
|
|
// ================= 商品资料 packageMaterial(7) =================
|
|
|
{ key: 'category', title: '商品类别', apiPrefix: '/material/category/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:category:list', searchKey: 'name', dictKind: 'category' },
|
|
{ key: 'category', title: '商品类别', apiPrefix: '/material/category/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:category:list', searchKey: 'name', dictKind: 'category' },
|
|
|
- { key: 'material', title: '商品', apiPrefix: '/material/info/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:info:list', searchKey: 'name' },
|
|
|
|
|
|
|
+ { key: 'material', title: '商品信息', apiPrefix: '/material/info/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:info:list', searchKey: 'name' },
|
|
|
{ key: 'unit', title: '单位', apiPrefix: '/material/unit/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:unit:list', searchKey: 'name', dictKind: 'unit' },
|
|
{ key: 'unit', title: '单位', apiPrefix: '/material/unit/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:unit:list', searchKey: 'name', dictKind: 'unit' },
|
|
|
{ key: 'attribute', title: '多属性', apiPrefix: '/material/attribute/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:attribute:list', searchKey: 'attributeName' },
|
|
{ key: 'attribute', title: '多属性', apiPrefix: '/material/attribute/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:attribute:list', searchKey: 'attributeName' },
|
|
|
{ key: 'property', title: '多单位', apiPrefix: '/material/property/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:property:list', searchKey: 'nativeName' },
|
|
{ key: 'property', title: '多单位', apiPrefix: '/material/property/v1', pkg: 'packageMaterial', shape: 'entity', permission: 'material:property:list', searchKey: 'nativeName' },
|
|
@@ -55,12 +62,12 @@ export const MODULES: ModuleConfig[] = [
|
|
|
{ key: 'contract', title: '合同管理', apiPrefix: '/purchase/contract/v1', pkg: 'packagePurchase', shape: 'entity', permission: 'purchase:contract:list', searchKey: 'contractNo', dictKind: 'contract' },
|
|
{ key: 'contract', title: '合同管理', apiPrefix: '/purchase/contract/v1', pkg: 'packagePurchase', shape: 'entity', permission: 'purchase:contract:list', searchKey: 'contractNo', dictKind: 'contract' },
|
|
|
{ key: 'purchaseApply', title: '请购单', apiPrefix: '/purchase/apply/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:apply:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
{ key: 'purchaseApply', title: '请购单', apiPrefix: '/purchase/apply/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:apply:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
{ key: 'purchaseOrder', title: '采购订单', apiPrefix: '/purchase/order/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:order:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'convert'], hasItems: true },
|
|
{ key: 'purchaseOrder', title: '采购订单', apiPrefix: '/purchase/order/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:order:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'convert'], hasItems: true },
|
|
|
- { key: 'purchaseIn', title: '采购入库', apiPrefix: '/purchase/in/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:in:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
|
|
+ { key: 'purchaseIn', title: '采购入库', apiPrefix: '/purchase/in/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:in:list', searchKey: 'billNo', actions: ['confirm'], hasItems: true, statusModel: 'draftConfirm', finalizeViaSave: true },
|
|
|
{ key: 'purchaseBack', title: '采购退货', apiPrefix: '/purchase/back/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:back:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
{ key: 'purchaseBack', title: '采购退货', apiPrefix: '/purchase/back/v1', pkg: 'packagePurchase', shape: 'bill', permission: 'purchase:back:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
|
|
|
// ================= 销售 packageSales(3) =================
|
|
// ================= 销售 packageSales(3) =================
|
|
|
{ key: 'salesOrder', title: '销售订单', apiPrefix: '/sales/order/v1', pkg: 'packageSales', shape: 'bill', permission: 'sales:order:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'convert'], hasItems: true },
|
|
{ key: 'salesOrder', title: '销售订单', apiPrefix: '/sales/order/v1', pkg: 'packageSales', shape: 'bill', permission: 'sales:order:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'convert'], hasItems: true },
|
|
|
- { key: 'salesOut', title: '销售出库', apiPrefix: '/sales/out/v1', pkg: 'packageSales', shape: 'bill', permission: 'sales:out:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'lock', 'unlock', 'finish'], hasItems: true },
|
|
|
|
|
|
|
+ { key: 'salesOut', title: '销售出库', apiPrefix: '/sales/out/v1', pkg: 'packageSales', shape: 'bill', permission: 'sales:out:list', searchKey: 'billNo', actions: ['confirm', 'lock', 'unlock'], hasItems: true, statusModel: 'draftConfirm', finalizeViaSave: true },
|
|
|
{ key: 'salesBack', title: '销售退货', apiPrefix: '/sales/back/v1', pkg: 'packageSales', shape: 'bill', permission: 'sales:back:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
{ key: 'salesBack', title: '销售退货', apiPrefix: '/sales/back/v1', pkg: 'packageSales', shape: 'bill', permission: 'sales:back:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
|
|
|
// ================= 零售 packageRetail(2) =================
|
|
// ================= 零售 packageRetail(2) =================
|
|
@@ -68,9 +75,9 @@ export const MODULES: ModuleConfig[] = [
|
|
|
{ key: 'retailBack', title: '零售退货', apiPrefix: '/retail/back/v1', pkg: 'packageRetail', shape: 'bill', permission: 'retail:back:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
{ key: 'retailBack', title: '零售退货', apiPrefix: '/retail/back/v1', pkg: 'packageRetail', shape: 'bill', permission: 'retail:back:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
|
|
|
// ================= 仓库 packageWarehouse(8) =================
|
|
// ================= 仓库 packageWarehouse(8) =================
|
|
|
- { key: 'otherIn', title: '其他入库', apiPrefix: '/warehouse/other-in/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:otherIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
- { key: 'otherOut', title: '其他出库', apiPrefix: '/warehouse/other-out/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:otherOut:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
- { key: 'allocation', title: '调拨单', apiPrefix: '/warehouse/allocation/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:allocation:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
|
|
+ { key: 'otherIn', title: '其它入库', apiPrefix: '/warehouse/other-in/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:otherIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true, statusModel: 'audit' },
|
|
|
|
|
+ { key: 'otherOut', title: '其它出库', apiPrefix: '/warehouse/other-out/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:otherOut:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
|
|
+ { key: 'allocation', title: '调拨出库', apiPrefix: '/warehouse/allocation/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:allocation:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true, statusModel: 'audit' },
|
|
|
{ key: 'assemble', title: '组装单', apiPrefix: '/warehouse/assemble/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:assemble:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
{ key: 'assemble', title: '组装单', apiPrefix: '/warehouse/assemble/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:assemble:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
{ key: 'disassemble', title: '拆卸单', apiPrefix: '/warehouse/disassemble/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:disassemble:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
{ key: 'disassemble', title: '拆卸单', apiPrefix: '/warehouse/disassemble/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:disassemble:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
|
{ key: 'produceIn', title: '生产入库', apiPrefix: '/warehouse/produce-in/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:produceIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
{ key: 'produceIn', title: '生产入库', apiPrefix: '/warehouse/produce-in/v1', pkg: 'packageWarehouse', shape: 'bill', permission: 'warehouse:produceIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], hasItems: true },
|
|
@@ -80,24 +87,24 @@ export const MODULES: ModuleConfig[] = [
|
|
|
// ================= 财务 packageFinance(8) =================
|
|
// ================= 财务 packageFinance(8) =================
|
|
|
{ key: 'itemIn', title: '收入单', apiPrefix: '/finance/item-in/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:itemIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
{ key: 'itemIn', title: '收入单', apiPrefix: '/finance/item-in/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:itemIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
|
{ key: 'itemOut', title: '支出单', apiPrefix: '/finance/item-out/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:itemOut:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
{ key: 'itemOut', title: '支出单', apiPrefix: '/finance/item-out/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:itemOut:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
|
- { key: 'moneyIn', title: '收款单', apiPrefix: '/finance/money-in/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:moneyIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
|
|
|
- { key: 'moneyOut', title: '付款单', apiPrefix: '/finance/money-out/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:moneyOut:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
|
|
|
|
|
+ { key: 'moneyIn', title: '收款单', apiPrefix: '/finance/money-in/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:moneyIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], statusModel: 'audit' },
|
|
|
|
|
+ { key: 'moneyOut', title: '付款单', apiPrefix: '/finance/money-out/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:moneyOut:list', searchKey: 'billNo', actions: ['audit', 'unaudit'], statusModel: 'audit' },
|
|
|
{ key: 'giro', title: '转账单', apiPrefix: '/finance/giro/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:giro:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
{ key: 'giro', title: '转账单', apiPrefix: '/finance/giro/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:giro:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
|
{ key: 'advanceIn', title: '收预付款', apiPrefix: '/finance/advance-in/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:advanceIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
{ key: 'advanceIn', title: '收预付款', apiPrefix: '/finance/advance-in/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:advanceIn:list', searchKey: 'billNo', actions: ['audit', 'unaudit'] },
|
|
|
- { key: 'interestRate', title: '采购日利率', apiPrefix: '/finance/interest-rate/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:interestRate:list', actions: ['calc'] },
|
|
|
|
|
- { key: 'settlement', title: '结算单', apiPrefix: '/finance/settlement/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:settlement:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'fromBill', 'confirm'] },
|
|
|
|
|
|
|
+ { key: 'interestRate', title: '采购日利率', apiPrefix: '/finance/interest-rate/v1', pkg: 'packageFinance', shape: 'entity', permission: 'finance:interestRate:list', actions: ['calc'] },
|
|
|
|
|
+ { key: 'settlement', title: '结算单', apiPrefix: '/finance/settlement/v1', pkg: 'packageFinance', shape: 'bill', permission: 'finance:settlement:list', searchKey: 'billNo', actions: ['confirm'], statusModel: 'draftConfirm' },
|
|
|
|
|
|
|
|
// ================= 生产与物流 packageProductionLogistics(3) =================
|
|
// ================= 生产与物流 packageProductionLogistics(3) =================
|
|
|
- { key: 'productionOrder', title: '生产单', apiPrefix: '/production/order/v1', pkg: 'packageProductionLogistics', shape: 'bill', permission: 'production:order:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'confirm', 'finish'], hasItems: true },
|
|
|
|
|
|
|
+ { key: 'productionOrder', title: '生产单', apiPrefix: '/production/order/v1', pkg: 'packageProductionLogistics', shape: 'bill', permission: 'production:order:list', searchKey: 'billNo', actions: ['confirm', 'finish'], hasItems: true, statusModel: 'production' },
|
|
|
{ key: 'vehicle', title: '车辆管理', apiPrefix: '/logistics/vehicle/v1', pkg: 'packageProductionLogistics', shape: 'entity', permission: 'logistics:vehicle:list', searchKey: 'vehicleNo', dictKind: 'vehicle' },
|
|
{ key: 'vehicle', title: '车辆管理', apiPrefix: '/logistics/vehicle/v1', pkg: 'packageProductionLogistics', shape: 'entity', permission: 'logistics:vehicle:list', searchKey: 'vehicleNo', dictKind: 'vehicle' },
|
|
|
- { key: 'logisticsFee', title: '物流费用', apiPrefix: '/logistics/fee/v1', pkg: 'packageProductionLogistics', shape: 'bill', permission: 'logistics:fee:list', searchKey: 'billNo', actions: ['audit', 'unaudit', 'fromSales', 'confirm'] },
|
|
|
|
|
|
|
+ { key: 'logisticsFee', title: '物流费用', apiPrefix: '/logistics/fee/v1', pkg: 'packageProductionLogistics', shape: 'bill', permission: 'logistics:fee:list', searchKey: 'billNo', actions: ['confirm'], statusModel: 'draftConfirm' },
|
|
|
|
|
|
|
|
// ================= 报表 packageReport(14,只读) =================
|
|
// ================= 报表 packageReport(14,只读) =================
|
|
|
{ key: 'stock', title: '库存报表', apiPrefix: '/report/stock/v1', pkg: 'packageReport', shape: 'report', permission: 'report:stock:list', searchKey: 'materialName' },
|
|
{ key: 'stock', title: '库存报表', apiPrefix: '/report/stock/v1', pkg: 'packageReport', shape: 'report', permission: 'report:stock:list', searchKey: 'materialName' },
|
|
|
{ key: 'inOutStock', title: '出入库汇总', apiPrefix: '/report/in-out-stock/v1', pkg: 'packageReport', shape: 'report', permission: 'report:inOutStock:list', searchKey: 'materialName' },
|
|
{ key: 'inOutStock', title: '出入库汇总', apiPrefix: '/report/in-out-stock/v1', pkg: 'packageReport', shape: 'report', permission: 'report:inOutStock:list', searchKey: 'materialName' },
|
|
|
{ key: 'accountReport', title: '账户报表', apiPrefix: '/report/account/v1', pkg: 'packageReport', shape: 'report', permission: 'report:account:list' },
|
|
{ key: 'accountReport', title: '账户报表', apiPrefix: '/report/account/v1', pkg: 'packageReport', shape: 'report', permission: 'report:account:list' },
|
|
|
{ key: 'statement', title: '往来对账', apiPrefix: '/report/statement/v1', pkg: 'packageReport', shape: 'report', permission: 'report:statement:list' },
|
|
{ key: 'statement', title: '往来对账', apiPrefix: '/report/statement/v1', pkg: 'packageReport', shape: 'report', permission: 'report:statement:list' },
|
|
|
- { key: 'debtInvoice', title: '欠款欠票', apiPrefix: '/report/debt-invoice/v1', pkg: 'packageReport', shape: 'report', permission: 'report:debtInvoice:list' },
|
|
|
|
|
|
|
+ { key: 'debtInvoice', title: '欠款欠票', apiPrefix: '/report/debt-invoice/v1', pkg: 'packageReport', shape: 'report', permission: 'report:debtInvoice:list', searchKey: 'billNo' },
|
|
|
{ key: 'tradeBuy', title: '采购统计', apiPrefix: '/report/trade/v1/buy', pkg: 'packageReport', shape: 'report', permission: 'report:trade:list', searchKey: 'materialName' },
|
|
{ key: 'tradeBuy', title: '采购统计', apiPrefix: '/report/trade/v1/buy', pkg: 'packageReport', shape: 'report', permission: 'report:trade:list', searchKey: 'materialName' },
|
|
|
{ key: 'tradeSale', title: '销售统计', apiPrefix: '/report/trade/v1/sale', pkg: 'packageReport', shape: 'report', permission: 'report:trade:list', searchKey: 'materialName' },
|
|
{ key: 'tradeSale', title: '销售统计', apiPrefix: '/report/trade/v1/sale', pkg: 'packageReport', shape: 'report', permission: 'report:trade:list', searchKey: 'materialName' },
|
|
|
{ key: 'tradeRetail', title: '零售统计', apiPrefix: '/report/trade/v1/retail', pkg: 'packageReport', shape: 'report', permission: 'report:trade:list', searchKey: 'materialName' },
|
|
{ key: 'tradeRetail', title: '零售统计', apiPrefix: '/report/trade/v1/retail', pkg: 'packageReport', shape: 'report', permission: 'report:trade:list', searchKey: 'materialName' },
|
|
@@ -142,19 +149,65 @@ export const DOMAIN_GROUPS: DomainGroup[] = [
|
|
|
{ title: '报表中心', pkg: 'packageReport', icon: '📊', modules: getModulesByPkg('packageReport') }
|
|
{ title: '报表中心', pkg: 'packageReport', icon: '📊', modules: getModulesByPkg('packageReport') }
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
-/** 单据状态映射(0 未审核 / 1 已审核 / 2 已完成) */
|
|
|
|
|
|
|
+export function getStatusModel(module: ModuleConfig): StatusModel {
|
|
|
|
|
+ return module.statusModel || 'audit'
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 单据状态映射(审核流默认) */
|
|
|
export const BILL_STATUS_TEXT: Record<number, string> = {
|
|
export const BILL_STATUS_TEXT: Record<number, string> = {
|
|
|
0: '未审核',
|
|
0: '未审核',
|
|
|
1: '已审核',
|
|
1: '已审核',
|
|
|
2: '已完成'
|
|
2: '已完成'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const DRAFT_STATUS_TEXT: Record<number, string> = {
|
|
|
|
|
+ 0: '草稿',
|
|
|
|
|
+ 1: '定稿'
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const PRODUCTION_STATUS_TEXT: Record<number, string> = {
|
|
|
|
|
+ 0: '草稿',
|
|
|
|
|
+ 1: '进行中',
|
|
|
|
|
+ 2: '完成'
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export const BILL_STATUS_TYPE: Record<number, 'warning' | 'success' | 'primary'> = {
|
|
export const BILL_STATUS_TYPE: Record<number, 'warning' | 'success' | 'primary'> = {
|
|
|
0: 'warning',
|
|
0: 'warning',
|
|
|
1: 'success',
|
|
1: 'success',
|
|
|
2: 'primary'
|
|
2: 'primary'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+export function statusTextOf(module: ModuleConfig, status: number): string {
|
|
|
|
|
+ const model = getStatusModel(module)
|
|
|
|
|
+ if (model === 'draftConfirm') return DRAFT_STATUS_TEXT[status] ?? ''
|
|
|
|
|
+ if (model === 'production') return PRODUCTION_STATUS_TEXT[status] ?? ''
|
|
|
|
|
+ return BILL_STATUS_TEXT[status] ?? ''
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function statusOptionsOf(module: ModuleConfig): { label: string; value: number | null }[] {
|
|
|
|
|
+ const model = getStatusModel(module)
|
|
|
|
|
+ if (model === 'draftConfirm') {
|
|
|
|
|
+ return [
|
|
|
|
|
+ { label: '全部', value: null },
|
|
|
|
|
+ { label: '草稿', value: 0 },
|
|
|
|
|
+ { label: '定稿', value: 1 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ if (model === 'production') {
|
|
|
|
|
+ return [
|
|
|
|
|
+ { label: '全部', value: null },
|
|
|
|
|
+ { label: '草稿', value: 0 },
|
|
|
|
|
+ { label: '进行中', value: 1 },
|
|
|
|
|
+ { label: '完成', value: 2 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ return [
|
|
|
|
|
+ { label: '全部', value: null },
|
|
|
|
|
+ { label: '未审核', value: 0 },
|
|
|
|
|
+ { label: '已审核', value: 1 }
|
|
|
|
|
+ ]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/** 状态机动作文案 */
|
|
/** 状态机动作文案 */
|
|
|
export const ACTION_TEXT: Record<string, string> = {
|
|
export const ACTION_TEXT: Record<string, string> = {
|
|
|
audit: '审核',
|
|
audit: '审核',
|
|
@@ -166,30 +219,52 @@ export const ACTION_TEXT: Record<string, string> = {
|
|
|
unlock: '解锁',
|
|
unlock: '解锁',
|
|
|
fromBill: '从单据生成',
|
|
fromBill: '从单据生成',
|
|
|
fromSales: '从销售出库生成',
|
|
fromSales: '从销售出库生成',
|
|
|
- calc: '计息预览'
|
|
|
|
|
|
|
+ calc: '计息试算'
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function actionLabel(module: ModuleConfig, action: string): string {
|
|
|
|
|
+ if (getStatusModel(module) === 'production') {
|
|
|
|
|
+ if (action === 'confirm') return '开始加工'
|
|
|
|
|
+ if (action === 'finish') return '完工'
|
|
|
|
|
+ }
|
|
|
|
|
+ return ACTION_TEXT[action] || action
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export interface ActionContext {
|
|
|
|
|
+ locked?: string | number
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function isLocked(ctx?: ActionContext): boolean {
|
|
|
|
|
+ return String(ctx?.locked ?? '0') === '1'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 按单据 status 判定可执行动作(模板页渲染操作条的依据) */
|
|
/** 按单据 status 判定可执行动作(模板页渲染操作条的依据) */
|
|
|
-export function availableActions(module: ModuleConfig, status: number): CrudAction[] {
|
|
|
|
|
|
|
+export function availableActions(
|
|
|
|
|
+ module: ModuleConfig,
|
|
|
|
|
+ status: number,
|
|
|
|
|
+ ctx?: ActionContext
|
|
|
|
|
+): CrudAction[] {
|
|
|
const all = module.actions || []
|
|
const all = module.actions || []
|
|
|
|
|
+ const model = getStatusModel(module)
|
|
|
return all.filter((action) => {
|
|
return all.filter((action) => {
|
|
|
switch (action) {
|
|
switch (action) {
|
|
|
case 'audit':
|
|
case 'audit':
|
|
|
- return status === 0
|
|
|
|
|
|
|
+ return model === 'audit' && status === 0
|
|
|
case 'unaudit':
|
|
case 'unaudit':
|
|
|
- return status === 1
|
|
|
|
|
|
|
+ return model === 'audit' && status === 1
|
|
|
case 'convert':
|
|
case 'convert':
|
|
|
return status === 1
|
|
return status === 1
|
|
|
case 'finish':
|
|
case 'finish':
|
|
|
- return status === 1
|
|
|
|
|
|
|
+ return model === 'production' ? status === 1 : status === 1
|
|
|
case 'confirm':
|
|
case 'confirm':
|
|
|
- return status < 2
|
|
|
|
|
|
|
+ return (model === 'draftConfirm' || model === 'production') && status === 0
|
|
|
case 'lock':
|
|
case 'lock':
|
|
|
- return status === 0 || status === 1
|
|
|
|
|
|
|
+ return status === 1 && !isLocked(ctx)
|
|
|
case 'unlock':
|
|
case 'unlock':
|
|
|
- return status === 0 || status === 1
|
|
|
|
|
|
|
+ return isLocked(ctx)
|
|
|
case 'fromBill':
|
|
case 'fromBill':
|
|
|
case 'fromSales':
|
|
case 'fromSales':
|
|
|
|
|
+ return false
|
|
|
case 'calc':
|
|
case 'calc':
|
|
|
return true
|
|
return true
|
|
|
default:
|
|
default:
|