zuozhengqing
2024-04-08 37630069ea5db733bd8d20fd6b10b5000fb99eb9
src/views/sales/salesDetails/shipmentsDialog.vue
@@ -30,13 +30,12 @@
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="24">
              <!-- <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"
@@ -47,26 +46,27 @@
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="24">
              </el-col> -->
              <el-col :span="24">
                <el-form-item  label="发货仓库" prop="addressee">
                  <el-select  v-model="value" placeholder="请选择">
                  <el-select  v-model="value" placeholder="请选择" @change="optionsChange">
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                      :key="item.warehouseId"
                      :label="item.warehouseName"
                      :value="item">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col> -->
              </el-col>
            </el-row>
          </div>
          <div class="product-view">
          <div class="product-view" v-if="isCommonShow">
            <CommonFormTableView
              ref="commonFormTableView"
              :detail-enter="isView ? true : false"
              :selectBox="false"
              :colOpenShow="true"
              :addTypeIdMultiple="true"
              pageName="quotation"
              :isBorder="true"
@@ -97,7 +97,7 @@
<script>
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
import { getAllData } from "@/api/client/client"
import { getProjectList,getDeliveryPrepareInfo,confirmOutput } from "@/api/sales/salesDetails"
import { getProjectList,getDeliveryPrepareInfo,confirmOutput,getDeliveryPrepareInfoByWarehouse } from "@/api/sales/salesDetails"
import codeMixin from "@/components/makepager/mixin/codeMixin"
import { getSaleChanceList } from "@/api/sales/salesOpportunity"
import { getDataByType } from "@/api/data"
@@ -128,14 +128,14 @@
  data() {
    // 产品信息
    const productColumn = [
          { label: "产品编号", prop: "number", isShowColumn:true, },
          { label: "产品名称", prop: "name",isShowColumn:true, min: 110 },
          { label: "订单数量", prop: "orderAmount", isShowColumn:true,},
          { label: "订单完成数量", prop: "finishAmount",isShowColumn:true, },
          { label: "可用库存", prop: "availableAmount",isShowColumn:true, },
          { label: "未发货数量", prop: "leftAmount", isShowColumn:true, },
          { label: "本次发货数量", prop: "outputAmount", inputFloat: true,isRequird:true,isShowColumn:true,},
          { label: "剩余发货数量", prop: "availableAmount",isShowColumn:true,},
          { label: "产品编号", prop: "number",},
          { label: "产品名称", prop: "name", min: 110 },
          { label: "订单数量", prop: "orderAmount",min:110,},
          { label: "订单完成数量", min:120,prop: "finishAmount",},
          { label: "可用库存", prop: "availableAmount",},
          { label: "未发货数量", prop: "leftAmount", min:120, },
          { label: "本次发货数量", prop: "outputAmount", min:120,inputFloat: true,isRequird:true,},
          { label: "剩余发货数量", prop: "availableAmount",min:120,},
        ]
    return {
      dialogWidth: "60%",
@@ -210,18 +210,14 @@
          return time.getTime() > Date.now()
        }
      },
      options: [{
        value: '1',
        label: '仓库1--库存不足的情况'
      }, {
        value: '2',
        label: '仓库1--库存充足的情况'
      }],
      options: [],
      value:"",
      shipmentsList:[],
      shipmentsMsg:"",
      dissatisfy:false, // 一次发货-不足
      completely:false, // 多次发货,充足
      isCommonShow:true,
      warehouseId:null,
    }
  },
  mounted(){
@@ -239,6 +235,11 @@
    this.getDeliveryPrepareInfo({
          saleDetailID: this.editCommonConfig.infomation.saleDetailID,
          saleDetailNumber: this.editCommonConfig.infomation.saleDetailNumber
    })
    this.getDeliveryPrepareInfoByWarehouse({
      groupByWarehouse: true,
      saleDetailID: this.editCommonConfig.infomation.saleDetailID,
      saleDetailNumber: this.editCommonConfig.infomation.saleDetailNumber
    })
  },
  watch: {
@@ -289,12 +290,11 @@
      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.editConfig.infomation.deliverType===1){
              if(item.leftAmount<item.availableAmount&&item.leftAmount>0){
              if(item.leftAmount<=item.availableAmount&&item.leftAmount>0){
                isShipments=false
              }else if(item.leftAmount<=0){
                shipmentsNum=true
@@ -305,8 +305,6 @@
              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 if(item.leftAmount<=0){
                isShipments=true
@@ -334,7 +332,8 @@
    saveParams() {
      let params = {
        products:[],
        saleDetailNumber:this.editCommonConfig.infomation.saleDetailNumber
        saleDetailNumber:this.editCommonConfig.infomation.saleDetailNumber,
        warehouseId:this.warehouseId
      }
      this.shipmentsList.map((item)=>{
        let obj={
@@ -373,7 +372,6 @@
      var restaurants = []
      if (value === "client") {
        restaurants = this.clientList
        console.log(restaurants, "客户单")
      } else if (value === "chance") {
          restaurants = this.saleChancelist
      } else if (value === "subbill") {
@@ -468,19 +466,19 @@
        this.getQuotation(this.editConfig.infomation.saleChanceId, "全部产品")
      }
      this.tableColumn=[
          { label: "产品编号", prop: "number", isShowColumn:true, },
          { label: "产品名称", prop: "name",isShowColumn:true, min: 110 },
          { label: "订单数量", prop: "orderAmount", isShowColumn:true,},
          { label: "订单完成数量", prop: "finishAmount",isShowColumn:true, }
          { label: "产品编号", prop: "number", },
          { label: "产品名称", prop: "name", min: 110 },
          { label: "订单数量", prop: "orderAmount",},
          { label: "订单完成数量", min:120, prop: "finishAmount", }
        ]
      this.productTableList = {
        tableData: this.tableData,
        isReturn: true,
        // tableColumn: [
        //   { label: "产品编号", prop: "number", isShowColumn:true, },
        //   { label: "产品名称", prop: "name",isShowColumn:true, min: 110 },
        //   { label: "订单数量", prop: "orderAmount", isShowColumn:true,},
        //   { label: "订单完成数量", prop: "finishAmount",isShowColumn:true, }
        //   { label: "产品编号", prop: "number",},
        //   { label: "产品名称", prop: "name",min: 110 },
        //   { label: "订单数量", prop: "orderAmount",},
        //   { label: "订单完成数量", prop: "finishAmount",}
        // ],
        tableColumn: this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
      }
@@ -568,6 +566,9 @@
        pageSize: 100
      }).then((res) => {
        this.projectList = res.data
        // if(res&&res.data.length>0){
        //   this.editConfig.infomation.projectId=res.data[0].projectId
        // }
      })
    },
    // 销售负责人自定义校验规则
@@ -584,15 +585,19 @@
      this.shipmentsList=[]
      this.dissatisfy=false
      this.completely=false
      this.isCommonShow=false;
      this.$nextTick(()=>{
        this.isCommonShow=true;
      })
      if(value==1){
        this.productTableList.showcol= ['产品编号','产品名称', "订单数量", "订单完成数量","可用库存"]
        this.productTableList.allcol= ["订单数量", "订单完成数量","可用库存"]
        this.tableColumn=[
          { label: "产品编号", prop: "number",isShowColumn:true,  },
          { label: "产品名称", prop: "name",isShowColumn:true,  min: 110 },
          { label: "订单数量", prop: "orderAmount",isShowColumn:true, },
          { label: "订单完成数量", prop: "finishAmount",isShowColumn:true, },
          { label: "可用库存", prop: "availableAmount",isShowColumn:true, },
          { label: "产品编号", prop: "number", },
          { label: "产品名称", prop: "name",min: 110 },
          { label: "订单数量", prop: "orderAmount",},
          { label: "订单完成数量", min:120, prop: "finishAmount", },
          { label: "可用库存", prop: "availableAmount",},
        ]
        this.productTableList.tableColumn=this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
        this.dissatisfy=false
@@ -642,14 +647,14 @@
        this.productTableList.showcol= ['产品编号','产品名称', "订单数量", "订单完成数量","可用库存","未发货数量", "本次发货数量","剩余发货数量",]
        this.productTableList.allcol= [ "订单数量", "订单完成数量","可用库存","未发货数量", "剩余发货数量",]
        this.tableColumn= [
          { label: "产品编号", prop: "number",isShowColumn:true, },
          { label: "产品名称", prop: "name",  min: 110 ,isShowColumn:true,},
          { label: "订单数量", prop: "orderAmount",isShowColumn:true, },
          { label: "订单完成数量", prop: "finishAmount" ,isShowColumn:true,},
          { label: "可用库存", prop: "availableAmount",isShowColumn:true, },
          { label: "未发货数量", prop: "leftAmount", isShowColumn:true, },
          { label: "本次发货数量", prop: "outputAmount", inputFloat: true,isRequird:true,isShowColumn:true,},
          { label: "剩余发货数量", prop: "availableAmount",isShowColumn:true,},
          { label: "产品编号", prop: "number", },
          { label: "产品名称", prop: "name",  min: 110 ,},
          { label: "订单数量", prop: "orderAmount", },
          { label: "订单完成数量", min:120, prop: "finishAmount" ,},
          { label: "可用库存", prop: "availableAmount",},
          { label: "未发货数量", prop: "leftAmount", min:120, },
          { label: "本次发货数量", prop: "outputAmount",  min:120,inputFloat: true,isRequird:true,},
          { label: "剩余发货数量", prop: "availableAmount", min:120,},
        ]
        this.productTableList.tableColumn=this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
        let portion=0
@@ -696,7 +701,6 @@
                this.shipmentsList.push(item)
              }
            })
            console.log(portion,"portion2")
            if(portion===0){// 没有产品满足发货条件
              this.completely=false
              this.dissatisfy=true
@@ -714,6 +718,44 @@
          }
        }
      })
    },
    // 按仓库进行发货
    async getDeliveryPrepareInfoByWarehouse(params){
      await getDeliveryPrepareInfoByWarehouse(params).then((res)=>{
        this.options=res.data
      })
    },
    // 选择仓库
    optionsChange(val){
      this.warehouseId=val.warehouseId
      this.productTableList.tableData=val.storeInfoList||[]
          if(this.editConfig.infomation.deliverType===1){
            let portion=0
            this.productTableList.tableData.map((item)=>{
              item.availableAmount=Number(item.availableAmount)
              item.leftAmount=Number(item.leftAmount)
              item.finishAmount=Number(item.finishAmount)
              item.orderAmount=Number(item.orderAmount)
              if(item.availableAmount>=item.leftAmount&&item.availableAmount>0&&item.leftAmount>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{
              this.dissatisfy=false
              this.completely=true
              this.shipmentsMsg="能满足发货需求,直接发货吧"
            }
          }
    }
  }
}