packageView.vue 8.47 KB
<!-- 查看上架 -->
<template>
  <d2-container class="edit-commodity">
    <div class="" v-if="show">
      <detail ref="d2PackageDetail" :rules="rules" form-name="grounding" :origin-data="editData" :form-list="editForm"
              @handleCheck="handleCheck"
              @handleClose="handleAddClose"></detail>
    </div>
  </d2-container>
</template>
<script>
import { getPackageDetailInfo, batchCheckPackage } from '@api/packageManage'
import detail from './components/detail.vue'
import { sceneList, BaseData } from '@/common/constants.js'
import { mapActions } from 'vuex'
import { deepClone, Util } from '@/common/util'
import { baseConfig } from "@/main"
import { packageGoodsDetail, upgradeSupplyModeList, crowdUpgradeSupplyModeList } from '../grounding/constants/data'
import { filterSpecsStr } from "../filterOption"
export default {
  name: 'PackageDetail',
  components: {
    detail
  },
  data() {
    return {
      extendedPosiType: baseConfig.extendedPosiType || [], // 延保类
      rules: {
        merchantGoodsRefList: [{ required: true }],
        packageName: [{ required: true }],
        sceneName: [{ required: true }],
        positionStr: [{ required: true }],
        upgradeGoodsName: [{ required: true }],
        sellPrice: [{ required: true }],
        minSellPrice: [{ required: true }],
        djCost: [{ required: true }],
        thirdPartyCost: [{ required: true }],
        upgradeProductCost: [{ required: true }],
        recoveryCost: [{ required: true }],
        virtualAccountCost: [{ required: true }],
        financeCheckFlagStr: [{ required: true }]
      },
      editForm: [{
        title: '套餐信息',
        formBlock: [{
          name: 'packageName',
          label: '套餐名称'
        }, {
          name: 'packageAlias',
          label: '套餐别名'
        }, {
          name: 'sellPrice',
          label: '售价',
          // unit: true
          isPrice: true
        }, {
          name: 'minSellPrice',
          label: '最低售价',
          // unit: true
          isPrice: true
        }, {
          name: 'upgradeProductCost',
          label: '产品、升级成本',
          // unit: true
          isPrice: true
        }, {
          name: 'recoveryCost',
          label: '回收成本',
          // unit: true
          isPrice: true
        }, {
          name: 'virtualAccountCost',
          label: '虚拟对账成本',
          // unit: true
          isPrice: true
        }, {
          name: 'djCost',
          label: '嘀加成本',
          // unit: true
          isPrice: true
        }, {
          name: 'thirdPartyCost',
          label: '第三方成本',
          // unit: true
          isPrice: true
        }, {
          name: 'financeCheckFlagStr',
          label: '财务规则校验'
        }]
      }, {
        title: '商品信息',
        formBlock: []
      }, {
        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,
      detailId: '',
      warrantyTypeShow: {
        0: '质保卡',
        1: '质保权益卡'
      },
      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) {
      getPackageDetailInfo({ id }).then(res => {
        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
        }
        res.groundingGoodsList = []
        res?.merchantGoodsInfoList?.forEach(val => {
          if (val.goodsType == 1) { // 太阳膜类 升级产品供货模式(优先级高)
            arr = upgradeSupplyModeList
          }
          const { goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName } = val.goodsInfo || {}
          const types = [goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName]
          const result = types.filter(type => type).join('-')
          this.editForm[1].formBlock.push(packageGoodsDetail)
          // 太阳膜类回显部位
          const positionNamesArr = deepClone(this.positionTypeList).filter(subVal => (val?.upgradeGoods?.position?.split(','))?.includes(subVal.position + '')) || []
          res.groundingGoodsList.push({
            goodsType: val?.goodsType, // 类目值
            upgradeGoodsId: val?.upgradeGoodsId, // 升级商品Id
            goodsAlias: val?.goodsAlias || '-', // 商品别名
            positionStr: deepClone(this.positionTypeList)?.filter(subVal => val?.position == subVal.position)[0]?.confName || '', // 上架部位
            sellPrice: val?.sellPrice, // 售价
            minSellPrice: val?.minSellPrice, // 最低售价
            validMinSellPrice: val?.validMinSellPrice, // 是否校验最低价
            djCost: val?.djCost, // 嘀加成本
            thirdPartyCost: val?.thirdPartyCost, // 第三方成本
            supplierCode: val?.goodsInfo?.supplierCode, // 供应方
            warrantyTypeStr: this.warrantyTypeShow[val?.warrantyType] || '-', // 质保卡类型
            upgradeSupplyMode: val?.upgradeSupplyMode,
            upgradeSupplyModeStr: arr?.filter(v => v.confId == val.upgradeSupplyMode)[0]?.confName || '', // 升级产品供货模式
            upgradeProductCost: val?.upgradeProductCost, // 升级产品成本
            virtualAccountCost: val?.virtualAccountCost, // 虚拟对账成本
            recoveryCost: val?.recoveryCost, // 回收成本
            warrantyPeriod: val?.upgradeGoods?.warrantyPeriod, // 质保年限
            upgradePrice: val?.upgradeGoods?.upgradePrice, // 参考售价
            upgradeGoods: {
              ...val?.upgradeGoods,
              goodsName: val.goodsName,
              upgradeGoodsName: val?.upgradeGoodsName,
              goodsTypeName: val?.goodsTypeName, // 升级商品所属类目
              tempGoodsTypeName: result,
              serviceItemNames: val?.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(val?.upgradeGoods),
              carTypeConfigName: val?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join('/'),
              upgradeCommodityCode: val?.upgradeCommodityCode
            }
          })
        })
        res.sceneName = sceneList[res.sceneType] || '-'
        res.financeCheckFlagStr = res.financeCheckFlag == 'Y' ? '开启' : res.financeCheckFlag == 'N' ? '关闭' : '-'
        res.merchantGoodsRefList = res.merchantGoodsRefList || []
        res.voucherList = res?.voucherList || []
        this.editData = res || {}
        this.$nextTick(() => {
          this.show = true
        })
      })
    },
    filterEmpty(data) {
      return (data ?? '') === ''
    },
    handleCheck() {
      this.$confirm('<p>审核通过后,套餐完成上架,对应的门店可使用该商品</p>是否确定审核?', '提示', {
        confirmButtonText: '确定',
        dangerouslyUseHTMLString: true,
        type: 'warning'
      }).then(() => {
        batchCheckPackage({ ids: [this.detailId] }).then(res => {
          this.notice.okTips()
          this.handleClose(true)
        })
      }).catch(err => {
        console.log(err)
      })
    },
    handleClose() {
      this.close({ tagName: '/packageManage' })
      this.$router.push({ name: 'packageManage' })
      this.close({ tagName: '/packageView' })
    },
    handleAddClose() {
      this.handleClose()
    }
  }
}
</script>
<style lang="scss" scoped></style>