<template>
  <div class="goodsListEdit">
    <div class="head-title">
      <span @click="CommonJump('goodsList')" 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-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="12">
                  <el-form-item label="商品分类">
                    <template v-if="
                        addMsg.CategoryList && addMsg.CategoryList.length > 0
                      ">
                      <el-tag type="warning" style="margin-right:10px;" @close="exitCheck(item, index)"
                        v-for="(item, index) in addMsg.CategoryList" :key="index+'1'" closable>{{ item.CategoryName }}
                      </el-tag>
                    </template>
                    <el-button type="primary" @click="
                        (flDig = true), (keepCategoryList = addMsg.CategoryList)
                      " style="margin:0 10px;" size="small">选择分类</el-button>
                    <span @click="CommonJump('addGoodsClass')" class="blue point">添加分类</span>
                  </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-tooltip class="item" effect="dark" content="只能从商城中获取商品信息，且基本信息与商城商品保持一致" placement="top"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.Id" type="number" min="1" size="small" placeholder="请输入内容"
                      class="input-with-select">
                      <el-button slot="append" @click="getcode()">获取</el-button>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="商品名称" prop="Name">
                    <el-input v-model="addMsg.Name" size="small" placeholder="请输入内容" maxlength="100" show-word-limit>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="商品副标题" >
                    <el-input v-model="addMsg.SubName" size="small" placeholder="请输入内容" maxlength="100" show-word-limit>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="供应商" prop="SupplierId">
                    <el-select class="w150" style="margin-right: 10px;" v-model="SupplierId" size="small"
                      placeholder="请选择" @change='changeSupplier'>
                      <el-option v-for="item in options" :key="item.ID" :label="item.Name" :value="item.ID">
                      </el-option>
                    </el-select>
                  </el-form-item>

                  <el-form-item label="商品轮播图(多张)">
                    <el-tooltip class="item" effect="dark" content="第一张图片为封面图" placement="top"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <p style="color:#c9c9c9;margin-bottom: 12px;">
                      第一张图片为缩略图,其它图片为轮播图,建议像素750*750,最多支持上传9张
                    </p>
                    
                      <!-- <div flex="dir:left">
                        <div v-for="(item, index) in addMsg.CarouselImageList" :key="index+'2'"
                          style="margin-right: 20px; position: relative; ">
                          <div class="colapp-image" :style="{
                              backgroundImage: 'url(' + item.Path + ')'
                            }"></div>
                          <el-button @click="ClearCarouse(index)" class="delBtn" type="danger" icon="el-icon-close"
                            circle></el-button>
                        </div>
                        <div @click="openChangeDig(1)" class="add-image-btn 2222">
                          + 添加图片
                        </div>
                      </div> -->
                      <div class="nav_Main">
                        <div class="nav_IconContent">
                          <draggable v-model="addMsg.CarouselImageList">
                            <div v-for="(item, index) in addMsg.CarouselImageList" :key="index+'2'"
                              style="margin-right: 20px; position: relative; ">
                              <div class="colapp-image" :style="{
                                  backgroundImage: 'url(' + item.Path + ')'
                                }"></div>
                              <el-button @click="ClearCarouse(index)" class="delBtn" type="danger" icon="el-icon-close"
                                circle></el-button>
                            </div>
                          </draggable>
                           
                        </div>

                       <div @click="openChangeDig(1)" v-if="addMsg.CarouselImageList.length<9" class="add-image-btn 2222">
                            + 添加图片
                          </div> 
                      </div>  
                  
                  </el-form-item>
                  <el-form-item label="商品视频">
                    <el-input v-model="addMsg.VideoAddress" size="small" placeholder="请输入内容">
                      <el-button @click="changeState1 = true" slot="append">添加视频</el-button>
                    </el-input>
                    <a v-if="addMsg.VideoAddress != ''" class="blue noline" :href="addMsg.VideoAddress"
                      target="_blank">视频链接</a>
                  </el-form-item>
                  <el-form-item label="自定义分享标题">
                    <el-tooltip class="item" effect="dark" content="分享给好友时，作为商品名称" placement="top"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.CustomShareTitles" size="small" placeholder="请输入内容"
                      class="input-with-select"></el-input>
                    <p class="blue point" @click="imgDig = true">查看图例</p>
                  </el-form-item>
                  <el-form-item class="commonLabel discount" label="自定义分享图片">
                    <el-tooltip class="item" effect="dark" content="分享给好友时，作为分享图片" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="建议尺寸420*336" placement="top">
                      <el-button @click="openChangeDig(2)" size="small">选择图片</el-button>
                    </el-tooltip>
                    <div class="app-gallery-item" style="position: relative;width: 100px;margin-top: 10px;border:none">
                      <img v-if="
                          !addMsg.CustomShareImage ||
                            addMsg.CustomShareImage == ''
                        " src="../../assets/img/default.png" style="width:80px;height:80px" alt="" />
                      <el-button @click="clearCustom" style="position: absolute;right: 6px;top: -10px;" v-if="
                          addMsg.CustomShareImage &&
                            addMsg.CustomShareImage != ''
                        " size="mini" type="danger" icon="el-icon-close" circle></el-button>
                      <img style="width:80px;height:80px" :src="addMsg.CustomShareImage" alt="" />
                    </div>
                    <p style="margin-top:-15px" class="blue f12">
                      <span class="point" @click="imgDig = true">查看图例</span>
                    </p>
                  </el-form-item>
                  <el-form-item label="直播商品">
                    <el-switch v-model="addMsg.IsLiveGoods" active-color="#409EFF" :active-value="1"
                      :inactive-value="2">
                    </el-switch>
                  </el-form-item>
                  <el-form-item label="上架状态">
                    <el-switch v-model="addMsg.GoodsStatus" active-color="#409EFF" :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 label="排序">
                    <el-tooltip class="item" effect="dark" content="排序值越小排序越靠前" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.Sort" type="number" min="1" size="small" placeholder="请输入内容"
                      class="input-with-select"></el-input>
                  </el-form-item>
                  <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 label="原价" prop="OriginalPrice">
                    <el-tooltip class="item" effect="dark" content="以划线形式显示" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.OriginalPrice" 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 label="单位" prop="Unit">
                    <el-input v-model="addMsg.Unit" size="small" placeholder="请输入内容" class="input-with-select">
                    </el-input>
                  </el-form-item>
                  <el-form-item label="成本价">
                    <el-input @change="getSuggestPrice" v-model="addMsg.CostPrice" type="number" min="1" size="small"
                      placeholder="请输入内容" class="input-with-select">
                      <el-button slot="append">元</el-button>
                    </el-input>
                    <span v-if="
                        SuggestPriceInfo.Status && SuggestPriceInfo.Status == 1
                      " class="cred" style="position: absolute;width: 400px;margin-left: 15px;">
                      建议零售价：￥{{ SuggestPriceInfo.MPrice }}
                    </span>
                  </el-form-item>
                  <!-- 判断是开启了粉象返佣 -->
                  <el-form-item label="返佣总金额" prop="Commission" v-if="FxState==1">
                    <el-input v-model="addMsg.Commission" size="small" placeholder="请输入内容" class="input-with-select">
                    <el-button slot="append">元</el-button>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="商品面议">
                    <el-tooltip class="item" effect="dark" content="如果开启面议，则商品无法在线支付" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-switch v-model="addMsg.IsGoodsNegotiable" active-color="#409EFF" :active-value="1"
                      :inactive-value="0">
                    </el-switch>
                  </el-form-item>
                  <el-form-item label="已出售量">
                    <el-tooltip class="item" effect="dark" content="前端展示的销量=实际销量+已出售量" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.SalesNum" 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 label="商品总库存" prop="InventoryNum">
                    <el-input v-model="addMsg.InventoryNum" type="number" min="1" size="small" placeholder="请输入内容"
                      class="input-with-select"></el-input>
                  </el-form-item>
                  <el-form-item label="默认规则名">
                    <el-input :disabled="SpecificationList.length > 0" v-model="addMsg.DefaultSpecificationName"
                      size="small" placeholder="请输入内容" class="input-with-select"></el-input>
                  </el-form-item>
                  <el-form-item label="商品规格">
                    <el-tooltip class="item" effect="dark" content="如有颜色、尺码等多种规格，请添加商品规格" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <div style="width:130%">
                      <div class="app-attr-group">
                        <div v-for="(item, index) in SpecificationList" :key="index+'3'" style="margin-bottom:16px;">
                          <div flex="dir:left cross:center" class="bg">
                            <span>规格名:</span>
                            <el-input @input="ggzChange" v-model="item.Name" size="mini"
                              style="width: 94px;margin: 0px 16px;"></el-input>
                            <el-checkbox @change="CheckBox" v-show="index == 0" v-model="item.EnabledImage"
                              :true-label="1" :false-label="2">规格图片</el-checkbox>
                            <div style="margin-left: auto; line-height: 1;">
                              <div @click="DeleteggModule(item, index)" class="el-image del-img">
                                <img src="../../assets/img/userman/del1.png" class="el-image__inner" />
                              </div>
                            </div>
                          </div>
                          <div flex="dir:left" style="padding: 0px 10px;margin-top: 16px;">
                            <div class="box-grow-0">规格值：</div>
                            <div flex="dir:left" style="flex-wrap: wrap;">
                              <div v-for="(item2,
                                index2) in item.SpecificationValueList" :key="index2+'4'" class="attr-list">
                                <el-input @input="ggzChange" size="mini" v-model="item2.Name" width="152px"></el-input>
                                <i @click="Deleteggz(item, index, index2)" class="el-icon-error close"></i>
                                <div v-if="index == 0 && item.EnabledImage == 1" flex="cross:center main:center"
                                  class="img-box">
                                  <div class="attr-jt"></div>
                                  <div v-if="item2.Image == ''" @click="
                                      openggImg(item, index, item2, index2)
                                    " class="app-attachment">
                                    <div style="line-height: normal; display: inline-block;">
                                      <span>+添加图片</span>
                                    </div>
                                  </div>
                                  <div v-if="item2.Image != ''" class="el-image" style="height: 88px; width: 88px;">
                                    <img :src="item2.Image" style="width:100%;height:100%" />
                                  </div>
                                  <span v-if="item2.Image != ''" @click="
                                      DeleteImageUrl(item, index, item2, index2)
                                    " class="el-icon-error close"></span>
                                  <div v-if="item2.Image != ''" style="position: absolute;">
                                    <div class="app-attachment">
                                      <el-button @click="
                                          openggImg(item, index, item2, index2)
                                        " type="primary" size="small">替换</el-button>
                                    </div>
                                  </div>
                                </div>
                              </div>
                              <div>
                                <span @click="addGgz(item, index)" class="blue f12">添加规格值</span>
                              </div>
                            </div>
                          </div>
                        </div>
                        <div v-if="SpecificationList.length < 6" flex="dir:left cross:center" class="bg">
                          <el-button @click="addggModeule" size="small">添加规格模板</el-button>
                          <el-button @click="addggxm" size="small">添加规格项目</el-button>
                          <span style="padding-left: 14px;color: rgb(201, 201, 201)">注：规格名最多添加5个</span>
                        </div>
                      </div>
                    </div>
                    <div v-show="SpecificationPriceList.length > 0" style="width: 130%; margin-top: 24px;">
                      <div class="app-attr">
                        <div class="box">
                          <!-- <el-checkbox v-model="val2">全选</el-checkbox> -->
                          <el-form-item label-width="90px" style="display:inline-block" label="批量设置">
                            <el-input style="width:100%" size="small" v-model="valpl" placeholder="请输入内容"
                              class="input-with-select">
                              <el-select style="width:120px" v-model="ggpl" slot="prepend" placeholder="请选择">
                                <el-option label="价格" :value="1"></el-option>
                                <el-option label="库存" :value="2"></el-option>
                                <el-option label="成本价" :value="5"></el-option>
                                <el-option label="重量（g）" :value="3"></el-option>
                                <el-option label="货号" :value="4"></el-option>
                                <el-option v-if="FxState==1" label="返佣总金额" :value="6"></el-option>
                              </el-select>
                              <el-button @click="ggPlSet" slot="append">确定</el-button>
                            </el-input>
                          </el-form-item>
                        </div>
                        <el-table ref="table" :data="SpecificationPriceList" border style="width: 100%"
                          @selection-change="TbaleSelectionChange">
                          <el-table-column type="selection" width="55">
                          </el-table-column>
                          <template v-for="(item, index) in SpecificationList">
                            <el-table-column :key="index+'5'" :label="item.Name">
                              <template slot-scope="scope">
                                <span v-if="index == index2" v-for="(item2, index2) in scope.row.AttrList"
                                  :key="index2+'6'">
                                  {{ scope.row.AttrList[index2].SVName }}
                                </span>
                              </template>
                            </el-table-column>
                          </template>
                          <el-table-column :render-header="renderHeader" label="价格">
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.SellingPrice" size="small"></el-input>
                            </template>
                          </el-table-column>
                          <el-table-column :render-header="renderHeader" label="库存">
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.InventoryNum" size="small"></el-input>
                            </template>
                          </el-table-column>
                          <el-table-column :render-header="renderHeader" label="成本价" width="90">
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.CostMoney" size="small"></el-input>
                            </template>
                          </el-table-column>
                          <el-table-column :render-header="renderHeader" v-if="FxState==1" width="120" label="返佣总金额">
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.Commission" size="small"></el-input>
                            </template>
                          </el-table-column>
                          <el-table-column label="重量(克)" width="90">
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.GoodsWeight" size="small"></el-input>
                            </template>
                          </el-table-column>
                          <el-table-column prop="address" label="货号">
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.GoodsNumbers" size="small"></el-input>
                            </template>
                          </el-table-column>
                        </el-table>
                      </div>
                    </div>
                  </el-form-item>
                  <el-form-item label="商品货号">
                    <el-input v-model="addMsg.GoodsNumbers" size="small" placeholder="请输入内容" class="input-with-select">
                    </el-input>
                  </el-form-item>
                  <el-form-item label="商品重量">
                    <el-input v-model="addMsg.GoodsWeight" type="number" min="1" 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="商品服务">
                    <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),
                          (keepServiceList = addMsg.ServiceList)
                      " v-if="addMsg.IsDefaultService == 2" size="mini">新增服务</el-button>
                    <el-checkbox v-model="addMsg.IsDefaultService" :true-label="1" :false-label="2">默认服务</el-checkbox>
                  </el-form-item>
                  <!-- FreightId -->
                  <el-form-item label="运费设置">
                    <el-tooltip class="item" effect="dark" content="选择第一项（默认运费）将会根据运费管理的（默认运费）变化而变化"
                      placement="top-start" style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <template v-if="addMsg.FreightName && addMsg.FreightName != ''">
                      <el-tag style="margin-right:10px;" @close="
                          (addMsg.FreightName = ''), (addMsg.FreightId = -1)
                        " closable>
                        {{ addMsg.FreightName }}</el-tag>
                    </template>
                    <el-button @click="
                        (chooseyfDig = true), (keepFreightId = addMsg.FreightId)
                      " size="mini">选择运费</el-button>
                  </el-form-item>
                  <el-form-item label="自定义表单">
                    <el-tooltip class="item" effect="dark" content="选择第一项（默认表单）将会根据表单列表的（默认表单）变化而变化"
                      placement="top-start" style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <template v-if="addMsg.FormsName && addMsg.FormsName != ''">
                      <el-tag style="margin-right:10px;" @close="(addMsg.FormsName = ''), (addMsg.FormsId = -1)"
                        closable>
                        {{ addMsg.FormsName }}</el-tag>
                    </template>
                    <el-button @click="
                        (choosebdDig = true), (keepFormsId = addMsg.FormsId)
                      " size="mini">选择表单</el-button>
                  </el-form-item>
                  <el-form-item label="限购数量">
                    <el-form-item label-width="60px" label="商品">
                      <el-input :disabled="BuyGoodsNumState" v-model="addMsg.LimitBuyGoodsNum"
                        style="width:100%;margin-left:15px" type="number" min="1" size="small" placeholder="请输入内容"
                        class="input-with-select">
                        <el-button slot="append">件</el-button>
                      </el-input>
                      <el-checkbox style="margin-left:10px" v-model="BuyGoodsNumState"
                        @change="BuyGoodsNumState==true? addMsg.LimitBuyGoodsNum=-1:addMsg.LimitBuyGoodsNum=0">不限制
                      </el-checkbox>
                    </el-form-item>
                    <el-form-item label-width="60px" label="订单">
                      <el-input :disabled="BuyOrderNumState" v-model="addMsg.LimitBuyOrderNum"
                        style="width:100%;margin-left:15px" type="number" min="1" size="small" placeholder="请输入内容"
                        class="input-with-select">
                        <el-button slot="append">单</el-button>
                      </el-input>
                      <el-checkbox style="margin-left:10px" v-model="BuyOrderNumState"
                        @change="BuyOrderNumState==true? addMsg.LimitBuyOrderNum=-1:addMsg.LimitBuyOrderNum=0">不限制
                      </el-checkbox>
                    </el-form-item>
                  </el-form-item>
                  <el-form-item label="单品满件包邮">
                    <el-tooltip class="item" effect="dark" content="如果设置0或空，则不支持满件包邮" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.FullNumPinkage" 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 label="单品满额包邮">
                    <el-tooltip class="item" effect="dark" content="如果设置0或空，则不支持满额包邮" placement="top-start"
                      style="position: absolute;left: -22px;top:12px">
                      <i class="elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.FullMoneyPinkage" 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 label="区域购买">
                    <el-switch v-model="addMsg.IsAreaBuy" active-color="#409EFF" :active-value="1" :inactive-value="0">
                    </el-switch>
                  </el-form-item>
                  <el-form-item v-if="addMsg.IsAreaBuy == 1" label="允许购买区域">
                    <span v-if="addMsg.AreaList.length == 0" @click="addOf" class="blue point">+添加地区</span>
                    <div v-if="addMsg.AreaList.length > 0" style="border: 1px solid #EBEEF5;padding:20px"
                      flex="dir:left box:last">
                      <div>
                        <div flex="dir:left" style="flex-wrap: wrap; width: 90%;">
                          <span>区域：</span>
                          <el-tag v-for="item in addMsg.AreaList" :key="item.Id" type="info" style="margin:5px">
                            {{ item.AreaName }}</el-tag>
                        </div>
                      </div>
                      <div>
                        <img @click="editQy" src="../../assets/img/userman/edit.png" alt="" />
                        <img @click="(addMsg.AreaList = []), (AreaList = [])" style="margin-left:15px"
                          src="../../assets/img/userman/del.png" alt="" />
                      </div>
                    </div>
                  </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-tooltip class="item" effect="dark" placement="top"
                      style="position: absolute;left: -10px;top:12px">
                      <div slot="content">
                        用户购物赠送的积分,
                        如果不填写或填写0，则默认为不赠送积分<br />
                        如果为百分比则为按成交价格的比例计算积分<br />
                        如: 购买2件，设置10 积分, 不管成交价格是多少，
                        则购买后获得20积分<br />
                        如: 购买2件，设置10%积分, 成交价格2 * 200= 400，
                        则购买后获得 40 积分（400*10%)<br />
                      </div>
                      <i class="el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.IntegralPresent" style="width:100%;margin-left:15px" type="number"
                      min="1" size="small" placeholder="请输入内容" class="input-with-select">
                      <el-button slot="append">
                        分
                        <el-radio v-model="addMsg.IntegralPresentType" :label="2">固定值</el-radio>
                        <el-radio v-model="addMsg.IntegralPresentType" :label="1">百分比</el-radio>
                      </el-button>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="积分抵扣">
                    <el-tooltip class="item" effect="dark" content="如果设置0，则不支持积分抵扣 如果带%则为按成交价格的比例计算抵扣多少元"
                      placement="top" style="position: absolute;left: -10px;top:12px">
                      <i class="el-tooltip el-icon-info"></i>
                    </el-tooltip>
                    <el-input v-model="addMsg.PointsDeduction" style="width:100%;margin-left:15px" type="number"
                      min="1" size="small" placeholder="请输入内容" class="input-with-select">
                      <template slot="prepend">最多抵扣</template>
                      <el-button slot="append">
                        元
                        <el-radio v-model="addMsg.PointsDeductionType" :label="2">固定值</el-radio>
                        <el-radio v-model="addMsg.PointsDeductionType" :label="1">百分比</el-radio>
                      </el-button>
                    </el-input>
                  </el-form-item>
                  <el-form-item label-width="110px">
                    <el-checkbox v-model="addMsg.IsMultipleDeduction" :true-label="1" :false-label="2">允许多件抵扣
                    </el-checkbox>
                  </el-form-item>
                  <el-form-item  label="商品赠送VIP" v-if="FxState==1">
                     <el-select  class="w150" style="margin-left:15px" v-model="addMsg.PresentFXGrade" size="small" clearable 
                      placeholder="请选择" @change='changeVIP'>
                      <el-option v-for="item in FXlevelList" :key="item.Id" :label="item.GradeName" :value="item.Id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item  label="赠送日期" v-if="FxState==1 && giveDate==true">
                    <el-input v-model="addMsg.PresentFXMonth" style="width:100%;margin-left:15px" 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 label="广告词">
                 
                    <el-input v-model="addMsg.Advertising" style="width:100%;margin-left:15px" type="textarea" :rows="3"
                     size="small" placeholder="请输入内容" class="input-with-select"></el-input>
                  </el-form-item>
                  <el-form-item label="标签类型">
                    <el-radio v-model="addMsg.MarketingLogo.iswords" :label="1">文字模式</el-radio>
                     <el-radio v-model="addMsg.MarketingLogo.iswords" :label="2">图片模式</el-radio>
                     <el-radio v-model="addMsg.MarketingLogo.iswords" :label="0">无模式</el-radio>
                  </el-form-item>
                   <el-form-item label="标签文字" v-if="addMsg.MarketingLogo.iswords==1" >
                      <el-input v-model="addMsg.MarketingLogo.words" style="width:100%;margin-left:15px" 
                     size="small" placeholder="请输入内容" class="input-with-select" maxlength='10' show-word-limit></el-input>
                  </el-form-item>
                  <el-form-item label="标签字体颜色"  v-if="addMsg.MarketingLogo.iswords==1">
                    <el-color-picker
                    style="width:100%;margin-left:15px"
                      v-model="addMsg.MarketingLogo.wordsColor"
                      show-alpha
                      :predefine="predefineColors">
                    </el-color-picker>
                  </el-form-item>
                   <el-form-item label="标签背景颜色"  v-if="addMsg.MarketingLogo.iswords==1">
                    <el-color-picker
                    style="width:100%;margin-left:15px"
                      v-model="addMsg.MarketingLogo.wordsBack"
                      show-alpha
                      :predefine="predefineColors">
                    </el-color-picker>
                  </el-form-item>
                  <el-form-item class="commonLabel discount" label="标签图片"  v-if="addMsg.MarketingLogo.iswords==2">
                    <el-tooltip class="item" effect="dark" content="建议尺寸" placement="top">
                      <el-button @click="openChangeDig(4)" size="small">选择图片</el-button>
                    </el-tooltip>
                    <div class="app-gallery-item" style="position: relative;width: 100px;margin-top: 10px;border:none">
                      <img v-if="
                          !addMsg.MarketingLogo.ico ||
                            addMsg.MarketingLogo.ico == ''
                        " src="../../assets/img/default.png" style="width:80px;height:80px" alt="" />
                      <el-button @click="addMsg.MarketingLogo.ico = ''" style="position: absolute;right: 6px;top: -10px;" v-if="
                          addMsg.MarketingLogo.ico &&
                            addMsg.MarketingLogo.ico != ''
                        " size="mini" type="danger" icon="el-icon-close" circle></el-button>
                      <img style="width:80px;height:80px" :src="addMsg.MarketingLogo.ico" alt="" />
                    </div>
                  </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="242">
                  <UE style="width:750px;" :defaultMsg="defaultMsg" :config="config" :IsMultiple="true" ref="ue"></UE>
                </el-col>
              </el-row>
            </el-card>
          </el-tab-pane>
          <el-tab-pane label="分销价设置" name="second">
            <el-form-item label="是否开启单独分销">
              <el-switch @change="HpChange" v-model="addMsg.SeparateDistribution" active-color="#409EFF"
                :active-value="1" :inactive-value="0">
              </el-switch>
            </el-form-item>
            <template v-if="addMsg.SeparateDistribution == 1">
              <el-form-item label="分销类型">
                <el-radio v-model="addMsg.SeparateDistributionType" :label="1">普通设置</el-radio>
                <el-radio @change="butionType" v-model="addMsg.SeparateDistributionType" :label="2">详细设置</el-radio>
              </el-form-item>
              <el-form-item label="分销佣金类型">
                <el-radio v-model="addMsg.SeparateDistributionMoneyType" :label="2">固定金额</el-radio>
                <el-radio v-model="addMsg.SeparateDistributionMoneyType" :label="1">百分比</el-radio>
              </el-form-item>
              <el-form-item class="111">
                <div v-if="addMsg.SeparateDistributionType == 1" class="app-attr">
                  <div class="box">
                    <el-form-item label-width="90px" style="display:inline-block" label="批量设置">
                      <el-select style="width:130px" v-model="pusetVal" size="small">
                        <el-option v-for="(item, index) in butorInt" :label="`${index + 1}级分销`" :value="index + 1"
                          :key="index+'8'"></el-option>
                      </el-select>
                      <el-input style="width:150px;position:relative;top:5px" size="small" v-model="ptinput"
                        placeholder="请输入内容">
                        <el-button slot="append">
                          <span v-if="addMsg.SeparateDistributionMoneyType == 2">元</span>
                          <span v-if="addMsg.SeparateDistributionMoneyType == 1">%</span>
                        </el-button>
                      </el-input>
                      <el-button @click="PuSet" style="position:relative;" size="small" type="primary">设置</el-button>
                    </el-form-item>
                  </div>
                  <el-table ref="table" :data="GradeCommissionList" border style="width: 100%"
                    @selection-change="TbaleSelectionChange2">
                    <el-table-column type="selection" width="55">
                    </el-table-column>
                    <el-table-column width="100" label="等级名称">
                      <template slot-scope="scope">
                        <template v-for="(item2, index) in DropdownList">
                          <span :key="index+'9'" v-if="scope.row.DistributorGrade == item2.Id">{{ item2.Name }}</span>
                        </template>
                      </template>
                    </el-table-column>
                    <template v-for="(item, index) in butorIntList">
                      <el-table-column :key="index+'10'" :label="item.Name">
                        <template slot-scope="scope">
                          <span>
                            <el-input v-model="scope.row.OneCommission" v-if="index == 0" size="small">
                              <el-button slot="append">
                                <span v-if="
                                    addMsg.SeparateDistributionMoneyType == 2
                                  ">元</span>
                                <span v-if="
                                    addMsg.SeparateDistributionMoneyType == 1
                                  ">%</span>
                              </el-button>
                            </el-input>
                            <el-input v-model="scope.row.TwoCommission" v-if="index == 1" size="small">
                              <el-button slot="append">
                                <span v-if="
                                    addMsg.SeparateDistributionMoneyType == 2
                                  ">元</span>
                                <span v-if="
                                    addMsg.SeparateDistributionMoneyType == 1
                                  ">%</span>
                              </el-button>
                            </el-input>
                            <el-input v-model="scope.row.ThreeCommission" v-if="index == 2" size="small">
                              <el-button slot="append">
                                <span v-if="
                                    addMsg.SeparateDistributionMoneyType == 2
                                  ">元</span>
                                <span v-if="
                                    addMsg.SeparateDistributionMoneyType == 1
                                  ">%</span>
                              </el-button>
                            </el-input>
                          </span>
                        </template>
                      </el-table-column>
                    </template>
                  </el-table>
                </div>
              </el-form-item>
              <el-form-item class="222">
                <div v-if="addMsg.SeparateDistributionType == 2" class="app-attr">
                  <div class="box">
                    <el-form-item label-width="90px" style="display:inline-block" label="批量设置">
                      <el-select style="width:130px" v-model="gradeVal" size="small">
                        <el-option v-for="(item, index) in DropdownList" :label="item.Name" :value="item.Grade"
                          :key="index+'11'"></el-option>
                      </el-select>
                      <el-select style="width:130px" v-model="fxVal" size="small">
                        <el-option v-for="(item, index) in butorInt" :label="`${index + 1}级分销`" :value="index + 1"
                          :key="index+'12'"></el-option>
                      </el-select>
                      <el-input style="width:150px;position:relative;top:5px" size="small" v-model="xxVal"
                        placeholder="请输入内容">
                        <el-button slot="append">
                          <span v-if="addMsg.SeparateDistributionMoneyType == 2">元</span>
                          <span v-if="addMsg.SeparateDistributionMoneyType == 1">%</span>
                        </el-button>
                      </el-input>
                      <el-button @click="xxSet" style="position:relative;" size="small" type="primary">设置</el-button>
                    </el-form-item>
                  </div>
                  <el-table ref="table" :data="disList2.length>0?disList2:[]" border style="width: 100%"
                    @selection-change="TbaleSelectionChange3">
                    <template v-for="(item, index) in SpecificationList">
                      <el-table-column :key="index+'13'" :label="item.Name" width="100">
                        <template slot-scope="scope">
                          <span v-if="index == index2" v-for="(item2, index2) in scope.row.AttrList" :key="index2+'14'">
                            {{ scope.row.AttrList[index2].SVName }}
                          </span>
                        </template>
                      </el-table-column>
                    </template>
                    <template v-for="(item, index3) in DropdownList">
                      <el-table-column :key="index3" :label="item.Name">
                        <el-table-column width="100" v-if="butorInt > 0" label="一级分销">
                          <template slot-scope="scope">
                            <el-input v-model="
                                scope.row.GradeCommissionList[index3]
                                  .OneCommission
                              " size="small">
                            </el-input>
                          </template>
                        </el-table-column>
                        <el-table-column width="100" v-if="butorInt > 1" label="二级分销">
                          <template slot-scope="scope">
                            <el-input v-model="
                                scope.row.GradeCommissionList[index3]
                                  .TwoCommission
                              " size="small">
                            </el-input>
                          </template>
                        </el-table-column>
                        <el-table-column width="100" v-if="butorInt > 2" label="三级分销">
                          <template slot-scope="scope">
                            <el-input v-model="
                                scope.row.GradeCommissionList[index3]
                                  .ThreeCommission
                              " size="small">
                            </el-input>
                          </template>
                        </el-table-column>
                      </el-table-column>
                    </template>
                    <el-table-column type="selection" :fixed="true" width="55">
                    </el-table-column>
                  </el-table>
                </div>
              </el-form-item>
            </template>
            <template v-if="hpState==1">
              <table class="fen-table">
                <thead>
                  <tr>
                    <th>结算对象</th>
                    <th>结算成本(毛利)</th>
                    <th>预计返佣金额</th>
                  </tr>
                </thead>
                <tbody>
                  <tr v-for="(x, i) in shareSettings" :key="i">
                    <td>{{x.GradeName}}</td>
                    <td>{{x.cb}}（{{x.CommissionRatio}}%）</td>
                    <td>{{x.commission}}</td>
                  </tr>
                </tbody>
              </table>
              <div class="fen-sumg">
                <span style="margin-right:30px">直客卖价：{{addMsg.SellingPrice}}</span>
                <span style="margin-right:30px">成本：{{addMsg.CostPrice}}</span>
                <span style="margin-right:30px;color:red;">预计公司利润：{{companyCommission}}</span>
              </div>
            </template>
          </el-tab-pane>
          <el-tab-pane label="会员价设置" name="third">
            <el-form-item label="是否享受会员功能">
              <el-switch v-model="addMsg.EnjoyMember" active-color="#409EFF" :active-value="1" :inactive-value="0">
              </el-switch>
            </el-form-item>
            <el-form-item label="是否单独设置会员价">
              <el-switch v-model="addMsg.SeparateSetMember" active-color="#409EFF" :active-value="1"
                :inactive-value="0">
              </el-switch>
            </el-form-item>
            <el-form-item v-if="addMsg.SeparateSetMember == 1 && huiyList.length == 0" label="会员价设置">
              <el-button @click="CommonJump('setMember')" size="small" type="danger">如需设置请先添加会员</el-button>
            </el-form-item>
            <el-form-item v-if="
                addMsg.SeparateSetMember == 1 &&
                  SpecificationPriceList.length == 0
              " label="默认规格会员价设置">
              <div v-for="(item, index) in memberList1[0].GradePriceList" :key="index+'15'">
                <el-input style="width:700px" placeholder="请输入内容" v-model="item.MemberPrice" size="small"
                  class="input-with-select">
                  <el-button slot="prepend">{{ item.Name }}</el-button>
                  <el-button slot="append">元</el-button>
                </el-input>
              </div>
              <el-tag type="danger">如需设置多规格会员价,请先添加商品规格</el-tag>
            </el-form-item>
            <el-form-item v-if="
                addMsg.SeparateSetMember == 1 &&
                  SpecificationPriceList.length > 0
              " label="会员价设置">
              <div class="app-attr">
                <div class="box">
                  <el-form-item style="display:inline-block">
                    <el-input style="width:500px;position:relative;top:5px" size="small" v-model="memberinput"
                      placeholder="请输入内容">
                      <el-select slot="prepend" style="width:130px" v-model="memberVal" size="small">
                        <el-option v-for="(item, index) in huiyList" :label="item.Name" :value="item.Grade"
                          :key="index">
                        </el-option>
                      </el-select>
                      <el-button @click="HySet" slot="append">确定</el-button>
                    </el-input>
                  </el-form-item>
                </div>
                <el-table ref="table" :data="memberList2" border style="width: 100%"
                  @selection-change="TbaleSelectionChange4">
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <template v-for="(item, index) in SpecificationList">
                    <el-table-column :key="index+'16'" :label="item.Name" width="100">
                      <template slot-scope="scope">
                        <span v-if="index == index2" v-for="(item2, index2) in scope.row.AttrList" :key="index2+'17'">
                          {{ scope.row.AttrList[index2].SVName }}
                        </span>
                      </template>
                    </el-table-column>
                  </template>
                  <template v-for="(item, index) in huiyList">
                    <el-table-column :key="index+'18'" :label="item.Name">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.GradePriceList[index].MemberPrice" size="small"></el-input>
                      </template>
                    </el-table-column>
                  </template>
                </el-table>
              </div>
            </el-form-item>
          </el-tab-pane>
        </el-tabs>
      </el-form>
      <div class="bottom-div" style="margin-top:20px">
        <el-button size="small" type="primary" @click="Save('addMsg')">保存</el-button>
        <!-- <el-button size="small">预览</el-button> -->
      </div>
    </div>
    <!-- 选择分类 -->
    <el-dialog custom-class="app-add-cat" title="选择分类" :visible.sync="flDig" width="1100px">
      <el-row>
        <el-col :span="8" style="padding:0 10px;box-sizing:border-box">
          <h3 style="padding:15px 0">一级分类</h3>
          <div class="app-goods-cat-list active">
            <el-checkbox-group v-model="NewCategoryList" @change="handleCheckChange">
              <div v-for="(item, index) in fenleiData" :key="index+'19'" flex="dir:left box:first" class="cat-item">
                <el-checkbox :label="item.Id">
                  <span style="display: none;">{{ item.Name }}</span>
                </el-checkbox>
                <div flex="box:last cross:center">
                  <span>{{ item.Name }}</span>
                  <i v-if="item.ChildList.length > 0" @click="getChild2(item.ChildList)"
                    class="el-icon-arrow-right"></i>
                </div>
              </div>
            </el-checkbox-group>
          </div>
        </el-col>
        <el-col v-show="childList2.length > 0" :span="8" style="padding:0 10px;box-sizing:border-box">
          <h3 style="padding:15px 0">二级分类</h3>
          <div class="app-goods-cat-list active">
            <el-checkbox-group v-model="NewCategoryList" @change="handleCheckChange">
              <div v-for="(item, index) in childList2" :key="index+'20'" flex="dir:left box:first" class="cat-item">
                <el-checkbox :label="item.Id">
                  <span style="display: none;">{{ item.Name }}</span>
                </el-checkbox>
                <div flex="box:last cross:center">
                  <span>{{ item.Name }}</span>
                  <i v-if="item.ChildList.length > 0" @click="getChild3(item.ChildList)"
                    class="el-icon-arrow-right"></i>
                </div>
              </div>
            </el-checkbox-group>
          </div>
        </el-col>
        <el-col v-show="childList3.length > 0" :span="8" style="padding:0 10px;box-sizing:border-box">
          <h3 style="padding:15px 0">三级分类</h3>
          <div class="app-goods-cat-list active">
            <el-checkbox-group v-model="NewCategoryList" @change="handleCheckChange">
              <div v-for="(item, index) in childList3" :key="index+'21'" flex="dir:left box:first" class="cat-item">
                <el-checkbox :label="item.Id">
                  <span style="display: none;">{{ item.Name }}</span>
                </el-checkbox>
                <div flex="box:last cross:center">
                  <span>{{ item.Name }}</span>
                  <i class="el-icon-arrow-right"></i>
                </div>
              </div>
            </el-checkbox-group>
          </div>
        </el-col>
      </el-row>
      <div class="tag-box">
        <el-tag @close="exitCheck(item)" v-for="(item, index) in addMsg.CategoryList" :key="index+'22'" type="warning"
          closable style="margin-right:5px">{{ item.Name }}</el-tag>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="
            (flDig = false),
              (addMsg.CategoryList = keepCategoryList),
              ExitCateList()
          ">取 消</el-button>
        <el-button @click="(flDig = false), getSuggestPrice()" size="small" type="primary">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 查看图例 -->
    <el-dialog title="查看自定义分享图片图例" :visible.sync="imgDig" width="30%">
      <div class="center">
        <img style=" width: 310px;height: 360px;" src="../../assets/img/userman/app-share-name.png" alt="" />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="imgDig = false" size="small" type="primary">我知道了</el-button>
      </span>
    </el-dialog>
    <!-- 选择图片 -->
    <el-dialog title="选择文件" :visible.sync="changeState" width="1240px">
      <ChooseImg @SelectId="SelectId" :IsMultiple="true"></ChooseImg>
    </el-dialog>
    <!-- 选择视频 -->
    <el-dialog title="选择文件" :visible.sync="changeState1" width="1240px">
      <Choosevideo @Selectvideo="Selectvideo"></Choosevideo>
    </el-dialog>
    <!-- 选择商品服务 -->
    <el-dialog title="选择商品服务" :visible.sync="serviceDig" width="30%">
      <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="(addMsg.ServiceList = keepServiceList),(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="30%">
      <div>
        <el-radio-group v-model="val">
          <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), (addMsg.FreightId = keepFreightId)">取 消</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="val1">
          <el-radio @change="YfSelect1" style="padding-bottom:10px" class="yfradio" :label="{ Name: '默认运费', Id: 0 }">
            默认表单
          </el-radio>
        </el-radio-group>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="(choosebdDig = false), (addMsg.FormsId = keepFormsId)">取 消</el-button>
        <el-button size="small" @click="choosebdDig = false" type="primary">确 定</el-button>
      </span>
    </el-dialog>
    <!--区域-->
    <el-dialog custom-class="regionDig" title="区域" :visible.sync="dialogFormVisible">
      <region_Choice @event1="change($event)" :List="AreaList" ref="child"></region_Choice>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="Addto">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 选择规格模板 -->
    <el-dialog custom-class="speciDig" title="选择规格模板" :visible.sync="speciDig" width="680px">
      <div flex="dir:left">
        <div class="tpl-box">
          <div class="tpl-head">规格名选择</div>
          <div class="tpl-scrollbar el-scrollbar">
            <el-checkbox @change="(speciDigActive = index), changeCheckAll(item, index)"
              v-for="(item, index) in speciList" v-model="item.checkAll" :key="index">{{ item.Name }}</el-checkbox>
          </div>
        </div>
        <div class="tpl-box" style="margin-left:10px">
          <div class="tpl-head">规格值选择</div>
          <div class="tpl-scrollbar el-scrollbar">
            <el-checkbox-group v-model="item.SpecificationValueList" @change="changeSpeciList(item, index)"
              v-for="(item, index) in speciList" :key="index">
              <span v-if="speciDigActive == index">
                <el-checkbox style="padding-left:10px" v-for="(item2, index1) in item.NewSpecList" :label="item2"
                  :key="index1">{{ item2.Name }}</el-checkbox>
              </span>
            </el-checkbox-group>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="chooseSpecificationValueList">确定选择</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import ChooseImg from "@/components/global/ChooseImg.vue";
  import Choosevideo from "@/components/global/Choosevideo.vue";
  import region_Choice from "@/components/setup/view/regionChoice";
  import UE from "@/components/global/UE.vue";
  import draggable from "vuedraggable"
  export default {
    components: {
      ChooseImg,
      Choosevideo,
      region_Choice,
      UE,
      draggable
    },
    data() {
      return {
        ComTreeList: [],
        thisType: 0,
        tableData: [],
        SpecificationList: [],
        SpecificationPriceList: [],
        speciDigActive: -1,
        newSpecificationValueList: [],
        SpecificationValueList: [],
        speciDig: false,
        speciList: [],
        val2: "",
        defaultMsg: "",
        config: {
          initialFrameWidth: null,
          initialFrameHeight: 350
        },
        dialogFormVisible: false,
        choosebdDig: false,
        chooseyfDig: false,
        serviceDig: false,
        changeState1: false,
        changeState: false,
        BuyGoodsNumState: true,
        BuyOrderNumState: true,
        imgDig: false,
        activeName: "first",
        flDig: false,
        addMsg: {
          Id: 0,
          CategoryList: [],
          Name: "",
          CarouselImageList: [],
          VideoAddress: "",
          CustomShareTitles: "",
          CustomShareImage: "",
          CustomShareImagePath: "",
          IsLiveGoods:2, //直播商品
          GoodsStatus: 0,
          InventoryNum: 0,
          DefaultSpecificationName: "",
          SpecificationList: [],
          SpecificationPriceList: [],
          SellingPrice: 0,
          OriginalPrice: 0,
          Unit: "件",
          CostPrice: 0,
          IsGoodsNegotiable: 2,
          SalesNum: 0,
          GoodsNumbers: "",
          IsCustomSpecification: 2,
          GoodsWeight: "",
          IsDefaultService: 1,
          ServiceList: [],
          FreightId: -1,
          FreightName: "",
          FormsId: -1,
          FormsName: "",
          LimitBuyGoodsNum: -1,
          LimitBuyOrderNum: -1,
          IsAreaBuy: 2,
          AreaList: [],
          IntegralPresent: 0,
          IntegralPresentType: 2,
          PointsDeduction: 0,
          PointsDeductionType: 2,
          IsMultipleDeduction: 2,
          GoodsDetails: "",
          SeparateDistribution: 2,
          SeparateDistributionType: 1,
          SeparateDistributionMoneyType: 2,  //默认显示固定金额
          EnjoyMember: 1,
          SeparateSetMember: 2,
          IsQuickBuy: 1,
          FullNumPinkage: 0,
          FullMoneyPinkage: 0,
          SupplierId: '',
          Sort: 0,
          Commission:0,
          PresentFXGrade:'',
          PresentFXMonth:0,
          Advertising:'',
          SubName:'',
          MarketingLogo:{iswords:0,words:"",wordsColor:"",wordsBack:"",ico:""}
        },
        predefineColors: [
          '#000000',
          '#FFFFFF',
          '#888888',
          '#FF4544',
        ],
        SupplierId: '',
        fenleiData: [],
        checkList: [],
        childList2: [],
        childList3: [],
        keepCategoryList: [],
        rules: {
          CategoryIdNew: [{
            required: true,
            message: "分类不能为空",
            trigger: "change"
          }],
          Name: [{
            required: true,
            message: "请输入商品名称",
            trigger: "blur"
          }],
          InventoryNum: [{
            required: true,
            message: "请输入商品总库存",
            trigger: "blur"
          }],
          SellingPrice: [{
            required: true,
            message: "请输入商品售价",
            trigger: "blur"
          }],
          OriginalPrice: [{
            required: true,
            message: "请输入商品原价",
            trigger: "blur"
          }],
          Unit: [{
            required: true,
            message: "请输入商品单位",
            trigger: "blur"
          }],
          Commission: [{
            required: true,
            message: "返佣总金额",
            trigger: "blur"
          }]
        },
        imgType: 1,
        serviceList: [],
        checkService: [],
        keepServiceList: [],
        keepFreightId: -1,
        ruleList: [],
        val: {},
        val1: {},
        keepFormsId: -1,
        AreaList: [],
        skuList: [],
        GoodsId: "",
        butorInt: 0,
        butorIntList: [],
        DropdownList: [],
        DistributionCommissionTreeList: [],
        disList1: [{
          SpecificationSort: "",
          GradeCommissionList: []
        }],
        disList2: [],
        GradeCommissionList: [],
        ggpl: "",
        ggplList: [],
        valpl: "",
        pusetVal: "",
        pusetList: [],
        ptinput: "",

        fxVal: "",
        gradeVal: "",
        xxVal: "",
        xxList: [],
        huiyList: [],
        memberList1: [{
          Id: 0,
          SpecificationSort: "",
          GradePriceList: []
        }],
        memberList2: [],
        memberinput: "",
        memberVal: "",
        memberCheck: [],
        imgListIndex1: 0,
        imgListIndex2: 0,
        NewCategoryList: [],
        hpState: 0,
        FxState:0,
        SuggestPriceInfo: {},
        shareSettings: [],
        companyCommission: 0,
        options: [],
        FXlevelList:[],
        giveDate:false,
      };
    },
    created() {
      if (this.$route.query.hpState) {
        this.hpState = this.$route.query.hpState;
      }
      if (this.$route.query.FxState) {
        this.FxState = this.$route.query.FxState;
      }

      this.getTree();
      this.getService();
      this.getRule();
      this.getSpeciList();
      this.getDistributor();
      this.gethuiyList();
      this.getSupplierList()
      this.getFXDGradeList()
    },
    mounted() {
      this.$refs.ue.loadUe();
      if (this.$route.query.GoodsId) {
        this.GoodsId = this.$route.query.GoodsId;
        this.getData();
      }
    },
    methods: {
      initShareSettings() {
        let arr = [];
        this.addMsg.CategoryList.forEach(item => {
          item.Name = item.CategoryName;
          arr.push(item.CategoryId);
        });
        let CategoryIds = arr.join(",");
        this.apipost(
          "/api/user/GetHpDistributorGoodsInfo", {
            CategoryIds: CategoryIds,
            CostPrice: "10"
          },
          res => {
            if (res.data.resultCode == 1) {
              this.shareSettings = res.data.data.RatioList || []
              this.calcCommission(0)
            }
          }
        );
      },
      calcCommission(t) {
        if (t == 0) {
          let maxratio = 0
          let minratio = 100
          if (this.shareSettings.length > 0) {
            this.shareSettings.forEach(x => {
              if (x.CommissionRatio > maxratio) {
                maxratio = x.CommissionRatio
              }
            })
          }
          if (this.shareSettings.length > 0) {
            this.shareSettings.forEach(x => {
              x.cb = parseFloat(this.addMsg.CostPrice) / (1.00 - (parseFloat(x.CommissionRatio) / 100.00))
              x.commission = (this.addMsg.SellingPrice - x.cb).toFixed(2)
              x.cb = x.cb.toFixed(2)
              if (x.CommissionRatio < minratio) {
                this.companyCommission = (this.addMsg.SellingPrice - (parseFloat(x.commission) + parseFloat(this
                  .addMsg.CostPrice))).toFixed(2)
                minratio = x.CommissionRatio
              }
            })
          }
        }
      },
      HpChange() {
        if(this.FxState==1){
          this.Error("已开启粉象分销，请在粉象分销里面配置！");
          this.addMsg.SeparateDistribution = 0;
        } else if(this.hpState == 1){
          this.Error("已开启和平分销，请在和平分销里面配置！");
          this.addMsg.SeparateDistribution = 0;
        }
      },
      //
      HySet() {
        this.memberList2.forEach(item => {
          this.memberCheck.forEach(check => {
            if (item.Id == check.Id) {
              item.GradePriceList.forEach(list1 => {
                if (list1.MemberGrade == this.memberVal) {
                  list1.MemberPrice = this.memberinput;
                }
              });
            }
          });
        });
      },
      TbaleSelectionChange4(val) {
        this.memberCheck = val;
      },
      gethuiyList() {
        let msg = {
          Grade: 0,
          Name: "",
          Enabled: 1
        };
        this.apipost("/api/user/GetMemberGradeList", msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            let pageData = res.data.data;
            this.huiyList = pageData;
            this.huiyList.forEach(item => {
              let obj = {
                Name: item.Name,
                MemberGrade: item.Grade,
                MemberPrice: 0
              };
              this.memberList1[0].GradePriceList.push(obj);
            });
          }
        });
      },
      TbaleSelectionChange3(val) {
        this.xxList = val;
      },
      xxSet() {
        if (this.gradeVal === "") {
          this.Error("请选择等级！");
          return;
        }
        if (this.fxVal === "") {
          this.Error("请选择层级！");
          return;
        }
        this.disList2.forEach(item => {
          item.GradeCommissionList.forEach((grade, index) => {
            this.xxList.forEach(list => {
              if (item.Id == list.Id) {
                if (index == this.gradeVal) {
                  if (this.fxVal == 1) {
                    grade.OneCommission = this.xxVal;
                  }
                  if (this.fxVal == 2) {
                    grade.TwoCommission = this.xxVal;
                  }
                  if (this.fxVal == 3) {
                    grade.ThreeCommission = this.xxVal;
                  }
                }
              }
            });
          });
        });
      },
      PuSet() {
        this.GradeCommissionList.forEach(item => {
          this.pusetList.forEach(list => {
            if (item.DistributorGrade == list.DistributorGrade) {
              if (this.pusetVal == 1) {
                item.OneCommission = this.ptinput;
              }
              if (this.pusetVal == 2) {
                item.TwoCommission = this.ptinput;
              }
              if (this.pusetVal == 3) {
                item.ThreeCommission = this.ptinput;
              }
            }
          });
        });
      },
      TbaleSelectionChange2(val) {
        this.pusetList = val;
      },
      ggPlSet() {
        if (this.ggplList.length == 0) {
          this.Error("至少选择一项！");
          return;
        }
        this.SpecificationPriceList.forEach(item => {
          this.ggplList.forEach(list => {
            if (item.Id == list.Id) {
              if (this.ggpl == 1) {
                item.SellingPrice = this.valpl;
              }
              if (this.ggpl == 2) {
                item.InventoryNum = this.valpl;
              }
              if (this.ggpl == 3) {
                item.GoodsWeight = this.valpl;
              }
              if (this.ggpl == 4) {
                item.GoodsNumbers = this.valpl;
              }
              if(this.ggpl == 5){
                item.CostMoney = this.valpl;
              }
              if(this.ggpl == 6){
                item.Commission = this.valpl;
              }
            }
          });
        });
      },
      TbaleSelectionChange(val) {
        this.ggplList = val;
      },
      renderHeader(h, {
        column
      }) {
        // h即为cerateElement的简写，具体可看vue官方文档
        return h("div", [
          h("span", column.label),
          h("i", {
            class: "iconfont icon-xinghao1",
            style: "color:#F56C6C;float:left"
          })
        ]);
      },
      CheckBox(val) {},
      butionType(val) {},
      // 删除规格模板
      DeleteggModule(item, index) {
        this.ComTreeList = [];
        this.memberList2 = [];
        this.SpecificationList.splice(index, 1);
        if (this.SpecificationList.length == 0) {
          this.addMsg.SeparateDistributionType = 1;
        }
        this.$forceUpdate();
        this.skuList = [];
        this.getSkuData([], 0, this.SpecificationList);
      },
      // 删除规格值
      Deleteggz(item, index, index2) {
        this.SpecificationList[index].SpecificationValueList.splice(index2, 1);
        this.$forceUpdate();
        if (this.SpecificationList[index].SpecificationValueList.length == 0) {
          this.SpecificationList.splice(index, 1);
        }
        this.skuList = [];
        this.getSkuData([], 0, this.SpecificationList);
      },
      // 全选
      changeCheckAll(item, index) {
        if (item.checkAll) {
          this.speciList[index].SpecificationValueList = item.NewSpecList;
        } else {
          this.speciList[index].SpecificationValueList = [];
        }
        this.$forceUpdate();
      },
      changeSpeciList(val, index) {
        this.$forceUpdate();
      },
      // 添加规格模板
      addggxm() {
        let that = this;
        let obj = {
          Name: "",
          SpecificationValueList: [],
          Sort: that.SpecificationList.length + 1,
          Id: 0,
          EnabledImage: 2
        };
        this.SpecificationList.push(obj);
      },
      // 添加规格值
      addGgz(item, index) {
        let obj = {
          Id: 0,
          Image: "",
          Name: "",
          Sort: item.SpecificationValueList.length + 1
        };
        this.SpecificationList[index].SpecificationValueList.push(obj);
      },
      // 修改规格值
      ggzChange() {
        this.$forceUpdate();
        this.ComTreeList = [];
        this.memberList2 = [];
        this.skuList = [];
        this.getSkuData([], 0, this.SpecificationList);
      },
      // 值
      ggzChange2() {
        // this.$forceUpdate();
        // this.skuList = [];
        // this.getSkuData([], 0, this.SpecificationValueList.);
      },
      chooseSpecificationValueList() {
        if (!this.SpecificationList) {
          this.SpecificationList = [];
        }
        let arr = [];
        this.speciList.forEach(item => {
          if (item.checkAll) {
            arr.push(item);
          }
        });
        this.SpecificationList = JSON.parse(
          JSON.stringify(this.SpecificationList.concat(arr))
        );
        this.SpecificationList.forEach((item, index) => {
          item.EnabledImage = 2;
          item.Sort = index;
          item.SpecificationValueList.forEach((list, index2) => {
            list.Image = "";
            list.Sort = index2;
          });
        });
        this.ComTreeList = [];
        this.memberList2 = []
        this.skuList = [];
        this.getSkuData([], 0, this.SpecificationList);
        this.speciDig = false;
      },
      getSkuData(skuArr = [], i, list) {
        const testyunx = (skuArr = [], i, list) => {
          if (list[i]) {
            for (let j = 0; j < list[i].SpecificationValueList.length; j++) {
              skuArr[i] = {};
              if (i < list.length - 1) {
                skuArr[i].SName = list[i].Name;
                skuArr[i].SVName = list[i].SpecificationValueList[j].Name;
                skuArr[i].SVId = list[i].SpecificationValueList[j].Sort;
                testyunx(skuArr, i + 1, list); // 递归循环
              } else {
                skuArr[i].SName = list[i].Name;
                skuArr[i].SVName = list[i].SpecificationValueList[j].Name;
                skuArr[i].SVId = list[i].SpecificationValueList[j].Sort;
                this.skuList.push([...skuArr]); // 扩展运算符，连接两个数组
              }
            }
          }
        }
        testyunx(skuArr, i, list)
        this.calcList(this.skuList, this.SpecificationList);
      },
      calcList(list, calist) {
        let oldArr = JSON.parse(JSON.stringify(this.SpecificationPriceList))
        this.SpecificationPriceList = [];
        let arrList = [];
        list.forEach(item => {
          item.AttrList = [];
          item.SpecificationSort = "";
          item.forEach((item2, index2) => {
            let obj = {
              SName: item2.SName,
              SVName: item2.SVName,
              SVId: item2.SVId
            };
            let str = ":";
            if (index2 == item.length - 1) {
              str = "";
            }
            item.SpecificationSort += item2.SVId + str;
            item.GoodsNumbers = "";
            item.GoodsWeight = 0;
            item.InventoryNum = 0;
            item.SellingPrice = 0;
            item.CostMoney = 0;
            item.Commission = 0;
            item.AttrList.push(obj);
          });
        });
        list.forEach((item, i) => {
          let obj = {};
          obj = {
            isNoExite: true,
            AttrList: item.AttrList,
            SpecificationSort: item.SpecificationSort,
            GoodsNumbers: item.GoodsNumbers,
            GoodsWeight: item.GoodsWeight,
            InventoryNum: item.InventoryNum,
            SellingPrice: item.SellingPrice,
            CostMoney: item.CostMoney,
            Commission: item.Commission
          };
          oldArr.forEach(val => {
            if (val.SpecificationSort == item.SpecificationSort) {
              obj = {
                isNoExite: false,
                AttrList: item.AttrList,
                SpecificationSort: val.SpecificationSort,
                GoodsNumbers: val.GoodsNumbers,
                GoodsWeight: val.GoodsWeight,
                InventoryNum: val.InventoryNum,
                SellingPrice: val.SellingPrice,
                CostMoney: val.CostMoney,
                Commission: val.Commission
              };
            }
          })
          this.SpecificationPriceList.push(obj);
          let obj1 = {
            Id: i,
            AttrList: item.AttrList,
            SpecificationSort: item.SpecificationSort,
            GradeCommissionList: []
          };
          arrList.push(obj1);
        });
        this.calcdis(JSON.parse(JSON.stringify(arrList)));
      },
      calcdis(dislist) {
        let memberListarray = JSON.parse(JSON.stringify(dislist));
        let ComTreeList = JSON.parse(JSON.stringify(this.ComTreeList));
        // this.ComTreeList=[];//无法添加 报错 暂时注释掉
        for (let i = 0; i < dislist.length; i++) {
          if (this.addMsg.SeparateDistributionType == 2 && this.ComTreeList.length >
            0) { //this.ComTreeList.length为0 的时候 全部为空
            if (i < ComTreeList.length) {
              ComTreeList.forEach((val, z) => {
                if (val.SpecificationSort == dislist[i].SpecificationSort) {
                  dislist[i].GradeCommissionList = [];
                  dislist[i].GradeCommissionList = val.GradeCommissionList;
                }
              })
            } else {
              for (let j = 0; j < this.DropdownList.length; j++) {
                let obj = {
                  SpecificationSort: dislist[i].SpecificationSort,
                  DistributorGrade: this.DropdownList[j].Id,
                  OneCommission: 0,
                  TwoCommission: 0,
                  ThreeCommission: 0,
                  Name: dislist[i].Name
                };
                dislist[i].GradeCommissionList.push(obj);
              }
            }
          } else {
            for (let j = 0; j < this.DropdownList.length; j++) {
              let obj = {
                SpecificationSort: dislist[i].SpecificationSort,
                DistributorGrade: this.DropdownList[j].Id,
                OneCommission: 0,
                TwoCommission: 0,
                ThreeCommission: 0,
                Name: dislist[i].Name
              };
              dislist[i].GradeCommissionList.push(obj);
            }
          }
        }
        //以前的逻辑 暂时保留 6.22
        // dislist.forEach(item => {
        //   item.GradeCommissionList = [];
        //   // for (let i = 0; i < this.DropdownList.length; i++) {
        //   //   let obj = {
        //   //     SpecificationSort:item.SpecificationSort,
        //   //     DistributorGrade: this.DropdownList[i].Id,
        //   //     OneCommission: 0,
        //   //     TwoCommission: 0,
        //   //     ThreeCommission: 0,
        //   //     Name: item.Name
        //   //   };
        //   //   item.GradeCommissionList.push(obj);
        //     ComTreeList.forEach(val=>{
        //
        //       // if(val.SpecificationSort==item.SpecificationSort){
        //       //   item.GradeCommissionList=[];
        //       //   item.GradeCommissionList=val.GradeCommissionList;
        //       // }
        //     })
        //
        //   // }
        // });
        for (let i = 0; i < memberListarray.length; i++) {
          memberListarray[i].GradePriceList = [];
          if (this.addMsg.EnjoyMember == 1 && this.memberList2.length > 0) {

            if (i < this.memberList2.length) {
              this.memberList2.forEach(val => {
                if (val.SpecificationSort == memberListarray[i].SpecificationSort) {
                  memberListarray[i].GradePriceList = [];
                  memberListarray[i].GradePriceList = val.GradePriceList;
                }
              })
            } else {
              for (let j = 0; j < this.huiyList.length; j++) {
                let obj = {
                  MemberGrade: this.huiyList[j].Grade,
                  MemberPrice: 0
                };
                memberListarray[i].GradePriceList.push(obj);
              }
            }
          } else {
            for (let j = 0; j < this.huiyList.length; j++) {
              let obj = {
                MemberGrade: this.huiyList[j].Grade,
                MemberPrice: 0
              };
              memberListarray[i].GradePriceList.push(obj);
            }
          }
        }
        this.disList2 = JSON.parse(JSON.stringify(dislist));
        this.memberList2 = JSON.parse(JSON.stringify(memberListarray));
      },
      addggModeule() {
        this.speciDig = true;
        this.speciList.forEach(item => {
          item.NewSpecList = [];
          item.checkAll = false;
          item.SpecificationValueList = [];
          item.SpecList.forEach(val => {
            let obj = {
              Id: item.Id,
              Name: val
            };
            item.NewSpecList.push(obj);
          });
        });
      },
      Save(formName) {
        this.$refs[formName].validate(valid => {
          if (valid) {
            let content = this.$refs.ue.getUEContent();
            this.addMsg.GoodsDetails = content;
            if(this.addMsg.CategoryList.length==0){
              this.Error('请选择商品分类');
              return false
            }
            if (this.SpecificationList.length > 0) {
              this.addMsg.IsCustomSpecification = 1;
            }
            if (this.addMsg.SeparateDistributionType == 1) {
              this.disList1 = [{
                  SpecificationSort: "",
                  GradeCommissionList: this.GradeCommissionList
                }],
                this.addMsg.DistributionCommissionList = this.disList1;
            } else {
              this.addMsg.DistributionCommissionList = this.disList2;
            }
            if (this.addMsg.SeparateSetMember == 1 && this.SpecificationList.length == 0) {
              this.addMsg.MemberPriceList = this.memberList1;
              this.addMsg.MemberPriceTreeList = this.memberList1;
            }
            if (this.addMsg.SeparateSetMember == 1 && this.SpecificationList.length > 0) {
              this.addMsg.MemberPriceList = this.memberList2;
              this.addMsg.MemberPriceTreeList = this.memberList2;
            }
            let mall_userInfo = JSON.parse(localStorage.mall_userInfo)
            if(mall_userInfo.TenantId==1 && mall_userInfo.MallBaseId==1 && this.SupplierId ==''){
                   this.Error("请选择供应商!");
                    return
            }else{
              this.addMsg.SupplierId = this.SupplierId != '' ? this.SupplierId : 0; 
            }
            this.addMsg.SpecificationPriceList = this.SpecificationPriceList;
            this.addMsg.SpecificationList = this.SpecificationList;
            for(var i=0;i<this.addMsg.SpecificationPriceList.length;i++){
              if(this.addMsg.SpecificationPriceList[i].SellingPrice===''){
                this.Error('请输入商品规格第'+(i+1)+'行价格');
                return
              }
              if(this.addMsg.SpecificationPriceList[i].InventoryNum===''){
                this.Error('请输入商品规格第'+(i+1)+'行库存');
                return
              }
              if(this.addMsg.SpecificationPriceList[i].CostMoney===''){
                this.Error('请输入商品规格第'+(i+1)+'行成本价');
                return
              }
              if(this.FxState==1){
                if(this.addMsg.SpecificationPriceList[i].Commission===''){
                  this.Error('请输入商品规格第'+(i+1)+'行返佣总金额');
                  return
                }
              }
            }
            if(this.addMsg.PresentFXGrade==''){//没选择的时候默认为0
                  this.addMsg.PresentFXGrade=0
              }
              //标签的判断和处理
              if(this.addMsg.MarketingLogo.iswords==0){
                this.addMsg.MarketingLogo = {iswords:0,words:"",wordsColor:"",wordsBack:"",ico:""}
              }else if(this.addMsg.MarketingLogo.iswords==1){
                this.addMsg.MarketingLogo.ico= ''
              }else if(this.addMsg.MarketingLogo.iswords==2){
                this.addMsg.MarketingLogo.words= '';
                this.addMsg.MarketingLogo.wordsColor= '';
                this.addMsg.MarketingLogo.wordsBack= '';
              }
               this.addMsg.MarketingLogo = JSON.stringify( this.addMsg.MarketingLogo)
            this.apipost("/api/product/SetProductGoodsInfo", this.addMsg, res => {
              if (res.data.resultCode == 1) {
                this.Success(res.data.message);
                this.CommonJump("goodsList");
              } else {
                this.Error(res.data.message);
              }
            });
          } else {
            return false;
          }
        });
      },
      getSpeciList() {
        let msg = {
          pageIndex: 1,
          pageSize: 999,
          Name: "",
          Id: 0,
          Content: ""
        };
        this.apipost("/api/product/GetProductSpecificationPageList", msg, res => {
          if (res.data.resultCode == 1) {
            let pageData = res.data.data.pageData;
            this.speciList = pageData;
            this.speciList.forEach(item => {
              item.NewSpecList = [];
              item.checkAll = false;
              item.SpecList.forEach(val => {
                let obj = {
                  Id: item.Id,
                  Name: val
                };
                item.NewSpecList.push(obj);
              });
            });
          }
        });
      },
      editQy() {
        this.dialogFormVisible = true;
        setTimeout(() => {
          this.$refs.child.Receive(this.AreaList);
        }, 1000);
      },
      Addto() {
        this.addMsg.AreaList = [];
        this.AreaList.forEach(item => {
          let obj = {
            Id: item.RegionId,
            AreaId: item.RegionId,
            AreaName: item.RegionName
          };
          this.addMsg.AreaList.push(obj);
        });
        this.dialogFormVisible = false;
      },
      addOf() {
        this.dialogFormVisible = true;
        this.AreaList = [];
        this.addMsg.AreaList = [];
        setTimeout(() => {
          this.$refs.child.Receive(this.AreaList);
        }, 1000);
      },
      change(data) {
        this.AreaList = data;
      },
      YfSelect1(val) {
        this.addMsg.FormsId = val.Id;
        this.addMsg.FormsName = val.Name;
      },
      YfSelect(val) {
        this.addMsg.FreightId = val.ID;
        this.addMsg.FreightName = val.RulesName;
      },
      ServiceCheck(item, index) {
        this.addMsg.ServiceList.forEach((list, k) => {
          if (list.Id == item.Id) {
            this.addMsg.ServiceList.splice(k, 1);
          }
        });
      },
      clearCustom() {
        this.addMsg.CustomShareImage = "";
        this.addMsg.CustomShareImagePath = "";
      },
      Selectvideo(val) {
        this.addMsg.VideoAddress = val.Path;
        this.changeState1 = false;
      },
      ClearCarouse(index) {
        this.addMsg.CarouselImageList.splice(index, 1);
      },
      DeleteImageUrl(item, index, item2, index2) {
        this.SpecificationList[index].SpecificationValueList[index2].Image = "";
      },
      openggImg(item, index, item2, index2) {
        this.changeState = true;
        this.imgType = 3;
        this.imgListIndex1 = index;
        this.imgListIndex2 = index2;
      },
      openChangeDig(val) {
        this.changeState = true;
        this.imgType = val;
      },
      //选择图片
      SelectId(msg) {
        let that = this;
        if (msg && msg.length > 0) {
          if (this.imgType == 1) {
            msg.forEach(item => {
              let obj = {
                Id: item.selectId,
                Path: that.getIconLink(item.url),
              };
              this.addMsg.CarouselImageList.push(obj);
            })
          }
          if (this.imgType == 2) {
            this.addMsg.CustomShareImage = that.getIconLink(msg[0].url);
          }
          if (this.imgType == 3) {
            let imgListIndex1 = this.imgListIndex1;
            let imgListIndex2 = this.imgListIndex2;
            this.SpecificationList[imgListIndex1].SpecificationValueList[
              imgListIndex2
            ].Image = that.getIconLink(msg[0].url);
          }
          if(this.imgType == 4){
              that.addMsg.MarketingLogo.ico = that.getIconLink(msg[0].url)
          }
        }
        this.changeState = false;
      },
      getChild3(ChildList) {
        this.childList3 = ChildList;
      },
      getChild2(ChildList) {
        this.childList2 = ChildList;
      },
      ExitCateList() {
        this.NewCategoryList = [];
        this.addMsg.CategoryList.forEach(item => {
          item.Name = item.CategoryName;
          this.NewCategoryList.push(item.CategoryId);
        });
      },
      handleCheckChange() {
        this.addMsg.CategoryList = [];
        this.NewCategoryList.forEach(list => {
          this.fenleiData.forEach(item => {
            if (list == item.Id) {
              item.CategoryId = item.Id;
              this.addMsg.CategoryList.push(item);
            }
            item.ChildList.forEach(item2 => {
              if (list == item2.Id) {
                item2.CategoryId = item2.Id;
                this.addMsg.CategoryList.push(item2);
              }
              item2.ChildList.forEach(item3 => {
                if (list == item3.Id) {
                  item3.CategoryId = item3.Id;
                  this.addMsg.CategoryList.push(item3);
                }
              });
            });
          });
        });
      },
      exitCheck(item, index) {
        this.addMsg.CategoryList.forEach((list, k) => {
          if (list.Id == item.Id) {
            this.addMsg.CategoryList.splice(k, 1);
          }
        });
        this.ExitCateList();
        this.getSuggestPrice();
      },
      getTree() {
        let msg1 = {
          Id: 0,
          Name: "",
          Tier: 0,
          ParentId: 0,
          Enabled: 1,
          IsShow: 1
        };
        this.apipost("/api/product/GetProductCategoryTreeList", msg1, res => {
          if (res.data.resultCode == 1) {
            let pageData = res.data.data;
            this.fenleiData = pageData;
            this.fenleiData.forEach(item => {
              item.CategoryName = item.Name;
              item.ChildList.forEach(item2 => {
                item2.CategoryName = item2.Name;
                item2.ChildList.forEach(item3 => {
                  item3.CategoryName = item3.Name;
                });
              });
            });
          }
        });
      },
      getcode(){//编码获取详情
        this.GoodsId = this.addMsg.Id;
        this.getData()

      },
      getData() {
        this.apipost(
          "/api/product/GetProductGoodsInfo", {
            GoodsId: this.GoodsId
          },
          res => {
            if(res.data.resultCode == 1){
                this.addMsg = res.data.data;
                if (this.addMsg.SupplierId != 0) {
                  this.SupplierId = this.addMsg.SupplierId;

                }
                if (!this.$route.query.GoodsId) {
                  this.addMsg.Id=0
                }
                if (this.addMsg.LimitBuyGoodsNum != -1) {
                  this.BuyGoodsNumState = false
                }
                if (this.addMsg.LimitBuyOrderNum != -1) {
                  this.BuyOrderNumState = false
                }
                this.initShareSettings();
                this.SpecificationPriceList = this.addMsg.SpecificationPriceList;
                this.ComTreeList = this.addMsg.DistributionCommissionTreeList;
                this.SpecificationList = this.addMsg.SpecificationList;
                if(this.SpecificationList.length>0){ //根据编码来的详情 重新调用这个方法 否则分销详情设置没有数据
                  this.getDistributor()
                }
                if (this.addMsg.SeparateDistributionType == 1) {
                  this.disList1 = this.addMsg.DistributionCommissionTreeList;
                  if (this.addMsg.DistributionCommissionTreeList.length > 0) {
                    this.GradeCommissionList = this.addMsg.DistributionCommissionTreeList[0].GradeCommissionList;
                  }
                }
                this.memberList2 = this.addMsg.MemberPriceTreeList;
                this.thisType = 1;
                this.disList1 = [];
                let objNew = {
                  SpecificationSort: "",
                  GradeCommissionList: this.GradeCommissionList
                };
                this.disList1.push(objNew);
                if (this.addMsg.GoodsDetails && this.addMsg.GoodsDetails != "") {
                  // this.$refs.ue.SetVal(this.addMsg.GoodsDetails);
                  this.defaultMsg=this.addMsg.GoodsDetails;
                }
                this.NewCategoryList = [];
                this.addMsg.CategoryList.forEach(item => {
                  item.Name = item.CategoryName;
                  this.NewCategoryList.push(item.CategoryId);
                });
                if (this.hpState == 1) {
                  this.addMsg.SeparateDistribution = 0;
                }
                if(this.addMsg.PresentFXGrade==0){
                  this.addMsg.PresentFXGrade=''
                }
                if( this.addMsg.MarketingLogo==null){
                  this.addMsg.MarketingLogo ={iswords:0,words:"",wordsColor:"",wordsBack:"",ico:""}
                }else{
                  this.addMsg.MarketingLogo = JSON.parse(this.addMsg.MarketingLogo)
                }
                this.getSuggestPrice();
                this.getFXDGradeList2();
                
               
            }
            
          }
        );
      },
      getSuggestPrice() {
        if (this.hpState == 1 && Number(this.addMsg.CostPrice) > 0) {
          let arr = [];
          this.addMsg.CategoryList.forEach(item => {
            item.Name = item.CategoryName;
            arr.push(item.CategoryId);
          });
          let CategoryIds = arr.join(",");
          let msg = {
            CategoryIds: CategoryIds,
            CostPrice: this.addMsg.CostPrice
          };
          this.apipost("/api/user/GetHpGoodsSuggestPrice", msg, res => {
            if (res.data.resultCode == 1) {
              this.SuggestPriceInfo = res.data.data;
            }
          });
        }
      },
      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;
          }
        });
      },
      getService() {
        let msg = {
          pageIndex: 1,
          pageSize: 200,
          Name: "",
          IsDefault: 0
        };
        this.apipost("/api/product/GetProductServicePageList", msg, res => {
          if (res.data.resultCode == 1) {
            this.total = res.data.data.count;
            let pageData = res.data.data.pageData;
            this.serviceList = pageData;
          }
        });
      },
      getDistributor() {
        this.loading = true;
        this.apipost("/api/user/GetDistributorBasicsInfo", {}, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.butorInt = res.data.data.DistributorTier;
            this.butorIntList = [];
            for (let i = 0; i < res.data.data.DistributorTier; i++) {
              let msg = {
                Name: i + 1 + "级分销"
              };
              this.butorIntList.push(msg);
            }
            this.GetDropdownList();
          }
        });
      },
      GetDropdownList() {
        let msg = {
          Id: 0,
          Grade: 0,
          Name: "",
          Enabled: 1
        };
        this.apipost("/api/user/GetDistributorGradeDropdownList", msg, res => {
          this.DropdownList = JSON.parse(JSON.stringify(res.data.data));
          let msg = {
            Grade: 0,
            GradeCommissionList: [],
            Name: "默认等级",
            SpecificationSort: "",
            Id: 0
          };
          this.DropdownList.unshift(msg);
          this.disList1.GradeCommissionList = [];
          this.disList1.SpecificationSort = "";
          this.DropdownList.forEach(item => {
            item.GradeCommissionList = [];
            item.SpecificationSort = "";
            for (let i = 0; i < this.butorInt; i++) {
              let obj = {
                DistributorGrade: item.Id,
                OneCommission: 0,
                TwoCommission: 0,
                ThreeCommission: 0
              };
              item.GradeCommissionList.push(obj);
            }
          });
          this.DropdownList = JSON.parse(JSON.stringify(this.DropdownList));
          if (
            !this.$route.query.GoodsId ||
            (this.addMsg.DistributionCommissionTreeList && this.addMsg.DistributionCommissionTreeList.length ==
              0) || this.thisType == 1
          ) {
            this.GradeCommissionList = [];
            this.DropdownList.forEach(item => {
              let obj2 = {
                DistributorGrade: item.Id,
                OneCommission: 0,
                TwoCommission: 0,
                ThreeCommission: 0,
                Name: item.Name
              };
              this.GradeCommissionList.push(obj2);
            });
            this.GradeCommissionList = JSON.parse(
              JSON.stringify(this.GradeCommissionList)
            );
            this.disList2 = [];
            if (this.$route.query.GoodsId) {
              if (this.addMsg.SeparateDistributionType == 1) {
                this.disList1 = this.addMsg.DistributionCommissionTreeList;
                if (this.addMsg.DistributionCommissionTreeList.length > 0) {
                  this.GradeCommissionList = this.addMsg.DistributionCommissionTreeList[0].GradeCommissionList;
                }
              }
            } else {
              this.disList1 = [];
              let objNew = {
                SpecificationSort: "",
                GradeCommissionList: this.GradeCommissionList
              };
              this.disList1.push(objNew);
            }
            this.skuList = [];
            this.getSkuData([], 0, this.SpecificationList);
          }
        });
      },
      changeSupplier(val) {},
      getSupplierList() {
        this.apipost("/api/Supplier/GetSupplierAllList", {}, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.options = res.data.data;
          }
        });
      },
      getFXDGradeList(){
         this.apipost("/api/user/GetFXDistributorGradeList", {GradeName:''}, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            if(res.data.data!=null){
               let data =  res.data.data;
               let List =[];
               data.forEach(x=>{
                 let obj={};
                //  if(x.IsGuest !=1){
                 if(x.IsGuest ==3){//只显示vip 
                   let obj = x
                   List.push(obj)
                 }
               })
            this.FXlevelList = List;
            }
          }
        });
      },
       getFXDGradeList2(){
         
         this.apipost("/api/user/GetFXDistributorGradeList", {GradeName:''}, res => {
          if (res.data.resultCode == 1) {
           
           if(res.data.data!=null){
                res.data.data.forEach(x=>{
                  if(x.Id== this.addMsg.PresentFXGrade){
                    if(x.IsGuest==3){
                      this.giveDate=true;
                    }else{
                       this.giveDate=false;
                      this.addMsg.PresentFXMonth=0;
                    }
                  }
                })
            }
          }
        });
       
      },
      changeVIP(){
        if(this.addMsg.PresentFXGrade=='' || this.addMsg.PresentFXGrade==0){
          this.giveDate=false;
          this.addMsg.PresentFXMonth=0
        }else{
          this.giveDate=true;
        }
          // this.FXlevelList.forEach(x=>{
          //     if(x.Id== this.addMsg.PresentFXGrade){
          //       if(x.IsGuest==3){
          //         this.giveDate=true;
          //         this.addMsg.PresentFXMonth=1;
          //       }else{
          //          this.giveDate=false;
          //          this.addMsg.PresentFXMonth=0;
          //       }
          //     }
          //   })
      }
    }
  };
