AllocateDialog.vue 8.46 KB
<template>
  <div>
    <baseDialog :is-show.sync="dialogShow" :config="dialogConfig.setting" :dialog-config="dialogConfig.config"
      @closeDialog="handleDetailClose(false)">
      <div class="edit-order-dialog" v-if="dialogShow">
        <div class="addressTitle">
          <img src="../images/addressIcon.webp" alt="" class="icon">
          <span class="title">{{ paramsObj.merchantName }}</span>
        </div>
        <div class="address-info">
          <span class="name">收货人:<span class="label">{{ detailInfo.contactName }}</span></span>
          <span class="phone">电话:<span class="label">{{ detailInfo.contactPhone }}</span></span>
          <span class="address">收货地址:<span class="label">{{ detailInfo.contactAddress }}</span></span>
        </div>
        <div class="address-info"
           v-if="detailInfo.purchaseOrderRemark">
        <span class="address">备注:<span class="label">{{ detailInfo.purchaseOrderRemark }}</span></span>
      </div>
        <div class="table-class">
          <d2-table ref="purchaseOrderDetailTable" :table-params="tableParams" :has-page="hasPage"
            @refreshTable="refreshTable" :table-data="detailInfo.tableData" :table-total="detailInfo.tableTotal">
            <div slot="nowPurNum" slot-scope="scope">
              <div
                v-if="detailInfo.tableData[scope.index].purchaseNumber == detailInfo.tableData[scope.index].goodsNumber">
                {{ detailInfo.tableData[scope.index].shipper || '未分配' }}</div>
              <div
                v-else-if="detailInfo.tableData[scope.index].shipper && detailInfo.tableData[scope.index].purchaseNumber != 0">
                {{ detailInfo.tableData[scope.index].shipper }}</div>
              <div
                v-else-if="detailInfo.tableData[scope.index].purchaseNumber != 0 && !detailInfo.tableData[scope.index].shipper">
                未分配</div>
              <el-select v-else v-model="nowPurNumList[scope.index]" placeholder="请选择" clearable>
                <el-option v-for="item in staffList" :key="item.uuid" :label="item.staffName" :value="item.uuid">
                </el-option>
              </el-select>
            </div>
          </d2-table>
        </div>
        <div class="footer">
          <el-button @click="handleDetailClose(false)">取消</el-button>
          <el-button @click="submit" type="primary" v-preventReClick
            :loading="$store.state.d2admin.loading.value">确定</el-button>
        </div>
      </div>
    </baseDialog>
    <card-dialog v-if="cardVisible" :card-visible="cardVisible" :order-info="orderInfo"
      :selected-list="selectedCardList" @handleClose="handleCardDialog"
      @handleConfirm="handleCardConfirm"></card-dialog>
  </div>
</template>

