specifications.vue 5.59 KB
<template>
  <div class="specifications-form" ref="specifications-form">
    <p class="title">产品信息-SKU</p>
    <div class="content-box">
      <div class="sync_type_class">
        <span class="label"><span class="color-red">*</span>使用模式:</span>
        <el-radio-group v-model="goodsInfoData.shoppingMallFlag" :disabled="pageData.pageDisabled">
          <el-radio :label="'1'">采购上架及分发至单店</el-radio>
          <el-radio :label="'0'">仅分发至单店</el-radio>
        </el-radio-group>
      </div>
      <div style="margin-left: 120px;">
        <div class="add-btns">
          <div v-if="goodsInfoData.specificationType == '2'">
            <el-button icon="el-icon-plus"
                     type="primary" plain
                     :disabled="goodsInfoData.scrmFlag == 'Y' || pageData.pageDisabled"
                     @click="handleSpecsEdit(1)">新增规格</el-button>
            <el-button :disabled="goodsInfoData.scrmFlag == 'Y' || pageData.pageDisabled" type="primary" plain @click="handleSpecsManage">规格组合管理</el-button>
          </div>
          <el-button icon="el-icon-plus" :disabled="pageData.pageDisabled" v-if="goodsInfoData.specificationType == '1'" type="primary" plain @click="addShop">新增商品</el-button>
          <div class="assi_type">
            <span>规格:</span>
            <el-radio-group v-model="goodsInfoData.specificationType" :disabled="goodsInfoData.scrmFlag == 'Y' || pageData.pageDisabled" @change="changeRadio">
              <el-radio :label="'1'">单规格</el-radio>
              <el-radio :label="'2'">多规格</el-radio>
            </el-radio-group>
          </div>
        </div>
        <div class="speci-box" id="specificationDetailList">
          <singleSpecificationForm ref="singleSpecificationFormRef" v-show="goodsInfoData.specificationType == '1'"
                                   :product-service-item-list="productServiceItemList" :extend-service-part-list="extendServicePartList">
          </singleSpecificationForm>
          <multipleSpecificationForm ref="multipleSpecificationFormRef" v-show="goodsInfoData.specificationType == '2'"
                                     :product-service-item-list="productServiceItemList" :extend-service-part-list="extendServicePartList">
          </multipleSpecificationForm>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
import multipleSpecificationForm from './multipleSpecificationForm.vue'
import singleSpecificationForm from './singleSpecificationForm.vue'
import { mapGetters, mapMutations, mapActions } from 'vuex'
import { BaseData } from '@/common/constants.js'
import { getExtendServiceItemsParts } from '@/api/productManage'
export default {
  name: 'Specifications',
  components: {
    singleSpecificationForm,
    multipleSpecificationForm
  },
  inject: ['pageData'],
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      productPositionTypeList: [],
      productServiceItemList: [],
      extendServicePartList: []
    }
  },
  computed: {
    ...mapGetters('goodsInfoData', { goodsInfoData: 'getGoodsInfoData' })
  },
  mounted() {
    if (this.goodsInfoData.goodsSpecificationNameList?.length > 1) {
      // 多规格
      this.goodsInfoData.specificationType = '2'
    }
    this.getBaseData()
    // 获取延保服务项目部件数据
    this.getParts()
  },
  methods: {
    ...mapActions({
      get: 'd2admin/base/get'
    }),
    getParts() {
      getExtendServiceItemsParts({}).then(res => {
        this.extendServicePartList = res?.supportPositionList || []
        this.extendServicePartList.unshift('全部')
      })
    },
    async getBaseData() {
      this.productServiceItemList = await this.get(BaseData.productServiceItemList)
    },
    ...mapMutations('goodsInfoData', ['setUpdateGoodsInfo']),
    // 新增规格
    handleSpecsEdit(num) {
      this.$refs.multipleSpecificationFormRef.handleSpecsEdit(num)
    },
    // 规格管理
    handleSpecsManage() {
      this.$refs.multipleSpecificationFormRef.handleSpecsManage()
    },
    // 新增商品
    addShop() {
      this.$refs.singleSpecificationFormRef.addShop()
    },
    // 切换规格将数据清空
    changeRadio(value) {
      if (value == 1) { // 单规格
        this.setUpdateGoodsInfo({ specificationSingleDetailList: [], goodsSpecificationSingleList: [] })
      } else { // 多规格
        this.setUpdateGoodsInfo({ specificationDetailList: [] })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.specifications-form {
  margin-top: 20px;
  background: #ffffff;

  .title {
    height: 50px;
    line-height: 50px;
    padding: 0 20px;
    border-bottom: 1px solid #E5E5E5;
    font-size: 16px;
    font-weight: 600;
    color: #333333;
  }

  .content-box {
    padding: 20px 20px 40px 20px;
  }

  .add-btns {
    display: flex;
    justify-content: space-between;
    font-size: 14px;

    .el-button {
      width: 140px;
    }
  }

  .speci-box {
    width: 100%;

    .title-tip {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 15px;
      height: 40px;
      font-weight: bold;
      background: #F2F4F7;
    }
  }

  .sync_type_class {
    font-size: 14px;
    padding: 20px 0;

    .label {
      display: inline-block;
      text-align: right;
      width: 120px;

      .color-red {
        color: #eb4e4e;
        font-size: 14px;
        margin-right: 4px;
        cursor: pointer;
      }
    }
  }
}
::v-deep .el-radio__original {
  display: none !important;
}

::v-deep .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled)
  .el-radio__inner {
  box-shadow: none !important;
}
</style>