<template>
  <div class='AbnormalPriceMonitoreStrategy'>
    <div class="quickOperation">
      快捷操作：
      <Button
        type="fcdefault"
        style="margin-right:8px"
        @click="saveAll"
      >
        保存
      </Button>
      <!-- <Button type="fcdefault" style="margin-right:8px" @click="refreshParams">刷新</Button> -->
      <Button type="fcdefault"
      @click="backToList"
      >
        返回
      </Button>
    </div>
    <div class="content">
      <div
        v-for="(item,tabId) in tabList"
        :key="tabId"
        class="block"
      >
        <foldPanel
          v-model="item.blockShow"
          :title="item.tabtext"
          :explain="item.explainText"
        >
          <div
            slot="content"
            class="block"
          >
            <div class="item">
              <Row>
              <div
                v-for="(i,cindex) in tabList[tabId].list"
                :key="cindex"
                class="form"
              >
                <Col span="8" v-if="i.standard" >
                    <div
                      v-if="i.title"
                      :class="{'title':true,'order-setting-input-error':i.required}"
                    >{{ i.title }}
                     <Tooltip
                      max-width="200"
                      :content="i.explainContent"
                      placement="bottom"
                    >
                      <img
                      v-if="i.explain"
                      class="img-framelanflag"
                      src="../../../assets/icon/help.png"
                      >
                    </Tooltip>
                    </div>
                    <DatePicker :value="i.VALUE" :options="options3" v-if='i.SKEY=="strategyTimeRange"' type="datetimerange" format="yyyy-MM-dd HH:mm:ss" placeholder="请选择时间" style="width: 100%;max-width:400px;min-width: 180px;" :transfer="transfer" :clearable="clearable" @on-change="rangeDate"></DatePicker>
                  <Select v-model="i.VALUE" :filterable="i.SKEY=='shop_name'?true:false" :clearable='i.clearable' :disabled="i.disabled" class="input_box" v-else-if="(i.SKEY=='shop_name')||(i.SKEY=='orderTimeType')"  @on-change="searchSelectOnChange" > 
                     <!-- @on-query-change="checkInputSKU($event,i)" -->
                      <Option v-for="d in i.optionList" :value="d.value" :key="d.value">{{ d.label }}</Option>
                  </Select>
                  <Input
                    v-else-if="i.SKEY=='strategyName' || i.SKEY=='remark'"
                    class="input_box"
                    v-model="i.VALUE"
                    :placeholder="i.placeholder"
                    :disabled="i.disabled"
                    @on-keypress='noSpaces($event,i)'
                  />
                </Col>
              </div>
              </Row>
            </div>
          </div>
        </foldpanel>
      </div>
    </div>
    <div class="tableArea priceMonitor">
      <Tabs type="card">
        <TabPane label="商品明细" name="name1">
            <Row style="display: flex; 
                justify-content: space-between;
                align-items: center;
                height: 48px;
                margin-bottom: 16px;
                background: #F8F8F8;">
              <Col span="5">
                <div style="display: flex;align-items: center;">
                  <label style="width: 60px;text-align:right;margin-right:4px;">
                    <span style='color: red;'>*</span>商品类型</label>
                  <Select 
                  ref="JoinSelect"
                  style="width:240px;margin: 0 6px;"
                  v-model='detail.PriceMonitoreDimension'
                  @on-change="selectPriceMonitoreDimension">
                    <Option v-for="(option,index) in selectGoodTypeList" :key="index" :value="option.value">{{option.label}}</Option>
                  </Select>
                </div>
              </Col>
              <Col span="5">
                <div style="display: flex;align-items: center;" v-if='detail.PriceMonitoreDimension'>
                  <label style="width: 116px;text-align:right;margin-right:4px;"><span style='color: red;'>*</span>{{MonitorDimensionValueType}}</label>
                  <Select
                  ref="ExcludeSelect"
                  style="width:240px"
                  v-model="detail.MonitorDimensionValue"
                  @on-query-change="getExcludeSkuList"
                  @on-change="selectExcludeGoods"
                  @on-enter="addReturnGoods"
                  filterable
                  clearable
                >
                  <Option v-for="(option,index) in SKUArrExclude" :key="index" :value="option.value">{{option.label}}</Option>
                </Select>
                <img
                  style="width:16px;margin-left:8px"
                  src="../../../assets/icon/search.png"
                  @click="searchGoods('return')"
                  >
                </div>
              </Col>
              <Col span="5"></Col>
              <Col span="5"></Col>
              <Col span="2" >
                <Button type="primary" icon="md-return-left" @click="addReturnGoods">添加明细</Button>
              </Col>
            </Row>
            <div class="handleBtn">
              <div class="handleItem" @click="deleteReturnGoods">【删除】</div>
              <div class="handleItem" @click="importStrategyDetailExcel">【导入】</div>
              <div class="handleItem" @click="exportStrategyDetailExcel">【导出】</div>
            </div>
           <Table height="300" 
            :columns="returnColumns" 
            :data="currentReturnData"
            @on-select="selectReturnData"
            @on-select-cancel="selectReturnCancel"
            @on-select-all="selectReturnDataAll"
            @on-select-all-cancel="selectReturnDataCancel"
           ></Table>
           <div class="pageContent">
              <Page
                size="small"
                :current="returnCurrentPage"
                show-elevator
                :total="totalReturn"
                show-total
                show-sizer
                @on-change="changePageReturn"
                @on-page-size-change="changeSizeReturn"
              />
            </div>
        </TabPane>
      </Tabs>
    </div>
    <Modal
      v-model="selectGoodsModal"
      title="选择商品"
      width="900"
      :mask="mask"
      :closable="closable"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
      @on-cancel="cancelSelectGoods">
        <div class="conditionContent">
          <div class="itemContent">
            <div class="itemLabel">
              商品名称
            </div>
            <Input
              style="width:240px"
              v-model="selectGoodsData.PRODUCTNAME"
              clearable
            />
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              商品编码
            </div>
            <Input
              style="width:240px"
              v-model="selectGoodsData.PRODUCTCODE"
              clearable
            />
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              SKU
            </div>
            <Input
              v-model="selectGoodsData.SKU"
              clearable
            />
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              国标码
            </div>
            <Input
              v-model="selectGoodsData.GBCODE"
              clearable
            ></Input>
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              颜色
            </div>
            <Input
              v-model="selectGoodsData.NORMS1NAME"
              clearable
            ></Input>
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              尺寸
            </div>
            <Input
              v-model="selectGoodsData.NORMS2NAME"
              clearable
            ></Input>
          </div>
          
        </div>
        <ShrinkOrExtend
          :height="shrinkHeight"
          :current-value="currentValue"
          @click="upOrDown(shrinkHeight)"
          @on-reset="resetGoodsData"
          @on-query="searchGoodsData"
        />
        <Table 
        :height="tableHeight" 
        :columns="SKUColumns" 
        :data="GoodsData"
        highlight-row
        @on-current-change="selectGoods"
        ></Table>
        <div class="pageContent">
          <Page
            size="small"
            :current="GoodsCurrentPage"
            show-elevator
            :total="totalGoods"
            show-total
            show-sizer
            @on-change="changePageGoods"
            @on-page-size-change="changeSizeGoods"
          />
        </div>
      <footer style="display: flex; justify-content: center; margin-top: 12px;padding-top: 16px;border-top: 1px solid #DEDEDE;;">
        <Button
          type="fcdefault"
          @click="cancelSelectGoods"
        >
          取消
        </Button>
        <Button
          type="posdefault"
          style="margin-left: 16px"
          @click="okSelectGoods"
        >
          确认
        </Button>
      </footer>
    </Modal>
    <Modal
      v-model="selectPlatformGoodsModal"
      title="选择平台商品"
      width="900"
      :mask="mask"
      :closable="closable"
      :mask-closable="maskClosable"
      :footer-hide="hideFoot"
      @on-cancel="cancelSelectPlatformGoods">
        <div class="conditionContentOne">
          <div class="itemContent">
            <div class="itemLabel">
              系统商品编码
            </div>
            <Input
              style="width:240px"
              v-model="selectPlatformGoodsData.PRODUCTCODE"
              clearable
            />
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              系统SKU编码
            </div>
            <DropMultiSelectFilter
                  ref="SKUID" 
                  single
                  class="input_box"
                  :data="SystemSKUList"
                  :default-selected="defaultSelectedSystemSKU"
                  :total-row-count="SystemSKUtotalRowCount"
                  :show-colname-key="'isak'"
                  :columns="columnsSystemSKU"
                  :auto-data="SystemSKUAutoData"
                  @on-page-change="changePageShop($event,'SKUID')"
                  @on-input-value-change="InputValueChangeShop($event,'SKUID')"
                  @on-popper-show="searchShopData('SKUID')"
                  @on-fkrp-selected="checkDataShop($event,'SKUID')"
                  @on-focus="focusInputValueChangeShop($event,'SKUID')"
                  @on-clear="clearDataShop('SKUID')"
                />
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              店铺
            </div>
            <!-- <Input
              v-model="selectPlatformGoodsData.SHOPID"
              clearable
            /> -->
            <DropMultiSelectFilter
                  ref="shopID" 
                  single
                  class="input_box"
                  :data="shopIDList"
                  :default-selected="defaultSelectedshopID"
                  :total-row-count="shopIDtotalRowCount"
                  :show-colname-key="'isak'"
                  :columns="columnsshopID"
                  :auto-data="shopIDAutoData"
                  @on-page-change="changePageShop($event,'shopID')"
                  @on-input-value-change="InputValueChangeShop($event,'shopID')"
                  @on-popper-show="searchShopData('shopID')"
                  @on-fkrp-selected="checkDataShop($event,'shopID')"
                  @on-focus="focusInputValueChangeShop($event,'shopID')"
                  @on-clear="clearDataShop('shopID')"
                />
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              平台商品编码
            </div>
            <Input
              v-model="selectPlatformGoodsData.NUMIID"
              clearable
            ></Input>
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              平台SKU编码
            </div>
            <Input
              v-model="selectPlatformGoodsData.EXTSKUID"
              clearable
            ></Input>
          </div>
          <div class="itemContent">
            <div class="itemLabel">
              平台商品标题
            </div>
            <Input
              v-model="selectPlatformGoodsData.TITLE"
              clearable
            ></Input>
          </div>
          
        </div>
        <ShrinkOrExtend
          :height="shrinkHeight"
          :current-value="currentPlatformValue"
          @click="upOrDownOne(shrinkHeight)"
          @on-reset="resetPlatformGoodsData"
          @on-query="searchPlatformGoodsData"
        />
        <Table 
        :height="tableHeight" 
        :columns="SKUPlatformColumns" 
        :data="PlatformGoodsData"
        highlight-row
        @on-current-change="selectPlatformGoods"
        ></Table>
        <div class="pageContent">
          <Page
            size="small"
            :current="PlatformGoodsCurrentPage"
            show-elevator
            :total="totalPlatformGoods"
            show-total
            show-sizer
            @on-change="changePagePlatformGoods"
            @on-page-size-change="changeSizePlatformGoods"
          />
        </div>
      <footer style="display: flex; justify-content: center; margin-top: 12px;padding-top: 16px;border-top: 1px solid #DEDEDE;;">
        <Button
          type="fcdefault"
          @click="cancelSelectPlatformGoods"
        >
          取消
        </Button>
        <Button
          type="posdefault"
          style="margin-left: 16px"
          @click="okSelectPlatformGoods"
        >
          确认
        </Button>
      </footer>
    </Modal>
    <Modal
      v-model="showTip"
      mask
      :mask-closable="maskClosable"
      title="警告"
      title-align="left"
      class-name="showTipModel"
      width="400px"
      @on-ok="closePage"
    >
      <p><i class="iconfont iconbj_doubt fcWarning " />修改的数据未保存，确定返回？</p>
    </Modal>
    <SKULockInventoryDetailImport :visible='SKULockInventoryDetailvisible' @closeActionDialog = 'closeActionDialog' :pageMsgId='pageMsgId'></SKULockInventoryDetailImport>
  </div>
