groundingDetail.vue 9.57 KB
<!-- 查看上架 -->
<template>
  <d2-container class="edit-commodity">
    <div class="" v-if="show">
      <detail ref="d2GroundingDetail" :rules="rules" form-name="grounding" :origin-data="editData" :form-list="editForm"
              :product-service-item-list="productServiceItemList" @handleAddConfirm="handleAddConfirm"
              @handleClose="handleAddClose"></detail>
    </div>
  </d2-container>
</template>
<script>
import { getMerchantGoodsInfo, batchReviewAPI } from '@api/grounding'
import detail from './components/detail.vue'
import { sceneList, BaseData } from '@/common/constants.js'
import { mapActions } from 'vuex'
import { deepClone, Util } from '@/common/util'
import { productList, baseSupplyModeList, upgradeSupplyModeList, crowdUpgradeSupplyModeList } from './constants/data'
import { baseConfig } from "@/main"
import { filterSpecsStr } from '../filterOption'
export default {
  name: 'GroundingDetail',
  components: {
    detail
  },
  data() {
    return {
      extendedPosiType: baseConfig.extendedPosiType || [], // 延保类
      rules: {
        merchantGoodsRefList: [{ required: true }],
        sceneName: [{ required: true }],
        goodsName: [{ required: true }],
        productTypeStr: [{ required: true }],
        baseSupplyModeStr: [{ required: true }],
        upgradeSupplyModeStr: [{ required: true }],
        sellPrice: [{ required: true }],
        minSellPrice: [{ required: true }],
        upgradeProductCost: [{ required: true }],
        giftCost: [{ required: true }],
        recoveryCost: [{ required: true }],
        virtualAccountCost: [{ required: true }],
        warrantyTypeStr: [{ required: true }],
        djCost: [{ required: true }],
        thirdPartyCost: [{ required: true }],
        financeCheckFlagStr: [{ required: true }]
      },
      editForm: [{
        title: '商品信息',
        formBlock: [{
          name: 'goodsName',
          label: '上架商品',
          type: 'incidBox',
          key: 'goodsType',
          detailInfo: [{
            label: '商品名称',
            value: 'upgradeGoodsName'
          }, {
            label: '规格',
            value: 'specificationData'
          }, {
            label: '商品编码',
            value: 'type'
          }, {
            label: '第三方编码',
            value: 'thirdPartyCode'
          }, {
            label: '采购价',
            value: 'purchasePrice',
            unit: true
          }, {
            label: '参考售价',
            value: 'upgradePrice',
            unit: true
          }, {
            label: '适用车型',
            value: 'carTypeConfigName'
          }, {
            label: '所属系列',
            value: 'goodsName'
          }, {
            label: '所属分类',
            value: 'tempGoodsTypeName'
          }, {
            label: '商品ID',
            value: 'upgradeCommodityCode'
          }]
        }, {
          name: 'positionStr',
          label: '上架部位'
        }, {
          name: 'goodsAlias',
          label: '商品别名'
        }, {
          name: 'warrantyTypeStr',
          label: '质保卡类型'
        }, {
          name: 'productTypeStr',
          label: '产品类型'
        }, {
          name: 'baseSupplyModeStr',
          label: '基础产品供货模式'
        }, {
          name: 'upgradeSupplyModeStr',
          label: '升级产品供货模式'
        }, {
          name: 'sellPrice',
          label: '售价',
          unit: true
        }, {
          name: 'minSellPrice',
          label: '最低售价',
          unit: true
        }, {
          name: 'upgradeProductCost',
          label: '产品、升级成本',
          unit: true
        }, {
          name: 'giftCost',
          label: '赠送成本',
          unit: true
        }, {
          name: 'recoveryCost',
          label: '回收成本',
          unit: true
        }, {
          name: 'virtualAccountCost',
          label: '虚拟对账成本',
          unit: true
        }, {
          name: 'djCost',
          label: '嘀加成本',
          unit: true
        }, {
          name: 'thirdPartyCost',
          label: '第三方成本',
          unit: true
        }, {
          name: 'financeCheckFlagStr',
          label: '财务规则校验'
        }]
      }, {
        title: '门店信息',
        formBlock: [{
          name: 'sceneName',
          label: '业务场景'
        }, {
          name: 'merchantGoodsRefList',
          label: '上架门店',
          type: 'table'
        }, {
          name: 'voucherList',
          label: '上架凭证',
          type: 'upload'
        }]
      }, {
        title: '操作信息',
        formBlock: [{
          type: 'checkView',
          name: 'reviewLogList'
        }]
      }],
      show: false,
      editData: {},
      examineFlag: false,
      warrantyTypeShow: {
        0: '质保卡',
        1: '质保权益卡'
      },
      detailId: '',
      productServiceItemList: [],
      filterSpecsStr
    }
  },
  mounted() {
    this.getBaseData()
    // 获取商品详情
    const id = this.$route.params.id
    this.detailId = id
    if (!id) return this.show = true
    this.getDetailInfo(id)
  },
  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    async getBaseData() {
      this.positionTypeList = await this.get(BaseData.positionTypeList)
    },
    getDetailInfo(id) {
      getMerchantGoodsInfo({ id }).then(res => {
        const productType = []
        if (res?.upgradeProductFlag == 'Y') productType.push(2)
        if (res?.baseProductFlag == 'Y') productType.push(1)
        const { goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName } = res.goodsInfo || {}
        const types = [goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName]
        const result = types.filter(type => type).join('-')
        const productTypeTextArr = []
        // 太阳膜/延保类回显部位
        const positionNamesArr = deepClone(this.positionTypeList).filter(val => (res?.upgradeGoods.position?.split(','))?.includes(val.position + '')) || []
        // 产品类型
        productList.forEach(v => {
          if (productType.includes(v.confId)) productTypeTextArr.push(v.confName)
        })
        res.reviewLogList?.forEach(val => {
          val.updatedDateStr = val.updatedDate ? Util.dateFormate(val.updatedDate, 'YYYY-MM-DD HH:mm:ss') : ''
        })
        let arr = []
        if (res.sceneType == 3) { // 1.3场景 升级产品供货模式
          arr = crowdUpgradeSupplyModeList
        }
        if (res.goodsType == 1) { // 太阳膜类 升级产品供货模式(优先级高)
          arr = upgradeSupplyModeList
        }
        res.productTypeStr = productTypeTextArr?.length ? productTypeTextArr.join(';') : '-'
        res.warrantyTypeStr = this.warrantyTypeShow[res?.warrantyType] || '-'
        res.baseSupplyModeStr = baseSupplyModeList?.filter(v => v.confId == res.baseSupplyMode)[0]?.confName || ''
        res.upgradeSupplyModeStr = arr?.filter(v => v.confId == res.upgradeSupplyMode)[0]?.confName || ''
        res.sceneName = sceneList[res.sceneType] || '-'
        res.productType = productType
        res.merchantGoodsRefList = res.merchantGoodsRefList || []
        res.voucherList = res?.voucherList || []
        res.positionStr = deepClone(this.positionTypeList)?.filter(val => res?.position == val.position)[0]?.confName || ''
        res.supplierCode = res?.goodsInfo?.supplierCode
        res.financeCheckFlagStr = res?.financeCheckFlag == 'Y' ? '开启' : res?.financeCheckFlag == 'N' ? '关闭' : '-'
        res.upgradeGoods = {
          ...res.upgradeGoods,
          goodsName: res.goodsInfo.goodsName,
          tempGoodsTypeName: result,
          serviceItemNames: res?.upgradeGoods?.upgradeGoodsServiceItemsList?.map(item => { return `${item.serviceName}-${item.serviceGrade}/${item.servicePeriod}` })?.join(','), // 服务项目
          positionNames: positionNamesArr.length ? positionNamesArr.map(subItem => { return subItem?.confName }).join('/') : '',
          specificationData: this.filterSpecsStr(res?.upgradeGoods),
          carTypeConfigName: res?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join('/'),
          upgradeCommodityCode: res?.upgradeGoods?.commodityCode
        }
        this.editData = res || {}
        this.$nextTick(() => {
          this.show = true
        })
      })
    },
    filterEmpty(data) {
      return (data ?? '') === ''
    },
    handleAddConfirm() {
      this.$confirm('<p>审核通过后,商品完成上架,对应的门店可使用该商品</p>是否确定审核?', '提示', {
        confirmButtonText: '确定',
        dangerouslyUseHTMLString: true,
        type: 'warning'
      }).then(() => {
        batchReviewAPI({ ids: [this.detailId] }).then(res => {
          this.notice.okTips()
          this.handleClose(true)
        })
      }).catch(err => {
        console.log(err)
      })
    },
    handleClose(isRefresh = false) {
      if (isRefresh) {
        this.close({ tagName: '/grounding' })
        this.$router.push({ name: 'grounding' })
        this.close({ tagName: '/grounding' })
      } else {
        this.$confirm('内容未保存,是否返回?', '提示', {
          confirmButtonText: '确定',
          type: 'warning'
        }).then(() => {
          this.close({ tagName: '/grounding' })
          this.$router.push({ name: 'grounding' })
          this.close({ tagName: '/grounding' })
        }).catch(err => {
          console.log(err)
        })
      }
    },
    handleAddClose() {
      this.handleClose(true)
    }
  }
}
</script>
<style lang="scss" scoped></style>