<template>
|
<el-dialog
|
top="10vh"
|
width="80%"
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-tabs v-model="activeName" type="card">
|
<el-tab-pane label="待发货明细" name="待发货明细">
|
<div style="float: left; margin-right: 20px">
|
<el-button
|
type="primary"
|
v-show="dataForm.status !== '02completed'"
|
@click="openStockDialog()"
|
>新增</el-button
|
>
|
<el-button
|
type="primary"
|
v-show="dataForm.status !== '02completed'"
|
@click="deleteOrderStock()"
|
>删除</el-button
|
>
|
</div>
|
<el-table
|
ref="stockTable"
|
:data="escortDetailList"
|
@selection-change="selectionEscortDetail"
|
height="500px"
|
:header-cell-style="{ color: '#999' }"
|
:row-style="{ height: '26px' }"
|
:cell-style="{ padding: '0' }"
|
>
|
<el-table-column type="selection" width="55"></el-table-column>
|
|
<el-table-column
|
label="零件批号"
|
prop="partBatchNo"
|
align="center"
|
show-overflow-tooltip
|
min-width="120px"
|
>
|
<template slot="header">
|
<div style="line-height: 14px;">零件批号</div>
|
<div class="th" @click.stop>
|
<el-input
|
type="text"
|
v-model="queryParam.partBatchNo"
|
@keyup.enter.native="handleEscortDetailList"
|
clearable
|
@clear="handleEscortDetailList"
|
size="mini"
|
></el-input>
|
</div>
|
</template>
|
<template slot-scope="scope">
|
<span>{{ scope.row.partBatchNo }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="零件编号"
|
prop="partNo"
|
align="center"
|
show-overflow-tooltip
|
min-width="120px"
|
>
|
<template slot="header">
|
<div style="line-height: 14px;">零件编号</div>
|
<div class="th" @click.stop>
|
<el-input
|
type="text"
|
v-model="queryParam.partNo"
|
@keyup.enter.native="handleEscortDetailList"
|
clearable
|
@clear="handleEscortDetailList"
|
size="mini"
|
></el-input>
|
</div>
|
</template>
|
<template slot-scope="scope">
|
<span>{{ scope.row.partNo }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="零件名称"
|
prop="partName"
|
align="center"
|
show-overflow-tooltip
|
min-width="120px"
|
>
|
<template slot="header">
|
<div style="line-height: 14px;">零件名称</div>
|
<div class="th" @click.stop>
|
<el-input
|
type="text"
|
v-model="queryParam.partName"
|
@keyup.enter.native="handleEscortDetailList"
|
clearable
|
@clear="handleEscortDetailList"
|
size="mini"
|
></el-input>
|
</div>
|
</template>
|
<template slot-scope="scope">
|
<span>{{ scope.row.partName }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="本次发货数量"
|
prop="deliveryQty"
|
align="center"
|
show-overflow-tooltip
|
min-width="120px"
|
>
|
<template slot="header">
|
<div style="line-height: 14px;">本次发货数量</div>
|
<div class="th" @click.stop>
|
<el-input
|
type="text"
|
v-model="queryParam.deliveryQty"
|
@keyup.enter.native="handleEscortDetailList"
|
clearable
|
@clear="handleEscortDetailList"
|
size="mini"
|
></el-input>
|
</div>
|
</template>
|
<template slot-scope="scope">
|
<span>{{ scope.row.deliveryQty }}</span>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
<el-tab-pane label="押运单" name="押运单">
|
<div>
|
<el-button
|
type="primary"
|
v-show="dataForm.status !== '02completed'"
|
@click="openCustomOrderDialog()"
|
>新增</el-button
|
>
|
<el-button
|
type="primary"
|
v-show="dataForm.status !== '02completed'"
|
@click="cleanForm()"
|
>清空</el-button
|
>
|
</div>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="100px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="押运单号" prop="escortNo">
|
<el-input v-model="dataForm.escortNo" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="订单编号" prop="orderNo">
|
<el-input v-model="dataForm.orderNo"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="要求到货日期" prop="requestDate">
|
<el-date-picker
|
style="width: 100%"
|
v-model="dataForm.requestDate"
|
type="date"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="客户订单号" prop="customerOrderNo">
|
<el-input v-model="dataForm.customerOrderNo"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="工程名称" prop="entityName">
|
<el-input v-model="dataForm.entityName"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="客户名称" prop="customerName">
|
<el-input v-model="dataForm.customerName"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="交货地址" prop="address">
|
<el-input v-model="dataForm.address"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="联系人" prop="receiver">
|
<el-input v-model="dataForm.receiver"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="联系电话" prop="phone">
|
<el-input v-model="dataForm.phone"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="发货日期" prop="deliveryDate">
|
<el-date-picker
|
style="width: 100%"
|
v-model="dataForm.deliveryDate"
|
type="date"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="承运商" prop="carrier">
|
<el-input v-model="dataForm.carrier"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="业务员" prop="salesman">
|
<el-input v-model="dataForm.salesman"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="dataForm.remark"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</el-tab-pane>
|
</el-tabs>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button
|
type="primary"
|
v-show="dataForm.status !== '02completed'"
|
@click="dataFormSubmit()"
|
>确定</el-button
|
>
|
</span>
|
|
<!-- 库存信息选择弹框 -->
|
<StockMulti
|
:currshowlist.sync="relateVisible"
|
@handleSelectionChange="selectStock"
|
:multiSelect="multiSelect"
|
:paramObj="paramObj"
|
:paramSelArr="paramSelArr"
|
:paramSelCol="paramSelCol"
|
/>
|
<!--客户订单-->
|
<customerorder
|
:currshowlist.sync="showCustomerorder"
|
@handleSelectionChange="selectCustomerorder"
|
></customerorder>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {
|
getEscort,
|
addEscort,
|
putEscort,
|
fetchListEscortDetailAll,
|
getEscortInfoByOrder,
|
delEscort,
|
delEscortDetails
|
} from '@/api/warehouse/escort'
|
import { fetchList as fetchLocationList } from '@/api/warehouse/location'
|
import Customerorder from '@/views/common/customerorder.vue'
|
import StockMulti from '@/views/common/stock-multi.vue'
|
|
export default {
|
data() {
|
return {
|
clickDateArr: [],
|
visible: false,
|
multiSelect: true,
|
activeName: '押运单',
|
dataForm: {
|
id: 0,
|
escortNo: '',
|
requestDate: '',
|
orderNo: '',
|
customerOrderNo: '',
|
entityName: '',
|
customerName: '',
|
address: '',
|
receiver: '',
|
phone: '',
|
deliveryDate: '',
|
carrier: '',
|
salesman: '',
|
remark: '',
|
customerOrderId: null
|
},
|
dataRule: {
|
remark: [{ required: true, message: '备注不能为空', trigger: 'blur' }]
|
},
|
|
queryParam: {},
|
escortDetailList: [], // 发货明细
|
selectEscortDetailList: [],
|
|
paramObj: { locationId: null },
|
paramSelArr: [],
|
paramSelCol: 'id',
|
relateVisible: false,
|
showCustomerorder: false
|
}
|
},
|
components: {
|
StockMulti,
|
Customerorder
|
},
|
methods: {
|
init(id) {
|
this.getDefaultLocation()
|
this.dataForm.id = id || 0
|
this.activeName = '押运单'
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
this.clear()
|
if (this.dataForm.id) {
|
getEscort(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
this.moment = this.dataForm.createTime
|
})
|
} else {
|
this.dataForm.escortAutoId = ''
|
}
|
this.getEscortDetailList()
|
})
|
},
|
// 获取默认的待发货库位
|
getDefaultLocation() {
|
fetchLocationList(
|
Object.assign(
|
{
|
current: 1,
|
size: 20
|
},
|
{ locType: '9' }
|
)
|
).then((res) => {
|
if (res.data.code === 0) {
|
const toBeShippeds = res.data.data.records
|
if ((toBeShippeds != null) & (toBeShippeds.length > 0)) {
|
const toBeShipped = toBeShippeds[0]
|
this.paramObj.locationId = toBeShipped.id
|
}
|
}
|
})
|
},
|
clear() {
|
this.dataForm.status = ''
|
},
|
// 表单提交
|
dataFormSubmit() {
|
var canClickFlag = true
|
this.clickDateArr.push(new Date().getTime())
|
if (this.clickDateArr.length > 1) {
|
if (
|
this.clickDateArr[this.clickDateArr.length - 1] -
|
this.clickDateArr[this.clickDateArr.length - 2] <
|
2000
|
) {
|
// 小于2秒则认为重复提交
|
canClickFlag = false
|
}
|
}
|
if (!canClickFlag) {
|
return
|
}
|
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putEscort(
|
Object.assign({}, this.dataForm, {
|
escortDetailList: this.escortDetailList
|
})
|
)
|
.then((data) => {
|
this.$message.success('押运单修改成功')
|
this.$emit('refreshDataList')
|
this.visible = false
|
})
|
.catch((error) => {
|
console.log(error)
|
})
|
} else {
|
addEscort(
|
Object.assign({}, this.dataForm, {
|
status: '01draft',
|
escortDetailList: this.escortDetailList
|
})
|
)
|
.then((data) => {
|
this.$message.success('押运单新增成功')
|
this.$emit('refreshDataList')
|
this.visible = false
|
})
|
.catch((error) => {
|
console.log(error)
|
})
|
}
|
}
|
})
|
},
|
// 打开库存信息
|
openStockDialog() {
|
// 筛选出当前发货的库存
|
this.paramSelArr = []
|
if (this.escortDetailList && this.escortDetailList.length > 0) {
|
this.escortDetailList.forEach((e) => {
|
this.paramSelArr.push(e.stockId)
|
})
|
}
|
this.relateVisible = true
|
},
|
// 选择库存
|
selectStock(stockList) {
|
if (stockList && stockList.length > 0) {
|
// 添加发货明细
|
stockList.forEach((item) => {
|
this.escortDetailList.push(
|
Object.assign({
|
id: null,
|
stockId: item.id,
|
partBatchNo: item.partBatchNo,
|
partNo: item.partNo,
|
partName: item.partName,
|
deliveryQty: item.availableStockQuantity
|
})
|
)
|
})
|
}
|
},
|
// 选择订单预留
|
selectOrderStock(orderStockList) {
|
if (orderStockList && orderStockList.length > 0) {
|
const newCustomerOrderIdList = []
|
// 添加发货明细
|
orderStockList.forEach((item) => {
|
const exist = this.escortDetailList.find(
|
(detail) => detail.customerOrderId === item.customerOrderId
|
)
|
if (!exist) {
|
newCustomerOrderIdList.push(item.customerOrderId)
|
}
|
this.escortDetailList.push(
|
Object.assign({
|
stockOrderId: item.id,
|
customerOrderId: item.customerOrderId,
|
customerOrderNo: item.customerOrderNo,
|
customerName: item.customerName,
|
partBatchNo: item.partBatchNo,
|
partNo: item.partNo,
|
partName: item.partName,
|
reservedQuantity: item.reservedQuantity,
|
deliveredQuantity: item.deliveryQuantity,
|
deliveryQty: item.undeliveredQuantity
|
})
|
)
|
})
|
// 如果是新增的,自动填充押运单主表信息
|
if (
|
!this.dataForm.id &&
|
newCustomerOrderIdList &&
|
newCustomerOrderIdList.length > 0
|
) {
|
getEscortInfoByOrder(newCustomerOrderIdList).then((response) => {
|
if (response.data.code === 0) {
|
const escortInfoList = response.data.data
|
if (escortInfoList && escortInfoList.length > 0) {
|
escortInfoList.forEach((escortInfo) => {
|
if (escortInfo.orderNo) {
|
this.dataForm.orderNo =
|
(this.dataForm.orderNo
|
? this.dataForm.orderNo + ','
|
: '') + escortInfo.orderNo
|
}
|
if (!this.dataForm.requestDate) {
|
this.dataForm.requestDate = escortInfo.requestDate
|
}
|
if (escortInfo.customerOrderNo) {
|
this.dataForm.customerOrderNo =
|
(this.dataForm.customerOrderNo
|
? this.dataForm.customerOrderNo + ','
|
: '') + escortInfo.customerOrderNo
|
}
|
if (escortInfo.entityName) {
|
this.dataForm.entityName =
|
(this.dataForm.entityName
|
? this.dataForm.entityName + ','
|
: '') + escortInfo.entityName
|
}
|
if (escortInfo.customerName) {
|
this.dataForm.customerName =
|
(this.dataForm.customerName
|
? this.dataForm.customerName + ','
|
: '') + escortInfo.customerName
|
}
|
if (escortInfo.address) {
|
this.dataForm.address =
|
(this.dataForm.address
|
? this.dataForm.address + ','
|
: '') + escortInfo.address
|
}
|
if (escortInfo.receiver) {
|
this.dataForm.receiver =
|
(this.dataForm.receiver
|
? this.dataForm.receiver + ','
|
: '') + escortInfo.receiver
|
}
|
if (escortInfo.phone) {
|
this.dataForm.phone =
|
(this.dataForm.phone ? this.dataForm.phone + ',' : '') +
|
escortInfo.phone
|
}
|
if (escortInfo.salesman) {
|
this.dataForm.salesman =
|
(this.dataForm.salesman
|
? this.dataForm.salesman + ','
|
: '') + escortInfo.salesman
|
}
|
})
|
}
|
}
|
})
|
}
|
}
|
},
|
// 删除待发货明细
|
deleteOrderStock() {
|
if (
|
this.selectEscortDetailList &&
|
this.selectEscortDetailList.length > 0
|
) {
|
const escortDetailIds = []
|
this.selectEscortDetailList.forEach((obj) => {
|
if (obj.id != null) {
|
escortDetailIds.push(obj.id)
|
}
|
})
|
if (escortDetailIds.length > 0) {
|
delEscortDetails(escortDetailIds).then((response) => {
|
if (response.data.code === 0) {
|
this.selectEscortDetailList.forEach((obj) => {
|
const index = this.escortDetailList.findIndex(
|
(item) => item.stockId === obj.stockId
|
)
|
if (index !== -1) {
|
this.escortDetailList.splice(index, 1)
|
}
|
})
|
this.$message.warning('删除明细成功')
|
} else {
|
this.$message.warning('删除明细失败')
|
}
|
})
|
} else {
|
this.selectEscortDetailList.forEach((obj) => {
|
const index = this.escortDetailList.findIndex(
|
(item) => item.stockId === obj.stockId
|
)
|
if (index !== -1) {
|
this.escortDetailList.splice(index, 1)
|
}
|
})
|
this.$message.warning('删除明细成功')
|
}
|
} else {
|
this.$message.warning('请选择待发货明细')
|
}
|
},
|
|
// 查询待发货明细
|
handleEscortDetailList() {
|
this.getEscortDetailList()
|
},
|
getEscortDetailList() {
|
this.escortDetailList = []
|
if (this.dataForm.id) {
|
const query = Object.assign(
|
{ escortId: this.dataForm.id },
|
this.queryParam
|
)
|
fetchListEscortDetailAll(query).then((response) => {
|
if (response.data.code === 0) {
|
this.escortDetailList = response.data.data
|
} else {
|
this.$message.error('获取待发货明细失败')
|
}
|
})
|
}
|
},
|
// 选择待发货明细
|
selectionEscortDetail(val) {
|
this.selectEscortDetailList = val
|
},
|
// 打开客户订单对话框
|
openCustomOrderDialog() {
|
this.showCustomerorder = true
|
},
|
// 选中客户订单之后,回调重置押运单客户信息
|
selectCustomerorder(param) {
|
if (param && param.length > 0) {
|
const customerOrder = param[0]
|
const newCustomerOrderIdList = [customerOrder.id]
|
this.dataForm.customerOrderId = customerOrder.id
|
this.dataForm.orderNo = customerOrder.customerNo
|
this.dataForm.customerOrderNo = customerOrder.customerOrderNo
|
this.dataForm.customerName = customerOrder.customerName
|
getEscortInfoByOrder(newCustomerOrderIdList).then((response) => {
|
if (response.data.code === 0) {
|
const escortInfoList = response.data.data
|
if (escortInfoList && escortInfoList.length > 0) {
|
const escortInfo = escortInfoList[0]
|
|
if (!this.dataForm.requestDate) {
|
this.dataForm.requestDate = escortInfo.requestDate
|
}
|
if (escortInfo.entityName) {
|
this.dataForm.entityName = escortInfo.entityName
|
}
|
if (escortInfo.address) {
|
this.dataForm.address = escortInfo.address
|
}
|
if (escortInfo.receiver) {
|
this.dataForm.receiver = escortInfo.receiver
|
}
|
if (escortInfo.phone) {
|
this.dataForm.phone = escortInfo.phone
|
}
|
if (escortInfo.salesman) {
|
this.dataForm.salesman = escortInfo.salesman
|
}
|
}
|
}
|
})
|
}
|
},
|
initDataForm() {
|
this.dataForm.id = 0
|
this.dataForm.escortNo = ''
|
this.dataForm.requestDate = ''
|
this.dataForm.orderNo = ''
|
this.dataForm.customerOrderNo = ''
|
this.dataForm.entityName = ''
|
this.dataForm.customerName = ''
|
this.dataForm.address = ''
|
this.dataForm.receiver = ''
|
this.dataForm.phone = ''
|
this.dataForm.deliveryDate = ''
|
this.dataForm.carrier = ''
|
this.dataForm.salesman = ''
|
this.dataForm.remark = ''
|
this.dataForm.customerOrderId = null
|
},
|
// 清空
|
cleanForm() {
|
if (this.escortDetailList != null && this.escortDetailList.length > 0) {
|
this.$message.warning('请先删除待发货明细')
|
} else {
|
if (this.dataForm.id) {
|
// 存在押运单id,需调用后端接口删除
|
delEscort(this.dataForm.id).then((response) => {
|
if (response.data.code === 0) {
|
this.initDataForm()
|
this.$message.success('清空成功')
|
this.$emit('refreshDataList')
|
} else {
|
this.$message.error('清空失败')
|
}
|
})
|
} else {
|
// 不存在押运单id,押运单数据初始化
|
this.initDataForm()
|
}
|
}
|
}
|
}
|
}
|
</script>
|