</script>
<style>
  .app-attr-group .close {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 16px;
    cursor: pointer;
  }

  .goodsListEdit .el-image {
    position: relative;
    display: inline-block;
    overflow: hidden;
  }

  .goodsListEdit .pendSelect {
    width: 100px;
  }

  .goodsListEdit .el-table th>.cell {
    padding-left: 20px !important;
  }

  .goodsListEdit .app-attr .box {
    line-height: 64px;
    border-top: 1px solid #e8eaee;
    border-left: 1px solid #e8eaee;
    border-right: 1px solid #e8eaee;
    padding: 0 16px;
  }

  .speciDig .tpl-scrollbar .el-checkbox {
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 10px 0;
  }

  .speciDig .tpl-scrollbar {
    height: calc(440px - 44px - 10px);
  }

  .speciDig .tpl-box .tpl-head {
    padding: 0 20px;
    font-size: 15px;
    color: #909399;
    margin-bottom: 10px;
    line-height: 44px;
    background: #f5f7fa;
  }

  .speciDig .tpl-box {
    width: 300px;
    height: 440px;
  }

  .goodsListEdit .app-attr-group .attr-jt {
    background: #ffffff;
    width: 6px;
    height: 6px;
    border-top: 1px solid rgb(235, 238, 245);
    border-right: 1px solid #ebeef5;
    transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    position: absolute;
    top: -5px;
  }

  .goodsListEdit .app-attr-group .img-box {
    position: relative;
    height: 100px;
    width: 100px;
    margin-top: 8px;
    border: 1px solid #ebeef5;
  }

  .goodsListEdit .app-attr-group .close {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 16px;
    cursor: pointer;
  }

  .goodsListEdit .app-attr-group .attr-list {
    display: inline-block;
    margin-right: 10px;
    margin-bottom: 10px;
    position: relative;
    cursor: move;
  }

  .goodsListEdit .box-grow-0 {
    min-width: 0;
    -webkit-box-flex: 0;
    -webkit-flex-grow: 0;
    -ms-flex-positive: 0;
    flex-grow: 0;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
  }

  .goodsListEdit .app-attr-group .del-img {
    height: 20px;
    width: 20px;
    cursor: pointer;
  }

  .goodsListEdit .app-attr-group .bg {
    height: 44px;
    padding: 0 10px;
    background: #f8f8f8;
  }

  .regionDig .regionChoice .item_b {
    margin-bottom: 10px;
  }

  .goodsListEdit .app-attr-group .bg {
    height: 44px;
    padding: 0 10px;
    background: #f8f8f8;
  }

  .goodsListEdit .app-attr-group {
    border: 1px solid #ebeef5;
    padding: 10px;
  }

  .goodsListEdit .delBtn {
    position: absolute;
    right: -8px;
    top: -8px;
    padding: 4px 4px !important;
  }

  .goodsListEdit .add-image-btn {
    width: 100px;
    height: 100px;
    line-height: 100px;
    color: #419efb;
    border: 1px solid #e2e2e2;
    cursor: pointer;
    text-align: center;
  }

  .goodsListEdit .colapp-image {
    background-size: cover;
    background-position: center center;
    width: 100px;
    height: 100px;
    border-radius: 0%;
  }

  .goodsListEdit .el-form-item__label {
    padding-right: 26px;
  }

  .app-add-cat .el-checkbox-group {
    font-size: 14px !important;
  }

  .app-add-cat .el-checkbox {
    margin-right: 0;
  }

  .app-add-cat .el-dialog__body {
    padding: 10px 20px !important;
  }

  .app-add-cat .tag-box .tag-item {
    margin-right: 5px;
  }

  .app-add-cat .tag-box {
    margin: 20px 0;
  }

  .app-add-cat .app-goods-cat-list .active {
    background: #fafafa;
  }

  .app-add-cat .app-goods-cat-list .cat-item {
    cursor: pointer;
    padding: 5px 10px;
  }

  .app-add-cat .app-goods-cat-list {
    border: 1px solid #e8eaee;
    border-radius: 5px;
    margin-top: -5px;
    padding: 10px 0;
    overflow: scroll;
    height: 400px;
  }

  .goodsListEdit .bottom-div {
    border-top: 1px solid #e3e3e3;
    position: fixed;
    bottom: 0;
    background-color: #ffffff;
    z-index: 999;
    padding: 10px;
    width: 80%;
  }

  .goodsListEdit .fen-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    border: 1px solid #eee;
  }

  .goodsListEdit .fen-table td,
  .goodsListEdit .fen-table th {
    border: 1px solid #eee;
    padding: 10px 0;
    padding-left: 10px;
  }

  .goodsListEdit .fen-table td {
    font-size: 12px;
  }

  .goodsListEdit .fen-table th {
    background: #ddd;
    font-weight: 500;
  }

  .goodsListEdit .fen-sumg {
    margin: 20px 0;
    font-size: 12px;
  }
  @media (max-width:1920px) and (min-width:1300px) {
    .goodsListEdit .el-col-12 {
        width: 50%;
    }
  }
  @media (max-width:1910px) and (min-width:1200px) {
    .goodsListEdit .el-col-12 {
        width: 66.66667%;
    }
  }
  @media (max-width:1199px) and (min-width:200px) {
    .goodsListEdit .el-col-12 {
        width: 80%;
    }
  }
  .edui1_imagescale img{
    max-width: 100%;
  }
  .goodsListEdit .nav_Main {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .goodsListEdit .nav_IconContent {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .goodsListEdit .nav_IconContent div>div{
    display: inline-block;
  }
</style>
