<template>
  <div class="PostDelivery SplittingStrategy">
    <div class="quickOperation">
      快捷操作：
      <Button
        type="fcdefault"
        style="margin-right:8px"
        @click="isNew?saveAll():savestrategyBase()"
      >
      <!-- v-if='isNew' -->
        保存
      </Button>
      <!-- <Button type="fcdefault" style="margin-right:8px" @click="refreshParams">刷新</Button> -->
      <Button type="fcdefault"
      @click="closePage"
      >
        关闭
      </Button>
    </div>
    <div class="PostDeliveryContent">
      <!-- 注意事项 -->
      <div class="scanInWarning">
        <div class="warningTitle">
          <img
            src="../../assets/image/warningIcon.png"
            alt=""
          >
          <span>注意：</span>
          <Icon
            v-if="isOpen"
            color="#979797"
            type="ios-arrow-down"
            @click="toggleArrow"
          />
          <Icon
            v-else
            color="#979797"
            type="ios-arrow-up"
            @click="toggleArrow"
          />
        </div>
        <div
          v-if="isOpen"
          class="warningText"
        >
          <p>功能说明：订单进入系统后，将从上到下，从左到右执行设置的拆分策略，根据拆单策略中设置的拆单规则对订单进行拆分，最后分多个包裹发出。</p>
          <p>适用场景：1、不同类型商品不能同时发；2、仓库包装有最大包装限制；3、部分特殊商品需要单独包装发货（如液体不能空运等）。</p>
          <p>注意内容：1、如果一个订单中购买了多件同一商品，当订单将多件拆分时，只会把一个平台单号通知平台发货。2、修改商品不会重新匹配拆单策略。3、货到付款订单与JITX订单不会自动拆单。</p>
        </div>
      </div>
      <!-- 策略配置基础条件 -->
      <div class="conditionBefore">
        <div class="conditionContent">
          <div class="itemContent">
            <div
              class="itemLabel strategyName"
              style="display: flex;justify-content: flex-end;align-items: center;"
            ><span style='color: red;'>*</span>策略名称</div>
            <Input
              v-model="formInline.strategy_name"
              style='width: 500px;'
              placeholder=""
              class="conditionInput"
              @on-blur="keyUp($event,'strategyname')"
            />
          </div>
        </div>
        <div class="joinStore">
          <div class="conditionContent">
            <div class="itemContent">
              <div
                class="itemLabel storeLabel"
                style="display: flex;justify-content: flex-end;align-items: center;"
              >
                <Tooltip
                  max-width="400"
                  theme="dark"
                  content="未在参与店铺中设置的店铺，任何情况下都不会自动拆单。"
                  transfer
                  placement="right"
                >
                  <img
                    class="img-framelanflag"
                    src="../../../static/img/customize-1.3/tips.png"
                  >
                </Tooltip>
                <span style='color: red;'>*</span>参与店铺
              </div>
            </div>
          </div>
          <div class="minShop shopSelect">
            <DropDownCom
              ref="DropDownCom"
              style="width:700px"
              select-width="700"
              :choosed-express-list="choosedExpressList"
              :placeholder="placeholder"
              :express-list="shopList"
              :clearable="false"
              @changeShopArr="changeShopArr"
              @searchList="getEnterExpressList"
              @clearAllData="clearAllFilter"
            />
            <div
              v-if="selectShopArr.length"
              class="selectPart"
            >
              <span style="margin-right:8px;margin-top: 16px;font-size: 11px;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;color: #CDCDCD;line-height: 16px;">检索项</span>
              <div class="selectGroup">
                <div
                  v-for="(item,index) in selectShopArr"
                  :key="index"
                  class="groupItem"
                  :class="item.class"
                  @mouseenter="showCloseIcon(index)"
                  @mouseleave="hideCloseIcon(index)"
                >
                  <span :title='item.label'>{{ item.label }}</span>
                  <!-- v-if="item.flag" -->
                  <Icon
                    v-if="item.flag"
                    class="iconClose"
                    type="ios-close"
                    @click="deleteShop(item,index)"
                  />
                </div>
              </div>
              <div class="selectBtn">
                <div
                  style="cursor:pointer; padding:8px;padding-top: 0px;"
                  @click="clearAll"
                >
                  清空
                </div>
                <div style="padding:8px 0;height:40px;padding-top: 0px;">
                  |
                </div>
                <div
                  style="padding:8px;cursor:pointer;padding-top: 0px;padding-right: 0px;"
                  @click="showAll"
                >
                  {{ showAllText }}
                  <Icon :type="isShow?'iconios-arrow-down':'iconios-arrow-up'" />
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="OrderMsg">
          <foldPanel
            v-model="PrintBaseStatus"
            title="基础设置"
          >
            <div
              slot="content"
              class="block"
            >
              <div class="conditionContent">
                <div class="itemContent">
                  <div
                    class="itemLabel"
                    style="width:136px;display: flex;justify-content: flex-end;align-items: center;"
                  >
                    <Tooltip
                      max-width="400"
                      theme="dark"
                      content="勾选后虚拟商品将自动拆出，走虚拟商品发货流程。（虚拟商品设置路径：运维》系统参数管理》虚拟商品sku）"
                      transfer
                      placement="right"
                    >
                      <img
                        class="img-framelanflag"
                        src="../../../static/img/customize-1.3/tips.png"
                      >
                    </Tooltip>
                    虚拟商品单独拆出
                  </div>
                  <Checkbox v-model="formInline.is_virtual_sku"></Checkbox>
                </div>
              </div>
              <div class="conditionContent">
                <div class="itemContent">
                  <div
                    class="itemLabel"
                    style="width:136px;display: flex;justify-content: flex-end;align-items: center;"
                  >
                    <Tooltip
                      max-width="400"
                      theme="dark"
                      content="赠品参与拆单或赠品单独拆为一单，会导致赠品被单独拆出，如赠品先发货，买家申请退款，可能造成赠品多发。"
                      transfer
                      placement="right"
                    >
                      <img
                        class="img-framelanflag"
                        src="../../../static/img/customize-1.3/tips.png"
                      >
                    </Tooltip>
                    赠品拆单策略
                  </div>
                  <RadioGroup v-model="formInline.IsGiftSplit">
                    <!-- @on-change="savestrategyBase" -->
                    <Radio
                      value="1"
                      label="参与拆单"
                    />
                    <Radio
                      value="0"
                      label="绑定主品拆单"
                    />
                    <Radio
                      value="2"
                      label="单独拆为一单"
                    />
                  </RadioGroup>
                </div>
                <!-- <div class="itemContent">
                  <div
                    class="itemLabel"
                    style="display: flex;justify-content: flex-start;align-items: center;"
                  >
                    不拆单件数
                    <Tooltip
                      max-width="400"
                      theme="dark"
                      content="当订单商品分仓后，分仓后的具体订单（若拆单，指拆单后的订单）总件数大于等于设置值时，不拆分订单。用于包裹商品太多，直接走物流发货的情况。"
                      transfer
                      placement="right"
                    >
                      <img
                        class="img-framelanflag"
                        src="../../../static/img/customize-1.3/tips.png"
                      >
                    </Tooltip>
                  </div>
                  <Input
                    v-model="formInline.noSplitQty"
                    class="conditionInput"
                    @on-blur="keyUp($event,'noSplitQty')"
                  /><span class="itemContentUnit">件</span> -->
                  <!-- @on-change='savestrategyBase($event,"noSplitQty")' -->
                  <!-- clearable -->
                  <!-- :regx="regx2" -->
                  <!-- @on-keyup="formInline.noSplitQty=(formInline.noSplitQty.replace(/\D/g,'')==''?'':parseInt(formInline.noSplitQty))" -->
                <!-- </div> -->
                <!-- <div class="itemContent">
                  <div
                    class="itemLabel"
                    style="display: flex;justify-content: flex-start;align-items: center;"
                  >
                    不拆单体积
                    <Tooltip
                      max-width="400"
                      theme="dark"
                      content="当订单商品分仓后，分仓后的具体订单（若拆单，指拆单后的订单）总体积大于等于设置值时，不拆分订单。用于包裹商品太多，直接走物流发货的情况。"
                      transfer
                      placement="right"
                    >
                      <img
                        class="img-framelanflag"
                        src="../../../static/img/customize-1.3/tips.png"
                      >
                    </Tooltip>
                  </div>
                  <Input
                    v-model="formInline.noSplitVolume"
                    class="conditionInput"
                    @on-blur="keyUp($event,'noSplitVolume')"

                  /><span class="itemContentUnit">立方厘米</span> -->
                  <!-- clearable -->
                  <!-- @on-change='savestrategyBase($event,"noSplitVolume")'"  -->
                  <!-- :regx="regx2" -->
                <!-- </div> -->
              </div>
              <div class="conditionContent">
                <div class="itemContent" style="margin-bottom: 4px;">
                  <div
                    class="itemLabel"
                    style="width:136px;display: flex;justify-content: flex-end;align-items: center;"
                  >
                    <Tooltip
                      max-width="400"
                      theme="dark"
                      content="按组合拆分时，将按套进行拆分，一个组合商品的明细商品不会被拆开，支持设置指定商品按组合进行拆分，未设置的组合商品将按照明细进行拆分，未设置商品默认所有组合商品按照组合进行拆分；支持设置多个，多个使用英文分号进行分隔；按明细进行拆分时，将组合商品中的明细商品拆开，组合中部分明细发货后会同步平台发货，买家未收到全部商品时，可能会投诉虚假发货，支持设置指定商品按照明细进行拆分，未设置的组合商品将按照组合进行拆分，未设置商品默认所有组合商品按照明细进行拆分，支持设置多个，多个使用英文分号进行分隔。"
                      transfer
                      placement="right"
                    >
                      <img
                        class="img-framelanflag"
                        src="../../../static/img/customize-1.3/tips.png"
                      >
                    </Tooltip>
                    组合商品拆单策略
                  </div>
                  <RadioGroup v-model="formInline.constitute_goods_split">
                    <Radio
                      value="1"
                      label="按组合拆分"
                    />
                    <div style="display: inline-block;white-space: nowrap;" v-show="formInline.constitute_goods_split === '按组合拆分'">
                      <span>指定组合商品按组合拆</span>
                      <Input v-model="formInline.group_split_value" style="width: 200px;" type="textarea" rows="2" placeholder="请输入组合商品sku，多个用英文;号分隔" />
                    </div>
                    <Radio
                      value="0"
                      label="按明细拆分"
                    />
                    <div style="display: inline-block;white-space: nowrap;" v-show="formInline.constitute_goods_split === '按明细拆分'">
                      <span>指定组合商品按明细拆</span>
                      <Input v-model="formInline.detailed_split_value" style="width: 200px;" type="textarea" rows="2" placeholder="请输入组合商品sku，多个用英文;号分隔" />
                    </div>
                  </RadioGroup>
                </div>
              </div>
              <div class="conditionContent">
                <div class="itemContent">
                  <div
                    class="itemLabel"
                    style="width:136px;display: flex;justify-content: flex-end;align-items: center;"
                  >
                    <Tooltip
                      max-width="400"
                      theme="dark"
                      content="勾选后，按库存和按商品拆时，都不会将一个sku拆数量拆至多单"
                      transfer
                      placement="right"
                    >
                      <img
                        class="img-framelanflag"
                        src="../../../static/img/customize-1.3/tips.png"
                      >
                    </Tooltip>
                    同sku不拆分数量
                  </div>
                  <Checkbox v-model="formInline.byskusplit"></Checkbox>
                </div>
              </div>
              <div class="conditionContent">
                <div class="itemContent">
                    <div
                      class="itemLabel"
                      style="width:136px;display: flex;justify-content: flex-end;align-items: center;"
                    >
                      <Tooltip
                        max-width="400"
                        theme="dark"
                        content="设置的商品在执行拆单策略时，不会被单独拆为一单。"
                        transfer
                        placement="right"
                      >
                        <img
                          class="img-framelanflag"
                          src="../../../static/img/customize-1.3/tips.png"
                        >
                      </Tooltip>
                      指定商品不参与拆单
                    </div>
                    <Input
                      v-model="formInline.sku_no_split"
                      style='width: 500px;'
                      class="conditionInput"
                      placeholder="请输入sku，多个用英文逗号或英文分号分隔"
                    />
                </div>
              </div>
            </div>
          </foldPanel>
        </div>
        <!-- 策略配置明细条件 -->
        <div class="OrderMsg" v-if='!isNew'>
          <foldPanel
            v-model="PrintBillStatus"
            title="按库存"
          >
            <div
              slot="content"
              class="block"
            >
              <div class='subTitle'>根据商品库存情况，为订单进行拆分，按库存拆分后的订单，若满足按商品拆单策略，将继续拆单。</div>
              <div class="consitionModulesBox">
                <div
                  v-for="(item,index) in conditionModules.stockModules"
                  :key="index"
                  class="conditionItem"
                >
                  <div class="conditionItemSqure">
                    <div class="condTop">
                      <span>{{ item.title }}</span>
                      <i-switch @on-change="changeSwitch($event,item.key)" v-model="item.value" />
                    </div>
                    <div class="condMiddle">
                      {{ item.tips }}
                    </div>
                    <div class="bottomContent">
                      <div class="tipBottom">
                        {{ item.leftbottomTip }}&nbsp;&nbsp;{{ item.num }}
                      </div>
                      <div class="condBottom" v-if='item.key !== "multiBinSplit"'>
                        <Button
                          class="setBtn"
                          @click="squreBtn(item.key)"
                        >
                          {{ item.buttonText }}
                        </Button>
                      </div>
                    </div>
                  </div>
                  <img
                    src="../../../static/img/customize-1.3/Arrow.png"
                    alt=""
                  >
                </div>
              </div>
            </div>
          </foldpanel>
        </div>
        <div class="OrderMsg" v-if='!isNew'>
          <foldPanel
            v-model="PrintOrderStatus"
            title="按订单"
          >
            <div
              slot="content"
              class="block"
            >
              <div class='subTitle'>根据订单包含的商品数量或体积，若订单符合不拆单条件，订单将不会继续拆分；否则继续执行按商品拆单逻辑。</div>
              <div class="consitionModulesBox">
                <div
                  v-for="(item,index) in conditionModules.orderModules"
                  :key="index"
                  class="conditionItem"
                >
                  <div class="conditionItemSqure">
                    <div class="condTop">
                      <span>{{ item.title }}</span>
                      <i-switch @on-change="changeSwitch($event,item.key)" v-model="item.value" />
                    </div>
                    <div class="condMiddle">
                      {{ item.tips }}
                    </div>
                    <div class="bottomContent">
                      <div class="tipBottom">
                        {{ item.leftbottomTip }}&nbsp;&nbsp;{{ item.num }}
                      </div>
                      <div class="condBottom" v-if='item.key !== "multiBinSplit"'>
                        <Button
                          class="setBtn"
                          @click="squreBtn(item.key)"
                        >
                          {{ item.buttonText }}
                        </Button>
                      </div>
                    </div>
                  </div>
                  <img
                    src="../../../static/img/customize-1.3/Arrow.png"
                    alt=""
                  >
                </div>
              </div>
            </div>
          </foldpanel>
        </div>
        <div class="OrderMsg" v-if='!isNew'>
          <foldPanel
            v-model="PrintOutStatus"
            title="按商品"
          >
            <div
              slot="content"
              class="block"
            >
              <div class='subTitle'>根据商品属性，匹配规则，按次序对订单进行拆分，每次满足规则的商品，将会从订单中拆出，不再继续执行后续策略。</div>
              <div class="consitionModulesBox">
                <div
                  v-for="(item,index) in conditionModules.goodModules"
                  :key="index"
                  class="conditionItem"
                >
                  <div class="conditionItemSqure" v-if="item.display">
                    <div class="condTop">
                      <span>{{ item.title }}</span>
                      <i-switch @on-change="changeSwitch($event,item.key)" v-model="item.value" />
                    </div>
                    <div class="condMiddle">
                      {{ item.tips }}
                    </div>
                    <div class="bottomContent">
                      <div class="tipBottom">
                        {{ item.leftbottomTip }}{{ item.num }}
                      </div>
                      <div class="condBottom" v-if="item.buttonText">
                        <Button
                          class="setBtn"
                          @click="squreBtn(item.key)"
                        >
                          {{ item.buttonText }}
                        </Button>
                      </div>
                    </div>
                  </div>
                  <img
                    src="../../../static/img/customize-1.3/Arrow.png"
                    alt=""
                    v-if="item.display"
                  >
                </div>
              </div>
            </div>
          </foldPanel>
        </div>
      </div>
    </div>
    <!-- 设置包裹最小件数弹框 -->
    <Modal
      v-model="minPiecesInModal"
      title="【包裹最小件数】设置"
      title-align="left"
      width="450"
      :closable="closable"
      :mask="mask"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
    >
      <div class="chooseStorageForm SplitForm minPiecesForm">
        <p>只有某一发货仓库不缺货的商品件数大于等于设置的最小件数时，才会拆出，建议不要设置太小，不然包裹数量会太多，增加物流成本。</p>
        <Form
          ref="formValidate"
          :model="StorageForm"
          :label-width="90"
          class="chooseStorageBox"
        >
          <FormItem
            label="最小件数："
          >
            <Input
              v-model="StorageForm.minPieces"
              :regx="regx1"
            />
            <span class="itemContentUnit">件</span>
          </FormItem>
        </Form>
      </div>
      <div class="bottomBtnBox">
        <Button
          size="small"
          class="cancelBtn"
          ghost
          @click="cancel('minPieces')"
        >
          取消
        </Button>
        <Button
          type="primary"
          size="small"
          class="sureBtn"
          @click="sureMinPieces"
        >
          确定
        </Button>
      </div>
    </Modal>
    <!-- 设置不拆单商品个数弹框 -->
    <Modal
      v-model="noSplitNumModal"
      title="【不拆单商品个数】设置"
      title-align="left"
      width="550"
      :closable="closable"
      :mask="mask"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
    >
      <div class="chooseStorageForm SplitForm minPiecesForm">
        <p style="margin-left:24px;">订单sku个数大于等于设置值时，不拆分订单。</p>
        <Form
          ref="formValidate"
          :model="StorageForm"
          :label-width="170"
          class="chooseStorageBox"
        >
          <FormItem
            label="不拆单商品个数"
          >
            <Input
              v-model="StorageForm.noSplitNum"
              :regx="regx1"
            />
          </FormItem>
          <FormItem label="赠品是否参与计算">
            <RadioGroup v-model="StorageForm.gift_no_split_num">
              <Radio
                value="1"
                label="是"
              />
              <Radio
                value="0"
                label="否"
              />
            </RadioGroup>
          </FormItem>
          <FormItem
          label="不参与拆单商品是否参与计算">
            <RadioGroup v-model="StorageForm.sku_no_split_num">
              <Radio
                value="1"
                label="是"
              />
              <Radio
                value="0"
                label="否"
              />
            </RadioGroup>
          </FormItem>
        </Form>
      </div>
      <div class="bottomBtnBox">
        <Button
          size="small"
          class="cancelBtn"
          ghost
          @click="cancel('noSplitNum')"
        >
          取消
        </Button>
        <Button
          type="primary"
          size="small"
          class="sureBtn"
          @click="sureNoSplitNum"
        >
          确定
        </Button>
      </div>
    </Modal>
    <!-- 设置不拆单商品件数弹框 -->
    <Modal
      v-model="noSplitQtyModal"
      title="【不拆单商品件数】设置"
      title-align="left"
      width="550"
      :closable="closable"
      :mask="mask"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
    >
      <div class="chooseStorageForm SplitForm minPiecesForm">
        <p style="margin-left:24px;">订单商品数量大于等于设置值时，不拆分订单。</p>
        <Form
          ref="formValidate"
          :model="StorageForm"
          :label-width="170"
          class="chooseStorageBox"
        >
          <FormItem
            label="不拆单商品件数"
          >
            <Input
              v-model="StorageForm.noSplitQty"
              :regx="regx1"
            />
          </FormItem>
          <FormItem label="赠品是否参与计算">
            <RadioGroup v-model="StorageForm.gift_no_split_qty">
              <Radio
                value="1"
                label="是"
              />
              <Radio
                value="0"
                label="否"
              />
            </RadioGroup>
          </FormItem>
          <FormItem
          label="不参与拆单商品是否参与计算">
            <RadioGroup v-model="StorageForm.sku_no_split_qty">
              <Radio
                value="1"
                label="是"
              />
              <Radio
                value="0"
                label="否"
              />
            </RadioGroup>
          </FormItem>
        </Form>
      </div>
      <div class="bottomBtnBox">
        <Button
          size="small"
          class="cancelBtn"
          ghost
          @click="cancel('noSplitQty')"
        >
          取消
        </Button>
        <Button
          type="primary"
          size="small"
          class="sureBtn"
          @click="sureNoSplitQty"
        >
          确定
        </Button>
      </div>
    </Modal>
    <!-- 设置不拆单商品体积弹框 -->
    <Modal
      v-model="noSplitVolumeModal"
      title="【不拆单商品体积】设置"
      title-align="left"
      width="450"
      :closable="closable"
      :mask="mask"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
    >
      <div class="chooseStorageForm SplitForm minPiecesForm">
        <p style="margin-left:24px;">订单商品体积之和大于等于设置值时，不拆分订单。</p>
        <Form
          ref="formValidate"
          :model="StorageForm"
          :label-width="120"
          class="chooseStorageBox chooseStorageBoxVolume"
        >
          <FormItem
            label="不拆单商品体积"
          >
            <Input
              v-model="StorageForm.noSplitVolume"
              :regx="regx1"
            >
              <span slot="append">立方厘米</span>
            </Input>
          </FormItem>
        </Form>
      </div>
      <div class="bottomBtnBox">
        <Button
          size="small"
          class="cancelBtn"
          ghost
          @click="cancel('noSplitVolume')"
        >
          取消
        </Button>
        <Button
          type="primary"
          size="small"
          class="sureBtn"
          @click="sureNoSplitVolume"
        >
          确定
        </Button>
      </div>
    </Modal>
    <!-- 设置参与仓库弹框 -->
    <Modal
      v-model="setWarehouseInModal"
      title="【参与仓库】设置"
      title-align="left"
      width="832"
      :closable="closable"
      :mask="mask"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
    >
      <div class="chooseStorageForm SplitForm">
        <p>设置参与多仓拆分的仓库，订单分仓时，分到设置的仓库，才会拆分；如果分仓规则分到了不在设置中的仓库，不会分仓拆单。</p>
        <Form
          ref="formValidate"
          :model="StorageForm"
          :label-width="0"
          class="chooseStorageBox"
        >
          <FormItem
            label=""
          >
            <div class="shopSelect">
              <DropDownCom
                ref="DropDownComWarehouse"
                style="width:800px"
                select-width="800"
                :choosed-express-list="choosedWarehouseExpressList"
                :placeholder="placeholder"
                :express-list="warehouseList"
                :clearable="false"
                @changeShopArr="changeWarehouseArr"
                @searchList="getWarehouseEnterExpressList"
                @clearAllData="clearAllWarehouseFilter"
              />
              <div
                v-if="selectWarehouseArr.length"
                class="selectPart"
              >
                <div class="selectGroup">
                  <span style="margin-right:8px;font-size: 11px;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;color: #CDCDCD;line-height: 16px;">检索项</span>
                  <div
                    v-for="(item,index) in selectWarehouseArr"
                    :key="index"
                    class="groupItem"
                  >
                    <span :title='item.label'>{{ item.label }}</span>
                    <Icon
                      type="ios-close"
                      @click="deleteWarehouse(item,index)"
                    />
                  </div>
                </div>
                <div class="selectBtn">
                  <div
                    style="cursor:pointer; padding:8px;padding-top: 0px;"
                    @click="clearAllWarehouse"
                  >
                    清空
                  </div>
                  <div style="padding:8px 0;height:40px;padding-top: 0px;">
                    |
                  </div>
                  <div
                    style="padding:8px;cursor:pointer;padding-top: 0px;padding-right: 0px;"
                    @click="showAll('setWarehouse')"
                  >
                    {{ showAllTextWarehouse }}
                    <Icon :type="isShow?'iconios-arrow-down':'iconios-arrow-up'" />
                  </div>
                </div>
              </div>
            </div>
          </FormItem>
        </Form>
      </div>
      <div class="bottomBtnBox">
        <Button
          size="small"
          class="cancelBtn"
          ghost
          @click="cancel('setWarehouse')"
        >
          取消
        </Button>
        <Button
          type="primary"
          size="small"
          class="sureBtn"
          @click="sureSetWarehouse"
        >
          确定
        </Button>
      </div>
    </Modal>
    <!-- 箱规设置弹框 -->
    <Modal
      v-model="packageVolumeImModal"
      class='packageVolumeImModal'
      title="【箱规】设置"
      title-align="left"
      :mask="mask"
      :closable="closable"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
      width="900"
      @on-keydown="AddBoxSpecs"
      @on-cancel="cancel('packageVolume')"
    >
      <Form
        ref="formValidate3"
        :label-width="60"
        label-position="left"
        :model="formValidate3"
        :rules="ruleInline"
      >
        <Row style="display: flex; justify-content: space-around">
          <Col span="9">
            <div style="margin-bottom: 16px;">
              <!-- <label style="width: 80px;">箱规名称</label> -->
              <FormItem
                prop="name"
                label="箱规名称"
                :class="errorNameShow?'ark-form-item-error':''"
              >
                <Input
                  v-model.trim="formValidate3.name"
                  placeholder="请输入箱规名称"
                  @on-keydown='deleteTrim'
                  clearable
                />
                <p
                  v-if="errorNameShow"
                  class="ark-form-item-error-tip"
                >
                  {{ errorName }}
                </p>
              </FormItem>
            </div>
          </Col>
          <Col span="9">
            <div style="margin-bottom: 16px;">
              <!-- <label style="width: 80px;">箱规体积</label> -->
              <FormItem
                prop="volume"
                label="箱规体积"
                :class="errorVolumeShow?'ark-form-item-error':''"
              >
                <Input
                  v-model="formValidate3.volume"
                  placeholder="请输入体积"
                  :regx="regx1"
                  clearable
                >
                  <span slot="append">立方厘米</span>
                </Input>
                <p
                  v-if="errorVolumeShow"
                  class="ark-form-item-error-tip"
                >
                  {{ errorVolume }}
                </p>
              </FormItem>
              <!-- <span class="itemContentUnit">立方厘米</span> -->
            </div>
          </Col>
          <Col span="2">
            <Button
              type="primary"
              icon="md-return-left"
              @click="AddBoxSpecsBtn('formValidate3')"
            >
              添加
            </Button>
          </Col>
        </Row>
      </Form>
      <Table
        border
        height="300"
        :columns="columns2"
        :data="giftTableDataAdd"
        size="large"
      />
      <footer style="display: flex; justify-content: flex-end; margin-top: 16px">
        <Button
          type="fcdefault"
          style="width: 80px; height: 34px; font-size: 14px"
          @click="cancel('packageVolume')"
        >
          取消
        </Button>
        <Button
          type="posdefault"
          style="width: 80px; height: 34px; font-size: 14px; margin-left: 8px"
          @click="sureSetPackageVolume('formValidate3')"
        >
          确定
        </Button>
      </footer>
    </Modal>
    <!-- 策略设置内容打开关闭开关确认弹框 -->
    <Modal
      v-model="isShowSureToggleSwitch"
      mask
      :mask-closable="maskClosable"
      title="操作确认"
      title-align="left"
      class-name="showTipModel"
      width="400px"
      closable
      @on-ok="sureToggleSwitch"
      @on-cancel="cancel('ToggleSwitch')"
    >
      <p>{{ TipTitle }}</p>
    </Modal>
  </div>
