Commit 7bc6fc8b by 前端

Merge branch 'SAAS+V5.8.5' into 'master'

上线合并

See merge request !97
2 parents 30021037 101f2687
...@@ -64,11 +64,11 @@ ...@@ -64,11 +64,11 @@
<td style="white-space: nowrap; text-overflow: ellipsis; overflow: hidden" <td style="white-space: nowrap; text-overflow: ellipsis; overflow: hidden"
v-for="(n, idx) in subItem.specsValueList" :key="idx" :title="n">{{ n }}</td> v-for="(n, idx) in subItem.specsValueList" :key="idx" :title="n">{{ n }}</td>
<td> <td>
<!-- @input="handleTypeInput($event, subIndex)" --> <!-- 使用 subItem.originalIndex 传递原始数组索引,避免索引错位 -->
<el-input placeholder="请输入" maxlength="20" :disabled="routeInfo.type == 2" size="small" <el-input placeholder="请输入" maxlength="20" :disabled="routeInfo.type == 2" size="small"
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.insuranceCost) && subItem.insuranceCostEmpty }" :class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.insuranceCost) && subItem.insuranceCostEmpty }"
v-model.trim="subItem.insuranceCost" @input="handleKilometersInput($event, subIndex)" v-model.trim="subItem.insuranceCost" @input="handleKilometersInput($event, subItem.originalIndex)"
@blur="handleKilometersBlur($event, subIndex)"> @blur="handleKilometersBlur($event, subItem.originalIndex)">
<el-popover v-if="filterEmpty(subItem.insuranceCost) && subItem.insuranceCostEmpty" slot="suffix" <el-popover v-if="filterEmpty(subItem.insuranceCost) && subItem.insuranceCostEmpty" slot="suffix"
placement="top" title width="90" trigger="hover" content="投保成本是必填项"> placement="top" title width="90" trigger="hover" content="投保成本是必填项">
<i class="el-icon-warning color-red" slot="reference" /> <i class="el-icon-warning color-red" slot="reference" />
...@@ -79,8 +79,8 @@ ...@@ -79,8 +79,8 @@
<el-input placeholder="请输入" maxlength="20" :disabled="routeInfo.type == 2" size="small" <el-input placeholder="请输入" maxlength="20" :disabled="routeInfo.type == 2" size="small"
v-model.trim="subItem.shelfCost" v-model.trim="subItem.shelfCost"
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.shelfCost) && subItem.shelfCostEmpty }" :class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.shelfCost) && subItem.shelfCostEmpty }"
@input="handleWarrantyPeriodInput($event, subIndex)" @input="handleWarrantyPeriodInput($event, subItem.originalIndex)"
@blur="handleWarrantyPeriodBlur($event, subIndex)"> @blur="handleWarrantyPeriodBlur($event, subItem.originalIndex)">
<el-popover v-if="filterEmpty(subItem.shelfCost) && subItem.salesCostEmpty" slot="suffix" <el-popover v-if="filterEmpty(subItem.shelfCost) && subItem.salesCostEmpty" slot="suffix"
placement="top" title width="90" trigger="hover" content="上架成本是必填项"> placement="top" title width="90" trigger="hover" content="上架成本是必填项">
<i class="el-icon-warning color-red" slot="reference" /> <i class="el-icon-warning color-red" slot="reference" />
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<el-input placeholder="请输入" maxlength="20" :disabled="routeInfo.type == 2" size="small" <el-input placeholder="请输入" maxlength="20" :disabled="routeInfo.type == 2" size="small"
v-model.trim="subItem.salesCost" v-model.trim="subItem.salesCost"
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.salesCost) && subItem.salesCostEmpty }" :class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.salesCost) && subItem.salesCostEmpty }"
@input="handlePurchasePrice($event, subIndex)" @blur="handlePurchasePriceBlur($event, subIndex)"> @input="handlePurchasePrice($event, subItem.originalIndex)" @blur="handlePurchasePriceBlur($event, subItem.originalIndex)">
<el-popover v-if="filterEmpty(subItem.salesCost) && subItem.salesCostEmpty" slot="suffix" <el-popover v-if="filterEmpty(subItem.salesCost) && subItem.salesCostEmpty" slot="suffix"
placement="top" title width="90" trigger="hover" content="嘀加成本是必填项"> placement="top" title width="90" trigger="hover" content="嘀加成本是必填项">
<i class="el-icon-warning color-red" slot="reference" /> <i class="el-icon-warning color-red" slot="reference" />
...@@ -291,8 +291,21 @@ export default { ...@@ -291,8 +291,21 @@ export default {
...mapGetters('goodsInfoData', { goodsInfoData: 'getGoodsInfoData' }), ...mapGetters('goodsInfoData', { goodsInfoData: 'getGoodsInfoData' }),
filterStatus() { filterStatus() {
console.log(this.goodsInfoData?.goodsSpecificationList, 'this.goodsInfoData?.goodsSpecificationList') console.log(this.goodsInfoData?.goodsSpecificationList, 'this.goodsInfoData?.goodsSpecificationList')
//过滤禁用状态 // 过滤禁用状态,并为每一行添加原始索引(参照 dj-car-life-system 的实现)
return this.goodsInfoData ? this.goodsInfoData?.goodsSpecificationList.filter(item => item.useStatus != 1) : [] if (!this.goodsInfoData?.goodsSpecificationList) return []
return this.goodsInfoData.goodsSpecificationList
.map((item, originalIndex) => {
// 为每一行添加原始索引,方便模板中使用
if (item.useStatus != 1) {
return {
...item,
originalIndex // 添加原始数组索引
}
}
return null
})
.filter(item => item !== null)
}, },
disabledSpecificationName() { disabledSpecificationName() {
return ( return (
...@@ -561,23 +574,23 @@ export default { ...@@ -561,23 +574,23 @@ export default {
// console.log('changeSpecs') // console.log('changeSpecs')
this.computedTableWidth(this.goodsInfoData.goodsType) this.computedTableWidth(this.goodsInfoData.goodsType)
console.log(this.goodsInfoData, 'goodsInfoData') console.log(this.goodsInfoData, 'goodsInfoData')
const copySpecificationValueList = JSON.parse(JSON.stringify(this.goodsInfoData.goodsSpecificationList)) const copySpecificationValueList = deepClone(this.goodsInfoData.goodsSpecificationList)
const copyDetailLength = this.goodsInfoData.goodsSpecificationNameList?.length const copyDetailLength = this.goodsInfoData.goodsSpecificationNameList?.length
const copyDetailData = this.goodsInfoData.goodsSpecificationNameList const copyDetailData = this.goodsInfoData.goodsSpecificationNameList
this.goodsInfoData.goodsSpecificationList = [] this.goodsInfoData.goodsSpecificationList = []
console.log(copySpecificationValueList, 'copySpecificationValueList') console.log(copySpecificationValueList, 'copySpecificationValueList')
let flag = true let flag = true
var markIdx = 0
for (var i = 0; i < this.goodsInfoData.specificationDetailList?.length; i++) { for (var i = 0; i < this.goodsInfoData.specificationDetailList?.length; i++) {
markIdx = 0
// 规格名有变化 需清空id // 规格名有变化 需清空id
if (copyDetailLength && this.goodsInfoData.specificationDetailList[i]?.specificationName !== copyDetailData[i]?.specificationName) { if (copyDetailLength && this.goodsInfoData.specificationDetailList[i]?.specificationName !== copyDetailData[i]?.specificationName) {
console.log(this.goodsInfoData.specificationDetailList[i]?.specificationName, copyDetailData[i]?.specificationName) console.log(this.goodsInfoData.specificationDetailList[i]?.specificationName, copyDetailData[i]?.specificationName)
flag = false flag = false
delete this.goodsInfoData.specificationDetailList[i]?.id delete this.goodsInfoData.specificationDetailList[i]?.id
} }
for (var j = 0; j < this.goodsInfoData.specificationDetailList[i]?.specificationValueList?.length; j++) { for (var j = 0; j < this.goodsInfoData.specificationDetailList[i]?.specificationValueList?.length; j++) {
if (i == 0) { if (i == 0) {
// 第一层规格:直接创建新行
this.goodsInfoData.goodsSpecificationList.push({ this.goodsInfoData.goodsSpecificationList.push({
id: '', id: '',
position: [], position: [],
...@@ -594,35 +607,50 @@ export default { ...@@ -594,35 +607,50 @@ export default {
shelfCost: '', // 上架成本,单位元 shelfCost: '', // 上架成本,单位元
salesCost: '', // salesCost salesCost: '', // salesCost
seriesConfigList: [], seriesConfigList: [],
useStatus: 0 useStatus: 0,
checked: false,
insuranceCostEmpty: false,
shelfCostEmpty: false,
salesCostEmpty: false
}) })
} else { } else {
var targetValLen = this.goodsInfoData.specificationDetailList[i]?.specificationValueList?.length // 非第一层规格:需要复制现有行并与新规格值组合
var loopNum = 0 const targetValLen = this.goodsInfoData.specificationDetailList[i]?.specificationValueList?.length
var tempMarkIdx = 0
// debugger if (j == 0) {
// 第一次进入:复制现有行,为后续规格值做准备
if (j == 0 && targetValLen > 1) { const currentLength = this.goodsInfoData.goodsSpecificationList.length
var obj = JSON.parse(JSON.stringify(this.goodsInfoData.goodsSpecificationList)) const newRows = []
console.log(obj, 'obj')
this.goodsInfoData.goodsSpecificationList = [] // 复制现有行 targetValLen 次
obj.forEach(item => { for (let k = 0; k < targetValLen; k++) {
for (var k = 0; k < targetValLen; k++) { this.goodsInfoData.goodsSpecificationList.forEach(item => {
this.goodsInfoData.goodsSpecificationList.push(JSON.parse(JSON.stringify(item))) newRows.push(deepClone({
} ...item,
}) specsValueList: [...item.specsValueList]
}))
})
}
// 清空并重新赋值
this.goodsInfoData.goodsSpecificationList = newRows
} }
loopNum = this.goodsInfoData.goodsSpecificationList.length / targetValLen
tempMarkIdx = markIdx // 为当前规格值位置的所有行添加规格值
for (var k = 0; k < loopNum; k++) { const currentLen = this.goodsInfoData.goodsSpecificationList.length
this.goodsInfoData.goodsSpecificationList[tempMarkIdx].specsValueList.push(this.goodsInfoData.specificationDetailList[i]?.specificationValueList[j]?.specificationValue) const step = Math.floor(currentLen / targetValLen)
tempMarkIdx = tempMarkIdx + targetValLen const startIdx = j * step
for (let k = startIdx; k < startIdx + step; k++) {
if (this.goodsInfoData.goodsSpecificationList[k]) {
this.goodsInfoData.goodsSpecificationList[k].specsValueList.push(
this.goodsInfoData.specificationDetailList[i]?.specificationValueList[j]?.specificationValue
)
}
} }
markIdx = markIdx + 1
} }
} }
} }
this.goodsInfoData.goodsSpecificationList.forEach(item => { this.goodsInfoData.goodsSpecificationList.forEach(item => {
for (var i = 0; i < copySpecificationValueList.length; i++) { for (var i = 0; i < copySpecificationValueList.length; i++) {
var temp = copySpecificationValueList[i] var temp = copySpecificationValueList[i]
...@@ -644,6 +672,10 @@ export default { ...@@ -644,6 +672,10 @@ export default {
item.useStatus = temp.useStatus item.useStatus = temp.useStatus
item.seriesConfigList = temp.seriesConfigList item.seriesConfigList = temp.seriesConfigList
item.specificationData = temp.specificationData item.specificationData = temp.specificationData
item.checked = temp.checked || false
item.insuranceCostEmpty = temp.insuranceCostEmpty || false
item.shelfCostEmpty = temp.shelfCostEmpty || false
item.salesCostEmpty = temp.salesCostEmpty || false
break break
} }
} }
...@@ -659,7 +691,6 @@ export default { ...@@ -659,7 +691,6 @@ export default {
}, },
// 校验采购价 // 校验采购价
handlePurchasePrice(newValue, index) { handlePurchasePrice(newValue, index) {
// subItem.salesCost) && subItem.salesCostEmpty
newValue = newValue.replace(/[^\d.]/g, '') newValue = newValue.replace(/[^\d.]/g, '')
let oldValue = `${this.goodsInfoData.goodsSpecificationList[index]['oldsalesCost']}` let oldValue = `${this.goodsInfoData.goodsSpecificationList[index]['oldsalesCost']}`
this.$set(this.goodsInfoData.goodsSpecificationList[index], 'salesCost', limitPrice(newValue, oldValue, 20, 2, 0)) this.$set(this.goodsInfoData.goodsSpecificationList[index], 'salesCost', limitPrice(newValue, oldValue, 20, 2, 0))
...@@ -671,7 +702,6 @@ export default { ...@@ -671,7 +702,6 @@ export default {
}, },
// 质保 // 质保
handleWarrantyPeriodInput(newValue, index) { handleWarrantyPeriodInput(newValue, index) {
// subItem.shelfCost) && subItem.salesCostEmpty
newValue = newValue.replace(/[^\d.]/g, '') newValue = newValue.replace(/[^\d.]/g, '')
let oldValue = `${this.goodsInfoData.goodsSpecificationList[index]['oldshelfCost']}` let oldValue = `${this.goodsInfoData.goodsSpecificationList[index]['oldshelfCost']}`
this.$set(this.goodsInfoData.goodsSpecificationList[index], 'shelfCost', limitPrice(newValue, oldValue, 20, 2, 0)) this.$set(this.goodsInfoData.goodsSpecificationList[index], 'shelfCost', limitPrice(newValue, oldValue, 20, 2, 0))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!