</template>
<script>
  import foldPanel from '../../customizedContent/FoldPanel.vue'; // 折叠面板组件
  import ShrinkOrExtend from '../../customizedContent/shrinkOrExtend' //收缩伸展搜索条件组件 
  import tableFaker from '../../customizedContent/tableFaker.vue'; //表格组件
  import SKULockInventoryDetailImport from '../../modal/systemImport/SKULockInventoryDetailImport.vue'; // 参与商品导入弹框

  
  import { DispatchEvent, R3_IMPORT } from '../../../assets/js/__utils__/dispatchEvent';

  const R3 = window.R3;
  const { network, urlSearchParams, store } = R3;
  export default {
    data() {
      return {
        SKULockInventoryDetailvisible: false,
        MonitorDimensionValueType: '系统SKU编码',
        options3: {
          disabledDate(date) {
            return date && date.valueOf() < Date.now() - 86400000;
          }
        },
        tabList: [
          {
            tabId: '1',
            tabtext: '基本信息',
            blockShow: true,
            list: [
              {
                ID: '',
                SKEY: 'strategyName',
                title: '策略名称',
                VALUE: '',
                company: '',
                tips: '',
                placeholder:'请输入策略名称',
                disabled:false,
                standard:true,//标准输入框长度
                flag: true, // 控制必填校验样式展示
                required: true, // 是否为必填项
                explain:false, //是否有解释
              },
              {
                ID: 'T_V_IESSHOP',
                SKEY: 'shop_name',
                title: '使用店铺',
                VALUE: '',
                defaultvalue: '',
                company: '',
                tips: '',
                clearable:true,
                disabled:false,
                flag: true, // 控制必填校验样式展示
                required: true, // 是否为必填项
                standard:true,//标准输入框长度
                optionList:[]
              },
              {
                SKEY: 'strategyTimeRange',
                title: '起止时间',
                VALUE: '',
                defaultvalue: '',
                company: '',
                tips: '',
                disabled:false,
                required: true, // 是否为必填项
                standard:true,//标准输入框长度
                flag: true, // 控制必填校验样式展示
              },
              {
                SKEY: 'remark',
                title: '备注',
                VALUE: '',
                defaultvalue: '',
                placeholder: '',
                tips: '',
                clearable:false,
                disabled:false,
                required: false, // 是否为必填项
                standard:true,//标准输入框长度
              },
            ]
          },
        ],
        returnColumns: [ //策略明细
            {
              type: 'selection',
              width: 60,
              align: 'center'
            }, 
            {
              type: 'index',
              align: 'center',
              title: '序号',
            },
            {
              title: '商品类型',
              align: 'center',
              key: 'PriceMonitoreDimension',
            },
            {
              title: '类型值',
              align: 'center',
              key: 'MonitorDimensionValueText',
            },
        ],
        tableHeight:'200',//表格高度

        currentReturnData:[],//当前显示策略明细明细
        returnData:[],
        returnDataNoSame:[],//弹窗中没有的策略明细
        submitArrReturn:[],//选中的策略明细

        selectGoodTypeList: [  // 商品类型
          {
            label: '系统SKU编码',
            value: '1'
          },{
            label: '系统商品编码',
            value: '2'
          },{
            label: '平台SKU编码',
            value: '3'
          },{
            label: '平台商品编码',
            value: '4'
          },
        ],
        // 策略明细page
        returnCurrentPage:1,
        totalReturn: 0, // 总条数
        currentPageReturn: 0, // 页码
        pageSizeReturn: 10, // 每页的条数

        // 系统商品选择商品弹框
        selectGoodsModal:false,//选择商品弹窗
        selectGoodsData:{//选择商品搜索条件
          NORMS1NAME:'',//颜色
          NORMS2NAME:'',//尺寸
          SKU:'',//SKU
          GBCODE:'',//国标码
          PRODUCTCODE:'',//商品编码
          PRODUCTNAME:''//商品名称
        },
        submitArrGoods:[],//选择商品表格选中项
        SKUColumns:[
          {
            title: 'SKU',
            key: 'SKU'
          },
          {
            title: '商品编码',
            key: 'PRODUCTCODE'
          },
          {
            title: '销售价',
            key: 'SELLPRICE'
          },
          {
            title: '商品名称',
            key: 'PRODUCTNAME'
          },
          {
            title: '颜色',
            key: 'NORMS1NAME'
          },
          {
            title: '尺寸',
            key: 'NORMS2NAME'
          },
          {
            title: '重量',
            key: 'WEIGHT'
          },
          {
            title: '库位',
            key: 'STORESITE'
          },
          {
            title: '国标码',
            key: 'GBCODE'
          },
          {
            title:'图片地址',
             key: 'PICTUREURL',
              render: (h, params) => {
                return h(
                  'div',
                  { 
                    class:{
                      imgBox:true
                    },
                    style: {
                      zIndex: 999,
                      width:'60px',
                      height:'60px',
                      position:'relative'
                    },
                      
                  },
                  [
                    h('Img',
                    {
                       style: {
                          width:'60px',
                          height:'60px'
                        },
                      attrs: {
                        src:params.row.PICTUREURL==''?'../../../static/img/camera.jpg':params.row.PICTUREURL,
                      },
                      on:{
                        'mouseenter':(e)=>{
                          var txt3=document.createElement("img");
                          txt3.id='enlargeImg'
                          txt3.src=params.row.PICTUREURL==''?'../../../static/img/camera.jpg':params.row.PICTUREURL
                          txt3.style.height='120px'
                          txt3.style.width='120px'
                          txt3.style.position='fixed'
                          if(this.currentValue){
                            txt3.style.top=($(".imgBox")[params.index].offsetParent.offsetHeight + $(".imgBox")[params.index].offsetTop - $(".imgBox")[params.index].offsetParent.scrollTop + 30)-100+'px';
                          }else{
                            txt3.style.top=($(".imgBox")[params.index].offsetParent.offsetHeight + $(".imgBox")[params.index].offsetTop - $(".imgBox")[params.index].offsetParent.scrollTop + 30)+'px';
                          }
                          txt3.style.left=($(".imgBox")[0].offsetLeft-$(".imgBox")[params.index].offsetParent.scrollLeft + 60 + 30)+'px'
                          $(".imgBox")[params.index].append(txt3)
                        },
                        'mouseleave':(e)=>{
                          $("#enlargeImg").remove();
                        }
                      }
                    },
                    )
                  ]

                )
              }
          },
          {
            title: 'SKU是否有效',
            key: 'ISVALID',
            render: (h, params) => {
              const vm = this;
              return h(
                'div',
                {
                  style: {
                   color:params.row.ISVALID==1?'#63A4FE':'#D70017'
                  },
                },
                [params.row.ISVALID==1?'是':'否']
              );
            },
          },
          {
            title: '安全库存数',
            key: 'SECURITYSTOCK'
          },
        ],
        GoodsData:[],//选择商品数据
        // 换货商品page
        totalGoods: 0, // 总条数
        currentGoodsPage:0, // 页码
        pageSizeGoods: 10, // 每页的条数
        GoodsCurrentPage: 1,

        // 平台商品选择商品弹框
        selectPlatformGoodsModal:false,//选择商品弹窗
        selectPlatformGoodsData:{//选择商品搜索条件
          SHOPID:'',//店铺
          SKUID:'',//系统SKU编码
          EXTSKUID:'',//平台SKU编码
          NUMIID:'',//平台商品编码
          PRODUCTCODE:'',//系统商品编码
          TITLE:''//平台商品标题
        },
        submitArrPlatformGoods:[],//选择商品表格选中项
        SKUPlatformColumns:[
          {
            title: '平台',
            key: 'PLATFORM'
          },
          {
            title: '店铺',
            key: 'SHOPID'
          },
          {
            title: '系统商品编码',
            key: 'PRODUCTCODE'
          },
          {
            title: '系统SKU编码',
            key: 'SKUID'
          },
          {
            title: '平台商品编码',
            key: 'NUMIID'
          },
          {
            title: '平台SKU编码',
            key: 'EXTSKUID'
          },
          {
            title: '平台商品标题',
            key: 'TITLE'
          },
        ],
        PlatformGoodsData:[],//选择商品数据
        // 换货商品page
        totalPlatformGoods: 0, // 总条数PlatformGoodsCurrentPage
        currentPlatformGoodsPage:0, // 页码
        pageSizePlatformGoods: 10, // 每页的条数
        PlatformGoodsCurrentPage: 1,

        // 选择商品
        mask:true,
        closable: true,
        maskClosable: false,
        hideFoot: true,
        shrinkHeight: '58px',
        currentValue: false,//默认收缩

        showTip: false,
        showDetailTable: true, // 展示商品明细
        startTime: '',  // 活动开始时间
        endTime: '', // 活动结束时间

        // 平台商品选择商品弹框系统SKU编码参数
        SystemSKUList: {}, // 系统SKU编码下拉展示数据
        SystemSKUtotalRowCount: 0,
        SystemSKUcurrentIndex: 0, // 系统SKU编码搜索初始index
        SystemSKUAutoData: [], // 系统SKU编码模糊搜索的结果组
        columnsSystemSKU: ['name', 'value'], // 展现的组
        defaultSelectedSystemSKU: [],

        // 平台商品选择商品弹框店铺参数
        shopIDList: {}, // 店铺下拉展示数据
        shopIDtotalRowCount: 0,
        shopIDcurrentIndex: 0, // 店铺搜索初始index
        shopIDAutoData: [], // 店铺模糊搜索的结果组
        columnsshopID: ['name', 'value'], // 展现的组
        defaultSelectedshopID: [],

        detail:{
          PriceMonitoreDimension: '', // 商品类型
          PriceMonitoreDimensionType: '', // 商品类型id
          MonitorDimensionValue: '', // 类型值id
          MonitorDimensionValueText: '', // 类型值
        }, 

        //编辑页面
        pageMsgId: '', // 当前策略id

        SKUArrExclude:[],//排除商品SKU下拉框列表
        SKUAllDataExclude:[],//排除商品SKU下拉框列表完整数据
        selectExcludeSKUData:{},//排除商品选中的SKU数据
        selectExcludeSKUID:'',//排除商品sku下拉框双向数据绑定
        ExcludeGoodsNum:'',//排除商品数量
      };
    },
    components: {
      foldPanel,
      ShrinkOrExtend,
      tableFaker,
      SKULockInventoryDetailImport
    },
    created(){
      this.pageMsgId = window.parent.vm._route.params.customizedModuleId;
      this.getStategyDetail();
      this.getpageDetailList();
      this.getQuery('T_V_IESSHOP', {isactive: ["=Y"]})// 初始查询店铺名称列表
    },
    methods: {
      backToList() { // 返回策略列表页面
        let flag = true;
        for(let i = 0;i<this.tabList[0].list.length;i++){
          if(this.oldBaseMsg.name != this.tabList[0].list[0].VALUE){
            flag = false;
            break;
          }else if(this.oldBaseMsg.shopid != this.tabList[0].list[1].VALUE){
            flag = false;
            break;
          }else if(this.oldBaseMsg.startTime != this.startTime){
            flag = false;
            break;
          }else if(this.oldBaseMsg.endTime != this.endTime){
            flag = false;
            break;
          }
        }
        if(!flag){
          this.showTip = true;
        }else{
          this.closePage();
        }
      },
      // 重置选择系统商品搜索条件
      resetGoodsData(){
        this.selectGoodsData={ 
          NORMS1NAME:'',//颜色
          NORMS2NAME:'',//尺寸
          SKU:'',//SKU
          GBCODE:'',//国标码
          // SELLPRICE:'',//销售价
          // BASEPRICE:'',//成本价
          PRODUCTCODE:'',//商品编码
          PRODUCTNAME:''//商品名称
        }
        this.submitArrGoods=[]
        this.searchGoodsData()
      },
      // 重置选择平台商品搜索条件
      resetPlatformGoodsData() {
        this.selectPlatformGoodsData={ 
          SHOPID:'',//店铺
          SKUID:'',//系统SKU编码
          EXTSKUID:'',//平台SKU编码
          NUMIID:'',//平台商品编码
          PRODUCTCODE:'',//系统商品编码
          TITLE:''//平台商品标题
        }
        this.defaultSelectedSystemSKU = [];
        this.defaultSelectedshopID = [];
        this.submitArrPlatformGoods=[]
        this.searchPlatformGoodsData()
      },
      searchSelectOnChange(e) { // 更换使用店铺
        if(this.tabList[0].list[1].VALUE){
          this.$Modal.fcWarning({
            title: '警告',
            mask: true,
            showCancel: true,
            content: '修改使用店铺后将清空商品明细，确认修改？',
            onOk:()=>{
              let params = {
                id: this.pageMsgId,
                iesshopid: this.tabList[0].list[1].VALUE
              }
              network.post('/p/cs/BarCodeLockChangeShop',params).then(res => {
                if(res.data.code == 0){
                  this.getStategyDetail();
                  this.getpageDetailList();
                  this.$Message.success('修改使用店铺成功')
                }
              })
            },
            onCancel:()=>{
              this.tabList[0].list[1].VALUE = String(this.oldBaseMsg.shopid)
            }
          })
        }else {
          this.tabList[0].list[1].VALUE = String(this.oldBaseMsg.shopid)
        }
      },
      getStategyDetail(){ // 编辑页面获取策略详情
        let params = {
          id: this.pageMsgId
        }
        network.get('/p/cs/selectByIdBarCodeLock?id='+this.pageMsgId).then(res => {
          if(res.data.code == 0){
            this.tabList[0].list[0].VALUE = res.data.data.TACTICS_NAME
            this.tabList[0].list[1].VALUE = String(res.data.data.IESSHOPID)
            this.tabList[0].list[2].VALUE = [res.data.data.START_TIME,res.data.data.END_TIME]
            this.startTime = res.data.data.START_TIME
            this.endTime = res.data.data.END_TIME //new Date().getTime()
            this.tabList[0].list[3].VALUE = res.data.data.COMMENTS
            this.oldBaseMsg = {
              name: res.data.data.TACTICS_NAME, // 策略名称
              shopid: res.data.data.IESSHOPID, // 店铺
              startTime: res.data.data.START_TIME, // 开始时间
              endTime: res.data.data.END_TIME, // 结束时间
              type: res.data.data.COMMENTS, // 备注
            }
          }
        })
      },
      getpageDetailList(type){
        let params = {
          id: this.pageMsgId,
          page: this.returnCurrentPage,
          size: this.pageSizeReturn,
        }
        network.post('/p/cs/selectBarCodeLockItem/page',params).then(res => {
          if(res.data.code == 0) {
            let currentPageData = [];
            if(type == 'table'){
              this.returnData = [];
            }
            if(res.data.data.records.length > 0){
              res.data.data.records.forEach(item => {
                let obj = {};
                obj = {
                  id: item.ID,
                  PriceMonitoreDimensionType:item.GOODSTYPE == '1'?'1':item.GOODSTYPE == '2'?'3':item.GOODSTYPE == '3'?'4':'2',
                  PriceMonitoreDimension: item.GOODSTYPE == '1'?'系统SKU编码':item.GOODSTYPE == '2'?'平台SKU编码':item.GOODSTYPE == '3'?'平台商品编码':'系统商品编码',
                  // MonitorSetValue: item.GOODSCODE,
                  MonitorDimensionValueText: item.GOODSCODE,
                }
                currentPageData.push(obj);
                if(this.returnData.length < res.data.data.total){
                  this.returnData.push(obj);
                }
              })
            }
            this.totalReturn=res.data.data.total
            // 截取数组
            // let startIndex=this.pageSizeReturn*(this.returnCurrentPage-1)
            // let endIndex=startIndex+this.pageSizeReturn
            // this.returnData.slice(startIndex,endIndex)
            this.currentReturnData=currentPageData //当前页面显示明细
          }
        })
      },
      rangeDate(e) {
        this.startTime = e[0];
        this.endTime = e[1];
      },
      limitStartDate(e) {
        this.limitStartDate = e
      },
      limitEndDate(e) {
        this.limitEndDate = e
      },
      // 重置数据
      resetData(){
        this.tabList.forEach(item=>{
          item.list.forEach(i=>{
            if(i.TYPEONE=='checkbox'){
              i.VALUE=false
            }else{
              i.VALUE=''
            }
          })
        })
        this.showDetailTable = true;
        this.returnData = []; // 策略明细置空
        this.currentReturnData = []; // 策略明细置空

        // 策略明细搜索栏重置
        if(this.$refs.returnSelect){
          this.detail={
            PriceMonitoreDimension: '', // 商品类型
            PriceMonitoreDimensionType: '', // 商品类型id
            MonitorDimensionValue: '', // 类型值id
            MonitorDimensionValueText: '',//类型值
          }
          // this.$refs.returnSelect.clearSingleSelect()
        }
      },
      // 关闭当前页面
      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_IESSHOPSKUSTOCKLOCK',
            tableId:'11510',
            back:true
          });
        },0)
      },

      // 选择入库单弹框中的筛选下拉框数据start
      // 单选下拉分页改变
      changePageShop(e,type) {
        if(type == 'SKUID'){
          this.SystemSKUcurrentIndex = (e - 1) * 10;
          this.searchShopData('SKUID');
        }else if(type == 'shopID') {
          this.shopIDcurrentIndex = (e - 1) * 10;
          this.searchShopData('shopID');
        }
      },
      // 外键下拉框1234
      searchShopData(type) {
        if(type == 'SKUID'){
          let virtual = {
            searchdata: {
              isdroplistsearch: true,
              refcolid: 198192,
              startindex: this.SystemSKUcurrentIndex,
              range: 10,
            }
          }
          network.post('/p/cs/QueryList', urlSearchParams(virtual)).then((res) => {
            if (res.data.code == 0) {
              this.SystemSKUtotalRowCount = res.data.data.totalRowCount;
              this.SystemSKUList = res.data.data;
              this.SystemSKUcurrentIndex = 0;
            }
          });
        }else if(type == 'shopID'){
          let virtual = {
            searchdata: {
              isdroplistsearch: true,
              refcolid: 198185,
              startindex: this.shopIDcurrentIndex,
              range: 10,
            }
          }
          network.post('/p/cs/QueryList', urlSearchParams(virtual)).then((res) => {
            if (res.data.code == 0) {
              this.shopIDtotalRowCount = res.data.data.totalRowCount;
              this.shopIDList = res.data.data;
              this.shopIDcurrentIndex = 0;
            }
          });
        }
      },
      // 单选下拉模糊搜索数据
      InputValueChangeShop(e,type) {
        if(type == 'SKUID'){
          let virtual = {
            ak: e,
            colid: 198192,
            fixedcolumns: {}
          };
          network.post('/p/cs/fuzzyquerybyak', urlSearchParams(virtual)).then((res) => {
            if (res.data.code == 0) {
              let list = [];
              res.data.data.forEach(item => {
                let obj = {
                  value: item.value,
                  id: item.id
                };
                list.push(obj);
              });
              this.SystemSKUAutoData = list;
            }
          });
        }else if(type == 'shopID'){
          let virtual = {
            ak: e,
            colid: 198185,
            fixedcolumns: {}
          };
          network.post('/p/cs/fuzzyquerybyak', urlSearchParams(virtual)).then((res) => {
            if (res.data.code == 0) {
              let list = [];
              res.data.data.forEach(item => {
                let obj = {
                  value: item.value,
                  id: item.id
                };
                list.push(obj);
              });
              this.shopIDAutoData = list;
            }
          });
        }
      },
      // 外键下拉框搜索
      focusInputValueChangeShop(e,type) {
        if(type == 'SKUID'){
          let virtual = {
            ak: e.target.value,
            colid: 198192,
            fixedcolumns: {}
          };
          network.post('/p/cs/fuzzyquerybyak', urlSearchParams(virtual)).then((res) => {
            if (res.data.code == 0) {
              let list = [];
              res.data.data.forEach(item => {
                let obj = {
                  value: item.value,
                  id: item.id
                };
                list.push(obj);
              });
              this.SystemSKUAutoData = list;
            }
          });
        }else if(type == 'shopID'){
          let virtual = {
            ak: e.target.value,
            colid: 198185,
            fixedcolumns: {}
          };
          network.post('/p/cs/fuzzyquerybyak', urlSearchParams(virtual)).then((res) => {
            if (res.data.code == 0) {
              let list = [];
              res.data.data.forEach(item => {
                let obj = {
                  value: item.value,
                  id: item.id
                };
                list.push(obj);
              });
              this.shopIDAutoData = list;
            }
          });
        }
      },
      // 单选下拉选中
      checkDataShop(val,type) {
        if(type == 'SKUID'){
          let list = [];
          list.push(val[0]);
          this.selectPlatformGoodsData.SKUID = list[0].ID;
        }else if(type == 'shopID'){
          let list = [];
          list.push(val[0]);
          this.selectPlatformGoodsData.SHOPID = list[0].ID;
        }
      },
      clearDataShop(type) {
        if(type == 'SKUID'){
          this.selectPlatformGoodsData.SKUID = '';
        }else if(type == 'shopID'){
          this.selectPlatformGoodsData.SHOPID = '';
        }
      },

      // 监控维度option选中
      selectPriceMonitoreDimension(val){
        this.MonitorDimensionValueType = val=='1'?'系统SKU编码':val=='2'?'系统商品编码':val=='3'?'平台SKU编码':'平台商品编码';
        this.detail.MonitorDimensionValue = '';
        this.detail.MonitorDimensionValueText = '';
      },

      // 添加策略明细到表格
      addReturnGoods(){
          if(!this.detail.PriceMonitoreDimension){
            this.$Message.warning('商品类型不能为空');
            return
          }else if(!this.detail.MonitorDimensionValue){
            this.$Message.warning('类型值不能为空');
            return
          }else {
            this.$Modal.fcWarning({
              title: '警告',
              mask: true,
              showCancel: true,
              content: '添加操作数据库数据会同时发生变化，是否确认添加？',
              onOk:()=>{
                // let obj = {
                //   goodstype: this.detail.PriceMonitoreDimension == 1?1:this.detail.PriceMonitoreDimension == 2?4:this.detail.PriceMonitoreDimension == 3?2:3,
                //   goodscode: this.detail.MonitorDimensionValueText,
                // }
                let params = {
                  masterid: this.pageMsgId,
                  goodstype: this.detail.PriceMonitoreDimension == 1?1:this.detail.PriceMonitoreDimension == 2?4:this.detail.PriceMonitoreDimension == 3?2:3,
                  goodscode: this.detail.MonitorDimensionValueText,
                }
                network.post('/p/cs/insertBarCodeLockItem',params).then(res => {
                  if(res.data.code == 0){
                    this.detail={
                      PriceMonitoreDimension: '', // 商品类型
                      PriceMonitoreDimensionType: '', // 商品类型id
                      MonitorDimensionValue: '', // 类型值id
                      MonitorDimensionValueText: '', // 类型值
                    },
                    this.$Message.success('添加明细成功！')
                    this.getpageDetailList('table');
                  }
                })
              }
            })
          }
      },
      //初始查询标准下拉框数据
      getQuery(tableName,fixed){
        let virtual={
          fixedcolumns: fixed?fixed:{},
          range: 2000,
          startindex: 0,
          table: tableName
        }
        if(tableName=='T_V_IESSHOP'){
          virtual.isdroplistsearch = true
        }
          network.post('/p/cs/list/query', virtual).then((res) => {
            this.tabList[0].list.forEach(item=>{
              if(item.ID==tableName){
                if(tableName=='T_V_IESSHOP'){
                  item.optionList= res.data.rows.map(i=>{
                    return {
                      label:i.SHOPTITLE.val,
                      value:i.ID.val
                    }
                  })
                }else{
                  item.optionList= res.data.rows.map(i=>{
                    return {
                      label:i.NAME.val,
                      value:i.ID.val
                    }
                  })
                }
              }
            })
          })
      },

      // 选择系统商品 在单选下有效，选中某一项时触发
      selectGoods(selection){
        this.submitArrGoods=[selection]
      },
      // 选择平台商品 在单选下有效，选中某一项是触发
      selectPlatformGoods(selection){
        this.submitArrPlatformGoods=[selection]
      },
      
      // 选择系统商品页码改变时触发
      changePageGoods(val) {
        // 1=>0 2=>10 3=>20 
        this.currentGoodsPage = (val - 1) * 10;
        this.searchGoodsData();
      },
      // 选择平台商品页码改变时触发
      changePagePlatformGoods(val) {
        // 1=>0 2=>10 3=>20 
        this.currentPlatformGoodsPage = (val - 1) * 10;
        this.searchPlatformGoodsData();
      },
      // 选择系统商品页数改变时触发
      changeSizeGoods(val) {
        this.pageSizeGoods = val;
        this.currentGoodsPage = 1;
        this.searchGoodsData();
      },
      // 选择平台商品页数改变时触发
      changeSizePlatformGoods(val) {
        this.pageSizePlatformGoods = val;
        this.currentPlatformGoodsPage = 1;
        this.searchPlatformGoodsData();
      },

      // 打开系统商品选择商品弹窗
      searchGoods(name){
        if(this.detail.PriceMonitoreDimension == 3 || this.detail.PriceMonitoreDimension == 4) {
          this.searchPlatformGoods();
        }else {
          this.searchGoodsData()
          this.selectGoodsModal=true
        }
      },
      // 打开平台商品选择商品弹窗
      searchPlatformGoods(name){
        this.searchPlatformGoodsData()
        this.selectPlatformGoodsModal=true
      },
      // 查询符合搜索条件的系统商品
      searchGoodsData(){
        let virtual = {
          fixedcolumns: this.selectGoodsData ? this.selectGoodsData : {},
          isdroplistsearch: false,
          range: this.pageSizeGoods,
          startindex: this.currentGoodsPage,
          table: 'T_V_IESNOGROUPSKU',
        };
          network.post('/p/cs/list/query', virtual).then((res) => {
            this.totalGoods = res.data.total;
            let data = [];
            for (let i = 0; i < res.data.rows.length; i++) {
              for (let j = 0; j < Object.keys(res.data.rows[i]).length; j++) {
                let keyName = Object.keys(res.data.rows[i])[j];
                res.data.rows[i][keyName] = res.data.rows[i][keyName].val;
              }
              data.push(res.data.rows[i]);
            }
            this.GoodsData = data;
            this.GoodsData.forEach(i=>i.ISGIFT=0)
            this.GoodsData.forEach(i=>i.ISGROUP=0)
            if(this.returnData.length){
              let sameArr = [...this.GoodsData].filter((x) => [...this.returnData].some((y) => y.SKU == x.SKU));
              this.returnDataNoSame= [...this.returnData].filter((x) => [...this.GoodsData].every((y) => y.SKU != x.SKU));
              if(sameArr.length){
                this.GoodsData.forEach(item=>{
                  sameArr.forEach(i=>{
                    if(i.SKU==item.SKU){
                      item._checked=true
                      item.isSame=true //标记是否为之前选择项
                    }
                  })
                })
                this.submitArrGoods=[...this.submitArrGoods,...sameArr]
              }
            }
          });
      },
      // 查询符合搜索条件的平台商品
      searchPlatformGoodsData() { // PlatformGoodsData  T_V_IESPLATFORMSKU
        let virtual={
          searchdata: {
            "table":"T_V_IESPLATFORMSKU",
            "startindex":this.currentPlatformGoodsPage,
            'range':this.pageSizePlatformGoods,
            "fixedcolumns": this.selectPlatformGoodsData ? this.selectPlatformGoodsData : {},
            "column_include_uicontroller":true,
            "isolr":false
          }
        }
        network.post('/p/cs/QueryList', urlSearchParams(virtual)).then((res) => {
          this.totalPlatformGoods = res.data.data.totalRowCount;
          let data = [];
          for(let i = 0;i < res.data.data.row.length;i++) {
            for (let j = 0; j < Object.keys(res.data.data.row[i]).length; j++) {
              let keyName = Object.keys(res.data.data.row[i])[j];
              res.data.data.row[i][keyName] = res.data.data.row[i][keyName].val;
            }
            data.push(res.data.data.row[i]);
          }
          this.PlatformGoodsData = data;
          this.PlatformGoodsData.forEach(i=>i.ISGIFT=0)
          this.PlatformGoodsData.forEach(i=>i.ISGROUP=0)
          if(this.returnData.length){
              let sameArr = [...this.GoodsData].filter((x) => [...this.returnData].some((y) => y.SKU == x.SKU));
              this.returnDataNoSame= [...this.returnData].filter((x) => [...this.GoodsData].every((y) => y.SKU != x.SKU));
              if(sameArr.length){
                this.GoodsData.forEach(item=>{
                  sameArr.forEach(i=>{
                    if(i.SKU==item.SKU){
                        item._checked=true
                       item.isSame=true //标记是否为之前选择项
                    }
                  })
                })
                this.submitArrGoods=[...this.submitArrGoods,...sameArr]
              }
          }
        })
      },

      // 关闭系统商品选择商品弹窗
      cancelSelectGoods(){
        this.selectGoodsData={ 
          NORMS1NAME:'',//颜色
          NORMS2NAME:'',//尺寸
          SKU:'',//SKU
          GBCODE:'',//国标码
          PRODUCTCODE:'',//商品编码
          PRODUCTNAME:''//商品名称
        }
        this.submitArrGoods=[]
        this.selectGoodsModal=false
      },
      // 关闭平台商品选择商品弹框
      cancelSelectPlatformGoods(){
        this.selectPlatformGoodsData={ 
          SHOPID:'',//店铺
          SKUID:'',//系统SKU编码
          EXTSKUID:'',//平台SKU编码
          NUMIID:'',//平台商品编码
          PRODUCTCODE:'',//系统商品编码
          TITLE:''//平台商品标题
        }
        this.submitArrPlatformGoods=[]
        this.selectPlatformGoodsModal=false
      },
      // 选择系统商品确认按钮
      okSelectGoods(){
        if(!this.submitArrGoods.length){
          this.$Message.warning('请选择商品');
          return
        }
        if(this.detail.PriceMonitoreDimension == 1){  // 商品选择为按系统SKU编码
          network.post('/p/cs/getIesSku', {sku: this.submitArrGoods[0].SKU}).then((res) => {
            if(res.data.Code==0){
              if(!res.data.Rows.length){
                this.$Message.warning('该SKU无法添加，请重新选择');
                return
              }
              this.SKUArrExclude=res.data.Rows.map(i=>{
                return {
                  label:i.SKU,
                  value:i.ID
                }
              })
              this.SKUAllDataExclude=res.data.Rows
            }else{
              this.SKUArrExclude=[]
              this.SKUAllDataExclude=[]
            }
            this.selectExcludeSKUData=this.SKUAllDataExclude.find(item=>{
              return item.IESPRODUCTID==this.submitArrGoods[0].IESPRODUCTID
            }) //添加的数据
            this.detail.MonitorDimensionValue=this.selectExcludeSKUData.ID //双向数据绑定
            this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.SKU;
            this.cancelSelectGoods()
          })
        }else if(this.detail.PriceMonitoreDimension == 2){ // 商品选择为按系统商品编码
          network.post('/p/cs/getProductCode', {productCode: this.submitArrGoods[0].PRODUCTCODE}).then((res) => {
              if(res.data.Code==0){
                  if(!res.data.Rows.length){
                    this.$Message.warning('该商品编码无法添加，请重新选择');
                    return
                  }
                  this.SKUArrExclude=res.data.Rows.map(i=>{
                    return {
                      label:i.PRODUCTCODE,
                      value:i.ID
                    }
                  })
                  this.SKUAllDataExclude=res.data.Rows
              }else {
                  this.SKUArrExclude=[]
                  this.SKUAllDataExclude=[]
              }
                this.selectExcludeSKUData=this.SKUAllDataExclude.find(item=>{
                  return item.ID==this.submitArrGoods[0].IESPRODUCTID
                }) //添加的数据
                this.detail.MonitorDimensionValue=this.selectExcludeSKUData.ID //双向数据绑定
                this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.PRODUCTCODE;
                this.cancelSelectGoods()
          })
        }
      },
      // 选择平台商品确认按钮
      okSelectPlatformGoods() {
        if(!this.submitArrPlatformGoods.length){
          this.$Message.warning('请选择商品');
          return
        }
        if(this.detail.PriceMonitoreDimension == 3){ // 商品选择为按平台SKU编码
            this.SKUArrExclude=this.submitArrPlatformGoods.map(i=>{
                return {
                  label:i.EXTSKUID,
                  value:i.ID
                }
              })
              this.SKUAllDataExclude=this.submitArrPlatformGoods
              this.selectExcludeSKUData=this.SKUAllDataExclude.find(item=>{
                return item.ID==this.submitArrPlatformGoods[0].ID
              }) //添加的数据
              this.detail.MonitorDimensionValue=this.selectExcludeSKUData.ID //双向数据绑定
              this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.EXTSKUID;
            this.cancelSelectPlatformGoods()
        }else if(this.detail.PriceMonitoreDimension == 4){ // 商品选择为按平台商品编码
            this.SKUArrExclude=this.submitArrPlatformGoods.map(i=>{
              return {
                label:i.NUMIID,
                value:i.ID
              }
            })
            this.SKUAllDataExclude=this.submitArrPlatformGoods
            this.selectExcludeSKUData=this.SKUAllDataExclude.find(item=>{
              return item.ID==this.submitArrPlatformGoods[0].ID
            }) //添加的数据
            this.detail.MonitorDimensionValue=this.selectExcludeSKUData.ID //双向数据绑定
            this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.NUMIID;
            this.cancelSelectPlatformGoods()
        }
      },

      // 策略明细表删除
      deleteReturnGoods(){
        this.$Modal.fcWarning({
          title: '警告',
          mask: true,
          showCancel: true,
          content: '删除操作数据库数据会同时被清除，是否确认删除？',
          onOk:()=>{
            console.log(this.submitArrReturn)
            let idArray=this.submitArrReturn.map(item=>item.id)
            let params = {
              ids: idArray
            }
            network.post('/p/cs/deleteBarCodeLockItem',params).then(res => {
              if(res.data.code == 0){
                this.$Message.success('删除明细成功！');
                this.getpageDetailList('table');
              }
            })
          }
        })
      },
      
      // 策略明细页码改变时触发
      changePageReturn(val){
         // 1=>0 2=>10 3=>20 
         this.returnCurrentPage=val
         this.getpageDetailList();
        // 截取数组
        let startIndex=this.pageSizeReturn*(this.returnCurrentPage-1)
        let endIndex=startIndex+this.pageSizeReturn
        this.currentReturnData=this.returnData.slice(startIndex,endIndex)
      },
      // 策略明细页数改变时触发
      changeSizeReturn(val){
        this.pageSizeReturn = val;
        this.returnCurrentPage=1;
        // this.currentReturnPage = 0;
        // 截取数组
        let startIndex=this.pageSizeReturn*(this.returnCurrentPage-1)
        let endIndex=startIndex+this.pageSizeReturn
        this.currentReturnData=this.returnData.slice(startIndex,endIndex)
      },
      // 策略明细表格选中某项时触发
      selectReturnData(selection, row) {
        this.submitArrReturn = selection;
      },
      // 策略明细表格取消某项时触发
      selectReturnCancel(selection, row) {
        this.submitArrReturn = selection;
      },
      // 策略明细表格全选
      selectReturnDataAll(selection) {
        this.submitArrReturn = selection;
      },
      // 策略明细表格取消全选
      selectReturnDataCancel(selection) {
        this.submitArrReturn = selection;
      },
      
      checkInputSKU(e,i){
        let tableName=i.ID
        if(tableName=='T_V_IESSHOP'){
          this.getQuery(tableName,{SHOPTITLE:e})
        }
      },
      // 平台单号，退款单号(换货单没有)，退回物流单号禁止输入空格
      noSpaces(e,i){
        if(i.SKEY=='satisfied_amount'||i.SKEY=='satisfied_pieces'){
          if(e.keyCode == 32) e.returnValue = false
        }
      },
      // 获取排除商品数据
      getExcludeSkuList(val){
         if(this.detail.PriceMonitoreDimension == 1){
           let virtual={sku: val}
            network.post('/p/cs/getIesSku', virtual).then((res) => {
              if(res.data.Code==0){
                this.SKUArrExclude=res.data.Rows.map(i=>{
                  return {
                    label:i.SKU,
                    value:i.ID
                  }
                })
                this.SKUAllDataExclude=res.data.Rows
              }else{
                this.SKUArrExclude=[]
                this.SKUAllDataExclude=[]
              }
            })
         }else if(this.detail.PriceMonitoreDimension == 2){
           if(!val){
             return 
           }else {
            let virtual={productCode: val}
            network.post('/p/cs/getProductCode', virtual).then((res) => {
              if(res.data.Code==0){
                this.SKUArrExclude=res.data.Rows.map(i=>{
                  return {
                    label:i.PRODUCTCODE,
                    value:i.ID
                  }
                })
                this.SKUAllDataExclude=res.data.Rows
              }else{
                this.SKUArrExclude=[]
                this.SKUAllDataExclude=[]
              }
            })
           }
         }else if(this.detail.PriceMonitoreDimension == 3){
           if(!val){
             return 
           }else {
            let virtual={
              searchdata: {
                "table":"T_V_IESPLATFORMSKU",
                "startindex":0,
                'range':3000,
                "fixedcolumns":{"EXTSKUID":val},
                "column_include_uicontroller":true,
                "isolr":false}
            }
            network.post('/p/cs/QueryList', urlSearchParams(virtual)).then((res) => {
              let list = [];
              let newList = [];
              let paramsList = [];
              for (var key in res.data.data.row[0]) {
                paramsList.push(key);
              }
              res.data.data.row.forEach(item => {
                let obj = {
                  label: item.EXTSKUID.val,
                  value: item.ID.val
                };
                let objParams = {}
                paramsList.forEach(param => {
                  objParams[param] = item[param].val
                })
                list.push(obj);
                newList.push(objParams)
              });
              if(list.length > 0) {
                this.SKUArrExclude = list;
                this.SKUAllDataExclude = newList;
              }else {
                this.SKUArrExclude=[]
                this.SKUAllDataExclude=[]
              }
            })
           }
         }else if(this.detail.PriceMonitoreDimension == 4){
           if(!val){
             return 
           }else {
            let virtual={
              searchdata: {
                "table":"T_V_IESPLATFORMSKU",
                "startindex":0,
                'range':3000,
                "fixedcolumns":{"NUMIID":val},
                "column_include_uicontroller":true,
                "isolr":false}
            }
            network.post('/p/cs/QueryList', urlSearchParams(virtual)).then((res) => {
              let list = [];
              let newList = [];
              let paramsList = [];
              for (var key in res.data.data.row[0]) {
                paramsList.push(key);
              }
              res.data.data.row.forEach(item => {
                let obj = {
                  label: item.NUMIID.val,
                  value: item.ID.val
                };
                let objParams = {}
                paramsList.forEach(param => {
                  objParams[param] = item[param].val
                })
                list.push(obj);
                newList.push(objParams)
              });
              if(list.length > 0) {
                this.SKUArrExclude = list;
                this.SKUAllDataExclude = newList;
              }else {
                this.SKUArrExclude=[]
                this.SKUAllDataExclude=[]
              }
            })
           }
         }
      },
      // 排除商品查询option选中
      selectExcludeGoods(val) {
        if(this.detail.MonitorDimensionValue){
          this.selectExcludeSKUData=this.SKUAllDataExclude.find(item=>{
            return item.ID==val
          })
          this.detail.MonitorDimensionValue=this.selectExcludeSKUData.ID //双向数据绑定
          if(this.detail.PriceMonitoreDimension == 1){
            this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.SKU;
          }else if(this.detail.PriceMonitoreDimension == 2){
            this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.PRODUCTCODE;
          }else if(this.detail.PriceMonitoreDimension == 3){
            this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.EXTSKUID;
          }else {
            this.detail.MonitorDimensionValueText = this.selectExcludeSKUData.NUMIID;
          }
        }else{
          this.selectExcludeSKUData={}
        }
      },
        // 保存
        saveAll(){
          let baseMsg = this.tabList[0]; //基本设置
          if(!baseMsg.list[0].VALUE){
            return this.$Message.warning('策略名称不能为空！');
          }
          if(!baseMsg.list[1].VALUE){
            return this.$Message.warning('使用店铺不能为空！');
          }
          if(!this.startTime || !this.endTime){
            return this.$Message.warning('起止时间不能为空！');
          }
          if((new Date(this.endTime).getTime())<(new Date().getTime())){
            return this.$Message.warning('结束时间必须大于当前系统时间！');
          }
          if(!this.returnData.length){
            return this.$Message.warning('商品明细不能为空！');
          }
          // 策略明细
          let productInfo= []
          this.returnData.forEach(item => {
            let obj = {
              "goodstype":item.PriceMonitoreDimension == 1?1:item.PriceMonitoreDimension == 2?4:item.PriceMonitoreDimension == 3?2:3,
              "goodscode":item.MonitorDimensionValueText,
            }
            productInfo.push(obj)
          })
          
          let params = { // 保存接口参数
            id: this.pageMsgId,
            TACTICS_NAME: baseMsg.list[0].VALUE, // tacticsName
            iesshopid: baseMsg.list[1].VALUE,
            START_TIME: this.startTime, // startTime
            END_TIME: this.endTime, // endTime
            comments: baseMsg.list[3].VALUE,
            // productInfo: productInfo
          }
          this.saveSubmit(params)
        },
        saveSubmit(params) {
          network.post('/p/cs/saveBarCodeLock',params).then(res => {
            if(res.data.code == 0){
              this.$Message.success('修改策略成功！');
              this.closePage();
            }
          })
        },
        getTime(date){
          let time = new Date(date).getTime();
        },
        // 策略明细表导入
      importStrategyDetailExcel() {
        this.SKULockInventoryDetailvisible = true;
      },
      // 策略明细表导出
      async exportStrategyDetailExcel() {
        let userId = JSON.parse(localStorage.getItem('userInfo')).id;
        let data = await network.get(`/p/cs/judge/export_the_verification_code?tableName='T_IESSHOPSKUSTOCKLOCKITEM'`);
        if (data.data.data) {
          let virtual = {
            table: 'V_USERS', // USERS
            objid: userId,
          };
          this.$network.post('/p/cs/object/query', virtual).then((res) => {
            let str = res.data.MOBIL;
            let a = /^1\d{10}$/;
            if (str && a.test(str)) {
              let MOBIL = str;
              let refresh = this.searchClickData;
              this.$R3Dialog({
                dialogComponentName: 'exportValidate', // 自定义的弹框组件
                title: '导出校验', // 弹框标题
                footerHide: true,
                externalOptions: {
                  massage: MOBIL,
                  refresh
                }
              }, () => {
                this.batchExport(event); // 调用框架导出
              });
            } else {
              this.$Modal.fcError({
                title: '错误',
                content: '当前用户手机号为空或格式不正确，请联系管理员在【用户档案】中进行修改',
                mask: true,
              });
            }
          });
        } else {
          this.batchExport(event); // 调用框架导出
        }
      },
      batchExport(){
        let searchdata = {"table":"T_IESSHOPSKUSTOCKLOCKITEM","startIndex":0,"fixedcolumns":{"ID":null},"objectIds":"203866="+this.pageMsgId,"range":1000,"column_include_uicontroller":true}
        let fd = new FormData();
        fd.append('searchdata', JSON.stringify(searchdata));
        fd.append('filename', '店铺条码锁库存策略明细');
        fd.append('filetype', '.xlsx');
        fd.append("showColumnName", true);
        network.post('/p/cs/export',fd).then(res => {
          if(res.data.code == 0){
            this.$Modal.fcSuccess({
              title: '成功',
              mask: true,
              content: res.data.message
            });
            const asyncTaskScheme = () => (window.ProjectConfig && window.ProjectConfig.asyncTaskScheme ? window.ProjectConfig.asyncTaskScheme : '');  // 异步导出设计方案
            if(asyncTaskScheme() === 'skq') {
              const params = {
                detail: {
                  type: 'notice'
                }
              }
              DispatchEvent(R3_IMPORT, params)
              this.$R3loading.hide(this.loadingName);
              // this.closeDialog()
              return
            }
          }
        })
      },

      // 策略明细表导入弹框关闭
      closeActionDialog() {
        this.SKULockInventoryDetailvisible = false;
      },
    }
  };
