commodityDetail.vue 7.02 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 content" v-if="isShow">
          <div v-for="(subItem, index) in detailFormData" :key="index" :class="[detailForm[subItem.name] != '-' ? 'w-30' : '']">
            <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] === null ? '-' : detailForm[subItem.name] ? detailForm[subItem.name] + (subItem.suffix || '') : subItem.isNum ? '0' + (subItem.suffix || '') : '-' }}</span>
              </el-form-item>
            </template>
          </div>
        </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>
  </div>
</template>

<script>
export default {
  name: 'commodityDetail',
  data() {
    return {
      size: 'small',
      title: '查看商品',
      editChildRef: 'editChildRef',
      isShow: false,
      routeInfo: {
        orderCode: ''
      },
      detailForm: {},
      orderRefund: null,
      orderGoods: [],
      // 订单信息
      detailFormData: [
        {
          label: '商品名称',
          name: 'goodsName'
        },
        {
          label: '商品编码',
          name: 'type'
        },
        {
          label: '所属分类',
          name: 'goodsTypeName'
        },
        {
          label: '品牌方',
          name: 'brandMerchantName'
        },
        {
          label: '供应方',
          name: 'supplierName'
        },
        {
          label: '适用部位',
          name: 'posTxt'
        },
        {
          label: '比例换算',
          name: 'convertedValueTxt'
        },
        {
          label: '扣减标准',
          name: 'deductionStandard',
          suffix: '米/车'
        },
        {
          label: '产品类型',
          name: 'typeTxt'
        },
        {
          label: '售价',
          name: 'sellPrice',
          isNum: true,
          suffix: '元/件'
        },
        {
          label: '最低售价',
          name: 'minSellPrice',
          isNum: true,
          suffix: '元/件'
        },
        {
          label: '赠送成本',
          name: 'giftCost',
          isNum: true,
          suffix: '元/车'
        },
        {
          label: '产品成本',
          name: 'productCost',
          isNum: true,
          suffix: '元/件'
        },
        {
          label: '质保年限/年',
          name: 'warrantyPeriod',
          isNum: true
        },
        {
          label: '库存下限预警',
          name: 'warningValue',
          isNum: true,
          suffix: '米'
        },
        {
          label: '库存上限预警',
          name: 'warningValueMax',
          isNum: true,
          suffix: '米'
        }
      ],
      // 门店表格
      tableParams: {
        tableColumns: [
          {
            label: '门店名称',
            prop: 'merchantName'
          },
          {
            label: '商户号',
            prop: 'merchantId'
          }
        ]
      }
    }
  },

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

  methods: {
    getGoodsPosList() {
      this.$apis.commodity.getGoodsPosList({}).then(res => {
        this.goodsPosList = res
        let obj = this.goodsPosList.find(item => item.positionValue == this.detailForm.position)
        this.detailForm.posTxt = obj ? obj.positionName : '-'
      })
    },
    changeFormAttr(formName, attrName, labelList, attrValue) {
      labelList.forEach(item => {
        this[formName].forEach(k => {
          if (k.label == item) {
            k[attrName] = attrValue
          }
        })
      })
    },
    getInfo() {
      this.$apis.commodity.getGoodsDetail({ upgradeGoodsId: this.routeInfo.info.upgradeGoodsId }).then(res => {
        this.detailForm = {
          ...res,
          posTxt: ''
        }
        let list = []
        let baseLabelList = ['售价', '最低售价', '产品成本']
        let unitLabelList = ['库存下限预警', '库存上限预警']
        this.detailForm.baseProductFlag == 'Y' ? list.push('基础产品') : ''
        this.detailForm.upgradeProductFlag == 'Y' ? list.push('升级产品') : ''
        this.detailForm.typeTxt = list.join(',')
        this.changeFormAttr('detailFormData', 'suffix', baseLabelList, this.detailForm.goodsTypeName == '自建商品-精品' ? '元/件' : '元/车')
        this.changeFormAttr('detailFormData', 'suffix', unitLabelList, this.detailForm.goodsTypeName == '自建商品-精品' ? '件' : '米')
        this.detailForm.convertedValueTxt = this.detailForm.convertedValue ? '1卷=' + this.detailForm.convertedValue + '米' : '-'
        this.getGoodsPosList()
        if (list.length != 2 && this.detailForm.baseProductFlag == 'Y') {
          this.detailForm.sellPrice = '-'
          this.detailForm.minSellPrice = '-'
          this.detailForm.productCost = '-'
        }
        if (list.length != 2 && this.detailForm.upgradeProductFlag == 'Y') {
          this.detailForm.giftCost = '-'
        }
        if (this.detailForm.goodsTypeName != '自建商品-太阳膜') {
          this.detailForm.warrantyPeriod = '-'
          this.detailForm.giftCost = '-'
          this.detailForm.deductionStandard = '-'
          this.detailForm.typeTxt = '-'
        } else {
          this.detailForm.warrantyPeriod = (this.detailForm.warrantyPeriod || 0) + '年'
        }
        // console.log(this.detailForm, '000')
        this.isShow = true
      })
    },
    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;
}
.order-detail .content {
  display: flex;
  flex-wrap: wrap;
}
.order-detail .w-30 {
  width: 33%;
}
.marketing.order-detail .row-item {
  display: inline-block;
  /* 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>