<template>
    <div class="edit-signpackage" data-key="EDITOR_BAOGUO_RECEIVE">
      <div class="quickOperation">
        快捷操作：
        <Button
          :class="{'saveBtn':hideBtn}"
          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"
          v-if='item.blockShowOne'
          class="block"
        >
          <foldPanel
            v-model="item.blockShow"
            :title="item.tabtext"
          >
            <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" style="height:16px" > 
                    <div
                        v-if="i.title"
                        :class="{'title':true,'returnLongText':(i.SKEY=='return_logistics_num' && type!='list'),'nickTitle':(i.SKEY=='buyer_nickname' && type!='list'),'order-setting-input-error':(i.SKEY=='original_order_number'&&i.VALUE&&i.required) || (i.SKEY!='original_order_number'&&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>
                    <div v-if="(i.SKEY=='ISDEAL')||(i.SKEY=='ISPRINT')||(i.SKEY=='IS_INVALID')" style="display: inline-block;width: 100%;">
                        <Checkbox v-model="i.VALUE" :disabled="i.disabled"></Checkbox>
                    </div>
                    <Input
                      v-else-if="
                      (i.SKEY=='OMSORDERID')
                      ||(i.SKEY=='DISPATCHNO')
                      ||(i.SKEY=='packagefrom')
                      ||(i.SKEY=='SIGNTIME')
                      ||(i.SKEY=='DESCRIPTION')
                      ||(i.SKEY=='MOBILE')
                      ||(i.SKEY=='SELLADDRESS')
                      ||(i.SKEY=='signUserName')
                      ||(i.SKEY=='SIGNNAME')
                      ||(i.SKEY=='CREATIONDATE')
                      ||(i.SKEY=='MODIFEDNAME')
                      ||(i.SKEY=='MODIFIEDDATE')
                      "
                      class="input_box"
                      :id='i.SKEY=="consignee_people"?"consigneePeople":""'
                      v-model.trim="i.VALUE"
                      :placeholder="i.placeholder"
                      :disabled="i.disabled"
                      @on-keypress='noSpaces($event,i)'
                    />
                    <Select
                      v-else-if="i.SKEY==='ERECEIPT_CAUSE'"
                      v-model="i.VALUE"
                      clearable
                      @on-change="selectReturnGoods">
                      <Option
                        v-for="item in i.option"
                        :key="item.value"
                        :value="item.value">
                        {{ item.label }}
                      </Option>
                    </Select>
                    <DropDownSelectFilter 
                            :single="true"
                            v-if="(i.SKEY=='return_logistics_company') || (i.SKEY=='return_warehouse') || (i.SKEY=='brandname')"
                            class="input_box"
                            :data="i.shopData"
                            :disabled="i.disabled"
                            :totalRowCount="i.shopData.totalRowCount"
                            :showColnameKey="'isak'"
                            :defaultSelected="i.defaultSelected"
                            @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>
                  </Col>
                </div>
                </Row>
              </div>
            </div>
          </foldpanel>
        </div>
  
  
      </div>
      <div class="tableArea">
        <Tabs type="card" v-model="nowTabTable">
          <TabPane label="包裹明细" name='packageDetail'>
              <Row style="display: flex;
                  justify-content: space-around;
                  align-items: center;
                  height: 48px;
                  margin-bottom: 16px;
                  background: #F8F8F8;"  v-if="detailHandlePower">
                <Col span="8">
                <div style="display: flex;align-items: center;" >
                  <label style="width: 30px;">SKU</label>
                  <Select
                    ref="returnSelect"
                    style="width:240px"
                    v-model="selectReturnSKUID"
                    @on-query-change="getReturnSkuList"
                    @on-change="selectReturnGoods"
                    @on-enter="addEnterReturnGoods"
                    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="8" >
                <div style="display: flex;align-items: center;">
                  <label style="width: 30px;">数量</label>
                  <InputNumber style="width:240px" :min="1" v-model="returnGoodsNum"  @on-enter="addReturnGoods"></InputNumber>
                </div>
                </Col>
                <Col span="2" >
                <Button type="primary" icon="md-return-left" @click="addReturnGoods">添加</Button>
                </Col>
              </Row>
              <div class="handleBtn">
                <div class="handleItem" @click="deleteReturnGoods" v-if="detailHandlePower">【删除】</div>
              </div>
              <div class='returnGoodsTableBox'>
                <div class='returnGoodsTableOne' refs='returnGoodsTableOne' :style='tableStyleOne'>
                  <Table height="300"
                    :columns="returnColumns"
                    :data="currentReturnData"
                    highlight-row
                    :index='defaultIndex'
                    @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
                      :page-size-opts="pageSizeOpts"
                      :total="totalReturn"
                      show-total
                      show-sizer
                      @on-change="changePageReturn"
                      @on-page-size-change="changeSizeReturn"
                    />
                  </div>
                </div>
              </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="sureBtnHandle"
        >
        <p><i class="iconfont iconbj_doubt fcWarning " />修改的数据未保存，确定返回？</p>
        </Modal>
      <Spin fix v-if="spinShow">
        <Icon type="ios-loading" size=18 style="animation: ani-demo-spin 1s linear infinite"></Icon>
        <div>加载中...</div>
      </Spin>
    </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 {
          showTip: false,
          nowTabTable: 'packageDetail', // 默认展示包裹明细tab
          pageSizeOpts: [10, 50, 100, 500], // 数据权限弹窗更改每页多少条
          showCancel:false,
          hideBtn:false,//隐藏保存按钮
          allDisabled:false,//完成和取消状态退款金额也不能修改
          queryVirstatus:'',//查询到的状态
  
          spinShow:false, //开启加载模式
          SKUArrReturn:[],//退货商品SKU下拉框列表
          SKUAllDataReturn:[],//退货商品SKU下拉框列表完整数据
          selectReturnSKUData:{},//退货商品选中的SKU数据
          selectReturnSKUID:'',//退货商品sku下拉框双向数据绑定
          returnGoodsNum:1,//退货商品数量
          tabList: [
            {
              tabId: '1',
              tabtext: '基本信息',
              blockShow: true,
              blockShowOne: true,
              list: [
                {
                    ID: 'T_V_OMSLOGISTICSCOMPANY',
                    SKEY: 'return_logistics_company',
                    title: '物流公司',
                    VALUE: '',
                    clearable:true,
                    tableName:'',//表名
                    currentIndex:0,//当前页码
                    dataEmptyMessage: '数据加载中...', // 无数据的提示
                    columns:['name','value'],// 展现的组
                    AutoData:[],//模糊搜索
                    defaultSelected:[],//默认数据
                    shopData:{},
                    disabled: true,
                    standard:true,//标准输入框长度
                },
                {
                    ID: '',
                    SKEY: 'OMSORDERID',
                    title: '订单编号',
                    VALUE: '',
                    placeholder:'',
                    company: '',
                    tips: '',
                    disabled:true,//不可编辑
                    standard:true,//标准输入框长度
                    flag: true, // 控制必填校验样式展示
                    required: false, // 是否为必填项
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'DISPATCHNO',
                    title: '物流单号',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'packagefrom',
                    title: '包裹来源',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'SIGNTIME',
                    title: '签收时间',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'ERECEIPT_CAUSE',
                    title: '签收原因',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,
                    flag: false,
                    showTag: true,
                    option: [],
                },
                {
                    ID: '',
                    SKEY: 'DESCRIPTION',
                    title: '备注',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    ID: 'T_IESWAREHOUSE',
                    SKEY: 'return_warehouse',
                    title: '签收仓库',
                    VALUE: '',
                    clearable:true,
                    tableName:'',//表名
                    currentIndex:0,//当前页码
                    dataEmptyMessage: '数据加载中...', // 无数据的提示
                    columns:['name','value'],// 展现的组
                    AutoData:[],//模糊搜索
                    defaultSelected:[],//默认数据
                    shopData:{},
                    standard:true,//标准输入框长度
                    disabled: true,
                },
                {
                    ID: '',
                    SKEY: 'MOBILE',
                    title: '手机号',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'SELLADDRESS',
                    title: '发货地址',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    SKEY: 'brandname',
                    title: '品牌',
                    VALUE: '',
                    clearable:true,
                    tableName:'',//表名
                    currentIndex:0,//当前页码
                    dataEmptyMessage: '数据加载中...', // 无数据的提示
                    columns:['name','value'],// 展现的组
                    AutoData:[],//模糊搜索
                    defaultSelected:[],//默认数据
                    shopData:{},
                    standard:true,//标准输入框长度
                    disabled: true,
                },
                {
                    ID: '',
                    SKEY: 'signUserName',
                    title: 'WMS签收人',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                    disabled: true,
                },
                {
                    ID: '',
                    SKEY: 'ISDEAL',
                    title: '是否处理',
                    VALUE: false,
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    flag: false, // 控制必填校验样式展示
                    standard:true,//标准输入框长度
                    showTag: true,
                    disabled: true,
                },
                {
                    ID: '',
                    SKEY: 'ISPRINT',
                    title: '是否打印',
                    VALUE: false,
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    flag: false, // 控制必填校验样式展示
                    standard:true,//标准输入框长度
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'IS_INVALID',
                    title: '是否作废',
                    VALUE: false,
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    flag: false, // 控制必填校验样式展示
                    standard:true,//标准输入框长度
                    showTag: true,
                },
              ],
            },
            {
              tabId: '2',
              tabtext: '日志',
              blockShow: true,
              blockShowOne: true,
              list: [
                {
                    ID: '',
                    SKEY: 'SIGNNAME',
                    title: '签收人',
                    VALUE: '',
                    placeholder:'',
                    company: '',
                    tips: '',
                    disabled:true,//不可编辑
                    standard:true,//标准输入框长度
                    flag: true, // 控制必填校验样式展示
                    required: false, // 是否为必填项
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'CREATIONDATE',
                    title: '创建时间',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled:true,//不可编辑
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'MODIFEDNAME',
                    title: '修改人',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
                {
                    ID: '',
                    SKEY: 'MODIFIEDDATE',
                    title: '修改时间',
                    VALUE: '',
                    placeholder:'',
                    defaultvalue: '',
                    company: '',
                    tips: '',
                    disabled: true,
                    standard:true,//标准输入框长度
                    flag: false, // 控制必填校验样式展示
                    showTag: true,
                },
              ],
            },
          ],
          returnColumns: [ //退货商品
                {
                    type: 'selection',
                    width: 60,
                    align: 'center'
                },
                {
                    type: 'index',
                    align:'center',
                    title: '序号',
                },
                {
                    title: '商品名称',
                    align:'center',
                    key: 'NAME'
                },
                {
                    title: 'SKU',
                    align:'center',
                    key: 'SKU'
                },
                {
                    title: '商品数量',
                    align: 'center',
                    key: 'NUM',
                },
          ],
  
          highlightRow:true,//支持单选
          selectTableData:{},//选中的数据
          nowTab:'all',//默认当前tab页为全部
          lastTab:'',//上一个tab页

          tableHeight:'200',//表格高度
          currentReturnData:[],//当前显示退款明细
          returnData:[],
          originReturnData:[],//原始数据
          returnDataNoSame:[],//弹窗中没有的退货商品
          submitArrReturn:[],//选中的退货商品
          // 退货商品page
          returnCurrentPage:1,
          totalReturn: 0, // 总条数
          pageSizeReturn: 10, // 每页的条数
          choosedSKU: '', // 选择的退回商品SKU
  
          mask:true,
          closable: true,
          maskClosable: false,
          hideFoot: true,
          shrinkHeight: '58px',
          currentValue: false,//默认收缩

          selectGoodsModal:false,//选择商品弹窗
          nowGoodsType:'',//当前商品表类型
          selectGoodsData:{//选择商品搜索条件
            NORMS1NAME:'',//颜色
            NORMS2NAME:'',//尺寸
            SKU:'',//SKU
            GBCODE:'',//国标码
            PRODUCTCODE:'',//商品编码
            PRODUCTNAME:''//商品名称
          },
          submitArrGoods:[],//选择商品表格选中项
          SKUColumns:[
            {
              title: 'SKU',
              key: 'SKU'
            },
            {
              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,
  
          // 是否已传WMS
          ISTOWMS:'',
          originLOGISTICSCOMPANYID:'',//原始退回物流公司
          originLOGISTICSCOMPANYNAME: '',
          originSID:'',//原始退回物流单号
          originIESWAREHOUSEID:'',//原始退回仓库
  
          defaultIndex: undefined,
          isFold: false, // 折叠批次信息
          tableStyleOne: 'width: calc(100% - 34px);', // 表格1样式
          tableStyleTwo: 'width: 0', // 表格2样式
          encryptColumns: [],
          disableColumns: [],

          canmodifyStatus: '0', // 当前状态，区分哪些参数可修改
          DetailDataOld: {}, // 暂存详情主表数据
          oldReturnData: [], // 暂存明细数据
          saveArr: {
            BRANDID: 0,
            DESCRIPTION: '',
            IESSTOREID: 0,
            ISDEAL: 0,
            OMSORDERID: 0,
            SHIPPERID: 0,
            signUserName: '',
            REFUNDTOSTORE:0, //是否拒收
            REFUNDTYPE:'2',//单据类型
            ORIGINALORDERNO:'',//原订单编号
            OMSREASONTYPEID:'',//退换货原因
            REMARK:'',//备注
            LOGISTICSCOMPANYID:'',//退回物流公司ID
            COMPANY_NAME:'',//退回物流公司名称
            IESWAREHOUSEID:'',//退货仓库ID
            ERECEIPT_CAUSE: '',// 签收原因
          },
          detailHandlePower: false,
        };
      },
      components: {
        foldPanel,
        ShrinkOrExtend,
        tableFaker
      },
      created(){
          this._initFormData={}
          this.pageMsgId = window.vm.$route.params.customizedModuleId;
          this.getReceiveReason();
          this.getInitialData()  //初始化查询编辑数据
      },
      mounted() {
        // 计算文本在页面所占px宽度 -- 扩展String原型方法pxWidth
        String.prototype.pxWidth = function(font) {
          var canvas = String.prototype.pxWidth.canvas || (String.prototype.pxWidth.canvas = document.createElement("canvas")),
              context = canvas.getContext("2d");
  
          font && (context.font = font);
          var metrics = context.measureText(this);
  
          return metrics.width;
        }
      },
      methods: {
        async getReceiveReason(obj) {
          // const { reqType } = obj || {};
          let reqParam = { 
            table: 'T_OMSPACKAGERECEIPT_CAUSE',
            fixedcolumns: { },
            fkdrplist: {
              searchcols: ["ERECEIPT_CAUSE"],
              orderby: [{column: "ID", asc: true}]
            },
            isdroplistsearch: true,
            range: 1000,
            startindex: 0
          };
          const res = await network.post('/p/cs/list/query', reqParam)
          const { status, data = {} } = res || {};
          if (status === 200) {
            const { rows = [] } = data;
            let newOptions = [];
            if (rows.length) {
              newOptions = rows.map(item => {
                return {
                  label: item.ERECEIPT_CAUSE.val,
                  value: item.ID.val
                }
              })
            }
            this.tabList[0].list.find(item=>item.SKEY=='ERECEIPT_CAUSE').option = newOptions;
          }
        },
            //查询编辑数据
            getInitialData(){
                let virtual={
                    objid: this.pageMsgId,
                }
                network.post('/p/cs/signpackage/detail',virtual).then((res) => {
                        let data=res.data.data
                        this.tabList[0].list.find(item=>item.SKEY=='return_logistics_company').VALUE = data.SHIPPERID
                        this.tabList[0].list.find(item=>item.SKEY=='return_logistics_company').defaultSelected = data.SHIPPERID?[{
                          ID:  data.SHIPPERID,
                          Label: data.SHIPPERNAME
                        }]:[];
                        this.tabList[0].list.find(item=>item.SKEY=='OMSORDERID').VALUE = data.OMSORDERID
                        this.tabList[0].list.find(item=>item.SKEY=='DISPATCHNO').VALUE = data.DISPATCHNO
                        this.tabList[0].list.find(item=>item.SKEY=='packagefrom').VALUE = data.packagefrom == 1?'wms':data.packagefrom == 0?'云雀':''
                        this.tabList[0].list.find(item=>item.SKEY=='SIGNTIME').VALUE = data.SIGNTIME
                        this.tabList[0].list.find(item=>item.SKEY=='ERECEIPT_CAUSE').VALUE = data.ERECEIPT_CAUSEID + '';// 签收原因，字符串数字
                        this.tabList[0].list.find(item=>item.SKEY=='DESCRIPTION').VALUE = data.DESCRIPTION
                        this.tabList[0].list.find(item=>item.SKEY=='return_warehouse').VALUE = data.ieswarehouseid
                        this.tabList[0].list.find(item=>item.SKEY=='return_warehouse').defaultSelected = data.ieswarehouseid?[{
                          ID:  data.ieswarehouseid,
                          Label: data.ieswarehousename
                        }]:[];
                        this.tabList[0].list.find(item=>item.SKEY=='MOBILE').VALUE = data.MOBILE
                        this.tabList[0].list.find(item=>item.SKEY=='SELLADDRESS').VALUE = data.SELLADDRESS
                        this.tabList[0].list.find(item=>item.SKEY=='brandname').VALUE = data.BRANDID
                        this.tabList[0].list.find(item=>item.SKEY=='brandname').defaultSelected = data.BRANDID?[{
                          ID:  data.BRANDID,
                          Label: data.BRANDNAME
                        }]:[];
                        this.tabList[0].list.find(item=>item.SKEY=='signUserName').VALUE = data.signUserName
                        this.tabList[0].list.find(item=>item.SKEY=='ISDEAL').VALUE = data.ISDEAL==1?true:false
                        this.tabList[0].list.find(item=>item.SKEY=='ISPRINT').VALUE = data.ISPRINT==1?true:false
                        this.tabList[0].list.find(item=>item.SKEY=='IS_INVALID').VALUE = data.IS_INVALID==1?true:false

                        this.tabList[1].list.find(item=>item.SKEY=='SIGNNAME').VALUE = data.SIGNNAME
                        this.tabList[1].list.find(item=>item.SKEY=='CREATIONDATE').VALUE = data.CREATIONDATE
                        this.tabList[1].list.find(item=>item.SKEY=='MODIFEDNAME').VALUE = data.MODIFEDNAME
                        this.tabList[1].list.find(item=>item.SKEY=='MODIFIEDDATE').VALUE = data.MODIFIEDDATE
                        
                        let startIndex=this.pageSizeReturn*(this.returnCurrentPage-1)
                        let endIndex=startIndex+this.pageSizeReturn
                        this.returnData=data.ITEMS
                        this.currentReturnData=this.returnData.slice(startIndex,endIndex) //当前页面显示明细
                        this.oldReturnData=JSON.parse(JSON.stringify(this.returnData))

                        this.DetailDataOld = {
                            return_logistics_company: data.SHIPPERID,
                            OMSORDERID: data.OMSORDERID,
                            DISPATCHNO: data.DISPATCHNO,
                            DESCRIPTION: data.DESCRIPTION,
                            return_warehouse: data.ieswarehouseid,
                            brandname: data.BRANDID,
                            signUserName: data.signUserName,
                            ISDEAL: data.ISDEAL
                        }

                        if((data.ISTOWMS!=1 && data.IS_INVALID!=1) || (data.ISTOWMS==1 && data.IS_INVALID!=1 && data.WMSCANCELSTATUS==1)){
                            this.canmodifyStatus = '1';
                            this.tabList[0].list.find(item=>item.SKEY=='return_logistics_company').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='OMSORDERID').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='DESCRIPTION').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='return_warehouse').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='brandname').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='signUserName').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='ISDEAL').disabled = false;
                            this.detailHandlePower = true;
                        }else if(data.ISTOWMS==1 && !data.IS_INVALID && data.WMSCANCELSTATUS==0){
                            this.canmodifyStatus = '2';
                            this.tabList[0].list.find(item=>item.SKEY=='DESCRIPTION').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='signUserName').disabled = false;
                            this.tabList[0].list.find(item=>item.SKEY=='ISDEAL').disabled = false;
                        }                    
                        this.spinShow=false
                })
            },
            // 深拷贝
            deepCopy(o, c) {
                var c = c || {}
                for (var i in o) {
                    if (typeof o[i] === 'object') {
                        //要考虑深复制问题了
                        if (o[i].constructor === Array) {
                            //这是数组
                            c[i] = []
                        } else {
                            //这是对象
                            c[i] = {}
                        }
                        this.deepCopy(o[i], c[i])
                    } else {
                        c[i] = o[i]
                    }
                }
                return c
            },
            backToList() {
                this.BtnType = 'close'
                if(!this.ISChangesignpackage()){
                    this.showTip = true;
                }else {
                    this.closePage();
                }
            },
            refreshParams() {
                this.BtnType = 'refresh'
                if(!this.ISChangesignpackage()){
                    this.showTip = true;
                }else {
                    this.refreshPage();
                }
            },
            sureBtnHandle() {
                if(this.BtnType == 'close'){
                    this.closePage();
                }else if(this.BtnType == 'refresh') {
                    this.refreshPage();
                }
            },
            ISChangesignpackage() {
                let flag = true;
                if(this.tabList[0].list.find(item=>item.SKEY=='return_logistics_company').VALUE != this.DetailDataOld.return_logistics_company 
                || this.tabList[0].list.find(item=>item.SKEY=='OMSORDERID').VALUE != this.DetailDataOld.OMSORDERID
                || this.tabList[0].list.find(item=>item.SKEY=='DESCRIPTION').VALUE != this.DetailDataOld.DESCRIPTION
                || this.tabList[0].list.find(item=>item.SKEY=='return_warehouse').VALUE != this.DetailDataOld.return_warehouse
                || this.tabList[0].list.find(item=>item.SKEY=='brandname').VALUE != this.DetailDataOld.brandname
                || this.tabList[0].list.find(item=>item.SKEY=='signUserName').VALUE != this.DetailDataOld.signUserName
                || this.tabList[0].list.find(item=>item.SKEY=='ISDEAL').VALUE != this.DetailDataOld.ISDEAL){
                    flag = false;
                }
                if(this.returnData.length != this.oldReturnData.length){
                    flag = false;
                }
                let returnDeleteData = [...this.oldReturnData].filter(x => [...this.returnData].every(y => y.ID !== x.ID));
                let returnAddData = [...this.returnData].filter(x => [...this.oldReturnData].every(y => y.ID !== x.ID));
                if(returnDeleteData.length > 0 || returnAddData.length > 0){
                    flag = false;
                }
                return flag;
            },
            // 关闭当前页面
            closePage(){ 
                // this.$Modal.fcWarning({
                //     title: '提示',
                //     mask: true,
                //     showCancel: true,
                //     content: '有修改的信息尚未保存，请确定是否返回？',
                //     onOk:()=>{
                //         const { fullPath } = this.$route;
                //         const {
                //         keepAliveModuleName,tableName
                //         } = this.$store.state.global.activeTab;
                //         this.$store.commit('global/tabCloseAppoint', {
                //         tableName,
                //         routeFullPath: fullPath,
                //         keepAliveModuleName,
                //         stopRouterPush: true,
                //         });
                //         // 跳转
                //         setTimeout(()=>{
                //         R3.store.commit('global/tabOpen', {
                //             type: 'S',
                //             tableName:'T_V_OMSREFUNDORDERALL',
                //             tableId:'10612',
                //             back:true
                //         });
                //         },0)
                //     }
                // })
                const { fullPath } = this.$route;
                const {
                    keepAliveModuleName,tableName
                } = this.$store.state.global.activeTab;
                this.$store.commit('global/tabCloseAppoint', {
                    tableName,
                    routeFullPath: fullPath,
                    keepAliveModuleName,
                    stopRouterPush: true,
                });
                // 跳转
                setTimeout(()=>{
                    R3.store.commit('global/tabOpen', {
                        type: 'S',
                        tableName:'T_V_OMSSIGNPACKAGE',
                        tableId:'10715',
                        back:true
                    });
                },0)
            },
            refreshPage() {
                this.getInitialData()  //初始化查询编辑数据
            },
            saveAll() {
                this.saveArr.SHIPPERID = this.tabList[0].list.find(item=>item.SKEY=='return_logistics_company').VALUE
                this.saveArr.OMSORDERID = this.tabList[0].list.find(item=>item.SKEY=='OMSORDERID').VALUE
                this.saveArr.ERECEIPT_CAUSE = this.tabList[0].list.find(item=>item.SKEY=='ERECEIPT_CAUSE').VALUE || ''
                this.saveArr.DESCRIPTION = this.tabList[0].list.find(item=>item.SKEY=='DESCRIPTION').VALUE
                this.saveArr.IESSTOREID = this.tabList[0].list.find(item=>item.SKEY=='return_warehouse').VALUE
                this.saveArr.BRANDID = this.tabList[0].list.find(item=>item.SKEY=='brandname').VALUE
                this.saveArr.signUserName = this.tabList[0].list.find(item=>item.SKEY=='signUserName').VALUE
                this.saveArr.ISDEAL = this.tabList[0].list.find(item=>item.SKEY=='ISDEAL').VALUE

                let returnDeleteData = [...this.oldReturnData].filter(x => [...this.returnData].every(y => y.ID !== x.ID));
                let returnAddData = [...this.returnData].filter(x => [...this.oldReturnData].every(y => y.ID !== x.ID));

                returnAddData.forEach(i=>i.ROWSTATUS='CREATE')
                returnDeleteData.forEach(i=>i.ROWSTATUS='DELETE')
                let CHANGEITEMS=[...returnAddData,...returnDeleteData]
                let params = {
                    objId: this.pageMsgId,
                    SHIPPERID: this.saveArr.SHIPPERID,
                    OMSORDERID: this.saveArr.OMSORDERID,
                    ERECEIPT_CAUSEID: this.saveArr.ERECEIPT_CAUSE,
                    DESCRIPTION: this.saveArr.DESCRIPTION,
                    IESSTOREID: this.saveArr.IESSTOREID,
                    BRANDID: this.saveArr.BRANDID,
                    signUserName: this.saveArr.signUserName,
                    ISDEAL: this.saveArr.ISDEAL?1:0,
                    CHANGEITEMS
                }
                network.post('/p/cs/signpackage/save',params).then(res => {
                    if(res.data.code == 0){
                      this.getInitialData()
                        this.$Message.success('修改成功');
                    }
                })

            },
        getdiffrent(arr, arr1) { // 获取两个数组不同项
          let c = [...arr, ...arr1];
          let d = new Set(c);
          let e = Array.from(d);
          let f = [...e.filter(_ => !arr.includes(_)), ...e.filter(_ => !arr1.includes(_))];
          return f;
        },
        uniq(arr, arr1) { // 数组去重
          const temp = [];
          const index = [];
          const array = [...arr, ...arr1];
          const l = array.length;
          for (let i = 0; i < l; i++) {
            for (let j = i + 1; j < l; j++) {
              if (array[i].ID === array[j].ID) {
                i++;
                j = i;
              }
            }
            temp.push(array[i]);
            index.push(i);
          }
          return temp;
        },
        // 获取退货表格所有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={}
          }
        },
        // 添加退货商品到表格
        addReturnGoods(val){
            if(JSON.stringify(this.selectReturnSKUData)=='{}'){
              this.$Message.warning('添加条码不能为空');
              return
            }
            let obj=this.selectReturnSKUData
            if (this.returnGoodsNum) {
              if(obj){
                let addData= {
                    NAME:obj.SKUNAME,
                    SKU:obj.SKU,
                    ID:obj.ID,
                  }
                  if(this.returnData.length){
                    let sameData=this.returnData.find(i=>i.SKU==obj.SKU)
                    if(!sameData){
                      addData.NUM=this.returnGoodsNum
                      this.returnData=[...this.returnData,addData]
                    }else{
                      this.returnData.forEach(item=>{
                        if(obj.SKU==item.SKU){
                            item.NUM+=this.returnGoodsNum
                        }
                      })
                    }
                  }else{
                    addData.NUM=this.returnGoodsNum
                    this.returnData=[...this.returnData,addData]
                  }
                  this.returnGoodsNum=1
                  
                  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) //当前页面显示明细
                  this.currentReturnData.forEach((item,index) => {
                    if(this.currentReturnData.SKU == this.choosedSKU){
                      this.defaultIndex = index;
                    }
                  })
                  this.$refs.returnSelect.clearSingleSelect()
  
                  this.selectReturnSKUData = {};
                  this.selectReturnSKUID = '';
  
              }
            }else{
              this.$Message.warning('请输入数量');
            }
  
        },
        addEnterReturnGoods(val){  // select框enter触发事件
            let virtual={sku: val.target.value,type: '1'}
            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
                if(this.SKUAllDataReturn.length == 1){
                  this.selectReturnSKUData=this.SKUAllDataReturn[0] //添加的数据
                  this.selectReturnSKUID=this.selectReturnSKUData.ID //双向数据绑定
                  this.addReturnGoods();
                }else {
                  this.$Message.warning('添加条码不能为空');
                  return
                }
              }else{
                this.SKUArrReturn=[]
                this.SKUAllDataReturn=[]
              }
            })
  
        },
        //初始查询标准下拉框数据
        getQuery(tableName,fixed){
          let virtual={
            fixedcolumns:fixed?fixed:{},
            range: 1000,
            startindex: 0,
            table: tableName
          }
            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 if(tableName=='T_IESWAREHOUSE'){
  
                    item.optionList= res.data.rows.map(i=>{
                      return {
                        label:i.WAREHOUSENAME.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]
        },
  
        // 选择商品页码改变时触发
        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.nowGoodsType=name
          this.searchGoodsData()
          this.selectGoodsModal=true
        },
        // 关闭选择商品弹窗
        cancelSelectGoods(){
          this.selectGoodsData={
            NORMS1NAME:'',//颜色
            NORMS2NAME:'',//尺寸
            SKU:'',//SKU
            GBCODE:'',//国标码
            // SELLPRICE:'',//销售价
            // BASEPRICE:'',//成本价
            PRODUCTCODE:'',//商品编码
            PRODUCTNAME:''//商品名称
          }
          this.submitArrGoods=[]
          this.selectGoodsModal=false
        },
        okSelectGoods(){
          if(!this.submitArrGoods.length){
            this.$Message.warning('请选择商品');
            return
          }
          if(this.nowGoodsType=='exchange'){
              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.SKUArr=res.data.Rows.map(i=>{
                    return {
                      label:i.SKU,
                      value:i.ID
                    }
                  })
                  this.SKUAllData=res.data.Rows
                }else{
                  this.SKUArr=[]
                  this.SKUAllData=[]
                }
                this.selectSKUData=this.SKUAllData.find(item=>{
                  return item.ID==this.submitArrGoods[0].ID
                }) //添加的数据
                this.selectSKUID=this.selectSKUData.ID //双向数据绑定
                this.cancelSelectGoods()
              })
  
          }else if(this.nowGoodsType=='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()
            })
  
          }
        },
        // 重置选择商品搜索条件
        resetGoodsData(){
          this.selectGoodsData={
            NORMS1NAME:'',//颜色
            NORMS2NAME:'',//尺寸
            SKU:'',//SKU
            GBCODE:'',//国标码
            // SELLPRICE:'',//销售价
            // BASEPRICE:'',//成本价
            PRODUCTCODE:'',//商品编码
            PRODUCTNAME:''//商品名称
          }
          this.submitArrGoods=[]
          this.searchGoodsData()
        },
        // 查询符合搜索条件的商品
        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)
              if(this.nowGoodsType=='exchange'){
                 if(this.exchangeData.length){
                    let sameArr = [...this.GoodsData].filter((x) => [...this.exchangeData].some((y) => y.SKU == x.SKU));
                    this.exchangeDataNoSame = [...this.exchangeData].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]
                    }
  
                  }else{
                    this.GoodsData.forEach(item=>{
                      item.NUM=1
                      item.REFUND_FEE='' 
                      item.REFUNDNUM=1
                      item.ADJUSTAMOUNT=(item.BASEPRICE - item.SELLPRICE) * item.NUM
                    })
                  }
              }else if(this.nowGoodsType=='return'){
                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]
                  }
                }else{
                  this.GoodsData.forEach(item=>{
                    item.NUM=1
                    item.REFUND_FEE='' 
                    item.REFUNDNUM=1
                    item.ADJUSTAMOUNT=(item.BASEPRICE - item.SELLPRICE) * item.NUM
                    // item.PRODUCTMARK=1 //商品标记
                  })
                }
              }
            });
        },
        // 删除
        deleteReturnGoods(){
          let idArray=this.submitArrReturn.map(item=>item.ID)
          this.returnData = this.returnData.filter(i =>{
           return !idArray.includes(i.ID)
          });
          this.refundableAmount=0
          
          this.totalReturn=this.returnData.length //总条数
          // 截取数组
          let startIndex=this.pageSizeReturn*(this.returnCurrentPage-1)
          let endIndex=startIndex+this.pageSizeReturn
          this.currentReturnData=this.returnData.slice(startIndex,endIndex) //当前页面显示明细
          // 删除时，恰好包含了高亮选中的sku行
          let flag = false;
          for(let i=0;i < this.submitArrReturn.length;i++){
            if(this.submitArrReturn[i].SKU == this.choosedSKU){
              flag = true;
              break;
            }
          }
          if(this.currentReturnData[0] && flag){
            this.defaultIndex = 0;
            this.choosedSKU = this.currentReturnData[0].SKU;
            this.getBatchOrQRcodeList();
          }else {
            this.currentReturnData.forEach((item,index) => {
              if(item.SKU == this.choosedSKU){
                this.defaultIndex = index;
              }
            })
          }
        },
  
        // 退货页码改变时触发
        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;
          // 截取数组
          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;
        },
        parser(value) {
          if((typeof value=='string')){
            if(value==''){
              value='0'
            }
            return parseFloat(value.replace(/[^\d\.-]/g, ''));
          }else{
            return value
          }
  
        },
        // 平台单号，退款单号，退回物流单号禁止输入空格
        noSpaces(e,i){
          if( i.SKEY=='OMSORDERID'){
            if(e.keyCode == 32) e.returnValue = false
          }
        },
        // 表格单选一项
        selectOneData(val){
          this.selectTableData=val
        },
        upOrDown(height) {
          this.currentValue = !this.currentValue;
          document.getElementsByClassName('conditionContent')[0].style.maxHeight = this.currentValue ? height : '';
          this.tableHeight = this.currentValue ? '250' : '200';
        },

        // 下拉分页模糊搜索框
        // 外键下拉框
        searchShopData(i){
            let virtual={}
            if(i.SKEY==='brandname'){
                virtual={
                    searchdata:{
                        "isdroplistsearch":true,
                        "refcolid":196493,
                        "startindex":i.currentIndex,
                        "range":10,
                    }
                }
            }else if(i.SKEY==='return_logistics_company'){
                virtual={
                    searchdata:{
                        "isdroplistsearch":true,
                        "refcolid":194917,
                        "fixedcolumns":{},
                        "startindex":i.currentIndex,
                        "range":10,
                        "isdetail":true
                    }
                }
            } else if(i.SKEY==='return_warehouse') {
                virtual={
                    searchdata:{
                        "isdroplistsearch":true,
                        "refcolid":200118,
                        "startindex":i.currentIndex,
                        "range":10,
                        "isdetail":true
                    }
                }
            }
            network.post('/p/cs/QueryList',urlSearchParams(virtual)).then((res) => {
                 if(res.data.code==0){
                    this.tabList[0].list.forEach(item => {
                        if(item.SKEY===i.SKEY){
                            item.shopData=res.data.data
                            item.currentIndex=0
                        }
                    });
                 }
             })
        },
        // 单选下拉选中
        checkDataShop(val,i){
          this.tabList[0].list.forEach(item => {
            if(item.SKEY===i.SKEY){
                item.VALUE=val[0].ID
                item.NAME=val[0].Label
            }
          });
        },
        // 单选框失去焦点事件
        changeDataShop(e,i){
            if(!e.target.value){
              this.tabList[0].list.forEach(item => {
                  if(item.SKEY===i.SKEY){
                      item.VALUE=''
                      item.NAME=''
                  }
              });
            }else{
                this.tabList[0].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:''
                    }
                }); 
            }
        },
        // 清空选中项
        clearDataShop(i){
            // this.tabList[0].list.forEach(item => {
            //     if(item.SKEY==i.SKEY){
            //         item.VALUE=''
            //         item.NAME=''
            //     }
            // });
            // this.tabList = JSON.parse(JSON.stringify(this.tabList))
        },
        // 单选下拉分页改变
        changePageShop(e,i){
            this.tabList[0].list.forEach(item => {
                if(item.SKEY===i.SKEY){
                    item.currentIndex=(e-1)*10
                    this.searchShopData(item)
                }
            });
        },
        focusInputValueChangeShop(e,i){
            let virtual={}
            if(i.SKEY==='brandname'){
                virtual={
                    ak: e.target.value,
                    colid: 196493,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='return_logistics_company'){
                virtual={
                    ak: e.target.value,
                    colid: 194917,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='return_warehouse'){
                virtual={
                    ak: e.target.value,
                    colid: 200118,
                    fixedcolumns: {}
                }
            }
            network.post('/p/cs/fuzzyquerybyak',urlSearchParams(virtual)).then((res) => {
                if(res.data.code==0){
                    this.tabList[0].list.forEach(item => {
                        if(item.SKEY===i.SKEY){
                            item.AutoData=res.data.data
                        }
                    });
                }
            })
        },
        // 单选下拉模糊搜索数据
        InputValueChangeShop(e,i){
             let virtual={}
            if(i.SKEY==='brandname'){
                virtual={
                    ak: e,
                    colid: 196493,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='return_logistics_company'){
                virtual={
                    ak: e,
                    colid: 194917,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='return_warehouse'){
                virtual={
                    ak: e,
                    colid: 200118,
                    fixedcolumns: {}
                }
            }
            network.post('/p/cs/fuzzyquerybyak',urlSearchParams(virtual)).then((res) => {
                if(res.data.code==0){
                    this.tabList[0].list.forEach(item => {
                        if(item.SKEY===i.SKEY){
                          item.AutoData=res.data.data
                        }
                    });
                }
            })
        },
  
      }
    };
  </script>
  <style lang="less">
  .edit-signpackage .foldPanelContent .ark-collapse > .ark-collapse-item > .ark-collapse-content {
    padding-top: 0px;
  }
  .edit-signpackage .ark-collapse-content > .ark-collapse-content-box {
    padding-bottom: 0px;
  }
  .edit-signpackage .content .ark-col {
    margin-bottom: 8px !important;
  }
  .edit-signpackage .content .ark-col-span-6 {
    margin-bottom: 18px !important;
  }
  .edit-signpackage .content .ark-col-span-8 {
    margin-bottom: 18px !important;
  }
//   .edit-signpackage .content .ark-checkbox-wrapper {
//     width: 100%;
//   }
  </style>
  <style lang="less" scoped>
  .edit-signpackage {
    padding: 0 16px;
  }
  .quickOperation{
    height: 64px;
    border-bottom: 1px solid #D8D8D8;
    display: flex;
    align-items: center;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    margin-bottom: -12px;
  }
  .content{
    .block{
      padding-top: 12px;
    }
    .ark-col{
      display: flex;
      align-items: center;
      // justify-content: flex-end;
      margin-bottom: 16px;
      .input_box{
        // max-width: 220px;   // 240px
        min-width: 180px;
      }
      .title{
        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;
        }
      }
      // .returnLongText {
      //   width: 170px;
      // }
      // .nickTitle {
      //   margin-left: 36px;
      // }
    }
  
  }
  .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;
      }
  }
  
  </style>
  <style lang="less" scoped>
   .pageContent {
      margin-top: 12px;
      display: flex;
      justify-content: flex-end;
    }
    .order-setting-input-error:before{
      content: '*';
      color: red;
    }
    .conditionContent {
      width: 100%;
      display: flex;
      max-height: 3000px;
      overflow: hidden;
      flex-wrap: wrap;
      padding-top: 8px;
      // padding-right: 51px;
      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;
          }
      }
    }
    .saveBtn{
      display: none;
    }
    .content /deep/ .ark-select-input[disabled]{
        color: #575757;
    }
  
    .returnGoodsTableBox {
      display: flex;
      align-items: center;
      height: 380px;
      .returnGoodsTableOne:first-child {
        width: calc(60% - 34px);
        margin-right: 16px;
        transition: width 0.3s;
      }
      .fold-btn {
        flex: 0 0 16px;
        height: 44px;
        box-shadow: 0 2px 8px 0 rgba(0,0,0,.06);
        background: #EFF0F0;
        // margin-right: 16px;
        border: 1px solid #E7E9E8;
        // border-radius: 0 8px 8px 0;
        border-radius: 8px 0px 0px 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
      }
      .returnGoodsTableOne:last-child {
        width: 40%;
        transition: width 0.3s;
        overflow: hidden;
      }
    }
  
    .text1 /deep/ .ark-input {
      height: 80px;
      resize: none;
      background-color: #f5f5f5;
    }
  </style>
  