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

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

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

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

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

+ 1 - 1
ghs/src/service/cg/index.js

@@ -3,4 +3,4 @@ import { BaseService, Service } from '@/cool';
 export class CgService extends BaseService {
 export class CgService extends BaseService {
 
 
 }
 }
-export default new CgService();
+export default new CgService();

+ 225 - 99
ghs/src/views/in/components/begin-refund.vue

@@ -1,101 +1,89 @@
 <template>
 <template>
-	<div class="order-detail">
-		<el-drawer :visible.sync="showDtail" size="750px" :before-close="closeFn" custom-class="order-draw-wrap" direction="ltr">
-			<div class="order-manage-wrap" v-if="!$util.isEmpty(detailInfo)">
-				<div class="card-wrap">
-					<div class="card-tit">
-						花材信息 (按 Esc 关闭窗口)
-					</div>
-					<div class="card-body">
-						<el-table :data="detailInfo.product">
-							<el-table-column label="图片">
-								<template slot-scope="scope">
-									<el-popover placement="right" width="200" trigger="hover">
-										<div style="width:200px;height:200px;">
-											<img style="width:100%;height:100%;object-fit: cover;" :src="scope.row.bigCover" />
-										</div>
-										<div style="width:30px;" slot="reference">
-											<img style="width:100%;height:100%;object-fit: cover;border-radius:5px;" :src="scope.row.cover" />
-										</div>
-									</el-popover>
-								</template>
-							</el-table-column>
-							<el-table-column property="name" label="名称"></el-table-column>
-							<el-table-column property="cost" label="成本"></el-table-column>
-							<el-table-column property="stock" label="剩余"></el-table-column>
-							<el-table-column label="单价">
-								<template slot-scope="scope">
-									<el-input v-model="scope.row.currentHdPrice" @focus="scope.row.currentHdPrice=''" placeholder="数量" style="width:50px;margin-right:2px;" 
-									:class="[Number(scope.row.cost)>Number(scope.row.currentHdPrice) ? 'cost-blue' : '']">
-									</el-input>元
-								</template>
-							</el-table-column>
-							<el-table-column label="数量">
-								<template slot-scope="scope">
-									<el-input v-model="scope.row.xhNum" placeholder="数量" @focus="scope.row.xhNum=''" style="width:50px;" 
-									:class="[Number(scope.row.xhNum)>Number(scope.row.stock) ? 'stock-red' : '']"></el-input>
-								</template>
-							</el-table-column>
-
-							<el-table-column label="操作">
-								<template slot-scope="scope">
-
-									<el-popconfirm title="确认删除?" @confirm="confirmDel(scope.row)" @onConfirm="confirmDel(scope.row)">
-										<el-button size="small" type="primary" slot="reference">删除</el-button>
-									</el-popconfirm>
-
-								</template>
-							</el-table-column>
-
-						</el-table>
-					</div>
-				</div>
+<div>
+	<el-drawer :visible.sync="showDtail" size="750px" custom-class="order-draw-wrap" direction="ltr">
+		<div class="order-manage-wrap" v-if="!$util.isEmpty(orderInfo)">
+			<div>
 				<div>
 				<div>
 					<div class="accounts-list">
 					<div class="accounts-list">
-						客户名称
-						<div class="accounts-center" style="font-weight:bold;color:black;">{{ detailInfo.customName||'' }}</div>
-					</div>
-					<div class="accounts-list">
-						商品金额
-						<div class="accounts-center" style="font-weight:bold;color:black;">¥{{itemPrice}}</div>
+						退款方式
+						<div class="accounts-center">
+							<div v-if="refundType==1">
+								<el-button type="primary" @click="refundType=1">退货并退款</el-button>
+								<el-button  @click="refundType=2" style="margin-left:20px;">仅退款</el-button>
+							</div>
+							<div v-else>
+								<el-button @click="refundType=1">退货并退款</el-button>
+								<el-button type="primary" @click="refundType=2" style="margin-left:20px;">仅退款</el-button>
+							</div>
+						</div>
 					</div>
 					</div>
