<template>
  <div class="right-wrap">
    <topNavNew :navpath="navpath"></topNavNew>
    <div class="right-content">
      <div class="right-box">
        <div class="attention-wrap">
          <div class="form-wrap">
            <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm" :rules="rules">
              <dm-sub-title type="fill" text="基本信息" style="margin-bottom: 20px;"/>
              <el-form-item label="策略名称:" prop="strategyName">
                <el-input
                  placeholder="请输入策略名称"
                  v-model="ruleForm.strategyName"
                  class="w-340"
                  @keyup.native="value => toInput(value)"
                >
                  <!-- <template slot="append"><label class="input-label">{{cateNameLength}}/20</label></template> -->
                </el-input>
                <label class="input-label">{{ cateNameLength }}/20</label>
              </el-form-item>
              <dm-sub-title type="fill" text="渠道配置" style="margin-bottom: 20px; margin-top:40px;"/>
              <template v-for="(item, index) in ruleForm.channelList">
                <!-- 线下渠道 -->
                <template v-if="item.channelType == 3">
                  <el-form-item label="线下渠道:" prop="" :key="index">
                    <el-switch v-model="item.openStatus"></el-switch>
                    <span style="color: #909399;font-size:12px; margin-left:16px;">客户在线下门店产生的订单</span>
                  <div class="form-child" v-if="item.openStatus" :key="index">
                    <el-form-item label="消费门店:" prop="region">
                      <dm-store-selector
                        :scenesVal="scencs"
                        :options="options"
                        :isAdd="isAdd"
                        :uuid.sync="uuid"
                        :isClique="true"
                        ref="storeGroup"
                        :readonly="opendisabled3"
                      ></dm-store-selector>
                    </el-form-item>
                    <el-form-item label="适用商品:" prop="name" class="margin-20">
                      <el-select
                      :disabled="opendisabled3"
                      class=" w215"
                        v-model="item.channelRelationProType"
                        placeholder="请选择"
                        @change="changeGood($event)"
                      >
                        <el-option
                          v-for="item in applyGoods"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                      <!-- 二级 -->
                      <span
                      :disabled="opendisabled3"
                        class="span-txt"
                        ref="treeinput"
                        v-if="item.channelRelationProType == 2"
                        @click="toggle('brand')"
                      >已选择 {{ item.strategyGoodsRelationIdArr ? item.strategyGoodsRelationIdArr.length : 0 }} 个品牌</span>
                      <span
                        class="span-txt"
                        ref="treeinput"
                        v-if="item.channelRelationProType == 3"
                        @click="toggle('brand')"
                      >已选择 {{ item.strategyGoodsRelationIdArr ? item.strategyGoodsRelationIdArr.length : 0 }} 个品类</span>
                      <treeselect
                      :disabled="opendisabled3"
                        v-if="item.channelRelationProType == 2 || item.channelRelationProType == 3"
                        placeholder
                        noOptionsText="暂无数据"
                        noResultsText="无数据"
                        noChildrenText="暂无数据"
                        :multiple="true"
                        :flat="true"
                        :always-open="goodsOpen"
                        :options="goodsTreeOptions"
                        :load-options="loadOptions"
                        :normalizer="goodNormalizer"
                        :value-consists-of="valueConsistsOf"
                        v-model="item.strategyGoodsRelationIdArr"
                      />
                      <!--:default-expand-level="1":load-options="loadOptions" :normalizer="normalizer" :always-open="goodsOpen" -->
                      <el-button
                      :disabled="opendisabled3"
                        v-if="item.channelRelationProType == 4"
                        @click="showGoodsDialog"
                      >已选0件商品</el-button>
                    </el-form-item>
                    <el-form-item label="折扣控制:" prop="region" class="margin-20 padding-bottom-20">
                      <div class="radio-cell">
                        <el-radio v-model="item.integralUseDiscountControl" label="1" @change="radioEventN(0)">所有折扣商品都适用</el-radio>
                      </div>
                      <div class="radio-cell margin-20">
                        <el-radio class="zk0" v-model="item.integralUseDiscountControl" label="2">折扣</el-radio>
                        <!-- <el-input v-model="item.integralUseDiscountControlLower" @focus="inputFocus(item)"  @keyup.native="formatInput($event)"></el-input> -->
                        <el-input-number
                          v-model="item.integralUseDiscountControlLower"
                          placeholder="请输入"
                          :precision="2"
                          :controls="false"
                          :max="10.0"
                          :min="1"
                        ></el-input-number>
                        <label>至</label>
                        <!-- <el-input v-model="item.integralUseDiscountControlUpper" @focus="inputFocus(item)"  @keyup.native="formatInput($event)"></el-input> -->
                        <el-input-number
                          v-model="item.integralUseDiscountControlUpper"
                          placeholder="请输入"
                          :precision="2"
                          :controls="false"
                          :max="10.0"
                          :min="1"
                        ></el-input-number>
                        <label>折商品都适用</label>
                        <span
                          style="font-size: 12px;color: #828282;line-height: 1;padding-left: 10px;"
                        >折扣范围1-10，填写8.8，则表示“打8.8折”，也即商品原价*8.8/10=商品折后价</span>
                      </div>
                    </el-form-item>
                  </div>
                  </el-form-item>
                </template>

                <template v-if="item.channelType == 1">
                  <!-- 微信商城 -->
                  <el-form-item label="达摩微商城" prop="" :key="index">
                    <el-switch v-model="item.openStatus"></el-switch>
                    <span style="color: #909399;font-size:12px; margin-left:16px;">客户在达摩微商城产生的订单</span>
                  <div class="form-child margin-20" v-if="item.openStatus == true" :key="index">
                    <el-form-item label="选择商户:">
                      <el-select
                      class="w215"
                        size="small"
                        v-model="item.enterpriseRelationIdArr"
                        placeholder="请选择"
                        multiple
                      >
                        <el-option
                          v-for="(item, ind) in mechantOption"
                          :key="ind"
                          :label="item.label"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>

                    <el-form-item label="适用商品:" class="margin-20">
                      <el-select
                      :disabled="opendisabled1"
                      class="w215"
                        v-model="item.channelRelationProType"
                        placeholder="请选择"
                        @change="changeGood($event)"
                      >
                        <el-option
                          v-for="item in applyGoods"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                      <!-- 二级 -->
                      <span
                      :disabled="opendisabled1"
                        class="span-txt"
                        ref="treeinput"
                        v-if="item.channelRelationProType == 2"
                        @click="toggle('wx')"
                      >已选择 {{ item.goodsRelationIds ? item.goodsRelationIds.length : 0 }} 个品牌</span>
                      <span
                      :disabled="opendisabled1"
                        class="span-txt"
                        ref="treeinput"
                        v-if="item.channelRelationProType == 3"
                        @click="toggle('wx')"
                      >已选择 {{ item.goodsRelationIds ? item.goodsRelationIds.length : 0 }} 个品类</span>
                      <treeselect
                      :disabled="opendisabled1"
                        v-if="item.channelRelationProType == 2 || item.channelRelationProType == 3"
                        placeholder
                        noOptionsText="暂无数据"
                        noResultsText="无数据"
                        noChildrenText="暂无数据"
                        :multiple="true"
                        :always-open="wxOpen"
                        :options="goodsTreeOptions"
                        :value-consists-of="valueConsistsOf"
                        v-model="item.goodsRelationIds"
                        :normalizer="goodNormalizer"
                        @select="selectWx($event, index, item)"
                      />
                      <!--model=item.strategyGoodsRelationIds和上一个相同会有问题 -->
                      <el-button
                      :disabled="opendisabled1"
                        v-if="item.channelRelationProType == 4"
                        @click="showGoodsDialog"
                      >已选0件商品</el-button>
                    </el-form-item>
                    <el-form-item label="折扣控制:" prop="region" class="margin-20 padding-bottom-20">
                      <div class="radio-cell">
                        <el-radio v-model="item.integralUseDiscountControl" label="1" @change="radioEventN(1)">所有折扣商品都适用</el-radio>
                      </div>
                      <div class="radio-cell margin-20">
                        <el-radio class="zk1" v-model="item.integralUseDiscountControl" label="2">折扣</el-radio>
                        <!-- <el-input v-model="item.integralUseDiscountControlLower" @focus="inputFocus(item)"  @keyup.native="formatInput($event)"></el-input> -->
                        <el-input-number
                          v-model="item.integralUseDiscountControlLower"
                          placeholder="请输入"
                          :precision="2"
                          :controls="false"
                          :max="10.0"
                          :min="1"
                        ></el-input-number>
                        <label>至</label>
                        <!-- <el-input v-model="item.integralUseDiscountControlUpper" @focus="inputFocus(item)"  @keyup.native="formatInput($event)"></el-input> -->
                        <el-input-number
                          v-model="item.integralUseDiscountControlUpper"
                          placeholder="请输入"
                          :precision="2"
                          :controls="false"
                          :max="10.0"
                          :min="1"
                        ></el-input-number>
                        <label>折商品都适用</label>
                        <span style="font-size: 12px;color: #828282;line-height: 1;padding-left: 10px;">折扣范围1-10，填写8.8，则表示“打8.8折”，也即商品原价*8.8/10=商品折后价</span>
                      </div>
                    </el-form-item>
                  </div>
                  </el-form-item>
                </template>

                <template v-if="false">
                  <!-- 第三方 -->
                  <el-form-item label="第三方电商渠道" prop="" :key="index">
                    <el-switch v-model="item.openStatus" active-text="启用" inactive-text="停用"> </el-switch>
                  <div class="form-child margin-20" v-if="item.openStatus == true" :key="index">
                    <el-form-item label="选择店铺">
                      <el-select v-model="item.channelRelationStoreType" placeholder="请选择">
                        <el-option v-for="item in allShopOption" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                      </el-select>
                    </el-form-item>

                    <el-form-item label="天猫商品" class="padding-0">
                      <el-select v-model="item.channelRelationProType" placeholder="请选择">
                        <el-option v-for="item in allGoodOption" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                      </el-select>
                      <!-- 二级 -->
                      <!--  <treeselect
                      v-if="item.thirdApplyTmallGoods==1||item.thirdApplyTmallGoods==2"
                      placeholder="所有分类"
                      noOptionsText="暂无数据"
                      noResultsText="无数据"
                      :multiple="true"
                      :options="wxTreeOptions"
                      :value-consists-of="valueConsistsOf"
                      v-model="item.thirdApplyTmallGoodsIds"
                      />
                      <el-button v-if="item.thirdApplyTmallGoods==3" @click="showGoodsDialog">已选0件商品</el-button> -->
                    </el-form-item>

                    <el-form-item label="折扣控制" prop="region">
                      <div class="radio-cell">
                        <el-radio v-model="item.integralUseDiscountControl" label="1" >所有折扣商品都适用</el-radio>
                        <el-radio v-model="item.integralUseDiscountControl" label="1" >所有折扣商品都适用</el-radio>
                      </div>
                      <div class="radio-cell margin-20">
                        <el-radio v-model="item.integralUseDiscountControl" label="2">折扣</el-radio>
                        <!-- <el-input v-model="item.integralUseDiscountControlLower" @focus="inputFocus(item)"  @keyup.native="formatInput($event)"></el-input> -->
                        <el-input-number v-model="item.integralUseDiscountControlLower" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="0.01"></el-input-number>
                        <label>至</label>
                        <!-- <el-input v-model="item.integralUseDiscountControlUpper" @focus="inputFocus(item)"  @keyup.native="formatInput($event)"></el-input> -->
                        <el-input-number v-model="item.integralUseDiscountControlUpper" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="0.01"></el-input-number>
                        <label>折商品都适用</label>
                        <span style="font-size: 13px;color: #828282;line-height: 1;padding-left: 10px;">注意：折扣范围0.01-10.00，最低折扣不能大于最高折扣</span>
                      </div>
                    </el-form-item>
                  </div>
                  </el-form-item>
                </template>
                <!-- 微盟渠道-->
                <template v-if="item.channelType == 9">
                  <el-form-item label="微盟渠道:" prop="" :key="index">
                    <el-switch v-model="item.openStatus"> </el-switch>
                    <span style="color: #909399;font-size:12px; margin-left:16px;">客户在微盟微商城产生的订单</span>
                  <div class="form-child margin-20" v-if="item.openStatus == true" :key="index">
                    <el-form-item label="选择商户:">
                      <el-select size="small" v-model="item.enterpriseRelationIdArr" placeholder="请选择" multiple class="w215">
                        <el-option v-for="(item, ind) in mechantOption" :key="ind" :label="item.label" :value="item.value"> </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="选择店铺:" class="margin-20">
                      <el-select v-model="storeValue" v-if="!isJinHua" class="w215">
                        <el-option label="所有门店" value=""></el-option>
                      </el-select>
                      <vue-gic-store-new :disabled="opendisabled9" v-else :scenesVal="scencs" :options="options" :isAdd="isAdd" :uuid.sync="wmuuid" ref="wmstoreGroup"></vue-gic-store-new>
                    </el-form-item>
                    <el-form-item label="微盟商品:" class="margin-20">
                      <el-select :disabled="opendisabled9" v-model="item.channelRelationProType" placeholder="请选择" class="w215">
                        <el-option v-for="item in wMGoodOption" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="折扣控制:" prop="region" class="input-margin-b margin-20 padding-bottom-20">
                      <div class="radio-cell">
                        <el-radio v-model="item.integralUseDiscountControl" label="1" @change="radioEventN(2)">所有折扣商品都适用</el-radio>
                      </div>
                      <div class="radio-cell margin-20">
                        <el-radio class="zk2" v-model="item.integralUseDiscountControl" label="2">折扣</el-radio>
                        <el-input-number v-model="item.integralUseDiscountControlLower" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>至</label>
                        <el-input-number v-model="item.integralUseDiscountControlUpper" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>折商品都适用</label>
                        <span style="font-size: 12px;color: #828282;line-height: 1;padding-left: 10px;">折扣范围1-10，填写8.8，则表示“打8.8折”，也即商品原价*8.8/10=商品折后价</span>
                      </div>
                    </el-form-item>
                  </div>
                  </el-form-item>
                </template>
                <!-- 天猫渠道-->
                <template v-if="item.channelType == 8">
                  <el-form-item label="天猫渠道:" prop="" :key="index">
                    <el-switch v-model="item.openStatus"> </el-switch>
                    <span style="color: #909399;font-size:12px; margin-left:16px;">客户在天猫店铺产生的订单</span>
                  <div class="form-child margin-20" v-if="item.openStatus == true" :key="index">
                    <el-form-item label="选择商户:">
                      <el-select size="small" v-model="item.enterpriseRelationIdArr" placeholder="请选择" multiple class="w215">
                        <el-option v-for="(item, ind) in mechantOption" :key="ind" :label="item.label" :value="item.value"> </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="折扣控制:" prop="region" class="input-margin-b margin-20 padding-bottom-20">
                      <div class="radio-cell">
                        <el-radio v-model="item.integralUseDiscountControl" label="1" @change="radioEventN(3)">所有折扣商品都适用</el-radio>
                      </div>
                      <div class="radio-cell margin-20">
                        <el-radio class="zk3" v-model="item.integralUseDiscountControl" label="2">折扣</el-radio>
                        <el-input-number v-model="item.integralUseDiscountControlLower" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>至</label>
                        <el-input-number v-model="item.integralUseDiscountControlUpper" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>折商品都适用</label>
                        <span style="font-size: 12px;color: #828282;line-height: 1;padding-left: 10px;">折扣范围1-10，填写8.8，则表示“打8.8折”，也即商品原价*8.8/10=商品折后价</span>
                      </div>
                    </el-form-item>
                  </div>
                  </el-form-item>
                </template>
                <!-- 抖音渠道-->
                <template v-if="item.channelType == 11">
                  <el-form-item label="抖音渠道:" prop="" :key="index">
                    <el-switch v-model="item.openStatus"> </el-switch>
                    <span style="color: #909399;font-size:12px; margin-left:16px;">客户在抖音店铺产生的订单</span>
                  <div class="form-child margin-20" v-if="item.openStatus == true" :key="index">
                    <el-form-item label="选择商户:">
                      <el-select size="small" v-model="item.enterpriseRelationIdArr" placeholder="请选择" multiple class="w215">
                        <el-option v-for="(item, ind) in mechantOption" :key="ind" :label="item.label" :value="item.value"> </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="折扣控制:" prop="region" class="input-margin-b margin-20 padding-bottom-20">
                      <div class="radio-cell">
                        <el-radio v-model="item.integralUseDiscountControl" label="1" @change="radioEventN(4)">所有折扣商品都适用</el-radio>
                      </div>
                      <div class="radio-cell margin-20">
                        <el-radio class="zk4" v-model="item.integralUseDiscountControl" label="2">折扣</el-radio>
                        <el-input-number v-model="item.integralUseDiscountControlLower" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>至</label>
                        <el-input-number v-model="item.integralUseDiscountControlUpper" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>折商品都适用</label>
                        <span style="font-size: 12px;color: #828282;line-height: 1;padding-left: 10px;">折扣范围1-10，填写8.8，则表示“打8.8折”，也即商品原价*8.8/10=商品折后价</span>
                      </div>
                    </el-form-item>
                  </div>
                  </el-form-item>
                </template>
                <!-- 其他渠道-->
                <template v-if="item.channelType == 10">
                  <el-form-item label="其他渠道:" prop="" :key="index">
                    <el-switch v-model="item.openStatus"> </el-switch>
                    <span style="color: #909399;font-size:12px; margin-left:16px;">客户在其他渠道产生的订单</span>
                  <div class="form-child margin-20" v-if="item.openStatus == true" :key="index">
                    <el-form-item label="选择商户:">
                      <el-select size="small" v-model="item.enterpriseRelationIdArr" placeholder="请选择" multiple class="w215">
                        <el-option v-for="(item, ind) in mechantOption" :key="ind" :label="item.label" :value="item.value"> </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="折扣控制:" prop="region" class="input-margin-b margin-20 padding-bottom-20">
                      <div class="radio-cell">
                        <el-radio v-model="item.integralUseDiscountControl" label="1" @change="radioEventN(5)">所有折扣商品都适用</el-radio>
                      </div>
                      <div class="radio-cell margin-20">
                        <el-radio class="zk5" v-model="item.integralUseDiscountControl" label="2">折扣</el-radio>
                        <el-input-number v-model="item.integralUseDiscountControlLower" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>至</label>
                        <el-input-number v-model="item.integralUseDiscountControlUpper" placeholder="请输入" :precision="2" :controls="false" :max="10.0" :min="1"></el-input-number>
                        <label>折商品都适用</label>
                        <span style="font-size: 12px;color: #828282;line-height: 1;padding-left: 10px;">折扣范围1-10，填写8.8，则表示“打8.8折”，也即商品原价*8.8/10=商品折后价</span>
                      </div>
                    </el-form-item>
                  </div>
                  </el-form-item>
                </template>
              </template>
               <dm-sub-title text="规则配置" type="fill" style="margin: 40px 0 20px"></dm-sub-title>
              <el-form-item label="适用对象:" prop="useCrowd" class="margin-20">
                <el-radio-group v-model="ruleForm.useCrowd">
                  <el-radio :disabled="true" v-for="item in applyObjOption" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="人群定向" v-if="ruleForm.useCrowd == 2" prop="" class="padding-0">
                <el-button :disabled="true" style="width: 214px;" @click="showPeople">已设置{{ selectCount }}项筛选</el-button>
              </el-form-item>
              <el-form-item label="获取规则:" prop="integralGetStatus">
                <div>
                  <el-radio v-model="ruleForm.integralGetStatus" label="0" @change="radioEvent">不获取积分</el-radio>
                </div>
                <div class="margin-20">
                  <el-radio v-model="ruleForm.integralGetStatus" label="1">每消费</el-radio>
                  <!-- <el-input v-model="ruleForm.integralGet.fee" @blur="formatInputNumBlur($event)"></el-input> -->
                  <el-input-number v-model="ruleForm.integralGet.fee" placeholder="请输入"  :precision="1" :controls="false" :max="10000.0" :min="0.1"></el-input-number>
                  <label>元，获取 </label>
                  <!-- <el-input v-model="ruleForm.integralGet.integral" @blur="formatInputNumBlur($event)"></el-input> -->
                  <el-input-number v-model="ruleForm.integralGet.integral" placeholder="请输入" step-strictly  :controls="false"></el-input-number>
                  <label>积分。取整策略为</label>
                  <el-select v-model="ruleForm.integralGetStrategy" placeholder="请选择" style="width:115px;">
                    <el-option v-for="item in cateOptions" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                  </el-select>
                  <p style="color: #909399;font-size:12px;">例：根据消费金额计算出积分为4.3，选择「四舍五入」和「抹零」时为4积分，选择「进位制」则为5积分</p>
                </div>
              </el-form-item>
              <el-form-item label="积分冻结期:" v-if="ruleForm.integralGetStatus == 1" prop="integralGetFreezeDays">
                <label>自获取之日起</label><el-input v-model="ruleForm.integralGetFreezeDays" @keyup.native="formatInputNum($event)"></el-input><label>天</label>
                <span style="font-size: 12px;color: #828282;line-height: 1;padding-left: 10px;">仅对通过订单获取的积分生效，活动类获取的积分没有冻结期</span>
              </el-form-item>
              <el-form-item label="积分有效期:" prop="userGeneralIntegralExpireRule">
                <el-radio  v-model="ruleForm.userGeneralIntegralExpireRule" @change="radiouserGeneralIntegralExpireRule" :label="1">通用积分策略有效期</el-radio>
                <el-radio v-model="ruleForm.userGeneralIntegralExpireRule" @change="radiouserGeneralIntegralExpireRule" :label="0">自定义有效期
                  <el-tooltip placement="right" effect="light">
                    <div slot="content" style="line-height:20px">
                      <p style="color:#595959 font-size:14px;font-weight:600">规则说明：</p>
                      <p style="color:#e6a23c">
                        仅GIC计算积分时，配置的积分有效期才会生效，<br/>
                        ERP计算积分时，此配置项不生效；
                      </p>
                      <ul>
                        <li>1、永久有效：客户获取的积分永久有效，系统不会清零；</li>
                        <li>2、按年失效：在第X年的X月X日失效：例：设置第二年的12月1日失效，则2021年获取的所有积分在2022年12月1日失效；</li>
                        <li>3、按月失效：在第X个月的X日失效：例：设置第二月的1日失效，则3月获取的所有积分在4月1日失效；</li>
                        <li>4、按天失效：每天获取的所有积分在获取之日起365天后失效：例：设置365天，则2022年12月1号获取的积分在2023年12月1号失效；</li>
                        <li>5、修改积分有效期后，已经获取的积分有效期不变，后续获取的积分按照修改后的积分有效期生效；</li>
                      </ul>
                    </div>
                    <i class="iconfont icon-QuestionCircleOutlined" style="font-size:12px;color:#606266;"></i>
                  </el-tooltip>
                </el-radio>
                <!-- 通用积分有效期 -->
                 <div  v-if="ruleForm.userGeneralIntegralExpireRule == 1">
                  <div class="radio-cell" v-if="timeType == 1">
                    <el-radio  v-model="ruleForm.integralExpireType" label="1" @change="radioExpireType1" disabled="true">永久有效</el-radio>
                  </div>
                  <div class="radio-cell" v-else-if="timeType == 2">
                    <el-radio  v-model="ruleForm.integralExpireType" label="2" disabled="true"><label>按年失效：</label></el-radio>
                    <label>每年获取的所有积分，在</label>
                    <el-select v-model="yearYT" placeholder="请选择" style="width:120px;margin-right:20px" disabled="true">
                      <el-option v-for="n in yearList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>的</label>
                    <el-select v-model="yearMT" placeholder="请选择" style="width:120px;margin-right:20px" disabled="true">
                      <el-option v-for="n in 12" :key="n" :label="n" :value="n"></el-option>
                    </el-select>
                    <label>月</label>
                    <el-select v-model="yearDT" placeholder="请选择" style="width:120px;margin-right:20px" disabled="true">
                      <el-option v-for="n in dayList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>日失效</label>
                  </div>
                  <div class="radio-cell" v-else-if="timeType == 3">
                    <el-radio  v-model="ruleForm.integralExpireType" label="3" disabled="true"><label>按月失效：</label></el-radio>
                    <label>每月获取的所有积分，在</label>
                    <el-select v-model="mouthMT" placeholder="请选择" style="width:120px;margin-right:20px" disabled="true">
                      <el-option  v-for="n in mouthList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>的</label>
                    <el-select v-model="mouthDT" placeholder="请选择" style="width:120px; margin-right:20px" disabled="true">
                      <el-option v-for="n in dayList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>日失效</label>
                  </div>
                  <div class="radio-cell" v-else-if="timeType == 0 || timeType == null">
                    <el-radio  v-model="ruleForm.integralExpireType" label="0" disabled="true">
                    <label>每天获取的所有积分，在获取之日起</label></el-radio>
                    <el-input placeholder="请输入" style="width:115px" v-model="effectiveDays" @keyup.native="formatInput($event)" disabled="true"></el-input>
                    <label>天后失效</label>
                    <span style="font-size: 12px;color: #909399;line-height: 1;padding-left: 10px;">建议不超过3年(1095天)</span>
                  </div>
                  <div class="radio-cell" v-else>
                    <p style="color:red;">还未配置通用积分策略，请先配置通用积分策略再选择「通用积分策略有效期」</p>
                  </div>
                </div>
                <!-- 自定义有效期 -->
                <div class="form-child" style="padding:20px" v-if="ruleForm.userGeneralIntegralExpireRule == 0">
                  <div class="radio-cell mb20">
                    <el-radio  v-model="ruleForm.integralExpireType" :label="2" @change="radioExpireType1">按年失效：</el-radio>
                    <label>每年获取的所有积分，在</label>
                    <el-select v-model="yearY" placeholder="请选择" class="selectwm">
                      <el-option v-for="n in yearList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>的</label>
                    <el-select v-model="yearM" placeholder="请选择" class="selectwm">
                      <el-option v-for="n in 12" :key="n" :label="n" :value="n"></el-option>
                    </el-select>
                    <label>月</label>
                    <el-select v-model="yearD" placeholder="请选择" class="selectwm">
                      <el-option v-for="n in dayList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>日失效</label>
                  </div>
                  <div class="radio-cell mb20">
                    <el-radio  v-model="ruleForm.integralExpireType" :label="3" @change="radioExpireType1">按月失效：</el-radio>
                    <label>每月获取的所有积分，在</label>
                    <el-select v-model="mouthM" placeholder="请选择" class="selectwm">
                      <el-option  v-for="n in mouthList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>的</label>
                    <el-select v-model="mouthD" placeholder="请选择" class="selectwm">
                      <el-option v-for="n in dayList" :key="n.key" :label="n.value" :value="n.key"></el-option>
                    </el-select>
                    <label>日失效</label>
                  </div>
                  <div class="radio-cell">
                    <el-radio  v-model="ruleForm.integralExpireType" :label="0" @change="radioExpireType1">按天失效：</el-radio>
                    <label>每天获取的所有积分，在获取之日起</label>
                    <el-input placeholder="请输入" style="width:115px" v-model="ruleForm.integralGetEffectiveDays" @keyup.native="formatInput($event)"></el-input>
                    <label>天后失效</label>
                    <span style="font-size: 12px;color: #909399;line-height: 1;padding-left: 10px;">建议不超过3年(1095天)</span>
                  </div>
                </div>
              </el-form-item>
              <!-- 新增策略有效期配置 -->
              <el-form-item label="策略有效期:" prop="perpetualFlag">
                <!-- 1 永久 0 非永久 -->
                <el-radio v-model="ruleForm.perpetualFlag" :label="1">永久有效</el-radio>
                <el-radio v-model="ruleForm.perpetualFlag" :label="0">在该时段内有效</el-radio>
                <div style="marginTop:10px;">
                  <el-date-picker
                    v-if="ruleForm.perpetualFlag === 0"
                    v-model="ruleForm.perpetualDate"
                    type="datetimerange"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    format="yyyy-MM-dd HH:mm:ss"
                    value-format="timestamp"
                    :default-time="['00:00:00', '23:59:59']"
                  ></el-date-picker>
                </div>
              </el-form-item>
              <!-- <el-form-item>
                <el-button :disabled="tpnEditBool" type="primary" @click.stop="submitForm('ruleForm')">保 存</el-button>
                <el-button @click="goBack">返 回</el-button>
              </el-form-item> -->
            </el-form>
            <div class="bottom">
               <el-button :disabled="tpnEditBool" type="primary" @click.stop="submitForm('ruleForm')" style="margin:13px 0 0 -220px;">保 存</el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <vue-gic-footer></vue-gic-footer> -->
    <!-- 添加商品 -->
    <add-goods :goodShow="goodShow" :projectName="repProjectName" @selectGoods="selectGoods"></add-goods>
    <!-- 人群筛选器的弹框 -->
    <el-dialog title="自定义人群" :visible.sync="dialogVisiblePeople" :close-on-click-modal="false" width="980px">
      <div class="select-people">
        <vue-gic-group-people
          :useId="useId"
          :hasSearchData="hasSearchData"
          :sceneValue="sceneValue"
          ref="peopleFilter"
          @findFilter="findFilter"
          @getBackData="getBackData"
          @editHide="editHide"
          @editShow="editShow"
          @hideBtn="hideBtn"
        ></vue-gic-group-people>
        <div v-show="toggleTag" class="people-btn-wrap">
          <el-row>
            <el-button @click="getData" type="primary" size="small">确定</el-button>
            <el-button @click="cancelFilter" size="small">取消</el-button>
          </el-row>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-row>
          <el-button :disabled="true" @click="dialogVisiblePeople = false">取 消</el-button>
          <el-button :disabled="true" type="primary" @click="getPeopleData">确 定</el-button>
        </el-row>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import topNavNew from 'components/nav/navNew';
