factoryDeliveryDetailDialog.vue 11.1 KB
<!-- 发货单详情弹窗 -->
<template>
  <div>
    <baseDialog title="详细信息" :is-show.sync="detailVisible" :config="dialogConfig.setting" :dialog-config="dialogConfig.config" width="1050px" :no-cancel="true" btn-ok-label="关闭" @closeDialog="handleClose" @confirmDialog="handleClose">
      <div class="stockMonthDailog">
        <div class="addressTitle">
          <img src="../images/addressIcon.webp" alt="" class="icon">
          <span class="title">{{ recordInfo.merchantName }}</span>
        </div>
        <div class="address-info" v-if="detailInfo[0]">
          <span class="name">收货人:<span class="label">{{ detailInfo[0].contactName }}</span></span>
          <span class="phone">电话:<span class="label">{{ detailInfo[0].contactPhone }}</span></span>
          <span class="address">收货地址:<span class="label">{{ detailInfo[0].contactAddress }}</span></span>
        </div>
        <!-- <div class="address-info" v-if="detailInfo[0]">
          <span class="address">备注:<span class="label">{{ detailInfo[0].purchaseOrderRemark }}</span></span>
        </div> -->
        <div v-for="(itemList, index) in detailInfo" :key="index">
          <div class="detail-info">
            <div class="detail-item">
              <div class="detail-label">发货单号:</div>
              <span>{{ itemList.deliveryNumber }}</span>
            </div>
            <div class="detail-item">
              <div class="detail-label">承运公司:</div>
              <span>{{ itemList.deliveryCompany }}</span>
            </div>
            <div style="display: flex;">
              <div class="detail-label">发货时间:</div>
              <span>{{ itemList.deliveryDate }}</span>
            </div>
            <div>
              <el-button style="padding: 0;" v-if="itemList.putStatus == 0" type="text" @click="handleEdit(itemList)">编辑</el-button>
              <el-button style="padding: 0;" type="text" @click="handleSign(itemList)">发货签收单</el-button>
            </div>
          </div>
          <d2-table ref="recordTable" :table-data="itemList.deliveryDetailList" :table-params="tableParams" :has-page="false">
            <span slot="deliveryCard" slot-scope="scope">
              <template v-if="scope.scope.deliveryCardList && scope.scope.deliveryCardList.length > 1">
                <!-- {{ scope.scope.deliveryCardList.length || 0 }} -->
                <span>+{{ scope.scope.deliveryCardList.length }} </span>
                <el-button mini type="text" @click="handleDeliveryCard(scope.scope.deliveryCardList)">查看</el-button>
              </template>
              <template v-else-if="scope.scope.deliveryCardList && scope.scope.deliveryCardList.length == 1">
                <!-- {{ scope.scope.deliveryCardList.length || 0 }} -->
                <span>{{ scope.scope.deliveryCardList[0] }}</span>
                <!-- <el-button mini type="text" @click="handleDeliveryCard(scope.scope.deliveryCardList)">查看</el-button> -->
              </template>
              <template v-else>-</template>
            </span>
          </d2-table>
        </div>
      </div>
    </baseDialog>
    <baseDialog title="查看发货卡号" :config="carDialogConfig.setting" :dialog-config="carDialogConfig.config" :is-show.sync="handleDeliveryCardVisible" width="500px" :no-cancel="true" btn-ok-label="关闭" @closeDialog="handleDeliveryCardVisible = false" @confirmDialog="handleDeliveryCardVisible = false">
      <d2-table class="deliveryCardCon" ref="recordTable" :table-data="deliveryCardList" :table-params="innerParams" :has-page="false">
      </d2-table>
    </baseDialog>
    <!-- 编辑 -->
    <glsk-form-dialog v-if="editVisible" :selectVisible="editVisible" :dialogConfig="editDialogConfig" label-width="104px" dialog-width="520px" :formRules="editRules" :editData="editData" :editFormData="editFormData" :base-data="baseData" @handleClose="editVisible = false" @handleConfirm="handleEditConfirm"></glsk-form-dialog>
  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { factoryView, factoryUpdate, deliveryPdf } from '@/api/purchaseShopping.js'
import { baseConfig } from '@/main'

