<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>
                    <DropDownSelectFilter 
                            :single="true"
                            v-if="(i.SKEY=='iesWarehouse') || (i.SKEY=='iesStore')"
                            class="input_box"
                            :data="i.shopData"
                            :totalRowCount="i.shopData.totalRowCount"
                            :showColnameKey="'isak'"
                            :defaultSelected="i.defaultSelected"
                            :disabled='i.disabled'
                            @on-page-change="changePageShop($event,i)"
                            @on-input-value-change="InputValueChangeShop($event,i)"
                            @on-popper-show="searchShopData(i)"
                            @on-fkrp-selected="checkDataShop($event,i)"
                            @on-focus="focusInputValueChangeShop($event,i)"
                            @on-blur="changeDataShop($event,i)"
                            @on-clear="clearDataShop(i)"
                            :dataEmptyMessage="i.dataEmptyMessage"
                            :columns="i.columns"
                            :AutoData="i.AutoData">
                    </DropDownSelectFilter>
                    <DatePicker v-if='i.SKEY=="orderDate"' type="date" format="yyyy-MM-dd" placeholder="请选择单据日期" style="width: 100%;max-width:400px;min-width: 180px;" :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-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=='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="returnSelect"
                      style="width:240px"
                      v-model="selectReturnSKUID"
                      @on-query-change="getReturnSkuList"
                      @on-change="selectReturnGoods"
                      @on-enter="addReturnGoods"
                      filterable
                      clearable
                    >
                      <Option v-for="(option,index) in SKUArrReturn" :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">
                <div style="display: flex;align-items: center;">
                  <label style="width: 86px;text-align:right;margin-right:4px;"><span style='color: red;'>*</span>解冻数量</label>
                  <Input style="width:240px" :regx='regx' v-model="returnGoodsNum" @on-enter="addReturnGoods"></Input> 
                </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="importGiftGoodsExcel">【导入】</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="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>
  </div>
