index.vue 11.6 KB
<!-- 采购发货 -->
<template>
  <div class="layout">
    <div class="allocate" :style="{ height: isHeight ? 'calc(100vh - 68px)' : '100%' }">
      <!-- 订单基本信息 -->
      <div class="info-section">
        <div class="title">
          订单基本信息
          <div class="status">
            <span :style="{ color: getStepText('orderStatusOpts', allocateOrderInfo.billStatus, 'color') }">{{ getStepText('orderStatusOpts', allocateOrderInfo.billStatus, 'label') }}</span>
            |
            <span :style="{ color: getStepText('deliveryStatusOpts', allocateOrderInfo.deliveryStatus, 'color') }">
              {{ getStepText('deliveryStatusOpts', allocateOrderInfo.deliveryStatus, 'label') }}
            </span>
          </div>
        </div>
        <div v-for="(item, index) in orderBasicInfoList" :key="index" class="info-item">
          <span>{{ item.label }}</span>
          <span class="value" v-if="item.formatter">{{ item.formatter(allocateOrderInfo) }}</span>
          <span class="value" v-else>{{ allocateOrderInfo[item.value] || '--' }}</span>
        </div>
      </div>
      <!-- 订单基本信息 -->
      <div class="info-section">
        <div class="title">
          产品信息
          <span class="title-tip">点击产品名称可查看商品全部信息</span>
        </div>
        <StickyTable :columns="tableColumns" :data="allocateOrderInfo.stockAllocateDetailList" :height="allocateOrderInfo.stockAllocateDetailList.length > 5 ? '216px' : 'auto'">
          <template #goodsName="{ row }">
            <span style="color: #347bff; cursor: pointer" @click="handleProductClick(row)">{{ row.goodsName || '-' }}</span>
          </template>
        </StickyTable>
      </div>
      <!-- 其他信息 -->
      <div class="info-section">
        <div class="title">其他信息</div>
        <div class="info-item">
          <span>备注</span>
          <span class="word-break">{{ formatOpinionText(allocateOrderInfo.remark) }}</span>
        </div>
      </div>
      <!-- 审核流程进度 -->
      <div class="info-section">
        <div class="title">审核流程进度</div>
        <review-status :infoData="allocateOrderInfo"></review-status>
      </div>
      <!-- 审核记录 -->
      <div class="info-section">
        <div class="title">审核记录</div>
        <record :recordList="allocateOrderInfo.auditDetaiList"></record>
      </div>
    </div>
    <div class="footer">
      <div
        class="reject btn"
        @click="handleReject"
        v-if="
          (allocateOrderInfo.billStatus === 1 && staffType == 2) ||
          (allocateOrderInfo.billStatus === 2 && staffType == 3) ||
          (allocateOrderInfo.deliveryStatus === 1 && staffType == 4 && allocateOrderInfo.billStatus == 5)
        "
      >
        驳回
      </div>
      <div class="approve btn" @click="handleApprove" v-if="(allocateOrderInfo.billStatus === 1 && staffType == 2) || (allocateOrderInfo.billStatus === 2 && staffType == 3)">通过</div>
    </div>
    <reject-comp :isVisible="rejectVisible" v-if="rejectVisible" :infoData="allocateOrderInfo" @cancel="handleCancel" @success="handleSuccess"></reject-comp>
    <approve-comp :isVisible="approveVisible" v-if="approveVisible" :infoData="allocateOrderInfo" @cancel="handleApproveCancel" @success="handleApproveSuccess"></approve-comp>
  </div>
</template>

