Merge branch 'master' of https://gitee.com/beijing_hongye_huicheng/lilishop-ui
commit
248c4031c0
|
@ -444,7 +444,7 @@ export default {
|
||||||
addSettlementBtn: true, // 添加结算日按钮
|
addSettlementBtn: true, // 添加结算日按钮
|
||||||
day: 1, //结算日
|
day: 1, //结算日
|
||||||
tabName: "base", // tab栏name值
|
tabName: "base", // tab栏name值
|
||||||
tabNameList: ["base", "entry", "category", "send", "settlement"], // tab栏name值数组
|
tabNameList: ["base", "entry", "category", "settlement"], // tab栏name值数组
|
||||||
shopValidate: {
|
shopValidate: {
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
memberName: [{ required: true, message: "会员不能为空" }],
|
memberName: [{ required: true, message: "会员不能为空" }],
|
||||||
|
|
|
@ -274,7 +274,10 @@
|
||||||
placeholder="请输入规格名称"
|
placeholder="请输入规格名称"
|
||||||
:filter-method="filterMethod"
|
:filter-method="filterMethod"
|
||||||
:data="skuData"
|
:data="skuData"
|
||||||
@on-change="editSkuItem"
|
@on-focus="changeSkuItem(item.name)"
|
||||||
|
@on-change="
|
||||||
|
editSkuItem(item.name, $index, item)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
</AutoComplete>
|
</AutoComplete>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
@ -297,10 +300,8 @@
|
||||||
placeholder="请输入规格项"
|
placeholder="请输入规格项"
|
||||||
:filter-method="filterMethod"
|
:filter-method="filterMethod"
|
||||||
:data="skuVal"
|
:data="skuVal"
|
||||||
@on-focus="changeSkuVals(item.name)"
|
@on-focus="changeSkuVals(val, item.name)"
|
||||||
@on-change="
|
@on-change="skuValueChange(val, index, item)"
|
||||||
skuValueChange(val.value, index, item)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
</AutoComplete>
|
</AutoComplete>
|
||||||
<Button
|
<Button
|
||||||
|
@ -1298,24 +1299,55 @@ export default {
|
||||||
this.$Message.error("规格项不能大于5个!");
|
this.$Message.error("规格项不能大于5个!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.skuInfo.find((i) => i.name === "")) {
|
||||||
|
this.$Message.error("规格项不能为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 写入对象,下标,具体对象
|
// 写入对象,下标,具体对象
|
||||||
let num = this.global++;
|
let num = this.global++;
|
||||||
this.$set(this.skuInfo, this.skuInfo.length, {
|
this.$set(this.skuInfo, this.skuInfo.length, {
|
||||||
spec_values: [{ name: "规格名" + num, value: "" }],
|
spec_values: [{ name: "" + num, value: "" }],
|
||||||
name: "规格名" + num,
|
name: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
this.renderTableData(this.skuTableData);
|
this.renderTableData(this.skuTableData);
|
||||||
},
|
},
|
||||||
|
changeSkuItem(val) {
|
||||||
|
this.currentSkuItem = val;
|
||||||
|
},
|
||||||
// 编辑规格名
|
// 编辑规格名
|
||||||
editSkuItem() {
|
editSkuItem(val, index, item) {
|
||||||
|
if (this.skuTableData.find((i) => i[val])) {
|
||||||
|
this.$Message.error("已存在相同规格项!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.skuTableData = this.skuTableData.map((e) => {
|
||||||
|
e[val] = e[this.currentSkuItem];
|
||||||
|
delete e[this.currentSkuItem];
|
||||||
|
return e;
|
||||||
|
});
|
||||||
|
this.currentSkuItem = val;
|
||||||
this.renderTableData(this.skuTableData);
|
this.renderTableData(this.skuTableData);
|
||||||
},
|
},
|
||||||
// 编辑规格值
|
// 编辑规格值
|
||||||
async skuValueChange(val, index, item) {
|
skuValueChange(val, index, item) {
|
||||||
|
console.log("currentSkuVal: " + this.currentSkuVal);
|
||||||
|
if (this.skuTableData.find((i) => i[val.name] === val.value)) {
|
||||||
|
this.$Message.error("已存在相同规格值!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.skuTableData = this.skuTableData.map((e) => {
|
||||||
|
if (e[val.name] === this.currentSkuVal) {
|
||||||
|
e[val.name] = val.value;
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
});
|
||||||
|
this.currentSkuVal = val.value;
|
||||||
this.renderTableData(this.skuTableData);
|
this.renderTableData(this.skuTableData);
|
||||||
},
|
},
|
||||||
// 获取焦点时,取得规格名对应的规格值
|
// 获取焦点时,取得规格名对应的规格值
|
||||||
changeSkuVals(name) {
|
changeSkuVals(val, name) {
|
||||||
|
this.currentSkuVal = val.value;
|
||||||
if (name) {
|
if (name) {
|
||||||
this.skuData.forEach((e, index) => {
|
this.skuData.forEach((e, index) => {
|
||||||
if (e === name) {
|
if (e === name) {
|
||||||
|
@ -1328,10 +1360,15 @@ export default {
|
||||||
},
|
},
|
||||||
/** 移除当前规格项 进行数据变化*/
|
/** 移除当前规格项 进行数据变化*/
|
||||||
handleCloseSkuItem($index, item) {
|
handleCloseSkuItem($index, item) {
|
||||||
|
if ($index === 0 && this.skuInfo.length === 1) {
|
||||||
|
this.skuInfo = [];
|
||||||
|
this.skuTableData = [];
|
||||||
|
} else {
|
||||||
this.skuInfo.splice($index, 1);
|
this.skuInfo.splice($index, 1);
|
||||||
this.skuTableData.forEach((e, index) => {
|
this.skuTableData.forEach((e, index) => {
|
||||||
delete e[item.name];
|
delete e[item.name];
|
||||||
});
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 渲染规格详细表格
|
* 渲染规格详细表格
|
||||||
*/
|
*/
|
||||||
|
@ -1359,7 +1396,6 @@ export default {
|
||||||
this.$Message.error("规格值不能大于10个!");
|
this.$Message.error("规格值不能大于10个!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$set(item.spec_values, item.spec_values.length, {
|
this.$set(item.spec_values, item.spec_values.length, {
|
||||||
name: item.name,
|
name: item.name,
|
||||||
value: "",
|
value: "",
|
||||||
|
@ -1493,6 +1529,11 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.log("=====result=====");
|
||||||
|
// console.log(JSON.parse(JSON.stringify(result)));
|
||||||
|
// console.log("=====cloneTemp=====");
|
||||||
|
// console.log(JSON.parse(JSON.stringify(cloneTemp)));
|
||||||
cloneTemp.splice(0, 1);
|
cloneTemp.splice(0, 1);
|
||||||
result = this.specIterator(result, cloneTemp, skus);
|
result = this.specIterator(result, cloneTemp, skus);
|
||||||
this.skuTableData = result;
|
this.skuTableData = result;
|
||||||
|
@ -1510,25 +1551,33 @@ export default {
|
||||||
// console.log(JSON.parse(JSON.stringify(result)));
|
// console.log(JSON.parse(JSON.stringify(result)));
|
||||||
// console.log("-----cloneTemp-----");
|
// console.log("-----cloneTemp-----");
|
||||||
// console.log(JSON.parse(JSON.stringify(cloneTemp)));
|
// console.log(JSON.parse(JSON.stringify(cloneTemp)));
|
||||||
|
let empotyKey1 = "";
|
||||||
//是否还可以循环
|
//是否还可以循环
|
||||||
if (cloneTemp.length > 0) {
|
if (cloneTemp.length > 0) {
|
||||||
let table = [];
|
let table = [];
|
||||||
// 已有数据索引
|
// 已有数据索引
|
||||||
let findIndex = 0;
|
let findIndex = 0;
|
||||||
result.forEach((resItem, index) => {
|
result.forEach((resItem, index) => {
|
||||||
|
empotyKey1 = Object.keys(resItem).find(ke => resItem[ke] === "");
|
||||||
cloneTemp[0].spec_values.forEach((valItem, _index) => {
|
cloneTemp[0].spec_values.forEach((valItem, _index) => {
|
||||||
let obj = cloneObj(resItem);
|
let obj = cloneObj(resItem);
|
||||||
|
let containsEmptyValue =
|
||||||
|
valItem.value === "" || (!!empotyKey1 && obj[empotyKey1] === "");
|
||||||
|
// let containsEmptyValue = !!Object.values(obj).find(l => l === "");
|
||||||
|
// console.log(obj);
|
||||||
|
// console.log("-=-=-=-=-=-=-=-=-=-=-=-");
|
||||||
|
|
||||||
// 判断已存在数据数量是否大于渲染数据数量(认为是在编辑原存在数据的规格值)且规格值不为空且存在已存在数据,如符合条件,则认为为修改已存在数据
|
// 判断已存在数据数量是否大于渲染数据数量(认为是在编辑原存在数据的规格值)且规格值不为空且存在已存在数据,如符合条件,则认为为修改已存在数据
|
||||||
if (
|
if (
|
||||||
skus.length > result.length &&
|
skus.length > result.length &&
|
||||||
valItem.value !== "" &&
|
!containsEmptyValue &&
|
||||||
skus[findIndex]
|
skus[findIndex]
|
||||||
) {
|
) {
|
||||||
obj = cloneObj(skus[findIndex]);
|
obj = cloneObj(skus[findIndex]);
|
||||||
}
|
}
|
||||||
let emptyFlag = false;
|
let emptyFlag = false;
|
||||||
// 判断是否为规格项的第一个值,如果不为第一个值则判断为新加数据
|
// 判断是否为规格项的第一个值,如果不为第一个值则判断为新加数据
|
||||||
if (cloneTemp[0].spec_values.length > 1 && valItem.value === "") {
|
if (cloneTemp[0].spec_values.length > 1 && containsEmptyValue) {
|
||||||
delete obj.id;
|
delete obj.id;
|
||||||
delete obj.sn;
|
delete obj.sn;
|
||||||
delete obj.quantity;
|
delete obj.quantity;
|
||||||
|
@ -1550,7 +1599,7 @@ export default {
|
||||||
skus &&
|
skus &&
|
||||||
skus[findIndex] &&
|
skus[findIndex] &&
|
||||||
(!skus[findIndex].id || obj.id === skus[findIndex].id) &&
|
(!skus[findIndex].id || obj.id === skus[findIndex].id) &&
|
||||||
valItem.value !== "" &&
|
!containsEmptyValue &&
|
||||||
!emptyFlag
|
!emptyFlag
|
||||||
) {
|
) {
|
||||||
// 将原存在的数据放入结果中
|
// 将原存在的数据放入结果中
|
||||||
|
@ -1563,6 +1612,7 @@ export default {
|
||||||
weight: obj.weight || originSku.weight,
|
weight: obj.weight || originSku.weight,
|
||||||
...obj,
|
...obj,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (
|
if (
|
||||||
originSku[valItem.name] === valItem.value ||
|
originSku[valItem.name] === valItem.value ||
|
||||||
(obj.id && originSku.id === obj.id)
|
(obj.id && originSku.id === obj.id)
|
||||||
|
@ -1580,25 +1630,24 @@ export default {
|
||||||
if (
|
if (
|
||||||
skus.length > result.length &&
|
skus.length > result.length &&
|
||||||
skus[findIndex] &&
|
skus[findIndex] &&
|
||||||
valItem.value !== ""
|
!containsEmptyValue
|
||||||
) {
|
) {
|
||||||
findIndex++;
|
findIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj[cloneTemp[0].name] = valItem.value;
|
obj[cloneTemp[0].name] = valItem.value;
|
||||||
|
// console.log(resItem);
|
||||||
|
// console.log(obj);
|
||||||
table.push(obj);
|
table.push(obj);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
result = [];
|
result = table;
|
||||||
table.forEach((t) => {
|
|
||||||
result.push(t);
|
|
||||||
});
|
|
||||||
//清除当前循环的分组
|
//清除当前循环的分组
|
||||||
cloneTemp.splice(0, 1);
|
cloneTemp.splice(0, 1);
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return this.specIterator(result, cloneTemp, skus);
|
return this.specIterator(result, cloneTemp, skus, empotyKey1);
|
||||||
},
|
},
|
||||||
/** 根据分类id获取系统设置规格信息*/
|
/** 根据分类id获取系统设置规格信息*/
|
||||||
Get_SkuInfoByCategory(categoryId) {
|
Get_SkuInfoByCategory(categoryId) {
|
||||||
|
|
Loading…
Reference in New Issue