修改价格

This commit is contained in:
余同学 2024-08-13 18:03:15 +08:00
parent d67293dc4d
commit e16665cff0
4 changed files with 460 additions and 71 deletions

View File

@ -1,5 +1,5 @@
import $http from '@/utils/httpRequest.js'
import city_data from '@/utils/country-level2-data.js'
import $http from "@/utils/httpRequest.js";
import city_data from "@/utils/country-level2-data.js";
export const mer_admin = {
/**
@ -16,14 +16,14 @@ export const mer_admin = {
loginByAccount: (params) => {
return $http.post(`/auth/login`, {
...params,
type: 1
})
type: 1,
});
},
loginByMobile: (params) => {
return $http.post(`/merchant-api/auth/sms/login`, {
...params,
type: 2
})
type: 2,
});
},
getYZM(mobile) {
return $http.get(`/merchant-api/auth/login/code?mobile=${mobile}`);
@ -46,22 +46,41 @@ export const mer_admin = {
},
//商品分页
getProductPage: (data) => {
return $http.post(`/merchant-api/product/page`, data);
return $http.post(
`/merchant-api/product/page?pageNumber=${data.p.pageNumber}&pageSize=${data.p.pageSize}`,
data
);
},
//商户商品分类
getProductCategory: () => {
return $http.get(`/merchant-api/product/category/list?shopId=${JSON.parse(sessionStorage.getItem('userInfo')).shopId}`);
return $http.get(
`/merchant-api/product/category/list?shopId=${
JSON.parse(sessionStorage.getItem("userInfo")).shopId
}`
);
},
//批量删除商品
BatchDeleteProducts: (data) => {
return $http.post(`/merchant-api/product/batch/delete`, data);
},
//上架或下架商品
putOnShelvesProducts: (data) => {
return $http.post(`/merchant-api/product/batch/update/status`, data);
},
//获取销售单位
getSaleUnit: (data) => {
return $http.request({ url: `/merchant-api/product/unit/list`, method: 'get', params: data });
return $http.request({
url: `/merchant-api/product/unit/list`,
method: "get",
params: data,
});
},
//文件上传
uploadFile: () => {
return `${window.SITE_CONFIG['baseUrl']}/merchant-api/file/upload`
return `${window.SITE_CONFIG["baseUrl"]}/merchant-api/file/upload`;
},
//直接获取城市数据
getCityOptions: () => {
return city_data;
}
}
},
};

View File

@ -1,10 +1,13 @@
<template>
<div>
<div style="height: calc(100vh - 200px)">
<obj-table-plus
ref="oTable"
style="height: 100%"
:tableCols="tableCols"
:tableProp="tableProp"
@query="queryList"
v-model="dataList"
:tableEvent="tableEvent"
>
<template slot="tableTop">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
@ -42,17 +45,28 @@
<el-button type="primary" size="small" @click="addProduct"
>添加商品</el-button
>
<el-button
:disabled="selectList.length <= 0"
type="danger"
size="small"
@click="deleteProduct"
>批量删除</el-button
>
</div>
</template>
</obj-table-plus>
<!-- 添加或编辑 -->
<add-or-update ref="addOrUpdate"></add-or-update>
<!-- 改价格 -->
<AddPrice ref="AddPrice" @queryList="$refs.oTable.reload()"></AddPrice>
</div>
</template>
<script>
import AddPrice from "./popup/add-price.vue";
import AddOrUpdate from "./popup/add-or-update.vue";
export default {
components: { AddOrUpdate },
components: { AddOrUpdate, AddPrice },
data() {
return {
activeName: "出售中",
@ -61,13 +75,42 @@ export default {
user: "",
region: "",
},
tableProp: {
"auto-resize": true,
border: true,
height: "auto",
"row-id": "id",
},
productFilterType: "SALE",
selectList: [],
};
},
methods: {
addProduct() {
this.$refs.addOrUpdate.toggle().add();
},
deleteProduct() {
console.log(this.selectList);
let integers = this.selectList.map((item) => {
return item.id;
});
this.$confirm("此操作将删除该商品, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$api.mer_admin.BatchDeleteProducts(integers).then((res) => {
this.$refs.oTable.reload();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
queryList(pageNo, pageSize) {
this.$api.mer_admin
.getProductPage({
@ -109,32 +152,166 @@ export default {
computed: {
tableCols() {
return [
{
title: "ID",
},
{ type: "checkbox", width: "60px", fixed: "left" },
// { type: "seq", width: "60px", align: "center", title: "" },
{
title: "商品图",
field: "productPhotoList",
align: "center",
width: "160px",
type: "jsx",
render: ({ row }) => {
if (row.productPhotoList.length > 0) {
return <el-image src={row.productPhotoList[0].url}></el-image>;
} else {
return <span>暂无商品图</span>;
}
},
},
{
title: "商品名称",
align: "center",
field: "name",
},
{
title: "商品售价",
align: "center",
field: "minSalePrice",
type: "jsx",
render: ({ row }) => {
if (row.minSalePrice == row.maxSalePrice) {
return <span>{row.minSalePrice}</span>;
} else {
return (
<span>
{row.minSalePrice}~{row.maxSalePrice}
</span>
);
}
},
},
{
title: "销量",
align: "center",
field: "saleNum",
},
{
title: "库存",
align: "center",
field: "stockNum",
},
{
title: "状态",
// fixed: "right",
type: "jsx",
align: "center",
"title-suffix": {
message: "点击上架/下架切换责任书状态",
icon: "vxe-icon-question-circle-fill",
},
render: ({ row }) => {
let Enable = () => {
let data = {
ids: [row.id],
status: "UP",
};
if (row.status == "UP") {
data.status = "DOWN";
} else {
data.status = "UP";
}
this.$api.mer_admin.putOnShelvesProducts(data).then((res) => {
console.log(res);
this.$refs.oTable.reload();
});
};
return (
<el-popconfirm
title={
row.status == "DOWN"
? "当前为下架状态,是否更改为上架状态?"
: "当前为上架状态,是否更改为下架状态?"
}
confirmButtonText={
row.status == "DOWN" ? "确认上架" : "确认下架"
}
onConfirm={Enable}
>
<el-button
slot="reference"
size="mini"
plain
type={row.status == "DOWN" ? "info" : "success"}
>
{row.status == "DOWN" ? "已下架" : "上架中"}
</el-button>
</el-popconfirm>
);
},
},
{
title: "操作",
fixed: "right",
type: "jsx",
align: "center",
width: "340px",
render: ({ row }) => {
const grant = () => {};
let edit = () => {};
let priceAdjustment = () => {
console.log(row);
this.$refs.AddPrice.toggle(row).update();
};
return (
<div>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
onClick={edit}
>
编辑
</el-button>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
onClick={priceAdjustment}
>
改价
</el-button>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
onClick={grant}
>
改库存
</el-button>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
onClick={grant}
>
设置折扣
</el-button>
</div>
);
},
},
];
},
tableEvent() {
return {
"checkbox-all": ({ records, reserves }) => {
this.selectList = [...records, ...reserves];
},
"checkbox-change": ({ records, reserves }) => {
this.selectList = [...records, ...reserves];
},
};
},
},
};
</script>

View File

@ -10,7 +10,7 @@
:modalHandles="modalHandles"
>
<template slot="dialog__before">
<el-tabs v-model="currentPanel">
<el-tabs :before-leave="beforeTabLeave" v-model="currentPanel">
<el-tab-pane label="基础信息" name="基础信息"></el-tab-pane>
<el-tab-pane label="销售信息" name="销售信息"></el-tab-pane>
<el-tab-pane label="其他信息" name="其他信息"></el-tab-pane>
@ -147,6 +147,7 @@ export default {
},
fileList: [], //
place: "", //
passCheck: [], //
};
},
mounted() {},
@ -235,6 +236,13 @@ export default {
];
console.log(this.modalData);
},
beforeTabLeave(activeName) {
let state = "";
this.$refs.modal.validate((valid) => {
state = valid;
});
return state;
},
},
computed: {
modalCols() {

View File

@ -0,0 +1,185 @@
<template>
<div>
<obj-modal
ref="modal"
labelWidth="100px"
:modalConfig="modalConfig"
:modalCols="modalCols"
:modalData="modalData"
:modalHandles="modalHandles"
>
<obj-table-plus
v-show="tableData.length > 1"
style="height: calc(100vh - 120px - 240px)"
slot="dialog__after"
ref="oTable"
:toolbarProp="{}"
@query="queryTableData"
v-model="tableData"
:tableCols="tableCols"
:tableProp="tableProp"
:tableEvent="tableEvent"
:isPagination="false"
:enableAutoQuery="false"
>
</obj-table-plus>
</obj-modal>
</div>
</template>
<script>
import { debounce, cloneDeep } from "lodash";
export default {
components: {},
data() {
return {
isAdd: true,
//
tableData: [],
//
tableProp: {
height: "auto",
border: true,
"auto-resize": false,
"print-config": {},
},
toolbarProp: {},
tableEvent: {},
modalConfig: {
title: "修改价格",
show: false,
width: "60%",
},
modalData: {},
};
},
methods: {
queryTableData(pageNo, pageSize) {},
toggle(e) {
if (this.modalConfig.show == false) {
this.modalConfig.show = true;
this.$nextTick(() => {
this.$refs.oTable.doLayout();
});
} else {
this.modalConfig.show = false;
}
if (e) {
this.init(cloneDeep(e));
}
return {
add: () => {
this.modalData = {};
this.$nextTick(() => {
this.$refs.oTable.complete(false);
});
},
update: () => {
this.isAdd = false;
},
};
},
init(row) {
this.modalData = row;
this.tableData = row.productSpecificationList;
console.log(this.modalData);
},
},
computed: {
modalCols() {
if (this.tableData.length == 1) {
return [
{
label: "价格",
prop: "",
type: "Input",
width: "300px",
rules: { required: true, message: "请输入价格" },
type: "jsx",
render: () => {
return (
<el-input-number
v-model={this.modalData.productSpecificationList[0].salePrice}
min={0}
label="描述文字"
></el-input-number>
);
},
},
];
}
},
tableCols() {
return [
{
title: "序号",
type: "seq",
width: "60px",
align: "center",
},
{
title: "规格",
field: "attributeValue",
align: "center",
},
{
title: "价格",
field: "salePrice",
align: "center",
type: "jsx",
render: ({ row }) => {
return (
<div>
<el-input-number
min={0}
size="small"
v-model={row.salePrice}
placeholder="请输入数量"
></el-input-number>
</div>
);
},
},
];
},
modalHandles() {
return [
{
label: "取消",
handle: debounce(() => {
this.toggle();
}, 300),
},
{
label: this.isAdd ? "确认添加" : "确认编辑",
type: "primary",
submit: true,
handle: debounce(() => {
if (this.tableData.length == 1) {
this.$api.mer_admin
.saveProductBase(this.modalData)
.then((res) => {
console.log(res);
this.toggle();
this.$emit("queryList");
});
} else {
this.modalData.productSpecificationList = this.tableData;
this.$api.mer_admin
.saveProductBase(this.modalData)
.then((res) => {
console.log(res);
this.toggle();
this.$emit("queryList");
});
}
console.log(this.modalData);
}, 300),
},
];
},
},
asyncComputed: {},
};
</script>
<style lang="scss" scoped>
</style>