detailComp.vue 3.69 KB
<template>
  <h-dialog ref="myDialog" :title="title" :isVisible="isVisible" :hideCancelBtn="hideBtn" :hideConfirmBtn="hideBtn" :showCloseBtn="hideBtn" @confirm="handleSubmit" @cancel="handleCancel">
    <div class="formObj">
      <div class="cell" v-for="(item, index) in editFormData" :key="index">
        <div class="label">
          {{ item.label }}
        </div>
        <div class="value">{{ item.formatter ? item.formatter(infoData) : (infoData[item.prop] || '-') }}</div>
      </div>
    </div>
  </h-dialog>
</template>

<script>
import hDialog from './dialog'
import { Toast } from 'vant'
import purchaseApi from '@/api/purchase'
export default {
  components: { hDialog },
  data() {
    return {
      name: this.$route.query.name,
      title: '商品详情',
      hideBtn: true,
      editFormData: [
        {
          label: '产品名称',
          prop: 'upgradeGoodsName'
        },
        { label: '产品编码', prop: 'type', width: '100px' },
        { label: '规格', prop: 'specificationData', width: '90px' },
        {
          label: '采购数量',
          prop: 'goodsNumber',
          width: '100px',
          formatter: (row) => {
            const unit = row.conversionValue ? '卷' : '件'
            return (row.goodsNumber || 0) + unit
          }
        },
        {
          label: '库存总量',
          prop: 'inventoryTotal',
          width: '100px',
          formatter: (row) => {
            const total = (row.goodsNumber || 0) * (row.conversionValue || 1)
            if (!row.conversionValue) {
              return (row.goodsNumber || 0) + '件'
            } else {
              // 乘法可能存在精度问题,简单处理
              return ((row.goodsNumber || 0) * row.conversionValue).toFixed(2) + '米'
            }
          }
        },
        {
          label: '已发货数量', prop: 'purchaseNumber', width: '100px',
          formatter: (row) => {
            const unit = row.conversionValue ? '卷' : '件'
            return (row.purchaseNumber || 0) + unit
          }
        },
        {
          label: '单价', prop: 'upgradePurchasePrice', width: '90px',
          formatter: (row) => {
            return '¥' + row.upgradePurchasePrice
          }
        },
        {
          label: '总价', prop: 'goodsTotalPrice', width: '90px',
          formatter: (row) => {
            return '¥' + row.goodsTotalPrice
          }
        },
        {
          label: '备注',
          prop: 'remark'
        }
      ]
    }
  },

  props: {
    isVisible: {
      type: Boolean,
      default: false
    },
    infoData: {
      type: Object,
      default: () => ({})
    }
  },
  mounted() {
    console.log('mounted', this.infoData)
  },
  methods: {
    handleSubmit() {
    },
    handleCancel() {
      this.$emit('cancel')
      //   this.isVisible = false
    }
  }
}
</script>
<style lang="scss" scoped>
.formObj {
  margin: 0 12px;
  font-size: 14px;
  .cell {
    display: flex;
    align-items: flex-start;
    margin-top: 14px;
    color: #222222;
    // height: 52px;
    // border-bottom: 1px solid #eff0f2;
  }
  .label {
    width: 72px;
    color: #999999;
    font-size: 14px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    line-height: 17px;
    margin-right: 10px;
    flex-shrink: 0;
    .require {
      color: #f24724;
      font-size: 14px;
      margin-left: 4px;
      line-height: 52px;
      margin-top: 5px;
    }
  }
  .value {
    word-break: break-all;
  }
  .line-feed {
    .label {
      line-height: 52px;
    }
    .textarea {
      border-radius: 8px;
      border: 1px solid #eff0f2;
      //   height: 220px;
    }
  }
  .explain {
    color: #999999;
    font-size: 14px;
    margin-top: 10px;
  }
}
</style>