<template>
  <div>
    <div class="quickOperation">
      快捷操作：
      <Button
        type="fcdefault"
        style="margin-right:8px"
        @click="saveAll"
      >
        保存
      </Button>
      <Button type="fcdefault"
      @click="closePage"
      >
        关闭
      </Button>
    </div>
    <div class="content">
      <div
        v-for="(item,tabId) in basicMsg"
        :key="tabId"
        class="block"
      >
        <foldPanel
          v-model="item.blockShow"
          :title="item.parentdesc"
        >
          <div
            slot="content"
          >
            <div class="item">
              <Row>
                <div
                    v-for="(i,cindex) in basicMsg[tabId].list"
                    :key="cindex"
                    class="form"
                >
                    <Col span="8" >
                        <div v-if="i.title" :class="['title',i.required?'order-must-input':null]">{{ i.title }}</div>
                        <Select v-model="i.VALUE" :filterable="i.SKEY!=='GROUPGOODSTYPE'" class="input_box" v-if="(i.SKEY=='GROUPGOODSTYPE')" @on-open-change="dropDown($event,i)" @on-change="changeInput($event,i)" :clearable="i.clearable"  @on-query-change="checkInput($event,i)">
                            <Option v-for="d in i.optionList" :value="d.value" :key="d.value">{{ d.label }}</Option>
                        </Select>
                        <DropDownSelectFilter
                            :single="true"
                            v-if="(i.SKEY=='GOODSTYPEID')||(i.SKEY=='BRANDID')"
                            class="input_box"
                            :data="i.shopData"
                            :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>
                        <Input
                            v-else-if="
                            (i.SKEY=='PRODUCTCODE')
                            ||(i.SKEY=='TITLE')
                            "
                            class="input_box"
                            v-model="i.VALUE"
                            placeholder="请输入内容"
                        />
                    </Col>
                </div>
              </Row>
            </div>
          </div>
        </foldpanel>
      </div>
      <div class="tableContent">
          <div class="leftTable father">
              <div class="title">组合sku明细</div>
              <div class="tableArea" v-if="GROUPGOODSTYPE==1">
                  <div class="top-part" style="padding:16px;margin-bottom:16px;background: #F7F8FA;display: flex;flex-direction: column;align-items: flex-end;">
                       <Form style="display: flex;justify-content: space-between;width:100%;flex-wrap: wrap"  ref="SKUDetail_general" :model="SKUDetail_general">
                            <FormItem label="组合sku" class="must-input" style="40%">
                                <Input style="min-width:170px" type="text" v-model="SKUDetail_general.SKU" placeholder="请输入" @on-keydown="addSKUDetail_general">
                                </Input>
                            </FormItem>
                            <FormItem label="组合sku名称" style="40%">
                                <Input style="min-width:170px" type="text" v-model="SKUDetail_general.SKUNAME" placeholder="请输入" @on-keydown="addSKUDetail_general">
                                </Input>
                            </FormItem>
                        </Form>
                        <Button type="primary" @click="addSKUDetail_generalBtn">添加</Button>
                  </div>
                     <Button type="fcdefault"  label="small" style="margin-bottom:16px" @click="deleteSKUDetail_general">删除明细</Button>
                      <Table
                        height='270px'
                        :columns="SKUDetailColumns_general"
                        :row-class-name="rowClassName"
                        :data="currentSKUData"
                        :highlight-row="SKUDetailightRow"
                        size="small"
                        @on-current-change="selectSKUDetail"
                    />
                    <div style="display: flex;justify-content: center;margin-top:8px">
                        <Page
                            style=""
                            size="small"
                            :current="currentPageSKUDetail"
                            show-elevator
                            :total="totalSKUDetail"
                            show-total
                            show-sizer
                            @on-change="changePageSKUDetail($event,'general')"
                            @on-page-size-change="changeSizeSKUDetail($event,'general')"
                        />
                    </div>
              </div>
              <div class="tableArea" v-else>
                    <div class="top-part" style="padding:16px;margin-bottom:16px;background: #F7F8FA;display: flex;flex-direction: column;align-items: flex-end;">
                            <Form style="display: flex;justify-content: space-between;width:100%;flex-wrap: wrap" ref="SKUDetail_bag" :model="SKUDetail_bag">
                                <FormItem label="组合sku" class="must-input" style="40%">
                                    <Input style="min-width:170px" type="text" v-model="SKUDetail_bag.SKU" placeholder="请输入" @on-keydown="addSKUDetail_bag">
                                    </Input>
                                </FormItem>
                                <FormItem label="组合sku名称" style="40%">
                                    <Input style="min-width:170px" type="text" v-model="SKUDetail_bag.SKUNAME" placeholder="请输入" @on-keydown="addSKUDetail_bag">
                                    </Input>
                                </FormItem>
                                <FormItem label="每组抽取行数" class="must-input" style="40%">
                                    <Input style="min-width:156px" type="text" v-model="SKUDetail_bag.GROUPEXTRACTNUM"  placeholder="请输入"  @on-keydown="addSKUDetail_bag">
                                    </Input>
                                </FormItem>
                            </Form>
                            <Button type="primary" @click="addSKUDetail_bagBtn">添加</Button>
                    </div>
                    <Button type="fcdefault"  label="small" style="margin-bottom:16px" @click="deleteSKUDetail_bag">删除明细</Button>
                    <Table
                    height='270px'
                    :columns="SKUDetailColumns_bag"
                    :row-class-name="rowClassName"
                    :data="currentSKUData"
                    :highlight-row="SKUDetailightRow"
                    size="small"
                    @on-current-change="selectSKUDetail"
                />
                <div style="display: flex;justify-content: center;margin-top:8px">
                    <Page
                        style=""
                        size="small"
                        :current="currentPageSKUDetail"
                        show-elevator
                        :total="totalSKUDetail"
                        show-total
                        show-sizer
                        @on-change="changePageSKUDetail($event,'bag')"
                        @on-page-size-change="changeSizeSKUDetail($event,'bag')"
                    />
                </div>
              </div>
          </div>

          <div class="rightTable father">
              <div class="title">sku明细</div>
              <div class="tableArea" v-if="GROUPGOODSTYPE==1">
                  <div class="top-part" style="padding:16px;margin-bottom:16px;background: #F7F8FA;display: flex;flex-direction: column;align-items: flex-end;">
                        <Form style="display: flex;justify-content: space-between;width:100%"  ref="comboDetail_general" :model="comboDetail_general">
                            <FormItem label="sku" class="must-input"  style="50%">
                                <Select v-model="comboDetail_general.SKU" filterable clearable style="min-width:180px" placeholder=""  @on-query-change="checkInputSKU" @on-enter="addComboDetail_generalBtn">
                                    <Option v-for="d in SKUList" :value="d.label" :key="d.value" :label="d.label">{{ d.label }} {{d.NORMS1NAME || '  '}} {{d.NORMS1CODE || '  '}} {{d.NORMS2NAME || '  '}} {{d.NORMS2CODE || '  '}}</Option>
                                </Select>
                            </FormItem>
                            <FormItem label="数量"  style="50%">
                                <Input style="min-width:180px" type="text" v-model="comboDetail_general.NUM" placeholder="" @on-keydown="addComboDetail_general">
                                </Input>
                            </FormItem>
                        </Form>
                      <Button type="primary" @click="addComboDetail_generalBtn">添加</Button>
                  </div>
                <Button type="fcdefault"  label="small" style="margin-bottom:16px" @click="deleteComboDetail_general">删除</Button>
                <Table
                    height='270px'
                    :columns="comboDetailColumns_general"
                    :data="currentComboDataType"
                    size="small"
                    @on-selection-change="selectComboDetail"
                />
                <div style="display: flex;justify-content: center;margin-top:8px">
                    <Page
                        size="small"
                        :current="currentPageComboDetail"
                        show-elevator
                        :total="totalComboDetail"
                        :page-size="pageSizeComboDetail"
                        show-total
                        show-sizer
                        @on-change="changePageComboDetail"
                        @on-page-size-change="changeSizeComboDetail"
                    />
                </div>
              </div>
              <div class="tableArea" v-else>
                  <div class="top-part" style="padding:16px;margin-bottom:16px;background: #F7F8FA;display: flex;flex-direction: column;align-items: flex-end;">
                        <Form style="display: flex;justify-content: space-between;width:100%;flex-wrap: wrap" ref="comboDetail_bag" :model="comboDetail_bag">
                            <FormItem label="sku"  class="must-input" style="width:50%">
                                <Select v-model="comboDetail_bag.SKU" style="min-width:180px" filterable clearable class="input_box" placeholder=""  @on-query-change="checkInputSKU" @on-enter="addComboDetail_bagBtn">
                                    <Option v-for="d in SKUList" :value="d.label" :key="d.value" :label="d.label">{{ d.label }} {{d.NORMS1NAME || '  '}} {{d.NORMS1CODE || '  '}} {{d.NORMS2NAME || '  '}} {{d.NORMS2CODE || '  '}}</Option>
                                </Select>
                            </FormItem>
                            <FormItem label="数量" class="must-input" style="width:50%">
                                <Input style="min-width:180px" type="text" v-model="comboDetail_bag.NUM" placeholder=""  @on-keydown="addComboDetail_bag">
                                </Input>
                            </FormItem>
                            <FormItem label="分组"  class="must-input" style="width:50%">
                                <Input style="min-width:180px" type="text" v-model="comboDetail_bag.GROUPNUM" placeholder=""  @on-keydown="addComboDetail_bag">
                                </Input>
                            </FormItem>
                        </Form>
                      <Button type="primary" @click="addComboDetail_bagBtn">添加</Button>
                  </div>
                <Button type="fcdefault"  label="small" style="margin-bottom:16px" @click="deleteComboDetail_bag">删除</Button>
                <Table
                    height='270px'
                    :columns="comboDetailColumns_bag"
                    :data="currentComboDataType"
                    size="small"
                    @on-selection-change="selectComboDetail"
                />
                <div style="display: flex;justify-content: center;margin-top:8px">
                    <Page
                        style=""
                        size="small"
                        :current="currentPageComboDetail"
                        show-elevator
                        :total="totalComboDetail"
                        :page-size="pageSizeComboDetail"
                        show-total
                        show-sizer
                        @on-change="changePageComboDetail"
                        @on-page-size-change="changeSizeComboDetail"
                    />
                </div>
              </div>
          </div>
      </div>
    </div>

  </div>