<script>
import { purchaseOrderDetail, getShipperList, saveshipper } from '@/api/purchaseShopping.js'
import { baseConfig } from '@/main'
import CardDialog from './CardDialog'
export default {
  name: 'AllocateDialog',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    paramsObj: {
      type: Object,
      default: () => { }
    }
  },
  components: {
    CardDialog
  },
  computed: {
    dialogShow: {
      get() {
        if (this.visible) {
          return this.visible
        }
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    }
  },
  data() {
    return {
      dialogConfig: {
        setting: {
          showClose: true,
          appendToBody: true,
          btnList: [
          ]
        },
        config: {
          title: '发货分配',
          width: '1300px'
        }
      },
      isSubmit: false,
      dialogData: {},
      deliveryCardList: [],
      oldPurNumList: [],
      nowPurNumList: [],
      // 发货卡号
      cardVisible: false,
      orderInfo: {},
      hasPage: false,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [
          {
            label: '商品名称',
            prop: 'upgradeGoodsName'
          },
          {
            label: '商品编码',
            prop: 'type'

          },
          {
            label: '规格',
            prop: 'specificationData'

          },
          {
            label: '系列',
            prop: 'goodsName'
          },
          {
            label: '所属分类',
            prop: 'goodsTypeName'

          },
          {
            label: '采购数量',
            prop: 'goodsNumber',
            formatter: (cellValue) => {
              return baseConfig.membraneTypeList.includes(cellValue.goodsType) ? `${cellValue.goodsNumber}卷` : `${cellValue.goodsNumber}件`
            }
          },
          {
            label: '库存总量',
            prop: '',
            formatter: (cellValue) => {
              return baseConfig.membraneTypeList.includes(cellValue.goodsType) ? `${cellValue.conversionValue ? cellValue.goodsNumber * cellValue.conversionValue : '-'}米` : `${cellValue.goodsNumber}件`
            }
          },
          {
            label: '采购总价/元',
            prop: 'goodsTotalPrice',
            formatter: (cellValue) => {
              return "¥" + cellValue.goodsTotalPrice
            }
          },
          {
            label: '已发货数量',
            prop: 'purchaseNumber',
            formatter: (cellValue) => {
              return baseConfig.membraneTypeList.includes(cellValue.goodsType) ? `${cellValue.purchaseNumber || 0}卷` : `${cellValue.purchaseNumber || 0}件`
            }
          },
          {
            label: '发货方',
            prop: '',
            addHtml: 'nowPurNum'
          }
        ]
      },
      staffList: [],
      detailInfo: {}
    }
  },
  mounted() {
    this.getStaffList()
  },
  methods: {
    getStaffList() {
      getShipperList({}).then(res => {
        this.staffList = res
        this.getDetail({ currentPage: 1, pageSize: 999 })
      })
    },
    handleDetailClose(isRefresh = false) {
      this.$emit('editClose', isRefresh)
    },
    refreshTable(pageObj) {
      this.getDetail(pageObj)
    },
    getDetail(pageObj) {
      // if (!this.paramsObj?.orderCode) {
      //   return true
      // }
      this.nowPurNumList = []
      purchaseOrderDetail({ orderCode: this.paramsObj.orderCode, pageSize: pageObj.pageSize, currentPage: pageObj.currentPage }).then(res => {
        this.detailInfo = res
        this.detailInfo.tableData = res.pagination.list
        this.detailInfo.tableTotal = res.pagination.total
        this.detailInfo.tableData.forEach((item, idx) => {
          if (item.shipper) {
            this.nowPurNumList[idx] = {}
            this.nowPurNumList[idx] = this.staffList.find(k => k.staffName == item.shipper)?.uuid || ''
          }
        })
      })
    },
    submit() {
      this.isSubmit = true
      // 验证本次发货数量
      // if (this.nowPurNumList.every(item => item == 0 || !item)) {
      //   this.notice.errorTips('发货方不能全为空')
      //   return true
      // }
      var params = {
        purchaseOrderGoodsList: []
      }
      this.detailInfo.tableData.forEach((item, idx) => {
        // if (this.nowPurNumList[idx]) {
        params.purchaseOrderGoodsList.push({
          orderCode: this.paramsObj.orderCode,
          id: item.id,
          shipperUuid: this.nowPurNumList[idx] || '',
          shipper: this.staffList.find(k => k.uuid == this.nowPurNumList[idx])?.staffName || ''
        })
        // }
      })
      saveshipper(params).then(res => {
        this.handleDetailClose(true)
        this.notice.okTips()
      }).catch(() => {
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.addressTitle {
  display: flex;
  align-items: center;

  .title {
    font-family: PingFangSC-Medium;
    font-weight: 600;
    font-size: 16px;
    color: #333333;
  }

  .icon {
    width: 28px;
    height: 28px;
    margin-right: 8px;
  }
}

.address-info {
  display: flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  width: 100%;
  // height: 36px;
  // padding: 0 20px;
  margin-top: 10px;
  font-size: 14px;
  color: #666666;

  >span {
    margin-right: 20px;
    margin-bottom: 10px;
  }

  .label {
    color: #333333;
  }

  .address {
    min-width: 500px;
  }
}

.form-content {
  margin-top: 16px;

  .dis-in-block {
    width: 432px;
  }
}

.footer {
  display: flex;
  justify-content: flex-end;
}

.edit-order-dialog .el-input--medium.border-red .el-input__inner {
  border: 1px solid #eb4e4e;
}
</style>