</template>

<script>
  // import R3 from '../../../static/r3/r3.publish/r3.min';
  import DropDownCom from '@yunque/component/customizedContent/DropDownCom';
  import foldPanel from '../customizedContent/FoldPanel.vue';

  const R3 = window.R3;

  const { network, urlSearchParams } = R3;
  export default {
    components: { foldPanel, DropDownCom },
    data() {
      return {
        strategy_id: '', // 当前策略id
        loading: false,
        isOpen: true,
        PrintBaseStatus: true,
        PrintBillStatus: true,
        PrintOrderStatus: true,
        PrintOutStatus: true,
        choosedExpressList: [],
        choosedExpressListOld: [],
        choosedWarehouseExpressList: [],
        shopList: [], // 店铺列表
        warehouseList: [], // 仓库列表
        selectShopArr: [], // 店铺搜索列表选中数据
        selectWarehouseArr: [], // 仓库搜索列表选中数据
        isShow: false, // 主页面参与店铺
        isShowWarehouse: false, // 设置仓库弹框
        showAllText: '展开',
        showAllTextWarehouse: '展开',

        formInline: {
          strategy_name: '', // 策略名称
          IsGiftSplit: '绑定主品拆单',
          constitute_goods_split: '按明细拆分',
          sku_no_split: '',
          noSplitQty: '',
          noSplitVolume: '',
          group_split_value: '',
          detailed_split_value: '',
          byskusplit: false,
          is_virtual_sku: true,
        },
        test: true,
        conditionModules: {
          stockModules: [
            {
              key: 'outOfStock',
              title: '有货先发',
              tips: '当订单在某一发货仓库部分商品缺货，将有库存的商品单独拆出，先发货。',
              value: true,
              leftbottomTip: '设置包裹最小件数:',
              num:'',
              buttonText: '设置',
            },
            {
              key: 'multiBinSplit',
              title: '多仓分拆',
              tips: '一个订单多商品，分布在多个不同的仓库，需要拆分后才能正常发出。',
              value: true,
              buttonText: '设置参与仓库',
            },
          ],
          orderModules: [
            {
              key: 'noSplitNum',
              title: '不拆单商品个数',
              tips: '订单商品个数大于等于设置值时，不拆分订单。用于包裹商品种类太多，直接走物流发货的情况。',
              value: true,
              leftbottomTip: '不拆单商品个数:',
              num:'',
              buttonText: '设置',
            },
            {
              key: 'noSplitQty',
              title: '不拆单商品件数',
              tips: '订单商品件数大于等于设置值时，不拆分订单。用于包裹商品数量太多，直接走物流发货的情况。',
              value: true,
              leftbottomTip: '不拆单商品件数:',
              num:'',
              buttonText: '设置',
            },
            {
              key: 'noSplitVolume',
              title: '不拆单商品体积',
              tips: '总体积大于等于设置值时，不拆分订单。用于包裹商品太多，直接走物流发货的情况。',
              value: true,
              leftbottomTip: '不拆单商品体积:',
              num:'',
              buttonText: '设置',
            },
          ],
          goodModules: [
            {
              key: 'appointVirtualSKU',
              title: '虚拟商品SKU',
              tips: '设置虚拟商品条码，订单中包含设置的虚拟商品的SKU，会将虚拟商品SKU拆在一个包裹中发出，包裹订单系统状态为仓库发货。',
              value: true,
              display: false,
              buttonText: '设置虚拟商品SKU',
            },
            {
              key: 'appointGoodLine',
              title: '一单一sku拆',
              tips: '一个订单有多商品时，以单sku维度进行拆分，拆分后的订单一单只有一个sku。',
              value: true,
              display: true,
              buttonText: '',
            },
            {
              key: 'appointSKU',
              title: '指定SKU',
              tips: '设置商品SKU，订单中包含设置的SKU的，会将指定商品拆在一个包裹中发出。支持拆分到数量。',
              value: true,
              display: true,
              buttonText: '设置商品SKU',
            },
            {
              key: 'appointGoods',
              title: '指定商品',
              tips: '设置商品款编码，订单中包含设置的款编码的，会将指定商品拆在一个包裹中发出。支持拆分到数量。',
              value: true,
              display: true,
              buttonText: '设置商品款',
            },
            {
              key: 'appointType',
              title: '指定类型/品牌',
              tips: '设置商品的类型和品牌，订单中包含设置的类型+品牌的，会将指定商品拆在一个包裹中发出。支持拆分到数量。',
              value: true,
              display: true,
              buttonText: '设置商品类型/品牌',
            },
            {
              key: 'packageVolume',
              title: '包裹体积',
              tips: '根据商品档案中维护的商品体积，按照设置的箱子规格进行分包裹，使得拆分包裹数最小。',
              value: true,
              display: true,
              buttonText: '箱规设置',
            },
          ],
        },
        // 弹框设置相关
        // 选择仓库弹框
        minPiecesInModal: false, // 设置最小件数
        noSplitNumModal: false, // 设置不拆单商品个数
        noSplitQtyModal: false, // 设置不拆单商品件数
        noSplitVolumeModal: false, // 设置不拆单商品体积
        setWarehouseInModal: false, // 设置参与仓库
        packageVolumeImModal: false, // 设置箱规
        mask: true,
        closable: true,
        maskClosable: false,
        hideFoot: true,
        StorageForm: {
          minPieces: '',
          noSplitNum: '',
          gift_no_split_num: '是',
          sku_no_split_num: '是',
          noSplitQty: '',
          gift_no_split_qty: '是',
          sku_no_split_qty: '是',
          noSplitVolume: '',
        },
        regx: /^\d{0,15}?$/, // 0-99正整数
        regx1: /^[1-9]\d{0,7}?$/, // 非0开头的正整数
        regx2: /^([1-9]\d{0,7}|\d)$/, //非0开头的正整数
        formValidate3: {
          name: '',
          volume: '',
        },
        ruleInline: {
          name: [
            { required: true, message: '请输入内容', trigger: 'blur' },
          ],
          volume: [
            { required: true, message: '请输入内容', trigger: 'blur' },
          ]
        },
        errorNameShow: false,
        errorName: '箱规名称已存在，请检查后重新输入',
        errorVolumeShow: false,
        errorVolume: '箱规体积已存在，请检查后重新输入',

        // 添加赠品数据
        columns2: [
          {
            title: '箱规名称',
            key: 'name',
            align: 'center',
          },
          {
            title: '箱规体积',
            key: 'volume',
            align: 'center',
          },
          {
            title: '创建人',
            key: 'createder',
            align: 'center',
          },
          {
            title: '创建时间',
            key: 'createdTime',
            align: 'center',
          },
          {
            title: '操作',
            key: 'action',
            width: 100,
            align: 'center',
            render: (h, params) => {
              const vm = this;
              return h('div', [
                h('a', {
                  attrs:{
                    class:'deleteBtnText'
                  },
                  on: {
                    click: () => {
                      this.deleteGiftTable(params.row,params.index);
                    }
                  }
                },'删除' )
              ]);
            }
          }
        ],
        giftTableDataAdd: [],
        deleteGiftList: [],

        // 操作确认弹框
        isShowSureToggleSwitch: false,
        TipTitle: '',
        toggleKey: '',
        pageMsgId: '', // 策略id
        isNew: false, // 是否策略新增页面
      };
    },
    created() {
      this.pageMsgId = this.$route.params.customizedModuleId;
      this.getShopArr(); // 获取店铺列表
      this.getWarehouseArr(); // 获取仓库列表
      if(this.pageMsgId == 'New') {
        this.isNew = true;
      }else {
        this.isNew = false;
      }
    },
    mounted() {
      if(!this.isNew){
        this.getStrategyList(); // 获取拆单策略列表
      }
    },
    methods: {
      keyUp(e,type){
        if (type == 'strategyname') {
        }else if (type == 'noSplitQty'){
          if(this.formInline.noSplitQty){
            if(this.formInline.noSplitQty.length > 8){
              this.formInline.noSplitQty=(this.formInline.noSplitQty.replace(/\D/g,'')==''?'':parseInt(this.formInline.noSplitQty))
              this.formInline.noSplitQty = String(this.formInline.noSplitQty).slice(0,8)
              return;
            }else {
              this.formInline.noSplitQty=(this.formInline.noSplitQty.replace(/\D/g,'')==''?'':parseInt(this.formInline.noSplitQty))
            }
          }
        }else if(type == 'noSplitVolume'){
          if(this.formInline.noSplitVolume){
            if(this.formInline.noSplitVolume.length > 8){
              this.formInline.noSplitVolume=(this.formInline.noSplitVolume.replace(/\D/g,'')==''?'':parseInt(this.formInline.noSplitVolume))
              this.formInline.noSplitVolume = String(this.formInline.noSplitVolume).slice(0,8)
              return;
            }else {
                this.formInline.noSplitVolume=(this.formInline.noSplitVolume.replace(/\D/g,'')==''?'':parseInt(this.formInline.noSplitVolume))
            }
          }
        }
      },
      deleteTrim(e){
        if(e.keyCode == '32'){
          setTimeout(() => {
            e.target.value = e.target.value.replace(/\s+/g,'');
            this.formValidate3.name = this.formValidate3.name.replace(/\s+/g,'');
          },0)
        }
      },
      // 新增时保存按钮
      saveAll() {
        if(!this.formInline.strategy_name){
          return this.$Message.error('策略名称不能为空');
        }
        if(this.choosedExpressList.length <= 0){
          return this.$Message.error('参与店铺不能为空');
        }
        this.noSplitQty = this.formInline.noSplitQty
        this.noSplitVolume = this.formInline.noSplitVolume
        let params = {
          strategy_name: this.formInline.strategy_name,
          gift_in: this.formInline.IsGiftSplit == '参与拆单'?1:this.formInline.IsGiftSplit == '绑定主品拆单'?0:2,
          constitute_goods_split: this.formInline.constitute_goods_split == '按明细拆分'?0:1,
          sku_no_split: this.formInline.sku_no_split,
          // no_split_qty: String(this.formInline.noSplitQty) == ''?null:this.formInline.noSplitQty,
          // no_split_volume: String(this.formInline.noSplitVolume) == ''?null:this.formInline.noSplitVolume,
          shop_ids: this.choosedExpressList,
          group_split_value: this.formInline.group_split_value,
          detailed_split_value: this.formInline.detailed_split_value,
          byskusplit: this.formInline.byskusplit?1:0,
          is_virtual_sku: this.formInline.is_virtual_sku?1:0,
        }
        network.post('/p/cs/order/split/strategy/create',params).then(res => {
          if(res.data.code == 0){
            this.$Message.success('新增策略成功');
            const { fullPath } = this.$route;
            const {
              keepAliveModuleName,tableName
            } = this.$store.state.global.activeTab;
            this.$store.commit('global/tabCloseAppoint', {
              tableName,
              routeFullPath: fullPath,
              keepAliveModuleName,
              stopRouterPush: true,
            });
            // 跳转
            setTimeout(()=>{
              R3.store.commit('global/tabOpen', {
                type : 'tableDetailAction'||'C',
                label: '商品拆单策略',
                customizedModuleName:'SplittingStrategy',
                customizedModuleId:res.data.data,
              });
            },0)
          }
        })

      },
      // 关闭当前页面
      closePage(){
        const { fullPath } = this.$route;
        const {
          keepAliveModuleName,tableName
        } = this.$store.state.global.activeTab;
        this.$store.commit('global/tabCloseAppoint', {
          tableName,
          routeFullPath: fullPath,
          keepAliveModuleName,
          stopRouterPush: true,
        });
         // 跳转
        setTimeout(()=>{
          R3.store.commit('global/tabOpen', {
            type: 'S',
            tableName:'T_V_OMS_SPLITSTRATEGY',
            tableId:'11559',
            back:true
          });
        },0)
      },
      // 获取拆单策略列表,获取详情信息
      getStrategyList() {
        let params = {
          strategy_id: this.pageMsgId
        }
        network.post('/p/cs/order/split/strategy/list',params).then((res)=> {
          if(res.data.code == 0){
            this.choosedExpressList = [];
            this.strategy_id = res.data.data[0].strategy_id;
            this.formInline.strategy_name = res.data.data[0].strategy_name;
            this.formInline.IsGiftSplit = res.data.data[0].gift_in == 0?'绑定主品拆单':res.data.data[0].gift_in == 1?'参与拆单':'单独拆为一单';
            this.formInline.constitute_goods_split = res.data.data[0].constitute_goods_split == '1'?'按组合拆分':'按明细拆分';
            this.formInline.sku_no_split = res.data.data[0].sku_no_split;
            this.StorageForm.noSplitNum = String(res.data.data[0].no_split_num) == ''?'':res.data.data[0].no_split_num;
            this.StorageForm.gift_no_split_num = res.data.data[0].gift_no_split_num == 0?'否':'是';
            this.StorageForm.sku_no_split_num = res.data.data[0].sku_no_split_num == 0?'否':'是';
            this.formInline.noSplitQty = String(res.data.data[0].no_split_qty) == ''?'':res.data.data[0].no_split_qty;
            this.StorageForm.noSplitQty = String(res.data.data[0].no_split_qty) == ''?'':res.data.data[0].no_split_qty;
            this.StorageForm.gift_no_split_qty = res.data.data[0].gift_no_split_qty == 0?'否':'是';
            this.StorageForm.sku_no_split_qty = res.data.data[0].sku_no_split_qty == 0?'否':'是';
            this.formInline.noSplitVolume = String(res.data.data[0].no_split_volume) == ''?'':res.data.data[0].no_split_volume;
            this.StorageForm.noSplitVolume = String(res.data.data[0].no_split_volume) == ''?'':res.data.data[0].no_split_volume;
            this.conditionModules.orderModules[0].value = res.data.data[0].no_split_num_status == 0?false:true;
            this.conditionModules.orderModules[1].value = res.data.data[0].no_split_qty_status == 0?false:true;
            this.conditionModules.orderModules[2].value = res.data.data[0].no_split_volume_status == 0?false:true;
            this.conditionModules.orderModules[0].num = String(res.data.data[0].no_split_num) == ''?'':res.data.data[0].no_split_num;
            this.conditionModules.orderModules[1].num = String(res.data.data[0].no_split_qty) == ''?'':res.data.data[0].no_split_qty;
            this.conditionModules.orderModules[2].num = String(res.data.data[0].no_split_volume) == ''?'':res.data.data[0].no_split_volume;
            this.formInline.group_split_value = res.data.data[0].group_split_value
            this.formInline.detailed_split_value = res.data.data[0].detailed_split_value
            this.formInline.byskusplit = res.data.data[0].byskusplit==1?true: false;
            this.formInline.is_virtual_sku = res.data.data[0].is_virtual_sku==1?true: false;
            this.choosedExpressList = []
            if(res.data.data[0].shop_list && res.data.data[0].shop_list.length > 0){
              res.data.data[0].shop_list.forEach(item => {
                this.choosedExpressList.push(item.shop_id);
              })
              this.choosedExpressListOld = JSON.parse(JSON.stringify(this.choosedExpressList))
            }
            this.selectShopArr = [];
            if(this.shopList.length > 0){
              let list = []
              if (res.data.data[0].shop_list.length > 0) {
              res.data.data[0].shop_list.forEach(item => {
                this.shopList.forEach(obj => {
                  if (item.shop_id == obj.value) {
                    list.push(String(obj.value));
                    this.selectShopArr.push(obj);
                  }
                });
              });
              this.choosedExpressList = list;
              this.$refs.DropDownCom.choosedExpress = this.choosedExpressList;
            }
            }
            this.getStrategyRuleList();
          }
          // setTimeout(() => {
          //   this.getShopArr(); // 获取店铺列表
          // },500)
        })
      },
      // 获取策略配置是否开启
      getStrategyRuleList() {
        let params = {
          strategy_id: this.pageMsgId
        }
        network.post('/p/cs/order/split/strategy/rule/list',params).then(res => {
          res.data.data.forEach(item => {
            if(item.rule_key == 'StockOut'){
              this.conditionModules.stockModules[0].value = item.isactive=='Y'?true:false;
              this.conditionModules.stockModules[0].strategy_rule_id = item.strategy_rule_id;
            }else if(item.rule_key == 'MultiWarehouse'){
              this.conditionModules.stockModules[1].value = item.isactive=='Y'?true:false;
              this.conditionModules.stockModules[1].strategy_rule_id = item.strategy_rule_id;
            }else if(item.rule_key == 'VirtualSku'){
              this.conditionModules.goodModules.find(item=>item.key=='appointVirtualSKU').value = item.isactive=='Y'?true:false;
              this.conditionModules.goodModules.find(item=>item.key=='appointVirtualSKU').strategy_rule_id = item.strategy_rule_id;
            }else if(item.rule_key == 'ProductRow'){
              this.conditionModules.goodModules.find(item=>item.key=='appointGoodLine').value = item.isactive=='Y'?true:false;
              this.conditionModules.goodModules.find(item=>item.key=='appointGoodLine').strategy_rule_id = item.strategy_rule_id;
            }else if(item.rule_key == 'Sku'){
              this.conditionModules.goodModules.find(item=>item.key=='appointSKU').value = item.isactive=='Y'?true:false;
              this.conditionModules.goodModules.find(item=>item.key=='appointSKU').strategy_rule_id = item.strategy_rule_id;
            }else if(item.rule_key == 'Product'){
              this.conditionModules.goodModules.find(item=>item.key=='appointGoods').value = item.isactive=='Y'?true:false;
              this.conditionModules.goodModules.find(item=>item.key=='appointGoods').strategy_rule_id = item.strategy_rule_id;
            }else if(item.rule_key == 'Attribute'){
              this.conditionModules.goodModules.find(item=>item.key=='appointType').value = item.isactive=='Y'?true:false;
              this.conditionModules.goodModules.find(item=>item.key=='appointType').strategy_rule_id = item.strategy_rule_id;
            }else if(item.rule_key == 'Package'){
              this.conditionModules.goodModules.find(item=>item.key=='packageVolume').value = item.isactive=='Y'?true:false;
              this.conditionModules.goodModules.find(item=>item.key=='packageVolume').strategy_rule_id = item.strategy_rule_id;
            }
          })
          this.getStrategyRuleParam(this.conditionModules.stockModules[0].strategy_rule_id,this.conditionModules.stockModules[0])
        })
      },
      // 通过策略规则中的strategy_rule_id去查询具体设置信息
      getStrategyRuleParam(id,condition) {
        this.giftTableDataAdd = [];
        if(condition.key == 'packageVolume'){
          let virtual = {
            table: 'T_IESBOX_SPEC',
            startindex: 0,
            range: 100,
            fixedcolumns: { OMSSTRATEGYID: [`=${this.strategy_id}`] },
            isdroplistsearch: true
          };
          network.post('/p/cs/list/query',virtual).then((res) => {
              res.data.rows.forEach(item => {
                let obj = {
                  id: item.ID.val,
                  name: item.NAME.val,
                  volume: item.VOLUME.val,
                  createder: item.OWNERID.val,
                  createdTime: item.CREATIONDATE.val,
                }
                this.giftTableDataAdd.push(obj);
              })
          })
        }else {
          let params = {
            strategy_rule_id: id
          }
          network.post('/p/cs/order/split/strategy/rule/param/list',params).then(res => {
            if(res.data.code == 0){
              if(condition.key == 'outOfStock'){
                console.log(111,res.data.data[0])
                condition.num = res.data.data[0].split_qty;
                this.StorageForm.minPieces = res.data.data[0].split_qty;
              } else if(condition.key == 'multiBinSplit'){
                res.data.data.forEach(item => {
                  this.choosedWarehouseExpressList.push(item.rel_id);
                })
                this.getWarehouseArr();
              }
            }
          })
        }
      },
      // 策略规则中详细信息修改的保存
      saveStrategyRuleCon(id,condition){
        let params = {};
        if(condition.key == 'outOfStock' || condition.key == 'multiBinSplit'){
          if(condition.key == 'outOfStock'){
            params = {
              strategy_rule_id: id,
              ops_type:0,
              rel_list:[],
              split_qty: this.StorageForm.minPieces
            }
          }else if(condition.key == 'multiBinSplit'){
            let rel_list = []
            this.choosedWarehouseExpressList.forEach(item => {
              let obj = {
                id: item
              }
              rel_list.push(obj)
            })
            params = {
              strategy_rule_id: id,
              ops_type:0,
              rel_list: rel_list
            }
          }
          network.post('/p/cs/order/split/strategy/rule/param',params).then(res => {
            if(res.data.code == 0){
              if(condition.key == 'outOfStock'){
                this.cancel('minPieces')
              }else if(ondition.key == 'multiBinSplit'){
                this.choosedWarehouseExpressList = [];
                this.selectWarehouseArr = [];
                this.cancel('setWarehouse')
              }
            }
          })
        }else if(condition.key == 'packageVolume'){
          let box_list = []
          let flag = false;
          // 新增箱规
          this.giftTableDataAdd.forEach(item => {
            if(!item.id){
              flag = true;
              let obj = {
                name: item.name,
                volume: item.volume
              }
              box_list.push(obj);
            }
          })
          if(flag){
            let params = {
              strategy_id: this.strategy_id,
              box_list: box_list
            }
            network.post('/p/cs/order/split/strategy/boxspec/save',params).then(res =>{
              // this.cancel('packageVolume');
            })
          }
          // 删除箱规
          if(this.deleteGiftList.length > 0){
            let params = {
              ids: this.deleteGiftList,
              tableName: 'T_IESBOX_SPEC'
            }
            network.post('/p/cs/batchDelete',params).then(res => {
              // this.cancel('packageVolume');
            })
          }
          // if(this.deleteGiftList.length == 0 && !flag){
            this.cancel('packageVolume');
          // }
        }
      },

      sureNoSplitNum() {
        this.savestrategyBase();
      },
      sureNoSplitQty() {
        this.savestrategyBase();
      },
      sureNoSplitVolume() {
        this.savestrategyBase();
      },

      // 策略基础信息保存
      savestrategyBase(isactive,type) {
        // if(this.isNew){  // 如果是新增页面，无需实时更新
        //   return false;
        // }
        if(!this.formInline.strategy_name){
          return this.$Message.error('策略名称不能为空');
        }
        if(this.choosedExpressList.length <= 0){
          return this.$Message.error('参与店铺不能为空');
        }
        // if(type == 'noSplitQty' && e.target.value == String(this.noSplitQty)){
        //   return
        // }else if(type == 'noSplitVolume' && e.target.value == String(this.noSplitVolume)){
        //   return
        // }
        this.noSplitQty = this.formInline.noSplitQty
        this.noSplitVolume = this.formInline.noSplitVolume
        let params = {
          strategy_id: this.pageMsgId,
          strategy_name: this.formInline.strategy_name,
          gift_in: this.formInline.IsGiftSplit == '参与拆单'?1:this.formInline.IsGiftSplit == '绑定主品拆单'?0:2,
          constitute_goods_split:this.formInline.constitute_goods_split == '按明细拆分'?0:1,
          sku_no_split: this.formInline.sku_no_split,
          no_split_num: String(this.StorageForm.noSplitNum) == ''?null:this.StorageForm.noSplitNum,
          gift_no_split_num: this.StorageForm.gift_no_split_num == '是'?1:0,
          sku_no_split_num: this.StorageForm.sku_no_split_num == '是'?1:0,
          no_split_qty: String(this.StorageForm.noSplitQty) == ''?null:this.StorageForm.noSplitQty,// String(this.formInline.noSplitQty) == ''?null:this.formInline.noSplitQty,
          gift_no_split_qty: this.StorageForm.gift_no_split_qty == '是'?1:0,
          sku_no_split_qty: this.StorageForm.sku_no_split_qty == '是'?1:0,
          no_split_volume: String(this.StorageForm.noSplitVolume) == ''?null:this.StorageForm.noSplitVolume,// String(this.formInline.noSplitVolume) == ''?null:this.formInline.noSplitVolume,
          shop_ids: this.choosedExpressList,
          group_split_value: this.formInline.group_split_value,
          detailed_split_value: this.formInline.detailed_split_value,
          byskusplit: this.formInline.byskusplit?1:0,
          is_virtual_sku: this.formInline.is_virtual_sku?1:0,
        }
        if(type == 'noSplitNum'){
          params.no_split_num_status = isactive?'1':'0'
        } else if(type == 'noSplitQty') {
          params.no_split_qty_status = isactive?'1':'0'
        } else if(type == 'noSplitVolume') {
          params.no_split_volume_status = isactive?'1':'0'
        }
        network.post('/p/cs/order/split/strategy/save',params).then(res => {
          if(res.data.code == 0){
            if(this.noSplitNumModal){
              this.noSplitNumModal = false
            }
            if(this.noSplitQtyModal){
              this.noSplitQtyModal = false
            }
            if(this.noSplitVolumeModal){
              this.noSplitVolumeModal = false
            }
            if(!this.isNew){
              this.getStrategyList(); // 获取拆单策略列表
            }
            this.$Message.success('编辑策略成功');
          }
        })
      },
      // 策略规则开关开启关闭状态保存
      saveStrategyRuleSwitch(id,isactive) {
        let params = {
          strategy_rule_id: id,
          isactive: isactive?'Y':'N'
        }
        network.post('/p/cs/order/split/strateg/rule/switch',params).then(res => {
          if(res.data.code == 0){
          }
        })
      },
      // 按订单策略规则开关开启关闭状态保存
      saveOrderStrategyRuleSwitch(key, isactive){
        this.savestrategyBase(isactive,key);
      },

      showCloseIcon(index) {
        this.selectShopArr[index].class = 'showCloseIcon';
        this.selectShopArr[index].flag = true;
        this.selectShopArr = JSON.parse(JSON.stringify(this.selectShopArr));
      },
      hideCloseIcon(index) {
        this.selectShopArr[index].class = '';
        this.selectShopArr[index].flag = false;
        this.selectShopArr = JSON.parse(JSON.stringify(this.selectShopArr));
      },
      // 以下为使用店铺相关逻辑
      // 初始化店铺列表
      getShopArr() {
        let data = {
          table: 'T_V_IESSHOP',
          range: 1000,
          isdroplistsearch: true,
          fkdrplist: {
            searchcols: ['ID', 'SHOPTITLE']
          }
        };
        network.post('/p/cs/list/query', data).then((res) => {
          if (res.data.rows.length) {
            this.shopList = res.data.rows.map(item=>({
              value: item.ID.val,
              label: item.SHOPTITLE.val
            }));
            if (this.choosedExpressList.length > 0) {
              let list = [];
              this.choosedExpressList.forEach(item => {
                this.shopList.forEach(obj => {
                  if (item == obj.value) {
                    list.push(String(obj.value));
                    this.selectShopArr.push(obj);
                  }
                });
              });
              this.choosedExpressList = list;
              this.$refs.DropDownCom.choosedExpress = this.choosedExpressList;
            }
          }
        });
      },
      changeShopArr(val, deffArr) {
        if (val.length) {
          if (val.some(item=>Object.hasOwnProperty.call(item, 'label'))) { // 全选时第一次传入没有label
            this.shopName = '';
            this.shopIds = '';
            this.choosedExpressList = [];
            let Data = [...val].filter(x => [...this.selectShopArr].every(y => y.value !== x.value));
            this.selectShopArr = [...this.selectShopArr, ...Data];
            if (deffArr.length) {
              this.selectShopArr = this.selectShopArr.filter(x => [...deffArr].every(y => y.value !== x.value)); // 过滤掉取消项
            }

            this.selectShopArr.forEach(item=>{
              this.choosedExpressList.push(String(item.value));
              this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
              this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
              item.flag = false;
            });
            this.$refs.DropDownCom.choosedExpress = this.choosedExpressList;
          }
        } else { // 当前下拉列表里全部清空
          this.shopName = '';
          this.shopIds = '';
          this.choosedExpressList = [];
          if (deffArr.length) {
            this.selectShopArr = this.selectShopArr.filter(x => [...deffArr].every(y => y.value !== x.value)); // 过滤掉取消项
          }

          this.selectShopArr.forEach(item=>{
            this.choosedExpressList.push(String(item.value));
            this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
            this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
            item.flag = false;
          });
          this.$refs.DropDownCom.choosedExpress = this.choosedExpressList;
        }
        if(this.$refs.DropDownCom.choosedExpress.join(',') == this.choosedExpressListOld.join(',')){

        }else {
          // this.savestrategyBase();
        }
      },
      getEnterExpressList(val) {
        let data = {
          table: 'T_V_IESSHOP',
          range: 1000,
          isdroplistsearch: true,
          fkdrplist: {
            searchcols: ['ID', 'SHOPTITLE']
          },
          fixedcolumns: { SHOPTITLE: val },
        };
        this.$refs.DropDownCom.choosedExpress = this.choosedExpressList;
        network.post('/p/cs/list/query', data).then((res) => {
          this.shopList = res.data.rows.map(item=>({
            value: item.ID.val,
            label: item.SHOPTITLE.val
          }));
        });
      },
      deleteShop(obj, index) { // 删除某一检索项
        this.$refs.DropDownCom.choosedExpress = this.$refs.DropDownCom.choosedExpress.filter(item=>obj.value != item);
        this.selectShopArr = this.selectShopArr.filter(item=>obj.value != item.value);
        this.shopName = '';
        this.shopIds = '';
        this.choosedExpressList = [];
        this.selectShopArr.forEach(item=>{
          this.choosedExpressList.push(String(item.value));
          this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
          this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
          item.flag = false;
        });
        this.$refs.DropDownCom.choosedExpress = this.choosedExpressList;
      },
      clearAllFilter(value) { // 清空带有筛选的检索项
        value.forEach(itemOne => {
          this.selectShopArr.forEach((item, index) => {
            if (itemOne.value == item.value) {
              this.selectShopArr.splice(index, 1);
            }
          });
        });
        this.choosedExpressList = [];
        this.selectShopArr.forEach(item=>{
          this.choosedExpressList.push(String(item.value));
          this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
          this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
          item.flag = false;
        });
        this.$refs.DropDownCom.choosedExpress = this.choosedExpressList;
      },
      clearAll() { // 清空全部检索项
        this.$refs.DropDownCom.choosedExpress = [];// 检索项清空
        this.selectShopArr = [];
        this.shopName = '';
        this.shopIds = '';
      },
      showAll(type) { // 显示所有搜索项
        if (type == 'setWarehouse') {
          this.isShowWarehouse = !this.isShowWarehouse;
          if (this.isShowWarehouse) {
            this.showAllTextWarehouse = '收起';
            document.getElementsByClassName('selectGroup')[1].style.height = 'auto';
          } else {
            document.getElementsByClassName('selectGroup')[1].style.height = '80px';
            this.showAllTextWarehouse = '展开';
          }
        } else {
          this.isShow = !this.isShow;
          if (this.isShow) {
            this.showAllText = '收起';
            document.getElementsByClassName('selectGroup')[0].style.height = 'auto';
          } else {
            document.getElementsByClassName('selectGroup')[0].style.height = '80px';
            this.showAllText = '展开';
          }
        }
      },
      // 以下为使用仓库相关逻辑
      // 初始化仓库列表
      getWarehouseArr() {
        network.post('/p/cs/QueryList', urlSearchParams({
          searchdata: {
            table: 'T_IESWAREHOUSE',
            startindex: 0,
            range: 1000,
            fixedcolumns: {},
            column_include_uicontroller: true,
            isolr: false
          }
        })).then(res => {
          if (res.data.data.row.length) {
            this.warehouseList = res.data.data.row.map(item=>({
              value: item.ID.val,
              label: item.WAREHOUSENAME.val
            }));
            if (this.choosedWarehouseExpressList.length > 0) {
              this.choosedWarehouseExpressList.forEach(item => {
                this.warehouseList.forEach(obj => {
                  if (item == obj.value) {
                    this.choosedWarehouseExpressList.push(String(obj.value));
                    this.selectWarehouseArr.push(obj);
                  }
                });
              });
              this.$refs.DropDownComWarehouse.choosedExpress = this.choosedWarehouseExpressList;
            }
          }
        });
      },
      changeWarehouseArr(val, deffArr) {
        if (val.length) {
          if (val.some(item=>Object.hasOwnProperty.call(item, 'label'))) { // 全选时第一次传入没有label
            this.shopName = '';
            this.shopIds = '';
            this.choosedWarehouseExpressList = [];
            let Data = [...val].filter(x => [...this.selectWarehouseArr].every(y => y.value !== x.value));
            this.selectWarehouseArr = [...this.selectWarehouseArr, ...Data];
            if (deffArr.length) {
              this.selectWarehouseArr = this.selectWarehouseArr.filter(x => [...deffArr].every(y => y.value !== x.value)); // 过滤掉取消项
            }

            this.selectWarehouseArr.forEach(item=>{
              this.choosedWarehouseExpressList.push(String(item.value));
              this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
              this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
              item.flag = false;
            });
            this.$refs.DropDownComWarehouse.choosedExpress = this.choosedWarehouseExpressList;
          }
        } else { // 当前下拉列表里全部清空
          this.shopName = '';
          this.shopIds = '';
          this.choosedWarehouseExpressList = [];
          if (deffArr.length) {
            this.selectWarehouseArr = this.selectWarehouseArr.filter(x => [...deffArr].every(y => y.value !== x.value)); // 过滤掉取消项
          }

          this.selectWarehouseArr.forEach(item=>{
            this.choosedWarehouseExpressList.push(String(item.value));
            this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
            this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
            item.flag = false;
          });
          this.$refs.DropDownComWarehouse.choosedExpress = this.choosedWarehouseExpressList;
        }
      },
      getWarehouseEnterExpressList(val) {
        let data = {
          table: 'T_V_IESSHOP',
          range: 1000,
          isdroplistsearch: true,
          fkdrplist: {
            searchcols: ['ID', 'SHOPTITLE']
          },
          fixedcolumns: { SHOPTITLE: val },
        };
        this.$refs.DropDownComWarehouse.choosedExpress = this.choosedWarehouseExpressList;
        network.post('/p/cs/list/query', data).then((res) => {
          this.shopList = res.data.rows.map(item=>({
            value: item.ID.val,
            label: item.SHOPTITLE.val
          }));
        });
      },
      deleteWarehouse(obj, index) { // 删除某一检索项
        this.$refs.DropDownComWarehouse.choosedExpress = this.$refs.DropDownComWarehouse.choosedExpress.filter(item=>obj.value != item);
        this.selectWarehouseArr = this.selectWarehouseArr.filter(item=>obj.value != item.value);
        this.shopName = '';
        this.shopIds = '';
        this.choosedWarehouseExpressList = [];
        this.selectWarehouseArr.forEach(item=>{
          this.choosedWarehouseExpressList.push(String(item.value));
          this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
          this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
          item.flag = false;
        });
        this.$refs.DropDownCom.choosedExpress = this.choosedWarehouseExpressList;
      },
      clearAllWarehouseFilter(value) { // 清空带有筛选的检索项
        value.forEach(itemOne => {
          this.selectWarehouseArr.forEach((item, index) => {
            if (itemOne.value == item.value) {
              this.selectWarehouseArr.splice(index, 1);
            }
          });
        });
        this.choosedWarehouseExpressList = [];
        this.selectWarehouseArr.forEach(item=>{
          this.choosedWarehouseExpressList.push(String(item.value));
          this.shopName = this.shopName == '' ? item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '') : (`${this.shopName},${item.label.replace(/[\r\n]/g, '').replace(/\ +/g, '')}`);
          this.shopIds = this.shopIds == '' ? item.value : `${this.shopIds},${item.value}`;
          item.flag = false;
        });
        this.$refs.DropDownComWarehouse.choosedExpress = this.choosedWarehouseExpressList;
      },
      clearAllWarehouse() { // 清空全部检索项
        this.$refs.DropDownComWarehouse.choosedExpress = [];// 检索项清空
        this.selectWarehouseArr = [];
        this.shopName = '';
        this.shopIds = '';
      },

      // 箱规弹框
      AddBoxSpecs(e){
        if (e.keyCode == 13) {
          this.AddBoxSpecsBtn('formValidate3');
        }
      },
      AddBoxSpecsBtn(name){
        this.$refs[name].validate((valid) => {
          if (valid) {
            let that = this;
            let flag1 = true;
            let flag2 = true;
            this.errorNameShow = false;
            try {
              that.giftTableDataAdd.forEach(item => {
                if(item.name == that.formValidate3.name.trim() || item.volume == that.formValidate3.volume.trim()){
                  if(item.name == that.formValidate3.name.trim()){
                    that.errorNameShow = true;
                    flag1 = false;
                    if(item.volume == that.formValidate3.volume.trim()){
                      that.errorVolumeShow = true;
                      flag2 = false;
                    }
                    throw new Error('err');
                  }
                  if(item.volume == that.formValidate3.volume.trim()){
                    that.errorVolumeShow = true;
                    flag2 = false;
                    throw new Error('err');
                  }
                }else {
                  that.errorNameShow = false;
                  that.errorVolumeShow = false;
                  flag1 = true;
                  flag2 = true;
                }
              })
            } catch (e){
              return;
            }
            if(flag1 && flag2){
              if(that.formValidate3.name == ''){
                return that.$Message.warning('请输入箱规名称');
              }else if(that.formValidate3.volume == ''){
                return that.$Message.warning('请输入箱规体积');
              }else {
                let obj = {
                  name: that.formValidate3.name,
                  volume: that.formValidate3.volume,
                  createder: JSON.parse(window.localStorage.getItem('userInfo')).userenv.$USER_ENAME$,
                  createdTime: that.getNowDate(),
                }
                that.giftTableDataAdd.unshift(obj);
              }
            }
          } else {
            if(this.formValidate3.name == ''){
              this.errorNameShow = false;
              if(this.formValidate3.volume == ''){
                this.errorVolumeShow = false
              }
            }else if(this.formValidate3.volume == ''){
              this.errorVolumeShow = false
            }
          }
        })
      },
      deleteGiftTable(row,index){
        this.deleteGiftList.push(row.id);
        this.giftTableDataAdd.splice(index, 1);
      },
      getNowDate() {
          var n = new Date();
          return n.getFullYear() + "-" + (n.getMonth() + 1) + "-" + n.getDate() + " " + n.getHours() + ":" + n.getMinutes() + ":" + n.getSeconds();
      },

      // 设置弹框相关
      squreBtn(key) {
        switch (key) {
        case 'outOfStock': this.minPiecesInModal = true;break;
        case 'noSplitNum': this.noSplitNumModal = true;break;
        case 'noSplitQty': this.noSplitQtyModal = true;break;
        case 'noSplitVolume': this.noSplitVolumeModal = true;break;
        case 'multiBinSplit': this.setWarehouseInModal = true; this.getStrategyRuleParam(this.conditionModules.stockModules[1].strategy_rule_id,this.conditionModules.stockModules[1]);break;
        case 'packageVolume': this.packageVolumeImModal = true; this.getStrategyRuleParam(this.conditionModules.goodModules.find(item=>item.key=='packageVolume').strategy_rule_id,this.conditionModules.goodModules.find(item=>item.key=='packageVolume'));break;
        case 'appointVirtualSKU': this.GoLinkTo('SYSTEMPARAMSSETTING','3219');break;
        case 'appointSKU': this.GoLinkTo('T_V_SPLITSTRATEGYPARAM_SKU','11420');break;
        case 'appointGoods': this.GoLinkTo('T_V_SPLITSTRATEGYPARAM_PRO','11421');break;
        case 'appointType': this.GoLinkTo('T_OMS_SPLITSTRATEGYATTR','11422');break; //T_OMS_SPLITSTRATEGYPARAMATTR
        default: break;
        }
      },
      // 跳转到指定标准列表
      GoLinkTo(tableName,tableId){
        // 跳转
        let label = '';
        let OMSSTRATEGYRULEID = '';
        if(tableName == 'SYSTEMPARAMSSETTING'){
          // 跳转
          setTimeout(()=>{
            R3.store.commit('global/tabOpen', {
              type : 'tableDetailAction'||'C',
              label: '系统参数管理',
              customizedModuleName:'SYSTEMPARAMSSETTING',
              customizedModuleId:tableId
            });
          },0)
        }else {
          if(tableName == 'T_V_SPLITSTRATEGYPARAM_SKU'){
            label = '指定SKU'
            OMSSTRATEGYRULEID = this.conditionModules.goodModules.find(item=>item.key=='appointSKU').strategy_rule_id
          }else if(tableName == 'T_V_SPLITSTRATEGYPARAM_PRO'){
            label = '指定商品'
            OMSSTRATEGYRULEID = this.conditionModules.goodModules.find(item=>item.key=='appointGoods').strategy_rule_id
          }else if(tableName == 'T_OMS_SPLITSTRATEGYATTR'){
            label = '指定类型/品牌'
            OMSSTRATEGYRULEID = this.conditionModules.goodModules.find(item=>item.key=='appointType').strategy_rule_id
          }
          // OMSSTRATEGYRULEID: OMSSTRATEGYRULEID,
          setTimeout(() => {
            R3.store.commit('global/tabOpen', {
              type: 'S',
              tableName: tableName,
              tableId: tableId,
              label: label,
              back: true,
              originSource:{
                OMSSTRATEGYID: this.strategy_id
              },
            });
          }, 0);
        }
      },
      cancel(type) {
        if (type == 'minPieces') {
          this.minPiecesInModal = false;
        } else if(type == 'noSplitNum') {
          this.noSplitNumModal = false;
        } else if(type == 'noSplitQty') {
          this.noSplitQtyModal = false;
        } else if(type == 'noSplitVolume') {
          this.noSplitVolumeModal = false;
        } else if (type == 'setWarehouse') {
          this.setWarehouseInModal = false;
        } else if (type == 'packageVolume') {
          this.formValidate3 = {name: '',volume: ''};
          this.giftTableDataAdd = [];
          this.errorNameShow = false;
          this.errorVolumeShow = false;
          this.packageVolumeImModal = false;
        } else if (type == 'ToggleSwitch') {
          switch(this.toggleKey){ // 是否确认开启开关，取消情况下，开关变回原始状态
            case 'outOfStock': this.conditionModules.stockModules.find(item=>item.key=='outOfStock').value = !this.conditionModules.stockModules.find(item=>item.key=='outOfStock').value;break;
            case 'multiBinSplit': this.conditionModules.stockModules.find(item=>item.key=='multiBinSplit').value = !this.conditionModules.stockModules.find(item=>item.key=='multiBinSplit').value;break;
            case 'noSplitNum': this.conditionModules.orderModules.find(item=>item.key=='noSplitNum').value = !this.conditionModules.orderModules.find(item=>item.key=='noSplitNum').value;break;
            case 'noSplitQty': this.conditionModules.orderModules.find(item=>item.key=='noSplitQty').value = !this.conditionModules.orderModules.find(item=>item.key=='noSplitQty').value;break;
            case 'noSplitVolume': this.conditionModules.orderModules.find(item=>item.key=='noSplitVolume').value = !this.conditionModules.orderModules.find(item=>item.key=='noSplitVolume').value;break;
            case 'appointVirtualSKU': this.conditionModules.goodModules.find(item=>item.key=='appointVirtualSKU').value = !this.conditionModules.goodModules.find(item=>item.key=='appointVirtualSKU').value;break;
            case 'appointGoodLine': this.conditionModules.goodModules.find(item=>item.key=='appointGoodLine').value = !this.conditionModules.goodModules.find(item=>item.key=='appointGoodLine').value;break;
            case 'appointSKU': this.conditionModules.goodModules.find(item=>item.key=='appointSKU').value = !this.conditionModules.goodModules.find(item=>item.key=='appointSKU').value;break;
            case 'appointGoods': this.conditionModules.goodModules.find(item=>item.key=='appointGoods').value = !this.conditionModules.goodModules.find(item=>item.key=='appointGoods').value;break;
            case 'appointType': this.conditionModules.goodModules.find(item=>item.key=='appointType').value = !this.conditionModules.goodModules.find(item=>item.key=='appointType').value;break;
            case 'packageVolume': this.conditionModules.goodModules.find(item=>item.key=='packageVolume').value = !this.conditionModules.goodModules.find(item=>item.key=='packageVolume').value;break;
            default: break;
          }
          this.isShowSureToggleSwitch = false;
        }
      },
      // 确认设置最小件数
      sureMinPieces() {
        this.saveStrategyRuleCon(this.conditionModules.stockModules[0].strategy_rule_id,this.conditionModules.stockModules[0]);
      },
      // 确认设置参与仓库
      sureSetWarehouse() {
        this.saveStrategyRuleCon(this.conditionModules.stockModules[1].strategy_rule_id);
      },
      // 确认设置箱规
      sureSetPackageVolume() {
        this.saveStrategyRuleCon(this.conditionModules.goodModules.find(item=>item.key=='packageVolume').strategy_rule_id,this.conditionModules.goodModules.find(item=>item.key=='packageVolume'));
      },

      changeSwitch(e,key){
        this.toggleKey = key;
        this.isShowSureToggleSwitch = true;
        this.TipTitle = e ? '打开开关后立刻生效，是否确认修改策略状态为开启':'关闭开关后立刻生效，是否确认修改策略状态为关闭';
      },
      sureToggleSwitch() {
        this.conditionModules.stockModules.forEach(item => {
          if(this.toggleKey == item.key){
            this.saveStrategyRuleSwitch(item.strategy_rule_id,item.value)
          }
        })
        this.conditionModules.orderModules.forEach(item => {
          if(this.toggleKey == item.key){
            this.saveOrderStrategyRuleSwitch(this.toggleKey,item.value)
          }
        })
        this.conditionModules.goodModules.forEach(item => {
          if(this.toggleKey == item.key) {
            this.saveStrategyRuleSwitch(item.strategy_rule_id,item.value)
          }
        })
      },
      // 以上为使用店铺相关逻辑
      // 注意展开关闭
      toggleArrow() {
        this.isOpen = !this.isOpen;
      },

      // 去重
      unique(arr) {
        const res = new Map();
        return arr.filter((arr) => !res.has(arr) && res.set(arr, 1));
      },
    },
  };
