zhang_li
5 months ago
44 changed files with 736 additions and 53 deletions
@ -0,0 +1,530 @@ |
|||
// 获取供应商列表
|
|||
import { getSupplierListByCodes, importTemplate } from '@/api/wms/supplier' |
|||
// 获取物料列表
|
|||
import { getItemListByCodes } from '@/api/wms/itembasic' |
|||
// 获取供应商物料列表
|
|||
import { getSupplierItemListByCodes } from '@/api/wms/supplieritem' |
|||
// 获取生产线物料
|
|||
import { getProductionLineCodelistByCodes } from '@/api/wms/productionlineitem' |
|||
// 获取包装规格
|
|||
import { getPackageunitListByCodes } from '@/api/wms/packageunit' |
|||
// 获取物料包装规格
|
|||
import { getItemPackageunitListByCodes } from '@/api/wms/itempackage' |
|||
// 获取客户物料
|
|||
import { getCustomerItemListByCodes } from '@/api/wms/customeritem' |
|||
// 获取库存余额
|
|||
import { getBalanceItemListByCodes } from '@/api/wms/balance' |
|||
import { isString } from 'min-dash' |
|||
const message = useMessage() // 消息弹窗
|
|||
const { t } = useI18n() // 国际化
|
|||
/** |
|||
* 业务组件 |
|||
* tableFormBlur 表格表单失去焦点时候获取焦点 |
|||
* FormBlur 表格失去焦点时候获取焦点 |
|||
*/ |
|||
export const tableFormBlurVer = async (headerItem, val, row, index,routeName,formRef,detailData,tableData,callback) => { |
|||
if ( |
|||
headerItem.field == 'fromPackingNumber' || |
|||
headerItem.field == 'packingNumber' || |
|||
headerItem.field == 'itemCode' || |
|||
headerItem.field == 'packUnit' || |
|||
headerItem.field == 'secondPackUnit' || |
|||
headerItem.field == 'fromPackUnit' || |
|||
headerItem.field == 'toPackUnit'|| |
|||
headerItem.field == 'toPackUnit'|| |
|||
headerItem.field == 'supplierItemCode' |
|||
|
|||
) { |
|||
let searchField = headerItem.field |
|||
let pageApi = ref() |
|||
let params = ref() |
|||
|
|||
if (val && isString(val)) { |
|||
// const obj = props.tableAllSchemas.tableFormColumns.find((item) => item.field == headerItem.field)
|
|||
if (val.indexOf(',') > -1) { |
|||
message.alert('该输入框只能输入一条数据') |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
// 校验
|
|||
let params = ref({}) |
|||
let searchCondition1 = headerItem.tableForm.searchCondition //获取data.ts参数信息
|
|||
// 循环参数设置参数为key:value格式
|
|||
if (searchCondition1 && searchCondition1.length > 0) { |
|||
for (let i = 0; i < searchCondition1.length; i++) { |
|||
if (searchCondition1[i].isMainValue) { |
|||
params.value[searchCondition1[i].key] = formRef.formModel[ |
|||
searchCondition1[i].value |
|||
] |
|||
? formRef.formModel[searchCondition1[i].value] |
|||
: detailData |
|||
? detailData[searchCondition1[i].value] |
|||
: row |
|||
? row[searchCondition1[i].value] |
|||
: '' |
|||
// 是否含有空参数情况
|
|||
let isNull = false |
|||
if ( |
|||
params.value[searchCondition1[i].key] == '' || |
|||
params.value[searchCondition1[i].key] == undefined |
|||
) { |
|||
isNull = true |
|||
} |
|||
if (isNull) { |
|||
message.warning( |
|||
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|||
) |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
} else { |
|||
// 扩展 转换为筛选条件进行查询
|
|||
if (searchCondition1[i].isSearch) { |
|||
if (searchCondition1[i].isFormModel) { |
|||
//用formModel中的值
|
|||
if (searchCondition1[i].required) { |
|||
if ( |
|||
formRef.formModel[searchCondition1[i].value] == '' || |
|||
formRef.formModel[searchCondition1[i].value] == undefined |
|||
) { |
|||
message.warning( |
|||
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|||
) |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
} |
|||
} |
|||
} else { |
|||
params.value[searchCondition1[i].key] = searchCondition1[i].value |
|||
} |
|||
} |
|||
} |
|||
} |
|||
params.value[headerItem.field] = val?.trim() |
|||
// 判断改包装号是否已经添加
|
|||
const seen = new Set() |
|||
const repeatCode = new Set() |
|||
let arr = tableData.map((item) => item[headerItem.field]?.trim()) |
|||
arr.forEach((item) => { |
|||
if (seen.has(item)) { |
|||
repeatCode.add(item) |
|||
} else { |
|||
seen.add(item) |
|||
} |
|||
}) |
|||
const arr1 = Array.from(repeatCode) |
|||
if (arr1.length > 0) { |
|||
message.warning(`${arr1.join(',')}${t('ts.已经存在')}`) |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
if ( |
|||
headerItem.field == 'fromPackingNumber' || |
|||
headerItem.field == 'packingNumber' || |
|||
headerItem.field == 'itemCode' |
|||
) { |
|||
// 业务
|
|||
// 采购退货申请,制品拆解,调拨出库,报废出库申请,合格转隔离,隔离转合格,隔离转报废,合格转报废,报废转隔离,库存移动申请,库存修改申请
|
|||
if ( |
|||
routeName == 'PurchasereturnRequestMain' || |
|||
routeName == 'ProductdismantleRequestMain' || |
|||
routeName == 'TransferissueRequestMain' || |
|||
routeName == 'ScrapRequestMain' || |
|||
routeName == 'OktoholdRequestMain' || |
|||
routeName == 'HoldtookRequestMain' || |
|||
routeName == 'HoldtoscrapRequestMain' || |
|||
routeName == 'OktoscrapRequestMain' || |
|||
routeName == 'ScraptoholdRequestMain' || |
|||
routeName == 'InventorymoveRequestMain' || |
|||
routeName == 'InventorychangeRequestMain' |
|||
) { |
|||
//合格转隔离,隔离转合格,隔离转报废,合格转报废,报废转隔离,库存移动申请参数稍有不同
|
|||
if ( |
|||
routeName == 'OktoholdRequestMain' || |
|||
routeName == 'HoldtookRequestMain' || |
|||
routeName == 'HoldtoscrapRequestMain' || |
|||
routeName == 'OktoscrapRequestMain' || |
|||
routeName == 'ScraptoholdRequestMain' || |
|||
routeName == 'InventorymoveRequestMain' || |
|||
routeName == 'InventorychangeRequestMain' |
|||
) { |
|||
searchField = 'packingNumber' |
|||
params.value.packingNumber = val?.trim() |
|||
} |
|||
pageApi.value = getBalanceItemListByCodes |
|||
} else if ( |
|||
routeName == 'RepleinshRequestMain' || |
|||
routeName == 'IssueRequestMain' || |
|||
routeName == 'InventoryinitRequestMain' |
|||
) { |
|||
// 补料申请业务
|
|||
pageApi.value = getItemListByCodes |
|||
searchField = 'code' |
|||
params.value.codes = val?.trim() |
|||
} else if ( |
|||
routeName == 'ProductionMainAssemble' || |
|||
routeName == 'ProductionMainASparePart' || |
|||
routeName == 'ProductionMainPredictSparePart' || |
|||
routeName == 'ProductreceiptRequestMain' || |
|||
routeName == 'ProductreceiptRequestMainA' || |
|||
routeName == 'ProductreceiptscrapRequestMain' || |
|||
routeName == 'ProductscrapRequestMain' |
|||
) { |
|||
// 装配计划,裝配备件计划,预备产件计划,预生产收货申请,装配收货申请,报修收货申请,制品报废申请
|
|||
pageApi.value = getProductionLineCodelistByCodes |
|||
params.value.productionLineCode= |
|||
formRef.formModel.productionLine || formRef.formModel.productionLineCode || row.productionLine || row.productionLineCode, |
|||
params.value.itemCodes=val?.trim() |
|||
} |
|||
} else if ( |
|||
headerItem.field == 'packUnit' || |
|||
headerItem.field == 'secondPackUnit' || |
|||
headerItem.field == 'fromPackUnit' || |
|||
headerItem.field == 'toPackUnit' |
|||
) { |
|||
searchField = 'packUnit' |
|||
//包装规格
|
|||
// 预生产收货申请,装配收货申请,报修收货申请,客户退货申请,计划外入库,计划外出库,翻包申请
|
|||
if ( |
|||
routeName == 'ProductreceiptRequestMain' || |
|||
routeName == 'ProductreceiptRequestMainA' || |
|||
routeName == 'ProductreceiptscrapRequestMain' || |
|||
routeName == 'CustomerreturnRequestMain' || |
|||
routeName == 'UnplannedreceiptRequestMain' || |
|||
routeName == 'UnplannedissueJobMain' || |
|||
routeName == 'PackageoverRequestMain' |
|||
) { |
|||
params.value.itemCode= row.itemCode |
|||
params.value.packUnit= val?.trim() |
|||
pageApi.value = getItemPackageunitListByCodes |
|||
} |
|||
} else if ( |
|||
headerItem.field == 'supplierItemCode' |
|||
) { |
|||
// 生产退料申请,隔离退料申请
|
|||
if ( |
|||
routeName == 'ProductionreturnRequestMain' || |
|||
routeName == 'ProductionreturnRequestMainNo' |
|||
) { |
|||
searchField = 'supplierCode' |
|||
params.value.itemCodes= row.itemCode |
|||
params.value.supplierCode= val?.trim() |
|||
pageApi.value = getSupplierItemListByCodes |
|||
} |
|||
} |
|||
const list = ref() |
|||
// 调取包装接口
|
|||
await pageApi.value(params.value).then(async (res) => { |
|||
list.value = res ? res : [] |
|||
// 只查一条数据,多条数据查询默认显示不存在
|
|||
if (res.length == 1) { |
|||
callback(searchField,list.value) |
|||
} else { |
|||
message.alert('代码' + row[headerItem.field] + '没有找到对应数据') |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
export const FormBlur = async (formField, val,routeName,formRef,detailData,formSchema,callback) => { |
|||
let pageApi = ref() |
|||
let params = ref() |
|||
console.log(1111,val) |
|||
let setV = {} |
|||
setV[formField] = '' |
|||
if (val && isString(val)) { |
|||
if ( |
|||
formField == 'supplierCode' || |
|||
formField == 'itemCode' || |
|||
formField == 'productItemCode' || |
|||
formField == 'componentItemCode' || |
|||
formField == 'packUnit' || |
|||
formField == 'inPackUnit' || |
|||
formField == 'fromPackingNumber' |
|||
) { |
|||
let searchField = 'code' |
|||
if (formField == 'supplierCode') { |
|||
params.value = val?.trim() |
|||
pageApi.value = getSupplierListByCodes |
|||
} else if ( |
|||
formField == 'itemCode' || |
|||
formField == 'productItemCode' || |
|||
formField == 'componentItemCode' |
|||
) { |
|||
// 销售价格单
|
|||
if (routeName == 'Saleprice') { |
|||
console.log(22222,formRef.formModel.customerCode) |
|||
params.value = { |
|||
customerCode: formRef.formModel.customerCode, |
|||
itemCodes: val?.trim() |
|||
} |
|||
pageApi.value = getCustomerItemListByCodes |
|||
searchField = 'itemCode' |
|||
}else if (routeName == 'ProductscrapRequestMain') { |
|||
// 制品报废申请
|
|||
params.value = { |
|||
productionLineCode: |
|||
detailData.productionLine || detailData.productionLineCode, |
|||
itemCodes: val?.trim() |
|||
} |
|||
pageApi.value = getProductionLineCodelistByCodes |
|||
searchField = 'itemCode' |
|||
}else { |
|||
// params.value = val.trim()
|
|||
searchField = 'code' |
|||
|
|||
params.value={ |
|||
codes:val?.trim() |
|||
} |
|||
pageApi.value = getItemListByCodes |
|||
} |
|||
} else if (formField == 'packUnit') { |
|||
if(routeName == 'Itemwarehouse'||routeName == 'Callmaterials'){//物料仓库默认配置,叫料标签
|
|||
searchField = 'packUnit' |
|||
params.value = { |
|||
itemCode: formRef.formModel.itemCode, |
|||
packUnit: val?.trim() |
|||
} |
|||
pageApi.value = getItemPackageunitListByCodes |
|||
}else{ |
|||
params.value = val?.trim() |
|||
pageApi.value = getPackageunitListByCodes |
|||
} |
|||
} else if (formField == 'inPackUnit') { |
|||
params.value = { |
|||
itemCode: formRef.formModel.itemCode, |
|||
packUnit: val.trim() |
|||
} |
|||
pageApi.value = getItemPackageunitListByCodes |
|||
} else if (formField == 'fromPackingNumber') { |
|||
params.value = { |
|||
packingNumber: val?.trim() |
|||
} |
|||
pageApi.value = getBalanceItemListByCodes |
|||
} |
|||
let obj = {} |
|||
let searchCondition1 = formSchema.find((item) => item.field == formField).componentProps |
|||
.searchCondition //获取data.ts参数信息
|
|||
// 循环参数设置参数为key:value格式
|
|||
if (searchCondition1 && searchCondition1.length > 0) { |
|||
for (let i = 0; i < searchCondition1.length; i++) { |
|||
if (searchCondition1[i].isMainValue) { |
|||
obj[searchCondition1[i].key] = formRef.formModel[searchCondition1[i].value] |
|||
? formRef.formModel[searchCondition1[i].value] |
|||
: detailData |
|||
? detailData[searchCondition1[i].value] |
|||
: '' |
|||
// 是否含有空参数情况
|
|||
let isNull = false |
|||
if (obj[searchCondition1[i].key] == '' || obj[searchCondition1[i].key] == undefined) { |
|||
isNull = true |
|||
} |
|||
if (isNull) { |
|||
message.warning( |
|||
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|||
) |
|||
return |
|||
} |
|||
} else { |
|||
// 扩展 转换为筛选条件进行查询
|
|||
if (searchCondition1[i].isSearch) { |
|||
if (searchCondition1[i].isFormModel) { |
|||
//用formModel中的值
|
|||
if (searchCondition1[i].required) { |
|||
if ( |
|||
formRef.formModel[searchCondition1[i].value] == '' || |
|||
formRef.formModel[searchCondition1[i].value] == undefined |
|||
) { |
|||
message.warning( |
|||
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|||
) |
|||
return |
|||
} |
|||
} |
|||
} |
|||
} else { |
|||
obj[searchCondition1[i].key] = searchCondition1[i].value |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
let obj1 = formSchema.find((item) => item.field == formField) |
|||
if (!obj1.componentProps.multiple && val.indexOf(',') > -1) { |
|||
message.alert('该输入框只能输入一条数据') |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
await pageApi.value(params.value).then((res) => { |
|||
let arr1 = val.split(',') |
|||
let list = ref([]) |
|||
list.value = res |
|||
if (list.value?.length == 0) { |
|||
message.alert('暂无数据') |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
if (arr1.length != list.value.length) { |
|||
let arr2 = list.value.map((item) => item.code) |
|||
let str = [ |
|||
...arr1.filter((item) => !arr2.includes(item)), |
|||
...arr2.filter((item) => !arr1.includes(item)) |
|||
].join(',') |
|||
message.alert('代码' + str + '没有找到对应数据') |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
console.log(23232323) |
|||
// emit('searchTableSuccess', formField, searchField, list.value, formRef.value, 'form')
|
|||
callback(searchField,list.value) |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 根据下方输入框失去焦点校验信息
|
|||
export const getListByBottonInput = async (headerItem, val,row,routeName,formRef,detailData,tableData,callback) => { |
|||
let pageApi = ref() |
|||
let params = ref({}) |
|||
let list = ref([]) |
|||
let field = 'itemCode' |
|||
// scp采购订单
|
|||
if(!val)return; |
|||
if (routeName == 'PurchaseMain') { |
|||
pageApi.value = getSupplierItemListByCodes |
|||
params.value = { |
|||
supplierCode: formRef.formModel.supplierCode, |
|||
itemCodes: val?.trim(), |
|||
available: true |
|||
} |
|||
} else if (routeName == 'ProductionMain') { |
|||
pageApi.value = getProductionLineCodelistByCodes |
|||
params.value = { |
|||
productionLineCode: formRef.formModel.productionLine, |
|||
itemCodes: val?.trim() |
|||
} |
|||
} else if ( |
|||
routeName == 'ZZBJDeliverPlanMain' || |
|||
routeName == 'DeliverPlanMain' || |
|||
routeName == 'DeliverRequestMain' || |
|||
routeName == 'ZZBJDeliverRequestMain' |
|||
) { |
|||
// 自制备件发货计划,发货计划,成品发货申请,自制备件发货申请
|
|||
pageApi.value = getCustomerItemListByCodes |
|||
params.value = { |
|||
customerCode: formRef.formModel.customerCode, |
|||
itemCodes: val?.trim() |
|||
} |
|||
} else if (routeName == 'UnplannedissueRequestMain') { |
|||
// 计划外出库
|
|||
pageApi.value = getBalanceItemListByCodes |
|||
params.value = { |
|||
packingNumber: val?.trim() |
|||
} |
|||
field = 'packingNumber' |
|||
} else { |
|||
params.value.codes = val?.trim() |
|||
pageApi.value = getItemListByCodes |
|||
} |
|||
let searchCondition1 = headerItem.tableForm.searchCondition //获取data.ts参数信息
|
|||
console.log(98888,searchCondition1) |
|||
// 循环参数设置参数为key:value格式
|
|||
if (searchCondition1 && searchCondition1.length > 0) { |
|||
for (let i = 0; i < searchCondition1.length; i++) { |
|||
if (searchCondition1[i].isMainValue) { |
|||
params.value[searchCondition1[i].key] = formRef.formModel[ |
|||
searchCondition1[i].value |
|||
] |
|||
? formRef.formModel[searchCondition1[i].value] |
|||
: detailData |
|||
? detailData[searchCondition1[i].value] |
|||
: '' |
|||
// 是否含有空参数情况
|
|||
let isNull = false |
|||
if ( |
|||
params.value[searchCondition1[i].key] == '' || |
|||
params.value[searchCondition1[i].key] == undefined |
|||
) { |
|||
isNull = true |
|||
} |
|||
if (isNull) { |
|||
message.warning( |
|||
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|||
) |
|||
return |
|||
} |
|||
} else if (searchCondition1[i].isTableRowValue) { |
|||
if (searchCondition1[i].required) { |
|||
if (row[searchCondition1[i].value] == '' || row[searchCondition1[i].value] == undefined) { |
|||
message.warning( |
|||
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|||
) |
|||
return |
|||
} |
|||
} |
|||
row[searchCondition1[i].value] |
|||
//查询当前table表数据的值
|
|||
params.value[searchCondition1[i].key] = row[searchCondition1[i].value] |
|||
} else { |
|||
// 扩展 转换为筛选条件进行查询
|
|||
if (searchCondition1[i].isSearch) { |
|||
if (searchCondition1[i].isFormModel) { |
|||
//用formModel中的值
|
|||
if (searchCondition1[i].required) { |
|||
if ( |
|||
formRef.formModel[searchCondition1[i].value] == '' || |
|||
formRef.formModel[searchCondition1[i].value] == undefined |
|||
) { |
|||
message.warning( |
|||
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|||
) |
|||
return |
|||
} |
|||
} |
|||
}else { |
|||
params.value[searchCondition1[i].key] = searchCondition1[i].value |
|||
} |
|||
} else { |
|||
params.value[searchCondition1[i].key] = searchCondition1[i].value |
|||
} |
|||
} |
|||
} |
|||
} |
|||
console.log(788,params.value) |
|||
await pageApi.value(params.value).then(async (res) => { |
|||
list.value = res ? res : [] |
|||
let arr1 = val.split(',').map(item=>item.trim()) |
|||
console.log(res) |
|||
console.log(arr1) |
|||
if (arr1.length != res.length) { |
|||
let arr2 = res.map((item) => item[field]) |
|||
console.log(arr2) |
|||
let str = [ |
|||
...arr1.filter((item) => !arr2.includes(item)), |
|||
...arr2.filter((item) => !arr1.includes(item)) |
|||
].join(',') |
|||
console.log(str) |
|||
message.alert('代码' + str + '没有找到对应数据') |
|||
return |
|||
} else { |
|||
let repeatCode = [] |
|||
if(tableData.length > 0){ |
|||
tableData.forEach((item) => { |
|||
const findIndex = arr1.findIndex(valItem=>valItem==item[field]) |
|||
if(findIndex > -1){ |
|||
arr1.splice(findIndex,1) |
|||
repeatCode.push(item.itemCode) |
|||
} |
|||
}) |
|||
} |
|||
if(repeatCode.length>0){ |
|||
message.warning(`${t('ts.代码')}${repeatCode.join(',')}${t('ts.已经存在')}`); |
|||
return; |
|||
} |
|||
callback(list.value) |
|||
} |
|||
}) |
|||
} |
Loading…
Reference in new issue