<script>
|
export default {
|
data() {
|
return {
|
// 选择器配置参数
|
selectorConfig: {
|
title: '物料选择器',
|
width: '1000px',
|
visible: false,
|
// 配置路由
|
router: '/selector/s-product-selector'
|
},
|
selectorPositionConfig: {
|
title: '物料库存选择器',
|
width: '1000px',
|
visible: false,
|
// 配置路由
|
router: '/selector/x-product-selector',
|
url: '/api/common/GroupDataList'
|
},
|
// 明细转移是否显示
|
detailtransferVisible: false,
|
// 批量更改折扣率是否显示
|
batchupdateVisible: false,
|
// 批量拆分是否显示
|
batchtransferVisible: false,
|
// 批量拆分导入是否显示
|
batchimportVisible: false,
|
formLabelWidth: '120px',
|
// 明细拆分列表
|
splitDetails: [],
|
// 显示确认入库对话框
|
checkEnterVisible: false
|
}
|
},
|
methods: {
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case 'auditing':
|
// 批量审核
|
this.batchAuditing(this.dataListSelections)
|
return false
|
case 'inTransit':
|
// 确认为在途中
|
this.onInTransit()
|
return false
|
case 'determine':
|
// 付款确认
|
this.determine()
|
return false
|
case 'forceFinish':
|
// 强制完成
|
this.forceFinish()
|
return false
|
// 导入
|
case 'allImport':
|
this.orderInfoImportConfig.isShowDialog = true
|
return false
|
// 合并
|
case 'beTogether':
|
this.beTogether()
|
return false
|
// 一键确认入库
|
case 'confirmQuickEnter':
|
this.confirmQuickEnter()
|
return false
|
// 新建
|
case 'addOrder':
|
this.dialogFormVisible = true
|
return true
|
case 'print':
|
// 打印
|
this.print()
|
return true
|
case 'labelPrint':
|
// 打印物流单
|
this.printExpress()
|
break
|
}
|
},
|
// 明细按钮点击事件
|
detailButtonClick(authNode) {
|
switch (authNode) {
|
case 'detailAdd':
|
// 物料明细添加
|
this.detailAdd()
|
return true
|
case 'detailTransfer':
|
// 明细转移
|
this.detailTransfer()
|
return true
|
case 'batchUpdate':
|
// 批量设置折扣率
|
this.batchUpdate()
|
return true
|
case 'batchTransfer':
|
// 批量拆分
|
this.batchTransfer()
|
return true
|
case 'batchImport':
|
// 批量拆分导入
|
this.batchImport()
|
return true
|
// 明细添加 - 物料库存
|
case 'detailAddPosition':
|
this.openPositionSelected()
|
return true
|
// 明细导出
|
case 'exportList':
|
this.exportList()
|
return true
|
// 明细导入
|
case 'importList':
|
// this.importList();
|
// return true;
|
// 批量导入
|
this.orderImportConfig.isShowDialog = true
|
return false
|
case 'detailSplitOrders':
|
// 拆分订单
|
this.splitOrder()
|
return false
|
}
|
},
|
// 编辑按钮点击事件
|
editButtonClick(authNode, formData) {
|
switch (authNode) {
|
case 'auditing':
|
// 批量审核
|
this.batchAuditing([formData])
|
return false
|
}
|
},
|
// 审核
|
batchAuditing(dataListSelections) {
|
let isok = true
|
const order_Ids = dataListSelections.map((item, index, Array) => {
|
return item.order_Id
|
})
|
const statusText = dataListSelections.map((item, index, Array) => {
|
return item.statusText
|
})
|
statusText.forEach(status => {
|
if (status !== '新建') {
|
isok = false
|
}
|
})
|
if (isok === false) {
|
this.$message.error('只有新建货单,可以审核!')
|
return false
|
}
|
if (!order_Ids.length) {
|
this.$message.error('请至少选择一行数据!')
|
return false
|
}
|
this.$confirm('提示:确认后将无法进行修改', '确认审核', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
const url = '/api/inbound/order/batchAuditing'
|
const params = {
|
openNodeApi: true,
|
order_Ids: order_Ids
|
}
|
const ref = this.dataList
|
var callback = res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
ref.loadData()
|
}
|
}
|
this.common.ajax(url, params, callback, ref)
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消'
|
})
|
})
|
},
|
// 确认为在途中
|
onInTransit() {
|
const order_Ids = this.dataListSelections.map((item, index, Array) => {
|
return item.order_Id
|
})
|
if (!order_Ids.length) {
|
this.$message.error('请至少选择一行数据!')
|
return false
|
}
|
const statusText = ['审核成功']
|
const filterList = this.dataListSelections.filter((item, index, Array) => {
|
return statusText.indexOf(item.statusText) >= 0
|
})
|
if (!filterList.length) {
|
this.$message.error(`只有${statusText.join(',')}才可以确认为在途中!`)
|
return false
|
}
|
this.$confirm('是否确认为在途中?', '确认为在途中', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
// order_Id = order_Id[0];
|
const url = '/api/inbound/order/onInTransit'
|
const params = {
|
order_Ids: order_Ids,
|
openNodeApi: true,
|
isFullPlate: 1
|
}
|
const ref = this.dataList
|
var callback = res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
this.$message.success(res.msg)
|
ref.loadData()
|
}
|
}
|
this.common.ajax(url, params, callback, ref)
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消'
|
})
|
})
|
},
|
// 强制完成
|
forceFinish() {
|
let isok = true
|
let order_Id = this.dataListSelections.map((item, index, Array) => {
|
return item.order_Id
|
})
|
const statusText = this.dataListSelections.map((item, index, Array) => {
|
return item.statusText
|
})
|
if (!order_Id.length) {
|
this.$message.error('请至少选择一行数据!')
|
return false
|
}
|
statusText.forEach(rowData => {
|
if (rowData !== '部分交货') return (isok = false)
|
})
|
if (isok === false) {
|
this.$message.error('仅可部分交货时强制完成!')
|
return false
|
}
|
this.$confirm('强制完成后,剩余未收货物料将无法继续收货,是否继续?', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
order_Id = order_Id[0]
|
const url = '/api/inbound/order/forceFinish'
|
const params = {
|
openNodeApi: true,
|
order_Id: order_Id
|
}
|
const ref = this.dataList
|
var callback = res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
this.$message.success(res.msg)
|
ref.loadData()
|
}
|
}
|
this.common.ajax(url, params, callback, ref)
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消'
|
})
|
})
|
},
|
// 导入主表和明细
|
allAllImport() {
|
// window.location.href = "#/inbound/purchase/inbound/import/purchase-order";
|
this.$router.push('/inbound/import/purchase-order')
|
},
|
// 合并
|
beTogether() {
|
// 得到,明细选中项
|
var IsOrderStatus = true // 状态
|
const selectIDs = this.dataListSelections
|
.map((item, index, Array) => {
|
if (item.statusText !== '新建') {
|
IsOrderStatus = false
|
} else {
|
IsOrderStatus = true
|
}
|
return item.order_Id
|
})
|
.join(',')
|
if (selectIDs === '') {
|
this.$message({
|
message: '至少选中一行!',
|
type: 'warning'
|
})
|
return false
|
}
|
if (IsOrderStatus === false) {
|
this.$message({
|
message: '新建状态才能合并!',
|
type: 'warning'
|
})
|
return false
|
}
|
|
this.$confirm('确定要合并选中预到货单吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消'
|
})
|
.then(() => {
|
// 获得已选中的ID
|
const selectIDs = this.dataListSelections.map((item, index, Array) => {
|
return item.order_Id
|
})
|
const url = '/api/inbound/order/orderMerge'
|
const params = {
|
order_Ids: selectIDs
|
}
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res)
|
const ref = this.dataList
|
if (res.result) {
|
ref.loadData()
|
}
|
})
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消合并'
|
})
|
})
|
},
|
// 一键入库
|
confirmQuickEnter() {
|
if (this.dataListSelections.length !== 1) {
|
this.$message.error('请选择一条预到货单进行操作')
|
return false
|
}
|
const rowInfo = this.dataListSelections[0]
|
|
const statusText = rowInfo.statusText
|
const statusList = ['新建', '审核成功', '在途中', '部分交货']
|
if (statusList.indexOf(statusText) < 0) {
|
this.$message.error(`只有【${statusList.join(',')}】的单据才允许入库!`)
|
return false
|
}
|
this.checkEnterVisible = true // 显示对话框
|
var order_Id = rowInfo.order_Id
|
var storage_Id = rowInfo.storage_Id
|
var plateCode = rowInfo.plateCode
|
this.$refs.checkEnterDialog.initData(order_Id, storage_Id, plateCode)
|
},
|
// 拆分订单
|
splitOrder() {
|
this.detailsplitimportVisible = true
|
const datas = this.editorOptions.fields.filter(item => item.type === 'detail-grid')[0].options.detailSelections
|
const splitDetails = JSON.parse(JSON.stringify(datas))
|
const order_Id = this.editor.formData['order_Id']
|
this.$refs.detailsplitDialog.initData(splitDetails, order_Id)
|
},
|
// 显示一次性收费项弹窗
|
showFeeTtemPopup() {
|
const order_Id = this.editor.formData['order_Id']
|
if (!order_Id) {
|
this.$message({
|
message: '当前数据没有保存!',
|
type: 'warning'
|
})
|
return
|
}
|
// 显示一次性收费项弹窗
|
this.isFeeTtemPopupVisible = true
|
this.$refs.feeTtemPopupDialog.initData(order_Id)
|
},
|
// 打开物料选择器
|
detailAdd() {
|
const selector = this.$refs['selector-dialog']
|
selector.loadData()
|
this.selectorConfig.visible = true
|
},
|
// 将选择器选择中的数据填充到明细表中
|
onSelected(rows) {
|
debugger
|
rows.forEach(row => {
|
this.$set(row, 'originPlace', row.originPlace)
|
this.$set(row, 'quantity', 1)
|
this.$set(row, 'totalPackageQty', 1)
|
this.$set(row, 'totalWeight', row.weight)
|
this.$set(row, 'taxAmount', row.ratePrice)
|
this.$set(row, 'rateMoney', row.ratePrice)
|
this.$set(row, 'purchaseMoney', row.purchasePrice)
|
this.$set(row, 'originPlace', row.originPlace)
|
this.$set(row, 'totalPackageQty', 1)
|
this.$set(row, 'relationCode', row.typeName)
|
this.$set(row, 'productSpec', row.productSpec)
|
})
|
this.editor.addDetailDataRow(rows)
|
this.selectorConfig.visible = false
|
this.setTotal()
|
},
|
// 打开库存选择器
|
openPositionSelected() {
|
var editorRef = this.editor
|
if (!editorRef.formData.consignorName) {
|
this.$message({
|
message: '请选择货主!',
|
type: 'warning'
|
})
|
return
|
}
|
const selector = this.$refs['selector-position-dialog']
|
selector.setSearchValue('storage_Id', [editorRef.formData.storage_Id])
|
selector.setSearchValue('consignor_Id', [editorRef.formData.consignor_Id])
|
selector.setReadOnly('storage_Id', true) // 设为只读
|
selector.setReadOnly('consignor_Id', true) // 设为只读
|
|
selector.loadData()
|
this.selectorPositionConfig.visible = true
|
},
|
// 将库存物料选择器选择中的数据填充到明细表中
|
onPositionSelected(rows) {
|
rows.forEach(element => {
|
element.quantity = element.productStorage
|
element.totalPackageQty = element.quantity
|
element.singleSignCode = ''
|
this.$set(element, 'ratePrice', element.purchasePrice * (1 - (element.rate || 0)))
|
this.$set(element, 'taxAmount', element.ratePrice * element.productStorage)
|
this.$set(element, 'rateMoney', element.ratePrice * element.productStorage)
|
this.$set(element, 'originPlace', element.originPlace)
|
this.$set(element, 'totalPackageQty', element.quantity)
|
})
|
this.editor.addDetailDataRow(rows)
|
this.selectorPositionConfig.visible = false
|
this.setTotal()
|
},
|
// 明细转移
|
detailTransfer() {
|
const orderList_Ids = []
|
if (this.editor.detailFields[0].options.detailSelections.length < 1) {
|
this.$message.error('至少选中一行明细数据!')
|
return false
|
}
|
const order_Id = this.editor.detailFields[0].options.detailSelections[0]['order_Id']
|
|
this.detailtransferVisible = true
|
this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
|
orderList_Ids.push(rowData.orderList_Id)
|
})
|
|
this.$refs['detailtransfer-dialog'].order_Id = order_Id
|
this.$refs['detailtransfer-dialog'].detailIdList = orderList_Ids.join(',')
|
this.editor.config.visible = false
|
},
|
// 批量设置折扣率
|
batchUpdate() {
|
let orderList_Ids = []
|
if (this.editor.detailFields[0].options.detailSelections.length < 1) {
|
this.$message.error('至少选中一行明细数据!')
|
return false
|
}
|
this.batchupdateVisible = true
|
this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
|
orderList_Ids.push(rowData.orderList_Id)
|
})
|
orderList_Ids = orderList_Ids.join(',')
|
this.$refs['batchupdate-dialog'].showDetailIdList(orderList_Ids)
|
},
|
// 批量拆分
|
batchTransfer() {
|
const rows = []
|
if (this.editor.detailFields[0].options.detailSelections.length < 1) {
|
this.$message.error('至少选中一行明细数据!')
|
return false
|
}
|
this.batchtransferVisible = true
|
this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
|
rows.push(rowData)
|
})
|
this.$refs['batchtransfer-dialog'].showData(rows)
|
},
|
// 批量拆分导入
|
batchImport() {
|
const rows = []
|
if (this.editor.detailFields[0].options.detailSelections.length < 1) {
|
this.$message.error('至少选中一行明细数据!')
|
return false
|
}
|
this.batchimportVisible = true
|
this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
|
rows.push(rowData)
|
})
|
this.$refs['batchimport-dialog'].showData(rows)
|
},
|
// 明细导出
|
exportList() {
|
const ids = []
|
var formData = this.editor.formData
|
var detailRows = formData['Purchase_OrderList'].rows
|
detailRows.map((item, index, array) => {
|
ids.push(item.orderList_Id)
|
})
|
var url = '/api/inbound/order/exportList'
|
const params = {
|
ids: ids.join(',')
|
}
|
var callback = res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
const url = this.common.domain + '/api/common/download?url=' + res.data.url
|
window.open(url)
|
}
|
}
|
this.common.ajax(url, params, callback, true)
|
},
|
// 打印条码
|
printBarcode(formData, details, type) {
|
// 得到,明细选中项
|
var detailSelections = details[0].options.detailSelections
|
if (!detailSelections.length) {
|
this.$message.error('至少选择一项!')
|
return
|
}
|
// 自定义打印字段数据
|
var keyValues = [{ key: '供应商', value: formData.providerShortName }]
|
|
if (['middleBarcode', 'bigBarcode'].indexOf(type) >= 0) {
|
const url = '/api/basicInfo/base/productInfo/getBarcode'
|
const params = {
|
type: type,
|
code: detailSelections.map(item => {
|
return item.productModel
|
})
|
}
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
let rows = JSON.parse(JSON.stringify(detailSelections))
|
rows = rows.filter(item => {
|
return res.data.some(row => {
|
const exist = row.productModel === item.productModel
|
if (exist) {
|
item.productModel = row[type]
|
}
|
return exist
|
})
|
})
|
this.barcodeVisible = true
|
this.$refs['barcode-dialog'].showData(rows, keyValues)
|
}
|
},
|
true
|
)
|
} else {
|
this.barcodeVisible = true
|
var rows = JSON.parse(JSON.stringify(detailSelections))
|
this.$refs['barcode-dialog'].showData(rows, keyValues)
|
}
|
},
|
// 打印物流单
|
printExpress() {
|
var ids = []
|
this.dataListSelections.forEach(item => {
|
ids.push(item[this.dataOptions.idField])
|
})
|
if (!ids.length) {
|
this.$message.error('至少选择一项!')
|
return
|
}
|
var url = '/api/inbound/order/getOrderIds'
|
var params = {
|
ids: ids
|
}
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
// this.updatePrintCount(ids); // "logisticsPrint",
|
window.open('/#/print/base2/purchase-order/' + res.data.join(','))
|
}
|
},
|
this.dataList
|
)
|
},
|
// 更新打印次数
|
updatePrintCount(type, ids) {
|
const url = '/api/inbound/order/updatePrintCount'
|
const params = {
|
ids: ids,
|
type: type
|
}
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
this.dataList.reload()
|
}
|
})
|
}
|
// 明细添加后事件
|
// onAddDetailRowAfter(row) {
|
// debugger;
|
// var plateType = this.masterData.plateType;
|
// var plateType_Id = this.masterData.plateType_Id;
|
// const url = "/api/basicInfo/base/productInfo/getListByPlateType";
|
// const params = {
|
// plateType_Id: plateType_Id,
|
// plateType: plateType
|
// };
|
// var callback = res => {
|
// if (res.result) {
|
// this.editor.setDropdownData(34, res.data);
|
// // this.editor.addDetailDataRow(res.data);
|
// }
|
// };
|
// this.common.ajax(url, params, callback, true);
|
// }
|
}
|
}
|
</script>
|