</script>
<style lang='less'>
  .img-framelanflag{
      cursor: pointer;
      margin-left:4px;
      width: 16px;
  }
  .chooseStorageBox .ark-select-single .ark-select-selection {
    height: 32px;
    .ark-select-input {
      height: 32px;
      line-height: 30px;
    }
  }
  .chooseStorageBox .ark-select-single .ark-select-selection .ark-select-placeholder, .chooseStorageBox .ark-select-single .ark-select-selection .ark-select-selected-value {
    height: 32px;
    line-height: 30px;
  }
  .joinStore .DropDownSelectInput .ark-iconios-close-circle {
    margin-top: 6px;
  }
  .joinStore .DropDownSelectInput .ark-input-innerWrap {
    height: 36px;
    width: 64px;
    text-align: center;
    background: #eee;
    border: 1px solid #d8d8d8;
    border-radius: 0 2px 2px 0;
    border-left: none;
  }
  .joinStore .DropDownSelectFilter .ark-input {
    width: calc(100% - 64px);
  }

  .OrderMsg .foldPanelContent {
    margin-top: 24px;
  }
  .OrderMsg .ark-form-inline .ark-form-item {
    width: 300px;
  }
  .OrderMsg .ark-checkbox-large .ark-checkbox-inner {
    width: 24px;
    height: 24px;
  }
  // .OrderMsg .ark-checkbox-checked .ark-checkbox-inner:after {
  //   width: 7px;
  //   height: 12px;
  //   top: 3px;
  //   left: 7px;
  // }
  .OrderMsg .ark-collapse-content > .ark-collapse-content-box {
    padding-bottom: 0px;
    padding-left: 0px;
  }

  .conditionContent .itemLabel .ark-tooltip {
    margin-left: 6px;
    margin-top: 4px;
  }
  .condTop .ark-switch-checked {
    border-color: #52C41A;
    background-color: #52C41A;
  }
  .condTop .ark-switch:focus {
    box-shadow: 0 0 0 2px #eee;
  }
  .condBottom .ark-btn {
    padding: 7px;
  }
  .conditionInput {
    width: 240px;
    height: 32px;
    .ark-input {
      height: 32px;
      // margin-left: -10px;
    }
  }
  .chooseStorageForm.SplitForm.minPiecesForm .chooseStorageBox .ark-input-wrapper  {
    width: calc(100% - 50px);
    height: 32px;
  }
  .chooseStorageForm.SplitForm.minPiecesForm .chooseStorageBox .ark-form .ark-form-item-label {
    padding-top: 12px;
  }
  .chooseStorageForm.SplitForm.minPiecesForm .chooseStorageBox .ark-input-wrapper .ark-input {
    height: 32px;
  }
  .chooseStorageForm.SplitForm.minPiecesForm .chooseStorageBoxVolume .ark-input-wrapper .ark-input {
    // border-right: 0;
  }
  .packageVolumeImModal .ark-iconios-close-circle {
    margin-top: 4px;
  }
  .packageVolumeImModal .ark-input {
    height: 32px;
    line-height: 32px;
  }
  .packageVolumeImModal .ark-form-item-required .ark-form-item-label:before {
    display: none;
  }

  .PostDelivery.SplittingStrategy .foldPanelContent .foldPanelTitle {
    font-size: 18px;
    font-weight: 700;
  }
  .PostDelivery.SplittingStrategy .ark-input-group > .ark-input:last-child, .ark-input-group-append {
    background: #fff;
  }
  .chooseStorageForm  .chooseStorageBox .ark-form-item {
    margin-bottom: 10px;
  }
  // .deleteBtnText {
  //   color: #b1b1b1;
  // }
  // .deleteBtnText:hover {
  //   color: red;
  // }
