This commit is contained in:
余同学 2024-08-15 18:01:50 +08:00
parent 4257afc7c6
commit 13a802f527
3 changed files with 107 additions and 26 deletions

View File

@ -56,7 +56,10 @@
</template> </template>
</obj-table-plus> </obj-table-plus>
<!-- 添加或编辑 --> <!-- 添加或编辑 -->
<add-or-update ref="addOrUpdate"></add-or-update> <add-or-update
@queryList="$refs.oTable.reload()"
ref="addOrUpdate"
></add-or-update>
<!-- 改价格 --> <!-- 改价格 -->
<AddPrice ref="AddPrice" @queryList="$refs.oTable.reload()"></AddPrice> <AddPrice ref="AddPrice" @queryList="$refs.oTable.reload()"></AddPrice>
<!-- 改库存 --> <!-- 改库存 -->
@ -276,8 +279,9 @@ export default {
align: "center", align: "center",
width: "340px", width: "340px",
render: ({ row }) => { render: ({ row }) => {
const grant = () => {}; let edit = () => {
let edit = () => {}; this.$refs.addOrUpdate.toggle(row).update();
};
let priceAdjustment = () => { let priceAdjustment = () => {
console.log(row); console.log(row);
this.$refs.AddPrice.toggle(row).update(); this.$refs.AddPrice.toggle(row).update();

View File

@ -151,6 +151,14 @@ export default {
}; };
}, },
mounted() {}, mounted() {},
watch: {
"modalConfig.show"(newVal) {
if (!newVal) {
this.currentPanel = "基础信息";
this.fileList = [];
}
},
},
methods: { methods: {
toggle(e) { toggle(e) {
if (this.modalConfig.show == false) { if (this.modalConfig.show == false) {
@ -160,12 +168,12 @@ export default {
} }
if (e) { if (e) {
console.log(e); console.log(e);
this.init(cloneDeep(e.row)); this.init(cloneDeep(e));
} }
return { return {
add: (item) => { add: () => {
console.log(item);
this.$nextTick(() => { this.$nextTick(() => {
this.modalConfig.title = "添加商品";
this.modalData = { this.modalData = {
description: "", description: "",
merchantId: "", merchantId: "",
@ -192,21 +200,41 @@ export default {
this.modalData.shopId = JSON.parse( this.modalData.shopId = JSON.parse(
sessionStorage.getItem("userInfo") sessionStorage.getItem("userInfo")
).shopId; ).shopId;
this.passCheck = [];
this.place = [];
}); });
console.log(this.modalData);
this.isAdd = true; this.isAdd = true;
}, },
update: (row) => { update: () => {
this.modalData = row; this.modalConfig.title = "编辑商品";
this.isAdd = false; this.isAdd = false;
}, },
}; };
}, },
init(row) {}, init(row) {
console.log(row);
this.fileList = row.productPhotoList.map((item) => {
return {
name: "",
url: item.url,
};
});
this.place = row.productPlace.split("-");
this.modalData = row;
},
addSpecs() { addSpecs() {
console.log("123"); console.log("123");
if (this.isAdd) {
this.$refs.addSpecifications.toggle().add(); this.$refs.addSpecifications.toggle().add();
} else {
this.$refs.addSpecifications
.toggle()
.update(
this.modalData.productAttributeList,
this.modalData.productSpecificationList
);
}
}, },
// //
getSpecs(tableData, AttributeData, salePrice, stockNum) { getSpecs(tableData, AttributeData, salePrice, stockNum) {
@ -216,8 +244,6 @@ export default {
attributeValue: item.attributeValue.join(","), attributeValue: item.attributeValue.join(","),
}; };
}); });
console.log(AttributeList);
this.$set(this.modalData, "productSpecificationList", tableData); this.$set(this.modalData, "productSpecificationList", tableData);
this.$set(this.modalData, "productAttributeList", AttributeList); this.$set(this.modalData, "productAttributeList", AttributeList);
this.$set(this.modalData, "singlePrice", salePrice); this.$set(this.modalData, "singlePrice", salePrice);
@ -236,9 +262,17 @@ export default {
]; ];
console.log(this.modalData); console.log(this.modalData);
}, },
beforeTabLeave(activeName) { beforeTabLeave(activeName, oldActiveName) {
if (this.passCheck.includes(activeName)) {
return true;
}
let state = ""; let state = "";
this.$refs.modal.validate((valid) => { this.$refs.modal.validate((valid) => {
if (valid) {
if (!this.passCheck.includes(oldActiveName)) {
this.passCheck.push(oldActiveName);
}
}
state = valid; state = valid;
}); });
return state; return state;
@ -270,16 +304,22 @@ export default {
if (index == 0) { if (index == 0) {
return { return {
isMain: 1, isMain: 1,
url: item.response.data, url: item.response ? item.response.data : item.url,
}; };
} else { } else {
return { return {
url: item.response.data, url: item.response ? item.response.data : item.url,
}; };
} }
} }
); );
console.log(this.modalData.productPhotoList); console.log(this.modalData.productPhotoList);
this.fileList = fileList.map((item) => {
return {
name: item.name,
url: item.response ? item.response.data : item.url,
};
});
}; };
const handleRemove = (file, fileList) => { const handleRemove = (file, fileList) => {
console.log(file, fileList); console.log(file, fileList);
@ -288,16 +328,22 @@ export default {
if (index == 0) { if (index == 0) {
return { return {
isMain: 1, isMain: 1,
url: item.response.data, url: item.url,
}; };
} else { } else {
return { return {
url: item.response.data, url: item.url,
}; };
} }
} }
); );
console.log(this.modalData.productPhotoList); console.log(this.modalData.productPhotoList);
this.fileList = fileList.map((item) => {
return {
name: item.name,
url: item.url,
};
});
}; };
return ( return (
<el-upload <el-upload
@ -316,6 +362,7 @@ export default {
}} }}
multiple={true} multiple={true}
file-list={this.fileList} file-list={this.fileList}
list-type="picture"
> >
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text"> <div class="el-upload__text">
@ -361,6 +408,7 @@ export default {
prop: "name", prop: "name",
type: "Input", type: "Input",
required: true, required: true,
maxlength: "30",
rules: { rules: {
required: true, required: true,
message: "请输入商品名称", message: "请输入商品名称",
@ -382,6 +430,7 @@ export default {
return ( return (
<el-input <el-input
type="textarea" type="textarea"
maxlength={100}
v-model={this.modalData.description} v-model={this.modalData.description}
placeholder="请简单描述,如别称、口感、用途等" placeholder="请简单描述,如别称、口感、用途等"
/> />
@ -412,7 +461,7 @@ export default {
return ( return (
<el-option <el-option
label={item.name} label={item.name}
value={item.id} value={item.name}
></el-option> ></el-option>
); );
})} })}
@ -490,7 +539,6 @@ export default {
const change = (e) => { const change = (e) => {
console.log(e); console.log(e);
this.modalData.productPlace = e.join("-"); this.modalData.productPlace = e.join("-");
console.log(aa);
}; };
return ( return (
<el-cascader <el-cascader
@ -637,7 +685,7 @@ export default {
modalHandles() { modalHandles() {
return [ return [
{ {
label: this.currentPanel === "其他信息" ? "确定" : "下一步", label: this.currentPanel === "其他信息" ? "立即上架" : "下一步",
type: "primary", type: "primary",
loading: this.isLoading, loading: this.isLoading,
submit: true, submit: true,
@ -650,10 +698,27 @@ export default {
console.log("请求接口", this.modalData); console.log("请求接口", this.modalData);
this.$api.mer_admin.saveProduct(this.modalData).then((res) => { this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
console.log(res); console.log(res);
this.$emit("queryList");
this.toggle();
}); });
} }
}, 300), }, 300),
}, },
{
disabled: () => this.currentPanel != "其他信息",
label: "放入仓库",
type: "primary",
loading: this.isLoading,
submit: true,
handle: debounce(() => {
this.modalData.status = "DOWN";
this.$api.mer_admin.saveProduct(this.modalData).then((res) => {
console.log(res);
this.$emit("queryList");
this.toggle();
});
}, 300),
},
]; ];
}, },
}, },

