<template>
  <div class="directorGoodsEdit">
    <div class="head-title">
      <span @click="CommonJump('directorGoodsList')" 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="上架版面">
                      <el-radio-group v-model="addMsg.GoodsPageType" @change="getGoodType(addMsg.GoodsPageType)">
                        <el-radio v-for="(item,index) in My_cateList" :key="index" :label="item.Id">{{item.Name}}</el-radio>
                      </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-row>
              <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 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 v-if="addMsg.CustomShareImage ||addMsg.CustomShareImage !=''" 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="站点" prop="SiteId">
                    <el-select class="w150" style="margin-right: 10px;" v-model="addMsg.SiteId" size="small"
                      placeholder="请选择" @change='changeSiteId'>
                      <el-option v-for="item in SiteList" :key="item.ID" :label="item.SiteName" :value="item.ID">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="关联导游" prop="GuideId" v-if="addMsg.SiteId!=''">
                    <el-select class="w150" style="margin-right: 10px;" v-model="addMsg.GuideId" size="small"
                      placeholder="请选择">
                      <el-option v-for="item in GuideList" :key="item.ID" :label="item.Name" :value="item.ID">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="关联车辆" prop="CarId">
                    <el-select class="w150" style="margin-right: 10px;" v-model="addMsg.CarId" size="small"
                      placeholder="请选择" @change='changeCarId'>
                      <el-option v-for="item in CarList" :key="item.ID" :label="item.Name" :value="item.ID">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="车辆颜色" prop="CarColorId" v-if="addMsg.CarId!=''">
                    <el-select class="w150" style="margin-right: 10px;" v-model="addMsg.CarColorId" size="small"
                      placeholder="请选择" @change='changeCarColorList'>
                      <el-option v-for="item in CarColorList" :key="item.ID" :label="item.ColorName" :value="item.ID">
                      </el-option>
                    </el-select>
                    <!--                    <img v-for="(item,index) in CarColorList" :key="item.ID" src="" alt="">-->
                  </el-form-item>


                  <el-form-item label="车牌号" prop="CarNumber">
                    <el-input v-model="addMsg.CarNumber" size="small" placeholder="请输入车牌号" class="input-with-select">
                    </el-input>
                  </el-form-item>
                  <el-form-item label="车购买年份">
                    <el-input v-model="addMsg.CarBuyYear" size="small" placeholder="请输入车购买年份" class="input-with-select">
                    </el-input>
                  </el-form-item>
                  <el-form-item label="服务类型" prop="CarType">
                    <el-select class="w150" style="margin-right: 10px;" v-model="addMsg.CarType" size="small"
                      placeholder="请选择" @change='changeEnumList'>
                      <el-option v-for="item in EnumList" :key="item.Id" :label="item.Name" :value="item.Id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="线路名称" v-if="EnumType==5" prop="LineName">
                    <el-input v-model="addMsg.LineName" size="small" placeholder="请输入内容" class="input-with-select">
                    </el-input>
                  </el-form-item>
                  <el-form-item label="使用天数" v-if="EnumType==3||EnumType==4||EnumType==5">
                    <el-select class="w150" style="margin-right: 10px;" v-model="addMsg.UseDay" size="small"
                      placeholder="请选择" @change='changeSupplier'>
                      <el-option v-for="item in DayList" :key="item.ID" :label="item.Name" :value="item.ID">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="关联城市或景点" v-if="EnumType==5">
                    <div flex="dir:left" style="flex-wrap: wrap;">
                      <div class="attr-list" v-for="(item,index) in LineCityScen" :key="index">
                        <el-input size="mini" v-model="item.Name" width="152px"></el-input>
                        <i @click="Deleteggz(index)" class="el-icon-error close"></i>
                      </div>
                      <div>
                        <span @click="addGgz()" class="blue f12">添加城市或景点</span>
                      </div>
                    </div>
                  </el-form-item>
                  <el-form-item label="乘坐人数" prop="RideNum">
                    <el-input v-model="addMsg.RideNum" size="small" @keyup.native="checkInteger(addMsg,'RideNum')" placeholder="请输入内容" class="input-with-select">
                      <el-button slot="append">人</el-button>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="是否拼车" v-if="addMsg.CarType==5">
                    <el-radio v-model="addMsg.IsSpell" :label="1">是</el-radio>
                    <el-radio v-model="addMsg.IsSpell" :label="2">否</el-radio>
                  </el-form-item>
                  <el-form-item label="提前预定天数" prop="AdvanceDay">
                    <el-input v-model="addMsg.AdvanceDay" size="small" @keyup.native="checkPrice(addMsg,'AdvanceDay')" 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" 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-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="成本价">
                    <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" @keyup.native="checkPrice(addMsg,'Commission')" size="small"
                      placeholder="请输入内容" class="input-with-select">
                      <el-button slot="append">元</el-button>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="预订日期" class="is-required">
                    <el-select class="w120" style="margin-right: 10px;" v-model="dateMsg.DayType" size="small"
                      placeholder="请选择" @change='changeSupplier'>
                      <el-option v-for="item in reserveList" :key="item.ID" :label="item.Name" :value="item.ID">
                      </el-option>
                    </el-select>
                    <template v-if="dateMsg.DayType==1">
                      <div style="margin-left:30px;display:inline-block;">
                        日期：
                        <el-date-picker class="w130" size="small" v-model="dateMsg.StartDate" type="date"
                          value-format="yyyy-MM-dd" :picker-options="pickerBeginDateBefore" placeholder="选择日期">
                        </el-date-picker>
                        -
                        <el-date-picker class="w130" size="small" v-model="dateMsg.EndDate" value-format="yyyy-MM-dd"
                          type="date" :picker-options="pickerBeginDateAfter" placeholder="选择日期"></el-date-picker>
                      </div>
                    </template>
                    <template v-if="dateMsg.DayType==2">
                      <div style="margin-left:20px;display:inline-block;">
                        月：
                        <el-date-picker v-model="dateMsg.Month" size="small" value-format="yyyy-MM" type="month"
                          placeholder="选择月">
                        </el-date-picker>
                      </div>
                    </template>
                    <template v-if="dateMsg.DayType==3">
                      <div style="display:inline-block;">
                        年：
                        <el-date-picker class="w90" size="small" v-model="dateMsg.Year" value-format="yyyy" type="year"
                          placeholder="选择年">
                        </el-date-picker>
                        月：
                        <el-select size="small" class="w90" v-model="dateMsg.Month">
                          <el-option label="一月" value="01"></el-option>
                          <el-option label="二月" value="02"></el-option>
                          <el-option label="三月" value="03"></el-option>
                          <el-option label="四月" value="04"></el-option>
                          <el-option label="五月" value="05"></el-option>
                          <el-option label="六月" value="06"></el-option>
                          <el-option label="七月" value="07"></el-option>
                          <el-option label="八月" value="08"></el-option>
                          <el-option label="九月" value="09"></el-option>
                          <el-option label="十月" value="10"></el-option>
                          <el-option label="十一月" value="11"></el-option>
                          <el-option label="十二月" value="12"></el-option>
                        </el-select>
                        周：
                        <el-select size="small" class="w100" v-model="dateMsg.Week">
                          <el-option label="星期天" value="0"></el-option>
                          <el-option label="星期一" value="1"></el-option>
                          <el-option label="星期二" value="2"></el-option>
                          <el-option label="星期三" value="3"></el-option>
                          <el-option label="星期四" value="4"></el-option>
                          <el-option label="星期五" value="5"></el-option>
                          <el-option label="星期六" value="6"></el-option>
                        </el-select>
                      </div>
                    </template>
                    <el-button size="small" type="primary" @click="SaveDate()">添加</el-button>
                  </el-form-item>
                  <el-form-item>
                    <el-tag type="info" style="margin-right:20px;" closable @close="handleClose(index)"
                      v-for="(SubItem,index) in subDateList" :key="index" size="small">{{SubItem}}</el-tag>
                  </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="200px">
                    <el-checkbox v-model="addMsg.IsMultipleDeduction" :true-label="1" :false-label="2">允许多件抵扣
                    </el-checkbox>
                  </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.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>
            </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
              " label="默认规格会员价设置">
              <template v-if="memberList1&&memberList1[0].GradePriceList.length>0">
                <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.MemberGrade }}级会员</el-button>
                    <el-button slot="append">元</el-button>
                  </el-input>
                </div>
              </template>
            </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="选择表单" 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" width="950px">
      <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>

  </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: [],
        speciList: [],
        choosebdDig: false,
        val2: "",
        defaultMsg: "",
        config: {
          initialFrameWidth: null,
          initialFrameHeight: 350
        },
        dialogFormVisible: false,
        changeState1: false,
        changeState: false,
        imgDig: false,
        activeName: "first",
        flDig: false,
        addMsg: {
          Id: 0,
          CategoryList: [], //分类列表
          Name: "", //商品名称
          CarouselImageList: [], //轮播图
          VideoAddress: "", //视频地址	
          CustomShareTitles: "", // 分享标题	
          CustomShareImage: "", //分享图片	
          GoodsStatus: 0, //商品状态 1销售中 2下架
          IsLiveGoods: 2, //是否直播商品 1是 2否
          Sort: 0, //排序
          SellingPrice: 0, //销售价格
          OriginalPrice: 0, //原价
          CostPrice: 0, //成本价格
          IsAreaBuy: 2, //是否区域购买 1是 2否
          IntegralPresent: 0, //积分赠送
          IntegralPresentType: 2, //积分赠送类型
          PointsDeduction: 0, //积分抵扣
          PointsDeductionType: 2, //积分抵扣类型
          IsMultipleDeduction: 2, //是否可以多件累计抵扣 1是 2否
          GoodsDetails: "", //商品描述
          SeparateDistribution: 2, //分销
          SeparateDistributionType: 1,
          SeparateDistributionMoneyType: 2, //默认显示固定金额
          EnjoyMember: 1, //会员价
          SeparateSetMember: 0,
          SupplierId: '', //供应商id
          Commission: 0, // 返佣总金额 （粉象模式开启 才显示）
          AreaList: [], //区域列表	
          DistributionCommissionList: [], //分销佣金
          DistributionCommissionTreeList: [],
          MemberPriceList: [], //会员价格
          Advertising: '', //广告词
          SubName: '', //副标题
          MarketingLogo: { //图标
            iswords: 0,
            words: "",
            wordsColor: "",
            wordsBack: "",
            ico: ""
          },
          SiteId: '', //站点id
          GuideId: '', //导游id
          CarId: '', //车辆id
          CarColorId: 2, //车辆颜色id
          CarNumber: '', //车牌号
          CarBuyYear: '', //车购买年份
          CarType: '', //服务类型 枚举	
          UseDay: 1, //使用天数
          LineName: '', //线路名称
          LineDescriptionList: [], //关联城市或景点
          RideNum: 0, //乘坐人数
          IsSpell: 2, //是否拼车 1是 2否
          AdvanceDay: 0, //	提前预定天数
          TargetDateStrList: [],
          GoodsPageType:0, //分类 0全部 1商城 2校园

          // FormsId: -1,
          // FormsName: "",
        },
        LineCityScen:[], //关联城市或景点
        predefineColors: [
          '#000000',
          '#FFFFFF',
          '#888888',
          '#FF4544',
        ],
        EnumType: 0,
        SupplierId: '',
        fenleiData: [],
        checkList: [],
        childList2: [],
        childList3: [],
        keepCategoryList: [],
        rules: {
          CategoryIdNew: [{
            required: true,
            message: "分类不能为空",
            trigger: "change"
          }],
          Name: [{
            required: true,
            message: "请输入商品名称",
            trigger: "blur"
          }],

          SellingPrice: [{
            required: true,
            message: "请输入商品售价",
            trigger: "blur"
          }],

          OriginalPrice: [{
            required: true,
            message: "请输入原价",
            trigger: "blur"
          }],
          Commission: [{
            required: true,
            message: "返佣总金额",
            trigger: "blur"
          }],
          CarNumber: [{
            required: true,
            message: "请输入车牌号",
            trigger: "blur"
          }],
          UseDay: [{
            required: true,
            message: "请输入使用天数",
            trigger: "blur"
          }],
          RideNum: [{
            required: true,
            message: "请输入乘坐人数",
            trigger: "blur"
          }],
          AdvanceDay: [{
            required: true,
            message: "请输入提前预定天数",
            trigger: "blur"
          }],
          LineName: [{
            required: true,
            message: "请输入线路名称",
            trigger: "blur"
          }]
        },
        SiteList: [], //站点列表
        GuideList: [], //导游列表
        CarList: [], //导游列表
        CarColorList: [], //车辆颜色
        EnumList: [], //服务列表
        DayList: [{
            'ID': 0.5,
            'Name': '半日'
          },
          {
            'ID': 1,
            'Name': '一日'
          },
          {
            'ID': 2,
            'Name': '二日'
          },
          {
            'ID': 3,
            'Name': '三日'
          },
          {
            'ID': 4,
            'Name': '四日'
          },
          {
            'ID': 5,
            'Name': '五日'
          },
          {
            'ID': 6,
            'Name': '六日'
          },
          {
            'ID': 7,
            'Name': '七日'
          },
        ],
        reserveList: [{
            'ID': 1,
            'Name': '指定区间'
          },
          {
            'ID': 2,
            'Name': '按每月'
          },
          {
            'ID': 3,
            'Name': '按每周'
          },
        ],
        reserveType: 1,
        imgType: 1,
        checkService: [],
        keepServiceList: [],
        ruleList: [],
        val: {},
        val1: {},
        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: [],
        giveDate: false,

        //请求日期参数 
        dateMsg: {
          DayType: 1, //类型
          StartDate: '', //开始时间
          EndDate: '', //结束时间
          Year: '', //年
          Month: '', //月
          Week: '' //周
        },
        pickerBeginDateBefore: {
          disabledDate: time => {
            if (this.dateMsg.EndDate == null) {
              return false;
            } else {
              let endTime = new Date(this.dateMsg.EndDate);
              return endTime.getTime() < time.getTime();
            }
          }
        },
        pickerBeginDateAfter: {
          disabledDate: time => {
            let startTime = new Date(this.dateMsg.StartDate);
            return startTime.getTime() >= time.getTime();
          }
        },
        subDateList: [], //日期数组
        My_cateList:[]
      };
    },
    created() {
      if (this.$route.query.hpState) {
        this.hpState = this.$route.query.hpState;
      }
      if (this.$route.query.FxState) {
        this.FxState = this.$route.query.FxState;
      }
      this.gethuiyList();
      this.getRule();
      this.getSpeciList();
      this.getDistributor();
      this.getSupplierList()
      this.getAllGuideCarSiteList()
      this.getGuideCarList() //获取车辆下拉
      this.getOrderListExportEnumList()
      this.getCateList();
    },
    mounted() {
      this.$refs.ue.loadUe();
      if (this.$route.query.GoodsId) {
        this.GoodsId = this.$route.query.GoodsId;
        this.getData();
      }else{
        this.getTree();
      }
    },
    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;
      },

      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;
      },
      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
            }
            //预定日期设置
            this.addMsg.TargetDateStrList = this.subDateList;
            this.addMsg.LineDescriptionList=[];
            if(this.LineCityScen.length>0){
              this.LineCityScen.forEach(x=>{
                this.addMsg.LineDescriptionList.push(x.Name);
              })
            }

            if (this.addMsg.SeparateDistributionType == 1) {
              this.disList1 = [{
                  SpecificationSort: "",
                  GradeCommissionList: this.GradeCommissionList
                }],
                this.addMsg.DistributionCommissionList = this.disList1;
            }
            if (this.addMsg.SeparateSetMember == 1) {
              this.addMsg.MemberPriceList = this.memberList1;
              this.addMsg.MemberPriceTreeList = this.memberList1;
            }
            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;
            }

            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/GuideCar/SetGoodsInfo", this.addMsg, res => {
              if (res.data.resultCode == 1) {
                this.Success(res.data.message);
                this.CommonJump("directorGoodsList");
              } 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;
      },


      clearCustom() {
        this.addMsg.CustomShareImage = "";
      },
      Selectvideo(val) {
        this.addMsg.VideoAddress = val.Path;
        this.changeState1 = false;
      },
      ClearCarouse(index) {
        this.addMsg.CarouselImageList.splice(index, 1);
      },

      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: 0,
          CategoryPageType:this.addMsg.GoodsPageType
        };
        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/GuideCar/GetGoodsInfo", {
            GoodsId: this.GoodsId
          },
          res => {
            if (res.data.resultCode == 1) {
              this.addMsg = res.data.data;
              this.EnumType = this.addMsg.CarType;
              if (this.addMsg.SupplierId != 0) {
                this.SupplierId = this.addMsg.SupplierId;
              }
              if(this.addMsg.LineDescriptionList==null){
                this.addMsg.LineDescriptionList=[];
              }
              this.LineCityScen=[]
              if(this.addMsg.LineDescriptionList){
                this.addMsg.LineDescriptionList.forEach(x=>{
                  this.LineCityScen.push({'Name':x})
                })
              }
              if (!this.$route.query.GoodsId) {
                this.addMsg.Id = 0
              }
              if (this.addMsg.TargetDateList.length > 0) {
                this.addMsg.TargetDateList.forEach(x => {
                  this.subDateList.push(x.Date.split('T')[0])
                })
              }
              this.getGuideCarGuideList(this.addMsg.SiteId) //导游下拉

              this.initShareSettings();

              this.ComTreeList = this.addMsg.DistributionCommissionTreeList;

              if (this.addMsg.SeparateDistributionType == 1) {
                this.disList1 = this.addMsg.DistributionCommissionTreeList;
                if (this.addMsg.DistributionCommissionTreeList.length > 0) {
                  this.GradeCommissionList = this.addMsg.DistributionCommissionTreeList[0].GradeCommissionList;
                }
              }
              if(this.addMsg.MemberPriceTreeList.length>0){
                this.memberList1 = 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.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 || this.addMsg.MarketingLogo == null) {

                this.addMsg.MarketingLogo = {
                  iswords: 0,
                  words: "",
                  wordsColor: "",
                  wordsBack: "",
                  ico: ""
                }
              } else {
                let MarketingLogo = JSON.parse(this.addMsg.MarketingLogo)
                let obj = MarketingLogo
                this.addMsg.MarketingLogo = obj
              }
              this.getSuggestPrice();
              this.getFXDGradeList2();
              this.getTree();

              this.apipost("/api/GuideCar/GetGuideCarList", {}, res => {
                if (res.data.resultCode == 1) {
                  var MyData = res.data.data;
                  MyData.forEach(x => {
                    if (x.ID == this.addMsg.CarId) {
                      this.CarColorList = x.ColorList
                    }
                  })
                }
              });
            } else {
              this.Error(res.data.message);
            }
          }
        );
      },
      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;
          }
        });
      },

      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 = [];
          }
        });
      },
      changeSupplier(val) {

      },
      addGgz() {
        let obj = {
          Name: ''
        }
        this.LineCityScen.push(obj);
      },
      Deleteggz(index) {
        this.LineCityScen.splice(index, 1)
      },
      changeSiteId(val) {
        this.getGuideCarGuideList(val) //导游下拉
        this.addMsg.GuideId = ''
      },
      changeCarId(val) {
        this.addMsg.CarColorId = '';
        this.CarList.forEach(x => {
          if (x.ID == val) {
            this.CarColorList = x.ColorList
          }
        })
      },
      changeCarColorList(val) {
      },
      changeEnumList(val) {
        this.EnumType = val
      },
      getSupplierList() {
        this.apipost("/api/Supplier/GetSupplierAllList", {}, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.options = res.data.data;
          }
        });
      },
      getAllGuideCarSiteList() { //获取站点下拉
        this.apipost("/api/GuideCar/GetAllGuideCarSiteList", {}, res => {
          if (res.data.resultCode == 1) {
            this.SiteList = res.data.data
          }
        });
      },
      getGuideCarList() {
        this.apipost("/api/GuideCar/GetGuideCarList", {}, res => {
          if (res.data.resultCode == 1) {
            this.CarList = res.data.data;
          }
        });
      },
      getOrderListExportEnumList() { //获取服务类型枚举列表
        this.apipost("/api/GuideCar/GetOrderListExportEnumList", {}, res => {
          if (res.data.resultCode == 1) {
            this.EnumList = res.data.data;
          }
        });
      },

      getGuideCarGuideList(ID) {
        this.apipost("/api/GuideCar/GetGuideCarGuideList", {
          SiteId: ID
        }, res => {
          if (res.data.resultCode == 1) {
            this.GuideList = res.data.data
          }
        });
      },
      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;
                  }
                }
              })
            }
          }
        });

      },
      //追加日期
      SaveDate() {
        this.apipost("/api/GuideCar/GetGoodsTargetDateList", this.dateMsg, res => {
          if (res.data.resultCode == 1) {
            var myArr = res.data.data;
            //遍历当前数组
            for (var i = 0; i < myArr.length; i++) {
              //如果当前数组的第i已经保存进了临时数组，那么跳过，
              //否则把当前项push到临时数组里面
              if (this.subDateList.indexOf(myArr[i]) == -1) {
                this.subDateList.push(myArr[i]);
              }
            }
            //日期升序排列
            this.subDateList.sort(function (a, b) {
              return Date.parse(a) - Date.parse(b);
            });
          } else {
            this.Error(res.data.message);
          }
        });
      },
      //删除标签
      handleClose(index) {
        this.subDateList.splice(index, 1);
      },
       //获取上架版面下拉
      getCateList(){
         this.apipost("/api/Product/GoodsPageTypeEnumList", {}, res => {
          if (res.data.resultCode == 1) {
            this.My_cateList=res.data.data;
          }else{
            this.Error(res.data.message);
          }
        });
      },
      //选择上架版面
      getGoodType(num){
        if(num!=0){
          this.addMsg.CategoryList=[];
        }
        this.getTree()
      }
    }
  };

</script>
<style>
  .app-attr-group .close {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 16px;
    cursor: pointer;
  }

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

  .directorGoodsEdit .pendSelect {
    width: 100px;
  }

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

  .directorGoodsEdit .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;
  }

  .directorGoodsEdit .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;
  }

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

  .directorGoodsEdit .close {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 16px;
    cursor: pointer;
  }

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

  .directorGoodsEdit .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;
  }

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

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

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

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

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

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

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

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

  .directorGoodsEdit .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;
  }

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

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

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

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

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

  .directorGoodsEdit .fen-sumg {
    margin: 20px 0;
    font-size: 12px;
  }

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

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

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

  .edui1_imagescale img {
    max-width: 100%;
  }

  .directorGoodsEdit .nav_Main {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .directorGoodsEdit .nav_IconContent {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .directorGoodsEdit .nav_IconContent div>div {
    display: inline-block;
  }

  .directorGoodsEdit .w90 {
    width: 90px !important;
  }

  .directorGoodsEdit .w130 {
    width: 130px !important;
  }

</style>
