charles
2024-07-18 a0b97eb8e934ba28b9e51824d4cbbcc99cc70e17
src/views/sales/salesDetails/shipmentsDialog.vue
@@ -12,8 +12,8 @@
        ref="form"
        :model="editConfig.infomation"
        :rules="rules"
        label-position="right"
        label-width="10%"
        label-position="left"
        label-width="90px"
        size="mini"
        style="height: 60vh; overflow-x: hidden"
      >
@@ -23,20 +23,20 @@
          <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-form-item width="50%" label="交付类型:" prop="deliverType">
                  <el-radio-group v-model="editConfig.infomation.deliverType" @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-form-item label="关联项目:" prop="projectId">
                  <el-select
                    v-model="editConfig.infomation.projectId"
                    placeholder="请选择"
                    disabled
                    size="mini"
                    :disabled="true"
                  >
                    <el-option
                      v-for="item in projectList"
@@ -48,51 +48,47 @@
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="24">
              <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"
              :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"
              :isOperate="true"
              @inputContent="inputContent"
              @addProductClick="addProductClick"
              @getSelectArray="getSelectArray"
              @emptyProductClick="emptyProductClick"
              @clearupProduct="clearupProduct"
              @selTableCol="selTableCol"
            ></CommonFormTableView>
          </div>
          <p class="tips" v-if="completely"><i class="el-icon-warning-outline">当前仓库能满足发货需求,直接发货吧</i></p>
          <p class="tips" v-if="satisfyPartly"><i class="el-icon-warning-outline"></i>当前仓库只能部分满足发货需求,是否确认发货</p>
          <p class="tips" v-if="dissatisfy"><i class="el-icon-warning-outline"></i>当前仓库库存不足,不能完成一次发货,请选择其他仓库吧</p>
          <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 type="primary" size="small" :disabled="dissatisfy" @click.stop="saveClick('form')">确定发货</el-button>
        <el-button size="small" @click="editConfig.visible = false">取消</el-button>
      </div>
    </el-dialog>
@@ -102,7 +98,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"
@@ -131,6 +127,17 @@
    },
  },
  data() {
    // 产品信息
    const productColumn = [
          { 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},
          { label: "剩余发货数量", prop: "availableAmount",min:120,},
        ]
    return {
      dialogWidth: "60%",
      editConfig: this.editCommonConfig,
@@ -142,7 +149,15 @@
      wechatOrderStatusOptions: [], // 微信订单状态
      currencyOptions: [{ id: 1, name: "人民币" }], // 币种
      approvalWorkflowOptions: [], // 审批流程
      productTableList: {},
      productTableList: {
        allcol: [],
        showcol: ['产品编号','产品名称', "订单数量", "订单完成数量",],
        tableData: [],
        tableColumn: []
      },
      tableColumn: productColumn,
      searchOptions: [],
      showSummary: {
        show: true,
        total: true,
@@ -196,18 +211,14 @@
          return time.getTime() > Date.now()
        }
      },
      shipmentsType:1,
      options: [{
        value: '1',
        label: '仓库1--库存不足的情况'
      }, {
        value: '2',
        label: '仓库1--库存充足的情况'
      }],
      options: [],
      value:"",
      shipmentsList:[],
      shipmentsMsg:"",
      dissatisfy:false, // 一次发货-不足
      completely:false, // 多次发货,充足
      satisfyPartly:false, //多次发货,部分满足
      isCommonShow:true,
      warehouseId:null,
    }
  },
  mounted(){
@@ -217,11 +228,16 @@
  created() {
    this.$store.dispatch("geClient")
    this.setTableForm()
    this.handleRadioChange()
    this.getCommonData()
    this.formInfo()
    this.getUseSystemSet({ modeType: "xsmx" })
    this.getProjectList()
    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
    })
@@ -229,7 +245,9 @@
  watch: {
    "editClientManageConfig.visible"(val) {
      if (val) {
        this.handleRadioChange()
        this.formInfo()
      }
    }
  },
@@ -272,29 +290,64 @@
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const params = this.saveParams()
          confirmOutput(params).then((res)=>{
            console.log(res,"res")
            if(res&&res.code===200){
              this.$message.success("发货成功!")
              this.$parent.getData()
              this.editConfig.visible=false
          let isShipments=false
          let shipmentsNum=false
          this.shipmentsList.map((item)=>{
            if(this.editConfig.infomation.deliverType===1){
              if(item.leftAmount<=item.availableAmount&&item.leftAmount>0){
                isShipments=false
              }else if(item.leftAmount<=0){
                shipmentsNum=true
              }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.leftAmount<=0){
                isShipments=true
              }else{
                isShipments=false
              }
            }
          })
          });
          if(isShipments){
            this.$message.warning("发货数量超出未发货数量或超出当前可用库存")
          }/*else if(shipmentsNum){
            this.$message.warning("发货数量不能为0")
          }*/else{
              //过滤掉为空的数据
              params.products=params.products.filter(item=>item.outputAmount);
              if(params.products.length===0){
                  this.$message.warning('没有满足发货条件的明细,无法发货');
                  return;
              }
            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
        saleDetailNumber:this.editCommonConfig.infomation.saleDetailNumber,
        warehouseId:this.warehouseId
      }
      this.productTableList.tableData.map((item)=>{
      this.shipmentsList.map((item)=>{
        let obj={
          number:item.number,
          outputAmount:item.outputAmount||''
          outputAmount:this.editConfig.infomation.deliverType===1?item.leftAmount:item.outputAmount // 本次发货数量
        }
        params.products.push(obj)
      })
      });
      return params
    },
