web-base-admin/src/views/goodsManage/goodsList/goodsEdit/ggmx.vue

1023 lines
31 KiB
Vue
Raw Normal View History

2025-03-23 09:18:42 +08:00
<template>
<div class="ggmx">
<div class="tit">规格明细</div>
2025-04-29 14:02:21 +08:00
<div v-for="(item, index) in goodList" :key="index" class="goodsAll">
2025-03-23 09:18:42 +08:00
<div class="goods_t">
<div class="goods_tit">
<div class="goods_tit_1">{{ item.productName }}</div>
<div class="goods_tit_2">
2025-04-01 23:46:26 +08:00
{{ '产品编码' }}:{{ item.productCode }}
2025-03-23 09:18:42 +08:00
</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"
2025-04-29 14:02:21 +08:00
:label="child.typeName"
2025-03-23 09:18:42 +08:00
>
<el-checkbox-group
v-model="item.checked"
2025-04-29 14:02:21 +08:00
:disabled="methods == 0"
2025-03-23 09:18:42 +08:00
>
<el-checkbox
v-for="(sld, sindex) in child.specsList"
2025-04-29 14:02:21 +08:00
:key="sld.specsId"
:disabled="sld.disabled"
:label="sld.specsId"
2025-03-23 09:18:42 +08:00
@change="
getCheckBox(
$event,
item.productId,
child.pkId,
sld,
item.isGift
)
"
2025-04-29 14:02:21 +08:00
>{{ sld.value }}</el-checkbox>
2025-03-23 09:18:42 +08:00
</el-checkbox-group>
</el-form-item>
</el-form>
</div>
</div>
2025-04-29 14:02:21 +08:00
<div v-show="item.allSel" class="goods_b">
2025-03-23 09:18:42 +08:00
<div class="pl">
<el-row type="flex" justify="end" :gutter="20">
<el-col :span="2">
2025-04-01 23:46:26 +08:00
<div style="line-height: 40px">{{ '批量处理' }}</div>
2025-03-23 09:18:42 +08:00
</el-col>
<el-col :span="2">
<el-input
2025-04-29 14:02:21 +08:00
v-model="item.price"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
2025-04-01 23:46:26 +08:00
:placeholder="'产品价格'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</el-col>
2025-04-29 14:02:21 +08:00
<el-col v-if="specialArea == 31" :span="2">
2025-03-23 09:18:42 +08:00
<el-input
2025-04-29 14:02:21 +08:00
v-model="item.vipPrice"
2025-03-23 09:18:42 +08:00
clearable
size="medium"
:disabled="methods == 0"
placeholder="会员价"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</el-col>
2025-04-29 14:02:21 +08:00
<el-col v-if="specialArea == 31" :span="2">
2025-03-23 09:18:42 +08:00
<el-input
2025-04-29 14:02:21 +08:00
v-model="item.retailPrice"
2025-03-23 09:18:42 +08:00
clearable
size="medium"
:disabled="methods == 0"
placeholder="零售价"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</el-col>
<el-col :span="2">
<el-input
2025-04-29 14:02:21 +08:00
v-model="item.integral"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
2025-04-01 23:46:26 +08:00
:placeholder="'业绩'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</el-col>
<el-col :span="2">
<el-input
2025-04-29 14:02:21 +08:00
v-model="item.assAchieve"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
:placeholder="specialArea == 40 ? 'EV' : 'BV'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</el-col>
<el-col :span="2">
2025-04-29 14:02:21 +08:00
<el-select v-model="item.sj" clearable :disabled="methods == 0">
2025-03-23 09:18:42 +08:00
<el-option
v-for="item in agreeList"
:key="item.val"
:label="item.text"
:value="item.val"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</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)"
2025-04-29 14:02:21 +08:00
>{{ '批量操作' }}</el-button>
2025-03-23 09:18:42 +08:00
</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"
>
2025-04-29 14:02:21 +08:00
<el-table-column type="selection" width="55" />
2025-03-23 09:18:42 +08:00
<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"
2025-04-01 23:46:26 +08:00
:label="'产品名称'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
<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>
2025-04-29 14:02:21 +08:00
<el-table-column align="center" prop="retailPriceTmp" label="划线价" />
<el-table-column align="center" prop="quantity" label="数量" />
2025-03-23 09:18:42 +08:00
<el-table-column
align="center"
prop="productPrice"
2025-04-01 23:46:26 +08:00
:label="'产品金额'"
2025-03-23 09:18:42 +08:00
>
<template slot-scope="scope">
<el-input
2025-04-29 14:02:21 +08:00
v-model="scope.row.productPrice"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
2025-04-01 23:46:26 +08:00
:placeholder="'请输入'"
2025-04-29 14:02:21 +08:00
@input="() => $forceUpdate()"
/>
2025-03-23 09:18:42 +08:00
</template>
</el-table-column>
<el-table-column
v-if="specialArea == 31"
2025-04-29 14:02:21 +08:00
align="center"
2025-03-23 09:18:42 +08:00
prop="vipPrice"
label="会员价"
>
<template slot-scope="scope">
<el-input
2025-04-29 14:02:21 +08:00
v-model="scope.row.vipPrice"
2025-03-23 09:18:42 +08:00
clearable
size="medium"
:disabled="methods == 0"
2025-04-01 23:46:26 +08:00
:placeholder="'请输入'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</template>
</el-table-column>
<el-table-column
v-if="specialArea == 31"
2025-04-29 14:02:21 +08:00
align="center"
2025-03-23 09:18:42 +08:00
prop="retailPrice"
label="零售价"
>
<template slot-scope="scope">
<el-input
2025-04-29 14:02:21 +08:00
v-model="scope.row.retailPrice"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
size="medium"
2025-04-01 23:46:26 +08:00
:placeholder="'请输入'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</template>
</el-table-column>
<el-table-column
align="center"
prop="productAchieve"
label="*产品业绩/PV(¥)"
2025-03-23 09:18:42 +08:00
>
<template slot-scope="scope">
<el-input
2025-04-29 14:02:21 +08:00
v-model="scope.row.productAchieve"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
2025-04-01 23:46:26 +08:00
:placeholder="'请输入'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</template>
</el-table-column>
<el-table-column
align="center"
prop="assAchieve"
:label="specialArea == 40 ? 'EV($)' : 'BV'"
>
<template slot-scope="scope">
<el-input
2025-04-29 14:02:21 +08:00
v-model="scope.row.assAchieve"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
2025-04-01 23:46:26 +08:00
:placeholder="'请输入'"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</template>
</el-table-column>
<el-table-column
align="center"
prop="isPutOn"
2025-04-01 23:46:26 +08:00
:label="'上架状态'"
2025-03-23 09:18:42 +08:00
>
<template slot-scope="scope">
<el-select
2025-04-29 14:02:21 +08:00
v-model="scope.row.isPutOn"
2025-03-23 09:18:42 +08:00
clearable
:disabled="methods == 0"
>
<el-option
v-for="item in agreeList"
:key="item.val"
:label="item.text"
:value="item.val"
2025-04-29 14:02:21 +08:00
/>
2025-03-23 09:18:42 +08:00
</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"
2025-04-01 23:46:26 +08:00
:label="'销售状态'">
2025-03-23 09:18:42 +08:00
<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>
2025-04-29 14:02:21 +08:00
import { getProductSpecsIsGift } from '@/api/product.js'
2025-03-23 09:18:42 +08:00
// import SkuForm from 'vue-sku-form'
2025-04-29 14:02:21 +08:00
import { mapGetters } from 'vuex'
import ImageUpload from '@/components/ImageUpload'
2025-03-23 09:18:42 +08:00
export default {
2025-04-29 14:02:21 +08:00
name: 'Ggmx',
2025-03-23 09:18:42 +08:00
components: {
// SkuForm,
2025-04-29 14:02:21 +08:00
ImageUpload
2025-03-23 09:18:42 +08:00
},
2025-04-29 14:02:21 +08:00
props: ['waresSpecsSkuList', 'methods', 'specialArea'],
2025-03-23 09:18:42 +08:00
computed: {
2025-04-29 14:02:21 +08:00
...mapGetters(['productIds'])
2025-03-23 09:18:42 +08:00
},
watch: {
goodList: {
handler(newVal, oldVal) {
2025-04-29 14:02:21 +08:00
this.$emit('getGoodList', newVal, this.copyArr)
2025-03-23 09:18:42 +08:00
// this.fixThing()
},
2025-04-29 14:02:21 +08:00
deep: true // 加这个属性,深度监听
}
2025-03-23 09:18:42 +08:00
},
data() {
return {
agreeList: [
{
2025-04-01 23:46:26 +08:00
text: '允许',
2025-04-29 14:02:21 +08:00
val: 0
2025-03-23 09:18:42 +08:00
},
{
2025-04-01 23:46:26 +08:00
text: '禁止',
2025-04-29 14:02:21 +08:00
val: 1
}
2025-03-23 09:18:42 +08:00
],
form: {
specsList: [],
2025-04-29 14:02:21 +08:00
price: '',
integral: '',
productAchieve: '',
assAchieve: '',
retailPrice: '',
vipPrice: '',
sj: '',
xs: ''
2025-03-23 09:18:42 +08:00
},
// 批量操作选中数据
selCheckList: [],
// productIds: [],
goodList: [
{
checked: [],
showList: [
{
2025-04-29 14:02:21 +08:00
productPrice: 0
}
]
}
2025-03-23 09:18:42 +08:00
],
allData: [],
copyArr: [],
2025-04-29 14:02:21 +08:00
specialArea: ''
}
2025-03-23 09:18:42 +08:00
},
mounted() {
// this.getData()
},
methods: {
getNum(e, index, index1) {
2025-04-29 14:02:21 +08:00
this.goodList[index1].showList[index].productPrice = e
this.$forceUpdate()
2025-03-23 09:18:42 +08:00
},
// 单选时组装数组
getCheckBox(check, goodsId, pkId, sld, isGift) {
// unique
if (check) {
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
2025-04-29 14:02:21 +08:00
aTem.titName = []
2025-03-23 09:18:42 +08:00
aTem.selList.forEach((sTem, sIex) => {
if (sTem.selData.indexOf(sTem.typeName) == -1) {
2025-04-29 14:02:21 +08:00
aTem.titName.push(sTem.typeName)
2025-03-23 09:18:42 +08:00
}
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,
2025-04-29 14:02:21 +08:00
productName: aTem.productName
2025-03-23 09:18:42 +08:00
},
{ typeName: sTem.typeName, pkId: sTem.pkId },
sld
)
2025-04-29 14:02:21 +08:00
)
this.unique1(sTem.selData)
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
} 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
2025-04-29 14:02:21 +08:00
)
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
}
// this.allData
2025-04-29 14:02:21 +08:00
this.pushArr(goodsId, isGift)
2025-03-23 09:18:42 +08:00
},
// 把组装好的数组放入大数组去笛卡尔
pushArr(goodsId, isGift) {
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
2025-04-29 14:02:21 +08:00
aTem.checkList = []
2025-03-23 09:18:42 +08:00
aTem.selList.forEach((sTem, sIex) => {
2025-04-29 14:02:21 +08:00
aTem.checkList.push(sTem.selData)
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
this.runFunc(goodsId, isGift)
2025-03-23 09:18:42 +08:00
},
// 笛卡尔重组
runFunc(goodsId, isGift) {
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
2025-04-29 14:02:21 +08:00
aTem.checkList = this.calcDescartes(aTem.checkList)
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
this.goodList.forEach((item) => {
if (item.productId == goodsId && item.isGift == isGift) {
2025-04-29 14:02:21 +08:00
item.checkList = []
2025-03-23 09:18:42 +08:00
this.allData.forEach((aTem) => {
if ((aTem.productId == goodsId) & (aTem.isGift == isGift)) {
aTem.checkList.forEach((cTem) => {
if (item.pkId == aTem.pkid) {
2025-04-29 14:02:21 +08:00
item.checkList.push(cTem)
item.titName = aTem.titName
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
this.goodList.forEach((item, fdex) => {
if (item.productId == goodsId && item.isGift == isGift) {
2025-04-29 14:02:21 +08:00
item.showList = []
2025-03-23 09:18:42 +08:00
item.checkList.forEach((ctem, cdex) => {
2025-04-29 14:02:21 +08:00
ctem.assn = {}
ctem.waresSpecsList = []
2025-03-23 09:18:42 +08:00
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 = ''
2025-04-29 14:02:21 +08:00
cld.status = ''
cld.pkProduct = cld.productId
cld.quantity = item.quantity
cld.retailPriceTmp = item.retailPriceTmp
cld.isGift = cld.isGift
2025-03-23 09:18:42 +08:00
ctem.waresSpecsList.push({
pkSpecs: cld.specsId,
2025-04-29 14:02:21 +08:00
pkSpecsType: cld.pkSpecsType
})
2025-03-23 09:18:42 +08:00
if (index == 0) {
2025-04-29 14:02:21 +08:00
cld.value0 = cld.value
cld.pkId0 = cld.pkId
cld.specsId0 = cld.specsId
cld.typeName0 = cld.typeName
cld.pkSpecsType0 = cld.pkSpecsType
2025-03-23 09:18:42 +08:00
}
if (index == 1) {
2025-04-29 14:02:21 +08:00
cld.value1 = cld.value
cld.pkId1 = cld.pkId
cld.specsId1 = cld.specsId
cld.typeName1 = cld.typeName
cld.pkSpecsType1 = cld.pkSpecsType
2025-03-23 09:18:42 +08:00
}
if (index == 2) {
2025-04-29 14:02:21 +08:00
cld.value2 = cld.value
cld.pkId2 = cld.pkId
cld.specsId2 = cld.specsId
cld.typeName2 = cld.typeName
cld.pkSpecsType2 = cld.pkSpecsType
2025-03-23 09:18:42 +08:00
}
if (index == 3) {
2025-04-29 14:02:21 +08:00
cld.value3 = cld.value
cld.pkId3 = cld.pkId
cld.specsId3 = cld.specsId
cld.typeName3 = cld.typeName
cld.pkSpecsType3 = cld.pkSpecsType
2025-03-23 09:18:42 +08:00
}
if (index == 4) {
2025-04-29 14:02:21 +08:00
cld.value4 = cld.value
cld.pkId4 = cld.pkId
cld.specsId4 = cld.specsId
cld.typeName4 = cld.typeName
cld.pkSpecsType4 = cld.pkSpecsType
2025-03-23 09:18:42 +08:00
}
if (index == 5) {
2025-04-29 14:02:21 +08:00
cld.value5 = cld.value
cld.pkId5 = cld.pkId
cld.specsId5 = cld.specsId
cld.typeName5 = cld.typeName
cld.pkSpecsType5 = cld.pkSpecsType
2025-03-23 09:18:42 +08:00
}
item.showList.push(
Object.assign(ctem.assn, cld, {
2025-04-29 14:02:21 +08:00
waresSpecsList: ctem.waresSpecsList
2025-03-23 09:18:42 +08:00
})
2025-04-29 14:02:21 +08:00
)
})
2025-03-23 09:18:42 +08:00
} else {
ctem.waresSpecsList = [
{
pkSpecs: ctem.specsId,
2025-04-29 14:02:21 +08:00
pkSpecsType: ctem.pkSpecsType
}
]
2025-03-23 09:18:42 +08:00
// 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)
2025-04-29 14:02:21 +08:00
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)
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
this.goodList.forEach((item) => {
if (item.productId == goodsId && item.isGift == isGift) {
2025-04-29 14:02:21 +08:00
item.showList = this.unique(item.showList)
2025-03-23 09:18:42 +08:00
if (item.showList.length > 0 && item.showList[0].pkId0) {
2025-04-29 14:02:21 +08:00
item.allSel = true
2025-03-23 09:18:42 +08:00
} else {
2025-04-29 14:02:21 +08:00
item.allSel = false
2025-03-23 09:18:42 +08:00
}
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
this.goodList.forEach((item) => {
if (item.showList) {
item.showList.forEach((cld) => {
cld.specsIdList = [
cld.specsId0,
cld.specsId1,
cld.specsId2,
cld.specsId3,
cld.specsId4,
2025-04-29 14:02:21 +08:00
cld.specsId5
].filter(Boolean)
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
this.copyArr = JSON.parse(JSON.stringify(this.allData))
this.$forceUpdate()
2025-03-23 09:18:42 +08:00
},
// // 传参格式
// 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) {
// 判断连个值是否相等
2025-04-29 14:02:21 +08:00
arr.splice(j, 1) // 相等删除后者
j--
2025-03-23 09:18:42 +08:00
}
}
}
2025-04-29 14:02:21 +08:00
return arr
2025-03-23 09:18:42 +08:00
},
// 数组对象去重
unique(arr) {
for (var i = 0; i < arr.length; i++) {
// 首次遍历数组
for (var j = i + 1; j < arr.length; j++) {
// 再次遍历数组
if (arr[i] == arr[j]) {
// 判断连个值是否相等
2025-04-29 14:02:21 +08:00
arr.splice(j, 1) // 相等删除后者
j--
2025-03-23 09:18:42 +08:00
}
}
}
2025-04-29 14:02:21 +08:00
return arr
2025-03-23 09:18:42 +08:00
},
calcDescartes(array) {
// if (array.length < 2) return array[0] || []
return array.reduce((total, currentValue) => {
2025-04-29 14:02:21 +08:00
const res = []
2025-03-23 09:18:42 +08:00
// if (total.length == 0) {
// res.push([cv])
// }
total.forEach((t) => {
if (currentValue.length > 0) {
currentValue.forEach((cv) => {
if (t instanceof Array)
2025-04-29 14:02:21 +08:00
// 或者使用 Array.isArray(t)
{ res.push([...t, cv]) } else res.push([t, cv])
})
2025-03-23 09:18:42 +08:00
} else {
2025-04-29 14:02:21 +08:00
res.push([t])
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
return res
})
2025-03-23 09:18:42 +08:00
},
handleSelectionChange(val) {
2025-04-29 14:02:21 +08:00
this.selCheckList = val
2025-03-23 09:18:42 +08:00
},
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) {
2025-04-29 14:02:21 +08:00
sld.productPrice = item.price
2025-03-23 09:18:42 +08:00
this.$set(
this.goodList[index].showList[sndex],
2025-04-29 14:02:21 +08:00
'productPrice',
2025-03-23 09:18:42 +08:00
item.price
2025-04-29 14:02:21 +08:00
)
2025-03-23 09:18:42 +08:00
}
if (item.retailPrice) {
2025-04-29 14:02:21 +08:00
sld.retailPrice = item.retailPrice
2025-03-23 09:18:42 +08:00
this.$set(
this.goodList[index].showList[sndex],
2025-04-29 14:02:21 +08:00
'retailPrice',
2025-03-23 09:18:42 +08:00
item.retailPrice
2025-04-29 14:02:21 +08:00
)
this.$forceUpdate()
2025-03-23 09:18:42 +08:00
}
if (item.vipPrice) {
2025-04-29 14:02:21 +08:00
sld.vipPrice = item.vipPrice
2025-03-23 09:18:42 +08:00
this.$set(
this.goodList[index].showList[sndex],
2025-04-29 14:02:21 +08:00
'vipPrice',
2025-03-23 09:18:42 +08:00
item.vipPrice
2025-04-29 14:02:21 +08:00
)
this.$forceUpdate()
2025-03-23 09:18:42 +08:00
}
if (item.integral) {
2025-04-29 14:02:21 +08:00
sld.productAchieve = item.integral
2025-03-23 09:18:42 +08:00
this.$set(
this.goodList[index].showList[sndex],
2025-04-29 14:02:21 +08:00
'productAchieve',
2025-03-23 09:18:42 +08:00
item.integral
2025-04-29 14:02:21 +08:00
)
2025-03-23 09:18:42 +08:00
}
if (item.assAchieve) {
2025-04-29 14:02:21 +08:00
sld.assAchieve = item.assAchieve
2025-03-23 09:18:42 +08:00
this.$set(
this.goodList[index].showList[sndex],
2025-04-29 14:02:21 +08:00
'assAchieve',
2025-03-23 09:18:42 +08:00
item.assAchieve
2025-04-29 14:02:21 +08:00
)
2025-03-23 09:18:42 +08:00
}
if (item.productAchieve) {
2025-04-29 14:02:21 +08:00
sld.productAchieve = item.productAchieve
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
if (item.sj != '' || item.sj != undefined) {
sld.isPutOn = item.sj
2025-03-23 09:18:42 +08:00
this.$set(
this.goodList[index].showList[sndex],
2025-04-29 14:02:21 +08:00
'isPutOn',
2025-03-23 09:18:42 +08:00
item.sj
2025-04-29 14:02:21 +08:00
)
2025-03-23 09:18:42 +08:00
}
if (item.xs) {
2025-04-29 14:02:21 +08:00
sld.status = item.xs
2025-03-23 09:18:42 +08:00
}
// this.$set(this.goodList[index].showList[sndex], isPutOn, item.sj)
}
2025-04-29 14:02:21 +08:00
this.$set(this.goodList[index].showList, sndex, sld)
})
2025-03-23 09:18:42 +08:00
}
// 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
// }
// }
2025-04-29 14:02:21 +08:00
})
})
2025-03-23 09:18:42 +08:00
// this.selCheckList
// console.log(this.$refs.multipleTable)
// this.$set('this','goodList',this.goodList)
2025-04-29 14:02:21 +08:00
this.$forceUpdate()
2025-03-23 09:18:42 +08:00
this.$nextTick(() => {
for (var i = 0; i < this.$refs.multipleTable.length; i++) {
2025-04-29 14:02:21 +08:00
this.$refs.multipleTable[i].clearSelection()
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
},
compareArrays(arr1, arr2) {
if (arr1.length !== arr2.length) {
2025-04-29 14:02:21 +08:00
return false
2025-03-23 09:18:42 +08:00
}
for (let i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) {
2025-04-29 14:02:21 +08:00
return false
2025-03-23 09:18:42 +08:00
}
}
2025-04-29 14:02:21 +08:00
return true
2025-03-23 09:18:42 +08:00
},
getData(data, specialArea) {
2025-04-29 14:02:21 +08:00
this.specialArea = specialArea
2025-03-23 09:18:42 +08:00
// 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) {
2025-04-29 14:02:21 +08:00
const a = this.compareArrays(this.productIds, data)
2025-03-23 09:18:42 +08:00
if (a) {
} else {
2025-04-29 14:02:21 +08:00
this.getList(data)
this.$store.commit('settings/GGMX_SETTING', data)
2025-03-23 09:18:42 +08:00
}
} else {
2025-04-29 14:02:21 +08:00
this.getList(data)
this.$store.commit('settings/GGMX_SETTING', data)
2025-03-23 09:18:42 +08:00
}
},
getList(data) {
getProductSpecsIsGift({ productGiftList: data }).then((res) => {
2025-04-29 14:02:21 +08:00
const arr = res.data
2025-03-23 09:18:42 +08:00
// 获取数据重组数组
2025-04-29 14:02:21 +08:00
const allData = []
2025-03-23 09:18:42 +08:00
arr.forEach((item, index) => {
2025-04-29 14:02:21 +08:00
item.checked = []
2025-03-23 09:18:42 +08:00
allData.push({
productId: item.productId,
productCode: item.productCode,
productCover: item.productCover,
isGift: item.isGift,
productName: item.productName,
2025-04-29 14:02:21 +08:00
selList: []
})
2025-03-23 09:18:42 +08:00
item.specsTypeData.forEach((cld) => {
allData[index].selList.push({
pkId: cld.pkId,
typeName: cld.typeName,
2025-04-29 14:02:21 +08:00
selData: []
})
})
})
this.allData = allData
this.goodList = arr
2025-03-23 09:18:42 +08:00
if (this.waresSpecsSkuList.length > 0) {
2025-04-29 14:02:21 +08:00
this.checkedBox()
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
},
checkedBox() {
this.waresSpecsSkuList.forEach((item) => {
2025-04-29 14:02:21 +08:00
item.specsIdList = []
2025-03-23 09:18:42 +08:00
item.waresSpecsList.forEach((ctm) => {
2025-04-29 14:02:21 +08:00
item.specsIdList.push(ctm.pkSpecs)
})
})
const arr = []
2025-03-23 09:18:42 +08:00
// getCheckBox(check, goodsId, pkId, sld) {
this.waresSpecsSkuList.forEach((item) => {
item.waresSpecsList.forEach((ctm) => {
// this.getCheckBox(true,item.pkProduct,ctm.pkSpecsType,{pkSpecs})
2025-04-29 14:02:21 +08:00
ctm.value = ctm.specsName
ctm.specsId = ctm.pkSpecs
2025-03-23 09:18:42 +08:00
arr.push({
pkProduct: item.pkProduct,
isGift: item.isGift,
pkSpecsType: ctm.pkSpecsType,
tt: ctm,
2025-04-29 14:02:21 +08:00
pkSpecs: ctm.pkSpecs
})
})
})
2025-03-23 09:18:42 +08:00
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
) {
// 判断连个值是否相等
2025-04-29 14:02:21 +08:00
arr.splice(j, 1) // 相等删除后者
j--
2025-03-23 09:18:42 +08:00
}
}
}
arr.forEach((item) => {
this.getCheckBox(
true,
item.pkProduct,
item.pkSpecsType,
item.tt,
item.isGift
2025-04-29 14:02:21 +08:00
)
})
2025-03-23 09:18:42 +08:00
this.goodList.forEach((item) => {
if (item.showList) {
item.showList.forEach((ctm) => {
2025-04-29 14:02:21 +08:00
this.$set(ctm, 'productPrice', 0)
2025-03-23 09:18:42 +08:00
// 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()
) {
2025-04-29 14:02:21 +08:00
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)
2025-03-23 09:18:42 +08:00
// ctm.integral = stm.integral
// ctm.isPutOn = stm.isPutOn
// ctm.specCover = stm.specCover
2025-04-29 14:02:21 +08:00
this.$forceUpdate()
2025-03-23 09:18:42 +08:00
}
}
2025-04-29 14:02:21 +08:00
})
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
this.goodList.forEach((item) => {
this.waresSpecsSkuList.forEach((ctm) => {
ctm.waresSpecsList.forEach((stm) => {
if (item.productId == ctm.pkProduct && item.isGift == ctm.isGift) {
2025-04-29 14:02:21 +08:00
item.checked.push(stm.pkSpecs)
item.checked = this.unique(item.checked.sort())
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
})
})
2025-03-23 09:18:42 +08:00
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) {
2025-04-29 14:02:21 +08:00
sstem.disabled = true
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
})
})
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
})
2025-03-23 09:18:42 +08:00
}
},
tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 == 1) {
2025-04-29 14:02:21 +08:00
return 'warning-row'
2025-03-23 09:18:42 +08:00
} else if (rowIndex % 2 == 0) {
2025-04-29 14:02:21 +08:00
return 'success-row'
2025-03-23 09:18:42 +08:00
}
2025-04-29 14:02:21 +08:00
return ''
}
}
}
2025-03-23 09:18:42 +08:00
</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>