-					<div class="accounts-list">
-						总计
-						<div class="accounts-center" style="font-weight:bold;color:black;">¥{{allPrice}}</div>
+				</div>
+				<div>
+					<div class="refund-item-list" v-if="refundType==1">
+						<div class="refund-label">选择花材</div>
+						<div>
+							<div class="list" v-for="(res,i) in product" :key="i">
+								<div class="flex list-title">
+									<span class="product-name">{{res.name}}</span>
+									<span class="product-num">{{ `${parseFloat(res.itemNum)}` }}{{res.bigUnit}}</span>
+									<span class="product-price">{{`${parseFloat(res.bigPrice)}`}}元/{{res.bigUnit}}</span>
+								</div>
+								<div class="flex list-val" style="font-size:18px;font-weight:bold;">
+									<input type="text" placeholder="退货数" v-model="res.refundCount" placeholder-style="color:#CCCCCC" />
+									<span style="margin-left:10px;">{{res.bigUnit}}</span>
+									<span style="color:green;margin-left:20px;">可退{{Number(res.itemNum)-Number(res.refundNum)}}{{res.bigUnit}}</span>
+								</div>
+								<div v-if="orderInfo.inBooking && orderInfo.inBooking == 1 && !$util.isEmpty(res.sendList)" style="border:1px solid #6795da;font-size:18px;margin:8px 0 5px 0;padding:5px 0 5px 0;">
+									<div v-for="(send,sendIndex) in res.sendList" style="padding:5px 5px 5px 8px;" :key="sendIndex">
+										<div>{{ send.customName }}({{ send.seatSn }}) 上架数 {{ send.num }}{{res.bigUnit}}</div>
+										<div style="border-bottom:1px solid #77a977;padding-bottom:6px;padding-top:4px;display: flex;align-items: center;margin-top:3px;">
+											<input type="text" placeholder="下架数" v-model="send.currentRefundNum" placeholder-style="color:#CCCCCC" style="border: 1rpx solid #ddd;width:140px;font-size:18px;text-align:center;margin-right:10px;" />
+											<span>可下架{{parseFloat((Number(send.num)-Number(send.outNum)).toFixed(2))}}{{res.bigUnit}}</span>
+										</div>
+									</div>
+								</div>
+							</div>
+						</div>
 					</div>
 					</div>
