<style>
  .pintuanActive .box-grow-0 {
    flex-grow: 0;
    min-width: 0;
    flex-shrink: 0;
    display: inline-block;
  }

  .pintuanActive .bottom-div {
    border-top: 1px solid #E3E3E3;
    position: fixed;
    bottom: 0;
    background-color: #ffffff;
    z-index: 999;
    padding: 10px;
    width: 86%;
    left: 230px;
  }

  .pintuanActive .button-item {
    padding: 9px 25px;
    margin: 5px 0;
  }

  @media (max-width:1920px) and (min-width:1300px) {
    .pintuanActive .el-col-12 {
      width: 50%;
    }
  }

  @media (max-width:1910px) and (min-width:1200px) {
    .pintuanActive .el-col-12 {
      width: 66.66667%;
    }
  }

  @media (max-width:1199px) and (min-width:200px) {
    .pintuanActive .el-col-12 {
      width: 80%;
    }
  }

</style>
<template>
  <div class="pintuanActive">
    <div class="head-title">
      <span @click="CommonJump('pintuanList')" class="blue point">拼团活动</span>
      / 新建活动
    </div>
    <div style="background:#fff;margin-top:10px;padding:10px 20px 20px">
      <el-form class="app-batch" :model="addMsg" :rules="rules" ref="addMsg" label-width="180px">
        <el-row :gutter="24">
          <el-tabs v-model="activeName">
            <el-tab-pane label="商品设置" name="first">
              <el-card shadow="never">
                <div slot="header" class="clearfix">
                  <span>活动设置</span>
                </div>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="开始时间" prop="StartTime">
                      <el-date-picker v-model="addMsg.StartTime" size="small" type="datetime" placeholder="选择日期时间">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item label="结束时间" prop="EndTime">
                      <el-date-picker v-model="addMsg.EndTime" size="small" type="datetime" placeholder="选择日期时间">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>
              <el-card style="margin-top:20px" shadow="never">
                <div slot="header" class="clearfix">
                  <span>商品设置</span>
                </div>
                <el-row>
                  <el-col :span="12">
                    <el-form-item>
                      <template slot="label">
                        <span>商品信息获取</span>
                        <el-tooltip class="item" effect="dark" content="只能从商城中获取商品信息，且基本信息与商城商品保持一致" placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-button type="text">{{addMsg.name}}</el-button>
                      <el-button type="text" v-if="addMsg.ActivityId==0" @click="isShowGoods=true">选择商品</el-button>
                    </el-form-item>
                    <el-form-item label="商品名称" prop="name">
                      <el-input size="small" v-model="addMsg.name" placeholder="请输入内容" maxlength="500" :disabled="true">
                      </el-input>
                    </el-form-item>
                    <el-form-item label="上架状态">
                      <el-switch active-color="#409EFF" v-model="addMsg.GoodsStatus" :active-value="1"
                        :inactive-value="2">
                      </el-switch>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>排序</span>
                        <el-tooltip class="item" effect="dark" content="排序值越小排序越靠前" placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input v-model="addMsg.Sort" type="number" min="1" size="small" placeholder="请输入内容"
                        class="input-with-select"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>
              <el-card style="margin-top:20px" shadow="never">
                <div slot="header" class="clearfix">
                  <span>价格库存</span>
                </div>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="售价" prop="SellingPrice">
                      <el-input v-model="addMsg.SellingPrice" type="number" min="1" size="small" placeholder="请输入内容"
                        class="input-with-select">
                        <el-button slot="append">元</el-button>
                      </el-input>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>原价</span>
                        <el-tooltip class="item" effect="dark" content="以划线形式显示" placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input v-model="addMsg.Original_Price" type="number" :disabled="true" min="0" size="small"
                        placeholder="请输入内容" class="input-with-select">
                        <el-button slot="append">元</el-button>
                      </el-input>
                    </el-form-item>
                    <el-form-item label="商品总库存">
                      <el-input v-model="addMsg.Goods_Stock" size="small" :disabled="true" placeholder="请输入商品总库存"
                        class="input-with-select">
                      </el-input>
                    </el-form-item>
                    <el-form-item label="默认规格名">
                      <el-input v-model="addMsg.Goods_unit" type="text" :disabled="true" size="small"
                        placeholder="请输入默认规格名" class="input-with-select">
                      </el-input>
                    </el-form-item>
                    <el-form-item label="商品规格">
                      <template slot="label">
                        <span>商品规格</span>
                        <el-tooltip class="item" effect="dark" content="如有颜色、尺码等多种规格，请添加商品规格" placement="top-start">
                          <i class="elzk el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <goodsSpe v-show="IsShowSpec" @getSpecList="getSpecList" @getSpecPriceList="getSpecPriceList"
                        :SpecList="TempSpecList" :SpecPriceList="TempSpecPriceList"></goodsSpe>
                    </el-form-item>
                    <el-form-item label="商品货号">
                      <el-input v-model="addMsg.Goods_no" size="small" :disabled="true" placeholder="请输入商品货号"
                        class="input-with-select">
                      </el-input>
                    </el-form-item>
                    <el-form-item label="商品重量">
                      <el-input v-model="addMsg.Goods_weight" type="number" :disabled="true" min="0" size="small"
                        placeholder="请输入商品重量" class="input-with-select">
                        <el-button slot="append">克</el-button>
                      </el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>
              <el-card style="margin-top:20px;" shadow="never">
                <div slot="header" class="clearfix">
                  <span>购买设置</span>
                </div>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="是否开启虚拟成团">
                      <el-switch active-color="#409EFF" v-model="addMsg.Is_Auto_Add_Robot" :active-value="1"
                        :inactive-value="2">
                      </el-switch>
                      <div style="color:#c6c6c6">开启虚拟成团后，系统将模拟“匿名买家”凑满人数促成成团，商家仅需对真实拼团买家发货</div>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>已团商品数</span>
                        <el-tooltip class="item" effect="dark" content="前端展示的销量=实际销量+已团商品数" placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input type="number" :disabled="true" v-model="addMsg.Virtual_Sales" min="0" size="small"
                        placeholder="请输入内容" class="input-with-select">
                        <el-button slot="append">件</el-button>
                      </el-input>
                    </el-form-item>
                    <el-form-item label="是否允许单独购买">
                      <el-switch active-color="#409EFF" v-model="addMsg.Is_Alone_Buy" :active-value="1"
                        :inactive-value="2">
                      </el-switch>
                    </el-form-item>
                    <el-form-item label="商品服务">
                      <template v-if="addMsg.ServiceList && addMsg.ServiceList.length > 0">
                        <el-tag style="margin-right:10px;" @close="ServiceCheck(item, index)"
                          v-for="(item, index) in addMsg.ServiceList" :key="index+'7'" closable>{{ item.Name }}
                        </el-tag>
                      </template>
                      <el-button @click="serviceDig = true,checkService=[]" v-if="addMsg.IsDefaultService == 2"
                        size="mini">新增服务</el-button>
                      <el-checkbox v-model="addMsg.IsDefaultService" @change="getServeChange(addMsg.IsDefaultService)"
                        :true-label="1" :false-label="2">默认服务</el-checkbox>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>运费设置</span>
                        <el-tooltip class="item" effect="dark" content="选择第一项（默认运费）将会根据运费管理的（默认运费）变化而变化"
                          placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <template v-if="AreaName && AreaName != ''">
                        <el-tag style="margin-right:10px;" @close="
                            (AreaName = ''), (addMsg.FreightId = 0)
                          " closable>
                          {{ AreaName }}</el-tag>
                      </template>
                      <el-button @click="chooseyfDig = true" size="mini">选择运费</el-button>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>自定义表单</span>
                        <el-tooltip class="item" effect="dark" content="选择第一项（默认表单）将会根据表单列表的（默认表单）变化而变化"
                          placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <template v-if="formName && formName != ''">
                        <el-tag style="margin-right:10px;"
                          @close="(formName = ''),(checkedForm=''), (addMsg.FormsId = 0)" closable>
                          {{ formName }}</el-tag>
                      </template>
                      <el-button @click="choosebdDig = true" size="mini">选择表单</el-button>
                    </el-form-item>
                    <el-form-item label="限购数量" size="small">
                      <div flex="dir:left">
                        <span class="box-grow-0" style="color:#606266">商品</span>
                        <div style="width: 100%;margin:0 10px">
                          <el-input placeholder="请输入限购数量" v-model="addMsg.Confine_Count" size="small">
                            <template slot="append">件</template>
                          </el-input>
                        </div>
                        <el-checkbox v-model="addMsg.Confine_Count <= -1" @change="itemChecked"
                          style="margin-left:5px;line-height:32px;">无限制
                        </el-checkbox>
                      </div>
                      <div flex="dir:left" style="margin-top: 10px;">
                        <span class="box-grow-0" style="color:#606266">订单</span>
                        <div style="width: 100%;margin:0 10px">
                          <el-input placeholder="请输入限购数量" v-model="addMsg.Confine_Order_Count" size="small">
                            <template slot="append">单</template>
                          </el-input>
                        </div>
                        <el-checkbox v-model="addMsg.Confine_Order_Count<=-1" @change="itemOrderChecked"
                          style="margin-left:5px;line-height:32px;">无限制
                        </el-checkbox>
                      </div>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>单品满件包邮</span>
                        <el-tooltip class="item" effect="dark" content="如果设置0或空，则不支持满件包邮" placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input type="number" :disabled="true" v-model="addMsg.Pieces" min="0" size="small"
                        placeholder="请输入数量" class="input-with-select">
                        <el-button slot="append">件</el-button>
                      </el-input>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>单品满额包邮</span>
                        <el-tooltip class="item" effect="dark" content="如果设置0或空，则不支持满额包邮" placement="top">
                          <i class="el-tooltip el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input type="number" :disabled="true" v-model="addMsg.Forehead" min="0" size="small"
                        placeholder="请输入金额" class="input-with-select">
                        <el-button slot="append">元</el-button>
                      </el-input>
                    </el-form-item>
                    <el-form-item label="区域购买">
                      <el-switch active-color="#409EFF" v-model="addMsg.Is_Area_Limit" :active-value="1"
                        :inactive-value="2">
                      </el-switch>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>
              <el-card style="margin-top:20px;" shadow="never">
                <div slot="header" class="clearfix">
                  <span>营销设置</span>
                </div>
                <el-row>
                  <el-col :span="12">
                    <el-form-item>
                      <template slot="label">
                        <span>积分赠送</span>
                        <el-tooltip effect="dark" placement="top">
                          <div slot="content">用户购物赠送的积分, 如果不填写或填写0，则默认为不赠送积分，
                            如果为百分比则为按成交价格的比例计算积分"<br />
                            如: 购买2件，设置10 积分, 不管成交价格是多少， 则购买后获得20积分</br>
                            如: 购买2件，设置10%积分, 成交价格2 * 200= 400， 则购买后获得 40 积分（400*10%）
                          </div>
                          <i class="el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input type="number" min="0" v-model="addMsg.Give_integral" size="small"
                        placeholder="请输入赠送积分数量">
                        <template slot="append">
                          分
                          <el-radio :label="1" v-model="addMsg.Give_integral_type">固定值
                          </el-radio>
                          <el-radio :label="2" v-model="addMsg.Give_integral_type">百分比
                          </el-radio>
                        </template>
                      </el-input>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>积分抵扣</span>
                        <el-tooltip effect="dark" content="如果设置0，则不支持积分抵扣 如果带%则为按成交价格的比例计算抵扣多少元" placement="top">
                          <i class="el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input type="number" min="0" size="small" v-model="addMsg.Is_forehead_integral"
                        placeholder="请输最高抵扣金额">
                        <template slot="prepend">最多抵扣</template>
                        <template slot="append">
                          元
                          <el-radio :label="1" v-model="addMsg.Forehead_integral_type">固定值
                          </el-radio>
                          <el-radio :label="2" v-model="addMsg.Forehead_integral_type">百分比
                          </el-radio>
                        </template>
                      </el-input>
                      <el-checkbox :true-label="1" v-model="addMsg.Accumulative" :false-label="0">
                        允许多件累计抵扣
                      </el-checkbox>
                    </el-form-item>
                    <el-form-item label="卡券发放">
                      <el-button size="small">选择表单</el-button>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>
              <el-card style="margin-top:20px;" shadow="never">
                <div slot="header" class="clearfix">
                  <span>分享设置</span>
                </div>
                <el-row>
                  <el-col :span="12">
                    <el-form-item>
                      <template slot="label">
                        <span>自定义分享标题</span>
                        <el-tooltip effect="dark" content="分享给好友时，作为商品名称" placement="top">
                          <i class="el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-input type="text" size="small" v-model="addMsg.App_share_title" placeholder="请输入分享标题">
                      </el-input>
                      <el-button type="text">查看图例</el-button>
                    </el-form-item>
                    <el-form-item>
                      <template slot="label">
                        <span>自定义分享图片</span>
                        <el-tooltip effect="dark" content="分享给好友时，作为分享图片" placement="top">
                          <i class="el-icon-info"></i>
                        </el-tooltip>
                      </template>
                      <el-tooltip class="item" effect="dark" content="建议尺寸:420 * 336" placement="top">
                        <el-button size="mini" @click="imgDialog=true">选择图片</el-button>
                      </el-tooltip>
                      <div class="zk_pic_box" @click="imgDialog=true" style="width:80px;height:80px;"
                        flex="main:center cross:center"
                        :style="{backgroundImage:'url(' + getIconLink(addMsg.App_share_pic) + ')'}">
                        <i v-if="addMsg.App_share_pic==''" class="el-icon-picture-outline"></i>
                        <el-button type="danger" v-if="addMsg.App_share_pic!=''" class="image-delete" size="mini"
                          icon="el-icon-close" @click.stop="addMsg.App_share_pic=''" circle></el-button>
                      </div>
                      <el-button type="text">查看图例</el-button>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>
            </el-tab-pane>
            <el-tab-pane label="阶梯团设置">
              <groupStep v-if="TempSpecList&&TempSpecList.length>0"   @setNewVal="setNewVal" :SpecList="TempSpecList" :GroupPriceList="TempGroupPriceList"
                :SpecPriceList="TempSpecPriceList"></groupStep>
            </el-tab-pane>
            <el-tab-pane label="分销价设置">
              <distributePrice :shareGroup_list="TempGroupPriceList"></distributePrice>
            </el-tab-pane>
            <el-tab-pane label="会员价设置">
              <memberPrice :SpecificationPriceList="TempSpecPriceList" :SpecificationList="TempSpecList"></memberPrice>
            </el-tab-pane>
          </el-tabs>
        </el-row>
      </el-form>
      <div class="bottom-div" flex="cross:center" style="margin-top:20px">
        <el-button size="small" class="button-item" type="primary" @click="SaveInfo('addMsg')">保存</el-button>
        <el-button size="small" class="button-item" style="margin-left:10px;">预览</el-button>
      </div>
    </div>
    <!-- 选择商品 -->
    <el-dialog title="选择商品" :visible.sync="isShowGoods" custom-class="goodsDialog" width="800px">
      <choiceGood ref="choiceGood" :ckGoods="ckGoods" :isSingle="true" :IsGetSpec="1"></choiceGood>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="isShowGoods=false">取 消</el-button>
        <el-button size="small" type="danger" @click="getGoodsChoice()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 选择图片 -->
    <el-dialog title="选择文件" :visible.sync="imgDialog" width="1240px">
      <ChooseImg @SelectId="SelectId" :IsMultiple="true"></ChooseImg>
    </el-dialog>
    <!-- 选择商品服务 -->
    <el-dialog title="选择商品服务" :visible.sync="serviceDig" width="600px">
      <div style="border: 1px solid #EBEEF5;padding:20px 0">
        <el-checkbox-group v-model="checkService">
          <el-checkbox style="margin:5px" v-for="item in serviceList" :label="item" :key="item.Id">{{ item.Name }}
          </el-checkbox>
        </el-checkbox-group>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="serviceDig=false" size="small">取消</el-button>
        <el-button @click="(addMsg.ServiceList = checkService), (serviceDig = false)" size="small" type="primary">确定
        </el-button>
      </span>
    </el-dialog>
    <!-- 选择运费 -->
    <el-dialog title="选择运费" top="2%" :visible.sync="chooseyfDig" width="600px">
      <div>
        <el-radio-group v-model="selectYunFei">
          <el-radio @change="YfSelect" style="padding-bottom:10px" class="yfradio"
            :label="{ RulesName: '默认运费', ID: 0 }">默认运费
          </el-radio>
          <el-radio @change="YfSelect" style="padding-bottom:10px" class="yfradio" v-for="(item, index) in ruleList"
            :key="index+'23'" :label="item">{{ item.RulesName }}</el-radio>
        </el-radio-group>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="chooseyfDig = false">取 消</el-button>
        <el-button size="small" @click="chooseyfDig=false" type="primary">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 选择表单 -->
    <el-dialog title="选择表单" top="2%" :visible.sync="choosebdDig" width="30%">
      <div>
        <el-radio-group v-model="checkedForm">
          <el-radio :label="0">
            默认表单
          </el-radio>
        </el-radio-group>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="choosebdDig = false">取 消</el-button>
        <el-button size="small" @click="getCkedForm" type="primary">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>
