| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
- <template>
- <view class="refund-page">
- <!-- 商品选择卡片 -->
- <view class="card-section">
- <view class="section-title">
- <text class="title-text">退货商品</text>
- </view>
- <view class="product-list-compact">
- <template v-if="!$util.isEmpty(goodsInfoList)">
- <view class="product-row" v-for="(res,i) in goodsInfoList" :key="i">
- <view class="product-basic-info">
- <text class="product-name-compact">{{res.name}}</text>
- <view class="product-meta">
- <text class="stock-info">{{parseFloat(res.num)}}份 X ¥{{parseFloat(res.unitPrice)}}</text>
- <text class="available-info">可退 {{Number(res.num)-Number(res.refundNum)}}份</text>
- </view>
- </view>
- <view class="refund-control">
- <view class="refund-input-group">
- <view class="input-item">
- <text class="input-label">数量</text>
- <input
- class="refund-input-compact"
- type="number"
- placeholder="0"
- v-model="res.refundCount"
- placeholder-style="color:#ccc"
- @focus="clearRefundCount(res)" />
- <text class="unit-label">份</text>
- </view>
- <view class="input-item">
- <text class="input-label">单价</text>
- <input
- class="refund-input-compact"
- type="digit"
- placeholder="0.00"
- v-model="res.perPrice"
- placeholder-style="color:#ccc"
- @focus="clearPerPrice(res)" />
- <text class="unit-label">元</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <template v-if="!$util.isEmpty(itemInfoList)">
- <view class="product-row" v-for="(res,i) in itemInfoList" :key="i">
- <view class="product-basic-info">
- <text class="product-name-compact">{{res.name}}</text>
- <view class="product-meta">
- <text class="stock-info">{{parseFloat(res.num)}}{{res.unitName}} X ¥{{parseFloat(res.unitPrice)}}</text>
- <text class="available-info">可退 {{Number(res.num)-Number(res.refundNum)}}{{res.unitName}}</text>
- </view>
- </view>
- <view class="refund-control">
- <view class="refund-input-group">
- <view class="input-item">
- <text class="input-label">数量</text>
- <input
- class="refund-input-compact"
- type="number"
- placeholder="0"
- v-model="res.refundCount"
- placeholder-style="color:#ccc"
- @focus="clearRefundCount(res)" />
- <text class="unit-label">{{res.unitName}}</text>
- </view>
- <view class="input-item">
- <text class="input-label">单价</text>
- <input
- class="refund-input-compact"
- type="digit"
- placeholder="0.00"
- v-model="res.perPrice"
- placeholder-style="color:#ccc"
- @focus="clearPerPrice(res)" />
- <text class="unit-label">元</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- </view>
- </view>
- <!-- 金额信息卡片 -->
- <view class="card-section">
- <view class="section-title">
- <text class="title-text">金额信息</text>
- </view>
- <view class="amount-info">
- <view class="amount-row">
- <text class="amount-label">订单金额</text>
- <view class="amount-value">
- <text class="price-text">¥{{parseFloat(orderInfo.orderPrice)||0}}</text>
- </view>
- </view>
- <view class="amount-row" v-if="Number(orderInfo.tkPrice)>0">
- <text class="amount-label">已退金额</text>
- <view class="amount-value">
- <text class="refunded-text">¥{{orderInfo.tkPrice ? parseFloat(orderInfo.tkPrice) : 0}}</text>
- </view>
- </view>
- <view class="amount-row">
- <text class="amount-label">可退金额</text>
- <text class="amount-value available-amount">¥{{coundRefundPrice}}</text>
- </view>
- <view class="amount-row input-row">
- <text class="amount-label required">退款金额</text>
- <view class="amount-input-wrapper">
- <text class="currency-symbol">¥</text>
- <input
- class="amount-input"
- type="digit"
- v-model="refundMoney"
- placeholder="请输入"
- placeholder-style="color:#999"
- @focus="clearRefundMoney">
- </view>
- </view>
- </view>
- </view>
- <!-- 退款方式选择卡片 -->
- <view class="card-section">
- <view class="section-title">
- <text class="title-text">库存变化</text>
- </view>
- <view class="refund-type-buttons">
- <button
- class="admin-button-com big"
- :class="refundType==1?'blue':'default'"
- @tap="refundType=1">
- 库存退回来
- </button>
- <button
- class="admin-button-com big"
- :class="refundType==2?'blue':'default'"
- @tap="refundType=2">
- 库存不退回
- </button>
- </view>
- </view>
- <!-- 备注卡片 -->
- <view class="card-section">
- <view class="section-title">
- <text class="title-text">备注</text>
- </view>
- <view class="remark-container">
- <textarea
- class="remark-textarea"
- v-model="remark"
- placeholder="选填"
- placeholder-style="color:#999"
- @focus="clearRemark" />
- </view>
- </view>
- <!-- 底部操作按钮 -->
- <view class="bottom-actions">
- <button class="action-btn cancel-btn" @tap="cancelRefund">取消</button>
- <button class="action-btn confirm-btn" @tap="confirmRefund">确认退款</button>
- </view>
- </view>
- </template>
- <script>
- import { getDetail,refund } from "@/api/order/index";
- export default {
- name: "orderDetail",
- components: {},
- data() {
- return {
- goodsInfoList:[],
- itemInfoList:[],
- refundMoney:0,
- refundType:0,
- remark:'',
- orderInfo:{},
- coundRefundPrice:0
- };
- },
- computed:{
- refundPrice(){
- let price = 0
- if(!this.$util.isEmpty(this.goodsInfoList)){
- for (const item of this.goodsInfoList) {
- if(Number(item.refundCount)>0){
- let currentPrice = Number(item.refundCount)*Number(item.perPrice || item.unitPrice)
- currentPrice.toFixed(2)
- price = Number(price) + Number(currentPrice)
- price.toFixed(2)
- }
- }
- }
- if(!this.$util.isEmpty(this.itemInfoList)){
- for (const item of this.itemInfoList) {
- if(Number(item.refundCount)>0){
- let currentPrice = Number(item.refundCount)*Number(item.perPrice || item.unitPrice)
- currentPrice.toFixed(2)
- price = Number(price) + Number(currentPrice)
- price.toFixed(2)
- }
- }
- }
- this.refundMoney = parseFloat(price.toFixed(2))
- return price
- }
- },
- methods: {
- clearRefundCount(item) {
- this.$set(item, 'refundCount', '');
- },
- clearPerPrice(item) {
- this.$set(item, 'perPrice', '');
- },
- clearRefundMoney() {
- this.refundMoney = '';
- },
- clearRemark() {
- this.remark = '';
- },
- cancelRefund(){
- uni.navigateBack({delta: 1});
- },
- confirmRefund(){
- let hasError = false
- let selectProduct = []
- let that = this
- if(!this.$util.isEmpty(this.goodsInfoList)){
- this.goodsInfoList.forEach(ele=>{
- let currentRefundCont = ele.refundCount ? Number(ele.refundCount) :0
- let currentNum = ele.num ? Number(ele.num) : 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
- }
- if(Number(ele.refundCount)>0){
- if(Number(ele.perPrice)>Number(ele.unitPrice)){
- uni.showToast({title:ele.name+' 退款单价不能大于原价',icon:'none'})
- hasError = true;
- return false
- }
- selectProduct.push({"productId":ele.goodsId,"num":ele.refundCount,"unitType":ele.unitType,unitName:ele.unitName,unitPrice:ele.perPrice || ele.unitPrice,property:0})
- }
- })
- }
- if(!this.$util.isEmpty(this.itemInfoList)){
- this.itemInfoList.forEach(ele=>{
- let currentRefundCont = ele.refundCount ? Number(ele.refundCount) :0
- let currentNum = ele.num ? Number(ele.num) : 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
- }
- if(Number(ele.refundCount)>0){
- if(Number(ele.perPrice)>Number(ele.unitPrice)){
- uni.showToast({title:ele.name+' 退款单价不能大于原价',icon:'none'})
- hasError = true;
- return false
- }
- selectProduct.push({"productId":ele.itemId,"num":ele.refundCount,"unitType":ele.unitType,unitName:ele.unitName,unitPrice:ele.perPrice || ele.unitPrice,property:1})
- }
- })
- }
- if(hasError){
- return
- }
- if(this.$util.isEmpty(selectProduct)){
- uni.showToast({title:'请选择商品',icon:'none'})
- return;
- }
- if(this.refundType==0){
- uni.showToast({title:'请选择 库存退否退回',icon:'none'})
- return false
- }
- let refundParams = {product:JSON.stringify(selectProduct),id: this.option.id,price:this.refundMoney,remark:this.remark,refundType:this.refundType,getOriginalItem:1,version:2}
- that.$util.confirmModal({content:'确认退款?'},() => {
- uni.showLoading({mask:true})
- refund(refundParams).then(res => {
- uni.hideLoading()
- if(res.code == 1){
- this.$util.pageTo({url:'/common/success',query:{titleType:1},type:2})
- }
- })
- })
- },
- async init() {
- const res = await getDetail({ id: this.option.id})
- this.orderInfo = res.data
-
- this.coundRefundPrice = Number(res.data.orderPrice) - Number(res.data.tkPrice)
- this.coundRefundPrice = this.coundRefundPrice.toFixed(2)
- this.coundRefundPrice = parseFloat(this.coundRefundPrice)
- this.goodsInfoList = res.data.goodsInfoList.map(ele=>{
- return {...ele,refundCount:null,perPrice:''}
- })
- this.itemInfoList = res.data.itemInfoList.map(ele=>{
- return {...ele,refundCount:null,perPrice:''}
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .refund-page {
- min-height: 100vh;
- background: #f5f6f8;
- padding: 20upx 0 200upx;
- }
- // 卡片样式
- .card-section {
- background: #fff;
- margin: 0 20upx 20upx;
- border-radius: 16upx;
- box-shadow: 0 2upx 12upx rgba(0, 0, 0, 0.08);
- overflow: hidden;
- }
- // 节标题
- .section-title {
- padding: 30upx 30upx 20upx;
- border-bottom: 1upx solid #f0f0f0;
- display: flex;
- align-items: center;
-
- .title-text {
- font-size: 32upx;
- font-weight: 600;
- color: #333;
- }
-
- .required-mark {
- color: #ff4757;
- font-size: 32upx;
- margin-left: 8upx;
- }
- }
- // 退款方式按钮
- .refund-type-buttons {
- padding: 30upx 30upx 20upx;
- display: flex;
- gap: 30upx;
-
- .admin-button-com {
- flex: 1;
- border-radius: 12upx;
- font-weight: 500;
- transition: all 0.3s ease;
- }
- }
- // 紧凑商品列表
- .product-list-compact {
- margin-top:15upx;
- padding: 0 20upx 20upx;
- }
- .product-row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 20upx;
- margin-bottom: 8upx;
- background: #fafbfc;
- border-radius: 8upx;
- border: 1upx solid #eef0f2;
-
- &:last-child {
- margin-bottom: 0;
- }
-
- &:active {
- background: #f0f8ff;
- }
- }
- .product-basic-info {
- flex: 1;
- margin-right: 20upx;
-
- .product-name-compact {
- font-size: 30upx;
- font-weight: 600;
- color: #333;
- line-height: 1.3;
- display: block;
- margin-bottom: 8upx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- width: 360upx;
- }
-
- .product-meta {
- display: flex;
- gap: 12upx;
- flex-wrap: wrap;
-
- .stock-info {
- font-size: 28upx;
- color: #666;
- background: #f5f5f5;
- padding: 4upx 8upx;
- border-radius: 4upx;
- }
-
- .available-info {
- font-size: 28upx;
- color: #ff6b35;
- background: rgba(255, 107, 53, 0.1);
- padding: 4upx 8upx;
- border-radius: 4upx;
- }
- }
- }
- .refund-control {
- display: flex;
- align-items: center;
- gap: 8upx;
-
- .refund-input-group {
- display: flex;
- flex-direction: column;
- gap: 12upx;
-
- .input-item {
- display: flex;
- align-items: center;
- gap: 8upx;
-
- .input-label {
- font-size: 22upx;
- color: #666;
- min-width: 60upx;
- }
- }
- }
-
- .refund-input-compact {
- width: 100upx;
- height: 60upx;
- background: #fff;
- border: 1upx solid #ddd;
- border-radius: 6upx;
- text-align: center;
- font-size: 26upx;
- color: #333;
- font-weight: 500;
-
- &:focus {
- border-color: #09c567;
- box-shadow: 0 0 0 2upx rgba(9, 197, 103, 0.2);
- }
- }
-
- .unit-label {
- font-size: 24upx;
- color: #666;
- min-width: 40upx;
- }
- }
- // 金额信息
- .amount-info {
- padding: 30upx;
- }
- .amount-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20upx 0;
- border-bottom: 1upx solid #f0f0f0;
-
- &:last-child {
- border-bottom: none;
- }
-
- &.input-row {
- align-items: flex-start;
- padding-top: 30upx;
- }
-
- .amount-label {
- font-size: 28upx;
- color: #666;
-
- &.required::after {
- content: "*";
- color: #ff4757;
- margin-left: 5upx;
- }
- }
-
- .amount-value {
- display: flex;
- align-items: center;
-
- .price-text {
- font-size: 32upx;
- font-weight: 600;
- color: #333;
- }
-
- .refunded-text {
- margin-left: 20upx;
- font-size: 24upx;
- color: #09c567;
- background: rgba(9, 197, 103, 0.1);
- padding: 6upx 12upx;
- border-radius: 16upx;
- }
-
- &.available-amount {
- font-size: 32upx;
- font-weight: 600;
- color: #09c567;
- }
- }
- }
- .amount-input-wrapper {
- display: flex;
- align-items: center;
- background: #fafbfc;
- border: 1upx solid #ddd;
- border-radius: 8upx;
- padding: 0 20upx;
- width: 210upx;
-
- &:focus-within {
- border-color: #09c567;
- }
-
- .currency-symbol {
- font-size: 28upx;
- color: #666;
- margin-right: 10upx;
- }
-
- .amount-input {
- flex: 1;
- height: 80upx;
- font-size: 28upx;
- color: #333;
- font-weight: 500;
- border: none;
- background: transparent;
- width: 135upx;
- }
- }
- // 备注输入框
- .remark-container {
- padding: 20upx 30upx 30upx;
- }
- .remark-textarea {
- width: 100%;
- height: 120upx;
- background: #fafbfc;
- border: 1upx solid #ddd;
- border-radius: 8upx;
- padding: 15upx;
- font-size: 28upx;
- color: #333;
- line-height: 1.2;
- box-sizing: border-box;
- resize: none;
-
- &:focus {
- border-color: #09c567;
- }
- }
- // 警告提示
- .warning-notice {
- background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
- margin: 0 20upx 20upx;
- border-radius: 16upx;
- border-left: 6upx solid #f39c12;
- padding: 30upx;
- display: flex;
- align-items: flex-start;
-
- .warning-icon {
- font-size: 40upx;
- margin-right: 20upx;
- margin-top: 5upx;
- }
-
- .warning-text {
- flex: 1;
-
- .warning-title {
- font-size: 28upx;
- font-weight: 600;
- color: #d68910;
- margin-bottom: 12upx;
- }
-
- .warning-content {
- font-size: 26upx;
- color: #85751a;
- line-height: 1.5;
- }
- }
- }
- // 底部操作按钮
- .bottom-actions {
- z-index:9999;
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background: #fff;
- padding: 30upx;
- border-top: 1upx solid #eee;
- display: flex;
- gap: 30upx;
- box-shadow: 0 -4upx 12upx rgba(0, 0, 0, 0.1);
- }
- .action-btn {
- flex: 1;
- height: 88upx;
- border-radius: 12upx;
- font-size: 32upx;
- font-weight: 600;
- border: none;
- transition: all 0.3s ease;
-
- &.cancel-btn {
- background: #f8f9fa;
- color: #666;
- border: 1upx solid #ddd;
-
- &:active {
- background: #e9ecef;
- }
- }
-
- &.confirm-btn {
- background: linear-gradient(135deg, #09c567 0%, #00b894 100%);
- color: #fff;
- box-shadow: 0 4upx 12upx rgba(9, 197, 103, 0.3);
-
- &:active {
- transform: translateY(2upx);
- box-shadow: 0 2upx 8upx rgba(9, 197, 103, 0.3);
- }
- }
- }
- </style>
|