-					<div class="accounts-list">
-						预付金额
-						<div class="accounts-center" style="font-weight:bold;color:black;">¥{{ detailInfo.bookPrice ? parseFloat(detailInfo.bookPrice) : 0}}</div>
+				</div>
+				<div class="accounts-list">
+					订单金额
+					<div class="accounts-center">
+						¥{{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" style="font-weight:bold;color:green;;" v-if="settlePrice > 0">退 ¥{{settlePrice}},确认后自动退款</div>
-						<div class="accounts-center" style="font-weight:bold;color:red;" v-else-if="settlePrice < 0">欠 ¥{{Math.abs(settlePrice)}},确认后变成欠款单</div>
-						<div class="accounts-center" style="font-weight:bold;color:black;" v-else>0</div>
+				</div>
+				<div class="accounts-list">
+					可退金额
+					<div class="accounts-center">¥{{ couldRefundPrice }}</div>
+				</div>
+				<div class="accounts-list">
+					预计退款
+					<div class="accounts-center">¥{{refundPrice}}</div>
+				</div>
+				<div class="accounts-list">
+					实际退款
+					<div class="accounts-center">
+						<el-input v-model="refundMoney" placeholder="输入金额" style="width:120px;"></el-input>
 					</div>
 					</div>
-					<div class="accounts-list">
-						允许低于成本
-						<div class="accounts-center" style="">
-							<el-switch v-model="lessCostCould" active-value="1" inactive-value="0"></el-switch>
-						</div>
+				</div>
+				<div class="accounts-list">
+					备注内容
+					<div class="accounts-center">
+						<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="remark"> </el-input>
 					</div>
 					</div>
-	      		</div>
-				<div style="margin-left:80px;margin-top:20px;">
-					<el-button @click="closeFn">取消</el-button>
-
-					<el-popconfirm title="确认保存?" @confirm="savePrice()" @onConfirm="savePrice()" style="margin-left:80px;">
-						<el-button slot="reference">保存</el-button>
-					</el-popconfirm>
-
-					<el-popconfirm title="确认要提交?" @confirm="commitItem()" @onConfirm="commitItem()" style="margin-left:80px;">
-						<el-button type="primary" slot="reference">确认提交</el-button>
-					</el-popconfirm>
-
 				</div>
 				</div>
 			</div>
 			</div>
-			<div v-else  v-loading="loading" style="height:800px;"></div>
-		</el-drawer>
-	</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>
+		<div v-else v-loading="loading" style="height:800px;"></div>
+	</el-drawer>
+</div>
 </template>
 </template>
 <script>
 <script>
 export default {
 export default {
@@ -109,28 +97,116 @@ export default {
 	data() {
 	data() {
 		return {
 		return {
 			showDtail: false,
 			showDtail: false,
-			detailInfo: {},
-			loading:true
-		};
+			loading:true,
+			product:[],
+			refundMoney:0,
+			refundType:1,
+			remark:'',
+			orderInfo:{},
+			couldRefundPrice:0
+		}
 	},
 	},
 	computed: {
 	computed: {
-
+		refundPrice(){
+			let price = 0
+			if(this.product){
+				for (const item of this.product) {
+					if(Number(item.refundCount)>0){
+						let currentPrice = Number(item.refundCount)*Number(item.bigPrice)
+						currentPrice.toFixed(2)
+						price = Number(price) + Number(currentPrice)
+						price.toFixed(2)
+					}
+				}
+			}
+			price = parseFloat(price.toFixed(2))
+			this.refundMoney = price
+			return price
+		}
 	},
 	},
 	methods: {
 	methods: {
+		confirmRefund(){
+			let hasError = false
+			let product = []
+			let that = this
+			let sendData = null
+			this.product.forEach(ele=>{
+				let currentRefundCont = ele.refundCount ? Number(ele.refundCount) :0
+				let currentNum = ele.itemNum ? Number(ele.itemNum) : 0
+				let hasRefundNum = ele.refundNum ? Number(ele.refundNum) : 0
+				let couldRefundNum = Number(currentNum) - Number(hasRefundNum)
+				if(Number(currentRefundCont) > Number(couldRefundNum)){
+					uni.showToast({title:ele.name+'超过可退数量',icon:'none'})
+					hasError = true;
+					return false
+				}
+				//货位的售后和下架
+				sendData = []
+				if(!this.$util.isEmpty(ele.sendList)){
+					ele.sendList.forEach(sendele=>{
+						if(sendele.currentRefundNum && parseFloat(sendele.currentRefundNum)>0){
+							sendData.push({id:sendele.id,refundNum:sendele.currentRefundNum})
+						}
+					})
+				}
+				if(Number(ele.refundCount)>0){
+					product.push({
+						productId:ele.productId,
+						num:ele.refundCount,
+						unitType:0,
+						unitName:ele.bigUnit,
+						unitPrice:ele.bigPrice,
+						sendRefund:sendData
+					})
+				}
+			})
+			if(hasError){
+				return
+			}
+			if(this.$util.isEmpty(product)&&this.refundType==1){
+				uni.showToast({title:'请选择花材',icon:'none'})
+				return;
+			}
+			let refundParams = {
+				id:this.orderInfo.id,
+				product:JSON.stringify(product),
+				price:this.refundMoney,
+				remark:this.remark,
+				refundType:this.refundType
+			};
+			this.$service.cgRefund.createOrder(refundParams).then(data => {
+				this.$message.success('操作成功')
+				this.closeOpen()
+			})
+		},
 		init() {
 		init() {
-			this.data = []
+
+			this.product = []
+			this.refundMoney = 0
+			this.refundType = 1
+			this.remark = '',
+			this.orderInfo = {}
+			this.couldRefundPrice = 0
+
 			this.showDtail = true
 			this.showDtail = true
-			this.$service.purchaseOrder.detail({orderSn:this.currentRefundData.orderSn}).then(res => {
-				this.detailInfo = res
+			this.$service.purchaseOrder.detail({orderSn:this.currentRefundData.orderSn}).then(data => {
+				this.orderInfo = data
+
+				this.couldRefundPrice = Number(data.orderPrice) - Number(data.tkPrice)
+				this.couldRefundPrice = this.couldRefundPrice.toFixed(2)
+				this.couldRefundPrice = parseFloat(this.couldRefundPrice)
+
+				this.product = data.itemInfo.map(ele=>{
+					return {...ele,refundCount:null}
+				})
 			})
 			})
 		},
 		},
-		closeFn() {
+		closeOpen() {
 			this.showDtail = false;
 			this.showDtail = false;
 		}
 		}
 	}
 	}
 };
 };
 </script>
 </script>
-
 <style lang="scss">
 <style lang="scss">
 .order-draw-wrap {
 .order-draw-wrap {
 	.el-drawer__header {
 	.el-drawer__header {
@@ -163,7 +239,6 @@ export default {
 	height: calc(100vh - 64px);
 	height: calc(100vh - 64px);
 	overflow-y: auto;
 	overflow-y: auto;
 	padding-bottom: 20px;
 	padding-bottom: 20px;
-
 	.accounts-list{
 	.accounts-list{
 		width: 80%;
 		width: 80%;
 		display: flex;
 		display: flex;
@@ -175,7 +250,6 @@ export default {
 		width: 80%;
 		width: 80%;
 		}
 		}
 	}
 	}
-
 }
 }
 .card-wrap {
 .card-wrap {
 	margin: 20px;
 	margin: 20px;
@@ -205,4 +279,56 @@ export default {
 		border:2px solid blue;
 		border:2px solid blue;
 	}
 	}
 }
 }
+.refund-item-list{
+	display: flex;
+	padding-bottom: 30px;
+	padding-top: 30px;
+	.refund-label{
+		width: 200px;
+		color:black;
+		font-size:16px;
+		text-align:center;
+	}
+	.list{
+		margin-bottom: 10px;
+		.list-title{
+			height: 20px;
+			padding-bottom:20px;
+			font-size:18px;
+			font-weight:bold;
+			.product-name{
+				overflow: hidden;
+				text-overflow:ellipsis;
+				white-space: nowrap;
+				width:160px;
+				height:30px;
+			}
+			.product-price{
+				overflow: hidden;
+				text-overflow:ellipsis;
+				white-space: nowrap;
+				width:130px;
+				margin-left:0px;
+				height:30px;
+			}
+			.product-num{
+				width:90px;
+				overflow: hidden;
+				text-overflow:ellipsis;
+				white-space: nowrap;
+				margin-left:0px;
+				height:30px;
+			}
+		}
+		.list-val{
+			input{
+				width:150px;
+				height:28px;
+				border: 1px solid #ddd;
+				text-align: center;
+				font-weight: normal;
+			}
+		}
+	}
+}
 </style>
 </style>