<!--
 * @Descripttion:
 * @version:
 * @Author: kBank
 * @Date: 2022-11-04 09:04:48
-->
<!--
 * @Descripttion:
 * @version:
 * @Author: kBank
 * @Date: 2022-11-02 17:07:29
-->
<template>
  <div class="ggmx">
    <div class="tit">{{ '规格明细' }}</div>
    <div v-for="(item, index) in goodList" :key="index" class="goodsAll">
      <div class="goods_t">
        <div class="goods_tit">
          <div class="goods_tit_1">{{ item.productName }}</div>
          <div class="goods_tit_2">
            {{ '产品编码' }}:{{ item.productCode }}
          </div>
          <div class="goods_tit_3">({{ item.isGift ? "销售" : "赠品" }})</div>
        </div>
        <div class="goods_btm">
          <el-form label-width="auto">
            <el-form-item
              v-for="(child, cindex) in item.specsTypeData"
              :key="cindex"
              :label="child.typeName"
            >
              <el-checkbox-group
                v-model="item.checked"
                :disabled="methods == 0"
              >
                <el-checkbox
                  v-for="(sld, sindex) in child.specsList"
                  :key="sld.specsId"
                  :disabled="sld.disabled"
                  :label="sld.specsId"
                  @change="
                    getCheckBox(
                      $event,
                      item.productId,
                      child.pkId,
                      sld,
                      item.isGift
                    )
                  "
                >{{ sld.value }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div v-show="item.allSel" class="goods_b">
        <div class="pl">
          <el-row type="flex" justify="end" :gutter="20">
            <el-col :span="2">
              <div style="line-height: 40px">{{ '批量处理' }}</div>
            </el-col>
            <el-col :span="2">
              <el-input
                v-model="item.price"
                clearable
                :disabled="methods == 0"
                :placeholder="'产品价格'"
              />
            </el-col>
            <el-col v-if="specialArea == 31" :span="2">
              <el-input
                v-model="item.vipPrice"
                clearable
                size="medium"
                :disabled="methods == 0"
                placeholder="会员价"
              />
            </el-col>
            <el-col v-if="specialArea == 31" :span="2">
              <el-input
                v-model="item.retailPrice"
                clearable
                size="medium"
                :disabled="methods == 0"
                placeholder="零售价"
              />
            </el-col>
            <el-col :span="2">
              <el-input
                v-model="item.integral"
                clearable
                :disabled="methods == 0"
                :placeholder="'业绩'"
              />
            </el-col>
            <el-col :span="2">
              <el-input
                v-model="item.assAchieve"
                clearable
                :disabled="methods == 0"
                :placeholder="specialArea == 40 ? 'EV' : 'BV'"
              />
            </el-col>

            <el-col :span="2">
              <el-select v-model="item.sj" clearable :disabled="methods == 0">
                <el-option
                  v-for="item in agreeList"
                  :key="item.val"
                  :label="item.text"
                  :value="item.val"
                />
              </el-select>
            </el-col>
            <!-- <el-col :span="2">
              <el-select clearable  v-model="item.xs">
                <el-option v-for="item in agreeList"
                           :key="item.val"
                           :label="item.text"
                           :value="item.val"></el-option>
              </el-select>
            </el-col> -->
            <el-col :span="3">
              <el-button
                type="primary"
                style="margin-top: -1px"
                :disabled="methods == 0"
                @click="plcz(item.productId, item.isGift)"
              >{{ '批量操作' }}</el-button>
            </el-col>
          </el-row>
        </div>
        <!-- <div class="goods_t"></div> -->
        <el-table
          ref="multipleTable"
          :data="item.showList"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          :row-class-name="tableRowClassName"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column
            align="center"
            width="200"
            prop="productCover"
            label="产品图片"
          >
            <template slot-scope="scope">
              <!-- <img class="bgImg"
                   :src="scope.row.productCover"
                   alt="" /> -->
              <imageUpload v-model="scope.row.specCover" />
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="productName"
            :label="'产品名称'"
          />
          <el-table-column
            v-for="(ctm, index) in item.titName"
            :key="index"
            :label="ctm"
            align="center"
          >
            <template slot-scope="scope">
              <div v-show="index == 0">{{ scope.row.value0 }}</div>
              <div v-show="index == 1">{{ scope.row.value1 }}</div>
              <div v-show="index == 2">{{ scope.row.value2 }}</div>
              <div v-show="index == 3">{{ scope.row.value3 }}</div>
              <div v-show="index == 4">{{ scope.row.value4 }}</div>
              <div v-show="index == 5">{{ scope.row.value5 }}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="retailPriceTmp" label="划线价" />
          <el-table-column align="center" prop="quantity" label="数量" />

          <el-table-column
            align="center"
            prop="productPrice"
            :label="'产品金额'"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.productPrice"
                clearable
                :disabled="methods == 0"
                :placeholder="'请输入'"
                @input="() => $forceUpdate()"
              />
            </template>
          </el-table-column>
          <el-table-column
            v-if="specialArea == 31"
            align="center"
            prop="vipPrice"
            label="会员价"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.vipPrice"
                clearable
                size="medium"
                :disabled="methods == 0"
                :placeholder="'请输入'"
              />
            </template>
          </el-table-column>
          <el-table-column
            v-if="specialArea == 31"
            align="center"
            prop="retailPrice"
            label="零售价"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.retailPrice"
                clearable
                :disabled="methods == 0"
                size="medium"
                :placeholder="'请输入'"
              />
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="productAchieve"
            label="*产品业绩/PV($)"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.productAchieve"
                clearable
                :disabled="methods == 0"
                :placeholder="'请输入'"
              />
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="assAchieve"
            :label="specialArea == 40 ? 'EV($)' : 'BV'"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.assAchieve"
                clearable
                :disabled="methods == 0"
                :placeholder="'请输入'"
              />
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="isPutOn"
            :label="'上架状态'"
          >
            <template slot-scope="scope">
              <el-select
                v-model="scope.row.isPutOn"
                clearable
                :disabled="methods == 0"
              >
                <el-option
                  v-for="item in agreeList"
                  :key="item.val"
                  :label="item.text"
                  :value="item.val"
                />
              </el-select>
            </template>
          </el-table-column>
          <!-- <el-table-column align="center"
                           prop="code"
                           label="编码">
            <template slot-scope="scope">
              <el-input clearable  v-model="scope.row.code"
                        @input="() => $forceUpdate()"
                        placeholder="请输入编码"></el-input>
            </template>
          </el-table-column> -->
          <!-- <el-table-column align="center"
                           prop="status"
                           :label="'销售状态'">
            <template slot-scope="scope">
              <el-select clearable  v-model="scope.row.status">
                <el-option v-for="item in agreeList"
                           :key="item.val"
                           :label="item.text"
                           :value="item.val"></el-option>
              </el-select>
            </template>
          </el-table-column> -->
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import { getProductSpecsIsGift } from '@/api/product.js'
// import SkuForm from 'vue-sku-form'
import { mapGetters } from 'vuex'
import ImageUpload from '@/components/ImageUpload'
export default {
  name: 'Ggmx',
  components: {
    // SkuForm,
    ImageUpload
  },
  props: ['waresSpecsSkuList', 'methods', 'specialArea'],
  computed: {
    ...mapGetters(['productIds'])
  },
  watch: {
    goodList: {
      handler(newVal, oldVal) {
        this.$emit('getGoodList', newVal, this.copyArr)
        // this.fixThing()
      },
      deep: true // 加这个属性，深度监听
    }
  },
  data() {
    return {
      agreeList: [
        {
          text: '允许',
          val: 0
        },
        {
          text: '禁止',
          val: 1
        }
      ],
      form: {
        specsList: [],
        price: '',
        integral: '',
        productAchieve: '',
        assAchieve: '',
        retailPrice: '',
        vipPrice: '',
        sj: '',
        xs: ''
      },
      // 批量操作选中数据
      selCheckList: [],
      // productIds: [],
      goodList: [
        {
          checked: [],
          showList: [
            {
              productPrice: 0
            }
          ]
        }
      ],
      allData: [],
      copyArr: [],
      specialArea: ''
    }
  },
  mounted() {
    // this.getData()
  },
  methods: {
    getNum(e, index, index1) {
      this.goodList[index1].showList[index].productPrice = e
      this.$forceUpdate()
    },
    // 单选时组装数组
    getCheckBox(check, goodsId, pkId, sld, isGift) {
      // unique
      if (check) {
        this.allData.forEach((aTem) => {
          if (aTem.productId == goodsId && aTem.isGift == isGift) {
            aTem.titName = []
            aTem.selList.forEach((sTem, sIex) => {
              if (sTem.selData.indexOf(sTem.typeName) == -1) {
                aTem.titName.push(sTem.typeName)
              }
              if (sTem.pkId == pkId && sTem.selData.indexOf(sld) == -1) {
                sTem.selData.push(
                  Object.assign(
                    {},
                    {
                      productCode: aTem.productCode,
                      productCover: aTem.productCover,
                      productId: aTem.productId,
                      isGift: aTem.isGift,
                      productName: aTem.productName
                    },
                    { typeName: sTem.typeName, pkId: sTem.pkId },
                    sld
                  )
                )
                this.unique1(sTem.selData)
              }
            })
          }
        })
      } else {
        this.allData.forEach((aTem) => {
          if (aTem.productId == goodsId && aTem.isGift == isGift) {
            aTem.selList.forEach((sTem, sIex) => {
              if (sTem.pkId == pkId) {
                // sTem.selData.splice(
                //   sTem.selData.indexOf(
                //     Object.assign(
                //       {},
                //       {
                //         productCode: aTem.productCode,
                //         productCover: aTem.productCover,
                //         productId: aTem.productId,
                //         productName: aTem.productName,
                //       },
                //       { typeName: sTem.typeName, pkId: sTem.pkId },
                //       sld
                //     )
                //   ),
                //   1
                // )
                sTem.selData.splice(
                  sTem.selData.findIndex(
                    (sstem) => sstem.specsId === sld.specsId
                  ),
                  1
                )
              }
            })
          }
        })
      }
      // this.allData

      this.pushArr(goodsId, isGift)
    },
    // 把组装好的数组放入大数组去笛卡尔
    pushArr(goodsId, isGift) {
      this.allData.forEach((aTem) => {
        if (aTem.productId == goodsId && aTem.isGift == isGift) {
          aTem.checkList = []
          aTem.selList.forEach((sTem, sIex) => {
            aTem.checkList.push(sTem.selData)
          })
        }
      })
      this.runFunc(goodsId, isGift)
    },
    // 笛卡尔重组
    runFunc(goodsId, isGift) {
      this.allData.forEach((aTem) => {
        if (aTem.productId == goodsId && aTem.isGift == isGift) {
          aTem.checkList = this.calcDescartes(aTem.checkList)
        }
      })

      this.goodList.forEach((item) => {
        if (item.productId == goodsId && item.isGift == isGift) {
          item.checkList = []
          this.allData.forEach((aTem) => {
            if ((aTem.productId == goodsId) & (aTem.isGift == isGift)) {
              aTem.checkList.forEach((cTem) => {
                if (item.pkId == aTem.pkid) {
                  item.checkList.push(cTem)
                  item.titName = aTem.titName
                }
              })
            }
          })
        }
      })
      this.goodList.forEach((item, fdex) => {
        if (item.productId == goodsId && item.isGift == isGift) {
          item.showList = []
          item.checkList.forEach((ctem, cdex) => {
            ctem.assn = {}
            ctem.waresSpecsList = []
            if (ctem.forEach) {
              ctem.forEach((cld, index) => {
                // this.$set(
                //   this.goodList[fdex].checkList[cdex],
                //   'productPrice',
                //   ''
                // )
                // this.$set(this.goodList[fdex].checkList[cdex], 'isPutOn', '')
                // this.$set(
                //   this.goodList[fdex].checkList[cdex],
                //   'productAchieve',
                //   ''
                // )
                // this.$set(this.goodList[fdex].checkList[cdex], 'assAchieve', '')

                // cld.productPrice = 0
                // cld.productAchieve = ''
                // cld.assAchieve = ''
                // cld.isPutOn = ''
                cld.status = ''
                cld.pkProduct = cld.productId
                cld.quantity = item.quantity
                cld.retailPriceTmp = item.retailPriceTmp
                cld.isGift = cld.isGift
                ctem.waresSpecsList.push({
                  pkSpecs: cld.specsId,
                  pkSpecsType: cld.pkSpecsType
                })
                if (index == 0) {
                  cld.value0 = cld.value
                  cld.pkId0 = cld.pkId
                  cld.specsId0 = cld.specsId
                  cld.typeName0 = cld.typeName
                  cld.pkSpecsType0 = cld.pkSpecsType
                }
                if (index == 1) {
                  cld.value1 = cld.value
                  cld.pkId1 = cld.pkId
                  cld.specsId1 = cld.specsId
                  cld.typeName1 = cld.typeName
                  cld.pkSpecsType1 = cld.pkSpecsType
                }
                if (index == 2) {
                  cld.value2 = cld.value
                  cld.pkId2 = cld.pkId
                  cld.specsId2 = cld.specsId
                  cld.typeName2 = cld.typeName
                  cld.pkSpecsType2 = cld.pkSpecsType
                }
                if (index == 3) {
                  cld.value3 = cld.value
                  cld.pkId3 = cld.pkId
                  cld.specsId3 = cld.specsId
                  cld.typeName3 = cld.typeName
                  cld.pkSpecsType3 = cld.pkSpecsType
                }
                if (index == 4) {
                  cld.value4 = cld.value
                  cld.pkId4 = cld.pkId
                  cld.specsId4 = cld.specsId
                  cld.typeName4 = cld.typeName
                  cld.pkSpecsType4 = cld.pkSpecsType
                }
                if (index == 5) {
                  cld.value5 = cld.value
                  cld.pkId5 = cld.pkId
                  cld.specsId5 = cld.specsId
                  cld.typeName5 = cld.typeName
                  cld.pkSpecsType5 = cld.pkSpecsType
                }
                item.showList.push(
                  Object.assign(ctem.assn, cld, {
                    waresSpecsList: ctem.waresSpecsList
                  })
                )
              })
            } else {
              ctem.waresSpecsList = [
                {
                  pkSpecs: ctem.specsId,
                  pkSpecsType: ctem.pkSpecsType
                }
              ]
              // this.$set(this.goodList[fdex].checkList[cdex], 'productPrice', '')
              // this.$set(this.goodList[fdex].checkList[cdex], 'isPutOn', 0)
              // this.$set(
              //   this.goodList[fdex].checkList[cdex],
              //   'productAchieve',
              //   0
              // )
              // this.$set(this.goodList[fdex].checkList[cdex], 'assAchieve', 0)
              ctem.pkProduct = ctem.productId
              ctem.isGift = ctem.isGift
              ctem.quantity = item.quantity
              ctem.retailPriceTmp = item.retailPriceTmp
              ctem.value0 = ctem.value
              ctem.pkId0 = ctem.pkId
              ctem.specsId0 = ctem.specsId
              ctem.typeName0 = ctem.typeName
              ctem.pkSpecsType0 = ctem.pkSpecsType
              item.showList.push(ctem)
            }
          })
        }
      })
      this.goodList.forEach((item) => {
        if (item.productId == goodsId && item.isGift == isGift) {
          item.showList = this.unique(item.showList)
          if (item.showList.length > 0 && item.showList[0].pkId0) {
            item.allSel = true
          } else {
            item.allSel = false
          }
        }
      })
      this.goodList.forEach((item) => {
        if (item.showList) {
          item.showList.forEach((cld) => {
            cld.specsIdList = [
              cld.specsId0,
              cld.specsId1,
              cld.specsId2,
              cld.specsId3,
              cld.specsId4,
              cld.specsId5
            ].filter(Boolean)
          })
        }
      })
      this.copyArr = JSON.parse(JSON.stringify(this.allData))
      this.$forceUpdate()
    },
    // // 传参格式
    // fixThing() {
    //   let waresSpecsSkuList = []
    //   this.goodList.forEach((item) => {
    //     waresSpecsSkuList.push(...item.showList)
    //   })
    //   console.log(
    //     '%c [ waresSpecsSkuList ]-457',
    //     'font-size:13px; background:#2fda2e; color:#73ff72;',
    //     waresSpecsSkuList
    //   )
    // },
    // 数组对象去重
    unique1(arr) {
      for (var i = 0; i < arr.length; i++) {
        // 首次遍历数组
        for (var j = i + 1; j < arr.length; j++) {
          // 再次遍历数组
          if (arr[i].specsId == arr[j].specsId) {
            // 判断连个值是否相等
            arr.splice(j, 1) // 相等删除后者
            j--
          }
        }
      }
      return arr
    },
    // 数组对象去重
    unique(arr) {
      for (var i = 0; i < arr.length; i++) {
        // 首次遍历数组
        for (var j = i + 1; j < arr.length; j++) {
          // 再次遍历数组
          if (arr[i] == arr[j]) {
            // 判断连个值是否相等
            arr.splice(j, 1) // 相等删除后者
            j--
          }
        }
      }
      return arr
    },
    calcDescartes(array) {
      // if (array.length < 2) return array[0] || []
      return array.reduce((total, currentValue) => {
        const res = []
        // if (total.length == 0) {
        //   res.push([cv])
        // }
        total.forEach((t) => {
          if (currentValue.length > 0) {
            currentValue.forEach((cv) => {
              if (t instanceof Array)
              // 或者使用 Array.isArray(t)
              { res.push([...t, cv]) } else res.push([t, cv])
            })
          } else {
            res.push([t])
          }
        })
        return res
      })
    },
    handleSelectionChange(val) {
      this.selCheckList = val
    },
    plcz(productId, isGift) {
      this.goodList.forEach((item, index) => {
        this.selCheckList.forEach((cld, cndx) => {
          if (item.showList) {
            item.showList.forEach((sld, sndex) => {
              if (
                item.productId == productId &&
                item.isGift == isGift &&
                sld.specsIdList.sort().toString() ==
                  cld.specsIdList.sort().toString()
              ) {
                if (item.price) {
                  sld.productPrice = item.price
                  this.$set(
                    this.goodList[index].showList[sndex],
                    'productPrice',
                    item.price
                  )
                }
                if (item.retailPrice) {
                  sld.retailPrice = item.retailPrice
                  this.$set(
                    this.goodList[index].showList[sndex],
                    'retailPrice',
                    item.retailPrice
                  )
                  this.$forceUpdate()
                }
                if (item.vipPrice) {
                  sld.vipPrice = item.vipPrice
                  this.$set(
                    this.goodList[index].showList[sndex],
                    'vipPrice',
                    item.vipPrice
                  )
                  this.$forceUpdate()
                }
                if (item.integral) {
                  sld.productAchieve = item.integral
                  this.$set(
                    this.goodList[index].showList[sndex],
                    'productAchieve',
                    item.integral
                  )
                }
                if (item.assAchieve) {
                  sld.assAchieve = item.assAchieve
                  this.$set(
                    this.goodList[index].showList[sndex],
                    'assAchieve',
                    item.assAchieve
                  )
                }
                if (item.productAchieve) {
                  sld.productAchieve = item.productAchieve
                }
                if (item.sj != '' || item.sj != undefined) {
                  sld.isPutOn = item.sj
                  this.$set(
                    this.goodList[index].showList[sndex],
                    'isPutOn',
                    item.sj
                  )
                }
                if (item.xs) {
                  sld.status = item.xs
                }
                // this.$set(this.goodList[index].showList[sndex], isPutOn, item.sj)
              }
              this.$set(this.goodList[index].showList, sndex, sld)
            })
          }
          // if (item.productId == productId) {
          //   if (item.price != '') {
          //     cld.price = item.price
          //   }
          //   if (item.integral != '') {
          //     cld.integral = item.integral
          //   }
          //   if (item.sj != '') {
          //     cld.isPutOn = item.sj
          //   }
          //   if (item.xs != '') {
          //     cld.status = item.xs
          //   }
          // }
        })
      })
      // this.selCheckList

      // console.log(this.$refs.multipleTable)
      // this.$set('this','goodList',this.goodList)
      this.$forceUpdate()
      this.$nextTick(() => {
        for (var i = 0; i < this.$refs.multipleTable.length; i++) {
          this.$refs.multipleTable[i].clearSelection()
        }
      })
    },
    compareArrays(arr1, arr2) {
      if (arr1.length !== arr2.length) {
        return false
      }

      for (let i = 0; i < arr1.length; i++) {
        if (arr1[i] !== arr2[i]) {
          return false
        }
      }

      return true
    },
    getData(data, specialArea) {
      this.specialArea = specialArea
      // if (this.productIds) {
      //   if (
      //     this.productIds.length === data.length &&
      //     this.productIds.sort().toString() === data.sort().toString()
      //   ) {
      //   } else {
      //     this.getList(data)
      //     this.$store.commit('settings/GGMX_SETTING', data)
      //   }
      // } else {
      //   this.getList(data)
      //   this.$store.commit('settings/GGMX_SETTING', data)
      // }
      if (this.productIds.length > 0) {
        const a = this.compareArrays(this.productIds, data)
        if (a) {
        } else {
          this.getList(data)
          this.$store.commit('settings/GGMX_SETTING', data)
        }
      } else {
        this.getList(data)
        this.$store.commit('settings/GGMX_SETTING', data)
      }
    },
    getList(data) {
      getProductSpecsIsGift({ productGiftList: data }).then((res) => {
        const arr = res.data
        // 获取数据重组数组
        const allData = []
        arr.forEach((item, index) => {
          item.checked = []
          allData.push({
            productId: item.productId,
            productCode: item.productCode,
            productCover: item.productCover,
            isGift: item.isGift,
            productName: item.productName,
            selList: []
          })
          item.specsTypeData.forEach((cld) => {
            allData[index].selList.push({
              pkId: cld.pkId,
              typeName: cld.typeName,
              selData: []
            })
          })
        })
        this.allData = allData
        this.goodList = arr
        if (this.waresSpecsSkuList.length > 0) {
          this.checkedBox()
        }
      })
    },
    checkedBox() {
      this.waresSpecsSkuList.forEach((item) => {
        item.specsIdList = []
        item.waresSpecsList.forEach((ctm) => {
          item.specsIdList.push(ctm.pkSpecs)
        })
      })
      const arr = []
      // getCheckBox(check, goodsId, pkId, sld) {
      this.waresSpecsSkuList.forEach((item) => {
        item.waresSpecsList.forEach((ctm) => {
          // this.getCheckBox(true,item.pkProduct,ctm.pkSpecsType,{pkSpecs})
          ctm.value = ctm.specsName
          ctm.specsId = ctm.pkSpecs
          arr.push({
            pkProduct: item.pkProduct,
            isGift: item.isGift,
            pkSpecsType: ctm.pkSpecsType,
            tt: ctm,
            pkSpecs: ctm.pkSpecs
          })
        })
      })
      for (var i = 0; i < arr.length; i++) {
        // 首次遍历数组
        for (var j = i + 1; j < arr.length; j++) {
          // 再次遍历数组
          if (
            arr[i].pkProduct == arr[j].pkProduct &&
            arr[i].pkSpecs == arr[j].pkSpecs &&
            arr[i].isGift == arr[j].isGift
          ) {
            // 判断连个值是否相等
            arr.splice(j, 1) // 相等删除后者
            j--
          }
        }
      }
      arr.forEach((item) => {
        this.getCheckBox(
          true,
          item.pkProduct,
          item.pkSpecsType,
          item.tt,
          item.isGift
        )
      })
      this.goodList.forEach((item) => {
        if (item.showList) {
          item.showList.forEach((ctm) => {
            this.$set(ctm, 'productPrice', 0)
            // this.$set(ctm, 'code', '')
            this.waresSpecsSkuList.forEach((stm) => {
              if (
                item.productId == stm.pkProduct &&
                item.isGift == stm.isGift
              ) {
                if (
                  ctm.specsIdList.sort().toString() ==
                  stm.specsIdList.sort().toString()
                ) {
                  this.$set(ctm, 'productPrice', stm.productPrice)
                  this.$set(ctm, 'retailPrice', stm.retailPrice)
                  this.$set(ctm, 'vipPrice', stm.vipPrice)
                  this.$set(ctm, 'productAchieve', stm.productAchieve)
                  this.$set(ctm, 'assAchieve', stm.assAchieve)
                  this.$set(ctm, 'isPutOn', stm.isPutOn)
                  this.$set(ctm, 'specCover', stm.specCover)
                  this.$set(ctm, 'pkWaresSpecsSku', stm.pkWaresSpecsSku)
                  // ctm.integral = stm.integral
                  // ctm.isPutOn = stm.isPutOn
                  // ctm.specCover = stm.specCover
                  this.$forceUpdate()
                }
              }
            })
          })
        }
      })
      this.goodList.forEach((item) => {
        this.waresSpecsSkuList.forEach((ctm) => {
          ctm.waresSpecsList.forEach((stm) => {
            if (item.productId == ctm.pkProduct && item.isGift == ctm.isGift) {
              item.checked.push(stm.pkSpecs)
              item.checked = this.unique(item.checked.sort())
            }
          })
        })
      })
      if (this.methods != 2) {
        this.goodList.forEach((item) => {
          if (item.checked.length > 0) {
            item.checked.forEach((ctem) => {
              item.specsTypeData.forEach((stem) => {
                stem.specsList.forEach((sstem) => {
                  if (sstem.specsId == ctem) {
                    sstem.disabled = true
                  }
                })
              })
            })
          }
        })
      }
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return 'warning-row'
      } else if (rowIndex % 2 == 0) {
        return 'success-row'
      }
      return ''
    }
  }
}
</script>