</script>
<style lang="less">

.quickOperation{
  height: 64px;
  border-bottom: 1px solid #D8D8D8;
  display: flex;
  align-items: center;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #333333;
}
.content{
  .block{
    padding-top: 24px;
  }
  .ark-col{
    display: flex;
    align-items: center;
    // justify-content: flex-end;
    margin-bottom: 16px;
    .input_box{
      max-width: 400px;
      min-width: 180px;
    }
    
   .ark-input-wrapper /deep/ textarea{
      resize: none;
      min-height: 36px!important;
    }
    .title{
      min-width: 100px;
      display: flex;
      justify-content: flex-end;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      display: flex;
      align-items: center;
      margin-right: 8px;
      img{
        margin-left: 5px;
        width: 16px;
      }
    }
  }
 
}
.refund-content{
    margin:0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;

    .count-part{
        height: 60px;
        margin-bottom: 16px;
        border-bottom: 1px solid #D8D8D8;
        .item{
            display: flex;
            align-items: center;
            .text{
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #333333;
            }
        }
        .img-framelanflag{
            cursor: pointer;
            vertical-align: middle;
            margin-top: -3px;
            margin-left: 5px;
            width: 16px;
        }
        .input-money{
            width: 80px;margin:0 8px
        }
        .plus{
            margin: 0 16px;
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #979797;
        }
    }
    .total-part{
        display: flex;
        align-items: center;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #333333;
    }
}