export default {
  name: 'FactoryDeliveryDetailDialog',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    recordInfo: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
      dialogConfig: {
        setting: {
          showClose: true,
          appendToBody: false,
          btnList: [
          ]
        },
        config: {
          title: '详细信息',
          width: '1050px'
        }
      },
      carDialogConfig: {
        setting: {
          showClose: true,
          appendToBody: false,
          btnList: [
          ]
        },
        config: {
          title: '查看发货卡号',
          width: '500px'
        }
      },
      userInfo: this.$store.state.d2admin.user.info,
      membraneTypeList: baseConfig.membraneTypeList,
      detailInfo: '',
      searchFormSearch: {},
      tableData: [],
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '商品名称',
            prop: 'upgradeGoodsName'
          },
          {
            label: '商品编码',
            prop: 'type'
          },
          {
            label: '规格',
            prop: 'specificationData'
          },
          {
            label: '发货数量',
            prop: 'purchaseNumber',
            formatter: cellValue => {
              return this.membraneTypeList.includes(cellValue.goodsType) ? `${cellValue.purchaseNumber}卷` : `${cellValue.purchaseNumber}件`
            }
          },
          {
            label: '备注',
            prop: '',
            formatter: cellValue => {
              return ((cellValue.deliveryRemark || '') + (cellValue.purchaseOrderRemark || '')) || '-'
            }
          },
          {
            label: '发货卡号',
            prop: 'deliveryCardList',
            addHtml: 'deliveryCard'
          }
        ]
      },
      innerParams: {
        tableOption: false,
        tableColumns: [
          {
            label: '卡号',
            prop: 'cardNum'
          }
        ]
      },
      handleDeliveryCardVisible: false,
      deliveryCardList: [],
      // 编辑
      editVisible: false,
      editData: {
        id: '',
        deliveryNumber: '',
        deliveryCompany: ''
      },
      editFormData: [{
        name: 'deliveryNumber',
        label: '承运单号',
        type: 'input',
        inputType: 'textarea',
        rows: 3,
        maxlength: '50',
        isClear: true
      }, {
        name: 'deliveryCompany',
        label: '承运公司',
        type: 'input',
        maxlength: '20',
        isClear: true
      }],
      editRules: {
        deliveryNumber: [{ required: true, message: '请输入承运单号', trigger: 'change' }],
        deliveryCompany: [{ required: true, message: '请输入承运公司', trigger: 'change' }]
      },
      editDialogConfig: {
        title: '编辑'
      }
    }
  },
  computed: {
    detailVisible: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    }
  },
  mounted() {
    this.getDetail()
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    handleDeliveryCard(list) {
      this.handleDeliveryCardVisible = true
      this.deliveryCardList = list.map(item => {
        return { cardNum: item }
      })
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        resolve()
      })
    },

    getDetail() {
      var params = { id: deepClone(this.recordInfo.id), currentPage: 1, pageSize: 1000 }
      factoryView(params).then(res => {
        console.log(res, 'res')
        this.detailInfo = res.list
        this.detailInfo.forEach(item => {
          if (item.deliveryDate) {
            item.deliveryDate = Util.dateFormate(item.deliveryDate, 'YYYY-MM-DD HH:mm:ss')
          }
          const _deliveryDetailList = item.deliveryDetailList
          console.log(_deliveryDetailList, '_deliveryDetailList')
          if (_deliveryDetailList && _deliveryDetailList.length > 0) {
            _deliveryDetailList.forEach(info => {
              const _goodsWarehousingList = info.goodsWarehousingList
              if (_goodsWarehousingList && _goodsWarehousingList.length > 0) {
                _goodsWarehousingList.forEach(item => {
                  item.goodsType = info.goodsType
                })
              }
            })
          }
          // item.deliveryDetailList.forEach(info => {
          //   info.goodsWarehousingList.forEach(item => {
          //     item.goodsType = info.goodsType
          //   })
          // })
        })
      })
    },
    // 编辑
    editDialogVisible() {
      this.editVisible = !this.editVisible
    },

    handleEdit(targetItem) {
      this.editData = {
        id: targetItem.id,
        deliveryNumber: targetItem.deliveryNumber,
        deliveryCompany: targetItem.deliveryCompany
      }
      this.editDialogVisible()
    },

    handleEditConfirm() {
      this.loading = true
      factoryUpdate(this.editData).then((res) => {
        this.notice.okTips()
        this.editDialogVisible()
        this.getDetail()
        // this.handleReset()
      }).finally(() => {
        this.loading = false
      })
    },
    handleSign(row) {
      const params = {
        id: row.id
      }
      deliveryPdf(params).then((res) => {
        console.log(res)
        this.$open(res)
      })
    },

    handleClose() {
      // this.$emit('dialogClose')
      this.detailVisible = false
    }

  }
}

</script>
<style lang="scss" scoped>
.stockMonthDailog {
  // ::v-deep.el-dialog {
  max-height: 60vh;
  overflow: auto;
  // }
}

.deliveryCardCon {
  max-height: 60vh;
  overflow: auto;
}

.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;
  }
}

.detail-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  color: #666666ff;
  font-size: 14px;
  margin-top: 16px;

  .detail-item {
    display: flex;
    width: 319px;
  }
  .detail-label {
    width: 70px;
    flex-shrink: 0;
  }
  span {
    color: #333333ff;
  }

  .add-btn {
    font-size: 14px;
    color: #5850ff;
    cursor: pointer;
  }
}

.orderCode {
  margin-top: 0;
}

.table-wrap {
  border: 1px solid #e5e5e5;
  padding: 16px;
  box-sizing: border-box;
  margin-top: 16px;
}

.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;
  }
}
</style>