<template>
|
<div class="add-sales-details">
|
<el-dialog
|
:title="'发货单'"
|
:visible.sync="editConfig.visible"
|
:width="dialogWidth"
|
:before-close="handleClose"
|
append-to-body
|
custom-class="iframe-dialog"
|
>
|
<el-form
|
ref="form"
|
:model="editConfig.infomation"
|
:rules="rules"
|
label-position="right"
|
label-width="10%"
|
size="mini"
|
style="height: 60vh; overflow-x: hidden"
|
>
|
<!-- 信息 -->
|
<div class="basic-info">
|
<!-- 交付信息 -->
|
<div class="basic-info-view">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item width="50%" label="交付类型" prop="addressee">
|
<el-radio-group v-model="shipmentsType" @change="handleRadioChange">
|
<el-radio :label="1">一次发货</el-radio>
|
<el-radio :label="2">多次发货</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="关联项目" prop="projectId">
|
<el-select
|
v-model="editConfig.infomation.projectId"
|
placeholder="请选择"
|
size="mini"
|
:disabled="true"
|
>
|
<el-option
|
v-for="item in projectList"
|
:key="item.projectId"
|
:label="item.projectName"
|
:value="item.projectId"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<!-- <el-col :span="24">
|
<el-form-item label="发货仓库" prop="addressee">
|
<el-select v-model="value" placeholder="请选择">
|
<el-option
|
v-for="item in options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col> -->
|
</el-row>
|
</div>
|
<div class="product-view">
|
<CommonFormTableView
|
ref="commonFormTableView"
|
:detail-enter="isView ? true : false"
|
:selectBox="false"
|
:addTypeIdMultiple="true"
|
pageName="quotation"
|
:detailEnter="true"
|
:isOperate="
|
(autoCodeHeadersObj.Bjd == 'yes' && editConfig.infomation.quotation_number) ||
|
autoCodeHeadersObj.Bjd != 'yes'
|
? true
|
: false
|
"
|
:quotationNumber="autoCodeHeadersObj.Bjd == 'yes' ? editConfig.infomation.quotation_number : ''"
|
:product-table-list="productTableList"
|
@inputContent="inputContent"
|
@addProductClick="addProductClick"
|
@getSelectArray="getSelectArray"
|
@emptyProductClick="emptyProductClick"
|
@clearupProduct="clearupProduct"
|
></CommonFormTableView>
|
</div>
|
<p class="tips tips_success" v-if="completely"><i class="el-icon-warning-outline"></i>{{ shipmentsMsg }}</p>
|
<p class="tips tips_insufficient" v-if="dissatisfy"><i class="el-icon-warning-outline"></i>{{shipmentsMsg}}</p>
|
</div>
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" size="small" :disabled="dissatisfy" @click="saveClick('form')">确定发货</el-button>
|
<el-button size="small" @click="editConfig.visible = false">取消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
|
import { getAllData } from "@/api/client/client"
|
import { getProjectList,getDeliveryPrepareInfo,confirmOutput } from "@/api/sales/salesDetails"
|
import codeMixin from "@/components/makepager/mixin/codeMixin"
|
import { getSaleChanceList } from "@/api/sales/salesOpportunity"
|
import { getDataByType } from "@/api/data"
|
import { mapActions } from "vuex"
|
import { getQuotationList } from "@/api/sales/quotation"
|
|
export default {
|
name: "ShipmentsDialog",
|
mixins: [codeMixin],
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
}
|
}
|
}
|
},
|
components: { CommonFormTableView },
|
computed: {
|
clientList() {
|
return this.$store.state.getClientName.clientList
|
},
|
},
|
data() {
|
return {
|
dialogWidth: "60%",
|
editConfig: this.editCommonConfig,
|
rules: {
|
client_name: [{ required: true, message: "请选择客户名称", trigger: "change" }],
|
},
|
memberOptions: [],
|
selSourceOrderOptions: [],
|
wechatOrderStatusOptions: [], // 微信订单状态
|
currencyOptions: [{ id: 1, name: "人民币" }], // 币种
|
approvalWorkflowOptions: [], // 审批流程
|
productTableList: {},
|
showSummary: {
|
show: true,
|
total: true,
|
sumProp: ["Amount", "total"],
|
mergeNumber: 7
|
},
|
editSelectClientConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {}
|
},
|
editSelectChanceConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {},
|
search_map: {}
|
},
|
editSelCommonConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {}
|
},
|
clientId: this.editCommonConfig.infomation.client_id,
|
saleChanceId: this.editCommonConfig.infomation.sale_chance_id,
|
subbillId: this.editCommonConfig.infomation.subbillId,
|
productId: 1,
|
isNoProduct: true,
|
addCollectionConfig: {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
},
|
amountTotal: 0,
|
isNameChanceEdit: false,
|
isAddQuatation: true,
|
// 交付类型
|
deliveryTypeList: getDataByType("deliveryType"),
|
projectList: [],
|
quotationList: [],
|
quotationId: this.editCommonConfig.infomation.quotationId,
|
tableData: [],
|
isView: this.editCommonConfig.title === "查看",
|
thatMember: {},
|
pickerOptions: {
|
disabledDate(time) {
|
return time.getTime() < Date.now() - 8.64e7
|
}
|
},
|
pickerOptionsBefore: {
|
disabledDate(time) {
|
return time.getTime() > Date.now()
|
}
|
},
|
shipmentsType:1,
|
options: [{
|
value: '1',
|
label: '仓库1--库存不足的情况'
|
}, {
|
value: '2',
|
label: '仓库1--库存充足的情况'
|
}],
|
value:"",
|
shipmentsList:[],
|
shipmentsMsg:"",
|
dissatisfy:false, // 一次发货-不足
|
completely:false, // 多次发货,充足
|
}
|
},
|
mounted(){
|
this.getSaleChanceList()
|
this.getQuotation()
|
},
|
created() {
|
this.$store.dispatch("geClient")
|
this.setTableForm()
|
this.getCommonData()
|
this.formInfo()
|
this.getUseSystemSet({ modeType: "xsmx" })
|
this.getProjectList()
|
this.getDeliveryPrepareInfo({
|
saleDetailID: this.editCommonConfig.infomation.saleDetailID,
|
saleDetailNumber: this.editCommonConfig.infomation.saleDetailNumber
|
})
|
},
|
watch: {
|
"editClientManageConfig.visible"(val) {
|
if (val) {
|
this.formInfo()
|
}
|
}
|
},
|
methods: {
|
...mapActions(["getChanceFilter", "getSubunitFliter"]),
|
formInfo() {
|
this.objCode.type = "销售明细编码"
|
this.objCode.codeStandID = ""
|
if (this.editConfig.infomation.codeStandID) {
|
this.objCode.codeStandID = this.editConfig.infomation.codeStandID
|
}
|
this.getRCodeStandardList()
|
},
|
getCommonData() {
|
getAllData()
|
.then((res) => {
|
this.memberOptions = res.data.member
|
if (this.editConfig.title === "新建") {
|
let username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
|
this.memberOptions.map((item) => {
|
if (item.username == username) {
|
this.$set(this.editConfig.infomation, "memberId", item.id)
|
}
|
})
|
}
|
})
|
.catch((err) => {
|
console.log(err)
|
})
|
},
|
dataProcess() {
|
this.saleChancelist.map((item) => {
|
if (this.saleChanceId === item.id) {
|
this.editConfig.infomation.sale_chance_name = item.name
|
}
|
})
|
},
|
// 保存
|
saveClick(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
const params = this.saveParams()
|
console.log(params,"参数")
|
let isShipments=false
|
let shipmentsNum=false
|
this.shipmentsList.map((item)=>{
|
if(this.shipmentsType===1){
|
if(item.leftAmount<item.availableAmount){
|
isShipments=false
|
}else{
|
isShipments=true
|
}
|
}else{
|
if(item.outputAmount>item.availableAmount||item.outputAmount>item.leftAmount){
|
isShipments=true
|
}else if(item.outputAmount===0){
|
shipmentsNum=true
|
}else if(!item.outputAmount){
|
shipmentsNum=true
|
}else{
|
isShipments=false
|
}
|
}
|
})
|
if(isShipments){
|
this.$message.warning("发货数量超出未发货数量或超出当前可用库存")
|
}else if(shipmentsNum){
|
this.$message.warning("发货数量不能为0")
|
}else{
|
confirmOutput(params).then((res)=>{
|
if(res&&res.code===200){
|
this.$message.success("发货成功!")
|
this.$parent.getData()
|
this.editConfig.visible=false
|
}
|
})
|
}
|
}
|
})
|
},
|
saveParams() {
|
let params = {
|
products:[],
|
saleDetailNumber:this.editCommonConfig.infomation.saleDetailNumber
|
}
|
this.shipmentsList.map((item)=>{
|
let obj={
|
number:item.number,
|
outputAmount:this.shipmentsType===1?item.leftAmount:item.outputAmount // 本次发货数量
|
}
|
params.products.push(obj)
|
})
|
return params
|
},
|
|
handleClose() {
|
this.editConfig.visible = false
|
},
|
// 获取报价单
|
getQuotation(id, value) {
|
let params={
|
page: 0,
|
pageSize: 0,
|
}
|
if(id){
|
params.search_map={
|
sale_chance_id: id
|
}
|
}
|
getQuotationList(params).then((res) => {
|
if (res.code == 200) {
|
console.log(res)
|
this.quotationList = res.data.list
|
this.count = res.data.count
|
}
|
})
|
},
|
// 选择客户相关方法
|
querySearchAsync(queryString, cb, value) {
|
var restaurants = []
|
if (value === "client") {
|
restaurants = this.clientList
|
console.log(restaurants, "客户单")
|
} else if (value === "chance") {
|
restaurants = this.saleChancelist
|
} else if (value === "subbill") {
|
restaurants = this.subOrderList
|
} else if (value === "quotation") {
|
restaurants = this.quotationList
|
}
|
var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants
|
cb(results)
|
},
|
createStateFilter(queryString, value) {
|
return (state) => {
|
if (value === "subbill" || value === "quotation") {
|
return state.number.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
} else {
|
return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
}
|
}
|
},
|
// 销售机会列表
|
async getSaleChanceList(item) {
|
let params={}
|
if(item){
|
params={
|
page: 0,
|
pageSize: 0,
|
}
|
params.search_map={
|
client_id: item.id
|
}
|
}else{
|
params={
|
page: 0,
|
pageSize: 0,
|
}
|
}
|
await getSaleChanceList(params).then((res) => {
|
console.log(res)
|
this.saleChancelist = res.data.list
|
})
|
},
|
selClientClick(value) {
|
if (value === "client") {
|
this.editSelectClientConfig.editVisible = true
|
} else if (value === "chance") {
|
if (this.clientId) {
|
this.editSelectChanceConfig.clientId = this.clientId
|
}
|
this.editSelectChanceConfig.editVisible = true
|
} else if (value === "subbill") {
|
this.editSelCommonConfig.title = "销售子单"
|
this.editSelCommonConfig.editVisible = true
|
this.editSelCommonConfig.clientId = this.clientId
|
} else if (value === "quotation") {
|
this.editSelCommonConfig.title = "报价单"
|
if (this.saleChanceId && this.clientId) {
|
this.editSelCommonConfig.clientId = this.clientId
|
// 正向选择客户 销售机会 报价单
|
this.editSelCommonConfig.isRequest = false
|
this.editSelCommonConfig.count = this.count
|
this.editSelCommonConfig.tableInfomation = [...this.quotationList]
|
} else {
|
// 反向选择
|
this.editSelCommonConfig.isRequest = true
|
}
|
this.editSelCommonConfig.editVisible = true
|
}
|
},
|
setTableForm() {
|
if (this.editConfig.title === "新建" || this.editConfig.infomation.products.length === 0) {
|
this.tableData = [
|
{
|
productId: this.productId,
|
id: 0,
|
amount: 0,
|
desc: "",
|
name: "",
|
number: "",
|
price: 0,
|
cost: "",
|
profit: "",
|
margin: "",
|
total: 0,
|
unit: ""
|
}
|
]
|
} else {
|
this.tableData = this.editConfig.infomation.products
|
this.tableData.map((item, index) => {
|
item.productId = index + 1
|
})
|
this.getQuotation(this.editConfig.infomation.saleChanceId, "全部产品")
|
}
|
this.productTableList = {
|
tableData: this.tableData,
|
isReturn: true,
|
tableColumn: [
|
{ label: "产品编号", prop: "number" },
|
{ label: "产品名称", prop: "name", min: 110 },
|
{ label: "订单数量", prop: "orderAmount" },
|
{ label: "订单完成数量", prop: "finishAmount" },
|
// { label: "可用库存", prop: "unit" },
|
]
|
}
|
},
|
// 产品列表输入
|
inputContent(val, prop, row) {
|
console.log(val,prop,row,)
|
// this.productTableList.tableData.map((item) => {
|
// if (item.number === row.number) {
|
// item[prop] = val
|
// }
|
// })
|
},
|
// 产品新增
|
addProductClick() {
|
|
},
|
// 新增方式修改
|
getSelectArray(val, index) {
|
if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
|
this.tableData = []
|
}
|
if (index < this.tableData.length) {
|
this.tableData.splice(index, 1)
|
val.map((item, ind) => {
|
this.tableData.splice(index + ind, 0, item)
|
})
|
} else {
|
this.tableData = this.tableData.concat(val)
|
}
|
this.productTableList.tableData = this.tableData
|
this.showSummary.show = true
|
},
|
// 产品清空
|
emptyProductClick() {
|
this.productId = 1
|
this.tableData = [
|
{
|
productId: this.productId,
|
id: 0,
|
amount: 0,
|
desc: "",
|
name: "",
|
number: "",
|
price: 0,
|
cost: "",
|
profit: "",
|
margin: "",
|
total: 0,
|
unit: ""
|
}
|
]
|
this.productTableList.tableData = this.tableData
|
},
|
clearupProduct(data) {
|
this.tableData = data
|
this.productTableList.tableData = this.tableData
|
},
|
// 获取项目列表
|
async getProjectList() {
|
await getProjectList({
|
page: 1,
|
pageSize: 100
|
}).then((res) => {
|
this.projectList = res.data
|
})
|
},
|
// 销售负责人自定义校验规则
|
validateMemberId(rule, value, callback) {
|
if (this.editConfig.infomation?.memberId > 0) {
|
callback()
|
} else {
|
callback(new Error("请选择销售负责人"))
|
}
|
},
|
// 选择发货方式
|
handleRadioChange(value) {
|
this.shipmentsList=[]
|
this.dissatisfy=false
|
this.completely=false
|
if(value===1){
|
this.productTableList.tableColumn=[
|
{ label: "产品编号", prop: "number" },
|
{ label: "产品名称", prop: "name", min: 110 },
|
{ label: "订单数量", prop: "orderAmount" },
|
{ label: "订单完成数量", prop: "finishAmount" },
|
{ label: "可用库存", prop: "availableAmount" },
|
]
|
this.dissatisfy=false
|
let portion=0
|
this.productTableList.tableData.map((item)=>{
|
if(item.availableAmount>=item.leftAmount&&item.availableAmount>0){
|
portion++
|
this.shipmentsList.push(item)
|
}
|
if(portion===0){// 没有产品满足发货条件
|
this.completely=false
|
this.dissatisfy=true
|
this.shipmentsMsg="当前仓库库存不足,不能完成一次发货"
|
}else if(portion>0&&portion<this.productTableList.tableData.length){// 部分产品满足发货条件
|
this.dissatisfy=false
|
this.completely=true
|
this.shipmentsMsg="只能满足部分发货需求,是否确认发货"
|
|
}else if(portion===this.productTableList.tableData.length){// 充分满足
|
this.dissatisfy=false
|
this.completely=true
|
this.shipmentsMsg="能满足发货需求,直接发货吧"
|
}
|
})
|
if(portion===this.productTableList.tableData.length){ // 全部满足发货条件
|
this.dissatisfy=false
|
this.completely=false
|
this.completely=true
|
}
|
}else if(value===2){
|
this.productTableList.tableColumn= [
|
{ label: "产品编号", prop: "number" },
|
{ label: "产品名称", prop: "name", min: 110 },
|
{ label: "订单数量", prop: "orderAmount" },
|
{ label: "订单完成数量", prop: "finishAmount" },
|
{ label: "可用库存", prop: "availableAmount" },
|
{ label: "未发货数量", prop: "leftAmount", },
|
{ label: "本次发货数量", prop: "outputAmount", inputFloat: true,isRequird:true },
|
{ label: "剩余发货数量", prop: "availableAmount",},
|
]
|
let portion=0
|
this.productTableList.tableData.map((item)=>{
|
if(item.availableAmount>0){
|
portion++
|
this.shipmentsList.push(item)
|
}
|
if(portion===0){ // 没有一件产品能满足发货条件
|
this.completely=false
|
this.dissatisfy=true
|
this.shipmentsMsg="当前仓库库存为0,无法发货"
|
}else if(portion>0&&portion<this.productTableList.tableData.length){
|
this.dissatisfy=false
|
this.completely=true
|
this.shipmentsMsg="只能满足部分发货需求,是否确认发货"
|
}else if(portion===this.productTableList.tableData.length){
|
this.dissatisfy=false
|
this.completely=true
|
this.shipmentsMsg="能满足发货需求,直接发货吧"
|
}
|
})
|
}
|
},
|
// 产品入库信息
|
async getDeliveryPrepareInfo(params){
|
await getDeliveryPrepareInfo(params).then((res)=>{
|
this.shipmentsList=[]
|
if(res&&res.code===200){
|
this.productTableList.tableData=res.data||[]
|
if(this.shipmentsType===1){
|
let portion=0
|
this.productTableList.tableData.map((item)=>{
|
if(item.availableAmount>=item.leftAmount&&item.availableAmount>0){
|
portion++
|
this.shipmentsList.push(item)
|
}
|
if(portion===0){// 没有产品满足发货条件
|
this.completely=false
|
this.dissatisfy=true
|
this.shipmentsMsg="当前产品可用库存为0,无法发货"
|
}else if(portion>0&&portion<this.productTableList.tableData.length){
|
this.dissatisfy=false
|
this.completely=true
|
this.shipmentsMsg="只能满足部分发货需求,是否确认发货"
|
// 部分产品满足发货条件
|
}else if(portion===this.productTableList.tableData.length){
|
this.dissatisfy=false
|
this.completely=true
|
this.shipmentsMsg="能满足发货需求,直接发货吧"
|
}
|
})
|
}
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
::v-deep {
|
.iframe-dialog .el-dialog__body {
|
.el-form {
|
.el-form-item {
|
width: 100%;
|
}
|
}
|
.basic-info {
|
.basic-info-title {
|
background-color: #f4f8fe;
|
padding-left: 10px;
|
font-size: 15px;
|
font-weight: bold;
|
color: #666;
|
height: 42px;
|
line-height: 42px;
|
}
|
.basic-info-view {
|
margin-top: 10px;
|
padding-right: 40px;
|
.custom-name,
|
.common-select {
|
display: flex;
|
.common-select-sel {
|
width: 270px;
|
}
|
.common-select-btn {
|
margin-left: 5px;
|
font-size: 16px;
|
cursor: pointer;
|
}
|
}
|
}
|
.annex-view {
|
display: flex;
|
color: #6166d3;
|
.setFormat {
|
margin-left: 10px;
|
}
|
}
|
.tips{
|
font-size: 16px;
|
display: flex;
|
margin-left: 20px;
|
i{
|
font-size: 24px;
|
margin-right: 10px;
|
}
|
}
|
.tips_success{
|
color: #5299FF;
|
}
|
.tips_portion{
|
color: #FF9C49;
|
}
|
.tips_insufficient{
|
color: #FF9C49;
|
}
|
}
|
.unflod-collapse {
|
display: flex;
|
height: 30px;
|
justify-content: center;
|
align-items: center;
|
color: #6166d3;
|
}
|
.dialog-footer {
|
background-color: #f5f5f5;
|
height: 55px;
|
line-height: 55px;
|
}
|
.el-input__inner {
|
text-align: left;
|
}
|
}
|
}
|
</style>
|