.AbnormalPriceMonitoreStrategy .ark-upload-drag {
  border: none;
}
.AbnormalPriceMonitoreStrategy .ark-select-multiple .ark-select-item.ark-select-item-all {
  display: none;
}
.priceMonitor .img-framelanflag {
  cursor: pointer;
  vertical-align: middle;
  margin-top: 0px;
  margin-left: 0px;
  width: 16px;
}
.AbnormalPriceMonitoreStrategy .input_box.ark-fkrp-select {
  width: 220px;
}

</style>
<style lang="less" scoped>
  .AbnormalPriceMonitoreStrategy {
    min-width: 1480px;
  }
 .pageContent {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
  }
  .order-setting-input-error:before{
    content: '*';
    color: red;
  }
  .conditionContent,.conditionContentOne {
    width: 100%;
    display: flex;
    max-height: 3000px;
    overflow: hidden;
    flex-wrap: wrap;
    padding-top: 8px;   
    justify-content: space-between;
    .itemContent {
      width: calc((100% - 120px) / 3);
      display: flex;
      align-items: center;
      margin:0 20px 24px;
      .itemLabel {
        min-width: 84px;
        font-size: 12px;
        font-weight: 500;
        color: #4C4C4C;
        line-height: 17px;
        margin-right: 8px;
        text-align: right;
      }
      .posterType {
        width: calc(100% - 84px);
      }
    }
  }
  .tableArea /deep/ .ark-tabs-bar{
    margin-bottom: 0px;
    .ark-tabs-tab{
      line-height: 22px !important;
    }
  }
  .tableArea{
    padding-top:24px;
    .handleBtn{
        height:16px;
        margin-bottom:16px;
        display:flex;
        .handleItem{
          width: 48px;
          height: 16px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: var(--primary-color);
          line-height: 16px;
          margin: 0 2px;
          cursor: pointer;
        }
    }
  }
  .content /deep/ .ark-select-input[disabled]{
      color: #575757;
  }
</style>