<script>
  import ChooseImg from "@/components/global/ChooseImg.vue";
  import goodsSpe from "@/components/pintuan/pintuanPlugin/goodsSpecifica.vue"
  import choiceGood from "@/components/common/choiceGood.vue";
  import groupStep from "@/components/pintuan/pintuanPlugin/groupStep.vue"
  import distributePrice from "@/components/pintuan/pintuanPlugin/distributePrice.vue"
  import memberPrice from "@/components/pintuan/pintuanPlugin/memberPrice.vue"

  export default {
    components: {
      ChooseImg,
      goodsSpe,
      choiceGood,
      groupStep,
      distributePrice,
      memberPrice
    },
    data() {
      return {
        ckGoods: 0,
        isShowGoods: false, //是否显示商品
        activeName: "first",
        addMsg: {
          ActivityId: 0, //活动Id
          StartTime: '', //开始时间
          EndTime: '', //结束时间
          GoodId: 0, //商品编号
          name: '', //商品名称
          GoodsStatus: 1, //上架状态(0-未开始，1-上架,2-下架中,3-删除)
          Sort: 100, //排序
          SellingPrice: 0, //售价
          Original_Price: 0, //原价
          Goods_Stock: 0, //商品总库存
          Goods_unit: "", // 商品规格字段
          Goods_no: '', //商品货号
          Goods_weight: '', //商品重量
          Is_Auto_Add_Robot: 0, //是否开启虚拟团
          Virtual_Sales: 0, //已团商品数
          Is_Alone_Buy: 0, //是否允许单独购买
          IsDefaultService: 1, //是否默认商品服务(1是,2否)
          ServiceList: [], //商品服务字段
          FreightId: 0, //运费设置
          FormsId: 0, //自定义表单
          Confine_Count: -1, //限购数量
          Confine_Order_Count: -1, //限购订单
          Pieces: 0, //单品满件包邮 
          Forehead: 0, //单品满额包邮
          Is_Area_Limit: 0, //区域购买
          Area_limit: "", //购买区域
          Give_integral: 0, //积分赠送
          Give_integral_type: 1, //积分赠送=>1固定值 2百分比
          Is_forehead_integral: 0, //积分抵扣
          Forehead_integral_type: 1, //积分抵扣=>1固定值 2百分比
          Accumulative: 0, //允许多件累计抵扣
          CardIds: "", //卡券发放
          App_share_title: '', //自定义分享标题、
          App_share_pic: '', //自定义分享图片
          IsCustomSpecification: 2, // 是否自定义规格  1是  2否
          GroupList:[],//阶梯价格
        },
        IsShowSpec: false, //是否显示规格
        TempSpecList: [], //规格列表
        TempSpecPriceList: [], //规格价格列表
        TempGroupPriceList: [], //阶梯团价

        serviceDig: false,
        serviceList: [], //新增服务弹出数据
        checkService: [],

        chooseyfDig: false, //运费弹窗
        ruleList: [], //运费数组
        selectYunFei: {}, //选中运费
        AreaName: '',

        choosebdDig: false, //选择表单
        checkedForm: '',
        formName: '',
        imgDialog: false,
        rules: {
          StartTime:[{
            required: true,
            message: "请选择开始时间",
            trigger: "change"
          }],
          EndTime:[{
            required:true,
            message: "请选择结束时间",
            trigger: "change"
          }],
          name:[{
            required:true,
            message: "请选择商品",
            trigger: "blur"
          }]
        },

      };
    },
    created() {},
    mounted() {
      if (this.$route.query.Id) {
        this.addMsg.ActivityId = this.$route.query.Id;
        this.getData();
      }
      this.getService();
      this.getRule();
    },
    methods: {
      //获取商品数据
      getData() {
        var qMsg = {
          ActivityId: this.addMsg.ActivityId
        }
        this.apipost("/api/GroupBuy/GetGroupbuyActivity", qMsg, res => {
          console.log("GetGroupbuyActivity", res.data.data);
          if (res.data.resultCode == 1) {
            let Mydata = res.data.data;
            this.addMsg.StartTime = Mydata.StartTimeStr;
            this.addMsg.EndTime = Mydata.EndTimeStr;
            this.addMsg.GoodId = Mydata.GoodId;
            this.addMsg.name = Mydata.QGoodName;
            this.addMsg.GoodsStatus = Mydata.GoodsStatus;
            this.addMsg.Sort = Mydata.Sort;
            this.addMsg.SellingPrice = Mydata.SellingPrice;
            this.addMsg.Original_Price = Mydata.Original_Price;
            this.addMsg.Goods_Stock = Mydata.Goods_Stock;
            this.addMsg.Goods_unit = Mydata.Goods_unit;
            this.addMsg.Goods_no = Mydata.Goods_no;
            this.addMsg.Goods_weight = Mydata.Goods_weight;
            this.addMsg.Is_Auto_Add_Robot = Mydata.Is_Auto_Add_Robot;
            this.addMsg.Virtual_Sales = Mydata.Virtual_Sales;
            this.addMsg.Is_Alone_Buy = Mydata.Is_Alone_Buy;
            this.addMsg.IsDefaultService = Mydata.IsDefaultService;
            this.addMsg.ServiceList = Mydata.ServiceList;
            this.addMsg.FreightId = Mydata.FreightId;
            this.addMsg.FormsId = Mydata.FormsId;
            this.addMsg.Confine_Count = Mydata.Confine_Count;
            this.addMsg.Confine_Order_Count = Mydata.Confine_Order_Count;
            this.addMsg.Pieces = Mydata.Pieces;
            this.addMsg.Forehead = Mydata.Forehead;
            this.addMsg.Is_Area_Limit = Mydata.Is_Area_Limit;
            this.addMsg.Area_limit = Mydata.Area_limit;
            this.addMsg.Give_integral = Mydata.Give_integral;
            this.addMsg.Give_integral_type = Mydata.Give_integral_type;
            this.addMsg.Is_forehead_integral = Mydata.Is_forehead_integral;
            this.addMsg.Forehead_integral_type = Mydata.Forehead_integral_type;
            this.addMsg.Accumulative = Mydata.Accumulative;
            this.addMsg.CardIds = Mydata.CardIds;
            this.addMsg.App_share_title = Mydata.App_share_title;
            this.addMsg.App_share_pic = Mydata.App_share_pic;
            this.addMsg.IsCustomSpecification = Mydata.IsCustomSpecification;

            if (Mydata.SpecificationList && Mydata.SpecificationList.length > 0) {
              this.addMsg.SpecificationList = Mydata.SpecificationList; //规格赋值
              this.TempSpecList = Mydata.SpecificationList;
            }
            if (Mydata.SpecificationPriceList && Mydata.SpecificationPriceList.length > 0) {
              this.addMsg.SpecificationPriceList = Mydata.SpecificationPriceList; //规格列表赋值
              this.TempSpecPriceList = JSON.parse(JSON.stringify(Mydata.SpecificationPriceList));
            }
            
            if (Mydata.GroupList && Mydata.GroupList.length > 0) {
              this.addMsg.GroupList = Mydata.GroupList;
              this.TempGroupPriceList = Mydata.GroupList;
            }
            this.IsShowSpec = true;
          } else {
            this.Error(res.data.message);
          }
        })
      },
      //点击checkbox是否限购商品
      itemChecked(type) {
        this.addMsg.Confine_Count = type ? -1 : 0;
      },
      //点击checkbox是否限购订单
      itemOrderChecked(type) {
        this.addMsg.Confine_Order_Count = type ? -1 : 0;
      },
      //保存
      SaveInfo(formName) {
        this.$refs[formName].validate(valid => {
          if (valid) {
            this.SaveActivity();
          } else {
            return false;
          }
        });
      },
      //保存拼团活动
      SaveActivity() {
        // 是否自定义规格  1是  2否
        if (this.addMsg.SpecificationList && this.addMsg.SpecificationList.length > 0) {
          this.addMsg.IsCustomSpecification = 1;
        }
        this.apipost("/api/GroupBuy/SetGroupbuyActivity", this.addMsg, res => {
          console.log("res", res.data);
          if (res.data.resultCode == 1) {
            this.CommonJump("pintuanList", {});
            this.Success(res.data.message);
          } else {
            this.Info(res.data.message);
          }
        })
      },
      //选择商品
      getGoodsChoice() {
        this.isShowGoods = false;
        this.IsShowSpec = false;
        var chooseGoods = this.$refs.choiceGood.getChoicedGoods();
        if (chooseGoods && chooseGoods.length > 0) {
          this.addMsg.GoodId = chooseGoods[0].Id;
          this.addMsg.name = chooseGoods[0].Name;
          this.addMsg.Sort = chooseGoods[0].Sort;
          this.addMsg.SellingPrice = chooseGoods[0].SellingPrice;
          this.addMsg.Original_Price = chooseGoods[0].OriginalPrice;
          this.addMsg.Goods_Stock = chooseGoods[0].InventoryNum;
          this.addMsg.Goods_unit = chooseGoods[0].DefaultSpecificationName;
          this.addMsg.Goods_no = chooseGoods[0].GoodsNumbers;
          this.addMsg.Goods_weight = chooseGoods[0].GoodsWeight;
          var tempSpecArray = chooseGoods[0].SpecificationList;
          if (tempSpecArray && tempSpecArray.length > 0) {
            tempSpecArray.forEach(item => {
              item.Id = 0;
              if (item.SpecificationValueList && item.SpecificationValueList.length > 0) {
                item.SpecificationValueList.forEach(secondItem => {
                  secondItem.Id = 0;
                })
              }
            })
          }
          this.TempSpecList = JSON.parse(JSON.stringify(tempSpecArray));
          var tempPriceArray = chooseGoods[0].SpecificationPriceList;
          if (tempPriceArray && tempPriceArray.length > 0) {
            tempPriceArray.forEach(item => {
              item.Id = 0;
            });
          }
          this.TempSpecPriceList = JSON.parse(JSON.stringify(tempPriceArray));
          this.IsShowSpec = true;
        }
        this.$refs.choiceGood.toggleSelection();
      },
      //删除商品服务
      ServiceCheck(item, index) {
        this.addMsg.ServiceList.forEach((list, k) => {
          if (list.Id == item.Id) {
            this.addMsg.ServiceList.splice(k, 1);
          }
        });
      },
      //获取服务
      getService() {
        let msg = {
          pageIndex: 1,
          pageSize: 200,
          Name: "",
          IsDefault: 0
        };
        this.apipost("/api/product/GetProductServicePageList", msg, res => {
          if (res.data.resultCode == 1) {
            let pageData = res.data.data.pageData;
            this.serviceList = pageData;
          }
        });
      },
      //服务改变
      getServeChange(type) {
        if (type == 1) {
          this.addMsg.ServiceList = [];
        }
      },
      //获取运费规则
      getRule() {
        let msg1 = {
          pageIndex: 1,
          pageSize: 999,
          RulesName: ""
        };
        this.apipost("/api/MallBase/GetLogisticsRulesPage", msg1, res => {
          if (res.data.resultCode == 1) {
            let pageData = res.data.data.pageData;
            this.ruleList = pageData;
          }
        });
      },
      //点击radio
      YfSelect(val) {
        this.addMsg.FreightId = val.ID;
        this.AreaName = val.RulesName;
      },
      //选择默认表单
      getCkedForm() {
        if (this.checkedForm === '') {
          this.addMsg.FormsId = 0;
        } else {
          this.addMsg.FormsId = this.checkedForm;
        }
        this.formName = '默认表单';
        this.choosebdDig = false;
      },
      //选择图片
      SelectId(msg) {
        let that = this;
        this.addMsg.App_share_pic = that.getIconLink(msg[0].url);
        this.imgDialog = false;
      },
      //设置阶梯价格
      setNewVal(val){
  
        var tempObj=JSON.parse(JSON.stringify(val));
        this.TempGroupPriceList =tempObj ;
        this.addMsg.GroupList = tempObj;
    
      },
      //获取子组件规格
      getSpecList(val) {
        this.addMsg.SpecificationList = val;
      },
      //获取子组件规格价格列表
      getSpecPriceList(val) {
        this.addMsg.SpecificationPriceList = val;
      }
    }
  };

</script>