</style>
<style lang='less' scoped>
    .PostDelivery {
      min-width: 1300px;
      height: 100%;
    }
    .PostDeliveryContent {
      width: 100%;
      min-height: calc(100% - 70px);
      background: #fff;
      // margin-top:-50px;
      padding: 24px 0px;
      .scanInWarning {
        padding: 16px;
        background: #D5E7FF;
        .warningTitle {
          display: flex;
          align-items: center;
          span {
            color: #0046B9;
          }
          img {
            width: 14px;
            height: 14px;
            margin-right: 6px;
          }
        }
        .warningText {
          padding-left: 16px;
          margin-top: 6px;
          color: #0046B9;
          p {
            line-height: 18px;
          }
        }
      }
      .conditionBefore {
        margin-top: 24px;
        .joinStore {
          display: flex;
          .conditionContent {
            width: unset;
          }
          .shopSelect {
            width: 100%;
          }
        }
      }
      .conditionContent {
        width: 100%;
        display: flex;
        // padding-left: 16px;
        .itemContent {
          // width: calc(100%  / 3);
          display: flex;
          flex: 1;
          align-items: baseline;
          justify-content: flex-end;
          margin: 0 40px 16px 0px;
          .itemLabel {
            // min-width: 80px;
            min-width: 100px;
            font-size: 12px;
            font-weight: 500;
            color: #4C4C4C;
            line-height: 17px;
            margin-right: 8px;
            text-align: right;
          }
          .itemLabel.storeLabel, .itemLabel.strategyName {
            min-width: 80px;
          }
          .ark-radio-wrapper:last-child {
            margin-left: 20px;
          }
          .itemContentUnit {
            color: #909399;
            font-size: 12px;
            margin-left: -6px;
          }
          .posterType {
            width: calc(100% - 84px);
          }
          img {
            width: 16px;
            height: 16px;
          }
        }
        .itemContent:nth-child(2) {
          justify-content: center;
        }
        .itemContent:first-child {
          justify-content: flex-start;
        }
        .itemContent:last-child {
          margin-right: 0px;
        }
      }
      .OrderMsg {
        position: relative;
        .subTitle {
          // position: absolute;
          // top: 51px;
          // left: 16px;
          font-size: 14px;
        }
        .consitionModulesBox {
          display: flex;
          .conditionItem {
            display: flex;
            .conditionItemSqure {
              width: 290px;
              height: 150px;
              background: #F6F7FB;
              margin-right: 10px;
              padding: 16px;
              font-size: 12px;
              color: #4C4C4C;
              margin-top: 20px;
              .condTop {
                display: flex;
                justify-content: space-between;
                align-items: center;
                font-weight: bold;
              }
              .condMiddle {
                height: 50px;
                margin: 8px 0;
              }
              .bottomContent {
                display: flex;
                justify-content: space-between;
                align-items: center;
              }
              .condBottom {
                text-align: right;
                .setBtn {
                  min-width: 60px;
                  color: var(--primary-color);
                  border: 1px solid #DEDEDE;
                }
              }
            }
            img {
              width: 14px;
              height: 20px;
              margin-right: 10px;
              margin-top: 62px;
            }
          }
          .conditionItem:last-child img {
            display: none;
          }
        }
      }
    }
    .shopSelect{
          .selectPart{
            display: flex;
            width: 800px;
            .selectGroup{
              flex: 1;
              height:52px;
              overflow: hidden;
              margin-top: 8px;
              display: flex;
              flex-wrap: wrap;
              .groupItem{
                background: #F2F2F2;
                border-radius: 2px;
                margin-right:8px;
                margin-bottom:8px;
                padding: 0 8px;
                height: 18px;
                font-size: 11px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #333333;
                line-height: 16px;
              }
            }
            .selectBtn{
              display: flex;
              height:40px;
              color:#0F6AFB;
              font-family: PingFangSC-Medium, PingFang SC;
              font-weight: 500;

            }
          }
    }
    .minShop.shopSelect{
          .selectPart{
            display: flex;
            width: 100%;
            .selectGroup{
              flex: 1;
              height:80px;
              overflow: hidden;
              margin-top: 8px;
              display: flex;
              flex-wrap: wrap;
              width: calc(100% - 100px);
              .groupItem{
                display: flex;
                align-items: center;
                justify-content: center;
                text-align: center;
                width: 120px;
                height: 32px;
                background: #fff;
                border: 1px solid #DADADA;
                border-radius: 2px;
                margin-right:8px;
                margin-bottom:8px;
                padding: 0 8px;
                font-size: 11px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #333333;
                span {
                  display: inline-block;
                  width: 100px;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                }
              }
              .groupItem.showCloseIcon {
                width: 140px;
                color: var(--primary-color);
                background: #F0F4FF;
                border: 1px solid var(--primary-color);
                padding-right: 0px;
                .iconClose {
                  margin-left: 8px;
                  color: #0046B9;
                  font-size: 30px;
                }
              }
            }
            .selectBtn{
              display: flex;
              height:40px;
              color:#0F6AFB;
              font-family: PingFangSC-Medium, PingFang SC;
              font-weight: 500;
              margin-top: 10px;
            }
          }
    }
    .chooseStorageForm {
      padding-right: 30px;
    }
    .bottomBtnBox {
      width: calc(100% + 32px);
      margin: 16px auto 0px;
      margin-left: -16px;
      text-align: center;
      border-top: 1px solid #DEDEDE;
      padding-top: 16px;
      .cancelBtn,.sureBtn {
        width: 72px;
        height: 32px;
        font-size: 12px;
      }
      .cancelBtn {
        color: #909399;
        border: 1px solid #DADADA;
        margin-right: 8px;
      }
    }
    .chooseStorageForm.SplitForm p {
      font-size: 12px;
      color: #AEAEAE;
      line-height: 20px;
      margin-bottom: 20px;
    }
    .packageVolumeImModal .itemContentUnit {
      width: 100px;
      height: 32px;
      text-align: center;
      line-height: 30px;
      border: 1px solid #d8d8d8;
      border-left: none;
    }

    .quickOperation{
      height: 64px;
      border-bottom: 1px solid #D8D8D8;
      display: flex;
      align-items: center;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
    }

</style>