View File

@ -136,12 +136,22 @@ export default {
add: () => { add: () => {
this.modalConfig.title = "属性"; this.modalConfig.title = "属性";
this.$nextTick(() => { this.$nextTick(() => {
// this.$refs.modal.resetFields();
this.modalData = {}; this.modalData = {};
this.$refs.modal.resetFields();
}); });
this.isAdd = true; this.isAdd = true;
}, },
update: () => { update: (productAttributeList, productSpecificationList) => {
console.log(productAttributeList, productSpecificationList);
this.AttributeData = productAttributeList.map((item) => {
return {
attributeName: item.attributeName,
attributeValue: item.attributeValue.split(","),
id: item.id,
inputVisible: false,
};
});
this.tableData = productSpecificationList;
this.isAdd = false; this.isAdd = false;
}, },
}; };
@ -211,9 +221,9 @@ export default {
this.tableData = data.map((item) => { this.tableData = data.map((item) => {
return { return {
attributeValue: item, attributeValue: item,
salePrice: "", salePrice: 0,
costPrice: "", costPrice: 0,
stockNum: "", stockNum: 0,
}; };
}); });
console.log(data); console.log(data);
@ -259,6 +269,7 @@ export default {
<div> <div>
<el-input-number <el-input-number
min={0} min={0}
max={row.salePrice}
size="small" size="small"
v-model={row.costPrice} v-model={row.costPrice}
placeholder="请输入成本" placeholder="请输入成本"
@ -319,6 +330,7 @@ export default {
label: this.isAdd ? "确认添加" : "确认修改", label: this.isAdd ? "确认添加" : "确认修改",
type: "primary", type: "primary",
loading: this.isLoading, loading: this.isLoading,
disabled: () => this.tableData.length <= 0,
// submit: true, // submit: true,
handle: () => { handle: () => {
let salePrice = ""; // let salePrice = ""; //