import addGoods from 'components/memberShip/add-goods';
import Treeselect from '@riophae/vue-treeselect';
// import the styles
import '@riophae/vue-treeselect/dist/vue-treeselect.css';

import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
import { postRequest, postJson } from '@/api/api';
import strLength from '@/common/js/strlen';
import { log } from '@/utils/index.js';
import wmMixins from './strategy.js';
import { scrollToError } from '@/utils/validate';

const timeStramp = {
  year: new Date().getFullYear(),
  month: new Date().getMonth(),
  day: new Date().getDate()
};

export default {
  name: 'editPointSytem',
  mixins: [wmMixins],
  data() {
    // 天数
    const dayList = ()=> {
      let arr = []
      for(let i = 1; i < 28; i++){
        arr.push({key: i,value: i})
      }
      arr.push({key: '0', value: '月末'})
      return arr;
    }
    // 月数
    const mouthList = ()=> {
      let arr = []
      for(let i = 2; i < 37; i++){
        arr.push({key: i,value: `第${i}个月`})
      }
      return arr;
    }
    // 年数
    const yearList = ()=> {
      let arr = []
      for(let i = 2; i < 5; i++){
        arr.push({key: i,value: `第${i}年`})
      }
      return arr;
    }
    return {
      scrollToError,
      opendisabled3: false,
      opendisabled1: false,
      opendisabled9: false,
      yearYT: '', //按年失效 年
      yearMT: '', //按年失效 月
      yearDT: '', //按年失效 日
      mouthMT: '', //按月失效 月
      mouthDT: '', //按月失效 月
      effectiveDays: '',
      timeType: '',
      timeRuleType: '',
      dayList: dayList(),
      mouthList: mouthList(),
      mouthM: '', //按月失效 月
      mouthD: '', //按月失效 月
      yearList: yearList(),
      yearY: '', //按年失效 年
      yearM: '', //按年失效 月
      yearD: '', //按年失效 日
      repProjectName: 'gic-clique',
      navpath: [
        {
          name: '集团管理',
          path: ''
        },
        {
          name: '会员制度',
          path: ''
        },
        {
          name: '积分制度',
          path: '/pointSystem'
        },
        {
          name: '编辑积分获取策略',
          path: ''
        }
      ],
      // 添加商品弹窗
      goodShow: false,
      // 输入字限制
      inputFlagNum: 20,

      // 门店
      StoreOptions: [
        {
          label: '所有门店',
          value: '1'
        },
        {
          label: '门店分组',
          value: '2'
        },
        {
          label: '部分门店',
          value: '3'
        }
      ],
      StoreTypeOptions: [
        {
          label: '所有门店',
          value: '-1'
        },
        {
          label: '自营',
          value: '0'
        },
        {
          label: '联营',
          value: '1'
        },
        {
          label: '加盟',
          value: '2'
        },
        {
          label: '代销',
          value: '3'
        },
        {
          label: '托管',
          value: '4'
        }
      ],
      applyGoods: [
        {
          label: '所有商品',
          value: '1'
        }
      ],
      // tree
      openOnFocus: true,
      alwaysOpen: false,
      goodsOpen: false,
      wxOpen: false,
      valueConsistsOf: 'ALL',
      treeOptions: [],
      storeNormalizer(node) {
        return {
          id: node.storeGroupId,
          label: node.storeGroupName,
          children: node.children
        };
      },
      // 适用商品
      goodsTreeOptions: [],
      goodNormalizer(node /*, id */) {
        // there is an extra `id` argument,
        // which could be useful if you have multiple instances
        // of vue-treeselect that share the same `normalizer` function
        log(node);
        return {
          id: node.key,
          label: node.name,
          children: node.subOptions
        };
      },

      // wxTreeOptions
      wxTreeOptions: [],
      // 商户
      mechantOption: [],
      // 第三方下拉
      allShopOption: [
        {
          label: '所有店铺',
          value: '1'
        }
      ],
      allGoodOption: [
        {
          label: '所有商品',
          value: '1'
        }
      ],
      // 微盟渠道
      wMShopOption: [
        {
          label: '所有店铺', // 就是所有门店
          value: '1'
        }
      ],
      wMGoodOption: [
        {
          label: '所有商品',
          value: '1'
        }
      ],
      storeListOptions: [], //下拉搜索出现的门店列表
      // 适用对象
      applyObjOption: [
        {
          label: '所有会员',
          value: '1'
        },
        {
          label: '自定义人群',
          value: '2'
        }
      ],
      // 长度
      cateNameLength: 0,
      rules: {
        strategyName: { required: true, message: '请输入策略名称', trigger: 'blur' },
        useCrowd: { required: true, message: '请选择适用对象', trigger: 'blur' },
        integralGetStatus: { required: true, message: '请选择获取规则', trigger: 'blur' },
        integralGetFreezeDays: { required: true, message: '请输入积分冻结期', trigger: 'blur' },
        userGeneralIntegralExpireRule: { required: true, message: '请输入有效期类型', trigger: 'blur' },
        perpetualFlag: { required: true, message: '请选择策略有效期', trigger: 'blur' }
      },

      ruleForm: {
        userGeneralIntegralExpireRule: 1,
        integralExpireType: '1', //积分有效期类型 0 未默认滚动到期 1永久 2 按年失效 3按月失效
        integralExpireRule: '', //积分有效期规则 年 x(年),x(月),x(日，为0标识月末)  月,x(月),x(日，为0标识月末)
        // 积分获取规则
        integralStrategyId: 'ff80808163a7a09b0163b01171e202db', //策略id
        enterpriseId: 'ff8080815dacd3a2015dacd3ef5c0000',
        strategyName: 1, //策略名称
        strategyType: 1, // 策略类型 1消费积分 2积分抵现
        useCrowd: 1, // 策略类型 1所有 2人群筛选
        crowdJson: '', //人群筛选器内容
        integralGetStatus: '1', // 积分获取开启 1是0否
        integralGet: { fee: undefined, integral: undefined },
        integralGetStrategy: '1', // 取整策略 1四舍五入 2抹零 3向上取整
        integralGetFreezeDays: 1, // 获取积分冻结天数
        integralGetEffectiveDays: '', // 获取积分有效天
        integralUseStatus: 0, // 积分抵现开启 1是0否
        // integralUse: { fee: undefined, integral: undefined }, // 积分抵现 {fee:5,integral:5}
        perpetualFlag: 1,
        channelList: [],
        perpetualDate: [
          new Date(timeStramp.year, timeStramp.month, timeStramp.day, 0, 0, 0),
          new Date(timeStramp.year, timeStramp.month, timeStramp.day, 23, 59, 59)
        ]
      },
      cateOptions: [
        {
          value: '1',
          label: '四舍五入'
        },
        {
          value: '2',
          label: '抹零'
        },
        {
          value: '3',
          label: '进位制'
        }
      ],

      /* 人群筛选器 */
      dialogVisiblePeople: false,
      sceneValue: 'member', // 场景值
      useId: '',
      searchParams: '',
      hasSearchData: '', // 当前页回显的数据(接口返回)
      toggleTag: false,
      selectCount: 0,
      // 门店  新
      uuid: '', // 新增传空，编辑必传,
      options: [0, 1, 2, 3, 4, 5], // 0 全部 1 门店类型 2门店标签 3 门店区域 4 门店分组 5 部分门店
      isAdd: true,
      scencs: 'integral',
      wmuuid: '', // 微盟
      // 太平鸟标识
      tpnEditBool: false,
      tpnEnterpriseId: 'ff808081671d3ceb01672adebf4e6149'
    };
  },

  methods: {
    radiouserGeneralIntegralExpireRule(e) {
      if(e==1) {
        this.getPointInfo();
      }
    },
    // 获取通用积分策略
    getPointInfo() {
      var that = this
      postRequest('/api-admin/get-member-integral-setting',{requestProject: that.projectName})
        .then((res) => {
          var resData = res.data
          if(resData.errorCode == 0) {
            this.timeType = resData.result.memberIntegral.integralExpireType;
            this.timeRuleType = resData.result.memberIntegral.integralExpireRule.split(',');
            if(this.timeType ==2) {
              this.yearYT = Number(this.timeRuleType[0])
              this.yearMT = Number(this.timeRuleType[1])
              this.yearDT = this.timeRuleType[2]
            }else if(this.timeType == 3) {
              this.mouthMT = Number(this.timeRuleType[0])
              this.mouthDT = this.timeRuleType[1]
            } else if (this.timeType == 0 || this.timeType == null) {
              this.effectiveDays = resData.result.memberIntegral.integralGetEffectiveDays;
            }
          }
        })
    },
    radioEventN(n) {
      this.ruleForm.channelList[n].integralUseDiscountControlLower = undefined;
      this.ruleForm.channelList[n].integralUseDiscountControlUpper = undefined;
    },
    radioEvent() {
      this.ruleForm.integralGet.fee = undefined;
      this.ruleForm.integralGet.integral = undefined;
    },
    radioExpireType1(e) {
      if(e==0){
        this.yearY='';
        this.yearM='';
        this.yearD='';
        this.mouthM='';
        this.mouthD='';
      }else if(e==1) {
        this.yearY='';
        this.yearM='';
        this.yearD='';
        this.mouthM='';
        this.mouthD='';
        this.ruleForm.integralGetEffectiveDays = '';
      }else if (e==2) {
        this.mouthM='';
        this.mouthD='';
        this.ruleForm.integralGetEffectiveDays = '';
      } else if (e == 3) {
        this.yearY='';
        this.yearM='';
        this.yearD='';
        this.ruleForm.integralGetEffectiveDays = '';
      }
    },
    // 返回
    goBack() {
      this.$router.go(-1);
    },

    // 路由跳转
    changeRoute(route) {
      this.$router.push(route);
    },

    // input focus
    inputFocus(obj) {
      let that = this;
      that.tempData = obj;
    },

    // 输入框输入校验数字
    formatInput(e) {
      let that = this;
      that.tempData.integralUseDiscountControlLower = Number(String(that.tempData.integralUseDiscountControlLower).replace(/[^\.\d]/g, undefined)).toFixed(2) == 'NaN' ? '0.00' : Number(String(that.tempData.integralUseDiscountControlLower).replace(/[^\.\d]/g, undefined)).toFixed(2);
      that.tempData.integralUseDiscountControlUpper = Number(String(that.tempData.integralUseDiscountControlUpper).replace(/[^\.\d]/g, undefined)).toFixed(2) == 'NaN' ? '0.00' : Number(String(that.tempData.integralUseDiscountControlUpper).replace(/[^\.\d]/g, undefined)).toFixed(2);
    },
    formatInputNum(e) {
      let that = this;
      that.ruleForm.integralGetEffectiveDays = strLength.getCharVal(String(that.ruleForm.integralGetEffectiveDays).replace(/[^\d]/g, ''), 4);
      that.ruleForm.integralGetFreezeDays = strLength.getCharVal(String(that.ruleForm.integralGetFreezeDays).replace(/[^\d]/g, ''), 4);

      // that.ruleForm.integralGet.fee = strLength.getCharVal(String(that.ruleForm.integralGet.fee).replace(/[^\.\d]/g,''),6)
      // that.ruleForm.integralGet.integral = strLength.getCharVal(String(that.ruleForm.integralGet.integral).replace(/[^\d]/g, ''), 8);
    },

    formatInputNumBlur() {
      let that = this;
      that.ruleForm.integralGet.fee = Number(strLength.getCharVal(String(that.ruleForm.integralGet.fee).replace(/[^\.\d]/g, ), 6)).toFixed(1);
      // that.ruleForm.integralGet.integral = Number(strLength.getCharVal(String(that.ruleForm.integralGet.integral).replace(/[^\.\d]/g,''),8)).toFixed(1)
    },
    async checkListValue(data) {
      let obj = {
        flag: true,
        text: ''
      };
      if (!!data.channelList.length) {
        for (let i = 0; i < data.channelList.length; i++) {
          if (!!data.channelList[i].openStatus) {
            if (data.channelList[i].integralUseDiscountControl == 2) {
              if (!data.channelList[i].integralUseDiscountControlUpper || !data.channelList[i].integralUseDiscountControlLower) {
                obj.flag = false;
                this.scrollToError(this, `zk${i}`);
                obj.text = '请填写折扣';
              }
              if (parseInt(data.channelList[i].integralUseDiscountControlUpper) > 10 || parseInt(data.channelList[i].integralUseDiscountControlLower) > 10 || Number(data.channelList[i].integralUseDiscountControlUpper) <= Number(data.channelList[i].integralUseDiscountControlLower)) {
                obj.flag = false;
                this.scrollToError(this, `zk${i}`);
                obj.text = '折扣格式有误';
              }
            }
            if (data.channelList[i].channelType == 1 && !data.channelList[i].enterpriseRelationIdArr.length) {
              obj.flag = false;
              obj.text = '请选择商户';
            }
            if (data.channelList[i].channelType == 9 && !data.channelList[i].enterpriseRelationIdArr.length) {
              obj.flag = false;
              obj.text = '请选择商户';
            }
            if (data.channelList[i].channelType == 3) {
              const storeGroupDom = this.$refs.storeGroup;
              let flag = null;
              if (storeGroupDom instanceof Array) {
                flag = await this.$refs.storeGroup[0].isStoreSave();
              } else {
                flag = await this.$refs.storeGroup.isStoreSave();
              }
              if (!flag) {
                obj.flag = false;
                obj.text = '请选择门店';
              }
            }
            if (data.channelList[i].channelType == 9 && this.isJinHua) {
              const storeGroupDom = this.$refs.wmstoreGroup;
              let flag = null;
              if (storeGroupDom instanceof Array) {
                flag = await this.$refs.wmstoreGroup[0].isStoreSave();
              } else {
                flag = await this.$refs.wmstoreGroup.isStoreSave();
              }
              if (!flag) {
                obj.flag = false;
                obj.text = '请选择门店';
              }
            }
          }
        }
      }
      return obj;
    },

    // 保存
    submitForm(formName) {
      let that = this;
      if (!that.tpnEditBool) {
        this.$refs[formName].validate(valid => {
          if (valid) {
            // 处理数据
            let data = JSON.parse(JSON.stringify(that.ruleForm));
            delete data.selectorParamsId;
            if (!data.strategyName) {
              showMsg.showmsg('请填写策略名称', 'error');
              return;
            }
            let flag = !data.integralGet.fee || String(data.integralGet.integral) == '';
            if (data.integralGetStatus == 1 && flag) {
              this.scrollToError(this, 'integralGet');
              showMsg.showmsg('请填写获取规则', 'error');
              return;
            }
            if (data.integralGetStatus == 1) {
              if (!Number(data.integralGet.fee)) {
                this.scrollToError(this, 'integralGet');
                showMsg.showmsg('获取规则中的消费金额不能为0', 'error');
                return;
              }
              if (!Number(data.integralGet.integral)) {
                this.scrollToError(this, 'integralGet');
                showMsg.showmsg('获取规则中的获取积分不能为0', 'error');
                return;
              }
            }
            if (data.integralGetStatus == 1 && !Number(data.integralGetFreezeDays) && data.integralGetFreezeDays != '0') {
              showMsg.showmsg('请设置积分有效期', 'error');
              return;
            }
            if (data.userGeneralIntegralExpireRule == 0) {
              if(data.integralExpireType ==3 && (this.mouthM == '' || this.mouthD == '')) {
                this.scrollToError(this, 'mouthM');
                showMsg.showmsg('请完善积分有效期信息','error')
                return;
              }else if(data.integralExpireType ==2 && (this.yearY == '' || this.yearM == '' || this.yearD == '' )) {
                this.scrollToError(this, 'yearY');
                showMsg.showmsg('请完善积分有效期信息','error')
                return;
              } else if (data.integralExpireType ==0  && !Number(data.integralGetEffectiveDays)) {
                this.scrollToError(this, 'integralGetEffectiveDays');
                showMsg.showmsg('请完善积分有效期信息','error')
                return;
              }
            }
            that.checkListValue(data).then(res => {
              if (!res.flag) {
                showMsg.showmsg(res.text, 'error');
                return;
              } else {
                data.channelList.forEach(function(ele, index) {
                  ele.openStatus = ele.openStatus == true ? 1 : 0;
                  delete ele.strategyGoodsRelationIds;
                  delete ele.enterpriseRelationIds;
                  delete ele.storeRelationIds;
                  if (ele.channelType == 1) {
                    ele.strategyGoodsRelationIdArr = ele.goodsRelationIdArr;
                    delete ele.goodsRelationIdArr;
                  }
                  if (!ele.enterpriseRelationIdArr || !ele.enterpriseRelationIdArr.length) {
                    ele.enterpriseRelationIdArr = [];
                  }
                  if (!ele.storeRelationIdArr || !ele.storeRelationIdArr.length) {
                    ele.storeRelationIdArr = [];
                  }
                  if (!ele.strategyGoodsRelationIdArr || !ele.strategyGoodsRelationIdArr.length) {
                    ele.strategyGoodsRelationIdArr = [];
                  }
                  if (ele.channelType == '3') {
                    ele.channelRelationStoreType = '1';
                    ele.channelStoreType = '-1';
                    ele.storeControlId = that.uuid;
                  }
                  if (ele.channelType == '9') {
                    ele.storeControlId = that.wmuuid;
                  }
                });
                data.integralGet.fee = parseInt(data.integralGet.fee * 10);
                data.integralGet.integral = parseInt(data.integralGet.integral * 10);
                data.integralGet = JSON.stringify(data.integralGet);
                // 3.0_特殊策略新增有效期配置
                if (data.perpetualFlag === 1) {
                  // 永久
                  // perpetualFlag 是否永久  0 非永久  1永久'
                  // startValidTime 有效期时间开始(毫秒时间戳)
                  // endValidTime  有效时间结束（毫秒时间戳）
                } else {
                  // 时间区间
                  // if (data.perpetualDate[0].indexOf('Z') > -1) {
                  //   // 说明第一次没有动过
                  //   data.startValidTime = new Date(this.transUTCTime(data.perpetualDate[0]) + ' 00:00').getTime();
                  //   data.endValidTime = new Date(this.transUTCTime(data.perpetualDate[1]) + ' 23:59').getTime();
                  // } else {
                  //   data.startValidTime = new Date(data.perpetualDate[0].slice(0, -3)).getTime();
                  //   data.endValidTime = new Date(data.perpetualDate[1].slice(0, -3)).getTime();
                  // }
                  data.startValidTime = data.perpetualDate[0];
                  data.endValidTime = data.perpetualDate[1];
                }
                delete data.perpetualDate;
                if(data.userGeneralIntegralExpireRule == 1) {
                  data.integralExpireType = this.timeType
                  if(this.timeType==0 || this.timeType == null){
                    data.integralGetEffectiveDays = this.effectiveDays
                  }else {
                    data.integralExpireRule = this.timeRuleType.toString()
                  }
                }else if (data.userGeneralIntegralExpireRule == 0) {
                  if(data.integralExpireType == 0) {
                    data.integralExpireRule = ''
                  }else if(data.integralExpireType == 1) {
                    data.integralExpireRule = ''
                    data.integralGetEffectiveDays = ''
                  } else if(data.integralExpireType == 2) {
                    data.integralExpireRule = `${this.yearY},${this.yearM},${this.yearD}`
                    data.integralGetEffectiveDays = ''
                  }else if(data.integralExpireType == 3) {
                    data.integralExpireRule = `${this.mouthM},${this.mouthD}`
                    data.integralGetEffectiveDays = ''
                  }
                }
                that.saveForm(data);
              }
            });
          } else {
            this.scrollToError(this);
            showMsg.showmsg('表单信息未填写完整','error')
            return false;
          }
        });
      }
    },

    // 保存数据
    saveForm(data) {
      let that = this;
      let para = data;
      postJson('/api-admin/save-member-integral-strategy', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 0) {
            that.$message.success('保存成功');
            that.changeRoute('/pointSystem');
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          log(error);
        });
    },

    // 更新数据
    updateData() {
      let that = this;
      // that.ruleForm.integralGet = JSON.parse(that.ruleForm.integralGet)
      that.ruleForm.integralGet.fee = parseInt(that.ruleForm.integralGet.fee / 10);
      that.ruleForm.integralGet.integral = parseInt(that.ruleForm.integralGet.integral / 10);
    },

    // 树形结构
    toggle(flag) {
      let that = this;
      that.treeFlag = flag;
      if (flag == 'store') {
        that.alwaysOpen = true;
        log(that.alwaysOpen);
      }
      if (flag == 'brand') {
        that.goodsOpen = true;
      }
      if (flag == 'wx') {
        that.wxOpen = true;
      }
      document.addEventListener('click', that.hidePanel, false);
    },

    hidePanel(e) {
      let that = this;
      log(that.$refs.treeinput, e.target.className, typeof e.target.className, that.treeFlag);
      if (typeof e.target.className == 'object') {
        return;
      }
      let tag =
        e.target.className != 'span-txt' &&
        e.target.className != 'vue-treeselect__list' &&
        e.target.className != 'vue-treeselect__label' &&
        !e.target.className.includes('vue-treeselect__list-item vue-treeselect__indent-level') &&
        e.target.className != 'vue-treeselect__minus-mark' &&
        e.target.className != 'vue-treeselect__option' &&
        e.target.className != 'vue-treeselect__option vue-treeselect__option--highlight' &&
        !e.target.className.includes('vue-treeselect__checkbox vue-treeselect__checkbox--') &&
        e.target.className != 'vue-treeselect__option-arrow-placeholder' &&
        e.target.className != 'el-form demo-ruleForm' &&
        e.target.className != 'vue-treeselect__option vue-treeselect__option--selected vue-treeselect__option--highlight' &&
        e.target.className != 'vue-treeselect__list-item vue-treeselect__indent-level-1' &&
        e.target.className != 'vue-treeselect__list-item vue-treeselect__indent-level-0' &&
        e.target.className != 'vue-treeselect__checkbox-container' &&
        e.target.className != 'vue-treeselect__option-arrow-container' &&
        e.target.className != 'vue-treeselect__option-arrow vue-treeselect__option-arrow--rotated';
      log(tag);
      if (tag) {
        if (that.treeFlag == 'store') {
          that.alwaysOpen = false;
        }
        if (that.treeFlag == 'brand') {
          that.goodsOpen = false;
        }
        if (that.treeFlag == 'wx') {
          that.wxOpen = false;
        }
      }
    },

    // 微信
    selectWx(e, index, item) {
      let that = this;
      item.strategyGoodsRelationIds = item.goodsRelationIds;
      let data = that.ruleForm.channelList[index];
      data.strategyGoodsRelationIds = [];
      data.goodsRelationIds.forEach(function(ele, index) {
        data.strategyGoodsRelationIds.push(ele);
      });
    },

    // 搜索后出现下拉列表
    // 点击
    searchFocus(index, item) {
      log(index, item);
    },
    // 搜索
    remoteMethod(query) {
      let that = this;
      if (query !== '') {
        // 获取搜索列表数据
        that.getStoreList(query);
      } else {
        that.storeListOptions = [];
      }
    },

    // 获取门店列表
    getStoreList(query) {
      let that = this;
      log(query);
      let para = {
        searchParam: query,
        flag: null,
        requestProject: that.repProjectName
      };

      postRequest('/api-plug/query-store-by-code-name', para)
        .then(res => {
          log(res, res.data, res.data.errorCode);
          let resData = res.data;
          if (resData.errorCode == 0) {
            resData.result.forEach(function(ele, index) {
              ele.id = ele.storeId;
              ele.value = ele.storeName;
              ele.key = ele.storeId;
            });
            that.storeListOptions = resData.result;
            return;
          }

          that.$message.error({
            duration: 1000,
            message: resData.message
          });
        })
        .catch(function(error) {
          log(error);
          // that.toLogin()
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },

    // 获取门店分组
    getStoreGroup() {
      let that = this;
      let para = {};
      log(para, '1111');
      postRequest('/api-admin/get-clique-storegroup', para)
        .then(res => {
          log(res.data.result);
          let resData = res.data;
          if (resData.errorCode == 0) {
            that.treeOptions = resData.result;
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          log(error);

          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },

    // 输入
    toInput: function(value) {
      let that = this;
      let temp = strLength.getByteVal(value.target.value, that.inputFlagNum);
      that.ruleForm.strategyName = temp.trim();
      that.cateNameLength = strLength.getZhLen(that.ruleForm.strategyName);
    },
    selStore(e, index, item) {
      item.storeRelationIdArr = [];
    },

    // 微信选择商品类别
    wxChange(e) {
      let that = this;
      that.getGoodsCategory();
    },

    // 线下渠道选择商品类别
    changeGood(e) {
      let that = this;
      log('线下渠道选择商品类别:', e);
      if (e == 2) {
        that.getGoodsBrand();
      }
      if (e == 3) {
        that.getGoodsCategory();
      }
    },

    // 获取商品品牌
    getGoodsBrand() {
      let that = this;
      let para = {};

      postRequest('/api-admin/', para)
        .then(res => {
          log(res.data.result);
          let resData = res.data;
          if (resData.errorCode == 0) {
            let data = resData.result;
            that.goodsTreeOptions = data;
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          log(error);

          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },

    // 子组件显示方法
    showGoodsDialog() {
      let that = this;
      that.goodShow = true;
    },

    // 子组件触发方法
    selectGoods(val) {
      let that = this;
      that.goodShow = false;
    },

    // 获取策略信息
    getInfo() {
      let that = this;
      let para = {
        strategyId: that.ruleForm.integralStrategyId
      };
      postRequest('/api-admin/get-member-integral-strategy', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 0) {
            let item = res.data.result.strategy;
            // 商户列表
            let prise = res.data.result.enterpriseList;
            prise.forEach(function(ele, index) {
              ele.label = ele.brandName;
              ele.value = ele.enterpriseId;
            });
            that.mechantOption = prise;

            // 自定义人群
            if (item.useCrowd == 2) {
              let arr = item.crowdJson ? JSON.parse(item.crowdJson) : [];
              that.selectCount = 0;
              if (arr.list) {
                arr.list.forEach(item => {
                  if (item.list) {
                    that.selectCount += item.list.length;
                  }
                });
              }
              that.useId = item.selectorParamsId;
              that.hasSearchData = item.crowdJson;
            }

            // 对channelList进行排序
            const channelListSort = [3, 1, 9, 8, 11, 10]
            let channelList = channelListSort.map(el => {
              let result = item.channelList.find(item => item.channelType == el);
              if (!result) {
                switch(el) {
                  case 11:
                    result = {
                      integralStrategyChannelId: "", //id
                      enterpriseId: "",
                      integralStrategyId: "", //策略id
                      channelType: "11", //渠道类型 1微信 3:线下 5淘宝 6京东 7唯品会 8天猫 11抖音
                      openStatus: 0, //渠道配置是否启用 1启用 0停用
                      channelRelationEnterpriseType: "1", // 策略关联企业 1所有企业 2部分企业
                      channelRelationStoreType: "1", //策略关联门店类型 1所有门店 2门店分组 3部分门店
                      channelStoreType: "-1", // 策略选择门店类型 （-1:所有 0:自营 1:联营 2:加盟,3代销4托管）
                      channelRelationProType: "1", // 策略关联商品类型 1所有商品 2商品品牌 3商品类目 4部分商品
                      integralUseDiscountControl: "1", // 折扣控制 1所有折扣商品适用 2折扣范围
                      integralUseDiscountControlUpper: undefined,
                      integralUseDiscountControlLower: undefined,
                      useProportionalRestriction: "0.0", // 抵现比例限制
                      strategyGoodsRelationIdArr: [], // 商品
                      storeRelationIdArr: [], //门店
                      enterpriseRelationIdArr: [] //商户
                    }
                    break;
                  case 10:
                    result = {
                      integralStrategyChannelId: "", //id
                      enterpriseId: "",
                      integralStrategyId: "", //策略id
                      channelType: "10", //渠道类型 1微信 3:线下 5淘宝 6京东 7唯品会 8天猫 9微盟 10其他 11抖音
                      openStatus: 0, //渠道配置是否启用 1启用 0停用
                      channelRelationEnterpriseType: "1", // 策略关联企业 1所有企业 2部分企业
                      channelRelationStoreType: "1", //策略关联门店类型 1所有门店 2门店分组 3部分门店
                      channelStoreType: "-1", // 策略选择门店类型 （-1:所有 0:自营 1:联营 2:加盟,3代销4托管）
                      channelRelationProType: "1", // 策略关联商品类型 1所有商品 2商品品牌 3商品类目 4部分商品
                      integralUseDiscountControl: "1", // 折扣控制 1所有折扣商品适用 2折扣范围
                      integralUseDiscountControlUpper: undefined,
                      integralUseDiscountControlLower: undefined,
                      useProportionalRestriction: "0.0", // 抵现比例限制
                      strategyGoodsRelationIdArr: [], // 商品
                      storeRelationIdArr: [], //门店
                      enterpriseRelationIdArr: [] //商户
                    }
                    break;
                }
              }
              return result
            });
            // 将channelListSort中不存在的渠道拼到channelList上
            channelList = channelList.concat(item.channelList.filter(el => !channelListSort.some(item => el.channelType == item)));
            item.channelList = channelList;
            item.channelList.forEach(item => {
              if(item.openStatus == true) {
                if(item.channelType==3) {
                  this.opendisabled3 = true;
                }else if(item.channelType==1) {
                  this.opendisabled1 = true;
                }else if(item.channelType==9) {
                  this.opendisabled9 = true;
                }
              }
              if(item.openStatus == false) {
                item.integralUseDiscountControl == 1
              }
              if(item.integralUseDiscountControl == 1){
                item.integralUseDiscountControlUpper = undefined;
                item.integralUseDiscountControlLower = undefined;
              }
            })
            that.ruleForm = that.formatData(item);
            if(that.ruleForm.integralGetStatus==0){
              that.ruleForm.integralGet.fee = undefined;
              that.ruleForm.integralGet.integral = undefined;
            }

            // 积分有效期
            // 当有效期类型为null时判断有效期天数是否为null 不为null 有效期类型为0  为null 无选中状态
            if(that.ruleForm.integralExpireType==null) {
              this.ruleForm.integralExpireType = 0;
            }
            // 积分有效期
            that.ruleForm.integralExpireRule = that.ruleForm.integralExpireRule ? that.ruleForm.integralExpireRule.split(',') : '';
            if(that.ruleForm.userGeneralIntegralExpireRule==0){
              // 当有效期类型为null时判断有效期天数是否为null 不为null 有效期类型为0  为null 无选中状态
              if(that.ruleForm.integralExpireType==null) {
                if(that.ruleForm.integralGetEffectiveDays != null) {
                  this.ruleForm.integralExpireType = 0;
                }else {
                  this.ruleForm.integralExpireType = -1;
                }
              }else if(that.ruleForm.integralExpireType==2){
                this.yearY = Number(that.ruleForm.integralExpireRule[0]);
                this.yearM = Number(that.ruleForm.integralExpireRule[1]);
                this.yearD = that.ruleForm.integralExpireRule[2];
                that.ruleForm.integralGetEffectiveDays = '';
              }else if(that.ruleForm.integralExpireType==3){
                this.mouthM = Number(that.ruleForm.integralExpireRule[0]);
                this.mouthD = that.ruleForm.integralExpireRule[1];
                that.ruleForm.integralGetEffectiveDays = '';
              }
            }else if(that.ruleForm.userGeneralIntegralExpireRule==1){
              this.getPointInfo();
            }

            that.$set(that.ruleForm, 'perpetualDate', []);

            that.ruleForm.perpetualDate[1] = this.ruleForm.endValidTime;
            that.ruleForm.perpetualDate[0] = this.ruleForm.startValidTime;


            // 字数控制
            that.cateNameLength = strLength.getZhLen(that.ruleForm.strategyName);
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          log(error);
        });
    },
    formatData(item) {
      item.integralGetStatus = String(item.integralGetStatus);
      item.integralUseStatus = String(item.integralUseStatus);
      item.integralGetStrategy = String(item.integralGetStrategy);
      item.useCrowd = String(item.useCrowd);
      item.integralGet = JSON.parse(item.integralGet);
      // 获取规则需要除以 10
      if (!!item.integralGet && !!item.integralGet.fee) {
        item.integralGet.fee = Number(item.integralGet.fee / 10).toFixed(1);
      }
      if (!!item.integralGet && !!item.integralGet.integral) {
        item.integralGet.integral = Number(item.integralGet.integral / 10).toFixed(1);
      }
      let channelType = [];
      if (!!item.channelList.length) {
        // item.channelList[0] = item.channelList.splice(1, 1, item.channelList[0])[0]; // 第一个与第二个互换位置
        item.channelList.forEach((ele, index) => {
          ele.openStatus = ele.openStatus == 0 ? false : true;
          ele.channelType = String(ele.channelType);
          // ele.useCrowd = String(ele.useCrowd);
          ele.channelRelationStoreType = String(ele.channelRelationStoreType);
          ele.channelStoreType = String(ele.channelStoreType);
          ele.channelRelationProType = String(ele.channelRelationProType);
          ele.integralUseDiscountControl = String(ele.integralUseDiscountControl);
          // ele.integralUseDiscountControlUpper = String(ele.integralUseDiscountControlUpper);
          // ele.integralUseDiscountControlLower = String(ele.integralUseDiscountControlLower);
          ele.useProportionalRestriction = String(ele.useProportionalRestriction);

          if (!ele.enterpriseRelationIdArr || !ele.enterpriseRelationIdArr.length || ele.enterpriseRelationIdArr[0] == '[]') {
            ele.enterpriseRelationIdArr = [];
          }
          if (!ele.storeRelationIdArr || !ele.storeRelationIdArr.length) {
            ele.storeRelationIdArr = [];
          }
          if (!ele.strategyGoodsRelationIdArr || !ele.strategyGoodsRelationIdArr.length) {
            ele.strategyGoodsRelationIdArr = [];
          }

          if (ele.channelType == 1) {
            ele.goodsRelationIdArr = [];
            ele.goodsRelationIdArr = ele.strategyGoodsRelationIdArr || []; // 复制商品字段
          }
          if (ele.channelType == 3) {
            this.uuid = ele.storeControlId;
            this.isAdd = false;
          }
          if (ele.channelType == 9) {
            this.wmuuid = ele.storeControlId;
            this.isAdd = false;
          }
          // 判断是否有微盟
          channelType.push(ele.channelType);
        });
        if (channelType.indexOf('9') < 0) {
          item.channelList.push({
            integralStrategyChannelId: '', //id
            enterpriseId: '',
            integralStrategyId: '', //策略id
            channelType: '9', //渠道类型 1微信 3:线下 5淘宝 6京东 7唯品会 8天猫
            openStatus: true, //渠道配置是否启用 1启用 0停用
            channelRelationEnterpriseType: '1', // 策略关联企业 1所有企业 2部分企业
            channelRelationStoreType: '1', //策略关联门店类型 1所有门店 2门店分组 3部分门店
            channelStoreType: '-1', // 策略选择门店类型 （-1:所有 0:自营 1:联营 2:加盟,3代销4托管）
            channelRelationProType: '1', // 策略关联商品类型 1所有商品 2商品品牌 3商品类目 4部分商品
            integralUseDiscountControl: '1', // 折扣控制 1所有折扣商品适用 2折扣范围
            integralUseDiscountControlUpper: undefined,
            integralUseDiscountControlLower: undefined,
            useProportionalRestriction: '0.0', // 抵现比例限制
            strategyGoodsRelationIdArr: [], // 商品
            storeRelationIdArr: [], //门店
            enterpriseRelationIdArr: [] //商户
          });
        }
      }
      // log(item.channelList[0])
      return item;
    },

    // 获取商品品类
    getGoodsCategory() {
      let that = this;
      let para = {
        filterGoods: 1,
        parentId: ''
      };
      postRequest('/api-mall/list_mall_goods_category', para)
        .then(res => {
          log(res, res.data, res.data.errorCode);
          let resData = res.data;
          let onelevelCategory = '';
          if (resData.errorCode == 0) {
            resData.result.forEach(function(ele, index) {
              if (ele.parentId == '-1') {
                ele.children = [];
                ele.key = ele.mallCategoryId;
                ele.id = ele.mallCategoryId;
                ele.label = ele.name;
                onelevelCategory = ele;
                resData.result.splice(index, 1);
              }
            });
            let list = resData.result;
            list.forEach(function(ele, index) {
              onelevelCategory.children.push(ele);
            });
            that.goodsTreeOptions = [];
            that.goodsTreeOptions.push(onelevelCategory);
            return false;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          log(error);
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },

    loadOptions({ action, parentNode, callback }) {
      let that = this;
      log(action, parentNode, callback);
      if (action === 'LOAD_CHILDREN_OPTIONS') {
        if (parentNode.id) {
          that.getChildrenNode(parentNode, parentNode.id);
        }
      }
    },
    // 获取子节点方法
    getChildrenNode(parentNode, parentId) {
      let that = this;
      let para = {
        filterGoods: 1,
        parentId: parentId,
        requestProject: that.repProjectName
      };
      postRequest('/api-mall/list_mall_goods_category', para)
        .then(res => {
          log(res, res.data, res.data.errorCode);
          let resData = res.data;
          if (resData.errorCode == 0) {
            resData.result.forEach(function(ele, index) {
              if (ele.isLeaf == 0) {
                ele.subOptions = null;
              } else {
                ele.subOptions = [];
              }
              ele.key = ele.mallCategoryId;
            });
            parentNode.subOptions = resData.result;
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          log(error);
          // that.toLogin()
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },

    // 选择人群筛选器
    showPeople() {
      this.dialogVisiblePeople = true;
    },
    /* 人群筛选器 start */
    getData() {
      // 父组件调用子组件方法,触发父组件事件
      this.$refs.peopleFilter.confirmSet();
    },
    findFilter(value) {
      // 子组件触发父组件事件,返回过滤条件数据
      // log(value);
      this.ruleForm.crowdJson = value;
      this.searchParams = value;
      if (this.ruleForm.crowdJson) {
        let arr = JSON.parse(this.ruleForm.crowdJson);
        this.selectCount = 0;
        if (arr.list) {
          arr.list.forEach(item => {
            this.selectCount += item.list.length;
          });
        }
      }
    },
    cancelFilter() {
      this.$refs.peopleFilter.cancelSet();
    },
    getBackData(val) {
      log(val);
      this.ruleForm.selectorParams = val;
    },
    // 隐藏保存按钮和确认按钮  (子组件会调用)
    hideBtn() {
      let that = this;
      that.toggleTag = false;
    },
    // 显示编辑,保存按钮隐藏,确认按钮显示 (子组件会调用)
    editShow() {
      this.toggleTag = true;
    },
    editHide() {
      this.toggleTag = false;
    },
    getPeopleData() {
      // 筛选器 弹框的确认按钮
      let that = this;
      that.$refs.peopleFilter.confirmSet().then(res => {
        if (!res) {
          return;
        } else {
          setTimeout(_ => {
            if (that.searchParams) {
              that.lsSaveBtn(that.searchParams);
            }
          }, 500);
        }
      });
    },
    // 人群筛选器弹框的确定按钮  临时保存
    lsSaveBtn(searchParams) {
      postRequest('/api-admin/get-screen-detail-param', {
        requestProject: this.repProjectName,
        tempBusinessId: this.tempBusinessId ? this.tempBusinessId : '',
        detailParams: searchParams
      })
        .then(res => {
          if (res.data.errorCode == 0) {
            this.tempBusinessId = res.data.result;
            this.useId = res.data.result;
            this.dialogVisiblePeople = false;
            this.searchParams = '';
          } else {
            this.$message.error(res.data.message);
          }
        })
        .catch(err => {
          log(err);
        });
    },
    /* end */
    // 判断是否是太平鸟
    getLoginInfo() {
      let that = this;
      let param = {};
      postRequest('/api-auth/get-login-user-info', param)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 0) {
            if (resData.result.enterpriseId == that.tpnEnterpriseId) {
              that.tpnEditBool = true;
            }
          } else {
            errMsg.errorMsg(resData);
          }
        })
        .catch(function(error) {
          log(error);
        });
    }
  },
  components: {
    topNavNew,
    Treeselect,
    addGoods
  },
  created() {
    // this.selectReplayStyle()
  },
  mounted() {
    let that = this;
    log(that.$route.query.integralStrategyId);
    // 获取策略 id
    let id = that.$route.query.integralStrategyId;
    that.ruleForm.integralStrategyId = id;
    that.getInfo();

    // 获取门店分组
    that.getStoreGroup();
    that.getLoginInfo();
  }
};
</script>
<style lang="scss" scoped>
.selectwm {
  width:120px;
  margin:0 10px;
}
.mb20 {
  margin-bottom: 20px;
}
.bottom{
  position: fixed;
  bottom: 0px;
  left: 200px;
  width: 100%;
  height: 55px;
  text-align: center;
  background: #FFFFFF;
  box-shadow: 1px -2px 8px 0px rgba(220, 223, 230, 0.6);
}
.w215{
  width: 215px;
}
/deep/.dm-store {
    .w200 {
      width: 240px !important;
    }
  }
.attention-wrap {
  padding: 20px;
  background: #fff;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  .item-label {
    font-size: 14px;
    color: #606266;
    margin-bottom: 30px;
    span {
      display: inline-block;
      width: 80px;
    }
  }

  .vue-treeselect {
    display: inline-block;
    vertical-align: top;
    width: 300px;
  }
  // .attention-content-wrap {
  // }
}

.form-wrap {
  .el-radio {
    margin-right: 0;
  }
  .el-input {
    width: 115px;
    padding: 0 10px;
    &.w-300 {
      width: 300px;
    }
    &.w-340 {
      width: 340px;
    }
  }

  /deep/ .input-label {
    position: absolute;
    left: 303px;
    color: #ccc;
    font-size: 12px;
  }

  .el-select {
    vertical-align: top;
  }

  .span-txt {
    position: absolute;
    z-index: 2;
    width: 300px;
    text-align: center;
  }

  .padding-0 {
    padding: 0;
  }

  .form-child {
    padding: 20px 20px 0px 0px;
    background: #f5f6f9;
    margin-top: 20px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
  }

  .margin-20 {
    margin-top: 20px;
  }
.padding-bottom-20{
  padding-bottom: 20px;
}
  .tinymce-wrap {
    width: 780px;
  }
}
 /deep/ .el-input-number{
    width: 115px;
    padding: 0 10px;
    .el-input{
      margin: 0;
      .el-input__inner{
        text-align:left;
      }
    }
  }

/*树形*/
.vue-treeselect /deep/ {
  /deep/ .vue-treeselect__control {
    height: 30px;
    /*line-height: 36px;*/
    cursor: pointer;
  }

  .vue-treeselect__placeholder {
    line-height: 30px;
    font-size: 12px;
  }

  .vue-treeselect__multi-value-item-container,
  .vue-treeselect__multi-value {
    line-height: 1;
    height: 0;
    opacity: 0;
  }

  span.vue-treeselect__multi-value-label {
    line-height: 1;
  }

  .vue-treeselect__multi-value-item {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    background-color: #f0f2f5;
    color: #909399;
  }

  .vue-treeselect__value-remove {
    color: #909399;
  }

  &:not(.vue-treeselect--disabled) .vue-treeselect__multi-value-item:not(.vue-treeselect__multi-value-item-disabled):hover {
    background-color: #f0f2f5;
    color: #909399;
  }

  .vue-treeselect--searchable:not(.vue-treeselect--disabled) .vue-treeselect__value-container {
    cursor: pointer;
  }

  .vue-treeselect__x-container {
    display: none;
  }

  .vue-treeselect__control-arrow {
    display: none;
  }

  .vue-treeselect__control-arrow-container {
    position: relative;
  }
  /deep/ .vue-treeselect__value-container {
    line-height: 30px;
  }

  /deep/.vue-treeselect__control-arrow-container:after,
  .vue-treeselect__control-arrow-container:before {
    border: 6px solid transparent;
    border-left: 6px solid #fff;
    width: 0;
    height: 0;
    position: absolute;
    top: 49%;
    left: 50%;
    margin-left: -6px;
    content: ' ';
    margin-top: -3px;
    -webkit-transform: rotate(90deg);
    -moz-transform: rotate(90deg);
    -o-transform: rotate(90deg);
    transform: rotate(90deg);
    -webkit-transition: -webkit-transform 0.3s;
    transition: -webkit-transform 0.3s;
    transition: transform 0.3s;
    transition: transform 0.3s, -webkit-transform 0.3s;
    transition: transform 0.3s, -webkit-transform 0.3s;
  }

  /deep/ .vue-treeselect__control-arrow-container:before {
    border-left-color: #c0c4cc;
    top: 52%;
  }

  &.vue-treeselect--focused .vue-treeselect__control-arrow-container:after,
  &.vue-treeselect--focused .vue-treeselect__control-arrow-container:before {
    margin-top: -6px;
    -webkit-transform: rotateZ(-90deg);
    -moz-transform: rotateZ(-90deg);
    -o-transform: rotateZ(-90deg);
    transform: rotateZ(-90deg);
    -webkit-transition: -webkit-transform 0.3s;
    transition: -webkit-transform 0.3s;
    transition: transform 0.3s;
    transition: transform 0.3s, -webkit-transform 0.3s;
    transition: transform 0.3s, -webkit-transform 0.3s;
  }

  &.vue-treeselect--focused .vue-treeselect__control-arrow-container:before {
    border-left-color: #c0c4cc;
    top: 47%;
  }

  .vue-treeselect--has-value .vue-treeselect__multi-value {
    margin-bottom: 0;
  }
}

/*人群筛选器*/
.select-people {
  max-height: 500px;
  overflow-y: auto;
  overflow-x: hidden;
}
.select-people /deep/ .marginLeft134 {
  margin-left: 80px;
}
.select-people /deep/ .filter-content .member-templates-condition-title {
  text-align: left;
  font-size: 14px;
  line-height: 24px;
}
.select-people /deep/ .filter-content {
  margin-top: 0;
}
.people-btn-wrap {
  width: 100%;
  background: #f2f3f4;
  box-sizing: border-box;
  padding: 0 0 24px 100px;
}
.select-people /deep/ .detail {
  margin-top: 0;
}
</style>
