Commit e8631179 authored by pengyunqian's avatar pengyunqian

update:转换配送工具

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