<script type="text/ecmascript-6">
import { getLocalStorage } from '@/utils/util'
import { deepClone } from '@/utils/tools'
import { purchasingPatternOptions } from '@/utils/constants'
import reviewStatus from './reviewStatus.vue'
import record from './record.vue'
import rejectComp from './components/rejectComp.vue'
import ApproveComp from './components/approveComp.vue'
// import detailComp from './components/detailComp.vue'
import allocateApi from '@/api/allocate'
import StickyTable from '@/components/StickyTable.vue'
export default {
  components: { reviewStatus, record, rejectComp, ApproveComp, StickyTable },
  name: '',
  data() {
    return {
      staffType: this.$route.query.staffType, // (2-运营审核 3-商务审核 4-采购发货审核)
      orderCode: this.$route.query.orderCode,
      allocateOrderInfo: {},
      productInfo: {},
      approveVisible: false,
      rejectVisible: false,
      tableColumns: [
        { label: '产品名称', prop: 'goodsName', width: '120px' },
        { label: '产品ID', prop: 'upgradeGoodsCommodityCode', width: '150px' },
        { label: '产品编码', prop: 'productCode', width: '100px' },
        { label: '规格', prop: 'specificationData', width: '90px' },
        {
          label: '调拨数量',
          prop: 'allocateNumber',
          width: '100px',
          formatter: cellValue => {
            return cellValue.allocateNumber || cellValue.allocateNumber === 0 ? cellValue.allocateNumber + ([1, 4, 6, 12, 14].includes(cellValue.goodsType) ? '米' : '件') : '--'
          }
        },
        {
          label: '调入门店库存',
          prop: 'inStockQty',
          width: '120px',
          formatter: cellValue => {
            return cellValue.inStockQty || cellValue.inStockQty === 0 ? cellValue.inStockQty + ([1, 4, 6, 12, 14].includes(cellValue.goodsType) ? '米' : '件') : '--'
          },
          isHidden:false
        },
        {
          label: '调出门店库存', prop: 'outStockQty', width: '120px', formatter: cellValue => {
            return cellValue.outStockQty || cellValue.outStockQty === 0 ? cellValue.outStockQty + ([1, 4, 6, 12, 14].includes(cellValue.goodsType) ? '米' : '件') : '--'
          }
        },
        {
          label: '膜卷号', prop: 'filmRollNo', width: '90px'
        }
      ],
      orderBasicInfoList: [
        { label: '调拨编号', value: 'allocateCode' },
        { label: '调入门店', value: 'callInMerchantName' },
        { label: '调出门店', value: 'callOutMerchantName' },
        {
          label: '调拨数量',
          value: 'totalAllocateNumber'
        },
        { label: '发起时间', value: 'submitTime' },
        {
          label: '当前审核节点',
          value: '',
          formatter: cellValue => {
            return cellValue.billStatus == 1 ? '运营审核' : cellValue.billStatus == 2 ? '商务审核' : '--'
          }
        }
      ],
      deliveryStatusOpts: {
        1: {
          label: '未发货',
          color: '#999999'
        },
        2: {
          label: '全部发货',
          color: '#35C376'
        },
        3: {
          label: '部分发货',
          color: '#FF9D0A'
        },
        4: {
          label: '结束发货',
          color: '#F24724'
        }
      },
      // 订单状态 1.待审核,2运营已审核,3.已取消,4.运营已驳回,5.商务已审核,6.商务已驳回,7.发货已驳回
      orderStatusOpts: {
        1: {
          label: '待审核',
          color: '#FF9D0A'
        },
        2: {
          label: '待审核',
          color: '#FF9D0A'
        },
        3: {
          label: '已取消',
          color: '#999999'
        },
        4: {
          label: '已驳回',
          color: '#F24724'
        },
        5: {
          label: '已审核',
          color: '#35C376'
        },
        6: {
          label: '已驳回',
          color: '#F24724'
        },
        7: {
          label: '已驳回',
          color: '#F24724'
        }
      },
      baseData: {
        purchasingPatternOptions: deepClone(purchasingPatternOptions)
      }
    }
  },
  //D+调拨管理查找调拨单号
  // 第一步:http://192.168.2.111:9527/dj-scrm-wx-work-main-test/#/cannibalize?orderCode=DB202604152929&staffType=2&name=glsadmin 运营审核
  // 第二步:http://192.168.2.111:9527/dj-scrm-wx-work-main-test/#/cannibalize?orderCode=DB202604152929&staffType=3&name=glsadmin  商务审核
  // 第二步: http://192.168.2.111:9527/dj-scrm-wx-work-main-test/#/cannibalize?orderCode=DB202604152929&staffType=4&name=glsadmin 采购发货审核
  created() {

    this.allocateOrderDetail()
  },
  computed: {
    isHeight() {
      const { billStatus, deliveryStatus } = this.allocateOrderInfo || {}
      const staffType = this.staffType
      return (
        (billStatus === 1 && staffType == 2) ||
        (billStatus === 2 && staffType == 3) ||
        (deliveryStatus === 1 && staffType == 4 && billStatus == 5)
      )
    }
  },
  mounted() {
    this.tableColumns.forEach(item=>{
      //运营审核屏蔽调出门店
      if(item.label == '调出门店库存'&&this.staffType == 2){
        item.isHidden = true
      }
    })
   },
  methods: {
    formatOpinionText(opinion) {
			const s = String(opinion == null ? "-" : opinion);
			return s.replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n");
		},
    handleProductClick(row){
      this.$router.push({
        path: '/cannibalize/detail',
        query: {
          id: row.id,
          staffType:this.staffType,
          yqMerchantId:row.yqMerchantId
        }
      })
    },
    handleApproveCancel() {
      this.approveVisible = false
    },
    handleCancel() {
      this.rejectVisible = false
    },
    handleSuccess() {
      this.handleCancel()
      this.allocateOrderDetail()
    },
    handleApproveSuccess() {
      this.handleApproveCancel()
      this.allocateOrderDetail()
    },
    getStepText(opts, status, key) {
      const mapping = this[opts][status]

      return mapping ? mapping[key] : ''
    },
    getStatusItem(baseData, optKey, row, rowKey) {
      if (!baseData || !baseData[optKey] || !row) return null

      return baseData[optKey].find(
        item => item.confId == row[rowKey] // 使用严格相等
      )
    },
    handleSelect() {
      this.sendOutVisible = true
    },
    async allocateOrderDetail() {
      let result = await allocateApi.allocateOrderDetail({ allocateCode: this.orderCode })

      if (result.code == 0) {
        this.allocateOrderInfo = result.data
      }
    },

    //驳回
    handleReject() {
      this.rejectVisible = true
    },
    //通过
    handleApprove() {
      this.approveVisible = true
    }
  }
}
</script>

