chenfang
4 months ago
93 changed files with 4617 additions and 2738 deletions
@ -1,524 +0,0 @@ |
|||
// 获取供应商列表
|
|||
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() |
|||
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') { |
|||
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 |
|||
} |
|||
// 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参数信息
|
|||
// 循环参数设置参数为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 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
await pageApi.value(params.value).then(async (res) => { |
|||
list.value = res ? res : [] |
|||
let arr1 = val.split(',').map(item=>item.trim()) |
|||
if (arr1.length != res.length) { |
|||
let arr2 = res.map((item) => item[field]) |
|||
let str = [ |
|||
...arr1.filter((item) => !arr2.includes(item)), |
|||
...arr2.filter((item) => !arr1.includes(item)) |
|||
].join(',') |
|||
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) |
|||
} |
|||
}) |
|||
} |
@ -0,0 +1,922 @@ |
|||
// 获取供应商列表
|
|||
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.tableForm.searchPage && headerItem.tableForm.verificationParams) { |
|||
if (val && isString(val)) { |
|||
if (val.indexOf(',') > -1) { |
|||
message.alert('该输入框只能输入一条数据') |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
// 校验
|
|||
const params = ref({}) |
|||
const filters: any[] = [] |
|||
const searchCondition = headerItem.tableForm.searchCondition //获取data.ts参数信息
|
|||
const verificationParams = headerItem.tableForm.verificationParams //获取data.ts参数信息
|
|||
// 循环参数设置参数为key:value格式
|
|||
if (searchCondition && searchCondition.length > 0) { |
|||
for (let i = 0; i < searchCondition.length; i++) { |
|||
if (searchCondition[i].isMainValue) { |
|||
params.value[searchCondition[i].key] = formRef.formModel[ |
|||
searchCondition[i].value |
|||
] |
|||
? formRef.formModel[searchCondition[i].value] |
|||
: detailData |
|||
? detailData[searchCondition[i].value] |
|||
: row |
|||
? row[searchCondition[i].value] |
|||
: '' |
|||
// 是否含有空参数情况
|
|||
let isNull = false |
|||
if ( |
|||
params.value[searchCondition[i].key] == '' || |
|||
params.value[searchCondition[i].key] == undefined |
|||
) { |
|||
isNull = true |
|||
} |
|||
if (isNull) { |
|||
message.warning( |
|||
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|||
) |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: formRef.formModel[searchCondition[i].value] |
|||
}) |
|||
} else if (searchCondition[i].isTableRowValue) { |
|||
if (searchCondition[i].required) { |
|||
if (row[searchCondition[i].value] == '' || row[searchCondition[i].value] == undefined) { |
|||
message.warning( |
|||
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|||
) |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
} |
|||
//查询当前table表数据的值
|
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: row[searchCondition[i].value] |
|||
}) |
|||
} else { |
|||
// 扩展 转换为筛选条件进行查询
|
|||
if (searchCondition[i].isSearch) { |
|||
if (searchCondition[i].isFormModel) { |
|||
//用formModel中的值
|
|||
if (searchCondition[i].required) { |
|||
if ( |
|||
formRef.formModel[searchCondition[i].value] == '' || |
|||
formRef.formModel[searchCondition[i].value] == undefined |
|||
) { |
|||
message.warning( |
|||
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|||
) |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
} |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: formRef.formModel[searchCondition[i].value] |
|||
}) |
|||
} else { |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: searchCondition[i].value |
|||
}) |
|||
} |
|||
} else { |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: searchCondition[i].value |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
if (verificationParams && verificationParams.length > 0) { |
|||
// 转换筛选条件所需
|
|||
for (let i = 0; i < verificationParams.length; i++) { |
|||
// 扩展 转换为筛选条件进行查询
|
|||
if (verificationParams[i].isSearch) { |
|||
if (verificationParams[i].isFormModel) { |
|||
filters.push({ |
|||
action: verificationParams[i].action, |
|||
column: verificationParams[i].key, |
|||
value: formRef.formModel[verificationParams[i].value] |
|||
? formRef.formModel[verificationParams[i].value] |
|||
: val.trim() |
|||
}) |
|||
} else { |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: searchCondition[i].value |
|||
}) |
|||
} |
|||
} else { |
|||
params[verificationParams[i].key] = verificationParams[i].value |
|||
} |
|||
} |
|||
} |
|||
// 判断改包装号是否已经添加
|
|||
const seen = new Set() |
|||
const repeatCode = new Set() |
|||
const arr = tableData.map((item) => item[headerItem.field]?.trim()) |
|||
arr.forEach((item) => { |
|||
if (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 (filters.length > 0) { |
|||
params.value.isSearch = true |
|||
params.value.filters = filters |
|||
} |
|||
const obj = { |
|||
by: 'ASC', |
|||
pageNo: 1, |
|||
pageSize: 20 |
|||
} |
|||
params.value = { |
|||
isSearch: params.value.isSearch, |
|||
filters: params.value.filters, |
|||
...obj |
|||
} |
|||
const list = ref() |
|||
// 调取包装接口
|
|||
await headerItem.tableForm.searchPage(params.value).then(async (res) => { |
|||
|
|||
list.value = res?.list?.length > 0 ? res.list.slice(0, 1) : [] |
|||
// 只查一条数据,多条数据查询默认显示不存在
|
|||
if (list.value?.length == 0) { |
|||
message.alert('代码' + row[headerItem.field] + '没有找到对应数据') |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
callback(list.value) |
|||
}) |
|||
} |
|||
} else { |
|||
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(list.value) |
|||
} else { |
|||
message.alert('代码' + row[headerItem.field] + '没有找到对应数据') |
|||
row[headerItem.field] = '' |
|||
return |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
export const FormBlur = async (field, val, routeName, formRef, detailData, formSchema, callback) => { |
|||
if (formSchema.searchPage && formSchema.verificationParams) { |
|||
//获取data.ts参数信息
|
|||
const searchCondition = formSchema?.searchCondition || [] |
|||
//获取失去焦点参数信息
|
|||
const verificationParams = formSchema?.verificationParams || |
|||
[] |
|||
console.log('走新方法啦') |
|||
// searchCondition = [...searchCondition, ...verificationParams]
|
|||
|
|||
if (val && isString(val)) { |
|||
const setV = {} |
|||
setV[field] = '' |
|||
let params = {} |
|||
const _searchCondition = {} |
|||
const filters: any[] = [] |
|||
if (searchCondition && searchCondition.length > 0) { |
|||
// 转换筛选条件所需
|
|||
for (let i = 0; i < searchCondition.length; i++) { |
|||
// searchCondition.forEach((item) => {
|
|||
// 查询条件为主表某字段,需要赋值主表数据,数据来源是详情的,赋值需要从row中获取
|
|||
if (searchCondition[i].isMainValue) { |
|||
_searchCondition[searchCondition[i].key] = formRef.formModel[ |
|||
searchCondition[i].value |
|||
] |
|||
? formRef.formModel[searchCondition[i].value] |
|||
: detailData |
|||
? detailData[searchCondition[i].value] |
|||
: // : row
|
|||
// ? row[searchCondition[i].value]
|
|||
'' |
|||
// 是否含有空参数情况
|
|||
let isNull = false |
|||
if ( |
|||
_searchCondition[searchCondition[i].key] == '' || |
|||
_searchCondition[searchCondition[i].key] == undefined |
|||
) { |
|||
isNull = true |
|||
} |
|||
if (isNull) { |
|||
message.warning( |
|||
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|||
) |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: formRef.formModel[searchCondition[i].value] |
|||
}) |
|||
} |
|||
|
|||
// else if (searchCondition[i].isTableRowValue) {
|
|||
// if (searchCondition[i].required) {
|
|||
// if (row[searchCondition[i].value] == '' || row[searchCondition[i].value] == undefined) {
|
|||
// message.warning(
|
|||
// searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!'
|
|||
// )
|
|||
// return
|
|||
// }
|
|||
// }
|
|||
// row[searchCondition[i].value]
|
|||
// //查询当前table表数据的值
|
|||
// _searchCondition[searchCondition[i].key] = row[searchCondition[i].value]
|
|||
// }
|
|||
else { |
|||
// 扩展 转换为筛选条件进行查询
|
|||
if (searchCondition[i].isSearch) { |
|||
if (searchCondition[i].isFormModel) { |
|||
//用formModel中的值
|
|||
if (searchCondition[i].required) { |
|||
if ( |
|||
formRef.formModel[searchCondition[i].value] == '' || |
|||
formRef.formModel[searchCondition[i].value] == undefined |
|||
) { |
|||
message.warning( |
|||
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|||
) |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
} |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: formRef.formModel[searchCondition[i].value] |
|||
}) |
|||
} else { |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: searchCondition[i].value |
|||
}) |
|||
} |
|||
} else { |
|||
filters.push({ |
|||
action: searchCondition[i].action || '==', |
|||
column: searchCondition[i].key, |
|||
value: searchCondition[i].value |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
if (verificationParams && verificationParams.length > 0) { |
|||
// 转换筛选条件所需
|
|||
for (let i = 0; i < verificationParams.length; i++) { |
|||
// 扩展 转换为筛选条件进行查询
|
|||
if (verificationParams[i].isSearch) { |
|||
if (verificationParams[i].isFormModel) { |
|||
filters.push({ |
|||
action: verificationParams[i].action, |
|||
column: verificationParams[i].key, |
|||
value: formRef.formModel[verificationParams[i].value] |
|||
? formRef.formModel[verificationParams[i].value] |
|||
: val.trim() |
|||
}) |
|||
} else { |
|||
filters.push({ |
|||
action: verificationParams[i].action, |
|||
column: verificationParams[i].key, |
|||
value: verificationParams[i].value |
|||
}) |
|||
} |
|||
} else { |
|||
_searchCondition[verificationParams[i].key] = verificationParams[i].value |
|||
} |
|||
} |
|||
} |
|||
console.log(filters) |
|||
if (filters.length > 0) { |
|||
_searchCondition.isSearch = true |
|||
_searchCondition.filters = filters |
|||
} |
|||
console.log(4545, _searchCondition) |
|||
const obj = { |
|||
by: 'ASC', |
|||
pageNo: 1, |
|||
pageSize: 20 |
|||
} |
|||
console.log(888, _searchCondition) |
|||
params = { |
|||
isSearch: _searchCondition.isSearch, |
|||
filters: _searchCondition.filters, |
|||
...obj |
|||
} |
|||
// console.log(333,params)
|
|||
if (!formSchema?.multiple && val.indexOf(',') > -1) { |
|||
message.alert('该输入框只能输入一条数据') |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
await formSchema.searchPage(params).then((res) => { |
|||
const arr1 = val.split(',') |
|||
const list = ref([]) |
|||
list.value = res?.list?.length > 0 ? res.list.slice(0, 1) : [] |
|||
if (list.value?.length == 0) { |
|||
message.alert('暂无数据') |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
if (arr1.length != list.value.length) { |
|||
const arr2 = list.value.map((item) => item.code) |
|||
const str = [ |
|||
...arr1.filter((item) => !arr2.includes(item)), |
|||
...arr2.filter((item) => !arr1.includes(item)) |
|||
].join(',') |
|||
message.alert('代码' + str + '没有找到对应数据') |
|||
formRef.setValues(setV) |
|||
return |
|||
} |
|||
callback(list.value) |
|||
}) |
|||
} |
|||
} |
|||
else { |
|||
let pageApi = ref() |
|||
let params = ref() |
|||
let setV = {} |
|||
setV[field] = '' |
|||
if (val && isString(val)) { |
|||
if ( |
|||
field == 'supplierCode' || |
|||
field == 'itemCode' || |
|||
field == 'productItemCode' || |
|||
field == 'componentItemCode' || |
|||
field == 'packUnit' || |
|||
field == 'inPackUnit' || |
|||
field == 'fromPackingNumber' |
|||
) { |
|||
let searchField = 'code' |
|||
if (field == 'supplierCode') { |
|||
params.value = val?.trim() |
|||
pageApi.value = getSupplierListByCodes |
|||
} else if ( |
|||
field == 'itemCode' || |
|||
field == 'productItemCode' || |
|||
field == 'componentItemCode' |
|||
) { |
|||
// 销售价格单
|
|||
if (routeName == 'Saleprice') { |
|||
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 (field == '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 (field == '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.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 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (!formSchema.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 |
|||
} |
|||
// emit('searchTableSuccess', formField, searchField, list.value, formRef.value, 'form')
|
|||
callback(list.value) |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 根据下方输入框失去焦点校验信息
|
|||
export const getListByBottonInput = async (headerItem, val, row, routeName, formRef, detailData, tableData, callback) => { |
|||
let tableFormSchemaObj = headerItem?.tableForm |
|||
console.log(333,tableFormSchemaObj) |
|||
if (tableFormSchemaObj.searchPage && tableFormSchemaObj.verificationParams) { |
|||
let params = ref({}) |
|||
let list = ref([]) |
|||
console.log(3344) |
|||
let searchCondition1 = headerItem.tableForm.searchCondition //获取data.ts参数信息
|
|||
let verificationParams = headerItem.tableForm.verificationParams //获取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] |
|||
: '' |
|||
// 是否含有空参数情况
|
|||
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(999, verificationParams) |
|||
if (verificationParams && verificationParams.length > 0) { |
|||
for (let i = 0; i < verificationParams.length; i++) { |
|||
params.value[verificationParams[i].key] = val |
|||
} |
|||
} |
|||
await tableFormSchemaObj.verificationPage(params.value).then(async (res) => { |
|||
list.value = res ? res : [] |
|||
let arr1 = val.split(',').map(item => item.trim()) |
|||
if (arr1.length != res.length) { |
|||
let arr2 = res.map((item) => item[field]) |
|||
let str = [ |
|||
...arr1.filter((item) => !arr2.includes(item)), |
|||
...arr2.filter((item) => !arr1.includes(item)) |
|||
].join(',') |
|||
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) |
|||
} |
|||
}) |
|||
return |
|||
} else { |
|||
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 |
|||
} |
|||
|
|||
await pageApi.value(params.value).then(async (res) => { |
|||
list.value = res ? res : [] |
|||
let arr1 = val.split(',').map(item => item.trim()) |
|||
if (arr1.length != res.length) { |
|||
let arr2 = res.map((item) => item[field]) |
|||
let str = [ |
|||
...arr1.filter((item) => !arr2.includes(item)), |
|||
...arr2.filter((item) => !arr1.includes(item)) |
|||
].join(',') |
|||
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) |
|||
} |
|||
}) |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,105 @@ |
|||
|
|||
// 判断传入的值-是否为整数
|
|||
function isInteger(obj) { |
|||
return Math.floor(obj) === obj |
|||
} |
|||
|
|||
// 将一个浮点数转成整数,返回整数和倍数。如 3.14 >> 314,倍数是 100
|
|||
// @param floatNum { number } 小数
|
|||
// @return { object }
|
|||
// { times: 100, num: 314 }
|
|||
|
|||
// 用于返回整数和倍数
|
|||
function toInteger(floatNum) { |
|||
// 声明一个对象用来保存倍数和整数
|
|||
const ret = { times: 1, num: 0 } |
|||
// 第一种情况:是整数
|
|||
if (isInteger(floatNum)) { |
|||
// 把整数给 ret中的 num
|
|||
ret.num = floatNum |
|||
return ret // 最后返回 ret
|
|||
} |
|||
|
|||
// 第二种情况-不是整数,
|
|||
const strfi = floatNum + '' // 转为字符串 "0.1"
|
|||
const dotPos = strfi.indexOf('.') // 查询小数点
|
|||
const len = strfi.substr(dotPos + 1).length; // 获取小数点后的长度
|
|||
const times = Math.pow(10, len) // 放大多少倍
|
|||
const intNum = Number(floatNum.toString().replace('.', '')) // 返回 转为字符串 截取掉小数点 最后转为数字(整数)
|
|||
// 把获取到的倍数和整数存入对象中
|
|||
ret.times = times |
|||
ret.num = intNum |
|||
return ret |
|||
} |
|||
|
|||
|
|||
// 核心方法,实现加减乘除运算,确保不丢失精度
|
|||
// 思路:把小数放大为整数(乘),进行算术运算,再缩小为小数(除)
|
|||
// @param a { number } 运算数1
|
|||
// @param b { number } 运算数2
|
|||
// @param digits { number } 精度,保留的小数点数,比如 2, 即保留为两位小数
|
|||
// @param op { string } 运算类型,有加减乘除(add / subtract / multiply / divide)
|
|||
|
|||
|
|||
|
|||
function operation(a, b, digits, op) { |
|||
// 获取倍数和整数的对象
|
|||
const o1 = toInteger(a) |
|||
const o2 = toInteger(b) |
|||
// 提取整数
|
|||
const n1 = o1.num |
|||
const n2 = o2.num |
|||
// 提取倍数
|
|||
const t1 = o1.times |
|||
const t2 = o2.times |
|||
|
|||
// 获取最大倍数
|
|||
const max = t1 > t2 ? t1 : t2 |
|||
let result = 0 //
|
|||
|
|||
switch (op) { |
|||
case 'add': |
|||
if (t1 === t2) { // 两个小数位数相同
|
|||
result = n1 + n2 //
|
|||
} else if (t1 > t2) { // o1 小数位 大于 o2
|
|||
result = n1 + n2 * (t1 / t2) |
|||
} else { // o1 小数位 小于 o2
|
|||
result = n1 * (t2 / t1) + n2 |
|||
} |
|||
return result / max |
|||
case 'subtract': |
|||
if (t1 === t2) { |
|||
result = n1 - n2 |
|||
} else if (t1 > t2) { |
|||
result = n1 - n2 * (t1 / t2) |
|||
} else { |
|||
result = n1 * (t2 / t1) - n2 |
|||
} |
|||
return result / max |
|||
case 'multiply': |
|||
result = (n1 * n2) / (t1 * t2) |
|||
return result |
|||
case 'divide': |
|||
result = (n1 / n2) * (t2 / t1) |
|||
return result |
|||
} |
|||
} |
|||
|
|||
// 加减乘除的四个接口
|
|||
export function add(a, b, digits) { |
|||
return operation(a, b, digits, 'add') |
|||
} |
|||
export function subtract(a, b, digits) { |
|||
return operation(a, b, digits, 'subtract') |
|||
} |
|||
export function multiply(a, b, digits) { |
|||
return operation(a, b, digits, 'multiply') |
|||
} |
|||
export function divide(a, b, digits) { |
|||
return operation(a, b, digits, 'divide') |
|||
} |
|||
|
|||
|
|||
|
|||
// console.log(floatObj.add(0.5, 0.2))
|
|||
// console.log(floatObj.add(0.12, 0.3))
|
@ -1,325 +0,0 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="SupplierinvoiceRecordMain.allSchemas.searchSchema" @search="searchList" @reset="searchList" > |
|||
<template #cha> |
|||
<div style="display:flex;flex-direction: row"> |
|||
<el-input-number /> |
|||
<span>{{' 到 '}}</span> |
|||
<el-input-number /> |
|||
</div> |
|||
|
|||
</template> |
|||
</Search> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="SupplierinvoiceRecordMain.allSchemas" |
|||
/> |
|||
|
|||
<!-- 列表 --> |
|||
<ContentWrap> |
|||
<Table ref="tableRef" |
|||
:selection="true" |
|||
v-clientTable |
|||
:columns="tableColumns" |
|||
:data="tableObject.tableList" |
|||
:loading="tableObject.loading" |
|||
:pagination="{ |
|||
total: tableObject.total |
|||
}" |
|||
v-model:pageSize="tableObject.pageSize" |
|||
v-model:currentPage="tableObject.currentPage" |
|||
v-model:sort="tableObject.sort" |
|||
@getSelectionRows="getSelectionRows" |
|||
> |
|||
<template #number="{row}"> |
|||
<el-button type="primary" link @click="openDetail(row, t('ts.单据号'), row.number)"> |
|||
<span>{{ row.number }}</span> |
|||
</el-button> |
|||
</template> |
|||
<template #differencePrice="{row}"> |
|||
<span :class="{'red-text':row.differencePrice!=0}">{{ row.differencePrice }}</span> |
|||
</template> |
|||
<template #action="{ row,$index }"> |
|||
<ButtonBase :Butttondata="butttondata(row,$index)" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="formRef" |
|||
@success="getList" |
|||
:rules="SupplierinvoiceRecordMainRules" |
|||
:formAllSchemas="SupplierinvoiceRecordMain.allSchemas" |
|||
:tableAllSchemas="SupplierinvoiceRecordDetail.allSchemas" |
|||
:tableFormRules="SupplierinvoiceRecordDetailRules" |
|||
:isBusiness="true" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail |
|||
ref="detailRef" |
|||
:annexTable="[{ |
|||
label: t('ts.合同附件'), |
|||
prop: 'Annex', |
|||
tableName:'contract', |
|||
showDownload:true, |
|||
hiddenDelete:true, |
|||
queryParams:[{ |
|||
queryField:'tableId', |
|||
rowField:'annexMasterId', |
|||
}], |
|||
},{ |
|||
label: t('ts.发票附件'), |
|||
prop: 'Annex', |
|||
tableName:'invoice', |
|||
showDownload:true, |
|||
hiddenDelete:true, |
|||
queryParams:[{ |
|||
queryField:'tableId', |
|||
rowField:'annexMasterId', |
|||
}], |
|||
},{ |
|||
label: t('ts.货运单附件'), |
|||
prop: 'Annex', |
|||
tableName:'waybill', |
|||
showDownload:true, |
|||
hiddenDelete:true, |
|||
queryParams:[{ |
|||
queryField:'tableId', |
|||
rowField:'annexMasterId', |
|||
}], |
|||
},{ |
|||
label: t('ts.其他附件'), |
|||
prop: 'Annex', |
|||
tableName:'invoiceOther', |
|||
showDownload:true, |
|||
hiddenDelete:true, |
|||
queryParams:[{ |
|||
queryField:'tableId', |
|||
rowField:'annexMasterId', |
|||
}], |
|||
}]" |
|||
:annexAlias="{ |
|||
hidden:true, |
|||
label:t('ts.其他附件'), |
|||
showDownload:true, |
|||
hiddenDelete:true |
|||
}" |
|||
:isBasic="false" |
|||
direction="horizontal" |
|||
:column="3" |
|||
:allSchemas="SupplierinvoiceRecordDetailMain.allSchemas" |
|||
:detailAllSchemas="SupplierinvoiceRecordDetail.allSchemas" |
|||
:detailAllSchemasRules="SupplierinvoiceRecordDetailRules" |
|||
:apiPage="SupplierinvoiceRecordDetailApi.getSupplierinvoiceRecordDeatilPage" |
|||
> |
|||
<template #differencePrice="{row}"> |
|||
<span :class="{'red-text':row.differencePrice!=0}">{{ row.differencePrice }}</span> |
|||
</template> |
|||
</Detail> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { SupplierinvoiceRecordMain,SupplierinvoiceRecordMainRules,SupplierinvoiceRecordDetail,SupplierinvoiceRecordDetailRules,SupplierinvoiceRecordDetailMain } from './supplierinvoiceRecordMain.data' |
|||
import * as SupplierinvoiceRecordMainApi from '@/api/wms/supplierinvoiceRecordMain' |
|||
import * as SupplierinvoiceRecordDetailApi from '@/api/wms/supplierinvoiceRecordDeatil' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
|||
import * as SupplierinvoiceRequestDetailApi from '@/api/wms/supplierinvoiceRequestDetail' |
|||
import * as PackageApi from "@/api/wms/package"; |
|||
import {getAccessToken} from "@/utils/auth"; |
|||
import {getJmreportBaseUrl} from "@/utils/systemParam"; |
|||
|
|||
// 供应商发票记录主 |
|||
defineOptions({ name: 'SupplierinvoiceRecordMain' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(SupplierinvoiceRecordMain.allSchemas.tableColumns) |
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: SupplierinvoiceRecordMainApi.getSupplierinvoiceRecordMainPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultExportBtn({hasPermi:'wms:supplierinvoice-record-main:export'}), // 导出 |
|||
defaultButtons.mainLisSelectiontPointBtn(null), // 批量打印 |
|||
defaultButtons.defaultFreshBtn(null), // 刷新 |
|||
defaultButtons.defaultFilterBtn(null), // 筛选 |
|||
defaultButtons.defaultSetBtn(null), // 设置 |
|||
// { |
|||
// label: '自定义扩展按钮', |
|||
// name: 'zdy', |
|||
// hide: false, |
|||
// type: 'primary', |
|||
// icon: 'Select', |
|||
// color: '' |
|||
// }, |
|||
] |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'export') { // 导出 |
|||
handleExport() |
|||
}else if (val=='selection_point'){// 批量打印 |
|||
handleSelectionPoint() |
|||
} else if (val == 'refresh') { // 刷新 |
|||
if (tableObject.params.filters && tableObject.params.filters.length > 0 ) { |
|||
searchFormClick({ |
|||
filters: tableObject.params.filters |
|||
}) |
|||
} else { |
|||
getList() |
|||
} |
|||
} else if (val == 'filtrate') { // 筛选 |
|||
}else { // 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
} |
|||
|
|||
const BASE_URL = getJmreportBaseUrl() |
|||
const srcPoint = ref(BASE_URL + '/jmreport/view/970966724605804544?token=' + getAccessToken()) |
|||
const handleSelectionPoint = async ()=>{ |
|||
let rows:any = [] |
|||
selectionRows.value.forEach(item=>{ |
|||
rows = [...rows,...item.selectionRows.map(item1=>item1.id)] |
|||
}) |
|||
if(rows.length==0){ |
|||
message.warning('至少选择一条数据!') |
|||
return |
|||
} |
|||
console.log('批量打印',rows.join(',')) |
|||
window.open(srcPoint.value+'&ids='+rows.join(',')) |
|||
} |
|||
|
|||
// 列表-操作按钮 |
|||
const butttondata = (row,$index) => { |
|||
return [ |
|||
{ |
|||
label: t('ts.查看明细'), |
|||
name: 'open_detail', |
|||
type: 'primary', |
|||
icon: '', |
|||
color: '', |
|||
hasPermi: '', |
|||
link: true, // 文本展现按钮 |
|||
} |
|||
] |
|||
} |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'open_detail') { // 查看明细 |
|||
openDetail(row, '单据号', row.number) |
|||
} |
|||
} |
|||
// 获取部门 用于详情 部门回显 |
|||
const { wsCache } = useCache() |
|||
/** 详情操作 */ |
|||
const detailRef = ref() |
|||
const openDetail = async (row: any, titleName: any, titleValue: any) => { |
|||
console.log('openDetail',row) |
|||
const departmentCode = wsCache.get(CACHE_KEY.DEPT).find((account) => account.id == row.departmentCode)?.name |
|||
//获取申请中的masterId |
|||
const { tableObject: requestTableObject, tableMethods:requestTableMethods } = useTable({ |
|||
getListApi: SupplierinvoiceRequestDetailApi.getSupplierinvoiceRequestDetailPage // 分页接口 |
|||
}) |
|||
const { getList:requestGetList } = requestTableMethods |
|||
requestTableObject.params.number = row.requestNumber |
|||
await requestGetList() |
|||
if(requestTableObject.tableList.length>0){ |
|||
row.annexMasterId = requestTableObject.tableList[0].masterId |
|||
} |
|||
|
|||
|
|||
if (departmentCode) row.departmentCode = JSON.parse(JSON.stringify(departmentCode)) |
|||
detailRef.value.openDetail(row, titleName, titleValue) |
|||
} |
|||
const searchList = (model)=>{ |
|||
if(model.postingDate&&model.postingDate.length>1){ |
|||
model.postingDate[1] = model.postingDate[1].replace('00:00:00','23:59:59') |
|||
} |
|||
selectionRows.value = [] |
|||
setSearchParams(model) |
|||
} |
|||
const selectionRows = ref<any>([]) |
|||
const tableRef = ref() |
|||
const getSelectionRows = (currentPage,currentPageSelectionRows) => { |
|||
console.log("getSelectionRows",currentPage,currentPageSelectionRows) |
|||
const currentRows = selectionRows.value.find(item=>item.currentPage==currentPage) |
|||
if(currentRows){ |
|||
currentRows.selectionRows = currentPageSelectionRows |
|||
}else{ |
|||
selectionRows.value.push({ |
|||
currentPage, |
|||
selectionRows:currentPageSelectionRows |
|||
}) |
|||
} |
|||
} |
|||
/** 导出按钮操作 */ |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
let rows:any = [] |
|||
selectionRows.value.forEach(item=>{ |
|||
rows = [...rows,...item.selectionRows.map(item1=>item1.number)] |
|||
}) |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await SupplierinvoiceRecordMainApi.exportSupplierinvoiceRecordMain({...tableObject.params,checkNums:rows}) |
|||
download.excel(data, `${t('ts.供应商发票记录主')}.xlsx`) |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
} |
|||
|
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
} |
|||
getList() // 刷新当前列表 |
|||
} |
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
}) |
|||
</script> |
|||
<style lang="scss" scoped> |
|||
.is-red{ |
|||
border-radius:var(--el-border-radius-base); |
|||
border:1px solid var(--el-color-danger); |
|||
box-shadow: 0 0 0 1px var(--el-color-danger) inset; |
|||
} |
|||
.red-text{ |
|||
color:var(--el-color-danger); |
|||
font-weight:700; |
|||
} |
|||
</style> |
@ -0,0 +1,475 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search class="search-box" :schema="SupplierinvoiceRequestMain.allSchemas.searchSchema" @search="searchList" @reset="resetList" > |
|||
<template #cha> |
|||
<div style="display:flex;flex-direction: row"> |
|||
<el-input-number v-model="staDifferencePrice" :max="endDifferencePrice" size="small" :placeholder="t('ts.最小值')"/>-<el-input-number v-model="endDifferencePrice" :min="staDifferencePrice" size="small" :placeholder="t('ts.最大值')"/> |
|||
</div> |
|||
</template> |
|||
</Search> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="SupplierinvoiceRequestMain.allSchemas" |
|||
|
|||
/> |
|||
|
|||
<!-- 列表 --> |
|||
<ContentWrap> |
|||
<Table ref="tableRef" |
|||
:selection="true" |
|||
:selectionColor="true" |
|||
v-clientTable :columns="tableColumns" :data="tableObject.tableList" :loading="tableObject.loading" :pagination="{ |
|||
total: tableObject.total |
|||
}" v-model:pageSize="tableObject.pageSize" v-model:currentPage="tableObject.currentPage" |
|||
v-model:sort="tableObject.sort" |
|||
@getSelectionRows="getSelectionRows" |
|||
> |
|||
<template #number="{row}"> |
|||
<el-button type="primary" link @click="openDetail(row, '单据号', row.number)"> |
|||
<span>{{ row.number }}</span> |
|||
</el-button> |
|||
</template> |
|||
<template #differencePrice="{row}"> |
|||
<span :class="{'red-text':row.differencePrice!=0}">{{ Number(row.differencePrice).toFixed(2) }}</span> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
|
|||
<!-- 详情 --> |
|||
<Detail |
|||
ref="detailRef" |
|||
:isOpenSearchTable="true" |
|||
fieldTableColumn="poLine" |
|||
:annexTable="detailAnnexTable" |
|||
direction="horizontal" |
|||
:column="3" |
|||
:annexAlias="{ |
|||
hidden:true, |
|||
label:t('ts.其他附件') |
|||
}" |
|||
:otherHeadButttonData="[{ |
|||
label: t('ts.打印明细'), |
|||
name: 'printing', |
|||
hide: false, |
|||
type: 'primary', |
|||
// icon: 'ep:operation', |
|||
color: '', |
|||
float:'left', |
|||
hasPermi: '' |
|||
},{ |
|||
label: t('ts.打印全部发货单'), |
|||
name: 'printing-all', |
|||
hide: false, |
|||
type: 'primary', |
|||
// icon: 'ep:operation', |
|||
color: '', |
|||
float:'left', |
|||
hasPermi: '' |
|||
},{ |
|||
label: t('ts.导出明细'), |
|||
name: 'export-detail', |
|||
hide: false, |
|||
type: 'primary', |
|||
// icon: 'ep:operation', |
|||
color: '', |
|||
float:'left', |
|||
hasPermi: '' |
|||
}]" |
|||
:buttondataTable = "[{ |
|||
label: t('ts.打印'), |
|||
name: 'print', |
|||
hide: false, |
|||
type: 'primary', |
|||
// icon: 'ep:operation', |
|||
color: '', |
|||
float:'left', |
|||
link: true, // 文本展现按钮 |
|||
hasPermi: '' |
|||
}]" |
|||
:sumFormDataByForm ="(formRef,formModel)=>{ |
|||
const {singlePrice=0,purchasePrice=0} = formModel |
|||
formRef.value.setValues({ |
|||
differencePrice:Number((Number(singlePrice)-Number(purchasePrice)).toFixed(2)) |
|||
}) |
|||
}" |
|||
:isBasic="false" |
|||
:allSchemas="SupplierinvoiceRequestDetailMain.allSchemas" |
|||
:detailAllSchemas="SupplierinvoiceRequestDetail.allSchemas" |
|||
:detailAllSchemasRules="SupplierinvoiceRequestDetailRules" |
|||
:searchTableParams="searchTableParams" |
|||
:apiCreate="SupplierinvoiceRequestDetailApi.createSupplierinvoiceRequestDetail" |
|||
:apiUpdate="SupplierinvoiceRequestDetailApi.updateSupplierinvoiceRequestDetail" |
|||
:apiPage="SupplierinvoiceRequestDetailApi.getSupplierinvoiceRequestDetailPage" |
|||
:apiDelete="SupplierinvoiceRequestDetailApi.deleteSupplierinvoiceRequestDetail" |
|||
:Echo="Echo" |
|||
:detailButtonIsShowEdit="false" |
|||
:detailButtonIsShowDelete="false" |
|||
:detailButtonIsShowAdd="false" |
|||
@buttonBaseClick="detailButtonBaseClick" |
|||
@tableFormButton="tableFormButton" |
|||
:mainSubmitCreateApi="true" |
|||
@searchTableSuccessDetail="searchTableSuccessDetail" |
|||
@handleMainFefresh="handleMainFefresh" |
|||
> |
|||
<template #differencePrice="{row}"> |
|||
<span :class="{'red-text':row.differencePrice!=0}">{{ row.differencePrice }}</span> |
|||
</template> |
|||
</Detail> |
|||
|
|||
|
|||
</template> |
|||
<script setup lang="ts"> |
|||
import dayjs from 'dayjs' |
|||
// 供应商发票申请 |
|||
import download from '@/utils/download' |
|||
import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
|||
import { SupplierinvoiceRequestMain, |
|||
SupplierinvoiceRequestMainRules, |
|||
SupplierinvoiceRequestDetail, |
|||
SupplierinvoiceRequestDetailRules, |
|||
SupplierinvoiceRequestFinance, |
|||
SupplierinvoiceRequestFinanceRules, |
|||
PurchasePass, |
|||
PurchasePassRules, |
|||
SupplierinvoiceRequestDetailMain |
|||
} from './supplierinvoiceRequestMainDifference.data' |
|||
import * as SupplierinvoiceRequestMainApi from '@/api/wms/supplierinvoiceRequestMain' |
|||
import * as SupplierinvoiceRequestDetailApi from '@/api/wms/supplierinvoiceRequestDetail' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import * as SupplierApi from '@/api/wms/supplier' |
|||
import { Supplier } from '../../../basicDataManage/supplierManage/supplier/supplier.data' |
|||
import { getAccessToken } from '@/utils/auth' |
|||
import { ElMessageBox } from 'element-plus' |
|||
import { getJmreportBaseUrl } from '@/utils/systemParam' |
|||
import { accountantFormart } from '@/utils/formatter' |
|||
|
|||
defineOptions({ name: 'SupplierinvoiceRequestMain' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(SupplierinvoiceRequestMain.allSchemas.tableColumns) |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
|
|||
// 查询列表页面参数设置 |
|||
const searchTableParams = ref([ |
|||
{ |
|||
formField: 'supplierCode', |
|||
searchTableTitle: t('ts.供应商信息'), |
|||
searchTableAllSchemas: Supplier.allSchemas, |
|||
searchTablePage: SupplierApi.getSupplierPage |
|||
} |
|||
]) |
|||
|
|||
const staDifferencePrice = ref() |
|||
const endDifferencePrice = ref() |
|||
const searchList = (model)=>{ |
|||
model.staDifferencePrice = staDifferencePrice.value |
|||
model.endDifferencePrice = endDifferencePrice.value |
|||
console.log('searchList',model) |
|||
selectionRows.value = [] |
|||
setSearchParams(model) |
|||
} |
|||
const resetList = (model)=>{ |
|||
staDifferencePrice.value = null |
|||
endDifferencePrice.value = null |
|||
searchList(model) |
|||
} |
|||
const selectionRows = ref<any>([]) |
|||
const tableRef = ref() |
|||
const getSelectionRows = (currentPage,currentPageSelectionRows) => { |
|||
console.log("getSelectionRows",currentPage,currentPageSelectionRows) |
|||
const currentRows = selectionRows.value.find(item=>item.currentPage==currentPage) |
|||
if(currentRows){ |
|||
currentRows.selectionRows = currentPageSelectionRows |
|||
}else{ |
|||
selectionRows.value.push({ |
|||
currentPage, |
|||
selectionRows:currentPageSelectionRows |
|||
}) |
|||
} |
|||
} |
|||
const handleMainFefresh = ()=>{ |
|||
getList() |
|||
} |
|||
|
|||
const searchTableSuccessDetail = async (formField, searchField, val, formRef,searchTableFormModel)=>{ |
|||
console.log('详情',formField, searchField, val, formRef,searchTableFormModel) |
|||
val.forEach(item=>{ |
|||
item.deliveryDate = item['prhRcpDate'] |
|||
item.arrivalQty = item['prhRcvd'] |
|||
}) |
|||
await SupplierinvoiceRequestDetailApi.createSupplierinvoiceRequestDetail({ |
|||
masterId:searchTableFormModel.masterId, |
|||
subList:val |
|||
}) |
|||
detailRef.value.updateList() |
|||
getList() |
|||
} |
|||
|
|||
|
|||
const Echo = [] |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
defaultParams:{ |
|||
balanceStatementStatus : 'TRUE' |
|||
}, |
|||
getListApi: SupplierinvoiceRequestMainApi.getSupplierinvoiceRequestMainPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultExportBtn({hasPermi: 'wms:supplierinvoice-request-main:export'}), // 导出 |
|||
defaultButtons.defaultFreshBtn(null), // 刷新 |
|||
defaultButtons.defaultFilterBtn(null), // 筛选 |
|||
defaultButtons.defaultSetBtn(null), // 设置 |
|||
] |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'export') { // 导出 |
|||
handleExport() |
|||
} else if (val == 'refresh') { // 刷新 |
|||
if (tableObject.params.filters && tableObject.params.filters.length > 0 ) { |
|||
searchFormClick({ |
|||
filters: tableObject.params.filters |
|||
}) |
|||
} else { |
|||
getList() |
|||
} |
|||
} else if (val == 'filtrate') { // 筛选 |
|||
} else { // 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
} |
|||
|
|||
// 获取部门 用于详情 部门回显 |
|||
const { wsCache } = useCache() |
|||
/** 详情操作 */ |
|||
const detailRef = ref() |
|||
const clicKRowId = ref(); |
|||
const detailAnnexTable = ref( |
|||
[{ |
|||
label: t('ts.合同附件'), |
|||
prop: 'Annex', |
|||
tableName:'contract', |
|||
hiddenDelete:true, |
|||
hiddenUpload:true, |
|||
fileSize:20 |
|||
},{ |
|||
label: t('ts.发票附件'), |
|||
prop: 'Annex', |
|||
tableName:'invoice', |
|||
hiddenDelete:true, |
|||
hiddenUpload:true, |
|||
fileSize:20 |
|||
|
|||
},{ |
|||
label: t('ts.货运单附件'), |
|||
prop: 'Annex', |
|||
tableName:'waybill', |
|||
hiddenDelete:true, |
|||
hiddenUpload:true, |
|||
fileSize:20 |
|||
},{ |
|||
label: t('ts.其他附件'), |
|||
prop: 'Annex', |
|||
tableName:'invoiceOther', |
|||
hiddenDelete:true, |
|||
hiddenUpload:true, |
|||
fileSize:20 |
|||
}]) |
|||
const openDetail = (row : any, titleName : any, titleValue : any) => { |
|||
const departmentCode = wsCache.get(CACHE_KEY.DEPT).find((account) => account.id == row.departmentCode)?.name |
|||
if (departmentCode) row.departmentCode = JSON.parse(JSON.stringify(departmentCode)) |
|||
clicKRowId.value = row.id |
|||
detailRef.value.openDetail(row, titleName, titleValue) |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
let rows:any = [] |
|||
selectionRows.value.forEach(item=>{ |
|||
rows = [...rows,...item.selectionRows.map(item1=>item1.number)] |
|||
}) |
|||
|
|||
let paramsData =JSON.parse(JSON.stringify(tableObject.params)) |
|||
if(tableObject.params&&tableObject.params.isSearch==true){ |
|||
paramsData.filters.push({ |
|||
action: "in", |
|||
column: "number", |
|||
value: rows.join(",") |
|||
}) |
|||
}else{ |
|||
paramsData = {...paramsData,checkNums:rows} |
|||
} |
|||
console.log('批量导出',paramsData) |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await SupplierinvoiceRequestMainApi.exportSupplierinvoiceRequestMain(paramsData) |
|||
download.excel(data, `${t('ts.供应商发票申请主')}.xlsx`) |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* tableForm方法 |
|||
*/ |
|||
const tableFormKeys = {} |
|||
SupplierinvoiceRequestDetail.allSchemas.tableFormColumns.forEach(item => { |
|||
tableFormKeys[item.field] = item.default ? item.default : '' |
|||
}) |
|||
const tableData = ref([]) |
|||
|
|||
// 导入附件弹窗所需的参数 |
|||
const importTemplateData = reactive({ |
|||
templateUrl: '', |
|||
templateTitle: `${t('ts.供应商发票申请主导入模板')}.xlsx` |
|||
}) |
|||
|
|||
|
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: [...searchData.filters,{ |
|||
action: "==", |
|||
column: "balanceStatementStatus", |
|||
value: "TRUE" |
|||
}] |
|||
} |
|||
getList() // 刷新当前列表 |
|||
} |
|||
|
|||
// 详情--头部按钮事件 |
|||
const detailButtonBaseClick = (val, item) => { |
|||
console.log("点击的按钮",val) |
|||
if(val == 'printing'){ |
|||
// 单据打印 |
|||
handleDocumentPrint(clicKRowId.value) |
|||
}else if(val === 'printing-all'){ |
|||
//打印全部发货单 |
|||
handlePrintAll(clicKRowId.value) |
|||
}else if(val === 'export-detail'){ |
|||
console.log("导出明细:",clicKRowId.value) |
|||
handleDetailExport(clicKRowId.value) |
|||
} |
|||
} |
|||
|
|||
const tableFormButton = (val, item) => { |
|||
console.log("点击的按钮",val) |
|||
if(val == 'print'){ |
|||
// 打印 |
|||
SupplierinvoiceRequestMainApi.printSupplierRecord(item.asnBillNum).then(res =>{ |
|||
if(res){ |
|||
handleSupplierdeliverRecordPrint(res); |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
|
|||
/** 导出明细按钮操作 */ |
|||
const exportLoadingDetail = ref(false) // 导出的加载中 |
|||
const handleDetailExport = async (masterId) => { |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出导出明细 |
|||
exportLoadingDetail.value = true |
|||
let params = { |
|||
masterId: masterId |
|||
} |
|||
const data = await SupplierinvoiceRequestMainApi.exportSupplierinvoiceRequestDetail(params) |
|||
download.excel(data, `${t('ts.供应商发票申请明细')}.xlsx`) |
|||
} catch { |
|||
} finally { |
|||
exportLoadingDetail.value = false |
|||
} |
|||
} |
|||
|
|||
const BASE_URL = getJmreportBaseUrl() |
|||
|
|||
//供应商发货单打印 |
|||
const documentSupplierdeliverRecordSrc = ref(BASE_URL + '/jmreport/view/932556833517789184?token=' + getAccessToken()) |
|||
const handleSupplierdeliverRecordPrint = async (id) => { |
|||
window.open(documentSupplierdeliverRecordSrc.value + '&id=' + id) |
|||
} |
|||
|
|||
// 单据打印 |
|||
const documentSrc = ref(BASE_URL + '/jmreport/view/936875675614240768?token=' + getAccessToken()) |
|||
const handleDocumentPrint = async (id) => { |
|||
window.open(documentSrc.value + '&id=' + id) |
|||
} |
|||
|
|||
const handlePrintAll = async (masterId) => { |
|||
// 打印 |
|||
SupplierinvoiceRequestMainApi.printSupplierRecordByMasterId(masterId).then(res =>{ |
|||
if(res && res.length > 0){ |
|||
for(let i=0;i<res.length;i++){ |
|||
let id = res[i]; |
|||
handleSupplierdeliverRecordPrint(id); |
|||
} |
|||
}else{ |
|||
message.warning(t('ts.非SCP订单无法打印')) |
|||
return; |
|||
} |
|||
}) |
|||
} |
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
importTemplateData.templateUrl = await SupplierinvoiceRequestMainApi.importTemplate() |
|||
}) |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.is-red{ |
|||
border-radius:var(--el-border-radius-base); |
|||
border:1px solid var(--el-color-danger); |
|||
box-shadow: 0 0 0 1px var(--el-color-danger) inset; |
|||
} |
|||
.red-text{ |
|||
color:var(--el-color-danger); |
|||
font-weight:700; |
|||
} |
|||
.search-box .el-input-number__decrease { |
|||
display: none !important; |
|||
} |
|||
::v-deep(.el-input-number__decrease) { |
|||
display: none !important; |
|||
} |
|||
::v-deep(.el-input-number__increase) { |
|||
display: none !important; |
|||
} |
|||
|
|||
|
|||
</style> |
|||
./supplierinvoiceRequestMainDifference.data |
File diff suppressed because it is too large
Loading…
Reference in new issue