shish 1 год назад
Родитель
Сommit
be5b6fc516

+ 4 - 0
ghs/src/cool/request/index.js

@@ -69,12 +69,16 @@ import bookRoadChange from '@/service/book-road-change/index';
 import bookItemGhs from '@/service/book-item-ghs/index';
 import orderItem from '@/service/order-item/index';
 import cgRefund from '@/service/cg-refund/index';
+import clear from '@/service/clear/index';
+import refund from '@/service/refund/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
 	// const ignore = ['./request.js'];
 
 	let modules = {
+		refund,
+		clear,
 		cgRefund,
 		orderItem,
 		bookItemGhs,

+ 13 - 0
ghs/src/service/clear/index.js

@@ -0,0 +1,13 @@
+import { BaseService, Service } from '@/cool';
+@Service('clear')
+export class ClearService extends BaseService {
+
+	getUnClear(data) {
+		return this.request({
+			url: '/get-un-clear',
+			params: data
+		});
+	}
+
+}
+export default new ClearService();

+ 14 - 0
ghs/src/service/refund/index.js

@@ -0,0 +1,14 @@
+import { BaseService, Service } from '@/cool';
+@Service('refund')
+export class RefundService extends BaseService {
+
+    refund(data) {
+		return this.request({
+			url: '/create-order',
+			method: 'POST',
+			data: data
+		});
+	}
+
+}
+export default new RefundService();

+ 145 - 6
ghs/src/views/order/components/begin-refund.vue

@@ -36,17 +36,63 @@
 							</div>
 						</div>
 					</div>
+
+					<div class="refund-item-list" v-if="Number(orderInfo.packCost)>0||Number(orderInfo.sendCost)>0">
+						<div class="refund-label">其他可退:</div>
+						<div>
+							<div class="list" v-if="Number(orderInfo.packCost)>0">
+								<div class="flex list-title" >
+									<span class="product-name">打包费</span>
+									<span class="product-num">{{ orderInfo.packCost?parseFloat(orderInfo.packCost):0 }}元</span>
+
+								</div>
+								<div class="flex list-val" style="font-size:17px;font-weight:bold;">
+									<input type="digit" placeholder="金额" v-model="orderInfo.refundPackCostAmount" placeholder-style="color:#CCCCCC" />
+									<span style="margin-left:10px;">元</span>
+									<span style="color:green;margin-left:20px;">可退{{parseFloat((Number(orderInfo.packCost)-Number(orderInfo.refundPackCost)).toFixed(2))}}元</span>
+								</div>
+							</div>
+							<div class="list" v-if="Number(orderInfo.sendCost)>0">
+								<div class="flex list-title" >
+									<span class="product-name">运费</span>
+									<span class="product-num">{{ orderInfo.sendCost?parseFloat(orderInfo.sendCost):0 }}元</span>
+								</div>
+								<div class="flex list-val" style="font-size:17px;font-weight:bold;">
+									<input type="digit" placeholder="金额" v-model="orderInfo.refundSendCostAmount" placeholder-style="color:#CCCCCC" />
+									<span style="margin-left:10px;">元</span>
+									<span style="color:green;margin-left:20px;">可退{{parseFloat((Number(orderInfo.sendCost)-Number(orderInfo.refundSendCost)).toFixed(2))}}元</span>
+								</div>
+							</div>
+						</div>
+					</div>
 				</div>
+
+				<div>
+					<div class="accounts-list">
+						退款原因
+						<div class="accounts-center">
+							<div v-if="cause==0">
+								<el-button type="primary" size="small" @click="cause=0">质量问题</el-button>
+								<el-button  @click="cause=1" size="small" style="margin-left:20px;">多开错开</el-button>
+							</div>
+							<div v-else>
+								<el-button @click="cause=0" size="small">质量问题</el-button>
+								<el-button type="primary" size="small" @click="cause=1" style="margin-left:20px;">多开错开</el-button>
+							</div>
+						</div>
+					</div>
+				</div>
+
 				<div class="accounts-list">
 					订单金额
 					<div class="accounts-center">
-						¥{{parseFloat(orderInfo.orderPrice)||0}}
+						¥{{orderInfo.orderPrice ? parseFloat(orderInfo.orderPrice):0}}
 						<span style="margin-left:15px;font-size:18px;color:green;font-weight:bold;" v-if="Number(orderInfo.tkPrice)>0">已退¥{{orderInfo.tkPrice ? parseFloat(orderInfo.tkPrice) : 0}}</span>
 					</div>
 				</div>
 				<div class="accounts-list">
 					可退金额
-					<div class="accounts-center">¥{{ couldRefundPrice }}</div>
+					<div class="accounts-center">¥{{couldRefundPrice}}</div>
 				</div>
 				<div class="accounts-list">
 					预计退款
@@ -55,7 +101,7 @@
 				<div class="accounts-list">
 					实际退款
 					<div class="accounts-center">
-						<el-input v-model="refundMoney" placeholder="输入金额" style="width:120px;"></el-input>
+						<el-input v-model="refundMoney" placeholder="输入金额" style="width:120px;" @focus="refundMoney=''"></el-input>
 					</div>
 				</div>
 				<div class="accounts-list">
@@ -65,12 +111,28 @@
 					</div>
 				</div>
 			</div>
+
+			<div style="padding:20upx 0 20upx 0;font-size:30upx;font-weight:bold;margin-left:70px;">
+				<span v-if="orderInfo.onlinePay == 2" style="color:green;">此单线上付款,提交后,钱会原路自动退回给客户</span>
+				<template v-else>
+					<span v-if="Number(orderInfo.debtPrice)>0" style="color:#3385ff;">
+					此单为欠款单,提交后,欠款金额会自动减少
+					</span>
+					<span v-else style="color:red;">此单线下付款,提交后钱不会原路退回,请线下转账给客户</span>
+				</template>
+			</div>
+
 			<div style="margin-left:80px;margin-top:20px;">
 				<el-button @click="closeOpen" style="margin-left:120px;">取消</el-button>
 				<el-popconfirm title="确认退款?" @confirm="confirmRefund()" @onConfirm="confirmRefund()" style="margin-left:180px;">
 					<el-button type="primary" slot="reference">确认</el-button>
 				</el-popconfirm>
 			</div>
+
+			<div style="font-size:20px;z-index:9999;color:red;text-align:center;font-weight:bold;margin-bottom:30px;" v-if="!$util.isEmpty(unClear)">
+				<span>有一个待结账单 ¥{{unClear.actPrice?parseFloat(unClear.actPrice):0}}</span>
+			</div>
+
 		</div>
 	</el-drawer>
 </div>
@@ -95,7 +157,7 @@ export default {
 			remark:'',
 			orderInfo:{},
 			couldRefundPrice:0,
-			unClear:[]
+			unClear:{}
 		}
 	},
 	computed: {
@@ -124,8 +186,85 @@ export default {
 	},
 	methods: {
 		confirmRefund(){
+			let hasError = false
+			let product = []
+			let that = this
+			this.product.forEach(ele=>{
+				let currentRefundCont = ele.refundCount ? Number(ele.refundCount) :0
+				let currentNum = ele.xhNum ? Number(ele.xhNum) : 0
+				let hasRefundNum = ele.refundNum ? Number(ele.refundNum) : 0
+				let couldRefundNum = Number(currentNum) - Number(hasRefundNum)
+				if(Number(currentRefundCont) > Number(couldRefundNum)){
+					this.$message.error(ele.name+'超过可退数量')
+					hasError = true;
+					return false
+				}
+				if(Number(ele.refundCount)>0){
+					product.push({
+						productId:ele.productId,
+						num:ele.refundCount,
+						unitType:ele.unitType,
+						unitName:ele.xhUnitName,
+						unitType:ele.xhUnitType,
+						unitPrice:ele.xhUnitPrice
+					})
+				}
+			})
+			if(hasError){
+				return
+			}
+			if(this.$util.isEmpty(product)&&this.refundType==1){
+				this.$message.error('请选择商品')
+				return;
+			}
+			if(Number(this.orderInfo.refundPackCostAmount)>0){
+				let couldRefundPackCost = parseFloat((Number(this.orderInfo.packCost)-Number(this.orderInfo.refundPackCost)).toFixed(2))
+				if(Number(this.orderInfo.refundPackCostAmount)>Number(couldRefundPackCost)){
+					this.$message.error('打包费超出可退金额')
+					return false
+				}
+			}
+			if(Number(this.orderInfo.refundSendCostAmount)>0){
+				let couldRefundSendCost = parseFloat((Number(this.orderInfo.sendCost)-Number(this.orderInfo.refundSendCost)).toFixed(2))
+				if(Number(this.orderInfo.refundSendCostAmount)>Number(couldRefundSendCost)){
+					this.$message.error('运费超出可退金额')
+					return false
+				}
+			}
+			let refundParams = {
+				id:this.currentRefundData.id,
+				product:JSON.stringify(product),
+				price:this.refundMoney,
+				remark:this.remark,
+				refundType:this.refundType,
+				getOriginalItem:1,
+				cause:this.cause,
+				refundSendCost:this.orderInfo.refundSendCostAmount,
+				refundPackCost:this.orderInfo.refundPackCostAmount
+			};		
+			this.$service.refund.refund(refundParams).then(data => {						
+				if(data.error && data.error == 'hasUnClearOrder'){
+					that.needCancelRemind(data.clearId)
+					return false
+				}
+				that.$message.success('售后成功')
+				that.closeOpen()
+			})
+		},
+		needCancelRemind(id){
+			this.$message.error('有结账单取消了才能退款');
 		},
 		init() {
+
+			this.product=[]
+			this.refundMoney=0
+			this.refundType=1
+			this.cause=0
+			this.remark=''
+			this.orderInfo={}
+			this.couldRefundPrice=0
+			this.unClear={}
+
 			this.showDtail = true
 			this.$service.order.detail({id:this.currentRefundData.id,getOriginalItem:1}).then(data => {
 				this.orderInfo = {...data,refundPackCostAmount:'',refundSendCostAmount:''}
@@ -141,7 +280,7 @@ export default {
 
 				let customId = data.customId ? data.customId : 0
 				if(Number(customId)>0){
-					getUnClear({customId:customId}).then(result=>{
+					this.$service.clear.getUnClear({customId:customId}).then(result=>{
 						this.unClear = result.info
 					})
 				}
@@ -240,7 +379,7 @@ export default {
 		.list-title{
 			height: 20px;
 			padding-bottom:20px;
-			font-size:18px;
+			font-size:16px;
 			font-weight:bold;
 			.product-name{
 				overflow: hidden;

+ 1 - 1
ghs/src/views/order/list.vue

@@ -96,7 +96,7 @@
         <el-button v-else size="small" @click.stop="detailShowFn(scope.row)">详情</el-button>
         
         <template v-if="scope.row.book == 0">
-          <el-popconfirm title="确认已发货?" @confirm="confirmSend(scope.row)" @onConfirm="confirmSend(scope.row)" style="margin-left:10px;" v-if="scope.row.status!=5 && scope.row.status==2">
+          <el-popconfirm title="确认已发货?" @confirm="confirmSend(scope.row)" @onConfirm="confirmSend(scope.row)" style="margin-left:10px;margin-right:10px;" v-if="scope.row.status!=5 && scope.row.status==2">
             <el-button size="small" type="primary" slot="reference">确认发货</el-button>
           </el-popconfirm>
           <el-button size="small" v-else>确认发货</el-button>