-
+
-
+
@@ -87,7 +87,7 @@
-
+
-
-
+
+
@@ -152,7 +152,7 @@
import { listBrand, getBrand, delBrand, addBrand, updateBrand } from "@/api/product/brand";
export default {
- name: "Brand",
+ namee: "Brand",
dicts: ['sys_yes_no'],
data() {
return {
@@ -178,7 +178,7 @@ export default {
queryParams: {
pageNum: 1,
pageSize: 10,
- nam: null,
+ name: null,
logo: null,
start: null,
introduction: null,
@@ -187,7 +187,7 @@ export default {
form: {},
// 表单校验
rules: {
- nam: [
+ name: [
{ required: true, message: "品牌名称不能为空", trigger: "blur" }
],
logo: [
@@ -227,7 +227,7 @@ export default {
reset() {
this.form = {
id: null,
- nam: null,
+ name: null,
logo: null,
start: null,
introduction: null,
diff --git a/src/views/product/category/index.vue b/src/views/product/category/index.vue
index 977dd35..728dc59 100644
--- a/src/views/product/category/index.vue
+++ b/src/views/product/category/index.vue
@@ -305,7 +305,8 @@ export default {
createBy: null,
createTime: null,
updateBy: null,
- updateTime: null
+ updateTime: null,
+ attributeIdList:[]
};
this.resetForm("form");
},
diff --git a/src/views/product/info/index.vue b/src/views/product/info/index.vue
index 9f94ae5..4cef2ae 100644
--- a/src/views/product/info/index.vue
+++ b/src/views/product/info/index.vue
@@ -183,11 +183,11 @@
- {{brand.nam}}
+ {{brand.name}}
@@ -229,7 +229,7 @@
属性组【{{templateAttributeGroup.groupName}}】
-
+
@@ -370,6 +370,7 @@ import {listBrand} from "@/api/product/brand";
import {getTemplateAttribute, listCategory} from "@/api/product/category";
import {listRule} from "@/api/product/rule";
import {addAttribute} from "@/api/product/attribute";
+import attribute from '@/views/product/attribute/index.vue'
export default {
name: "Info",
@@ -413,18 +414,34 @@ export default {
form: {},
// 表单校验
rules: {
- name:[
- { required: true, message: '请输入商品名称', trigger: 'blur' },
- { min: 2, max: 8, message: '长度在 2 到 8 个字符', trigger: 'blur' }
+ name: [
+ { required: true, message: "商品名称不能为空", trigger: "blur" }
],
- createBy: [
- { required: true, message: "创建人不能为空", trigger: "blur" }
+ status: [
+ { required: true, message: "商品状态不能为空", trigger: "blur" }
],
- createTime: [
- { required: true, message: "创建时间不能为空", trigger: "blur" }
+ brandId: [
+ { required: true, message: "商品品牌不能为空", trigger: "blur" }
+ ],
+ image: [
+ { required: true, message: "商品图片不能为空", trigger: "blur" }
+ ],
+ carouselImages: [
+ { required: true, message: "商品轮播图不能为空", trigger: "blur" }
+ ],
+ type: [
+ { required: true, message: "商品品类不能为空", trigger: "blur" }
+ ],
+ ruleId: [
+ { required: true, message: "商品规格不能为空", trigger: "blur" }
],
},
- stepNumber: 1,
+ rulesTemplateMap:{
+ 0: ["name", "status", "brandId", "image", "carouselImages"],
+ 1: ["type"],
+ 2: ["ruleId"],
+ },
+ stepNumber: 0,
brandList: [],
categoryOptions: [],
categoryOptionValue: [],
@@ -621,7 +638,16 @@ export default {
this.stepNumber--
},
next() {
- this.stepNumber++
+ let isValidate = true;
+ this.$refs["form"].validateField(this.rulesTemplateMap[this.stepNumber],(valid) => {
+ console.log(valid)
+ if (valid) {
+ isValidate = false;
+ }
+ });
+ if (isValidate){
+ this.stepNumber++
+ }
},
/** 查询商品信息列表 */
getList() {
@@ -697,6 +723,40 @@ export default {
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
+ let attrValueList = [];
+ for (const templateAttributeGroup of this.categoryCommonElement.templateAttributeGroupList) {
+ templateAttributeGroup.attributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
+ }
+
+ this.categoryCommonElement.templateAttributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
+ this.attributeCheckedList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
+ let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === this.form.ruleId);
+ const {ruleAttrList} = ruleInfo;
+ let ruleAttrSize = ruleAttrList.length;
+ let productSkuList = this.skuList.map(skuInfo => {
+ let sku = "";
+ for (let index = 0; ; index++) {
+ sku += skuInfo["prop"+index];
+ if (index+1 >= ruleAttrSize){
+ break;
+ }else {
+ sku += "-";
+ }
+ }
+ return {
+ sku: sku,
+ image: skuInfo.image,
+ stock: skuInfo.stock,
+ price: skuInfo.price
+ }
+ })
+ let productAddReq = {
+ projectAddModel: this.form,
+ attrValueList: attrValueList,
+ productSkuList: productSkuList
+ };
+ console.log(productAddReq)
+
if (this.form.id != null) {
updateInfo(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
@@ -704,7 +764,7 @@ export default {
this.getList();
});
} else {
- addInfo(this.form).then(response => {
+ addInfo(productAddReq).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();