import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import * as ItembasicApi from '@/api/wms/itembasic' import { Itembasic } from '../itembasic/itembasic.data' import * as PackageunitApi from '@/api/wms/packageunit' import { Packageunit } from '../packageunit/packageunit.data' const { t } = useI18n() // 国际化 /** * @returns {Array} 基础包装信息 */ export const Itempackaging = useCrudSchemas(reactive([ { label: '物料代码', field: 'itemCode', sort: 'custom', isSearch: true, table: { width: 180, fixed: 'left' }, form: { // labelMessage: '信息提示说明!!!', componentProps: { enterSearch: true, //可输入回车 isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择物料代码', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '物料基础信息', // 查询弹窗标题 searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 searchPage: ItembasicApi.getItembasicPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', isMainValue: false }], verificationParams: [{ key: 'code', action: '==', value: '', isMainValue: false, isSearch: 'true', isFormModel: true }], // 失去焦点校验参数 } } }, { label: '计量单位', field: 'uom', sort: 'custom', dictType: DICT_TYPE.UOM, dictClass: 'string', isSearch: true, isTable: true, table: { width: 120 },form: { // labelMessage: '信息提示说明!!!', componentProps: { disabled: true } } }, { label: '包装规格', field: 'packUnit', sort: 'custom', table: { width: 150 }, form: { // labelMessage: '信息提示说明!!!', componentProps: { enterSearch: true, //可输入回车 isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择包装规格', // 输入框占位文本 searchField: 'code', // 查询弹窗赋值字段 searchTitle: '包装规格信息', // 查询弹窗标题 searchAllSchemas: Packageunit.allSchemas, // 查询弹窗所需类 searchPage: PackageunitApi.getPackageunitPage, // 查询弹窗所需分页方法 searchCondition: [{ key: 'available', value: 'TRUE', action: '==', isSearch: true, isMainValue: false }], verificationParams: [{ key: 'code', action: '==', value: '', isMainValue: false, isSearch: 'true', isFormModel: true }], // 失去焦点校验参数 } } }, { label: '包装名称', field: 'packName', sort: 'custom', isSearch: false, table: { width: 120 }, isTable:true, isTableForm:false, isForm:false, isDetail:false }, { label: '包装类型', field: 'packType', dictType: DICT_TYPE.PACK_UNIT_TYPE, dictClass: 'string', sort: 'custom', isSearch: false, table: { width: 150 }, }, { label: '包装数量', field: 'packQty', sort: 'custom', isSearch: false, table: { width: 120 }, form: { component: 'InputNumber', componentProps: { min: 0, precision: 6 } } }, { label: '默认包装规格', field: 'defaultPackageunit', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: false, isDetail:false, isForm:false, table: { width: 120 }, form: { component: 'Switch', value: 'FALSE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } } }, { label: '是否可用', field: 'available', sort: 'custom', isSearch:true, isForm: false, dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 search: { value: 'TRUE', }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, table: { width: 110 } }, { label: '生效时间', field: 'activeTime', sort: 'custom', isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '失效时间', field: 'expireTime', sort: 'custom', isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '数据来源', field: 'dataSource', sort: 'custom', isForm:false, table: { width: 180 }, }, { label: '创建时间', field: 'createTime', sort: 'custom', isForm: false, isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '创建者', field: 'creator', isForm: false, isTable: true, table: { width: 150 } }, { label: '最后更新时间', field: 'updateTime', sort: 'custom', isDetail: true, isForm: false, isTable: true, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: {width:'100%'}, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', } } }, { label: '最后更新者', field: 'updater', isDetail: true, isForm: false, isTable: true, table: { width: 150 } }, { label: '操作', field: 'action', isDetail: false, isForm: false, table: { width: 150, fixed: 'right' } } ])) const validateQty = (rule: any, value: any, callback: any,a,b) => { console.log('validateQty',rule, value,a,b) if (!value) { callback(new Error('包装数量必须大于0')); } else { callback(); } } // 表单校验 export const ItempackagingRules = reactive({ itemCode: [{ required: true, message: '物料代码不能为空', trigger: 'change' }], uom: [{ required: true, message: '计量单位不能为空', trigger: 'change' }], packUnit: [{ required: true, message: '包装单位不能为空', trigger: 'change' }], packQty: [ { required: true, message: '包装数量不能为空', trigger: 'change' }, { validator: validateQty, trigger: 'change' } ], available: [{ required: true, message: '是否可用不能为空', trigger: 'change' }] })