@@ -325,7 +378,6 @@
      var restaurants = []
      if (value === "client") {
        restaurants = this.clientList
        console.log(restaurants, "客户单")
      } else if (value === "chance") {
          restaurants = this.saleChancelist
      } else if (value === "subbill") {
@@ -413,32 +465,60 @@
          }
        ]
      } else {
        this.tableData = this.editConfig.infomation.products
        this.tableData = this.editConfig.infomation.products?this.editConfig.infomation.products:[]
        this.tableData.map((item, index) => {
          item.productId = index + 1
        })
        this.getQuotation(this.editConfig.infomation.saleChanceId, "全部产品")
      }
      this.tableColumn=[
          { 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" },
          { label: "产品名称", prop: "name",   min: 110 },
          { label: "订单数量", prop: "specs" },
          { label: "订单完成数量", prop: "type" },
          // { label: "可用库存", prop: "unit" },
        ]
        // tableColumn: [
        //   { label: "产品编号", prop: "number",},
        //   { label: "产品名称", prop: "name",min: 110 },
        //   { label: "订单数量", prop: "orderAmount",},
        //   { label: "订单完成数量", prop: "finishAmount",}
        // ],
        tableColumn: this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
      }
      this.setTableList(this.productTableList)
    },
    setTableList(tableList) {
      tableList.allcol = tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
      this.searchOptions = []
      for (let i = 0; i < tableList.tableColumn.length; i++) {
        const label = tableList.tableColumn[i].label
        const value = tableList.tableColumn[i].prop
        this.searchOptions.push({ value: value, label: label })
      }
    },
    setColumnVisible(showcol, tableColumn) {
      return tableColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn: showcol.includes(ele.label)
        }
      })
    },
    selTableCol(val) {
      this.productTableList.showcol = val
      this.productTableList.tableColumn = this.setColumnVisible(val, this.tableColumn)
    },
    // 产品列表输入
    inputContent(val, prop, row) {
      // this.productId = row.productId
      this.tableData.map((item) => {
        if (item.number === row.number) {
          item[prop] = val
        }
      })
      console.log(val,prop,row,)
      // this.productTableList.tableData.map((item) => {
      //   if (item.number === row.number) {
      //     item[prop] = val
      //   }
      // })
    },
    // 产品新增
    addProductClick() {
@@ -503,77 +583,182 @@
      }
    },
    // 选择发货方式
    handleRadioChange(value) {
      if(value===1){
        this.completely=false
        this.satisfyPartly=false
        this.productTableList.tableColumn=[
          { label: "产品编号", prop: "number" },
          { label: "产品名称", prop: "name",   min: 110 },
          { label: "订单数量", prop: "orderAmount" },
          { label: "订单完成数量", prop: "finishAmount" },
          { label: "可用库存", prop: "availableAmount" },
    handleRadioChange() {
      let value=this.editConfig.infomation.deliverType
      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", },
          { 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
        let portion=0
        // let noUsable=false
        this.productTableList.tableData.map((item)=>{
          if(item.availableAmount-item.leftAmount<0){
            this.dissatisfy=true
            return this.dissatisfy
          }else{
          item.availableAmount=Number(item.availableAmount)
          item.leftAmount=Number(item.leftAmount)
          item.finishAmount=Number(item.finishAmount)
          item.orderAmount=Number(item.orderAmount)
          console.log(item,"item")
          if(item.availableAmount>=item.leftAmount&&item.availableAmount>0&&item.leftAmount>0){
            portion++
            this.shipmentsList.push(item)
          }
          // if(item.availableAmount<item.leftAmount){
          //   noUsable=true
          // }
        })
        if(portion===this.productTableList.tableData.length){
          if(portion===0){// 没有产品满足发货条件
            this.completely=false
            this.dissatisfy=true
            // if(noUsable){
            //   this.shipmentsMsg="可用库存不满足未发货数量,无法发货"
            // }else{
            // }
            this.shipmentsMsg="可用库存或未发货数量为0或当前可用库存不满足未发货数量,不能完成一次发货"
          }else if(portion>0&&portion<this.productTableList.tableData.length){// 部分产品满足发货条件
            this.dissatisfy=false
            this.completely=true
            this.shipmentsMsg="只能满足部分发货需求,是否确认发货"
          }else if(portion!==0){
            this.dissatisfy=false
            this.completely=true
            console.log(portion,"portion")
            this.shipmentsMsg="能满足发货需求,直接发货吧"
          }
        if(portion===this.productTableList.tableData.length){ // 全部满足发货条件
          this.dissatisfy=false
          this.completely=false
          this.completely=true
        }
      }else if(value===2){
        this.dissatisfy=false
        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",},
      }else if(value==2){
        this.productTableList.showcol= ['产品编号','产品名称', "订单数量", "订单完成数量","可用库存","未发货数量", "本次发货数量","剩余发货数量",]
        this.productTableList.allcol= [ "订单数量", "订单完成数量","可用库存","未发货数量", "剩余发货数量",]
        this.tableColumn= [
          { 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},
          { label: "剩余发货数量", prop: "availableAmount", min:120,},
        ]
        this.productTableList.tableColumn=this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
        let portion=0
        this.productTableList.tableData.map((item)=>{
          if(item.availableAmount-item.leftAmount>=0){
          item.availableAmount=Number(item.availableAmount)
          item.leftAmount=Number(item.leftAmount)
          item.finishAmount=Number(item.finishAmount)
          item.orderAmount=Number(item.orderAmount)
          if(item.availableAmount>0&&item.leftAmount>0){
            portion++
            this.shipmentsList.push(item)
          }
        })
        if(0<portion<this.productTableList.tableData.length){
          this.satisfyPartly=true
        }else if(portion===this.productTableList.tableData.length){
          this.completely=true
          this.dissatisfy=fasle
        }else if(portion===0){
          this.dissatisfy=true
        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){
          if(this.editConfig.infomation.deliverType===1){
            let portion=0
            this.productTableList.tableData.map((item)=>{
              if(item.availableAmount-item.leftAmount<0){
                this.dissatisfy=true
                return this.dissatisfy
              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="能满足发货需求,直接发货吧"
            }
          }
        }
      })
    },
    // 按仓库进行发货
    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="能满足发货需求,直接发货吧"
            }
          }
    }
  }
}
@@ -589,6 +774,9 @@
      }
    }
    .basic-info {
      padding: 0px 20px ;
      .product-view{
      }
      .basic-info-title {
        background-color: #f4f8fe;
        padding-left: 10px;
@@ -623,13 +811,20 @@
      }
      .tips{
        font-size: 16px;
        color: #FF9C49;
        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 {
@@ -643,10 +838,33 @@
      background-color: #f5f5f5;
      height: 55px;
      line-height: 55px;
      text-align: right !important;
    }
    .el-input__inner {
      text-align: left;
    }
    // .el-input__inner {
    //   text-align: left;
    // }
  }
  .el-table tr {
    background-color: #fff;
  }
  .el-table th.el-table__cell.is-leaf{
    background-color: #F1F3F8 !important;
  }
  .el-dialog__footer{
    text-align: right !important;
    padding-right: 20px;
  }
  .el-dialog__header {
    background: #f5f7fa;
    height: 50px !important;
    line-height: 50px !important;
    padding: 0;
    font-weight: 600 !important;
    font-size: 15px !important;
    padding-left: 20px !important;
  }
  // .el-table{
  //   border: 1px solid #e1e1e1;
  // }
}
</style>