Browse Source

去掉商品管理没有物料分类id提示和限制

hcf 1 year ago
parent
commit
6c8b1e3e52
1 changed files with 64 additions and 13 deletions
  1. 64 13
      src/views/audit/productManagement/index.vue

+ 64 - 13
src/views/audit/productManagement/index.vue

@@ -1211,6 +1211,19 @@
 						}
 					}).catch(() => loading.close());
 				}
+				
+				this.intercept = data.attributeId // 拦截物料属性判断
+				this.isEdit = true;
+				this.editInfo = data;
+				this.isShow = 'add';
+				// 标签
+				if (data.tags) {
+					this.tagsData = data.tags.split(",")
+				} else this.tagsData = [];
+				this.materialSpec = data.materialSpec
+				this.isSingle = data.materialSpec === 0 ? true : false;
+				if (data.attributeList) this.attributeList = JSON.parse(data.attributeList);
+				 
 				if (data.categoryId) {
 					api.single({ id: data.categoryId }, 'maindataMaterialCategory').then((res : any) => {
 						if (res.code === 200) data.categoryName = res.data.name;
@@ -1221,17 +1234,6 @@
 								}
 							}).catch(() => loading.close());
 						}
-						this.intercept = data.attributeId // 拦截物料属性判断
-						this.isEdit = true;
-						this.editInfo = data;
-						this.isShow = 'add';
-						// 标签
-						if (data.tags) {
-							this.tagsData = data.tags.split(",")
-						} else this.tagsData = [];
-						this.materialSpec = data.materialSpec
-						this.isSingle = data.materialSpec === 0 ? true : false;
-						if (data.attributeList) this.attributeList = JSON.parse(data.attributeList);
 						other.selectByMaterialId({ id: data.id }, 'maindataMaterialSku').then((info : any) => {
 							if (info.code === 200) {
 								this.status = data.status
@@ -1283,8 +1285,57 @@
 						}).catch(() => loading.close());
 					}).catch(() => loading.close());
 				} else {
-					loading.close();
-					this.$message.error('该数据没有物料分类id')
+					// loading.close();
+					// this.$message.error('该数据没有物料分类id')
+					other.selectByMaterialId({ id: data.id }, 'maindataMaterialSku').then((info : any) => {
+						if (info.code === 200) {
+							this.status = data.status
+							console.log(data.ismakeup);
+							this.ismakeup = data.ismakeup
+							if (data.ismakeup === 0 && data.maindataMaterialLinks.length > 0) {
+								(this as any).makeupList = data.maindataMaterialLinks;
+								setTimeout(() => {
+									(this as any).$refs.makeupTable.setValue(data.maindataMaterialLinks) // 设置组合表格数据
+								})
+							}
+							this.issued = data.issued
+							if (this.isSingle) {
+								this.selectValue = '' // 物料属性名称
+								this.towTable = '' // 表格数据
+								this.attributeList = []; // 属性规格
+								this.$nextTick(() => {
+									(this as any).$refs.singeTable.setValue(info.data);
+								});
+							} else {
+								this.forFun(this.attributeList[0], 0) // 生成sku
+								let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
+								let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
+								let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
+								info.data.map((v : any, i : any) => {
+									v = Object.assign(v, skuRuleList[i])
+									v.dataIndex = i
+								});
+								newColumns.map((v : any) => {
+									tableConfig.columns.unshift({
+										width: '80px',
+										title: v.title,
+										field: v.field,
+									})
+								});
+								this.tableList = (this as any).$lodash.cloneDeep(info.data);
+								// console.log('表格配置 ==> ', tableConfig);
+								console.log('skuRuleList ==> ', skuRuleList);
+								console.log('表格数据 ==> ', this.tableList);
+								this.setTableConfig = tableConfig;
+								this.$nextTick(() => {
+									(this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
+									(this as any).$refs.table.setValue(this.tableList) // 设置表格数据
+								});
+							}
+						}
+						(this as any).$refs.form.setValue(data)
+						loading.close()
+					}).catch(() => loading.close());
 				}
 			}).catch(() => loading.close());
 		}