Commit e8631179 authored by pengyunqian's avatar pengyunqian

update:转换配送工具

parents 5c778d43 bde824ed
......@@ -3,131 +3,132 @@ const req = require("../utils/request").httpReq;
// 获取订单管理列表
exports.getOrderList = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/order_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/order_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 获取主页配送列表
exports.getList = async ctx => {
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/list_day_deliverer_conf`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/list_day_deliverer_conf`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 获取配送列表
exports.getDelivererList = async ctx => {
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/list_day_deliverer`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/list_day_deliverer`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 添加骑手
exports.getAddDeliverer = async ctx => {
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/add_deliverer`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/add_deliverer`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 分配骑手
exports.getSaveDeliverer = async ctx => {
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/save_day_deliverer`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
const opts = {
url: `${GROUPMEAL_URI}/order/deliverer/save_day_deliverer`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 获取活动名称
exports.getMarketingList = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/marketing_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/marketing_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 获取商品名称
exports.getGoodsList = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/goods_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/goods_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 获取自提点
exports.getSubShopList = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/sub_shop_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/sub_shop_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 导出订单
exports.orderExport = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/order_export`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/order_export`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 打印订单
exports.orderPrint = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/print`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/order_print`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 订单退款列表
exports.orderItemList = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/order_item_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/order_item_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 订单退款列表
exports.orderRefund = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/order_refundt`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/order_refund`;
const opts = {
url,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 订单驳回
exports.orderRefundReject = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/order_refund_reject`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
const url = `${GROUPMEAL_URI}/order/background/order_refund_reject`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
......@@ -75,9 +75,9 @@ router.get(`${API_VERSION}/order/background/goods_list`, groupmeal.getGoodsList)
router.get(`${API_VERSION}/order/background/sub_shop_list`, groupmeal.getSubShopList);
router.get(`${API_VERSION}/order/background/order_export`, groupmeal.orderExport);
router.get(`${API_VERSION}/order/background/order_export`, groupmeal.orderExport);
router.get(`${API_VERSION}/order/background/print`, groupmeal.orderPrint);
router.get(`${API_VERSION}/order/background/order_print`, groupmeal.orderPrint);
router.get(`${API_VERSION}/order/background/order_item_list`, groupmeal.orderItemList);
router.get(`${API_VERSION}/order/background/order_refund_reject`, groupmeal.orderRefundReject);
router.get(`${API_VERSION}/order/background/order_refundt`, groupmeal.orderRefund);
router.post(`${API_VERSION}/order/background/order_refund`, groupmeal.orderRefund);
module.exports = router;
......@@ -100,9 +100,11 @@
label="订单状态"
></el-table-column>
<el-table-column prop="order_item" label="商品信息">
<!-- <template #default="scope">
{{ scope }}
</template> -->
<template #default="scope">
<div v-for="(item, index) in scope.row.order_item" :key="index">
{{ item.goods_name }}
</div>
</template>
</el-table-column>
<el-table-column prop="user_name" label="收货人"></el-table-column>
<el-table-column
......@@ -157,10 +159,13 @@
prop="order_status_text"
label="订单状态"
></el-table-column>
<el-table-column
prop="order_item"
label="商品信息"
></el-table-column>
<el-table-column prop="order_item" label="商品信息">
<template #default="scope">
<div v-for="(item, index) in scope.row.order_item" :key="index">
{{ item.goods_name }}
</div>
</template>
</el-table-column>
<el-table-column prop="user_name" label="收货人"></el-table-column>
<el-table-column
prop="sub_shop_name"
......@@ -175,12 +180,16 @@
></el-table-column>
<el-table-column fixed="right" label="操作" width="100">
<template #default="scope">
<!-- v-if="scope.row.order_status_text == '已支付'" -->
<el-button type="text" size="small" @click="refund(scope.row)"
<el-button
type="text"
size="small"
@click="refund(scope.row)"
v-show="scope.row.order_status_text == '已支付'"
>退款</el-button
>
<!-- v-else -->
<el-button-group>
<el-button-group
v-show="scope.row.order_status_text == '待退款'"
>
<el-button type="text" size="small" @click="agree(scope.row)"
>同意</el-button
>
......@@ -199,15 +208,22 @@
<el-dialog title="导出订单" width="25%" top="10%" v-model="exportShow">
<el-form-item class="exportForm" label>
<div>请选择导出活动{{ exportType }}的表格类型</div>
<el-checkbox-group v-model="exportSel.type">
<el-checkbox label="总表" name="type"></el-checkbox>
<el-checkbox label="商品表" name="type"></el-checkbox>
<el-checkbox label="配送表" name="type"></el-checkbox>
<el-checkbox-group v-model="exportSel">
<el-checkbox
v-for="i in exportSelOpt"
:label="i.type"
:key="i.type"
>{{ i.name }}</el-checkbox
>
</el-checkbox-group>
</el-form-item>
<el-form-item class="exportBtn">
<el-button @click="exportShow = false">取消</el-button>
<el-button type="primary" @click="confirmExport">确定导出</el-button>
<a :href="exportURL" style="margin-left: 20px"
><el-button type="primary" @click="exportShow = false"
>确定导出</el-button
></a
>
</el-form-item>
</el-dialog>
<!-- 退款弹窗 -->
......@@ -243,19 +259,24 @@
v-model="item.refundableQuantity"
@change="handleChange"
:min="1"
:max="10"
:max="item.goods_num"
label="描述文字"
></el-input-number>
</el-row>
<el-row>
退款金额(可退金额{{ item.refundAmount }}元):
<el-input v-model="item.ipt" style="width: 150px"></el-input>
<el-input
v-model="item.amountToRefund"
style="width: 150px"
></el-input>
</el-row>
</div>
<template #footer>
<span class="dialog-footer refundBtnGroup">
<el-button @click="refundShow = false">取 消</el-button>
<el-button type="primary" @click="refundConfirm">退款</el-button>
<el-button type="primary" @click="handleConfirmRefund"
>退款</el-button
>
</span>
</template>
</el-dialog>
......@@ -270,11 +291,11 @@ import {
getMarketingList,
getGoodsList,
getSubShopList,
orderExport,
orderPrint,
orderItemList,
orderRefundReject,
orderRefund,
refundOrder,
getOrderExportURL,
} from "@/service/Groupmeal/groupmeal";
import page from "../../components/Pagination.vue";
......@@ -341,9 +362,12 @@ export default {
// 导出
exportShow: false,
exportType: "xxxxx",
exportSel: {
type: [],
},
exportSel: [],
exportSelOpt: [
{ type: "1", name: "总表" },
{ type: "2", name: "商品表" },
{ type: "3", name: "配送表" },
],
// 表格数据
orderTableData: [],
......@@ -366,11 +390,19 @@ export default {
payment: "", // 实付
refundableQuantity: "",
refundAmount: "",
ipt: "",
amountToRefund: "",
},
],
};
},
computed: {
exportURL() {
return getOrderExportURL(this.orderQueryObj.marketing_id, this.exportSel);
},
},
methods: {
// 获取活动名称
async getMarketingListMet() {
......@@ -398,7 +430,6 @@ export default {
try {
const res = await getSubShopList();
this.selLiftPoinArr = res.result;
console.log(this);
} catch (error) {
this.$message.error("发生未知错误,请稍后再试一下吧~~~");
console.error(error);
......@@ -426,8 +457,8 @@ export default {
handleClick(targetName) {
if (targetName.props.name == "all") {
this.orderQueryObj.order_status = "0";
this.orderStatusArr[1].disabled = true;
this.orderStatusArr[2].disabled = true;
this.orderStatusArr[1].disabled = false;
this.orderStatusArr[2].disabled = false;
} else {
this.orderQueryObj.order_status = "7";
this.orderStatusArr[1].disabled = true;
......@@ -441,29 +472,52 @@ export default {
this.exportShow = true;
},
// 确认导出
async confirmExport() {
console.log(this.exportSel.type);
async printOrderMet(forcePrint) {
const params = {
type: this.exportSel.type,
// marketing_id: this.orderQueryObj.marketing_id,
marketing_id: "1NJETU",
force_print: forcePrint? "1": "",
};
const res = await orderExport(params);
console.log(res);
const res = await orderPrint(params);
return res
},
// 打印
async printOrder() {
const params = {
marketing_id: this.orderQueryObj.marketing_id,
};
const res = await orderPrint(params);
console.log(res);
if(this.orderQueryObj.marketing_id === "") {
this.$message.error("请选择活动名称");
return
}
let res = this.printOrderMet(false);
if (res.code === 0) {
this.$message({
type: "success",
message: "打印成功",
});
return
}
try {
await this.$confirm("是否强制打印?", "打印", {
cancelButtonText: "取消",
confirmButtonText: "确定",
})
} catch(e) {
// 取消
return
}
res = this.printOrderMet(true)
if (res.code !== 0) {
this.$message.error("打印失败");
}
},
// 获取订单列表
async getOrderListMet() {
try {
const res = await getOrderList(this.params);
console.log(res);
this.goodsNum = res.count;
this.totalNum = res.count;
this.orderTableData = res.result;
......@@ -481,7 +535,6 @@ export default {
// 拒绝
refuse(val) {
console.log(val);
this.$confirm("确定要拒绝退款么?", "拒绝", {
cancelButtonText: "取消",
confirmButtonText: "确定",
......@@ -491,28 +544,23 @@ export default {
order_id: val.order_id,
};
const res = orderRefundReject(params);
console.log(res);
console.log(res.status);
this.$message({
type: "success",
message: "退款成功!",
message: "此订单已驳回",
});
this.getOrderListMet()
})
.catch(() => {
this.$message({
type: "info",
message: "已取消",
});
});
.catch(() => {});
},
// 同意
agree(val) {
console.log(val);
this.refund(val);
},
// 全选
handleCheckAllChange(val) {
console.log(val);
this.refundGoods.refundedGoodsSel = val;
this.isIndeterminate = false;
},
......@@ -524,20 +572,46 @@ export default {
order_id: val.order_id,
};
const res = await orderItemList(params);
console.log(res.result);
this.refundGoods = res.result;
},
// 退款确认
async refundConfirm() {
const params = {
order_id: "",
refund_list: "",
order_item_id: "",
refund_num: "",
refund_amount: "",
async handleConfirmRefund() {
const isCheckAllSelected = () => this.refundGoods.refundedGoodsSel;
const getAllItems = () => this.refundGoods;
const getSelectedItems = () => {
const isSelected = ({ refundedGoodsSel }) => refundedGoodsSel;
return this.refundGoods.filter(isSelected);
};
const convertToNumber = (str) => {
return !Number.isNaN(parseFloat(str)) ? parseFloat(str) : 0;
};
const res = await orderRefund(params);
console.log(res);
const processRefundItem = (item) => {
return {
order_item_id: item.order_item_id,
refund_num: item.refundableQuantity || 0,
refund_amount: convertToNumber(item.amountToRefund),
};
};
const orderId = this.refundGoods[0].order_id;
let itemsToRefund = null;
if (isCheckAllSelected()) {
itemsToRefund = getAllItems();
} else {
itemsToRefund = getSelectedItems();
}
itemsToRefund = itemsToRefund.map(processRefundItem);
const res = await refundOrder(orderId, itemsToRefund);
if (res.code === 0) {
this.$message.success("退款成功");
return;
}
this.$message.error(res.reason);
},
},
created() {
......@@ -548,5 +622,4 @@ export default {
};
</script>
<style lang="less" src="./index.less" scope>
</style>
\ No newline at end of file
<style lang="less" src="./index.less" scope></style>
......@@ -6,60 +6,66 @@ export async function getList (params) {
return res;
}
// 获取分配配送员列表
export async function getDelivererList (params) {
const res = await axios.post("/api/v1/order/deliverer/list_day_deliverer",params);
return res;
}
export async function getDelivererList(params) {
const res = await axios.post(
"/api/v1/order/deliverer/list_day_deliverer",
params
);
return res;
}
// 添加配送员
export async function getAddDeliverer (params) {
const res = await axios.post("/api/v1/order/deliverer/add_deliverer",params);
return res;
export async function getAddDeliverer(params) {
const res = await axios.post("/api/v1/order/deliverer/add_deliverer", params);
return res;
}
// 分配配送员
export async function getSaveDeliverer (params) {
const res = await axios.post("/api/v1/order/deliverer/save_day_deliverer",params);
return res;
export async function getSaveDeliverer(params) {
const res = await axios.post(
"/api/v1/order/deliverer/save_day_deliverer",
params
);
return res;
}
// 获取订单列表
export async function getOrderList (params) {
const res = await axios.get("/api/v1/order/background/order_list",{
// 获取订单列表
export async function getOrderList(params) {
const res = await axios.get("/api/v1/order/background/order_list", {
params
});
return res;
}
// 获取活动名称
export async function getMarketingList () {
// 获取活动名称
export async function getMarketingList() {
const res = await axios.get("/api/v1/order/background/marketing_list");
return res;
}
// 获取商品名称
// 获取商品名称
export async function getGoodsList(params) {
const res = await axios.get("/api/v1/order/background/goods_list",{
const res = await axios.get("/api/v1/order/background/goods_list", {
params
});
return res;
}
// 获取自提点
// 获取自提点
export async function getSubShopList() {
const res = await axios.get("/api/v1/order/background/sub_shop_list");
return res;
}
// 导出订单
// 导出订单
export async function orderExport(params) {
const res = await axios.get("/api/v1/order/background/order_export",{
const res = await axios.get("/api/v1/order/background/order_export", {
params
});
return res;
}
// 打印订单
// 打印订单
export async function orderPrint(params) {
const res = await axios.get("/api/v1/order/background/print",{
const res = await axios.get("/api/v1/order/background/order_print", {
params
});
return res;
......@@ -67,24 +73,34 @@ export async function orderPrint(params) {
// 订单退款列表
export async function orderItemList(params) {
const res = await axios.get("/api/v1/order/background/order_item_list",{
const res = await axios.get("/api/v1/order/background/order_item_list", {
params
});
return res;
}
// 订单退款
export async function orderRefund(params) {
const res = await axios.get("/api/v1/order/background/order_refund",{
params
export async function refundOrder(orderId, itemsToRefund) {
// const params = {
// order_id: orderId,
// refund_list: itemsToRefund
// };
const res = await axios.post("/api/v1/order/background/order_refund", {
order_id: orderId,
refund_list: itemsToRefund
});
return res;
}
// 订单驳回
export async function orderRefundReject(params) {
const res = await axios.get("/api/v1/order/background/order_refund_reject",{
const res = await axios.get("/api/v1/order/background/order_refund_reject", {
params
});
return res;
}
// 导出订单
export function getOrderExportURL(eventId, type) {
return `http://bp-dev.ini.yidian-inc.com/order/background/order_export?marketing_id=${eventId}&type=${type}`;
}
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