</template>
<script>
  import foldPanel from '../../customizedContent/FoldPanel.vue'; // 折叠面板组件
  import ShrinkOrExtend from '../../customizedContent/shrinkOrExtend' //收缩伸展搜索条件组件 
  import tableFaker from '../../customizedContent/tableFaker.vue'; //表格组件

  const R3 = window.R3;
  const { network, urlSearchParams, store } = R3;
  export default {
    data() {
      return {
        MonitorDimensionValueType: '系统SKU编码',
        tabList: [
          {
            tabId: '1',
            tabtext: '基本信息',
            blockShow: true,
            list: [
              {
                ID: '',
                SKEY: 'orderDate',
                title: '单据日期',
                VALUE: '',
                company: '',
                tips: '',
                placeholder:'请输入日期范围',
                disabled:false,
                standard:true,//标准输入框长度
                flag: true, // 控制必填校验样式展示
                required: true, // 是否为必填项
                explain:false, //是否有解释
              },
              {
                ID: '',
                SKEY:'iesWarehouse', //字段
                title:'实体仓库', //字段名称
                VALUE: '', //字段值
                clearable:true,
                required: true, // 是否为必填项
                tableName:'',//表名
                currentIndex:0,//当前页码
                dataEmptyMessage: '数据加载中...', // 无数据的提示
                columns:['name','value'],// 展现的组
                AutoData:[],//模糊搜索
                defaultSelected:[],//默认数据
                shopData:{},
                standard:true,//标准输入框长度
              },
              {
                ID: '',
                SKEY:'iesStore', //字段
                title:'逻辑仓库', //字段名称
                VALUE: '', //字段值
                clearable:true,
                disabled:true,
                required: true, // 是否为必填项
                tableName:'',//表名
                currentIndex:0,//当前页码
                dataEmptyMessage: '数据加载中...', // 无数据的提示
                columns:['name','value'],// 展现的组
                AutoData:[],//模糊搜索
                defaultSelected:[],//默认数据
                shopData:{},
                standard: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: 'TITLE',
            },
            {
              title: '商品编码',
              align: 'center',
              key: 'PRODUCTCODE',
            },
            {
              title: 'sku',
              align: 'center',
              key: 'SKU',
            },
            {
              title: '解冻数量',
              align: 'center',
              key: 'NUM',
            },
        ],
        tableHeight:'200',//表格高度

        currentReturnData:[],//当前显示策略明细明细
        returnData:[],
        returnDataNoSame:[],//弹窗中没有的策略明细
        submitArrReturn:[],//选中的策略明细
        // 策略明细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,

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

        showTip: false,
        showDetailTable: true, // 展示商品明细
        orderDate: '',  // 单据日期

        SKUArrReturn:[],//退货商品SKU下拉框列表
        SKUAllDataReturn:[],//退货商品SKU下拉框列表完整数据
        returnGoodsNum: '', //数量
      };
    },
    components: {
      foldPanel,
      ShrinkOrExtend,
      tableFaker
    },
    created(){
      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.orderDate){
            flag = false;
            break;
          }
          if(this.tabList[0].list[i].VALUE){
            flag = false;
            break;
          }
        }
        if(!flag){
          this.showTip = true;
        }else{
          this.closePage();
        }
      },
      rangeDate(e) {
        this.orderDate = e;
      },
      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 = []; // 策略明细置空
      },
      // 关闭当前页面
      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_IESSTOCKTHAW',
            tableId:'11516',
            back:true
          });
        },0)
      },

      // 下拉分页模糊搜索框
      // 外键下拉框
        searchShopData(i){
             let virtual={}
            if(i.SKEY==='iesWarehouse'){
                virtual={
                    searchdata:{
                      "isdroplistsearch":true,
                      "refcolid":203898,
                      "startindex":i.currentIndex,
                      "range":10,
                    }
                }
            }else if(i.SKEY==='iesStore'){
                virtual={
                    searchdata:{
                      "isdroplistsearch":true,
                      "refcolid":203897,
                      "startindex":i.currentIndex,
                      "range":10,
                      "fixedcolumns":{"IESWAREHOUSEID":this.tabList[0].list[1].VALUE}
                    }
                }
            }
            network.post('/p/cs/QueryList',urlSearchParams(virtual)).then((res) => {
                 if(res.data.code==0){
                    if(i.SKEY==='iesStore' || i.SKEY === 'iesWarehouse'){
                      this.tabList[0].list.forEach(item => {
                        if(item.SKEY===i.SKEY){
                            item.shopData=res.data.data
                            item.currentIndex=0
                        }
                      });
                    }
                 }
                 
             })
        },
        // 单选下拉选中
        checkDataShop(val,i){
          let index = 0
          if(i.SKEY==='iesWarehouse') {
            index = 0;
          }else if(i.SKEY==='iesStore') {
            index = 0;
          }
          this.tabList[index].list.forEach(item => {
            if(item.SKEY===i.SKEY){
                item.VALUE=val[0].ID
                item.NAME=val[0].Label
            }
            if(i.SKEY==='iesWarehouse' && i.VALUE && item.SKEY=='iesStore'){
              item.disabled = false;
            }
          });
        },
        // 单选框失去焦点事件
        changeDataShop(e,i){
            let index = 0
            if(i.SKEY==='iesWarehouse') {
              index = 0;
            }else if(i.SKEY==='iesStore') {
              index = 0;
            }
            if(!e.target.value){
              this.tabList[index].list.forEach(item => {
                  if(item.SKEY===i.SKEY){
                      item.VALUE=''
                      item.NAME=''
                  }
                  if(i.SKEY==='iesWarehouse'&& !i.VALUE && item.SKEY=='iesStore'){
                    item.disabled = true;
                  }
              });
            }else{
                this.tabList[index].list.forEach(item => {
                    if(item.SKEY===i.SKEY){
                        if(item.AutoData.length){
                            item.AutoData.forEach(v=>{
                                if(e.target.value==v.value){
                                    item.VALUE=v.id
                                    item.NAME=v.value
                                }
                            })
                        }
                        e.target.value=item.NAME?item.NAME:''
                    }
                    if(i.SKEY==='iesWarehouse' && i.VALUE && item.SKEY=='iesStore'){
                      item.disabled = false;
                    }
                }); 
            }
        },
        // 清空选中项
        clearDataShop(i){
            let index = 0
            if(i.SKEY==='iesWarehouse') {
              index = 0;
            }else if(i.SKEY==='iesStore') {
              index = 0;
            }
            this.tabList[index].list.forEach(item => {
                if(item.SKEY==i.SKEY){
                    item.VALUE=''
                    item.NAME=''
                }
                if(i.SKEY==='iesWarehouse'&& !i.VALUE && item.SKEY=='iesStore'){
                  item.disabled = true;
                }
            });
            this.tabList = JSON.parse(JSON.stringify(this.tabList))
        },
        // 单选下拉分页改变
        changePageShop(e,i){
          let index = 0
            if(i.SKEY==='iesWarehouse') {
              index = 0;
            } else if(i.SKEY==='iesStore') {
              index = 0;
            }
            this.tabList[index].list.forEach(item => {
                if(item.SKEY===i.SKEY){
                    item.currentIndex=(e-1)*10
                    this.searchShopData(item)
                }
            });
        },
        focusInputValueChangeShop(e,i){
            let virtual={}
            if(i.SKEY==='iesWarehouse'){
                virtual={
                    ak: e.target.value,
                    colid: 203898,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='iesStore'){
                virtual={
                    ak: e.target.value,
                    colid: 203897,
                    fixedcolumns: {"whereKeys":{"IESWAREHOUSEID":"="+this.tabList[0].list[1].VALUE}}
                }
            }
            network.post('/p/cs/fuzzyquerybyak',urlSearchParams(virtual)).then((res) => {
                if(res.data.code==0){
                    if(i.SKEY==='iesWarehouse' || i.SKEY==='iesStore'){
                      this.tabList[0].list.forEach(item => {
                          if(item.SKEY===i.SKEY){
                              item.AutoData=res.data.data
                          }
                      });
                    }
                }
                
            })
        },
        // 单选下拉模糊搜索数据
        InputValueChangeShop(e,i){
             let virtual={}
            if(i.SKEY==='iesWarehouse'){
                virtual={
                    ak: e,
                    colid: 203898,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='iesStore'){
                virtual={
                    ak: e,
                    colid: 203897,
                    fixedcolumns: {"whereKeys":{"IESWAREHOUSEID":"="+this.tabList[0].list[1].VALUE}}
                }
            }
            network.post('/p/cs/fuzzyquerybyak',urlSearchParams(virtual)).then((res) => {
                if(res.data.code==0){
                    if(i.SKEY==='iesWarehouse' || i.SKEY==='iesStore'){
                      this.tabList[0].list.forEach(item => {
                          if(item.SKEY===i.SKEY){
                              item.AutoData=res.data.data
                          }
                      });
                    }
                }
                
            })
        },

      // 添加策略明细到表格
      addReturnGoods(){
          if(JSON.stringify(this.selectReturnSKUData)=='{}'){
            this.$Message.warning('添加条码不能为空');
            return
          }
          if(!this.returnGoodsNum) {
            this.$Message.warning('解冻数量不能为空');
            return
          }
          let obj=this.selectReturnSKUData
          if(obj){
              let addData= {
                  ID: 'cs'+ Math.floor(Math.random()*10000),
                  SKUID: obj.ID,
                  TITLE:obj.SKUNAME,
                  PRODUCTCODE:obj.PRODUCTCODE,
                  SKU:obj.SKU,
                  NUM: this.returnGoodsNum,
              }
              if(this.returnData.length){
                  let sameData=this.returnData.find(i=>i.SKU==addData.SKU&&addData.SKUID==i.SKUID)
                  if(!sameData){
                    this.returnData.push(addData)
                  }else{
                    this.returnData.forEach(item=>{
                      if(addData.SKU==item.SKU&&addData.SKUID==item.SKUID){
                        item=sameData
                        item.NUM=Number(item.NUM)+Number(this.returnGoodsNum)
                      }
                    })
                  }
              }else {
                this.returnData.push(addData)
              }
              this.$refs.returnSelect.clearSingleSelect()
              this.selectReturnSKUID = ''
              this.returnGoodsNum=''
              this.totalReturn=this.returnData.length
              if(this.totalReturn){ //翻页
                this.returnCurrentPage=parseInt((this.totalReturn-1)/this.pageSizeReturn)+1
              }
              // 截取数组
              let startIndex=this.pageSizeReturn*(this.returnCurrentPage-1)
              let endIndex=startIndex+this.pageSizeReturn
              this.currentReturnData=this.returnData.slice(startIndex,endIndex) //当前页面显示明细
          }
      },
      //初始查询标准下拉框数据
      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
                    }
                  })
                }
              }
            })
          })
      },

      // 获取退货表格所有SKU
      getReturnSkuList(val){
         let virtual={sku: val}
          network.post('/p/cs/getIesSku', virtual).then((res) => {
            if(res.data.Code==0){
              this.SKUArrReturn=res.data.Rows.map(i=>{
                return {
                  label:i.SKU,
                  value:i.ID
                }
              })
              this.SKUAllDataReturn=res.data.Rows
            }else{
              this.SKUArrReturn=[]
              this.SKUAllDataReturn=[]
            }
          })
      },
      selectReturnGoods(val){
        if(this.selectReturnSKUID){
          this.selectReturnSKUData=this.SKUAllDataReturn.find(item=>{
            return item.ID==val
          })
        }else{
          this.selectReturnSKUData={}
        }
      },
      // 选择系统商品 在单选下有效，选中某一项时触发
      selectGoods(selection){
        this.submitArrGoods=[selection]
      },
      
      // 选择系统商品页码改变时触发
      changePageGoods(val) {
        // 1=>0 2=>10 3=>20 
        this.currentGoodsPage = (val - 1) * 10;
        this.searchGoodsData();
      },
      // 选择系统商品页数改变时触发
      changeSizeGoods(val) {
        this.pageSizeGoods = val;
        this.currentGoodsPage = 1;
        this.searchGoodsData();
      },

      // 打开系统商品选择商品弹窗
      searchGoods(name){
        this.searchGoodsData()
        this.selectGoodsModal=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]
              }
            }
          });
      },

      // 关闭系统商品选择商品弹窗
      cancelSelectGoods(){
        this.selectGoodsData={ 
          NORMS1NAME:'',//颜色
          NORMS2NAME:'',//尺寸
          SKU:'',//SKU
          GBCODE:'',//国标码
          PRODUCTCODE:'',//商品编码
          PRODUCTNAME:''//商品名称
        }
        this.submitArrGoods=[]
        this.selectGoodsModal=false
      },
      // 选择系统商品确认按钮
      okSelectGoods(){
        if(!this.submitArrGoods.length){
          this.$Message.warning('请选择商品');
          return
        }
          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.SKUArrReturn=res.data.Rows.map(i=>{
                  return {
                    label:i.SKU,
                    value:i.ID
                  }
                })
                this.SKUAllDataReturn=res.data.Rows
              }else{
                this.SKUArrReturn=[]
                this.SKUAllDataReturn=[]
              }
              this.selectReturnSKUData=this.SKUAllDataReturn.find(item=>{
                return item.ID==this.submitArrGoods[0].ID
              }) //添加的数据
              this.selectReturnSKUID=this.selectReturnSKUData.ID //双向数据绑定
              this.cancelSelectGoods()
            })
      },

      // 策略明细表删除
      deleteReturnGoods(){
        let idArray=this.submitArrReturn.map(item=>item.MODIFYDISCERNID)
        this.returnData = this.returnData.filter(i =>{ 
         return !idArray.includes(i.MODIFYDISCERNID)
        });
        this.totalReturn=this.returnData.length //总条数
        // 截取数组
        let startIndex=this.pageSizeReturn*(this.returnCurrentPage-1)
        let endIndex=startIndex+this.pageSizeReturn
        this.currentReturnData=this.returnData.slice(startIndex,endIndex) //当前页面显示明细
      },
      
      // 策略明细页码改变时触发
      changePageReturn(val){
         // 1=>0 2=>10 3=>20 
         this.returnCurrentPage=val
        // 截取数组
        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
        }
      },
        // 保存
        saveAll(){
          let baseMsg = this.tabList[0]; //基本设置
          if(!this.orderDate){
            return this.$Message.warning('单据日期不能为空！');
          }
          if(!baseMsg.list[1].VALUE){
            return this.$Message.warning('实体仓库不能为空！');
          }
          if(!baseMsg.list[2].VALUE){
            return this.$Message.warning('逻辑仓库不能为空！');
          }
          if(!this.returnData.length){
            return this.$Message.warning('商品明细不能为空！');
          }
          // 策略明细
          let productInfo= []
          this.returnData.forEach(item => {
            let obj = {
              "sku": item.SKU,
              "IESSKUID": item.SKUID,
              "num":item.NUM,
            }
            productInfo.push(obj)
          })
          
          let params = { // 保存接口参数
            ORDER_DATE: this.orderDate,  // orderDate
            IES_WAREHOUSE_ID: baseMsg.list[1].VALUE, // iesWarehouseId
            IES_STORE_ID: baseMsg.list[2].VALUE, // iesStoreId
            remark: baseMsg.list[3].VALUE,
            details: productInfo
          }
          this.saveSubmit(params)
        },
        saveSubmit(params) {
          network.post('/p/cs/thaw/save',params).then(res => {
            if(res.data.code == 0){
              this.$Message.success('解冻单新增成功！');
              this.closePage();
            }
          })
        },
        getTime(date){
          let time = new Date(date).getTime();
        }
    }
  };
</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: 1380px;
  }
 .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>
