import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { TableColumn } from '@/types/table' import { dateFormatter } from '@/utils/formatTime' import * as BalanceApi from '@/api/wms/balance' import { Balance } from '@/views/wms/inventoryManage/balance/balance.data' import * as LocationApi from '@/api/wms/location' import { Location } from '@/views/wms/basicDataManage/factoryModeling/location/location.data' import * as getRequestsettingApi from '@/api/wms/requestsetting/index' import * as getBusinessTypeApi from '@/api/wms/businesstype/index' // 表单校验 export const ContainerMainRequestRules = reactive({ type: [ { required: true, message: '请选择类型', trigger: 'change' }, ], concurrencyStamp: [required], }) // 获取自动提交自动通过自动执行,跳过任务直接删生成记录的默认值 const queryParams = { pageSize: 10, pageNo: 1, code: 'ContainerRequest' } const data = await getRequestsettingApi.getRequestsettingPage(queryParams) const requestsettingData = data?.list[0] || {} const businessTypeQueryParams = { pageSize:10, pageNo:1, code:'ScrapContainerManage', name:'器具报废管理' } const businessTypeValue = await getBusinessTypeApi.getBusinesstypePage(businessTypeQueryParams) const businessTypeData =businessTypeValue?.list[0]||{} // 获取当前操作人的部门 import { useUserStore } from '@/store/modules/user' const userStore = useUserStore() const userDept = userStore.userSelfInfo.dept // id 转str 否则form回显匹配不到 userDept.id = userDept.id.toString() const userDeptArray: any = [userDept] export const ContainerMainRequest = useCrudSchemas(reactive([ { label: '单据号', field: 'number', sort: 'custom', isSearch: true, isForm: false, table: { width: 100 }, }, { label: '状态', field: 'status', dictType: DICT_TYPE.REQUEST_STATUS, dictClass: 'string', isSearch: true, isForm: false, isTable: true, sort: 'custom', table: { width: 150 }, form: { componentProps: { disabled: true } } }, // { // label: '到库位代码', // field: 'toLocationCode', // sort: 'custom', // table: { // width: 150 // }, // tableForm:{ // isInpuFocusShow: true, // 开启查询弹窗 // searchListPlaceholder: '请选择到库位代码', // searchField: 'code', // searchTitle: '库位信息', // searchAllSchemas: Location.allSchemas, // searchPage: LocationApi.selectBusinessTypeToLocation, // searchCondition: [{ // key: 'businessType', // value: businessTypeData.code, // },{ // key: 'isIn', // value: 'in', // isMainValue: false // }] // }, // form: { // // labelMessage: '信息提示说明!!!', // componentProps: { // isSearchList: true, // 开启查询弹窗 // searchListPlaceholder: '请选择到库位代码', // searchField: 'code', // searchTitle: '库位信息', // searchAllSchemas: Location.allSchemas, // searchPage: LocationApi.selectBusinessTypeToLocation, // searchCondition: [{ // key: 'businessType', // value: businessTypeData.code, // },{ // key: 'isIn', // value: 'in', // isMainValue: false // }] // } // } // }, { label: '类型', field: 'type', sort: 'custom', dictType: DICT_TYPE.CONTAIN_MANAGE_TYPE, dictClass: 'string', isSearch: true, isTable: true, table: { width: 120 }, form: { componentProps: { disabled: true, } } }, { label: '是否可用', field: 'available', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isSearch: false, isForm: false, isTable: false, table: { width: 150 }, }, { label: '主备注', field: 'mainRemark', sort: 'custom', isSearch: false, isForm: true, isTable: false, }, { label: '部门', field: 'departmentCode', sort: 'custom', table: { width: 150 }, isSearch: false, isForm: false, isTable: false, formatter: (_: Recordable, __: TableColumn, cellValue: number) => { return userDeptArray.find((account) => account.id == cellValue)?.name }, form: { value: userDept.id, component: 'Select', api: () => userDeptArray, componentProps: { disabled: true, optionsAlias: { labelField: 'name', valueField: 'id' } } } }, { label: '自动提交', field: 'autoCommit', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: false, isForm: false, sort: 'custom', table: { width: 150 }, form: { component: 'Switch', value: requestsettingData.autoCommit, componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE', disabled: true } } }, { label: '自动通过', field: 'autoAgree', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: false, isForm: false, sort: 'custom', table: { width: 150 }, form: { component: 'Switch', value: requestsettingData.autoAgree, componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE', disabled: true } } }, { label: '自动执行', field: 'autoExecute', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isTable: false, isForm: false, sort: 'custom', table: { width: 150 }, form: { component: 'Switch', value: requestsettingData.autoExecute, componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE', disabled: true } } }, { label: '直接生成记录', field: 'directCreateRecord', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', isForm: false, isTable: false, sort: 'custom', table: { width: 150 }, form: { component: 'Switch', value: requestsettingData.directCreateRecord, componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE', disabled: true } } }, { label: '创建时间', field: 'createTime', sort: 'custom', formatter: dateFormatter, table: { width: 180 }, detail: { dateFormat : 'YYYY-MM-DD HH:mm:ss' }, isSearch: false, isForm: false, isTable: false, 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: 'creator', table: { width: 130 }, isSearch: false, isForm: false, isTable: false, }, { label: '最后更新时间', field: 'updateTime', sort: 'custom', isDetail: true, isForm: false, isTable: false, 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, isSearch: false, isForm: false, isTable: false, table: { width: 150 } }, { label: '扩展属性', field: 'extraProperties', sort: 'custom', isSearch: false, isForm: false, isTable: false, }, { label: '并发乐观锁', field: 'concurrencyStamp', sort: 'custom', form: { component: 'InputNumber', value: 0 }, isSearch: false, isForm: false, isTable: false, }, { label: '地点ID', field: 'siteId', sort: 'custom', isSearch: false, isForm: false, isTable: false, }, { label: '操作', field: 'action', isForm: false, table: { width: 200, fixed: 'right' } } ])) // 表单校验 export const ContainerDetailRequestRules = reactive({ toLocationCode: [ { required: true, message: '请选择目标库位', trigger: 'blur' } ], containerNumber: [ { required: true, message: '请选择器具号', trigger: 'blur' } ], toQty: [ { required: true, message: '请输入到数量', trigger: 'blur' } ], }) export const ContainerDetailRequest = useCrudSchemas(reactive([ { label: 'id', field: 'id', sort: 'custom', isForm: false, isTableForm: false, isTable: false }, { label: '主表ID', field: 'masterId', sort: 'custom', isSearch: true, form: { component: 'InputNumber', value: 0 }, isForm: false, isTableForm: false, isTable: false }, { label: '单据号', field: 'number', sort: 'custom', isSearch: true, isForm: false, isTableForm: false, isTable: false }, { label: '器具号', field: 'containerNumber', sort: 'custom', tableForm:{ multiple:true, isInpuFocusShow: true, // 开启查询弹窗 searchListPlaceholder: '请选择器具号', searchField: 'itemCode', searchTitle: '库存余额信息', searchAllSchemas: Balance.allSchemas, searchPage: BalanceApi.getBalanceByQJToScrap, }, form: { // labelMessage: '信息提示说明!!!', componentProps: { isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择器具号', searchField: 'itemCode', searchTitle: '库存余额信息', searchAllSchemas: Balance.allSchemas, searchPage: BalanceApi.getBalanceByQJToScrap, } } }, { label: '来源库位代码', field: 'fromLocationCode', sort: 'custom', isForm: false, isTableForm: false, isTable: false, table: { width: 150 }, tableForm: { disabled: true, type: 'Select' }, form: { // labelMessage: '信息提示说明!!!', componentProps: { disabled: true, } } }, // { // label: '目标库位代码', // field: 'toLocationCode', // sort: 'custom', // table: { // width: 150 // }, // tableForm: { // enterSearch:true, // isInpuFocusShow: true, // 开启查询弹窗 // searchListPlaceholder: '请选择到库位代码', // searchField: 'code', // searchTitle: '库位信息', // searchAllSchemas: Location.allSchemas, // searchPage: LocationApi.selectPageItemAreaToLocation, // // 失去焦点校验参数 // verificationParams: [{ // key: 'code', // action: '==', // value: '', // isMainValue: false, // isSearch: 'true', // isFormModel: true, // }] // }, // form: { // // labelMessage: '信息提示说明!!!', // componentProps: { // enterSearch: true, // isSearchList: true, // 开启查询弹窗 // searchListPlaceholder: '请选择到库位代码', // searchField: 'code', // searchTitle: '库位信息', // searchAllSchemas: Location.allSchemas, // searchPage: LocationApi.selectPageItemAreaToLocation, // // 失去焦点校验参数 // verificationParams: [{ // key: 'code', // action: '==', // value: '', // isMainValue: false, // isSearch: 'true', // isFormModel: true, // }] // } // } // }, { label: '库存状态', field: 'fromInventoryStatus', dictType: DICT_TYPE.INVENTORY_STATUS, dictClass: 'string', isForm: false, isTableForm: false, isTable: true, sort: 'custom', table: { width: 150 }, tableForm: { disabled: true, type: 'Select' }, }, // { // label: '从数量', // field: 'fromQty', // sort: 'custom', // tableForm: { // disabled: true, // }, // }, // { // label: '库存状态', // field: 'toInventoryStatus', // dictType: DICT_TYPE.INVENTORY_STATUS, // dictClass: 'string', // isTable: true, // sort: 'custom', // table: { // width: 150 // }, // tableForm: { // type: 'Select', // disabled: true // }, // }, { label: '数量', field: 'toQty', sort: 'custom', form: { component: 'InputNumber', componentProps: { disabled: true, min: 0, precision: 6 } }, tableForm: { type: 'InputNumber', min: 0, precision: 6 } }, { label: '计量单位', field: 'uom', dictType: DICT_TYPE.UOM, dictClass: 'string', isTable: true, sort: 'custom', table: { width: 150 }, tableForm: { disabled: true, type: 'Select' } }, { label: '子备注', field: 'remark', sort: 'custom', isTable: false, isForm: false, isTableForm: false }, { label: '创建时间', field: 'createTime', sort: 'custom', formatter: dateFormatter, 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')] } }, isTable: false, isForm: false, isTableForm: false }, { label: '地点ID', field: 'siteId', sort: 'custom', isForm: false, isTableForm: false, isTable: false }, { label: '并发乐观锁', field: 'concurrencyStamp', sort: 'custom', isForm: false, isTableForm: false, isTable: false }, { label: '从货主代码', field: 'fromOwnerCode', sort: 'custom', isForm: false, isTableForm: false, isTable: false }, { label: '到货主代码', field: 'toOwnerCode', sort: 'custom', isForm: false, isTableForm: false, isTable: false }, { label: '操作', field: 'action', isForm: false, hiddenInMain:true, isTableForm: false, table: { width: 200, fixed: 'right' } } ]))