You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

878 lines
21 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view>
<topnav :title='pageTitle' @tohome='tohome'></topnav>
<view class="content">
<orderinfo :info="order"></orderinfo>
<view class="pageTitle">请选择结算到的日期</view>
<view class="listBox" style="margin-top: 30rpx;">
<picker mode="date" :value="to_date" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="listBoxItem">
<view class="listBoxItemLeft">
<view class="vred">*</view>日期
</view>
<view class="listBoxItemRight">
<text class="novalue" v-if="to_date==''"></text>
<text v-else>{{to_date}}</text>
<text class="iconfont icon-Icons_ToolBar_ArrowRight"></text>
</view>
</view>
</picker>
</view>
<view class="orderitembox" v-if="orderItems.length>0">
<view class="pageTitle" style="position: sticky;top: 160rpx;padding-top: 30rpx;
padding-bottom:30rpx;background-color: #F2F2F2;margin-top: 0rpx;">
<text>子订单
</text>
</view>
<view class="l-orderitem listBox"
style="position: sticky;top: 254rpx;margin-bottom: 0rpx;margin-top: 0rpx;">
<view class="listBoxItem">
<view class="listBoxItemLeft" @click="bindAllItemCheck">
<text class="iconfont icon-check3" :class="checkAll?'icon-check3-on':''"></text>
<text class="tdate">合计 {{chklength}}/{{orderItems==null?0:orderItems.length}}</text>
</view>
<view class="listBoxItemRight">
<view class="l-btn l-btnConfirm " v-if="order.status!=100" @click="bindAllItemEdit">
<text class=" l-btnTxt l-btnConfirmTxt">编辑</text>
</view>
</view>
</view>
</view>
<view class="l-orderitem listBox" style="margin-top: 0rpx;">
<block v-for="(item,index) in orderItems">
<view class="listBoxItem">
<view class="listBoxItemLeft" @click="bindItemCheck" :data-index="index">
<text class="iconfont icon-check3" :class="item.checked?'icon-check3-on':''"></text>
<text class="tdate">{{item.service_date}}</text>
<text class="tname">{{item.paramedic==null?'':item.paramedic.name}}</text>
<text class="ttag">{{item.patient_quantity>1?"1对多":"1对1"}}</text>
<text class="tamt">{{item.total==null?"0":"¥"+item.total}}</text>
</view>
<view class="listBoxItemRight" @click="bindItemEdit" :data-item="item">
<text class="tstatus tstatuson">{{item.paid_status}}</text>
<text class="iconfont icon-edit" v-if="order.status!=100"
style="margin-left: 40rpx;"></text>
</view>
</view>
<view class="listBoxline"></view>
</block>
</view>
</view>
<view v-if='torechargetotal>0'>
<view class="pageTitle">请选择收款方式</view>
<view class="payList" style="margin-top: 30rpx;">
<view class="l-box">
<block v-for="(item,index) in paylist">
<view class="l-box-info" @click="tochange" :data-index="index">
<view class="l-box-info-left" :data-index="index">
<view class="l-box-info-left-logo">
<image :src="item.img" class="icon_logo"></image>
</view>
<view class="l-box-info-left-rinfo">
<view class="l-box-info-left-title">
{{item.name}}
</view>
<view class="l-box-info-left-ftitle">
{{item.comment}}
</view>
</view>
</view>
<view class="l-box-info-right">
<text class="iconfont icon-check icon-check-in" v-if="item.chekced"></text>
<text class="iconfont icon-check" v-else></text>
</view>
</view>
</block>
</view>
</view>
<view class="payBox">
<view class="listBox mp-20">
<view class="listBoxItem">
<view class="listBoxItemLeft">
<view class="vred"> </view>备注
</view>
<view class="listBoxItemRight">
<input type="text" class="listBoxItemInput"
placeholder-class="listBoxItemInputPlaceholder" placeholder="请输入"
@input='bindChangeComment' @confirm='bindPay' />
</view>
</view>
</view>
</view>
</view>
</view>
<view v-if='torefundtotal==0'>
<view class="bottom" v-if='torechargetotal>0'>
<view class="bottomLeft">
<text class="priceTitle">收款金额:</text>
<text class="priceInfo">¥{{torechargetotal}}</text>
</view>
<view class="bottomRight">
<view class="btnSubmit btn" @click="bindPay">确认收款</view>
</view>
</view>
<view class="bottom" v-else-if="torechargetotal==0&&isCanfinish">
<view class="bottomLeft">
</view>
<view class="bottomRight" style="flex: 1;">
<view class="btnSubmit btn" style="width: 100%;" @click="bindBudget">确认结算</view>
</view>
</view>
<view class="bottom" v-else>
<view class="bottomLeft">
</view>
<view class="bottomRight" style="flex: 1;">
<view class="btnCancel btn" style="width: 100%;" @click="bindBack">返回</view>
</view>
</view>
</view>
<view v-else>
<view class="bottom" v-if='torefundtotal>0'>
<view class="bottomLeft">
<text class="priceTitle">退款金额:</text>
<text class="priceInfo">¥{{torefundtotal}}</text>
</view>
<view class="bottomRight">
<view class="btnSubmit btn" style="background-color: #ED4242;" @click="bindRefund">退</view>
</view>
</view>
</view>
</view>
</template>
<script>
var util = require("../../../../utils/util.js");
var app = getApp();
export default {
data() {
return {
pageTitle: "订单结算",
windowHeight: 720,
windowWidth: 720,
isCanfinish: true,
orderItems: [],
order: {
"id": 731,
"serial": "",
"customer_id": 16,
"manager_id": null,
"bed_id": 778,
"patient_id": 793,
"project_id": 1,
"product_id": 1,
"product_item_id": 1,
"product_paramedic_level_id": 1,
"from_date": "",
"to_date": "",
"status": 0,
"total": 150,
"paid_total": 0,
"contact": null,
"mobile": "13912797667",
"paramedic_id": 31,
"price": "150.00",
"patient_quantity": null,
"created_at": "",
"updated_at": "",
"balance": "0.00",
"status_name": "",
"days": 0,
"product_item": {
"id": 1,
"name": "一对一"
},
"paramedic_level": {
"id": 8,
"name": "普通护工",
"laravel_through_key": 1
},
"project": {
"id": 1,
"name": "武进中医院",
"logo_url": null,
"banners_url": null
},
"bed": {
"id": 778,
"name": "1",
"room_name": "101",
"area_name": "一楼(十九病区)",
"building_name": "内科楼"
},
"customer": {
"id": 16,
"name": null,
"balance": "0.00"
},
"patient": {
"id": 793,
"name": "",
"sex": null,
"age": null,
"mobile": null
},
"paramedic": {
"id": 31,
"name": "",
"mobile": "15850579275",
"paramedic_level_name": "普通护工",
"avatar_url": null,
"age": "",
"status_name": null
},
"factorjson": [{
"fee": "0.00",
"price": "0.00",
"factor_id": 1,
"factor_name": "所在科室",
"fee_percent": "25.00",
"used_for_fee": 1,
"factor_item_id": 2,
"factor_item_name": "骨科"
}]
},
totalPrice: 0,
paylist: [{
name: "微信支付",
comment: "推荐微信用户使用",
chekced: true,
img: "/static/resources/weixin.png",
type: "weixin"
}, {
name: "支付宝支付",
comment: "推荐支付宝用户使用",
chekced: false,
img: "/static/resources/alipay.png",
type: "alipay"
}, {
name: "刷卡支付",
comment: "推荐刷卡用户使用",
chekced: false,
img: "/static/resources/pos.png",
type: "pos"
}, {
name: "现金支付",
comment: "推荐现金",
chekced: false,
img: "/static/resources/cash.png",
type: "cash"
}],
payType: "weixin",
id: "",
moneyArr: [],
comment: "",
selectOtherAmt: false,
showPopAmt: false,
focusAmtSet: false,
to_date: "",
torechargetotal: 0,
torefundtotal: 0,
refund: {},
isCanfinish: false,
chklength: 0,
checkAll: false
}
},
onLoad: function(option) {
var that = this;
this.id = option.id;
this.windowHeight = app.globalData.winHeight;
this.windowWidth = app.globalData.winWidth;
that.loadInfo(that.id, "init");
},
onShow: function(option) {},
computed: {
startDate() {
return this.getDate('start');
},
endDate() {
return this.getDate('end');
}
},
methods: {
tohome: function() {
uni.navigateTo({
url: "../../../../pages/index/index"
})
},
bindBack: function() {
uni.navigateBack({
})
},
loadInfo(id, from) {
var that = this;
util.getOrderInfo(id, function(r) {
that.order = r.data;
that.orderItems = r.data.order_items;
that.loadMoneyArr(that.order.price);
if (from != "afterPay")
that.to_date = that.$moment().format("yyyy-MM-DD") //that.order.to_date;
//that.to_date = that.order.to_date;
that.checkoutorder(id, true, that.to_date)
}, function() {
})
},
bindDateChange: function(e) {
var that = this;
that.to_date = e.target.value
that.checkoutorder(that.id, true, e.target.value)
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
openPop() {
// 通过组件定义的ref调用uni-popup方法
this.$refs.popup.open();
this.focusAmtSet = true;
},
closePop() {
// 通过组件定义的ref调用uni-popup方法
this.$refs.popup.close()
},
bindClickMoney: function(e) {
var index = e.currentTarget.dataset.index;
var _moneyArr = this.moneyArr;
for (var m of _moneyArr) {
m.checked = false;
}
_moneyArr[index].checked = true;
console.log(_moneyArr[index])
this.moneyArr = _moneyArr;
this.totalPrice = _moneyArr[index].amt;
this.selectOtherAmt = false;
this.closePop();
},
tochange: function(e) {
var index = e.currentTarget.dataset.index;
var _paylist = this.paylist;
for (var m of _paylist) {
m.chekced = false;
}
_paylist[index].chekced = true;
this.paylist = _paylist;
this.payType = _paylist[index].type;
},
bindinputotheramt: function() {
var _moneyArr = this.moneyArr;
for (var m of _moneyArr) {
m.checked = false;
}
this.moneyArr = _moneyArr;
this.totalPrice = 0;
this.selectOtherAmt = true;
this.openPop();
},
bindPopOk: function() {
if (this.totalPrice == 0) {
util.alert('请输入金额');
return false;
}
this.closePop();
},
bindPay: function(e) {
var that = this;
if (this.totalPrice == 0 || util.isNull(this.totalPrice)) {
util.alert('请输入金额');
return false;
}
if (util.isNull(that.payType)) {
util.alert('请选择收款方式');
return false;
}
switch (that.payType) {
case "weixin": // 只允许通过相机扫码
uni.scanCode({
onlyFromCamera: true,
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
util.scanPay(that.id, that.totalPrice, res.result, that.payType,
function(res) {
uni.showModal({
title: "收款成功",
success: function() {
that.processAfterPay(res, that.id);
}
})
},
function(res) {
util.alert("收款失败:" + res);
})
}
});
break;
case "alipay": // 只允许通过相机扫码
uni.scanCode({
onlyFromCamera: true,
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
util.scanPay(that.id, that.totalPrice, res.result, that.payType,
function(res) {
uni.showModal({
title: "收款成功",
success: function() {
that.processAfterPay(res, that.id);
}
})
},
function(res) {
util.alert("收款失败:" + res);
})
}
});
break;
case "cash":
case "pos":
uni.showModal({
title: '提示',
content: "确认收款¥[" + that.totalPrice + "],收款方式[" + (that.payType == 'cash' ? '现金' :
'刷卡') + "]",
confirmText: "确认",
confirmColor: "#000",
cancelColor: "#eee",
success(res) {
if (res.confirm) {
that.doReceivedMoney(that.id);
}
}
});
break;
}
},
doReceivedMoney: function(id) {
var that = this;
util.request({
bindThis: that,
method: 'POST',
customLoading: false,
api: 'manager/recharge-for-order/' + id,
data: {
payment: that.payType,
money: that.totalPrice,
remark: that.comment
},
utilSuccess: function(res) {
console.log('3提交成功返回');
console.log(res);
uni.showModal({
title: "收款成功",
success: function() {
that.processAfterPay(res, id);
}
})
},
utilFail: function(res) {
console.log('4提交失败' + res);
util.alert(res);
}
});
},
bindChangeMoney: function(e) {
this.totalPrice = e.detail.value;
},
processAfterPay: function(res, id) {
var that = this;
that.loadInfo(id, "afterPay");
},
loadMoneyArr: function(price) {
var moneyArr = [];
var that = this;
for (var i = 1; i <= 6; i++) {
var c = false;
if (i == 3) {
c = true;
that.totalPrice = i * price;
}
moneyArr.push({
amt: i * price,
checked: c
});
}
this.moneyArr = moneyArr;
},
bindChangeComment: function(e) {
this.comment = e.detail.value;
},
bindBudget: function() {
var that = this;
uni.showModal({
title: '提示',
content: "确认结算?",
confirmText: "确认",
confirmColor: "#000",
cancelColor: "#eee",
success(res) {
if (res.confirm) {
that.checkoutorder(that.id, false, that.to_date);
}
}
});
},
checkoutorder: function(id, justCheck, todate) {
var that = this;
util.request({
bindThis: that,
method: 'POST',
customLoading: false,
api: 'manager/checkout-order/' + id,
data: {
to_date: todate,
just_check: justCheck
},
utilSuccess: function(res) {
that.isCanfinish = true;
if (justCheck) {
console.log(res);
that.torechargetotal = res.to_recharge_total;
that.totalPrice = res.to_recharge_total;
that.torefundtotal = res.to_refund_total;
that.refund = res;
} else {
uni.showModal({
title: "结算成功",
success: function() {
uni.navigateTo({
url: "../orderinfo/orderinfo?id=" + that.id
})
}
})
}
},
utilFail: function(res) {
console.log('4提交失败' + res);
util.alert(res);
that.isCanfinish = false;
}
});
},
bindRefund: function() {
var that = this;
uni.showModal({
title: '提示',
content: "确认退款?",
confirmText: "确认",
confirmColor: "#000",
cancelColor: "#eee",
success(res) {
if (res.confirm) {
that.doRefund(that.id);
}
}
});
},
doRefund: function(id) {
var that = this;
util.request({
bindThis: that,
method: 'POST',
customLoading: false,
api: 'manager/refund-for-order/' + id,
data: {
money: that.refund.to_refund_total,
payment: that.refund.refund_payment,
recharge_id: that.refund.refund_recharge_id,
remark: that.comment
},
utilSuccess: function(res) {
uni.showModal({
title: "退款成功",
success: function() {
that.loadInfo(id, "afterPay");
}
})
},
utilFail: function(res) {
console.log('4提交失败' + res);
util.alert(res);
}
});
},
bindAllItemCheck: function(e) {
this.checkAll = !this.checkAll;
var _items = this.orderItems;
for (var m of _items) {
if (this.checkAll)
m.checked = true
else
m.checked = false
}
this.orderItems = _items;
this.chklength = this.checkAll ? this.orderItems.length : 0;
},
bindItemCheck: function(e) {
var index = e.currentTarget.dataset.index;
this.orderItems[index].checked = !this.orderItems[index].checked;
var len = 0;
for (var m of this.orderItems) {
if (m.checked)
len++;
}
if (len == this.orderItems.length) this.checkAll = true;
else this.checkAll = false;
this.chklength = len;
},
bindAllItemEdit: function(e) {
var arr = [];
for (var m of this.orderItems) {
if (m.checked)
arr.push({
id: m.id,
service_date: m.service_date
});
}
if (arr.length == 0) {
util.alert("请选择需要修改的子订单");
return false;
}
uni.navigateTo({
url: "../suborderedit/suborderedit?page=fin&from=select&d=" + JSON.stringify(arr) + "&oid=" + this
.order.id
})
},
bindItemEdit: function(e) {
var item = e.currentTarget.dataset.item;
var arr = [{
id: item.id,
service_date: item.service_date
}];
uni.navigateTo({
url: "../suborderedit/suborderedit?page=fin&from=single&d=" + JSON.stringify(arr) + "&oid=" + this
.order.id + "&id=" + item.id
})
},
}
}
</script>
<style>
page {
padding-top: 140rpx;
padding-bottom: 100rpx;
}
.l-orderitem {
margin-top: 30rpx;
}
.icon-check3 {
color: #CCCCCC;
font-size: 32rpx;
margin-right: 8rpx;
}
.icon-check3-on {
color: #0DC99E;
}
.icon-edit {
color: #999999;
font-size: 32rpx;
}
.tdate,
.tamt {
margin-left: 20rpx;
font-size: 28rpx;
color: #999999;
}
.tname {
margin-left: 10rpx;
font-size: 28rpx;
}
.ttag {
margin-left: 20rpx;
font-size: 20rpx;
height: 28rpx;
width: 54rpx;
line-height: 28rpx;
color: #4A90E2;
letter-spacing: 0;
background: rgba(60, 145, 245, 0.10);
text-align: center;
}
.tstatus {
font-size: 28rpx;
margin-left: 30rpx;
}
.l-box-info-left {
display: flex;
justify-content: space-between;
}
.btnOther {
background-color: #0CB790;
height: 200rpx;
width: 100%;
color: #FFFFFF;
box-sizing: border-box;
border-radius: 8rpx;
display: flex;
font-size: 28rpx;
align-items: center;
justify-content: center;
margin-left: 20rpx;
}
.btnOther-on {
background-color: orange;
}
.bottom {
background: #FFFFFF;
box-shadow: 0 -2rpx 12rpx 0 rgba(0, 0, 0, 0.16), inset 0 1rpx 0 0 #E4E4E4;
width: 100%;
height: 100rpx;
position: fixed;
bottom: 0;
left: 0;
display: flex;
justify-content: space-between;
}
.bottom .bottomLeft {
display: flex;
align-items: center;
}
.bottom .bottomRight {
display: flex;
}
.btn {
width: 220rpx;
line-height: 100rpx;
text-align: center;
line-height: 100rpx;
font-family: SourceHanSansCN-Medium;
font-size: 32rpx;
letter-spacing: 0;
}
.btnCancel {
color: #666666;
background: #F0F0F0;
}
.btnSubmit {
color: #FFFFFF;
background: #0DC99E;
}
.priceTitle {
font-family: SourceHanSansCN-Normal;
font-size: 24rpx;
color: #999999;
letter-spacing: 0;
line-height: 28rpx;
margin-left: 32rpx;
}
.priceInfo {
font-family: SourceHanSansCN-Normal;
font-size: 30rpx;
color: orange;
margin-left: 10rpx;
letter-spacing: 0;
line-height: 28rpx;
font-weight: bold;
}
.icon_logo {
width: 80rpx;
height: 80rpx;
margin-right: 24rpx;
}
.moneyBox {
display: flex;
justify-content: space-between;
padding: 20rpx 30rpx;
background-color: #FFFFFF;
}
.moneyBoxLeft {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 80%;
}
.moneyBoxRight {
flex: 1;
}
.moneyItem {
height: 90rpx;
width: 31.3%;
font-size: 28rpx;
display: flex;
justify-content: center;
border: 1rpx solid #333333;
margin-right: 1%;
margin-left: 1%;
color: #333333;
margin-bottom: 20rpx;
border-radius: 8rpx;
box-sizing: border-box;
line-height: 90rpx;
}
.moneyItemOn {
border-color: orange;
color: orange;
}
</style>