commodityDetail.vue 5.81 KB
<!-- 订单详情 -->
<template>
  <div class="order-detail marketing">
    <div class="edit-box ">
      <div class="m-b-20 bgf">
        <p class="edit-title">基础信息</p>
        <el-form label-width="120px" :inline="true" class="context-wrap">
          <el-row v-for="(item, index) in detailFormDataRow" :key="index">
            <span v-for="(subItem, subIndex) in item.rowList" :key="subIndex">
               <template v-if="detailForm[subItem.name] != '-'">
              <el-form-item   :label="subItem.label + ':'" class="row-item">
                <span class="detail-txt ellipsis-1" :title="detailForm[subItem.name]">{{ detailForm[subItem.name] ? detailForm[subItem.name] + (subItem.suffix || '') : subItem.isNum ? '0' + (subItem.suffix || '') : '-' }}</span>
              </el-form-item>
            </template>
            </span>
           
          </el-row>
        </el-form>
      </div>
      <div class="edit-container bgf">
        <p class="edit-title">使用门店</p>
        <GLTable ref="warehousListRef" class="context-wrap" :hasPage="false" :tableParams="tableParams" :tableData="detailForm.merchantList"></GLTable>
      </div>
    </div>
    <!-- <GLFooter>
      <el-button @click="handleCancel" size="medium">取消</el-button>
    </GLFooter> -->
  </div>
</template>

<script>
export default {
  name: 'commodityDetail',
  data() {
    return {
      size: 'small',
      title: '查看商品',
      editChildRef: 'editChildRef',
      routeInfo: {
        orderCode: ''
      },
      detailForm: {},
      orderRefund: null,
      orderGoods: [],
      // 订单信息
      detailFormDataRow: [],
      detailFormData: [
        {
          label: '商品名称',
          name: 'goodsName'
        },
        {
          label: '商品编码',
          name: 'type'
        },
        {
          label: '所属系列',
          name: 'goodsCodeName'
        },
        {
          label: '品牌方',
          name: 'brandMerchantName'
        },
        {
          label: '供应方',
          name: 'supplierName'
        },
        {
          label: '产品类型',
          name: 'typeTxt'
        },
        // {
        //   label: '所属系列',
        //   name: 'goodsCode'
        // },
        {
          label: '售价/元',
          name: 'sellPrice',
          isNum: true
        },
        {
          label: '最低售价/元',
          name: 'minSellPrice',
          isNum: true
        },
        {
          label: '赠送成本/元',
          name: 'giftCost',
          isNum: true
        },
        {
          label: '产品成本/元',
          name: 'productCost',
          isNum: true
        },
        {
          label: '库存下限预警',
          name: 'warningValue',
          isNum: true
        },
        {
          label: '库存预警上限',
          name: 'warningValueMax',
          isNum: true
        },
        {
          label: '质保年限',
          name: 'warrantyPeriod',
          isNum: true
        }
      ],
      // 门店表格
      tableParams: {
        tableColumns: [
          {
            label: '门店名称',
            prop: 'merchantName'
          },
          {
            label: '商户号',
            prop: 'merchantId'
          }
        ]
      }
    }
  },

  created() {
    this.formToRow('detailFormData')
  },

  mounted() {
    this.setMinHeight('.edit-box')
    this.routeInfo = this.$route.query
    this.getInfo()
  },

  methods: {
    formToRow(formName, numOfRow = 3) {
      var rowNum = Math.ceil(this[formName].length / numOfRow)
      for (var i = 0; i < rowNum; i++) {
        for (var j = 0; j < numOfRow; j++) {
          if (j == 0) {
            this[formName + 'Row'][i] = {
              rowList: []
            }
          }
          if (i * numOfRow + j < this[formName].length) {
            this[formName + 'Row'][i].rowList.push(this[formName][i * numOfRow + j])
          }
        }
      }
      console.log(this.detailFormDataRow, 'detailFormDataRow---')
    },
    getInfo() {
      this.$apis.commodity.getGoodsDetail({ upgradeGoodsId: this.routeInfo.info.upgradeGoodsId }).then(res => {
        this.detailForm = res
        let list = []
        this.detailForm.baseProductFlag == 'Y' ? list.push('基础产品') : ''
        this.detailForm.upgradeProductFlag == 'Y' ? list.push('升级产品') : ''
        this.detailForm.typeTxt = list.join(',')
        if (list.length != 2 && this.detailForm.baseProductFlag == 'Y') {
          this.detailForm.sellPrice = '-'
          this.detailForm.minSellPrice = '-'
          this.detailForm.productCost = '-'
        }
        if (this.detailForm.goodsCodeName != '太阳膜') {
          this.detailForm.warrantyPeriod = '-'
          this.detailForm.giftCost = '-'
        } else {
          this.detailForm.warrantyPeriod = (this.detailForm.warrantyPeriod || 0) + '年'
        }
      })
    },
    handleCancel() {
      this.$router.push({
        path: '/commodity/index'
      })
    }
  }
}
</script>
<style>
.marketing.order-detail .el-form--inline .el-form-item {
  margin: 0;
}
.marketing.order-detail .el-form--inline .el-form-item__content {
  height: 30px;
}
.marketing.order-detail .form-img .el-form--inline .el-form-item__content {
  height: auto !important;
}
.marketing.order-detail .flex {
  justify-content: flex-start;
}
.marketing.order-detail .row-item {
  width: 33%;
}
.detail-txt {
  display: inline-block;
  width: 220px;
}
.marketing.order-detail .show-table > tbody > tr > td {
  text-align: center;
  vertical-align: middle;
}
.marketing.order-detail .show-table td {
  padding-right: 20px;
}
.order-detail .comment-img {
  margin-top: 10px;
  margin-right: 20px;
}
.edit-title {
  height: 56px;
  background: #ffffff;
  line-height: 56px;
  border-bottom: 1px solid #f0f1f7;
  padding-left: 20px;
}
.bgf {
  background: #ffffff;
}
.context-wrap {
  padding: 20px;
}
</style>