<style scoped lang="scss">
.layout {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  .footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 7px 16px 10px;
    .btn {
      flex: 1;
      border-radius: 6px;
      height: 41px;
      line-height: 41px;
      font-size: 16px;
    }
    .reject {
      border: 1px solid #dee0e3;
      background: #f4f5f7;
      color: #292d33;
      text-align: center;
    }
    .approve {
      background: #347bff;
      color: #ffffff;
      text-align: center;
      margin-left: 11px;
    }
  }
}
.allocate {
  width: 100vw;
  padding: 12px 10px;
  box-sizing: border-box;
  height: calc(100% - 68px);
  overflow: scroll;
  .info-section {
    padding: 16px 16px 6px;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
    box-sizing: border-box;
    margin-bottom: 12px;
    .title {
      color: #333333;
      font-size: 15px;
      margin-bottom: 10px;
      position: relative;
      font-weight: 600;
      .status {
        font-size: 13px;
        position: absolute;
        right: 0px;
        font-weight: normal;
        top: 0px;
      }
      .title-tip {
        color: #999999;
        font-size: 12px;
        font-weight: 400;
        margin-left: 4px;
      }
    }
  }
  .info-item {
    margin-bottom: 10px;
    display: flex;
  }
  .info-item :nth-child(1) {
    display: inline-block;
    width: 88px;
    color: #999999;
    margin-right: 12px;
  }
  .info-item :nth-child(2) {
    color: #292d33;
    width: 223px;
    white-space: wrap;
    display: inline-block;
    white-space: pre-wrap;
    word-break: break-word;
  }
  .word-break {
    white-space: pre-wrap;
    word-break: break-word;
  }
}
</style>