import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import * as SupplierApi from '@/api/wms/supplier' import { Supplier } from '@/views/wms/basicDataManage/supplierManage/supplier/supplier.data' import * as PurchaseMainApi from '@/api/wms/purchaseMain' import * as PurchaseDetailApi from '@/api/wms/purchaseDetail' import { PurchaseDetail, PurchaseMain } from '../purchaseMain/purchaseMain.data' const { t } = useI18n() // 国际化 /** * @returns {Array} 要货计划主表 */ export const PurchasePlanMain = useCrudSchemas(reactive([ { label: '单据号', field: 'number', sort: 'custom', isForm: false, table: { width: 150, fixed: 'left' }, isSearch: true }, { label: '供应商代码', field: 'supplierCode', sort: 'custom', table: { width: 150 }, isSearch: true, form: { labelMessage: '影响明细中物品代码,需在供应商物品中维护', componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择供应商代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '供应商信息', // 查询弹窗标题 searchAllSchemas: Supplier.allSchemas, // 查询弹窗所需类 searchPage: SupplierApi.getSupplierPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } } }, { label: '时间窗口', field: 'timeWindow', sort: 'custom', table: { width: 150 }, isForm: false, }, { label: '仓库代码', field: 'warehouseCode', sort: 'custom', table: { width: 150 }, isForm: false, }, { label: '月台代码', field: 'dockCode', sort: 'custom', table: { width: 150 }, isForm: false, }, { label: '业务类型', field: 'businessType', sort: 'custom', table: { width: 150 }, isForm: false, form: { value: 'PurchaseReceipt', componentProps: { disabled: true } } }, { label: '状态', field: 'status', sort: 'custom', dictType: DICT_TYPE.PURCHASE_PLAN_STATUS, dictClass: 'string', isTable: true, isSearch: true, table: { width: 150 }, form: { value: '1', componentProps: { disabled: true } } }, { label: '开始时间', field: 'beginTime', isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } }, isForm: false, }, { label: '结束时间', field: 'endTime', isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } }, isForm: false, }, { label: '备注', field: 'remark', sort: 'custom', table: { width: 150 }, isTable: false, }, { label: '创建时间', field: 'createTime', isTable: true, isForm: false, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '创建者', field: 'creator', sort: 'custom', isForm: false, table: { width: 150 }, }, { label: '最后更新时间', field: 'updateTime', isTable: true, isForm: false, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '最后更新者', field: 'updater', sort: 'custom', isForm: false, table: { width: 150 }, }, { label: '是否可用', field: 'available', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, sort: 'custom', table: { width: 150 }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, isSearch: true, }, { label: '操作', field: 'action', isDetail: false, isForm: false, table: { width: 200, fixed: 'right' } } ])) //表单校验 export const PurchasePlanMainRules = reactive({ available: [ { required: true, message: '请选择是否可用', trigger: 'change' } ], status: [ { required: true, message: '请选择状态', trigger: 'change' } ], number: [ { required: true, message: '请输入单据号', trigger: 'blur' } ], businessType: [ { required: true, message: '请输入业务类型', trigger: 'blur' } ], }) /** * @returns {Array} 要货计划子表 */ export const PurchasePlanDetail = useCrudSchemas(reactive([ { label: '订单号', field: 'poNumber', sort: 'custom', table: { width: 150 }, tableForm: { isInpuFocusShow: true, searchListPlaceholder: '请选择订单号', searchField: 'number', searchTitle: '采购订单信息', searchAllSchemas: PurchaseMain.allSchemas, searchPage: PurchaseMainApi.getPurchaseMainPage, searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] }, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, searchListPlaceholder: '请选择订单号', searchField: 'number', searchTitle: '采购订单信息', searchAllSchemas: PurchaseMain.allSchemas, searchPage: PurchaseMainApi.getPurchaseMainPage, searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } } }, { label: '订单行', field: 'poLine', sort: 'custom', table: { width: 150 }, tableForm: { isInpuFocusShow: true, searchListPlaceholder: '请选择订单行', searchField: 'lineNumber', searchTitle: '采购订单信息', searchAllSchemas: PurchaseDetail.allSchemas, searchPage: PurchaseDetailApi.getPurchaseDetailPage, searchCondition: [{ key: 'number', value: 'poNumber', isMainValue: true }, { key: 'available', value: 'TRUE', isMainValue: false }] }, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, searchListPlaceholder: '请选择订单行', searchField: 'lineNumber', searchTitle: '采购订单信息', searchAllSchemas: PurchaseDetail.allSchemas, searchPage: PurchaseDetailApi.getPurchaseDetailPage, searchCondition: [{ key: 'number', value: 'number', isMainValue: true }, { key: 'available', value: 'TRUE', isMainValue: false }] } } }, { label: '单据号', field: 'number', sort: 'custom', isTableForm: false, table: { width: 150 }, form: { componentProps: { disabled: true } } }, { label: '物品代码', field: 'itemCode', sort: 'custom', table: { width: 150 }, form: { componentProps: { disabled: true } }, tableForm: { disabled: true } }, { label: '创建时间', field: 'createTime', formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, sort: 'custom', isTableForm: false, table: { width: 180 }, isForm: false, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '创建者', field: 'creator', sort: 'custom', isTableForm: false, table: { width: 150 }, isForm: false, }, { label: '已发货数量', field: 'shippedQty', sort: 'custom', table: { width: 150 }, isTableForm: false, isForm: false }, { label: '计划数量', field: 'planQty', sort: 'custom', table: { width: 150 }, tableForm: { type: 'InputNumber', min: 1, precision: 6 }, form: { component: 'InputNumber', componentProps: { min: 1, precision: 6 } } }, { label: '计量单位', field: 'uom', sort: 'custom', dictType: DICT_TYPE.UOM, dictClass: 'string', isSearch: true, isTable: true, table: { width: 150 }, tableForm: { type: 'Select' } }, { label: '最后更新者', field: 'updater', sort: 'custom', isTableForm: false, table: { width: 150 }, isForm: false, }, { label: '最后更新时间', field: 'updateTime', sort: 'custom', isTableForm: false, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 }, isForm: false, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '备注', field: 'remark', sort: 'custom', table: { width: 150 }, }, { label: '是否可用', field: 'available', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isSearch: true, isTable: true, sort: 'custom', table: { width: 150 }, tableForm: { type: 'Select', default: 'TRUE', inactiveValue: 'FALSE', activeValue: 'TRUE' }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } } }, { label: '操作', field: 'action', isDetail: false, isForm: false, table: { width: 150, fixed: 'right' }, isTableForm: false, } ])) //表单校验 export const PurchasePlanDetailRules = reactive({ // available: [ // { required: true, message: '请选择是否可用', trigger: 'change' } // ], poNumber: [ { required: true, message: '请选择采购订单号', trigger: 'change' } ], shippedQty: [ { required: true, message: '请输入已发货数量', trigger: 'blur' } ], uom: [ { required: true, message: '请选择计量单位', trigger: 'change' } ], planQty: [ { required: true, message: '请输入计划数量', trigger: 'blur' } ], })