</template>
<script>
  import foldPanel from '../customizedContent/FoldPanel.vue'; // 折叠面板组件
//   import R3 from '../../../static/r3/r3.publish/r3.min';
  const R3 = window.R3;
  const { network, urlSearchParams, store } = R3;
  export default {
    data() {
      return {
        //普通类型
        SKUDetail_general:{
            SKU:'',//组合sku
            SKUNAME:'',//组合sku名称
        },
        SKUDetailightRow:true,
        SKUDetailColumns_general:[
            {
                type: 'index',
                title: '序号',
                align: 'center'
            },
            {
                title: '组合sku',
                key: 'SKU',
                align: 'center',
                render: (h, params) => {
                    return h(
                    'Input',
                    {
                        style: {
                            width:'180px'
                        },
                        props: {
                            value: params.row.SKU,
                        },
                        on: {
                            'on-blur': (event) => {
                                // 截取数组
                                let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                                let endIndex=startIndex+this.pageSizeSKUDetail

                                let allIndex=startIndex+params.index

                                let chengeData=this.currentSKUData[params.index]
                                let isSame=false
                                this.SKUDetailData_general.forEach((item,index)=>{
                                    if(item.SKU.trim()==event.target.value.trim() && index!=allIndex){
                                        this.$Message.warning('当前虚拟条码已存在');
                                        isSame=true
                                    }else{
                                        if((item.SKU==chengeData.SKU)){
                                            item.SKU =event.target.value
                                            this.submitArrSKU.SKU=event.target.value
                                            item.isError=false// 有重复报错

                                        }
                                    }

                                })
                                if(isSame){
                                    this.SKUDetailData_general[allIndex].SKU=''
                                    this.SKUDetailData_general[allIndex].isError=true
                                    this.SKUDetailData_general[allIndex]._highlight=false
                                    this.submitArrSKU={}
                                }
                                this.totalSKUDetail=this.SKUDetailData_general.length// 总条数
                                this.currentSKUData=this.SKUDetailData_general.slice(startIndex,endIndex)
                                // 改变对应的组合商品明细
                                this.comboDetailData_general=[...this.comboDetailData_general].filter(x => [...this.SKUDetailData_general].some(y => y.SKU === x.GROUPSKU));
                                let startIndex1=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                let endIndex1=startIndex1+this.pageSizeComboDetail
                                this.currentComboData=this.comboDetailData_general.filter(item=>{
                                    return this.submitArrSKU.SKU==item.GROUPSKU
                                })
                                this.totalComboDetail=this.currentComboData.length// 总条数
                                this.currentComboDataType=this.currentComboData.slice(startIndex1,endIndex1)
                            }
                        }
                    },
                    );
                },
            },
            {
                title: '组合sku名称',
                key: 'SKUNAME',
                align: 'center',
                render: (h, params) => {
                    return h(
                    'Input',
                    {
                        style: {
                            width:'180px'
                        },
                        props: {
                            value: params.row.SKUNAME,
                        },
                        on: {
                            'on-blur': (event) => {
                                let chengeData=this.currentSKUData[params.index]
                                this.SKUDetailData_general.forEach(item=>{
                                    if((item.SKU==chengeData.SKU)){
                                        item.SKUNAME =event.target.value
                                        this.submitArrSKU.SKUNAME=event.target.value
                                    }
                                })
                                // 截取数组
                                let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                                let endIndex=startIndex+this.pageSizeSKUDetail
                                this.totalSKUDetail=this.SKUDetailData_general.length// 总条数
                                this.currentSKUData=this.SKUDetailData_general.slice(startIndex,endIndex)
                            }
                        }
                    },
                    );
                },
            },
        ],
        SKUDetailData_general:[],

        currentSKUData:[],//当前页数显示的条码明细数据
        submitArrSKU:{},//选中的商品明细

        // 商品SKUpage
        currentPageSKUDetail:1, //初始页码
        totalSKUDetail: 0, // 总条数
        pageSizeSKUDetail: 10, // 每页的条数

        GROUPGOODSTYPE:1,//组合商品类型

        comboDetail_general:{ //sku明细
            SKU:'',
            NUM:''
        },
        SKUList:[],//组合商品明细条码下拉框数据
        middleComboData:[],//中间值(回车时把该数据加入表格)
        // 组合商品page
        currentPageComboDetail:1, //初始页码
        totalComboDetail: 0, // 总条数
        pageSizeComboDetail: 10, // 每页的条数

        submitArrCombo:[],//选中的组合商品明细
        comboDetailData_general:[],//组合商品表格明细--普通
        // currentCombo_general:[],//
        currentComboData:[],//当前对应SKU的条码明细数据
        currentComboDataType:[],//当前页数显示对应SKU的条码明细数据
        comboDetailColumns_general:[
            {
                type: 'selection',
                width: 60,
                align: 'center'
            },
            {
                type: 'index',
                title: '序号',
                align: 'center'
            },
            {
                title: '商品名称',
                key: 'TITLE',
                align: 'center'
            },
            {
                title: '明细SKU',
                key: 'SKU',
                align: 'center'
            },
            {
                title: '组合数量',
                key: 'NUM',
                align: 'center',
                render: (h, params) => {
                    return h(
                        'Input',
                        {
                            style: {
                                width:'66px'
                            },
                            props: {
                                value: params.row.NUM,
                                // number: true
                            },
                            on: {
                            'on-blur': (event) => {
                                let chengeData=this.currentComboDataType[params.index]
                                if(isNaN(event.target.value)){
                                    event.target.value=''
                                }
                                this.comboDetailData_general.forEach(item=>{
                                    if((item.GROUPSKU==chengeData.GROUPSKU)&&(item.SKU==chengeData.SKU)){
                                        item.NUM =+event.target.value
                                        var reg = /^[+]{0,1}(\d+)$/g;
                                        if(!reg.test(item.NUM)){
                                            this.$Message.warning('请输入正确的组合数量');
                                            item.NUM=''
                                        }
                                    }
                                })
                                let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                let endIndex=startIndex+this.pageSizeComboDetail
                                this.currentComboData=this.comboDetailData_general.filter(item=>{
                                    return this.submitArrSKU.SKU==item.GROUPSKU
                                })
                                this.totalComboDetail=this.currentComboData.length// 总条数
                                this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                            }
                        }
                        },
                    );
                },
            },
            {
                title: '取商品原价',
                key: 'ISORIPRICESHARE ',
                align: 'center',
                render: (h, params) => {
                    return h(
                        'Checkbox',
                        {
                            props: {
                                value: params.row.ISORIPRICESHARE,
                                trueValue: 1,
                                falseValue:0
                            },
                            on: {
                            'on-change': (event) => {
                                let chengeData=this.currentComboDataType[params.index]
                                this.comboDetailData_general.forEach(item=>{
                                    if((item.GROUPSKU==chengeData.GROUPSKU)&&(item.SKU==chengeData.SKU)){
                                        item.ISORIPRICESHARE = event
                                        if(event == 1){
                                            item.PRICEPERCENT = ''
                                        }
                                    }
                                })
                                let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                let endIndex=startIndex+this.pageSizeComboDetail
                                this.currentComboData=this.comboDetailData_general.filter(item=>{
                                    return this.submitArrSKU.SKU==item.GROUPSKU
                                })
                                this.totalComboDetail=this.currentComboData.length// 总条数
                                this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                                console.log(this.currentComboData)
                            }
                        }
                        },
                    );
                },
            },
            {
                title: '分摊比例',
                key: 'PRICEPERCENT',
                align: 'center',
                render: (h, params) => {
                    return h(
                        'Input',
                        {
                            style: {
                                width:'66px'
                            },
                            props: {
                                value: params.row.PRICEPERCENT,
                                // number: true
                                disabled: params.row.ISORIPRICESHARE==1?true:false
                            },
                            on: {
                            'on-blur': (event) => {
                                let chengeData=this.currentComboDataType[params.index]
                                if(isNaN(event.target.value)){
                                    event.target.value=''
                                }
                                this.comboDetailData_general.forEach(item=>{
                                    if((item.GROUPSKU==chengeData.GROUPSKU)&&(item.SKU==chengeData.SKU)){
                                        if(event.target.value>1){
                                            item.PRICEPERCENT=1
                                        }else if(event.target.value<0){
                                            item.PRICEPERCENT=0
                                        }else{
                                           item.PRICEPERCENT =event.target.value?parseFloat(event.target.value).toFixed(2):''
                                        }
                                    }
                                })
                                let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                let endIndex=startIndex+this.pageSizeComboDetail
                                this.currentComboData=this.comboDetailData_general.filter(item=>{
                                    return this.submitArrSKU.SKU==item.GROUPSKU
                                })
                                this.totalComboDetail=this.currentComboData.length// 总条数
                                this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                            }
                        }
                        },
                    );
                },
            },
        ],
        basicMsg:[{
            parentdesc:'基础信息',
            blockShow: true,
            list: [
                {
                    SKEY:'TITLE', //字段
                    title:'商品名称', //字段名称
                    VALUE: '', //字段值
                    tableName:'',//表名
                    required:true,//是否必填
                },
                {
                    SKEY:'PRODUCTCODE', //字段
                    title:'商品编码', //字段名称
                    VALUE: '', //字段值
                    tableName:'',//表名
                    required:true,//是否必填
                },
                {
                    SKEY:'BRANDID', //字段
                    title:'品牌', //字段名称
                    VALUE: '', //字段值
                    clearable:true,
                    tableName:'T_IESBRAND',//表名
                    required:true,//是否必填
                    currentIndex:0,//当前页码
                    dataEmptyMessage: '数据加载中...', // 无数据的提示
                    columns:['name','value'],// 展现的组
                    AutoData:[],//模糊搜索
                    defaultSelected:[],//默认数据
                    shopData:{},
                },
                {
                    SKEY:'GOODSTYPEID', //字段
                    title:'商品类型', //字段名称
                    VALUE: '', //字段值
                    tableName:'T_IESGOODSTYPE',//表名
                    clearable:true,
                    required:false,//是否必填
                    currentIndex:0,//当前页码
                    dataEmptyMessage: '数据加载中...', // 无数据的提示
                    columns:['name','value'],// 展现的组
                    AutoData:[],//模糊搜索
                    defaultSelected:[],//默认数据
                    shopData:{},
                },
                {
                    SKEY:'GROUPGOODSTYPE', //字段
                    title:'组合商品类型', //字段名称
                    VALUE: 1, //字段值
                    tableName:'',//表名
                    clearable:false,
                    required:false,//是否必填
                    optionList:[
                        {value:1,label:'普通'},
                        {value:2,label:'福袋'},
                    ]
                }
            ]
        }],
        //福袋类型
        SKUDetail_bag:{
            SKU:'',//组合sku
            SKUNAME:'',//组合sku名称
            GROUPEXTRACTNUM:''//每组抽取行数
        },

        SKUDetailColumns_bag:[
            {
                type: 'index',
                title: '序号',
                align: 'center'
            },
            {
                title: '组合sku',
                key: 'SKU',
                align: 'center',
                render: (h, params) => {
                    return h(
                    'Input',
                    {
                        style: {
                            width:'180px'
                        },
                        props: {
                            value: params.row.SKU,
                        },
                        on: {
                            'on-blur': (event) => {
                                // 截取数组
                                let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                                let endIndex=startIndex+this.pageSizeSKUDetail

                                let allIndex=startIndex+params.index

                                let chengeData=this.currentSKUData[params.index]
                                let isSame=false
                                this.SKUDetailData_bag.forEach((item,index)=>{
                                    if(item.SKU.trim()==event.target.value.trim() && index!=allIndex){
                                        this.$Message.warning('当前虚拟条码已存在');
                                        isSame=true
                                    }else{
                                        if((item.SKU==chengeData.SKU)){
                                            item.SKU =event.target.value
                                            this.submitArrSKU.SKU=event.target.value
                                            item.isError=false// 有重复报错

                                        }
                                    }

                                })
                                if(isSame){
                                    this.SKUDetailData_bag[allIndex].SKU=''
                                    this.SKUDetailData_bag[allIndex].isError=true
                                    this.SKUDetailData_general[allIndex]._highlight=false
                                    this.submitArrSKU={}
                                }
                                this.totalSKUDetail=this.SKUDetailData_bag.length// 总条数
                                this.currentSKUData=this.SKUDetailData_bag.slice(startIndex,endIndex)

                                // 改变对应的组合商品明细
                                this.comboDetailData_bag=[...this.comboDetailData_bag].filter(x => [...this.SKUDetailData_bag].some(y => y.SKU === x.GROUPSKU));
                                let startIndex1=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                let endIndex1=startIndex1+this.pageSizeComboDetail
                                this.currentComboData=this.comboDetailData_bag.filter(item=>{
                                    return this.submitArrSKU.SKU==item.GROUPSKU
                                })
                                this.totalComboDetail=this.currentComboData.length// 总条数
                                this.currentComboDataType=this.currentComboData.slice(startIndex1,endIndex1)
                            }
                        }
                    },
                    );
                },
            },
            {
                title: '组合sku名称',
                key: 'SKUNAME',
                align: 'center',
                render: (h, params) => {
                    return h(
                    'Input',
                    {
                        style: {
                            width:'180px'
                        },
                        props: {
                            value: params.row.SKUNAME,
                        },
                        on: {
                            'on-blur': (event) => {
                                let chengeData=this.currentSKUData[params.index]
                                this.SKUDetailData_bag.forEach(item=>{
                                    if((item.SKU==chengeData.SKU)){
                                        item.SKUNAME =event.target.value
                                        this.submitArrSKU.SKUNAME=event.target.value
                                    }
                                })
                                // 截取数组
                                let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                                let endIndex=startIndex+this.pageSizeSKUDetail
                                this.totalSKUDetail=this.SKUDetailData_bag.length// 总条数
                                this.currentSKUData=this.SKUDetailData_bag.slice(startIndex,endIndex)
                            }
                        }
                    },
                    );
                },
            },

            {
                title: '每组抽取行数',
                key: 'GROUPEXTRACTNUM',
                align: 'center',
                render: (h, params) => {
                    return h(
                    'Input',
                    {
                        style: {
                            width:'66px'
                        },
                        props: {
                            value: params.row.GROUPEXTRACTNUM,
                            // number: true
                        },
                        on: {
                            'on-blur': (event) => {
                                let chengeData=this.currentSKUData[params.index]
                                if(isNaN(event.target.value)){
                                    event.target.value=''
                                }
                                 this.SKUDetailData_bag.forEach(item=>{
                                        if((item.SKU==chengeData.SKU)){
                                            item.GROUPEXTRACTNUM =+event.target.value
                                            var reg = /^[+]{0,1}(\d+)$/g;
                                            if(!reg.test(item.GROUPEXTRACTNUM)){
                                                this.$Message.warning('请输入正确的抽取数量');
                                                item.GROUPEXTRACTNUM=''
                                            }
                                            this.submitArrSKU=item
                                        }
                                    })
                                // 截取数组
                                let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                                let endIndex=startIndex+this.pageSizeSKUDetail
                                this.totalSKUDetail=this.SKUDetailData_bag.length// 总条数
                                this.currentSKUData=this.SKUDetailData_bag.slice(startIndex,endIndex)
                            }
                        }
                    },
                    );
                },
            },
        ],
        SKUDetailData_bag:[],

        comboDetail_bag:{  //sku明细
            SKU:'',
            NUM:'',
            GROUPNUM:''
        },
        comboDetailData_bag:[],//组合商品表格明细--福袋
        comboDetailColumns_bag:[
            {
                type: 'selection',
                width: 60,
                align: 'center'
            },
            {
                type: 'index',
                title: '序号',
                align: 'center'
            },
            {
                title: '商品名称',
                key: 'TITLE',
                align: 'center'
            },
            {
                title: '明细SKU',
                key: 'SKU',
                align: 'center'
            },
            {
                title: '组合数量',
                key: 'NUM',
                align: 'center',
                render: (h, params) => {
                    return h(
                        'Input',
                        {
                            style: {
                                width:'66px'
                            },
                            props: {
                                value: params.row.NUM,
                                // number: true
                            },
                            on: {
                                'on-blur': (event) => {
                                    let chengeData=this.currentComboDataType[params.index]
                                    if(isNaN(event.target.value)){
                                        event.target.value=''
                                    }
                                    this.comboDetailData_bag.forEach(item=>{
                                        if((item.GROUPSKU==chengeData.GROUPSKU)&&(item.SKU==chengeData.SKU)&&(item.GROUPNUM==item.GROUPNUM)){
                                            item.NUM =+event.target.value
                                            var reg = /^[+]{0,1}(\d+)$/g;
                                            if(!reg.test(item.NUM)){
                                                this.$Message.warning('请输入正确的组合数量');
                                                item.NUM=''
                                            }
                                            // if(item.NUM<=0){
                                            //     this.$Message.warning('请输入正确的组合数量');
                                            //     item.NUM=''
                                            // }
                                        }
                                    })
                                    let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                    let endIndex=startIndex+this.pageSizeComboDetail
                                    this.currentComboData=this.comboDetailData_bag.filter(item=>{
                                        return this.submitArrSKU.SKU==item.GROUPSKU
                                    })
                                    this.totalComboDetail=this.currentComboData.length// 总条数
                                    this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                                }
                            }
                        },
                    );
                },
            },
            {
                title: '分组',
                key: 'GROUPNUM',
                align: 'center',
                render: (h, params) => {
                    return h(
                        'Input',
                        {
                            style: {
                                width:'66px'
                            },
                            props: {
                                value: params.row.GROUPNUM,
                                number: true
                            },
                            on: {
                            'on-blur': (event) => {
                                let chengeData=this.currentComboDataType[params.index]
                                this.comboDetailData_bag.forEach(item=>{
                                    if((item.GROUPSKU==chengeData.GROUPSKU)&&(item.SKU==chengeData.SKU)&&(item.GROUPNUM==chengeData.GROUPNUM)){
                                        item.GROUPNUM =+event.target.value
                                        var reg = /^[+]{0,1}(\d+)$/g;
                                        if(!reg.test(item.GROUPNUM)){
                                            this.$Message.warning('请输入正确的分组');
                                            item.GROUPNUM=''
                                        }
                                    }
                                })
                                let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                let endIndex=startIndex+this.pageSizeComboDetail
                                this.currentComboData=this.comboDetailData_bag.filter(item=>{
                                    return this.submitArrSKU.SKU==item.GROUPSKU
                                })
                                this.totalComboDetail=this.currentComboData.length// 总条数
                                this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                            }
                        }
                        },
                    );
                },
            },
            {
                title: '分组价格比例',
                key: 'GROUPPRICEPERCENT',
                align: 'center',
                render: (h, params) => {
                    return h(
                        'Input',
                        {
                            style: {
                                width:'66px'
                            },
                            props: {
                                value: params.row.GROUPPRICEPERCENT,
                                // number: true
                            },
                            on: {
                            'on-blur': (event) => {
                                let chengeData=this.currentComboDataType[params.index]
                                if(isNaN(event.target.value)){
                                    event.target.value=''
                                }
                                this.comboDetailData_bag.forEach(item=>{
                                    if((item.GROUPSKU==chengeData.GROUPSKU)&&(item.SKU==chengeData.SKU)&&(item.GROUPNUM==chengeData.GROUPNUM)){
                                        if(event.target.value>1){
                                            item.GROUPPRICEPERCENT=1
                                        }else if(event.target.value<0){
                                            item.GROUPPRICEPERCENT=0
                                        }else{
                                           item.GROUPPRICEPERCENT =event.target.value?parseFloat(event.target.value).toFixed(2):0
                                        }
                                    }
                                })
                                let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                                let endIndex=startIndex+this.pageSizeComboDetail
                                this.currentComboData=this.comboDetailData_bag.filter(item=>{
                                    return this.submitArrSKU.SKU==item.GROUPSKU
                                })
                                this.totalComboDetail=this.currentComboData.length// 总条数
                                this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                            }
                        }
                        },
                    );
                },
            },
        ],
      }
    },
    components: {
      foldPanel
    },
    created(){
    },
    methods:{
        // 按钮新增条码明细--普通
        addSKUDetail_generalBtn(){
            this.SKUDetail_general.SKU = this.SKUDetail_general.SKU;
            if(!this.SKUDetail_general.SKU.trim()){
                this.$Message.warning('虚拟条码为必填项，不能为空');
            }else{
                if(this.SKUDetailData_general.length){
                    this.SKUDetailData_general.forEach(item=>{
                        item.isError=false
                        item._highlight=false //清除之前的选择项
                    })
                    let canAdd= this.SKUDetailData_general.some(item=>{
                        return item.SKU.trim()==this.SKUDetail_general.SKU.trim()
                    })
                    if(canAdd){
                        this.$Message.warning('当前虚拟条码已存在');
                    }else{
                        // 回车时限制条数
                        if(this.SKUDetailData_general.length==100){
                            this.$Message.warning('条码明细不能大于100条');
                            return
                        }
                        this.submitArrSKU=this.SKUDetail_general
                        this.SKUDetail_general._highlight=true //默认选中项
                        this.SKUDetailData_general.push(this.SKUDetail_general)
                        this.SKUDetail_general={
                            SKU:'',
                            SKUNAME:'',
                            isError:false
                        }
                    }
                }else{
                    this.submitArrSKU=this.SKUDetail_general
                    this.SKUDetail_general._highlight=true //默认选中项
                    this.SKUDetailData_general=[this.SKUDetail_general]
                    this.SKUDetail_general={
                        SKU:'',
                        SKUNAME:'',
                        isError:false
                    }

                }
                this.totalSKUDetail=this.SKUDetailData_general.length// 总条数
                if(this.totalSKUDetail){ //翻页
                    this.currentPageSKUDetail=parseInt((this.totalSKUDetail-1)/this.pageSizeSKUDetail)+1
                }
                // 截取数组
                let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                let endIndex=startIndex+this.pageSizeSKUDetail
                this.currentSKUData=this.SKUDetailData_general.slice(startIndex,endIndex)

                this.currentComboData=this.comboDetailData_general.filter(item=>{//初始化关联的组合商品明细
                    return this.submitArrSKU.SKU==item.GROUPSKU
                })
                this.currentPageComboDetail=1
                this.pageSizeComboDetail=10
                this.totalComboDetail=this.currentComboData.length// 总条数
                let startIndexCombo=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                let endIndexCombo=startIndexCombo+this.pageSizeComboDetail-1
                this.currentComboDataType=this.currentComboData.slice(startIndexCombo,endIndexCombo)
            }
        },
        // 回车新增条码明细--普通
        addSKUDetail_general(e){
            if(e.keyCode==13){
                this.addSKUDetail_generalBtn()
            }
        },
        // 删除条码明细--普通
        deleteSKUDetail_general(){
            if(JSON.stringify(this.submitArrSKU)=='{}'){
                this.$Message.warning('请选择删除明细');
                return
            }
            this.$Modal.fcWarning({
                title: '警告',
                mask: true,
                showCancel: true,
                content: '是否确认删除',
                onOk:()=>{
                    this.SKUDetailData_general = this.SKUDetailData_general.filter(i =>{
                        return this.submitArrSKU.SKU !==i.SKU
                    });

                    this.totalSKUDetail=this.SKUDetailData_general.length// 总条数
                    // 截取数组
                    let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                    let endIndex=startIndex+this.pageSizeSKUDetail
                    this.currentSKUData=this.SKUDetailData_general.slice(startIndex,endIndex)

                    // 处理关联的组合商品明细表
                    this.comboDetailData_general = [...this.comboDetailData_general].filter(x => this.submitArrSKU.SKU!==x.GROUPSKU)
                    let startIndexCombo=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                    let endIndexCombo=startIndexCombo+this.pageSizeComboDetail-1
                    this.currentComboData=this.comboDetailData_general.filter(item=>{
                        return this.submitArrSKU.SKU==item.GROUPSKU
                    })
                    this.totalComboDetail=this.currentComboData.length// 总条数
                    this.currentComboDataType=this.currentComboData.slice(startIndexCombo,endIndexCombo)
                    this.submitArrSKU={}
                    this.submitArrCombo=[]

                }
            });

        },
        // 按钮新增条码明细--福袋
        addSKUDetail_bagBtn(){
            if(!this.SKUDetail_bag.SKU){
                this.$Message.warning('虚拟条码为必填项，不能为空');
            }else{
                if(!this.SKUDetail_bag.GROUPEXTRACTNUM){
                    this.$Message.warning('每组抽取行数，不能为空');
                    return
                }
                if(this.checkNum(this.SKUDetail_bag.GROUPEXTRACTNUM)){
                    this.SKUDetail_bag.GROUPEXTRACTNUM=+this.SKUDetail_bag.GROUPEXTRACTNUM
                    this.SKUDetail_bag.isError=false
                    this.SKUDetail_bag._highlight=true
                    if(this.SKUDetailData_bag.length){
                        this.SKUDetailData_bag.forEach(item=>{
                            item._highlight=false //清除之前的选择项
                        })
                        let canAdd= this.SKUDetailData_bag.some(item=>{
                            return item.SKU.trim()==this.SKUDetail_bag.SKU.trim()
                        })
                        if(canAdd){
                            this.$Message.warning('当前虚拟条码已存在');
                        }else{
                            if(this.SKUDetailData_bag.length==100){
                                this.$Message.warning('条码明细不能大于100条');
                                return
                            }
                            this.submitArrSKU=this.SKUDetail_bag
                            this.SKUDetailData_bag.push(this.SKUDetail_bag)
                            this.SKUDetail_bag={
                                SKU:'',
                                SKUNAME:'',
                                GROUPEXTRACTNUM:'',
                                isError:false,
                            }
                        }
                    }else{
                        this.submitArrSKU=this.SKUDetail_bag
                        this.SKUDetailData_bag=[this.SKUDetail_bag]
                        this.SKUDetail_bag={
                            SKU:'',
                            SKUNAME:'',
                            GROUPEXTRACTNUM:'',
                            isError:false,
                        }
                    }
                }else{
                    this.SKUDetail_bag.GROUPEXTRACTNUM=''
                }

            }
            this.totalSKUDetail=this.SKUDetailData_bag.length // 总条数
            if(this.totalSKUDetail){ //翻页
                this.currentPageSKUDetail=parseInt((this.totalSKUDetail-1)/this.pageSizeSKUDetail)+1
            }
            // 截取数组
            let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
            let endIndex=startIndex+this.pageSizeSKUDetail
            this.currentSKUData=this.SKUDetailData_bag.slice(startIndex,endIndex)
            //初始化关联的组合商品明细
            this.currentComboData=this.comboDetailData_bag.filter(item=>{
                return this.submitArrSKU.SKU==item.GROUPSKU
            })
            this.currentPageComboDetail=1
            this.pageSizeComboDetail=10
            this.totalComboDetail=this.currentComboData.length// 总条数
            let startIndexCombo=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
            let endIndexCombo=startIndexCombo+this.pageSizeComboDetail-1
            this.currentComboDataType=this.currentComboData.slice(startIndexCombo,endIndexCombo)
        },
        // 回车新增条码明细--福袋
        addSKUDetail_bag(e){
            if(e.keyCode==13){
                this.addSKUDetail_bagBtn()
            }
        },
        // 删除条码明细--福袋
        deleteSKUDetail_bag(){
            if(JSON.stringify(this.submitArrSKU)=='{}'){
                this.$Message.warning('请选择删除明细');
                return
            }
            this.$Modal.fcWarning({
                title: '警告',
                mask: true,
                showCancel: true,
                content: '是否确认删除',
                onOk:()=>{
                    // 删除条码明细
                    this.SKUDetailData_bag = this.SKUDetailData_bag.filter(i =>{
                        return this.submitArrSKU.SKU !==i.SKU
                    });
                    this.totalSKUDetail=this.SKUDetailData_bag.length // 总条数
                    // 截取数组
                    let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                    let endIndex=startIndex+this.pageSizeSKUDetail
                    this.currentSKUData=this.SKUDetailData_bag.slice(startIndex,endIndex)

                    // 删除对应组合商品明细数据
                    this.comboDetailData_bag=this.comboDetailData_bag.filter(item=>{
                        return this.submitArrSKU.SKU!==item.GROUPSKU
                    })
                    let startIndex1=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                    let endIndex1=startIndex1+this.pageSizeComboDetail
                    this.currentComboData=this.comboDetailData_bag.filter(item=>{
                        return this.submitArrSKU.SKU==item.GROUPSKU
                    })
                    this.totalComboDetail=this.currentComboData.length// 总条数
                    this.currentComboDataType=this.currentComboData.slice(startIndex1,endIndex1)
                    this.submitArrCombo=[]
                    this.submitArrSKU={}
                }
            });
        },
      // 条码明细表格选中某项时触发
      selectSKUDetail(selection, row) {
        this.submitArrSKU = selection;
        if(this.GROUPGOODSTYPE==1){
            // 同步选中项高光
            this.SKUDetailData_general.forEach(item=>{
                if(this.submitArrSKU.SKU==item.SKU){
                    item._highlight=true
                }else{
                    item._highlight=false //清除之前的选择项
                }
            })
            this.currentComboData=this.comboDetailData_general.filter(item=>{
                return this.submitArrSKU.SKU==item.GROUPSKU
            })
        }else if(this.GROUPGOODSTYPE==2){
            // 同步选中项高光
            this.SKUDetailData_bag.forEach(item=>{
                if(this.submitArrSKU.SKU==item.SKU){
                    item._highlight=true
                }else{
                    item._highlight=false //清除之前的选择项
                }
            })
            this.currentComboData=this.comboDetailData_bag.filter(item=>{
                return this.submitArrSKU.SKU==item.GROUPSKU
            })
        }
        this.currentPageComboDetail=1
        this.pageSizeComboDetail=10
        this.totalComboDetail=this.currentComboData.length// 总条数
        let startIndexCombo=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
        let endIndexCombo=startIndexCombo+this.pageSizeComboDetail-1
        this.currentComboDataType=this.currentComboData.slice(startIndexCombo,endIndexCombo)

      },
      // 条码明细页码改变时触发
      changePageSKUDetail(val,tab){
         // 1=>0 2=>10 3=>20
          this.currentPageSKUDetail=val
        // 截取数组
        let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
        let endIndex=startIndex+this.pageSizeSKUDetail
        if(tab=='general'){
            this.currentSKUData=this.SKUDetailData_general.slice(startIndex,endIndex)
        }else if(tab=='bag'){
            this.currentSKUData=this.SKUDetailData_bag.slice(startIndex,endIndex)
        }

        // this.currentReturnPage = (val - 1) * 10;
      },
      //条码明细页数改变时触发
      changeSizeSKUDetail(val,tab){
         this.pageSizeSKUDetail=val
         this.currentPageSKUDetail=1
        // 截取数组
        let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
        let endIndex=startIndex+this.pageSizeSKUDetail
         if(tab=='general'){
            this.currentSKUData=this.SKUDetailData_general.slice(startIndex,endIndex)
        }else if(tab=='bag'){
            this.currentSKUData=this.SKUDetailData_bag.slice(startIndex,endIndex)
        }
      },
      //sku明细--普通 按钮
      addComboDetail_generalBtn(){
        if(!this.comboDetail_general.NUM){
            this.$Message.warning('请输入数量');
            return
        }
        if(this.checkNum(this.comboDetail_general.NUM)){ //判断是否为数字
            if(JSON.stringify(this.submitArrSKU) == "{}"){
                this.$Message.warning('请选中需要添加商品明细的虚拟SKU进行保存。');
            }else{
                // 有选中条码明细
                if(!this.comboDetail_general.SKU){
                    this.$Message.warning('商品条码为必填项，不能为空');
                }else{
                    this.middleComboData.forEach(item=>{
                        item.GROUPSKU=this.submitArrSKU.SKU //两张表的关联字段
                        item.IESSKUID=0
                        item.NUM=+this.comboDetail_general.NUM
                        item.ISORIPRICESHARE = 0;
                    }) //添加数量
                    let middledata=this.middleComboData.find(i=>i.SKU===this.comboDetail_general.SKU)
                    if(this.comboDetailData_general.length){
                        // 先找是否为同一组
                        let sameData=this.comboDetailData_general.find(i=>(i.SKU==this.comboDetail_general.SKU)&&(i.GROUPSKU==this.submitArrSKU.SKU))
                        if(sameData){
                            // 当前sku已存在 加数量
                            this.comboDetailData_general.forEach(item=>{
                                if(sameData.SKU==item.SKU&&(sameData.GROUPSKU==item.GROUPSKU)){
                                    item.NUM=(+item.NUM)+(+this.comboDetail_general.NUM)
                                }
                            })
                        }else{
                            if(this.comboDetailData_general.length==10000){
                                this.$Message.warning('系统最多维护10000个组合商品明细');
                                return
                            }
                            // sku不存在直接加一条数据
                            this.comboDetailData_general.push(middledata)
                        }
                    }else{
                        this.comboDetailData_general=[middledata]
                    }

                    this.comboDetail_general={
                        SKU:'',
                        NUM:''
                    }
                    this.middleComboData=[]
                    this.SKUList=[]
                    // 截取数组
                    let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                    let endIndex=startIndex+this.pageSizeComboDetail
                    this.currentComboData=this.comboDetailData_general.filter(item=>{
                            return this.submitArrSKU.SKU==item.GROUPSKU
                        })
                    this.totalComboDetail=this.currentComboData.length// 总条数
                    this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)

                }
            }
        }else{
            this.comboDetail_general.NUM=''
        }
      },
      //sku明细--普通 回车键
      addComboDetail_general(e){
        if(e.keyCode==13){
            this.addComboDetail_generalBtn()
        }
      },
      //sku明细--福袋 按钮
      addComboDetail_bagBtn(){
        if(!this.comboDetail_bag.NUM){
            this.$Message.warning('请输入数量')
            return
        }else{
            if(!this.checkNum(this.comboDetail_bag.NUM)){
                this.comboDetail_bag.NUM=''
                return
            }
        }
        if(!this.comboDetail_bag.GROUPNUM){
            this.$Message.warning('请输入分组')
            return
        }else{
            if(!this.checkNum(this.comboDetail_bag.GROUPNUM)){
                this.comboDetail_bag.GROUPNUM=''
                return
            }
        }
        if(JSON.stringify(this.submitArrSKU) == "{}"){
            this.$Message.warning('请选中需要添加商品明细的虚拟SKU进行保存。');
        }else{
            // 有选中条码明细
            if(!this.comboDetail_bag.SKU){
                this.$Message.warning('商品条码为必填项，不能为空');
            }else{
                this.middleComboData.forEach(item=>{
                    item.GROUPSKU=this.submitArrSKU.SKU //两张表的关联字段
                    item.IESSKUID=0
                    // item.SKU=this.comboDetail_bag.SKU
                    item.NUM=+this.comboDetail_bag.NUM
                    item.GROUPNUM=+this.comboDetail_bag.GROUPNUM
                    // item.GROUPPRICEPERCENT=''
                }) //添加数量
                let middledata=this.middleComboData.find(i=>i.SKU===this.comboDetail_bag.SKU)
                if(this.comboDetailData_bag.length){
                    // 先找是否为同一组
                    let sameData=this.comboDetailData_bag.find(i=>(i.SKU==this.comboDetail_bag.SKU)&&(i.GROUPSKU==this.submitArrSKU.SKU)&&(i.GROUPNUM==this.comboDetail_bag.GROUPNUM))
                    if(sameData){
                        // 当前sku已存在 加数量
                        this.comboDetailData_bag.forEach(item=>{
                            if(sameData.SKU==item.SKU&&(sameData.GROUPSKU==item.GROUPSKU)&&(sameData.GROUPNUM==item.GROUPNUM)){
                                item.NUM=(+item.NUM)+(+this.comboDetail_bag.NUM)
                            }
                        })
                    }else{
                        if(this.comboDetailData_bag.length==10000){
                            this.$Message.warning('系统最多维护10000个组合商品明细');
                            return
                        }
                        // sku不存在直接加一条数据
                        this.comboDetailData_bag.push(middledata)
                    }
                }else{
                    this.comboDetailData_bag=[middledata]
                }
                this.comboDetail_bag={
                    SKU:'',
                    NUM:'',
                    GROUPNUM:''
                }
                this.middleComboData=[]
                this.SKUList=[]
                // 截取数组
                let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                let endIndex=startIndex+this.pageSizeComboDetail
                this.currentComboData=this.comboDetailData_bag.filter(item=>{
                    return this.submitArrSKU.SKU==item.GROUPSKU
                })

                this.totalComboDetail=this.currentComboData.length// 总条数
                this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
            }
        }
      },
      //sku明细--福袋 回车键
      addComboDetail_bag(e){
        if(e.keyCode==13){
            this.addComboDetail_bagBtn()
        }
      },
      //组合商品明细选中项改变时触发
      selectComboDetail(selection){
          this.submitArrCombo=selection
      },
      // 删除组合商品明细--普通
      deleteComboDetail_general(){
          if(!this.submitArrCombo.length){
              this.$Message.warning('请选择删除明细');
              return
          }
          this.$Modal.fcWarning({
                title: '警告',
                mask: true,
                showCancel: true,
                content: '是否确认删除',
                onOk:()=>{
                    this.comboDetailData_general = [...this.comboDetailData_general].filter(x => [...this.submitArrCombo].every(y => (!(x.SKU==y.SKU && x.GROUPSKU==y.GROUPSKU))))
                    let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                    let endIndex=startIndex+this.pageSizeComboDetail
                    this.currentComboData=this.comboDetailData_general.filter(item=>{
                        return this.submitArrSKU.SKU==item.GROUPSKU
                    })
                    this.totalComboDetail=this.currentComboData.length// 总条数
                    this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                     this.submitArrCombo=[]
                }
            });

      },
      // 删除组合商品明细--福袋
      deleteComboDetail_bag(){
          if(!this.submitArrCombo.length){
              this.$Message.warning('请选择删除明细');
              return
          }
           this.$Modal.fcWarning({
                title: '警告',
                mask: true,
                showCancel: true,
                content: '是否确认删除',
                onOk:()=>{
                    this.comboDetailData_bag = [...this.comboDetailData_bag].filter(x => [...this.submitArrCombo].every(y => (!(x.SKU==y.SKU && x.GROUPSKU==y.GROUPSKU&& x.GROUPNUM==y.GROUPNUM))))
                    let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                    let endIndex=startIndex+this.pageSizeComboDetail
                    this.currentComboData=this.comboDetailData_bag.filter(item=>{
                        return this.submitArrSKU.SKU==item.GROUPSKU
                    })
                    this.totalComboDetail=this.currentComboData.length// 总条数
                    this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
                    this.submitArrCombo=[]
                }
            });

      },
    //组合商品明细SKU输入值改变时
    checkInputSKU(e){
        network.post('/p/cs/getIesSku',{sku:e}).then((res) => {
            if(res.data.Code==0){
                this.SKUList=res.data.Rows.map(_=>{
                    return {
                        value:_.ID,
                        label:_.SKU,
                        NORMS1CODE: _.NORMS1CODE,
                        NORMS1NAME: _.NORMS1NAME,
                        NORMS2CODE: _.NORMS2CODE,
                        NORMS2NAME: _.NORMS2NAME
                    }
                })
                this.middleComboData=res.data.Rows.map(i=>{
                    return {
                        SKU:i.SKU,
                        TITLE:i.SKUNAME,
                    }
                })
            }else{
                this.SKUList=[]
                this.middleComboData=[]
            }

        })
    },
    // 组合商品明细页码改变时触发
      changePageComboDetail(val){
         // 1=>0 2=>10 3=>20
          this.currentPageComboDetail=val
        // 截取数组
        let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
        let endIndex=startIndex+this.pageSizeComboDetail
            this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)

        // this.currentReturnPage = (val - 1) * 10;
      },
      //组合商品明细页数改变时触发
      changeSizeComboDetail(val){
         this.pageSizeComboDetail=val
         this.currentPageComboDetail=1
        // // 截取数组
        let startIndex=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
        let endIndex=startIndex+this.pageSizeComboDetail
           this.currentComboDataType=this.currentComboData.slice(startIndex,endIndex)
      },
        //下拉框展开时调用接口
        dropDown(e,i){
            if(e){
            let virtual={}
                if(i.SKEY==='BRANDID'){
                    this.getT_IESBRANDList()
                }else if(i.SKEY==='GOODSTYPEID'){
                    this.getT_IESGOODSTYPEList()
                }
            }
        },
        // 外键下拉框
        searchShopData(i){
             let virtual={}
            if(i.SKEY==='BRANDID'){
                virtual={
                    searchdata:{
                        "isdroplistsearch":true,
                        "refcolid":196493,
                        "startindex":i.currentIndex,
                        "range":10,
                    }
                }
            }else if(i.SKEY==='GOODSTYPEID'){
                virtual={
                    searchdata:{
                        "isdroplistsearch":true,
                        "refcolid":196494,
                        "startindex":i.currentIndex,
                        "range":10,
                    }
                }
            }
            network.post('/p/cs/QueryList',urlSearchParams(virtual)).then((res) => {
                 if(res.data.code==0){
                    // this.shopData=res.data.data
                    // this.currentIndex=0
                    // if(this.$route.params.customizedModuleId!=='New'){
                    //     this.getData() //获取编辑页面数据
                    // }

                    this.basicMsg[0].list.forEach(item => {
                        if(item.SKEY===i.SKEY){
                            item.shopData=res.data.data
                            item.currentIndex=0
                        }
                    });
                 }

             })
        },
        // 单选下拉选中
        checkDataShop(val,i){
            this.basicMsg[0].list.forEach(item => {
                if(item.SKEY===i.SKEY){
                    item.VALUE=val[0].ID
                    item.NAME=val[0].Label

                }
            });
        },
        // 单选框失去焦点事件
        changeDataShop(e,i){
            console.log(e.target.value,888888)
            if(!e.target.value){
                this.basicMsg[0].list.forEach(item => {
                    if(item.SKEY===i.SKEY){
                        item.VALUE=''
                        item.NAME=''

                    }
                });
            }else{
                this.basicMsg[0].list.forEach(item => {
                    if(item.SKEY===i.SKEY){
                        console.log(item.AutoData,777777)
                        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.basicMsg[0].list.forEach(item => {
                if(item.SKEY===i.SKEY){
                    item.VALUE=''
                    item.NAME=''

                }
            });
        },
        // 单选下拉分页改变
        changePageShop(e,i){
            this.basicMsg[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==='BRANDID'){
                virtual={
                    ak: e.target.value,
                    colid: 196493,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='GOODSTYPEID'){
                virtual={
                    ak: e.target.value,
                    colid: 196494,
                    fixedcolumns: {}
                }
            }
            network.post('/p/cs/fuzzyquerybyak',urlSearchParams(virtual)).then((res) => {
                if(res.data.code==0){
                     this.basicMsg[0].list.forEach(item => {
                        if(item.SKEY===i.SKEY){
                            item.AutoData=res.data.data
                        }
                    });
                }

            })
        },
        // 单选下拉模糊搜索数据
        InputValueChangeShop(e,i){
             let virtual={}
            if(i.SKEY==='BRANDID'){
                virtual={
                    ak: e,
                    colid: 196493,
                    fixedcolumns: {}
                }
            }else if(i.SKEY==='GOODSTYPEID'){
                virtual={
                    ak: e,
                    colid: 196494,
                    fixedcolumns: {}
                }
            }
            network.post('/p/cs/fuzzyquerybyak',urlSearchParams(virtual)).then((res) => {
                if(res.data.code==0){
                     this.basicMsg[0].list.forEach(item => {
                        if(item.SKEY===i.SKEY){
                            item.AutoData=res.data.data
                        }
                    });
                }

            })
        },
        //下拉框搜索词改变时触发
        checkInput(e,i){
            if(i.SKEY==='BRANDID'){
                this.getT_IESBRANDList(e)
            }else if(i.SKEY==='GOODSTYPEID'){
                this.getT_IESGOODSTYPEList(e)
            }
        },
        // 下拉框选中事件
        changeInput(e,i){
            if(i.SKEY==='GROUPGOODSTYPE'){
                if(this.GROUPGOODSTYPE!=i.VALUE){
                    this.$Modal.fcWarning({
                        title: '警告',
                        mask: true,
                        showCancel: true,
                        content: '切换组合商品类型会清空数据，确认切换组合商品类型',
                        onOk:()=>{
                        this.GROUPGOODSTYPE=i.VALUE //判断类型
                        // 条码明细表格
                        this.SKUDetailData_bag=[]
                        this.SKUDetailData_general=[]
                        this.submitArrSKU={} //清除单选数据
                        this.totalSKUDetail=this.SKUDetailData_bag.length // 总条数
                        this.currentPageSKUDetail=1 //初始页码
                        this.pageSizeSKUDetail=10// 每页的条数

                        let startIndex=this.pageSizeSKUDetail*(this.currentPageSKUDetail-1)
                        let endIndex=startIndex+this.pageSizeSKUDetail
                        this.currentSKUData=this.SKUDetailData_general.slice(startIndex,endIndex)

                        // 组合商品明细表格
                        this.comboDetailData_bag=[]
                        this.comboDetailData_general=[]
                        this.submitArrCombo=[]//清除多选数据
                        this.pageSizeSKUDetail=10// 每页的条数
                        this.currentPageComboDetail=1 //初始页码
                        this.pageSizeComboDetail=10// 每页的条数

                        let startIndex1=this.pageSizeComboDetail*(this.currentPageComboDetail-1)
                        let endIndex2=startIndex1+this.pageSizeComboDetail
                        this.currentComboData=this.comboDetailData_general.filter(item=>{
                            return this.submitArrSKU.SKU==item.GROUPSKU
                        })
                        this.totalComboDetail=this.currentComboData.length// 总条数
                        this.currentComboDataType=this.currentComboData.slice(startIndex1,endIndex2)
                        },
                        onCancel:()=>{
                            this.basicMsg[0].list.forEach(item=>{
                                if(item.SKEY===i.SKEY){
                                    item.VALUE=this.GROUPGOODSTYPE
                                }
                            })
                        }
                    });
                }


            }
        },
        // 获取品牌下拉框
        getT_IESBRANDList(e){
            let virtual={
                fixedcolumns: {BRANDNAME: e},
                fkdrplist: {searchcols: ["ID", "BRANDNAME"]},
                isdroplistsearch: true,
                range: 10000,
                table: "T_IESBRAND"
            }
            network.post('/p/cs/list/query',virtual).then((res) => {
                this.basicMsg[0].list.forEach(item => {
                    if(item.SKEY==='BRANDID'){
                        item.optionList=res.data.rows.map(_=>{
                            return {
                                value:_.ID.val,
                                label:_.BRANDNAME.val
                            }
                        })
                    }
                });
            })
        },
        //获取商品类型列表下拉框
        getT_IESGOODSTYPEList(e){
            let virtual={
                fixedcolumns: {NAME: e},
                fkdrplist: {searchcols: ["ID", "NAME"]},
                isdroplistsearch: true,
                range: 10000,
                table: "T_IESGOODSTYPE"
            }
            network.post('/p/cs/list/query',virtual).then((res) => {
                this.basicMsg[0].list.forEach(item => {
                    if(item.SKEY==='GOODSTYPEID'){
                        item.optionList=res.data.rows.map(_=>{
                            return {
                                value:_.ID.val,
                                label:_.NAME.val
                            }
                        })
                    }
                });
            })
        },
        // 保存新增组合商品
        saveAll(){
            let canSave=true
            let promptMessage =[]; // 没有设置商品提示信息
            let baseData={
                [this.basicMsg[0].list[0].SKEY]:this.basicMsg[0].list[0].VALUE,
                [this.basicMsg[0].list[1].SKEY]:this.basicMsg[0].list[1].VALUE,
                [this.basicMsg[0].list[2].SKEY]:this.basicMsg[0].list[2].VALUE,
                [this.basicMsg[0].list[3].SKEY]:this.basicMsg[0].list[3].VALUE,
                [this.basicMsg[0].list[4].SKEY]:this.basicMsg[0].list[4].VALUE,
                isGroup: "1"
            }
            if(!baseData.TITLE){
                this.$Message.warning('商品名称为必填项，不能为空');
                canSave=false
                return
            }else if(!baseData.PRODUCTCODE){
                this.$Message.warning('货号为必填项，不能为空');
                canSave=false
                return
            }else if(!baseData.BRANDID){
                this.$Message.warning('品牌为必填项，不能为空');
                canSave=false
                return
            }
            let virtual={}
            if(this.GROUPGOODSTYPE==2){ //福袋

                let isPass=true
                this.comboDetailData_bag.forEach(_=>{
                    if(_['GROUPPRICEPERCENT']!=undefined){
                        if(_.GROUPPRICEPERCENT.toString()==""||_.GROUPNUM.toString()==""){
                            isPass=false
                        }
                    }else{
                        isPass=false
                    }

                })
               if(isPass==false){
                     this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: true,
                            content: '分组和分组价格比例必填。',
                        });
                        return
                }
                if(this.SKUDetailData_bag.some(i=>i.SKU=='')){
                    this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: true,
                            content: '虚拟条码不能为空',
                        });
                        canSave=false
                        return
                }
                promptMessage =[]; // 没有设置商品提示信息
                this.SKUDetailData_bag.forEach(item=>{
                    let sameSKUData=this.comboDetailData_bag.filter(i=>{
                        return item.SKU==i.GROUPSKU;
                    })

                    if(!sameSKUData.length){
                        promptMessage.push(item.SKU)
                        // this.$Modal.fcWarning({
                        //     title: '警告',
                        //     mask: true,
                        //     showCancel: true,
                        //     content: '请先设置商品再保存。',
                        // });
                        // canSave=false
                        // return
                    }

                    if(sameSKUData.length<item.GROUPEXTRACTNUM){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: true,
                            content: '存在每组抽取行数大于每组福袋商品总行数,请重新检查！',
                        });
                        canSave=false
                        return
                    }
                    // 按照分组去重
                    var obj={}
                    let diffData = sameSKUData.reduce(function(a, b) {
                        obj[b.GROUPNUM] ? '' : obj[b.GROUPNUM] = true && a.push(b);
                        return a;
                    }, [])
                    let isSamePropor=true //分组比例
                    diffData.forEach(v=>{
                        sameSKUData.forEach(i=>{
                            if(v.GROUPNUM==i.GROUPNUM){
                                 if(i.GROUPPRICEPERCENT!=v.GROUPPRICEPERCENT){

                                    isSamePropor=false
                                    return false
                                }
                            }

                        })

                    })
                    if(!isSamePropor){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: true,
                            content: '同一虚拟条码下同一分组的分组比例必须相同。',
                        });
                        canSave=false
                        return
                    }
                    let isSum
                    if(diffData.length>1){
                        isSum = diffData.reduce((total, currentValue, currentIndex, arr)=>{
                            return total + this.parser(currentValue.GROUPPRICEPERCENT);
                        }, 0);
                    }else{
                        isSum=this.parser(diffData[0].GROUPPRICEPERCENT)
                    }
                    // if(isSum!==1){
                    //     this.$Modal.fcWarning({
                    //         title: '警告',
                    //         mask: true,
                    //         showCancel: true,
                    //         content: '同一个虚拟条码的分组价格比例和必须为1。',
                    //     });
                    //     canSave=false
                    //     return
                    // }
                })
                // if(promptMessage.length){
                //     this.$Modal.fcWarning({
                //         title: '警告',
                //         mask: true,
                //         showCancel: true,
                //         content: `${promptMessage.join()}没有设置商品，请先设置商品再保存。`,
                //     });
                //     canSave=false
                //     return
                // }
                let T_IESSkuData=this.SKUDetailData_bag.map(i=>{
                    i.SKU = i.SKU.trim();
                    return {
                        GROUPEXTRACTNUM: i.GROUPEXTRACTNUM,
                        SKU: i.SKU.trim(),
                        SKUNAME: i.SKUNAME,
                    }
                })
                T_IESSkuData.forEach(item => {
                    if(!item.SKU){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: true,
                            content: `虚拟条码不能为空`,
                        });
                        canSave=false
                        return
                    }
                })
                this.comboDetailData_bag.forEach(item => {
                    item.GROUPSKU = item.GROUPSKU.trim()
                })
                // virtual={
                //     table:"V_IES_PRODUCT",
                //     objId:-1,
                //     fixedData:{
                //         T_IESSku:T_IESSkuData,
                //         T_IESSkuGroupDetail:this.comboDetailData_bag,
                //         V_IES_PRODUCT:baseData
                //     }
                // }
                virtual = {
                    T_IESSku:T_IESSkuData,
                    T_IESSkuGroupDetail:this.comboDetailData_bag,
                    V_IES_PRODUCT:baseData
                }

            }else{
                if(this.SKUDetailData_general.some(i=>i.SKU=='')){
                    this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: true,
                            content: '虚拟条码不能为空',
                        });
                        canSave=false
                        return
                }
                 // 条码明细数量限制
                if(this.SKUDetailData_general.length>100){
                    this.$Modal.fcWarning({
                        title: '警告',
                        mask: true,
                        content: '条码明细不能大于100条',
                    });
                    canSave=false
                    return
                }
                if(this.comboDetailData_general.length>10000){
                    this.$Modal.fcWarning({
                        title: '警告',
                        mask: true,
                        content: '系统最多维护10000个组合商品明细',
                    });
                    canSave=false
                    return
                }
                promptMessage =[]; // 没有设置商品提示信息
                this.SKUDetailData_general.forEach(item=>{
                    let sameSKUData=this.comboDetailData_general.filter(i=>{
                        return item.SKU==i.GROUPSKU;
                    })
                    // 数量限制
                    if(sameSKUData.length>10000){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            content: '系统最多维护10000个条码明细',
                        });
                        canSave=false
                        return
                    }
                    if(!sameSKUData.length){
                        promptMessage.push(item.SKU)
                        // this.$Modal.fcWarning({
                        //     title: '警告',
                        //     mask: true,
                        //     showCancel: true,
                        //     content: '请先设置商品再保存。',
                        // });
                        // canSave=false
                        // return
                    }
                    if(sameSKUData.length == 1 && sameSKUData[0].ISORIPRICESHARE == 1){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            content: '组合明细有且仅有一条记录，不允许勾选取商品原价',
                        });
                        canSave=false
                        return
                    }
                    let isSum
                    let isEmptyAll=true
                    if(sameSKUData.length>1){
                        let count = 0
                        let countOne = 0
                        let newSameSKUData = []
                        sameSKUData.forEach(item => {
                            if(!item.PRICEPERCENT && item.ISORIPRICESHARE != 1) {
                                count ++
                            }
                            if(item.ISORIPRICESHARE == 1){
                                item.PRICEPERCENT = '';
                                countOne ++
                            }
                            if(item.ISORIPRICESHARE != 1){
                                newSameSKUData.push(item)
                            }
                        })
                        if(count > 0 && count < (sameSKUData.length - countOne)){
                            isEmptyAll = false;
                        }
                        isSum = newSameSKUData.reduce((total, currentValue, currentIndex, arr)=>{
                            return total + this.parser(currentValue.PRICEPERCENT);
                        }, 0);
                    }else if(sameSKUData.length==1){
                        isSum=this.parser(sameSKUData[0].PRICEPERCENT)
                    }
                    if(!isEmptyAll){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: false,
                            content: '请设置当前【SKU明细】分摊比例',
                        });
                        canSave=false
                        return
                    }
                    if(!isEmptyAll && isSum!==1){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: false,
                            content: '同一个组合SKU下SKU明细的价格比例和必须为1',
                        });
                        canSave=false
                        return
                    }
                })

                // if(promptMessage.length){
                //     this.$Modal.fcWarning({
                //         title: '警告',
                //         mask: true,
                //         showCancel: true,
                //         content: `${promptMessage.join()}没有设置商品，请先设置商品再保存。`,
                //     });
                //     canSave=false
                //     return
                // }
                let T_IESSkuData1=this.SKUDetailData_general.map(i=>{
                    i.SKU = i.SKU.trim();
                    return {
                        SKU: i.SKU.trim(),
                        SKUNAME: i.SKUNAME,
                    }
                })
                T_IESSkuData1.forEach(item => {
                    if(!item.SKU){
                        this.$Modal.fcWarning({
                            title: '警告',
                            mask: true,
                            showCancel: true,
                            content: `虚拟条码不能为空`,
                        });
                        canSave=false
                        return
                    }
                })

                this.comboDetailData_general.forEach(item => {
                    item.GROUPSKU = item.GROUPSKU.trim()
                })
                // virtual={
                //     table:"V_IES_PRODUCT",
                //     objId:-1,
                //     fixedData:{
                //         T_IESSku:T_IESSkuData1,
                //         T_IESSkuGroupDetail:this.comboDetailData_general,
                //         V_IES_PRODUCT:baseData
                //     }
                // }
                virtual = {
                    T_IESSku:T_IESSkuData1,
                    T_IESSkuGroupDetail:this.comboDetailData_general,
                    V_IES_PRODUCT:baseData
                }
            }
            if(canSave){ // /p/cs/objectSave
                network.post('/p/cs/combinedCommodity',virtual).then((res) => {
                    if(res.data.code==0){
                        this.$Message.success(res.data.message);
                        this.toModify(res.data.data.objId)
                    }else{
                        // this.$Message.warning(res.data.message);
                    }
                })
            }
        },

        // 跳转到修改页面
        toModify(objId) {
            let data = {
                'fixedcolumns': {
                    'ID': objId
                },
                'isdroplistsearch': false,
                'range': 10000,
                'startindex': 0,
                'table': 'V_IES_PRODUCT'
            }
            network.post('/p/cs/list/query',data).then((result) => {
                    sessionStorage['addProductData'] = JSON.stringify(result.data.rows[0]);
                    this.reset()//手动初始化
                    window.parent.R3.store.commit("global/tabCloseAppoint", {
                    tableName: 'V_IES_PRODUCT',
                    routeFullPath: window.parent.R3.store.state.global.activeTab.routeFullPath,
                    keepAliveModuleName: window.parent.R3.store.state.global.activeTab.tableName,
                    // stopRouterPush: true,
                    });
                    // 跳转
                    window.parent.R3.store.commit('global/tabOpen', {
                        type: 'tableDetailAction' || 'C',
                        label: '组合商品修改',
                        customizedModuleName: 'EDITCOMBOPRODUCT',
                        customizedModuleId: objId,
                    })
            })
        },

        // 取消新增组合商品返回上一页
        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:'V_IES_PRODUCT',
                    tableId:'10897',
                    back:true
                });
            },0)
        },
        // 手动初始化
        reset(){
            this.SKUDetail_general={
                SKU:'',//组合sku
                SKUNAME:'',//组合sku名称
            }
            this.SKUDetailData_general=[]
            this.originSKUDetail_general=[]//初始数据 不变
            this.currentSKUData=[]//当前页数显示的条码明细数据
            this.submitArrSKU={}//选中的商品明细

            // 商品SKUpage
            this.currentPageSKUDetail=1//初始页码
            this.totalSKUDetail= 0 // 总条数
            this.pageSizeSKUDetail=10 // 每页的条数

            this.GROUPGOODSTYPE=1//组合商品类型
            this.comboDetail_general={ //sku明细
                SKU:'',
                NUM:''
            }
            this.SKUList=[]//组合商品明细条码下拉框数据
            this.middleComboData=[]//中间值(回车时把该数据加入表格)
            // 组合商品page
            this.currentPageComboDetail=1 //初始页码
            this.totalComboDetail=0 // 总条数
            this.pageSizeComboDetail=10 // 每页的条数

            this.submitArrCombo=[]//选中的组合商品明细
            this.comboDetailData_general=[]//组合商品表格明细--普通
            this.origincomboDetail_general=[]//原始组合商品表格明细--普通
            this.currentComboData=[]//当前对应SKU的条码明细数据
            this.currentComboDataType=[]//当前页数显示对应SKU的条码明细数据
            this.basicMsg=[{
                parentdesc:'基础信息',
                blockShow: true,
                list: [
                    {
                        SKEY:'TITLE', //字段
                        title:'商品名称', //字段名称
                        VALUE: '', //字段值
                        tableName:'',//表名
                        required:true,//是否必填
                    },
                    {
                        SKEY:'PRODUCTCODE', //字段
                        title:'商品编码', //字段名称
                        VALUE: '', //字段值
                        tableName:'',//表名
                        required:true,//是否必填
                    },
                    {
                        SKEY:'BRANDID', //字段
                        title:'品牌', //字段名称
                        VALUE: '', //字段值
                        tableName:'T_IESBRAND',//表名
                        required:true,//是否必填
                        currentIndex:0,//当前页码
                        dataEmptyMessage: '数据加载中...', // 无数据的提示
                        columns:['name','value'],// 展现的组
                        AutoData:[],//模糊搜索
                        defaultSelected:[],//默认数据
                        shopData:{},
                        optionList:[]
                    },
                    {
                        SKEY:'GOODSTYPEID', //字段
                        title:'商品类型', //字段名称
                        VALUE: '', //字段值
                        tableName:'T_IESGOODSTYPE',//表名
                        required:false,//是否必填
                        currentIndex:0,//当前页码
                        dataEmptyMessage: '数据加载中...', // 无数据的提示
                        columns:['name','value'],// 展现的组
                        AutoData:[],//模糊搜索
                        defaultSelected:[],//默认数据
                        shopData:{},
                        optionList:[]
                    },
                    {
                        SKEY:'GROUPGOODSTYPE', //字段
                        title:'组合商品类型', //字段名称
                        VALUE: '1', //字段值
                        tableName:'',//表名
                        required:false,//是否必填
                        optionList:[
                            {value:'1',label:'普通'},
                            {value:'2',label:'福袋'},
                        ]
                    }
                ]
            }]
            //福袋类型
            this.SKUDetail_bag={
                SKU:'',//组合sku
                SKUNAME:'',//组合sku名称
                GROUPEXTRACTNUM:''//每组抽取行数
            }

            this.SKUDetailData_bag=[]
            this.originSKUDetail_bag=[]
            this.comboDetail_bag={  //sku明细
                SKU:'',
                NUM:'',
                GROUPNUM:''
            }
            this.comboDetailData_bag=[]//组合商品表格明细--福袋
            this.origincomboDetail_bag=[]//原始组合商品表格明细--福袋
        },
        // 判断是否数字的方法
        checkNum(str){
            let  flag = new RegExp("^[1-9]([0-9])*$").test(str);
            if(!flag){
                this.$Message.warning('请合理输入数字')
                return false
            }else{
                return true
            }
        },
        // 金额字符串转换为数字
        parser(value) {
            if((typeof value=='string')){
            return parseFloat(value.replace(/[^\d\.-]/g, ''));
            }else{
            return value
            }
        },
        rowClassName(row, index){
            if(row.isError){
                 return 'table-error';
            }
             return '';
        }
    }

  };
</script>
<style lang="less">
.table-error{
    color: red;
    border: 1px solid red;
}
.must-input:before{
    content: '*';
    color: red;
    position: relative;
    top:10px
}
</style>
<style lang="less" scoped>

.content /deep/ .ark-select-input[disabled]{
    color: #575757;
}
  .order-must-input:before{
    content: '*';
    color: red;
    position: relative;
  }
    .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;
            margin-bottom: 16px;
            .input_box{
            max-width: 240px;
            min-width: 180px;
            }
            .title{
                width: 72px;
                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;
            }
        }
        .tableContent{
            display: flex;
            width: 100%;
            padding-bottom: 24px;
            .father{
                width: 50%;
                .title{
                    height: 34px;
                    line-height: 34px;
                    color: var(--primary-color);
                    border-bottom: 2px solid var(--primary-color);
                    width: 92px;
                    text-align: center;
                }
                .tableArea{
                    width: 100%;
                    // height: 443px;
                    border: 1px solid #DADADA;
                    padding:24px;
                    .ark-form-item{
                        display: flex !important;
                        margin-bottom: 16px !important;
                    }
                }
            }
            .leftTable{
                margin-right: 12px;
            }
            .rightTable{
                margin-left: 12px;
            }
        }
    }
</style>
