yangfeng
2024-03-23 ef815963da1ebaebcb4de8985f178e3add8c54a3
src/views/orderManageModule/orderManage/components/DeliveryDialog.vue
@@ -39,7 +39,6 @@
          style="width: 100%"
          height="500"
          border
          @selection-change="getSelectArray"
          :header-cell-style="{
            background: '#f1f3f8',
            color: '#000009',
@@ -50,12 +49,12 @@
        >
          <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
          <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
          <el-table-column prop="name" label="产品名称" show-overflow-tooltip></el-table-column>
          <el-table-column prop="number" label="产品编号" show-overflow-tooltip> </el-table-column>
          <el-table-column prop="orderAmount" label="订单数量"> </el-table-column>
          <el-table-column prop="amount" label="已发货数量"> </el-table-column>
          <el-table-column prop="specifications" label="产品规格"> </el-table-column>
          <el-table-column prop="modelNumber" label="产品型号"> </el-table-column>
          <el-table-column prop="productName" label="产品名称" show-overflow-tooltip></el-table-column>
          <el-table-column prop="productId" label="产品编号" show-overflow-tooltip> </el-table-column>
          <el-table-column prop="amount" label="订单数量"> </el-table-column>
          <el-table-column prop="sendAmount" label="已发货数量"> </el-table-column>
          <el-table-column prop="specs" label="产品规格"> </el-table-column>
          <el-table-column prop="type" label="产品型号"> </el-table-column>
          <el-table-column prop="unit" label="单位"> </el-table-column>
          <el-table-column prop="deliveryAmount" label="发货数量">
            <template slot-scope="scope">
@@ -82,7 +81,7 @@
          <el-button @click="editRow.visible = false">关闭</el-button>
        </template>
        <template v-else>
          <el-button type="primary" :loading="isAddloading" @click="saveClick('form')">全部发货完成</el-button>
          <!-- <el-button type="primary" :loading="isAddloading" @click="deliveryCompleteClick()">全部发货完成</el-button> -->
          <el-button @click="editRow.visible = false">取消</el-button>
          <el-button type="primary" :loading="isAddloading" @click="saveClick('form')">确认发货</el-button>
        </template>
@@ -92,6 +91,7 @@
</template>
<script>
import { getDeliveryPrepare, saveDelivery, changeOutsourceOrderStatus } from "@/api/orderManageModule/orderManage"
export default {
  name: "DeliveryDialog",
  props: {
@@ -118,12 +118,7 @@
        infomation: {}
      },
      isAddloading: false,
      tableData: [
        {
          name: "顶顶顶顶",
          deliveryAmount: 2
        }
      ],
      tableData: [],
      ruleForm: {
        number: "",
        carrier: "",
@@ -136,6 +131,7 @@
  },
  created() {
    // this.setTableForm()
    this.getDeliveryPrepare()
  },
  watch: {
    "editCommonConfig.visible"(val) {
@@ -148,27 +144,26 @@
    handleClose() {
      this.editRow.visible = false
    },
    // 获取发货产品列表
    getDeliveryPrepare() {
      getDeliveryPrepare({
        outsourcingOrderID: this.editRow.infomation.id
      }).then((res) => {
        console.log(res)
        if (res.code == 200) {
          let list = res.data.map((item) => {
            return {
              ...item,
              deliveryAmount: 0
            }
          })
          this.tableData = list
        }
      })
    },
    // 多选回调
    getSelectArray(arr) {
      console.log(arr)
      // let isPush = true
      // if (arr.length > 0) {
      //   for (let i in arr) {
      //     let item = {
      //       outsourcingOrderNumber: this.editRow.infomation.outsourcingOrderNumber,
      //       materialNumber: arr[i].id,
      //       materialName: arr[i].name,
      //       amount: 1,
      //       unit: arr[i].unit ? arr[i].unit : 1,
      //       type: arr[i].type ? arr[i].type : "",
      //       specs: arr[i].specs ? arr[i].specs : ""
      //     }
      //     console.log(arr, "8989")
      //     isPush = this.getIsPush(this.productTableList.tableInfomation, arr[i].id)
      //     if (isPush) {
      //       this.productTableList.tableInfomation.splice(this.productTableList.tableInfomation.length, 0, item)
      //     }
      //   }
    },
    // 数量输入回调
    inputContent(val, scope) {
@@ -177,9 +172,50 @@
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log("保存内容处理")
          console.log(this.ruleForm, "保存内容处理", this.tableData)
          let deliveryList = this.tableData.map((item) => {
            return {
              outsourcingOrderProductID: item.id,
              sendAmount: item.deliveryAmount
            }
          })
          let params = {
            carrier: this.ruleForm.carrier,
            deliveryList: deliveryList,
            number: this.ruleForm.number,
            outsourcingOrderID: this.editRow.infomation.id,
            waybillNumber: this.ruleForm.waybillNumber
          }
          saveDelivery(params).then((res) => {
            if (res.code == 200) {
              this.handleClose()
              this.$message.success("发货成功")
              this.$emit("reRreshData")
            }
          })
        }
      })
    },
    // 全部发货完成
    deliveryCompleteClick() {
      this.$confirm("是否确认全部发货完成?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        changeOutsourceOrderStatus({
          outsourcingOrderNumber: this.editRow.infomation.number,
          status: 7
        })
          .then((reply) => {
            if (reply.code == 200) {
              this.handleClose()
              this.$message.success("全部发货完成成功")
              this.$emit("reRreshData")
            }
          })
          .catch(() => {})
      })
    }
  }
}