feat: pad点单设置修复

This commit is contained in:
YeMingfei666 2025-02-26 17:21:06 +08:00
parent 9cab42401a
commit 2763ee2a7a
4 changed files with 53 additions and 57 deletions

View File

@ -37,7 +37,15 @@ const API = {
method: "delete", method: "delete",
data: data, data: data,
}); });
} },
// pad布局列表
getLayout() {
return request<any>({
url: `${baseURL}/layout`,
method: "get",
});
},
} }
export default API; export default API;

View File

@ -1,11 +1,16 @@
<template> <template>
<el-dialog title="选择商品" top="5vh" v-model="dialogVisible"> <el-dialog title="选择商品" top="5vh" v-model="dialogVisible" @close="resetHandle">
<el-form :model="searhForm" inline> <el-form :model="searhForm" inline>
<el-form-item> <el-form-item>
<el-input v-model="searhForm.name" placeholder="商品名称"></el-input> <el-input v-model="searhForm.name" placeholder="商品名称"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-select v-model="searhForm.category" placeholder="商品分类" :disabled="disableCategory"> <el-select
style="width: 200px"
v-model="searhForm.category"
placeholder="商品分类"
:disabled="disableCategory"
>
<el-option <el-option
:label="item.name" :label="item.name"
:value="item.id" :value="item.id"
@ -110,7 +115,7 @@ export default {
}, },
categoryList: [], categoryList: [],
tableData: { tableData: {
page: 0, page: 1,
size: 10, size: 10,
total: 0, total: 0,
loading: false, loading: false,
@ -131,14 +136,14 @@ export default {
this.$emit("success", res); this.$emit("success", res);
this.close(); this.close();
}, },
// //
resetHandle() { resetHandle() {
this.searhForm.name = ""; this.searhForm.name = "";
this.searhForm.category = ""; this.searhForm.category = "";
this.tableData.page = 0; this.tableData.page = 1;
this.tableData.size = 10; this.tableData.size = 10;
this.tableData.list = []; this.tableData.list = [];
this.getTableData();
}, },
// //
sizeChange(e) { sizeChange(e) {
@ -147,7 +152,7 @@ export default {
}, },
// //
paginationChange(e) { paginationChange(e) {
this.tableData.page = e - 1; this.tableData.page = e;
this.getTableData(); this.getTableData();
}, },
// //
@ -160,8 +165,8 @@ export default {
name: this.searhForm.name, name: this.searhForm.name,
categoryId: this.searhForm.category, categoryId: this.searhForm.category,
}); });
this.tableData.list = res.content; this.tableData.list = res.records;
this.tableData.total = res.totalElements; this.tableData.total = res.totalRow;
if (this.goods.length) { if (this.goods.length) {
this.$nextTick(() => { this.$nextTick(() => {
@ -179,10 +184,10 @@ export default {
async tbShopCategoryGet() { async tbShopCategoryGet() {
try { try {
const res = await paoductCategoryApi.getPage({ const res = await paoductCategoryApi.getPage({
page: 0, page: 1,
size: 100, size: 600,
}); });
this.categoryList = res.content; this.categoryList = res.records;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@ -194,17 +199,12 @@ export default {
} else { } else {
this.goods = []; this.goods = [];
} }
this.resetHandle();
console.log(categoryId);
if (categoryId) { if (categoryId) {
this.searhForm.category = categoryId; this.searhForm.category = categoryId;
} }
console.log(this.searhForm);
await this.tbShopCategoryGet(); await this.tbShopCategoryGet();
await this.getTableData(); await this.getTableData();
}, },
close() { close() {

View File

@ -50,7 +50,7 @@
</div> </div>
<div class="tab" v-if="!preview"> <div class="tab" v-if="!preview">
<el-radio-group v-model="typeListActive" @change="tabChange"> <el-radio-group v-model="typeListActive" @change="tabChange">
<el-radio-button :label="item.id" v-for="item in typeList" :key="item.id"> <el-radio-button :value="item.id" v-for="item in typeList" :key="item.id">
{{ item.name }} {{ item.name }}
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
@ -61,16 +61,19 @@
<el-button type="primary" :loading="loading" @click="submitHandle"> </el-button> <el-button type="primary" :loading="loading" @click="submitHandle"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<GoodsSelect ref="refSelGoods"></GoodsSelect> <GoodsSelect
ref="refSelGoods"
radio
disableCategory
@success="selectConfirmGoods"
></GoodsSelect>
<!-- <shopList ref="shopList" disableCategory radio @success="selectConfirmGoods" /> --> <!-- <shopList ref="shopList" disableCategory radio @success="selectConfirmGoods" /> -->
</div> </div>
</template> </template>
<script> <script>
import { layoutList } from "./layout.js"; import { ElNotification } from "element-plus";
// import shopList from "@/components/shopList/index.vue"; import padApi from "@/api/account/padProd";
// import { tbProduct } from "@/api/shop.js";
// import { layoutlist, productGroup, productCategoryDetail, productGroupPut } from "@/api/pad.js";
export default { export default {
props: { props: {
category: { category: {
@ -88,7 +91,7 @@ export default {
id: "", id: "",
list: [], list: [],
}, },
typeListActive: 1, typeListActive: "1",
typeList: [], typeList: [],
preview: false, preview: false,
}; };
@ -128,7 +131,7 @@ export default {
try { try {
if (this.typeList.find((item) => item.id == this.typeListActive).code == "text-menu") { if (this.typeList.find((item) => item.id == this.typeListActive).code == "text-menu") {
if (!this.form.list.length) { if (!this.form.list.length) {
this.$notify.error({ ElNotification.error({
title: "错误", title: "错误",
message: "请生成菜单", message: "请生成菜单",
}); });
@ -142,7 +145,7 @@ export default {
}); });
if (!isEmpty) { if (!isEmpty) {
this.$notify.error({ ElNotification.error({
title: "错误", title: "错误",
message: "请添加商品", message: "请添加商品",
}); });
@ -152,35 +155,27 @@ export default {
this.loading = true; this.loading = true;
let res = null; let res = null;
if (this.form.id) { if (this.form.id) {
await productGroupPut({ await padApi.edit({
id: this.form.id, id: this.form.id,
padLayoutId: this.typeListActive, padLayoutId: this.typeListActive,
customName: "",
productCategoryId: this.category || this.form.list[0].categoryId, productCategoryId: this.category || this.form.list[0].categoryId,
shopId: localStorage.getItem("shopId"),
sort: 1,
remark: "",
productIdList: this.form.list.map((item) => item.id), productIdList: this.form.list.map((item) => item.id),
}); });
} else { } else {
res = await productGroup({ res = await padApi.add({
padLayoutId: this.typeListActive, padLayoutId: this.typeListActive,
customName: "",
productCategoryId: this.category, productCategoryId: this.category,
shopId: localStorage.getItem("shopId"),
sort: 1,
remark: "",
productIdList: this.form.list.map((item) => item.id), productIdList: this.form.list.map((item) => item.id),
}); });
} }
this.loading = false; this.loading = false;
if (this.form.id) { if (this.form.id) {
this.$notify.success({ ElNotification.success({
title: "提示", title: "提示",
message: "编辑成功", message: "编辑成功",
}); });
} else { } else {
this.$notify.success({ ElNotification.success({
title: "提示", title: "提示",
message: "添加成功", message: "添加成功",
}); });
@ -194,11 +189,9 @@ export default {
}, },
// //
async layoutlist() { async layoutlist() {
this.typeList = layoutList;
return;
try { try {
const res = await layoutlist(); const res = await padApi.getLayout();
this.typeList = res; this.typeList = res.records;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@ -212,15 +205,16 @@ export default {
selectConfirmGoods(res) { selectConfirmGoods(res) {
// this.form.list = res // this.form.list = res
const flag = this.form.list.filter((item) => item.id == res[0].id); const flag = this.form.list.filter((item) => item.id == res[0].id);
this.form.list[this.activeItem] = { ...res[0] };
if (flag.length) { if (flag.length) {
this.$notify({ ElNotification({
title: "注意", title: "注意",
message: "请勿重复添加", message: "请勿重复添加",
type: "error", type: "error",
}); });
} else { } else {
this.$set(this.form.list, this.activeItem, { ...res[0] }); this.form.list[this.activeItem] = { ...res[0] };
} }
}, },
// tab // tab
@ -241,7 +235,7 @@ export default {
async productCategoryDetail(id) { async productCategoryDetail(id) {
try { try {
this.pageLoading = true; this.pageLoading = true;
const res = await productCategoryDetail(id); const res = await padApi.get({ id });
this.pageLoading = false; this.pageLoading = false;
this.typeListActive = res.padLayoutId; this.typeListActive = res.padLayoutId;
this.form.id = res.id; this.form.id = res.id;
@ -259,7 +253,7 @@ export default {
// type=1 type=2 // type=1 type=2
async show(id = "", type = 1) { async show(id = "", type = 1) {
this.reset(); this.reset();
this.typeListActive = 1; this.typeListActive = "1";
this.dialogVisible = true; this.dialogVisible = true;
this.tabChange(); this.tabChange();
if (id) { if (id) {

View File

@ -43,7 +43,6 @@
<el-table-column label="自定义分类" prop="customName"></el-table-column> <el-table-column label="自定义分类" prop="customName"></el-table-column>
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200">
<template v-slot="scope"> <template v-slot="scope">
<el-button type="text" v-if="isPcBowser">拖动排序</el-button>
<el-button type="text" @click="editorHandle(scope.row, 1)">编辑</el-button> <el-button type="text" @click="editorHandle(scope.row, 1)">编辑</el-button>
<el-popconfirm title="确定删除吗?" @confirm="delTableHandle(scope.row.id)"> <el-popconfirm title="确定删除吗?" @confirm="delTableHandle(scope.row.id)">
<template #reference> <template #reference>
@ -76,7 +75,7 @@ import AddPadPage from "./components/addPadPage.vue";
import paoductCategoryApi from "@/api/product/productclassification"; import paoductCategoryApi from "@/api/product/productclassification";
import padProdApi from "@/api/account/padProd"; import padProdApi from "@/api/account/padProd";
import { swapArrayEle } from "@/utils/tools.js"; import { swapArrayEle } from "@/utils/tools.js";
import { ElMessage, ElNotification } from "element-plus";
export default { export default {
components: { components: {
AddPadPage, AddPadPage,
@ -101,11 +100,6 @@ export default {
}, },
mounted() { mounted() {
this.tbShopCategoryGet(); this.tbShopCategoryGet();
if (this.isPcBowser) {
this.$nextTick(() => {
this.tableDrag();
});
}
}, },
methods: { methods: {
// //
@ -150,8 +144,8 @@ export default {
// //
async delTableHandle(id) { async delTableHandle(id) {
try { try {
await padProdApi.delete(id); await padProdApi.delete({ id });
this.$message.success("已删除"); ElMessage.success("已删除");
this.getTableData(); this.getTableData();
} catch (error) { } catch (error) {
console.log(error); console.log(error);
@ -171,7 +165,7 @@ export default {
if (this.selectCatory.id) { if (this.selectCatory.id) {
this.$refs.AddPadPage.show(); this.$refs.AddPadPage.show();
} else { } else {
this.$notify.error({ ElNotification.error({
title: "错误", title: "错误",
message: "请选择分类", message: "请选择分类",
}); });