Commit 1f2e266d authored by gengshaojing's avatar gengshaojing

Merge branch 'feature/point'

parents c06ebf92 ef113548
const ACTIVITY_URI = require("../config.js").ACTIVITY_URI;
const req = require("../utils/request").httpReq;
// 获取商家列表
exports.edit = async (ctx) => {
const url = `${ACTIVITY_URI}/marketing/background/business_circle_edit`;
const opts = {
url,
method: "GET",
};
ctx.body = await req(ctx, opts);
};
// 商品库列表
exports.list = async (ctx) => {
const url = `${ACTIVITY_URI}/marketing/background/business_circle_list`;
const opts = {
url,
method: "GET",
};
ctx.body = await req(ctx, opts);
};
// 查看商品详情
exports.delete = async (ctx) => {
const url = `${ACTIVITY_URI}/marketing/background/business_circle_delete`;
const opts = {
url,
method: "GET",
};
ctx.body = await req(ctx, opts);
};
const ACTIVITY_URI = require("../config.js").ACTIVITY_URI;
const req = require("../utils/request").httpReq;
// 获取商家列表
exports.edit = async (ctx) => {
const url = `${ACTIVITY_URI}/marketing/background/tag_edit`;
const opts = {
url,
method: "GET",
};
ctx.body = await req(ctx, opts);
};
// 商品库列表
exports.list = async (ctx) => {
const url = `${ACTIVITY_URI}/marketing/background/tag_list`;
const opts = {
url,
method: "GET",
};
ctx.body = await req(ctx, opts);
};
// 查看商品详情
exports.delete = async (ctx) => {
const url = `${ACTIVITY_URI}/marketing/background/tag_delete`;
const opts = {
url,
method: "GET",
};
ctx.body = await req(ctx, opts);
};
......@@ -11,6 +11,8 @@ const withdrawal = require("./controllers/withdrawal");
const groupmeal = require("./controllers/groupmeal");
const qr_code = require("./controllers/qr-code");
const relay = require("./controllers/relay");
const tag = require("./controllers/tag");
const business_circle = require("./controllers/business_circle");
const router = Router();
const API_VERSION = "/api/v1";
......@@ -157,4 +159,14 @@ router.post(`${API_VERSION}/relay/ks3api_upload`, relay.uploadPic);
router.get(`${API_VERSION}/relay/order_export`, relay.orderExport);
router.get(`${API_VERSION}/relay/old_order_export`, relay.oldOrderExport);
// 分类
router.get(`${API_VERSION}/marketing/background/tag_edit`, tag.edit);
router.get(`${API_VERSION}/marketing/background/tag_list`, tag.list);
router.get(`${API_VERSION}/marketing/background/tag_delete`, tag.delete);
// 分类
router.get(`${API_VERSION}/marketing/background/business_circle_edit`, business_circle.edit);
router.get(`${API_VERSION}/marketing/background/business_circle_list`, business_circle.list);
router.get(`${API_VERSION}/marketing/background/business_circle_delete`, business_circle.delete);
module.exports = router;
......@@ -16,6 +16,8 @@ exports.httpReq = (ctx, opts) => {
opts.qs = { ...defaultQs, ...ctx.request.query, ...opts.qs };
console.log(opts);
request(opts, (err, res, body) => {
console.info(`[Api] httpReq (${opts.url}, user:[${opts.qs.op_cur_user}]) spent: ${+new Date() - time_start}ms`);
......
This diff is collapsed.
This diff is collapsed.
<template>
<div class="type_list-box">
<el-form :inline="true" class="demo-form-inline">
<el-form-item label="分类:" label-width="100px">
<el-button
size="small"
:type="item.checked ? 'primary' : ''"
v-for="(item, index) in tagList"
@click="onTagStatus(item)"
:key="index"
>
{{ item.tag_name }}
</el-button>
</el-form-item>
</el-form>
</div>
<div class="search_form">
<el-form :inline="true" :model="searchForm" class="demo-form-inline">
<el-form-item label="自提点名称:" label-width="100px">
<el-input v-model="searchForm.keywords" placeholder="请输入自提点名称" clearable></el-input>
</el-form-item>
<el-form-item label="商圈:">
<el-select v-model="searchForm.business_circle_ids" placeholder="请选择商圈" clearable multiple>
<el-option
:label="item.business_circle_name"
:value="item.business_circle_id"
:key="item.business_circle_id"
v-for="item in businessCircleList"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSearch">搜索</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { onMounted, reactive, toRefs } from "vue";
import { getTagList, getBusinessCircleList } from "@/service/point";
import { ElMessage } from "element-plus";
export default {
emits: ["getData"],
setup(props, { emit }) {
console.log("emit", emit);
const dataMap = reactive({
tagList: [],
businessCircleList: [],
takePlaceList: [],
loading: false,
searchForm: {
keywords: "",
business_circle_ids: [],
tag_ids: [],
offset: 0,
limit: 20,
},
});
// 获取 分类标签列表
const onGetTagList = () => {
getTagList().then((res) => {
console.log("分类标签列表", res.result);
const defaultTagList = [
{ tag_name: "全部", tag_id: "", checked: true },
{ tag_name: "未分类", tag_id: 0, checked: false },
];
const tagList = res.result.map((item) => {
item.checked = false;
return { ...item };
});
dataMap.tagList = defaultTagList.concat(tagList);
console.log("分类标签列表", dataMap.tagList);
});
};
// 获取 商圈商圈列表
const onGetBusinessCircleList = async () => {
try {
const { list } = await getBusinessCircleList();
console.log("商圈商圈列表", list);
dataMap.businessCircleList = list;
} catch (e) {
console.log(e);
ElMessage.error("获取商圈列表失败");
}
};
const onTagStatus = (item) => {
if (item.tag_name === "全部") {
dataMap.tagList.forEach((item) => {
item.checked = item.tag_name === "全部";
});
} else {
dataMap.tagList[0].checked = false;
item.checked = !item.checked;
}
if (!dataMap.tagList.find((item) => item.checked)) {
dataMap.tagList[0].checked = true;
}
onSearch();
};
const onSearch = () => {
const selectedTag = dataMap.tagList.filter((item) => item.tag_name !== "全部" && item.checked === true);
const selectedTagIds = selectedTag.map((item) => item.tag_id);
console.log("选中的tag", selectedTag);
console.log("选中tag的id", selectedTagIds);
dataMap.searchForm.tag_ids = selectedTagIds;
console.log(dataMap.searchForm);
onGetTakePlaceList();
};
const onGetTakePlaceList = () => {
const params = Object.assign({}, dataMap.searchForm);
if (params.business_circle_ids.length > 0) {
params.business_circle_ids = params.business_circle_ids.join(",");
} else {
delete params.business_circle_ids;
}
if (params.tag_ids.length > 0) {
params.tag_ids = params.tag_ids.join(",");
} else {
delete params.tag_ids;
}
if (!params.keywords) {
delete params.keywords;
}
emit("getData", params);
};
onMounted(() => {
onGetTagList();
onGetBusinessCircleList();
});
return {
...toRefs(dataMap),
onTagStatus,
onSearch,
onGetBusinessCircleList,
onGetTagList,
};
},
};
</script>
<style scoped lang="less">
.type_list-box {
display: flex;
align-items: center;
.tag_list {
}
}
</style>
<template>
<div class="type_dialog">
<el-dialog title="分类管理" v-model="comDialogVisible" width="70%" @closed="closeFormDialog">
<el-form :inline="true" :model="addForm">
<el-form-item label="分类名称:" label-width="100px">
<el-input v-model="addForm.type_name" placeholder="请输入分类名称" clearable style="min-width: 300px"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addType" :loading="addBtnLoading">添加</el-button>
</el-form-item>
</el-form>
<el-table class="dialog_table" align="center" :data="type_list" border v-loading="loading">
<el-table-column align="center" label="分类名称">
<template #default="{ row }">
<div v-if="row.edit" class="inline_edit">
<el-input size="small" v-model="row.tag_name"></el-input>
</div>
<p v-else>{{ row.tag_name }}</p>
</template>
</el-table-column>
<el-table-column prop="prop" label="操作" align="center" min-width="60">
<template #default="{ row, $index }">
<template v-if="row.edit">
<el-button size="small" @click="onRowCancel(row, $index)" class="inline_edit--cancel">取消</el-button>
<el-button type="primary" size="small" @click="onTagEdit(row)" v-loading="row.loading">保存</el-button>
</template>
<template v-else>
<el-popconfirm
confirmButtonText="确定"
cancelButtonText="取消"
icon="el-icon-info"
iconColor="red"
title="请确认是否要删除该分类?"
@confirm="onTagDelete(row)"
>
<template #reference>
<el-button type="primary" size="small">删除</el-button>
</template>
</el-popconfirm>
<el-button type="primary" size="small" @click="onRowEdit(row)">修改</el-button>
</template>
</template>
</el-table-column>
</el-table>
<template #footer>
<div class="dialog-footer">
<el-button @click="closeFormDialog">关 闭</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script>
import { onMounted, reactive, toRefs, watch } from "vue";
import { getTagList, handleTag, tagDelete } from "@/service/point";
import { ElMessage } from "element-plus";
export default {
props: {
dialogVisible: {
type: Boolean,
default: false,
},
},
setup(props, { emit }) {
const dataMap = reactive({
loading: false,
addBtnLoading: false,
comDialogVisible: false,
addForm: {
type_name: "",
},
type_list: [],
edit_row: {},
});
// 获取 分类标签列表
const onGetTagList = async () => {
dataMap.loading = true;
try {
const { result } = await getTagList();
console.log("分类标签列表", result);
const newArr = result.map((item) => {
item.edit = false;
item.loading = false;
return { ...item };
});
console.log("newArr", newArr);
dataMap.type_list = newArr;
} catch (e) {
console.log(e);
ElMessage.error("获取分类列表失败");
} finally {
dataMap.loading = false;
}
};
// 添加分类
const addType = async () => {
if (!dataMap.addForm.type_name) {
ElMessage.error("请输入分类名称");
return;
}
dataMap.addBtnLoading = true;
try {
const { code, reason } = await handleTag({ tag_name: dataMap.addForm.type_name });
console.log("添加标签列表code", code);
console.log("添加标签列表reason", reason);
if (+code === 0) {
ElMessage.success("添加成功");
onGetTagList();
onReset();
} else {
ElMessage.error(reason);
}
} catch (e) {
console.log(e);
ElMessage.error("添加分类失败");
} finally {
dataMap.addBtnLoading = false;
}
};
const onTagDelete = async (row) => {
console.log(row);
try {
const { code, reason } = await tagDelete({ tag_id: row.tag_id, is_delete: 1 });
console.log("删除标签code", code);
console.log("删除标签reason", reason);
if (+code === 0) {
ElMessage.success("删除成功");
onGetTagList();
} else {
ElMessage.error(reason);
}
} catch (e) {
console.log(e);
ElMessage.error("删除失败");
}
};
// 修改
const onTagEdit = async (row) => {
console.log(row);
row.loading = true;
try {
const { code, reason } = await handleTag({ tag_id: row.tag_id, tag_name: row.tag_name });
console.log("修改标签code", code);
console.log("修改标签reason", reason);
if (+code === 0) {
ElMessage.success("修改成功");
row.edit = false;
onGetTagList();
} else {
ElMessage.error(reason);
}
} catch (e) {
console.log(e);
ElMessage.error("修改失败");
} finally {
row.loading = false;
}
};
watch(
() => props.dialogVisible,
(newValue) => {
console.log("props.dialogVisible", newValue);
dataMap.comDialogVisible = newValue;
if (newValue) onGetTagList();
},
);
// 关闭dialog
const closeFormDialog = () => {
console.log("关闭dialog");
dataMap.comDialogVisible = false;
emit("closeDialog");
onReset();
emit("onGetTagList");
};
const onReset = () => {
dataMap.addForm = {
type_name: "",
};
};
const onRowEdit = (row) => {
row.edit = true;
dataMap.edit_row = Object.assign({}, row);
};
const onRowCancel = (row, index) => {
console.log(index);
dataMap.edit_row.edit = false;
dataMap.type_list[index] = dataMap.edit_row;
};
return {
...toRefs(dataMap),
addType,
onTagDelete,
onTagEdit,
closeFormDialog,
onRowEdit,
onRowCancel,
};
},
};
</script>
<style lang="less" scoped>
.courier_dialog {
.dialog_header {
display: flex;
.num {
margin-left: 30px;
}
}
.dialog_form {
.dialog_form-item {
display: flex;
align-items: center;
.courier_name {
}
.courier_input {
width: 300px;
margin-left: 10px;
}
.courier_btn {
margin-left: 10px;
}
}
}
.dialog_selection,
.dialog_table,
.dialog_form {
margin-top: 20px;
}
}
.inline_edit {
display: flex;
align-items: center;
.inline_edit--cancel {
margin-left: 20px;
}
}
</style>
.item_label {
width: 100px;
text-align: right;
}
.business_circle-btn {
margin: 0 20px;
}
.el-check-tag.is-checked {
background: #409eff;
color: #ffffff;
border: 1px solid #409eff;
}
.el-check-tag {
background: #ffffff;
color: #606266;
border: 1px solid #dcdfe6;
}
.goods {
width: 100%;
height: 100%;
padding: 0 30px;
.header {
display: flex;
justify-content: flex-end;
margin-bottom: 30px;
}
.dioFor {
margin-left: 5%;
width: 70%;
}
.diotab {
margin-left: 5%;
margin-top: 10px;
}
.dialog-footer {
display: flex;
align-items: center;
justify-content: center;
}
.commodity_list {
margin-top: 30px;
}
.pagination {
margin-top: 30px;
}
}
<template>
<Layout>
<el-card class="goods" v-loading="pageLoading">
<search @getData="onGetTakePlaceList"></search>
<div class="header">
<el-button type="primary" @click="typeDialogVisible = true">分类管理</el-button>
<el-button type="primary" @click="businessCircleDialogVisible = true">商圈管理</el-button>
<el-button type="primary" @click="pointDialogVisible = true">添加自提点</el-button>
</div>
<el-table :data="takePlaceList" border stripe fit style="width: 100%" v-loading="loading">
<el-table-column align="center" prop="take_place_name" label="自提点名称"></el-table-column>
<el-table-column align="center" prop="business_circle_name" label="商圈"></el-table-column>
<el-table-column align="center" prop="location" label="位置"></el-table-column>
<el-table-column align="center" prop="address" label="详细地址"></el-table-column>
<el-table-column align="center" prop="activeName" label="联系人">
<template #default="{ row }">
<p>{{ row.contact_name }}</p>
<p>{{ row.phone }}</p>
</template>
</el-table-column>
<el-table-column align="center" label="分类">
<template #default="{ row }">
<span v-if="row.tag_name">{{ row.tag_name }}</span>
<span v-else>未分类</span>
</template>
</el-table-column>
<el-table-column prop="prop" label="操作" align="center" min-width="60">
<template #default="{ row }">
<el-popconfirm
confirmButtonText="确定"
cancelButtonText="取消"
icon="el-icon-info"
iconColor="red"
title="请确认是否要删除该商圈?"
@confirm="onDelete(row)"
>
<template #reference>
<el-button type="primary" size="small">删除</el-button>
</template>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!-- 页码区 -->
<Pagination
@current-change="onCurrentChange"
:current-page="pagination.page"
:page-size="pagination.pageSize"
:total="pagination.total"
></Pagination>
<!-- 添加自提点弹窗 -->
<pointDialog
:dialogVisible="pointDialogVisible"
@closeDialog="pointDialogVisible = false"
:tagList="tagList"
:businessCircleList="businessCircleList"
@onGetTakePlaceList="onGetTakePlaceList"
/>
<!-- 分类管理弹窗 -->
<typeDialog :dialogVisible="typeDialogVisible" @closeDialog="typeDialogVisible = false" @onGetTagList="onGetTagList" />
<!-- 商圈管理弹窗 -->
<businessCircleDialog
:dialogVisible="businessCircleDialogVisible"
@closeDialog="businessCircleDialogVisible = false"
@onGetBusinessCircleList="onGetBusinessCircleList"
/>
</el-card>
</Layout>
</template>
<script>
import Layout from "../layout/index.vue";
import Pagination from "../components/Pagination/index.vue";
import typeDialog from "./components/typeDialog";
import businessCircleDialog from "./components/businessCircleDialog";
import pointDialog from "./components/pointDialog";
import search from "./components/search";
import { onMounted, reactive, toRefs } from "vue";
import { getTagList, getTakePlaceList, takePlaceDelete, getBusinessCircleList } from "../../../service/point";
import ActivityService from "@/service/Activity/index";
import { ElMessage } from "element-plus";
export default {
name: "point",
components: {
Layout,
Pagination,
typeDialog,
businessCircleDialog,
pointDialog,
search,
},
setup() {
const dataMap = reactive({
tagList: [],
businessCircleList: [],
takePlaceList: [],
loading: false,
formInline: {
user: "",
region: "",
},
searchForm: {
keywords: "",
business_circle_ids: [],
tag_ids: [],
offset: 0,
limit: 20,
},
pagination: {
page: 1,
total: 0,
pageSize: 20,
},
// 自提点弹窗
pointDialogVisible: false,
// 分类管理弹窗
typeDialogVisible: false,
// 商圈管理弹窗
businessCircleDialogVisible: false,
});
// 获取 分类标签列表
const onGetTagList = () => {
getTagList().then((res) => {
console.log("分类标签列表", res.result);
const defaultTagList = [
{ tag_name: "全部", tag_id: "", checked: true },
{ tag_name: "未分类", tag_id: 0, checked: false },
];
const tagList = res.result.map((item) => {
item.checked = false;
return { ...item };
});
dataMap.tagList = defaultTagList.concat(tagList);
console.log("分类标签列表", dataMap.tagList);
});
};
// 获取 商圈商圈列表
const onGetBusinessCircleList = async () => {
try {
const { list } = await getBusinessCircleList();
console.log("商圈商圈列表", list);
dataMap.businessCircleList = list;
} catch (e) {
console.log(e);
ElMessage.error("获取商圈列表失败");
}
};
const onTagStatus = (item) => {
if (item.tag_name === "全部") {
dataMap.tagList.forEach((item) => {
item.checked = item.tag_name === "全部";
});
} else {
dataMap.tagList[0].checked = false;
item.checked = !item.checked;
}
if (!dataMap.tagList.find((item) => item.checked)) {
dataMap.tagList[0].checked = true;
}
onSearch();
};
const onGetTakePlaceList = async (params = {}) => {
dataMap.loading = true;
try {
const { page, pageSize } = dataMap.pagination;
params.offset = page === 1 ? 0 : (page - 1) * pageSize;
const { result } = await ActivityService.getPlaceList(params);
dataMap.takePlaceList = result.list;
dataMap.pagination.total = result.total;
} catch (e) {
console.log(e);
ElMessage.error("获取自提点列表失败");
} finally {
dataMap.loading = false;
}
};
const onDelete = async (row) => {
console.log(row);
try {
const { code, reason } = await ActivityService.deletePlace({ take_place_id: row.take_place_id });
if (+code === 0) {
ElMessage.success("删除成功");
onGetTakePlaceList();
} else {
ElMessage.error(reason);
}
} catch (e) {
console.log(e);
ElMessage.error("删除失败");
}
};
const onCurrentChange = (val) => {
console.log(val);
dataMap.pagination.page = val;
onGetTakePlaceList();
};
const onSearch = () => {
const selectedTag = dataMap.tagList.filter((item) => item.tag_name !== "全部" && item.checked === true);
const selectedTagIds = selectedTag.map((item) => item.tag_id);
console.log("选中的tag", selectedTag);
console.log("选中tag的id", selectedTagIds);
dataMap.searchForm.tag_ids = selectedTagIds;
console.log(dataMap.searchForm);
onGetTakePlaceList();
};
onMounted(() => {
onGetTagList();
onGetTakePlaceList();
onGetBusinessCircleList();
});
return {
...toRefs(dataMap),
onTagStatus,
onGetTakePlaceList,
onDelete,
onSearch,
onCurrentChange,
onGetBusinessCircleList,
onGetTagList,
};
},
};
</script>
<style lang="less" src="./index.less" scoped></style>
......@@ -15,6 +15,10 @@ const headerConfig = [
path: "/op/groupmeal/distrib",
name: "配送员管理",
},
{
path: "/op/groupmeal/point",
name: "自提点管理",
},
{
path: "/op/groupmeal/merchantManagement",
name: "商家管理",
......
......@@ -39,6 +39,11 @@ const groupmealRouters = [
name: "couponManagement",
component: () => import(/* webpackChunkName: "couponManagement" */ "@/pages/Groupmeal/couponManagement"),
},
{
path: "/op/groupmeal/point",
name: "point",
component: () => import(/* webpackChunkName: "goods" */ "@/pages/Groupmeal/Point"),
},
];
export default groupmealRouters;
import axios from "../utils/request";
// 分类--列表
export async function getTagList(params) {
const res = await axios.get(`/api/v1/marketing/background/tag_list`, {
params,
});
return res.result;
}
// 分类--添加 || 编辑
export async function handleTag(params) {
return await axios.get(`/api/v1/marketing/background/tag_edit`, {
params,
});
}
// 分类--删除
export async function tagDelete(params) {
return await axios.get(`/api/v1/marketing/background/tag_delete`, {
params,
});
}
// 商圈--列表
export async function getBusinessCircleList(params) {
const res = await axios.get(`/api/v1/marketing/background/business_circle_list`, {
params,
});
return res.result;
}
// 分类--添加 || 编辑
export async function handleBusinessCircle(params) {
return await axios.get(`/api/v1/marketing/background/business_circle_edit`, {
params,
});
}
// 分类--删除
export async function businessCircleDelete(params) {
return await axios.get(`/api/v1/marketing/background/business_circle_delete`, {
params,
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment