import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter,dateFormatter2 } 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' import {getPurchaseDetailPagePoNumber} from "@/api/wms/purchaseDetail"; import * as ItembasicApi from '@/api/wms/itembasic' import {Itembasic} from "@/views/wms/basicDataManage/itemManage/itembasic/itembasic.data"; const { t } = useI18n() // 国际化 /** * @returns {Array} 要货计划主表 */ export const PurchasePlanMain = useCrudSchemas(reactive([ { label: '供应商代码', field: 'supplierCode', sort: 'custom', table: { width: 150, fixed: 'left' }, isSearch: true, sortTableDefault:1, sortSearchDefault:1, form: { labelMessage: '影响明细中物料代码,需在供应商物料中维护', componentProps: { enterSearch: true, isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择供应商代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '供应商信息', // 查询弹窗标题 searchAllSchemas: Supplier.allSchemas, // 查询弹窗所需类 searchPage: SupplierApi.getSupplierPageSCP, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }], verificationParams: [{ key: 'code', action: '==', value: '', isMainValue: false, isSearch: 'true', isFormModel: true }], // 失去焦点校验参数 } }, search: { componentProps: { enterSearch: true, isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择供应商代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '供应商信息', // 查询弹窗标题 searchAllSchemas: Supplier.allSchemas, // 查询弹窗所需类 searchPage: SupplierApi.getSupplierPageSCP, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }] } } }, //仅是主列表页面的筛选搜索条件 { label: '送达日期', field: 'deliveryDate', sort: 'custom', isDetail:false, isTable: false, isForm:false, isTableForm:false, isSearch:true, sortSearchDefault:3, formatter: dateFormatter2, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', // type: 'datetimerange', type: 'daterange', defaultTime: [new Date('1 '), new Date('1 ')] } }, }, { label: '要货计划单号', field: 'number', sort: 'custom', isForm: false, table: { width: 180, }, sortTableDefault:8, sortSearchDefault:4, isSearch: true }, { label: '采购订单', field: 'poNumber', sort: 'custom', table: { width: 150 }, isTable:false, form: { // labelMessage: '信息提示说明!!!', componentProps: { enterSearch:true, dialogWidth:'1085px',//搜索出来弹窗的宽度 isSearchList: true, searchListPlaceholder: '请选择采购订单', searchField: 'number', searchTitle: '采购订单信息', searchAllSchemas: PurchaseMain.allSchemas, searchPage: PurchaseMainApi.getPurchaseMainPage, searchCondition: [{ key: 'type', value: 'SCHEDULE', isMainValue: false },{ key: 'available', value: 'TRUE', isMainValue: false },{ key: 'supplierCode', value: 'supplierCode', message: '请填写供应商代码!', isMainValue: true },{ key: 'status', value: 2, isMainValue: false }], verificationParams: [{ key: 'number', action: '==', value: '', isMainValue: false, isSearch: 'true', isFormModel: true }], // 失去焦点校验参数 } } }, { label: '送达日期', field: 'deliveryDate', table: { width: 180 }, formatter: dateFormatter2, sortTableDefault:2, form: { component: 'DatePicker', componentProps: { type: 'date', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } }, detail: { dateFormat: 'YYYY-MM-DD' }, }, { label: '采购订单类型', field: 'type', sort: 'custom', dictType: DICT_TYPE.PURCHASE_ORDER_TYPE, dictClass: 'string', isTable: true, isForm:true, table: { width: 150 }, form: { // labelMessage: '信息提示说明!!!', componentProps: { disabled: true } } }, { label: '收货人', field: 'contacts', isTable:false, table: { width: 150 }, form: { componentProps: { disabled: false } } }, { label: '联系电话', field: 'phone', isTable:false, table: { width: 150 }, form: { componentProps: { disabled: false } } }, { label: '时间窗口', field: 'timeWindow', table: { width: 150 }, isTable:false, isForm: false }, { label: '开始时间', field: 'beginTime', sort: 'custom', table: { width: 150 }, isTable:false, isForm:false, isDetail:false, form:{ component:"TimePicker", componentProps: { format:"HH:mm", } } }, { label: '结束时间', field: 'endTime', sort: 'custom', table: { width: 150 }, isTable:false, isForm:false, isDetail:false, form:{ component:"TimePicker", componentProps: { format:"HH:mm", } } }, { label: '仓库代码', field: 'warehouseCode', sort: 'custom', table: { width: 150 }, isTable:false, isForm: false, }, { label: '月台代码', field: 'dockCode', sort: 'custom', table: { width: 150 }, isForm: false, isTable:false, }, { label: '业务类型', field: 'businessType', sort: 'custom', table: { width: 150 }, isForm: false, isTable:false, form: { value: 'PurchaseReceipt', componentProps: { disabled: true } } }, { label: '状态', field: 'status', sort: 'custom', dictType: DICT_TYPE.PURCHASE_PLAN_STATUS, dictClass: 'string', isTable: true, isForm:false, isSearch: true, table: { width: 150 }, sortTableDefault:13, sortSearchDefault:6, search:{ value:[], componentProps: { multiple:true } }, form: { value: '1', componentProps: { disabled: true } } }, // { // label: '自动发布', // field: 'autoPublish', // dictType: DICT_TYPE.TRUE_FALSE, // dictClass: 'string', // isTable: true, // sort: 'custom', // table: { // width: 150 // }, // form: { // component: 'Switch', // value: "TRUE", // componentProps: { // inactiveValue: 'FALSE', // activeValue: 'TRUE' // } // } // }, // { // label: '自动接收', // field: 'autoAccept', // dictType: DICT_TYPE.TRUE_FALSE, // dictClass: 'string', // isTable: true, // sort: 'custom', // table: { // width: 150 // }, // form: { // component: 'Switch', // value: "TRUE", // componentProps: { // inactiveValue: 'FALSE', // activeValue: 'TRUE' // } // } // }, // { // 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', // disabled: true // } // }, // isSearch: true, // }, { label: '创建者', field: 'creator', sort: 'custom', isForm: false, isTable:false, table: { width: 150 }, }, { 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', } }, isSearch: true, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, }, { label: '最后更新者', field: 'updater', sort: 'custom', isForm: false, isTable:false, table: { width: 150 }, }, { label: '最后更新时间', field: 'updateTime', isTable: false, 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: 'remark', sort: 'custom', table: { width: 150 }, isTable: false, isForm:false, isDetail:false, }, { label: '操作', field: 'action', isDetail: false, isForm: false, table: { width: 250, fixed: 'right' } } ])) //表单校验 export const PurchasePlanMainRules = reactive({ available: [ { required: true, message: '请选择是否可用', trigger: 'change' } ], supplierCode: [ { required: true, message: '请选择供应商代码', trigger: 'change' } ], poNumber: [ { required: true, message: '请选择采购订单号', trigger: 'change' } ], deliveryDate: [ { required: true, message: '请选择送达时间', trigger: 'change' } ], status: [ { required: true, message: '请选择状态', trigger: 'change' } ], number: [ { required: true, message: '请输入单据号', trigger: 'blur' } ], businessType: [ { required: true, message: '请输入业务类型', trigger: 'blur' } ], remark: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], }) /** * @returns {Array} 要货计划子表 */ export const PurchasePlanDetail = useCrudSchemas(reactive([ { label: '要货计划单号', field: 'number', sort: 'custom', isTableForm: false, hiddenInMain:true, table: { width: 180 }, form: { componentProps: { disabled: true } } }, { label: '采购订单号', field: 'poNumber', isSearch:true, isTable:true, sortTableDefault:9, sortSearchDefault:2, isForm:false, isTableForm:false, table: { width: 150 }, search: { // labelMessage: '信息提示说明!!!', componentProps: { dialogWidth:'1085px',//搜索出来弹窗的宽度 isSearchList: true, enterSearch: true, searchListPlaceholder: '请选择采购订单', searchField: 'number', searchTitle: '采购订单信息', searchAllSchemas: PurchaseMain.allSchemas, searchPage: PurchaseMainApi.getPurchaseMainPage, searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false },{ key: 'supplierCode', value: 'supplierCode', message: '请填写供应商代码!', isMainValue: true },{ key: 'status', value: 2, isMainValue: false }] } } }, // { // label: '订单号', // field: 'poNumber', // sort: 'custom', // table: { // width: 180 // }, // hiddenInMain:true, // isTableForm:false, // tableForm: { // disabled: true, // isInpuFocusShow: false, // searchListPlaceholder: '请选择订单号', // searchField: 'number', // searchTitle: '采购订单信息', // searchAllSchemas: PurchaseMain.allSchemas, // searchPage: PurchaseMainApi.getPurchaseMainPage, // searchCondition: [{ // key: 'available', // value: 'TRUE', // isMainValue: false // }, { // key: 'supplierCode', // value: 'supplierCode', // message: '请填写供应商代码!', // isMainValue: true // }, { // key: 'status', // value: 2, // isMainValue: false // } // ] // }, // form: { // // labelMessage: '信息提示说明!!!', // componentProps: { // disabled: true, // isSearchList: false, // searchListPlaceholder: '请选择订单号', // searchField: 'number', // searchTitle: '采购订单信息', // searchAllSchemas: PurchaseMain.allSchemas, // searchPage: PurchaseMainApi.getPurchaseMainPage, // searchCondition: [{ // key: 'available', // value: 'TRUE', // isMainValue: false // },{ // key: 'supplierCode', // value: 'supplierCode', // message: '请填写供应商代码!', // isMainValue: true // },{ // key: 'status', // value: 2, // isMainValue: false // }] // } // } // }, { label: '计划数量', field: 'planQty', sort: 'custom', table: { width: 150 }, tableForm: { type: 'InputNumber', precision: 6 }, sortTableDefault:4, form: { component: 'InputNumber', componentProps: { min: 0, precision: 6 } } }, { label: '订单行', field: 'poLine', sort: 'custom', table: { width: 150 }, sortTableDefault:10, form: { // labelMessage: '信息提示说明!!!', componentProps: { disabled: true, isSearchList: false, searchListPlaceholder: '请选择订单行', searchField: 'lineNumber', searchTitle: '采购订单信息', searchAllSchemas: PurchaseDetail.allSchemas, searchPage: PurchaseDetailApi.getPurchaseDetailPagePoNumber, searchCondition: [{ key: 'number', value: 'poNumber', message: '请填写订单号!', isMainValue: true },{ key: 'available', value: 'TRUE', isMainValue: false }] } }, tableForm: { multiple:true, disabled: true, isInpuFocusShow: false, searchListPlaceholder: '请选择订单行', searchField: 'lineNumber', searchTitle: '采购订单信息', searchAllSchemas: PurchaseDetail.allSchemas, searchPage: PurchaseDetailApi.getPurchaseDetailPagePoNumber, searchCondition: [{ key: 'number', value: 'poNumber', message: '请填写订单号!', isMainValue: true },{ key: 'available', value: 'TRUE', isMainValue: false }] } }, { label: '物料代码', field: 'itemCode', sort: 'custom', table: { width: 150 }, sortTableDefault:3, sortSearchDefault:5, isSearch:true, form: { componentProps: { disabled: true } }, tableForm: { disabled: true }, search: { // labelMessage: '信息提示说明!!!', componentProps: { multiple: true, enterSearch: true, isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择物料代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '物料基础信息', // 查询弹窗标题 searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 searchPage: ItembasicApi.getItembasicPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'supplierCode', value: 'supplierCode', message: '请填写供应商代码!', isMainValue: true, },{ key: 'available', value: 'TRUE', isMainValue: false }] } } }, { label: '订单数量', field: 'orderQty', sort: 'custom', table: { width: 150 }, form: { componentProps: { disabled: true } }, sortTableDefault:11, tableForm: { disabled: true } }, { label: '已发货数量', field: 'shippedQty', sort: 'custom', table: { width: 150 }, isTableForm: false, isForm: false, sortTableDefault:5, }, { label: '已收货数量', field: 'receivedQty', sort: 'custom', table: { width: 150 }, isTableForm: false, isForm: false, sortTableDefault:6, }, { label: '在途数量', field: 'notReceiveQty', sort: 'custom', table: { width: 150 }, isTableForm: false, isForm: false, sortTableDefault:7, }, { label: '计量单位', field: 'uom', sort: 'custom', dictType: DICT_TYPE.UOM, dictClass: 'string', isTable: true, table: { width: 150 }, sortTableDefault:12, form: { componentProps: { disabled: true } }, tableForm: { type: 'Select', disabled:true, } }, { label: '是否可用', field: 'available', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: true, isTableForm:false, isForm:false, hiddenInMain:true, sort: 'custom', table: { width: 150 }, tableForm: { type: 'Select', inactiveValue: 'FALSE', disabled: true }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } } }, { label: '最后更新者', field: 'updater', sort: 'custom', isTableForm: false, hiddenInMain:true, table: { width: 150 }, isForm: false, }, { label: '最后更新时间', field: 'updateTime', sort: 'custom', isTableForm: false, hiddenInMain:true, 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', hiddenInMain:true, isTableForm:false, table: { width: 150 }, }, { label: '操作', field: 'action', isDetail: false, isForm: false, hiddenInMain:true, table: { width: 150, fixed: 'right' }, isTableForm: false, } ])) const validatePlanQty = (rule, value, callback) => { console.log('validatePlanQty',value) const numReg = /^[\d]+$/ if (numReg.test(value)&&value>=0) { callback() } else { callback(new Error('计划数量不能小于0')) } } //表单校验 export const PurchasePlanDetailRules = reactive({ // available: [ // { required: true, message: '请选择是否可用', trigger: 'change' } // ], shippedQty: [ { required: true, message: '请输入已发货数量', trigger: 'blur' } ], uom: [ { required: true, message: '请选择计量单位', trigger: 'change' } ], planQty: [ { required: true, message: '请输入计划数量', trigger: 'blur' }, { validator:validatePlanQty, message: '计划数量不能小于0', trigger: 'blur'} ], remark: [ { max: 50, message: '不得超过50个字符', trigger: 'blur' } ], })