<style scoped lang="scss">
::v-deep .el-form-item {
  margin-bottom: 0;
}
.ggmx {
  margin-left: -20px;
  .goodsAll {
    padding: 0 20px;
    .goods_t {
      margin-bottom: 20px;
      background: #ffffff;
      box-shadow: 0px 1px 20px 0px rgba(#ccc, 0.3);
      border-radius: 8px;
      .goods_tit {
        display: flex;
        padding: 20px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        .goods_tit_1 {
          font-size: 14px;
          font-weight: bold;
          color: #333333;
          margin-right: 40px;
        }
        .goods_tit_2 {
          font-size: 14px;
          color: #666666;
        }
        .goods_tit_3 {
          font-size: 14px;
          color: #aa3931;
          margin-left: 20px;
        }
      }
      .goods_btm {
        padding: 0 20px;
      }
    }
  }
}
.tit {
  font-size: 14px;
  font-weight: bold;
  color: #333333;
  padding: 0 20px;
  border-left: 5px solid #4391fd;
  margin-bottom: 9px;

  padding: 10px 20px 0 20px;
}
.bgImg {
  width: 48px;
  height: 48px;
}
.pl {
  margin-bottom: 20px;
}
.goods_b {
  margin-bottom: 30px;
}
// ::v-deep .el-table .cell{
//   overflow: auto;
// }
::v-deep .el-input__suffix {
  top: -3px;
}
::v-deep .el-select .el-input__suffix {
  top: 5px;
}
</style>
