Explorar o código

修改退款,收款和结账功能

许智捷 %!s(int64=2) %!d(string=hai) anos
pai
achega
ccf28cd4e6

+ 75 - 131
src/views/room/modules/checkIn/BillRoomInfo.vue

@@ -456,7 +456,7 @@
               /><a-button type="link" > 收款 </a-button>
             </div>
             <div
-              @click="refund(2)"
+              @click="refund"
               :class="`${chooseLivingRoom.livingOrder && chooseLivingRoom.livingOrder.settleType !== -1 ? 'disabled' : ''}`"
               style="display: flex; flex-direction: column">
               <a-icon
@@ -502,31 +502,27 @@
           <a-descriptions-item label="合计收款">
             + {{ paymentAmount.toFixed(2) }}
           </a-descriptions-item>
-          <a-descriptions-item label="会员待收">
-            + {{ withholdAmout.toFixed(2) }}
-          </a-descriptions-item>
           <a-descriptions-item
             label="合计消费"
           >-{{ feesAmount.toFixed(2) }}
           </a-descriptions-item>
           <a-descriptions-item
             label="结账应退"
-            v-if="paymentAmount + withholdAmout - feesAmount > 0"
+            v-if="paymentAmount  - feesAmount > 0"
           >
-            {{ (paymentAmount + withholdAmout - feesAmount).toFixed(2) }}
+            {{ (paymentAmount  - feesAmount).toFixed(2) }}
           </a-descriptions-item>
           <a-descriptions-item label="结账应收" v-else>
-            {{ (feesAmount - paymentAmount - withholdAmout).toFixed(2) }}
+            {{ (feesAmount - paymentAmount).toFixed(2) }}
           </a-descriptions-item>
           <a-descriptions-item
-            label="优    惠"
-            v-if="paymentAmount - feesAmount < 0">
+            label="优    惠">
             <a-input-number v-model="preferentialMoney"></a-input-number>
           </a-descriptions-item>
         </a-descriptions>
         <a-button
-          v-if="paymentAmount +withholdAmout - feesAmount > 0"
+          v-if="paymentAmount - feesAmount > 0"
           @click="handleAdd"
           type="danger"
           style="margin-left: 100px"
@@ -543,12 +539,12 @@
         >
       </div>
     </div>
-    <enter-account-model ref="enterAccountModel" @ok="modalFormOk"></enter-account-model>
     <adjust-price-form ref="adjustPriceForm" @ok="modalFormOk"></adjust-price-form>
     <customer-modal ref="modalCustomerForm" @ok="modalFormOk"></customer-modal>
-    <refund-modal ref="modalRefundForm" @ok="modalFormOk"></refund-modal>
     <payment-modal ref="modalPaymentForm" @ok="modalFormOk"></payment-modal>
-<!--    <pay-or-refund-modal ref="modalPayOrRefundForm" @ok="modalFormOk"></pay-or-refund-modal>-->
+    <enter-account-model ref="enterAccountModel" @ok="modalFormOk"></enter-account-model>
+    <refund-modal ref="modalRefundForm" @ok="modalFormOk"></refund-modal>
+    <pay-or-refund-modal ref="modalPayOrRefundForm" @ok="modalFormOk"></pay-or-refund-modal>
     <fee-modal ref="modalFeeForm" @ok="modalFormOk"></fee-modal>
     <strike-balance-model  ref="modalStrikeBalanceForm" @ok="modalFormOk"></strike-balance-model>
     <member-message-modal ref="modalMemberMessage"></member-message-modal>
@@ -644,7 +640,7 @@ import EditRemarkModal from './EditRemarkModal.vue'
 import EditBreakfastNumModal from './EditBreakfastNumModal.vue'
 import EditBookingTypeModal from './EditBookingTypeModal.vue'
 import { match } from 'assert'
-// import PayOrRefundModal from '@views/room/modules/checkIn/PayOrRefundModel'
+import PayOrRefundModal from '@views/room/modules/checkIn/PayOrRefundModal'
 import AdjustPriceForm from '@views/room/modules/checkIn/AdjustPriceForm'
 import StrikeBalance from '@views/room/modules/checkIn/StrikeBalanceModel'
 import StrikeBalanceModel from '@views/room/modules/checkIn/StrikeBalanceModel'
@@ -672,7 +668,9 @@ const columns = [
     dataIndex: 'dayTime',
     width: 110,
     customRender: function (text, record) {
-      return record.dayTime.substring(0, 10)
+      if (text !== null && text !== '') {
+        return record.dayTime.substring(0, 10)
+      }
     }
   },
   {
@@ -709,8 +707,13 @@ const columns = [
 const columns2 = [
   {
     title: '入账时间',
-    dataIndex: 'createTime'
+    dataIndex: 'createTime',
     // width: 110,
+    customRender: function (text, record) {
+      if (text !== null && text !== '') {
+        return record.createTime.substring(0, 10)
+      }
+    }
   },
   {
     title: '支付方式',
@@ -758,7 +761,7 @@ export default {
     StrikeBalanceModel,
     StrikeBalance,
     AdjustPriceForm,
-    // PayOrRefundModal,
+    PayOrRefundModal,
     CustomerModal,
     RefundModal,
     PaymentModal,
@@ -869,17 +872,18 @@ export default {
       // var amount2 = list2.reduce(function (total, item) {
       //   return total + item.money;
       // }, 0);
-      var find = this.payTypeList.find(e => e.name === '会员卡')
-      var amount = this.paymentList.filter(t => t.payType !== find.id).reduce(function (total, item) {
-        return total + item.money
-      }, 0)
-      return amount
-    },
-    withholdAmout() {
-      var find = this.payTypeList.find(e => e.name === '会员卡')
-      var amount = this.paymentList.filter(t => t.payType === find.id).reduce(function (total, item) {
-        return total + item.money
-      }, 0)
+      // var find = this.payTypeList.find(e => e.name === '会员卡')
+      // var amount = this.paymentList.filter(t => t.payType !== find.id).reduce(function (total, item) {
+      //   return total + item.money
+      // }, 0)
+      let amount = 0
+      this.paymentList.forEach(e => {
+        if (e.subjectType === 13) {
+          amount -= e.money
+        } else {
+          amount += e.money
+        }
+      })
       return amount
     },
     btnSisabled() {
@@ -1145,6 +1149,8 @@ export default {
       this.$refs.modalEditCustomerSource.disableSubmit = false
     },
     editCustomerType(item) {
+      debugger
+      console.log(item)
       var obj = {
         orderId: item.livingOrder.id,
         customerType: item.livingOrder.customerType,
@@ -1345,6 +1351,8 @@ export default {
       return find ? find.name : ''
     },
     getRoomName(id) {
+      console.log(this.model.livingRoomIds)
+      debugger
       var index = this.model.livingRoomIds.findLastIndex((t) => t.roomId == id)
       var find = this.model.livingRoomIds[index]
       return find ? find.roomName : ''
@@ -1512,30 +1520,14 @@ export default {
       this.selectedRowKeys = selectedRowKeys
       this.selectionRows = selectionRows
     },
-    // refund(value) {
-    //   let ids = []
-    //   let mess = ''
-    //   if (value === 1) {
-    //     ids = this.consumSelectedRowKeys
-    //     mess = '消费详情中要收款'
-    //   } else {
-    //     ids = this.selectedRowKeys
-    //     mess = '收款详情中要退款'
-    //   }
-    //   if (!ids || ids.length === 0) {
-    //     this.$message.warning('请先勾选' + mess + '的账单')
-    //     return
-    //   }
-    //   postAction('/business/busRoomBookingOrders/payPortionFee', ids
-    //   ).then(resp => {
-    //     if (resp.result === true) {
-    //       this.$message.success('操作成功')
-    //       this.getBookingOrderInfo()
-    //     } else {
-    //       this.$message.success('操作失败')
-    //     }
-    //   })
-    // },
+    refund() {
+      let chooseRooms = [this.chooseLivingRoom]
+      if (this.selectRoomId === '1') {
+        chooseRooms = this.model.livingRoomIds.filter(e => e.roomId !== '1')
+      }
+      this.$refs.modalRefundForm.edit(chooseRooms)
+      this.$refs.modalRefundForm.payTypeList = this.payTypeList
+    },
     strikeBalance() {
       debugger
       console.log(this.consumSelectedRows)
@@ -1548,6 +1540,7 @@ export default {
     },
     enterAccount() {
       let chooseRooms = [this.chooseLivingRoom]
+      // vipCustomerId: livingRoom.livingOrder.vipCustomerId,
       if (this.selectRoomId === '1') {
         chooseRooms = this.model.livingRoomIds.filter(e => e.roomId !== '1')
       }
@@ -1561,6 +1554,10 @@ export default {
       )
       var livingRoom = this.model.livingRoomIds[index]
       var livingOrderId = ''
+      if (livingRoom.isMain && livingRoom.roomId !== '1') {
+        this.$message.warning('主房不能单独结账,请选择 全部')
+        return
+      }
       if (livingRoom.roomId != '1') {
         livingOrderId = livingRoom.livingOrder.id
       } else {
@@ -1590,88 +1587,35 @@ export default {
         }
       })
       if (count == 0) {
-        var list = this.paymentList.filter((t) => t.subjectType === 1)
-        var deposit = list.reduce(function (total, item) {
-          return total + item.money
-        }, 0)
-
-        var list2 = this.paymentList.filter((t) => t.subjectType === 2)
-        var sum = list2.reduce(function (total, item) {
-          return total + item.money
-        }, 0)
-
-        var list3 = this.feesList.filter((t) => t.subjectType === 3)
-        var sum2 = list3.reduce(function (total, item) {
-          return total + item.money
-        }, 0)
-        if (this.paymentAmount + this.withholdAmout - this.feesAmount > 0) {
-          debugger
-          this.$refs.modalRefundForm.edit({
-            billRefund: this.paymentAmount + this.withholdAmout - this.feesAmount,
-            deposit: deposit,
-            roomFee: sum2,
-            money: this.paymentAmount + this.withholdAmout - this.feesAmount,
-            subjectType: 5,
-            feeType: 2,
-            bookingOrderId: this.model.orderInfo.id,
-            livingOrderId:
-                livingRoom.roomId != '1' ? livingRoom.livingOrder.id : '',
-            vipCustomerId: livingRoom.livingOrder.vipCustomerId,
-            contractTeamId: livingRoom.livingOrder.contractTeamId,
-            contractTeamProtocolId:
-            livingRoom.livingOrder.contractTeamProtocolId
-          })
-          this.$refs.modalRefundForm.title = '结账退款'
-          this.$refs.modalRefundForm.disableSubmit = false
-        } else {
-
-        }
-        if (this.paymentAmount + this.withholdAmout - this.feesAmount > 0) {
-          debugger
-          this.$refs.modalRefundForm.edit({
-            billRefund: this.paymentAmount + this.withholdAmout - this.feesAmount,
-            deposit: deposit,
-            roomFee: sum2,
-            money: this.paymentAmount + this.withholdAmout - this.feesAmount,
-            subjectType: 5,
-            feeType: 2,
-            bookingOrderId: this.model.orderInfo.id,
-            livingOrderId:
+        let differMoney = this.feesAmount - this.paymentAmount
+        this.$refs.modalPayOrRefundForm.edit({
+          money: differMoney,
+          collection: this.paymentAmount,
+          consumption: this.feesAmount,
+          subjectType: 5,
+          feeType: 2,
+          bookingOrderId: this.model.orderInfo.id,
+          preferentialMoney: this.preferentialMoney,
+          livingOrderId:
               livingRoom.roomId != '1' ? livingRoom.livingOrder.id : '',
-            vipCustomerId: livingRoom.livingOrder.vipCustomerId,
-            contractTeamId: livingRoom.livingOrder.contractTeamId,
-            contractTeamProtocolId:
-              livingRoom.livingOrder.contractTeamProtocolId
-          })
-          this.$refs.modalRefundForm.title = '结账退款'
-          this.$refs.modalRefundForm.disableSubmit = false
+          vipCustomerId: livingRoom.livingOrder.vipCustomerId,
+          contractTeamId: livingRoom.livingOrder.contractTeamId,
+          contractTeamProtocolId:
+          livingRoom.livingOrder.contractTeamProtocolId,
+          preferentialType: 1,
+          couponFirstAmount: 0,
+          discount: 9,
+          isRefund: differMoney + this.preferentialMoney > 0
+        })
+        if (differMoney - this.preferentialMoney > 0) {
+          this.$refs.modalPayOrRefundForm.title = '结账收款'
+          // this.$refs.modalPayOrRefundForm.isRefund = false
         } else {
-          debugger
-          this.$refs.modalPaymentForm.edit({
-            billAmount: parseFloat(
-              Math.abs(this.paymentAmount + this.withholdAmout - this.feesAmount).toFixed(2)
-            ),
-            deposit: deposit - (sum - sum2),
-            roomFee: parseFloat(
-              Math.abs(this.paymentAmount + this.withholdAmout - this.feesAmount).toFixed(2)
-            ),
-            preferentialMoney: this.preferentialMoney,
-            subjectType: 5,
-            feeType: 2,
-            bookingOrderId: this.model.orderInfo.id,
-            livingOrderId:
-              livingRoom.roomId != '1' ? livingRoom.livingOrder.id : '',
-            preferentialType: 1,
-            couponFirstAmount: 0,
-            discount: 9,
-            vipCustomerId: livingRoom.livingOrder.vipCustomerId,
-            contractTeamId: livingRoom.livingOrder.contractTeamId,
-            contractTeamProtocolId:
-              livingRoom.livingOrder.contractTeamProtocolId
-          })
-          this.$refs.modalPaymentForm.title = '结账收款'
-          this.$refs.modalPaymentForm.disableSubmit = false
+          this.$refs.modalPayOrRefundForm.title = '结账退款'
+          // this.$refs.modalPayOrRefundForm.isRefund = true
         }
+        this.$refs.modalPayOrRefundForm.disableSubmit = false
+
       }
     },
     puls() {

+ 2 - 2
src/views/room/modules/checkIn/EditCustomerTypeForm.vue

@@ -329,7 +329,7 @@ export default {
       var find = this.customerList.find((t) => t.id === e);
       this.model.cusPhone = find.phone;
       this.model.cusName = find.name;
-      this.model.cusId = find.id;
+      this.model.cusId = find.gradeId;
     },
     getbusCustomer() {
       getAction("/bus/busCustomer/list", {}).then((res) => {
@@ -375,4 +375,4 @@ export default {
     },
   },
 };
-</script>
+</script>

+ 30 - 24
src/views/room/modules/checkIn/EnterAccountModel.vue

@@ -47,7 +47,7 @@
               sm: { span: 10 },
             }">
             <a-select v-model="item.payType">
-              <a-select-option v-for="type in payTypeList" :value="type.id">{{ type.name }}</a-select-option>
+              <a-select-option v-for="type in payTypeList" :value="type.id" :disabled="type.delFlag == 99">{{ type.name }}</a-select-option>
             </a-select>
           </a-form-model-item>
           <a-form-model-item
@@ -124,6 +124,7 @@ export default {
           remark: '',
           livingOrderId: e.livingOrder.id,
           feeType: 2,
+          vipCardId: e.livingOrder.vipCustomerId,
           addAccountList: [{
             payType: '',
             money: '',
@@ -163,9 +164,6 @@ export default {
       this.$emit('ok')
       this.visible = false
     },
-    submitCallback() {
-
-    },
     handleCancel () {
       this.close()
     },
@@ -183,31 +181,39 @@ export default {
       }).then((res) => {
         if (res.success) {
           this.payTypeList = res.result.records
+          if (this.payTypeList && this.payTypeList.length > 0) {
+            this.changePayTypeList(this.roomInfos[0])
+          }
         }
       })
     },
     changeSelect(value) {
-      // debugger
-      console.log(value + 'value')
-      // this.roomInfos.forEach(e => {
-      //   if (value === e.roomId) {
-      //     let list = e.addAccountList // 每条下的二级
-      //     e.addAccountList = this.addAccountList;
-      //     this.addAccountList = list;
-      //     console.log("addAccountList", e.addAccountList)
-      //     console.log("this.addAccountList", this.addAccountList)
-      //   }
-      // })
-
-      // let index = this.roomInfos.findIndex(item => item.roomId == value)
-      // if (this.errIndex !== '') {
-      //   this.roomInfos[this.errIndex].addAccountList = this.addAccountList
-      // }
-      // this.addAccountList = this.roomInfos[index].addAccountList
-      // this.errIndex = index
+      console.log(value)
       this.errIndex = this.roomInfos.findIndex(item => item.roomId == value)
-
-      this.$forceUpdate();
+      if (this.payTypeList && this.payTypeList.length > 0) {
+        let roomInfo = this.roomInfos.find(item => item.roomId == value)
+        this.changePayTypeList(roomInfo)
+      }
+      this.$forceUpdate()
+    },
+    changePayTypeList(roomInfo) {
+      if (!roomInfo.vipCardId || roomInfo.vipCardId.length === 0) {
+        var index = this.payTypeList.findIndex((t) =>
+            t.name.includes('会员')
+        )
+        if (index >= 0) {
+          this.payTypeList[index].delFlag = 99
+        }
+      }
+      if (!roomInfo.contractTeamId || roomInfo.contractTeamId.length === 0 ||
+          !roomInfo.contractTeamProtocolId || roomInfo.contractTeamProtocolId.length === 0) {
+        let index = this.payTypeList.findIndex((t) =>
+            t.name.includes('单位')
+        )
+        if (index >= 0) {
+          this.payTypeList[index].delFlag = 99
+        }
+      }
     },
 
     isDeposit(index) {

+ 476 - 208
src/views/room/modules/checkIn/PayOrRefund.vue

@@ -2,160 +2,213 @@
   <a-spin :spinning="confirmLoading">
     <j-form-container :disabled="formDisabled">
       <a-form-model
-          ref="form"
-          :model="model"
-          :rules="validatorRules"
-          slot="detail"
+        ref="form"
+        :model="model"
+        :rules="validatorRules"
+        slot="detail"
       >
         <a-row>
           <a-col :span="24">
             <a-form-model-item
-                label="押金"
-                :labelCol="labelCol"
-                :wrapperCol="wrapperCol"
-                prop="deposit"
+              label="收款金额"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
             >
-              <a-input
-                  style="width: 100px"
-                  disabled
-                  v-model="model.deposit"
-                  placeholder="押金应退"
-              ></a-input
-              >元
-              <a-select
-                  v-model="model.payType"
-                  style="width: 200px"
-                  placeholder="支付类型"
-              >
-                <a-select-option
-                    :value="item.id"
-                    v-for="item in payTypeList"
-                    :key="item.id"
-                    :disabled="item.delFlag == 99"
-                >{{ item.name }}</a-select-option
-                >
-              </a-select>
+              {{ model.collection.toFixed(2) }}元
             </a-form-model-item>
           </a-col>
           <a-col :span="24">
             <a-form-model-item
-                label="预付款"
-                :labelCol="labelCol"
-                :wrapperCol="wrapperCol"
-                prop="billRefund"
+              label="消费金额"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
             >
-              <a-input
-                  style="width: 100px"
-                  disabled
-                  v-model="model.billRefund"
-                  placeholder="请输入结账应退"
-              ></a-input
-              >元
-              <a-select
-                  v-model="model.payType"
-                  style="width: 200px"
-                  placeholder="支付类型"
-              >
-                <a-select-option
-                    :value="item.id"
-                    v-for="item in payTypeList"
-                    :key="item.id"
-                    :disabled="item.delFlag == 99"
-                >{{ item.name }}</a-select-option
-                >
-              </a-select>
+              {{ model.consumption.toFixed(2) }}元
+              <a-switch v-model="model.coupon" />优惠
             </a-form-model-item>
           </a-col>
-          <a-col :span="24">
-            <a-form-model-item
-                label="房费"
+
+          <template v-if="model.coupon">
+            <a-col :span="24">
+              <a-form-model-item
+                label="优惠方式"
                 :labelCol="labelCol"
                 :wrapperCol="wrapperCol"
-                prop="roomFee"
-            >
-              <a-input
+                prop="refund"
+              >
+                <a-radio-group v-model="model.preferentialType">
+                  <a-radio :value="1"> 抹零 </a-radio>
+                  <a-radio :value="2"> 减现 </a-radio>
+                  <a-radio :value="3"> 打折 </a-radio>
+                </a-radio-group>
+                <template
+                  v-if="model.preferentialType === 3"
+                >打<a-input-number
+                  style="width: 50px"
+                  v-model="model.discount"
+                  :min="1"
+                  :max="9"
+                ></a-input-number
+                >折
+                </template>
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24" v-if="model.preferentialType == 2">
+              <a-form-model-item
+                label="优惠金额"
+                :labelCol="labelCol"
+                :wrapperCol="wrapperCol"
+                prop="couponFirstAmount"
+              >
+                <a-input-number
                   style="width: 100px"
-                  disabled
-                  v-model="model.roomFee"
-                  placeholder="请输入房费应退"
-              ></a-input
-              >元
-              <a-select
-                  v-model="model.payType"
-                  style="width: 200px"
-                  placeholder="支付类型"
+                  :min="0"
+                  v-model="model.couponFirstAmount"
+                  placeholder="请输入优惠金额"
+                ></a-input-number
+                >元
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-model-item
+                label="惠后金额"
+                :labelCol="labelCol"
+                :wrapperCol="wrapperCol"
               >
-                <a-select-option
-                    :value="item.id"
-                    v-for="item in payTypeList"
-                    :key="item.id"
-                    :disabled="item.delFlag == 99"
-                >{{ item.name }}</a-select-option
+                {{ couponAmount.toFixed(2) }}元
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-model-item
+                label="优惠券"
+                :labelCol="labelCol"
+                :wrapperCol="wrapperCol"
+                prop="refund"
+              >
+                <a-select
+                  v-if="model.couponCard"
+                  v-model="model.couponId"
+                  style="width: 200px"
+                  placeholder="优惠券"
+                  :allowClear="true"
                 >
-              </a-select>
+                  <a-select-option
+                    :value="couponItem.id"
+                    v-for="couponItem in memeberCouponList"
+                    :key="couponItem.id"
+                  >{{ couponItem.couponsName }}</a-select-option
+                  >
+                </a-select>
+                <a-switch v-model="model.couponCard" />使用优惠券
+              </a-form-model-item>
+            </a-col>
+          </template>
+
+          <a-col :span="24" v-show="showYinshou">
+            <a-form-model-item
+              :label="&quot;结账应&quot; + (model.money < 0 ? &quot;退&quot; : &quot;收&quot;)"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              prop="money"
+            >
+              {{ Math.abs(model.money.toFixed(2)) }}元
             </a-form-model-item>
           </a-col>
           <a-col :span="24">
             <a-form-model-item
-                label="合计消费"
-                :labelCol="labelCol"
-                :wrapperCol="wrapperCol"
-                prop="roomFee"
+              :label="&quot;实&quot; + (this.isRefund ? &quot;退&quot; : &quot;收&quot;) + &quot;金额&quot;"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
             >
-              <a-input
-                  style="width: 100px"
-                  disabled
-                  v-model="model.roomFee"
-                  placeholder="合计消费"
-              ></a-input
-              >元
+              {{ realityAmount.toFixed(2) }}元
             </a-form-model-item>
           </a-col>
-
           <a-col :span="24">
             <a-form-model-item
-                label="应退金额"
-                :labelCol="labelCol"
-                :wrapperCol="wrapperCol"
-                prop="money"
+              :label="(this.isRefund ? &quot;退&quot; : &quot;收&quot;) + &quot;款金额&quot;"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
             >
-              <a-input
-                  style="width: 100px"
-                  disabled
-                  v-model="model.money"
-                  placeholder="请输入应退金额"
-              ></a-input>
+              <div v-for="(item, index) in payList" :key="index">
+                <a-row type="flex" :key="index">
+                  <a-col :span="6">
+                    <a-input-number
+                      style="width: 100px"
+                      v-model="item.money"
+                      :min="0"
+                    ></a-input-number>
+                  </a-col>
+                  <a-col :span="6">
+                    <a-select
+                      v-model="item.payType"
+                      @change="(event) => onChange(event, item)"
+                    >
+                      <a-select-option
+                        :value="item2.id"
+                        v-for="item2 in payTypeList"
+                        :key="item2.id"
+                        :disabled="item2.delFlag == 99"
+                      >
+                        {{ item2.name }}
+                      </a-select-option>
+                    </a-select></a-col
+                  >
+                  <a-col :span="6">
+                    <a-icon
+                      v-if="index == payList.length - 1"
+                      type="plus-circle"
+                      class="dynamic-delete-button"
+                      @click="puls()" />
+                    <a-icon
+                      v-if="payList.length > 1"
+                      type="minus-circle"
+                      style="color: #f56c6c"
+                      class="dynamic-delete-button"
+                      @click="() => remove(index)"
+                    /></a-col>
+                </a-row>
+
+                <a-row type="flex" v-if="item.isVipMemmber">
+                  <a-col :span="12"> 姓名:{{ memberCard.name }} </a-col>
+                  <a-col :span="12"> 卡号:{{ memberCard.cardNo }} </a-col>
+                  <a-col :span="12">
+                    会员级别: {{ memberCard.gradeName }}</a-col
+                  >
+                  <a-col :span="12"> 余额:{{ memberCard.balance }} </a-col>
+                  <a-col :span="12"> 积分:{{ memberCard.integral }} </a-col>
+                  <!-- <a-col :span="12"> 本次扣后剩余: </a-col>
+                <a-col :span="12"> 本次新增积分: </a-col> -->
+                </a-row>
+                <a-row type="flex" v-if="item.isDanwei">
+                  <a-col :span="12">
+                    协议单位:{{ agreementUnitData.customerName }}
+                  </a-col>
+                  <a-col :span="12">
+                    签约开始日期:{{ danwei.signTime }}
+                  </a-col>
+                  <a-col :span="12">
+                    签约结束日期: {{ danwei.effective }}</a-col
+                  >
+                  <a-col :span="12">
+                    可用额度:{{ agreementUnitData.balance || 0 }}
+                  </a-col>
+                </a-row>
+              </div>
             </a-form-model-item>
           </a-col>
           <a-col :span="24">
             <a-form-model-item
-                label="实退金额"
-                :labelCol="labelCol"
-                :wrapperCol="wrapperCol"
-                prop="billRefund"
+              :label="&quot;实&quot; + (this.isRefund ? &quot;退&quot; : &quot;收&quot;) + &quot;合计&quot;"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
             >
-              <a-input
-                  style="width: 100px"
-                  disabled
-                  v-model="model.billRefund"
-                  placeholder="请输入实退金额"
-              ></a-input
-              >元
-              <a-select
-                  v-model="model.payType"
-                  style="width: 200px"
-                  placeholder="支付类型"
-              >
-                <a-select-option
-                    :value="item.id"
-                    v-for="item in payTypeList"
-                    :key="item.id"
-                    :disabled="item.delFlag == 99"
-                >{{ item.name }}</a-select-option
-                >
-              </a-select>
+              {{ Math.abs(sumAmount.toFixed(2)) }}元
             </a-form-model-item>
           </a-col>
+          <a-col :span="24" style="text-align: end">
+            <a-checkbox default-checked>打印结账单</a-checkbox>
+            <a-checkbox default-checked>打印发票二维码</a-checkbox>
+          </a-col>
         </a-row>
       </a-form-model>
     </j-form-container>
@@ -163,36 +216,44 @@
 </template>
 
 <script>
-import { httpAction, getAction } from "@/api/manage";
+import { httpAction, getAction } from '@/api/manage'
+import { validateDuplicateValue } from '@/utils/util'
 
 export default {
-  name: "PayOrRefund",
+  name: 'PayOrRefund',
   components: {},
   props: {
-    //表单禁用
+    // 表单禁用
     disabled: {
       type: Boolean,
       default: false,
-      required: false,
+      required: false
     },
+    showYinshou: {
+      type: Boolean,
+      default: true,
+      required: false
+    }
   },
   data() {
     return {
+      isRefund: false,
       model: {
-        payType: "",
-        payType2: "",
-        livingOrderId: "",
-        certType: 1,
-        gender: 1,
-        bookingOrderId: "",
+        coupon: false,
+        discount: 1,
+        couponCard: false,
+        couponType: 1,
+        couponFirstAmount: 0,
+        billAmount: 0,
+        selectedFeeIds: []
       },
       labelCol: {
         xs: { span: 24 },
-        sm: { span: 5 },
+        sm: { span: 5 }
       },
       wrapperCol: {
         xs: { span: 24 },
-        sm: { span: 16 },
+        sm: { span: 16 }
       },
       confirmLoading: false,
       validatorRules: {
@@ -200,22 +261,22 @@ export default {
           {
             required: true,
             pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
-            message: "请输入手机号!",
-          },
+            message: '请输入手机号!'
+          }
         ],
-        cardNo: [{ required: true, message: "请输入会员卡号!" }],
-        gradeId: [{ required: true, message: "请输入等级类型!" }],
-        payType: [{ required: true, message: "请输入付款类型!" }],
-        paymentMethod: [{ required: true, message: "请输入付款方式!" }],
-        customerName: [{ required: true, message: "请输入会员姓名!" }],
-        sex: [{ required: true, message: "请输入性别!" }],
-        certificateType: [{ required: true, message: "请输入证件类型!" }],
-        validity: [{ required: true, message: "请输入有效期!" }],
+        cardNo: [{ required: true, message: '请输入会员卡号!' }],
+        gradeId: [{ required: true, message: '请输入等级类型!' }],
+        payType: [{ required: true, message: '请输入付款类型!' }],
+        paymentMethod: [{ required: true, message: '请输入付款方式!' }],
+        customerName: [{ required: true, message: '请输入会员姓名!' }],
+        sex: [{ required: true, message: '请输入性别!' }],
+        certificateType: [{ required: true, message: '请输入证件类型!' }],
+        validity: [{ required: true, message: '请输入有效期!' }]
       },
       url: {
-        add: "/business/busRoomBookingOrders/booking-to-live",
-        edit: "/business/busMemberCard/edit",
-        queryById: "/business/busMemberCard/queryById",
+        add: '/business/busRoomBookingOrders/booking-to-live',
+        edit: '/business/busMemberCard/edit',
+        queryById: '/business/busMemberCard/queryById'
       },
       gradeList: [],
       paymentMethodList: [],
@@ -223,40 +284,93 @@ export default {
       customerList: [],
       oldcustomerList: [],
       payTypeList: [],
-    };
+      memberCard: {},
+      danwei: {},
+      isVipMemmber: false,
+      isDanwei: false,
+      payList: [],
+      memeberCouponList: [],
+      agreementUnitData: {}
+    }
   },
   computed: {
     formDisabled() {
-      return this.disabled;
+      return this.disabled
+    },
+    sumAmount() {
+      var sum = this.payList.reduce(function (total, item) {
+        return total + item.money
+      }, 0)
+      return sum
+    },
+    couponAmount() {
+      var sum = 0
+      if (this.model.coupon) {
+        if (this.model.preferentialType == 1) {
+          sum = Math.floor(this.model.consumption)
+        } else if (this.model.preferentialType == 2) {
+          sum = this.model.consumption - (this.model.couponFirstAmount || 0)
+        } else if (this.model.preferentialType == 3) {
+          sum = parseFloat(
+              ((this.model.consumption * this.model.discount) / 10).toFixed(2)
+          )
+        }
+      } else {
+        sum = this.model.consumption
+        debugger
+      }
+      return sum
     },
+    realityAmount() {
+      // 实际要收的钱,为负表示要退的钱
+      let relMoney = this.couponAmount.toFixed(2) - this.model.collection
+      this.isRefund = relMoney < 0
+      if (this.model.couponCard) {
+        var find = this.memeberCouponList.find(
+            (t) => t.id == this.model.couponId
+        )
+        if (find) {
+          this.isRefund = relMoney - find.cost < 0
+          return Math.abs(relMoney - find.cost)
+        }
+      }
+      return Math.abs(relMoney)
+    }
   },
   created() {
-    var _info = JSON.parse(localStorage.getItem("storeInfo"));
+    var _info = JSON.parse(localStorage.getItem('storeInfo'))
     if (_info) {
-      this.model.hotelId = _info.id;
+      this.model.hotelId = _info.id
     }
-    //备份model原始值
-    this.modelDefault = JSON.parse(JSON.stringify(this.model));
-    this.getbusCustomer();
+    // 备份model原始值
+    this.modelDefault = JSON.parse(JSON.stringify(this.model))
+    // getAction("/business/busRoomPayType/list", {
+    //   pageSize: 99999,
+    //   pageNo: 1,
+    // }).then((res) => {
+    //   if (res.success) {
+    //     this.payTypeList = res.result.records;
+    //   }
+    // });
   },
   methods: {
     getbusRoomPayType() {
-      getAction("/business/busRoomPayType/list", {
+      getAction('/business/busRoomPayType/list', {
         pageSize: 99999,
-        pageNo: 1,
+        pageNo: 1
       }).then((res) => {
         if (res.success) {
-          this.payTypeList = res.result.records;
+          this.payTypeList = res.result.records
           if (this.payTypeList && this.payTypeList.length > 0) {
             if (
                 !this.model.vipCustomerId ||
                 this.model.vipCustomerId.length == 0
             ) {
               var index = this.payTypeList.findIndex((t) =>
-                  t.name.includes("会员")
-              );
+                  t.name.includes('会员')
+              )
               if (index >= 0) {
-                this.payTypeList[index].delFlag = 99;
+                this.payTypeList[index].delFlag = 99
               }
             }
             if (
@@ -266,89 +380,243 @@ export default {
                 this.model.contractTeamProtocolId.length == 0
             ) {
               var index = this.payTypeList.findIndex((t) =>
-                  t.name.includes("单位")
-              );
+                  t.name.includes('单位')
+              )
               if (index >= 0) {
-                this.payTypeList[index].delFlag = 99;
+                this.payTypeList[index].delFlag = 99
               }
             }
-            this.$set(this.model, "payType", this.payTypeList[0].id);
+            this.$set(this.model, 'payType', this.payTypeList[0].id)
+
+            this.payList = [
+              {
+                money: this.realityAmount,
+                payType: this.payTypeList[0].id,
+                isVipMemmber: false,
+                isDanwei: false
+              }
+            ]
           }
         }
-      });
+      })
+    },
+    puls() {
+      var sum = this.payList.reduce(function (total, item) {
+        return total + item.money
+      }, 0)
+      var money = this.realityAmount - sum
+      if (money < 0) {
+        money = 0
+      }
+      this.payList.push({
+        money: money,
+        payType: this.payTypeList[0].id,
+        isVipMemmber: false,
+        isDanwei: false
+      })
+    },
+    remove(index) {
+      this.payList.splice(index, 1)
+    },
+    onChange(e, value) {
+      console.log('value', value)
+      console.log('e', e)
+      var find = this.payTypeList.find((t) => t.id == value.payType)
+      value.isVipMemmber = find && find.name.includes('会员')
+      value.isDanwei = find && find.name.includes('单位')
     },
     handleSearch(value) {
-      let result;
+      let result
       if (!value) {
-        result = this.oldcustomerList;
+        result = this.oldcustomerList
       } else {
-        result = this.oldcustomerList.filter((t) => t.name.includes(value));
+        result = this.oldcustomerList.filter((t) => t.name.includes(value))
       }
-      this.customerList = result;
+      this.customerList = result
     },
     handleSelectMember(e) {
-      var find = this.customerList.find((t) => t.id === e);
-      this.model.phone = find.phone;
-      this.model.customerName = find.name;
-      this.model.customerId = find.id;
+      var find = this.customerList.find((t) => t.id === e)
+      this.model.phone = find.phone
+      this.model.customerName = find.name
+      this.model.customerId = find.id
     },
-    getbusCustomer() {
-      getAction("/bus/busCustomer/list", {}).then((res) => {
+    getMemeberCouponList() {
+      getAction('/business/busMarketCouponsCashUsed/memeberCouponList', {
+        pageNo: 1,
+        pageSize: 99,
+        conditions: 900,
+        mobile: this.model.vipCustomerId
+      }).then((res) => {
         if (res.success) {
-          this.customerList = res.result.records;
-          this.oldcustomerList = JSON.parse(JSON.stringify(this.customerList));
+          this.memeberCouponList = res.result.records
         }
-      });
+      })
     },
     add(livingOrderId, roomId) {
-      this.modelDefault.livingOrderId = livingOrderId;
-      this.modelDefault.roomId = roomId;
-      this.edit(this.modelDefault);
+      this.modelDefault.livingOrderId = livingOrderId
+      this.modelDefault.roomId = roomId
+      this.edit(this.modelDefault)
     },
     edit(record) {
-      this.model = Object.assign({}, record);
-
-      this.getbusRoomPayType();
-      this.visible = true;
+      this.model = Object.assign({}, record)
+      this.isRefund = this.model.isRefund
+      if (record.preferentialMoney !== 0 && record.preferentialMoney !== null) {
+        this.model.coupon = true
+        this.model.preferentialType = 2
+        this.model.couponFirstAmount = record.preferentialMoney
+      }
+      this.getbusRoomPayType()
+      if (this.model.vipCustomerId) {
+        this.getMemeberCouponList()
+      }
+      if (this.model.vipCustomerId) {
+        getAction('/business/busMemberCard/list', {
+          id: this.model.vipCustomerId
+        }).then((res) => {
+          if (res.success) {
+            if (res.result.records && res.result.records.length > 0) {
+              this.memberCard = res.result.records[0]
+            }
+          }
+        })
+      }
+      if (this.model.contractTeamId && this.model.contractTeamProtocolId) {
+        getAction('/business/busMarketAgreementUnit/list', {
+          id: this.model.contractTeamId
+        }).then((res) => {
+          if (res.success) {
+            var list = res.result.records
+            if (list.length > 0) {
+              this.agreementUnitData = list[0]
+              getAction('/business/busMarketAgreementCustomer/list', {
+                agreementId: this.model.contractTeamId
+              }).then((res2) => {
+                if (res2.success) {
+                  var list2 = res2.result.records
+                  if (list2 && list2.length > 0) {
+                    this.danwei = list2.find(
+                        (t) => t.id == this.model.contractTeamProtocolId
+                    )
+                  }
+                }
+              })
+            }
+          }
+        })
+      }
+      this.visible = true
     },
     submitForm() {
-      const that = this;
+      const that = this
       // 触发表单验证
       this.$refs.form.validate((valid) => {
         if (valid) {
-          that.confirmLoading = true;
-          var fees = [];
-          fees.push({
-            feeType: this.model.feeType,
-            money: this.model.money,
-            payType: this.model.payType,
-            custorerOrderRemark: "结账退款",
-            isPreferential: false,
-            livingOrderId: this.model.livingOrderId,
-          });
+          if (this.realityAmount != this.sumAmount) {
+            that.$message.warning('实收金额和实收合计必须相等')
+            return
+          }
+          var obj = {}
+          var fees = []
+          if (this.model.coupon) {
+            fees.push({
+              feeType: this.model.feeType,
+              preferentialType: this.model.preferentialType,
+              money: this.couponAmount.toFixed(2) - this.model.consumption.toFixed(2),
+              custorerOrderRemark: '优惠金额',
+              isPreferential: true
+            })
+          }
+          console.log(fees, 'fees')
+          if (this.model.couponCard && this.model.couponId) {
+            var find = this.memeberCouponList.find(
+                (t) => t.id === this.model.couponId
+            )
+            if (find) {
+              fees.push({
+                feeType: this.model.feeType,
+                money: -find.cost.toFixed(2),
+                custorerOrderRemark: '优惠券',
+                isPreferential: true,
+                couponscashId: find.id
+              })
+            }
+          }
+          this.payList.forEach((item) => {
+            let remark = '结账收款'
+            let money = item.money.toFixed(2)
+            if (this.isRefund) {
+              remark = '结账退款'
+              money = -money
+            }
+            fees.push({
+              feeType: this.model.feeType,
+              money,
+              payType: item.payType,
+              custorerOrderRemark: remark,
+              isPreferential: this.model.isPreferential,
+              preferentialMoney: this.model.preferentialMoney
+            })
+          })
+
+          that.confirmLoading = true
           var url =
-              "/business/busRoomBookingOrders/settle-checkout?bookingOrderId=" +
-              this.model.bookingOrderId;
+              '/business/busRoomBookingOrders/settle-checkout?bookingOrderId=' +
+              this.model.bookingOrderId
           if (this.model.livingOrderId) {
             url =
-                "/business/busRoomBookingOrders/living-settle-checkout?livingOrderId=" +
-                this.model.livingOrderId;
+                '/business/busRoomBookingOrders/living-settle-checkout?livingOrderId=' +
+                this.model.livingOrderId
           }
-          httpAction(url, fees, "post")
+          if (
+              this.model.selectedFeeIds &&
+              this.model.selectedFeeIds.length > 0
+          ) {
+            url = '/business/busRoomBookingOrders/partial-settle'
+            obj = {
+              fees: fees,
+              livingOrderId: this.model.livingOrderId,
+              selectedFeeIds: this.model.selectedFeeIds
+            }
+          }
+          httpAction(
+              url,
+              this.model.selectedFeeIds && this.model.selectedFeeIds.length > 0
+                  ? obj
+                  : fees,
+              'post'
+          )
               .then((res) => {
                 if (res.success) {
-                  that.$message.success("结账成功");
-                  that.$emit("ok");
+                  that.$message.success('结账成功')
+                  that.$emit('ok')
                 } else {
-                  that.$message.warning(res.message);
+                  that.$message.warning(res.message)
                 }
               })
               .finally(() => {
-                that.confirmLoading = false;
-              });
+                that.confirmLoading = false
+              })
         }
-      });
-    },
-  },
-};
+      })
+    }
+  }
+}
 </script>
+<style scoped>
+.dynamic-delete-button {
+  cursor: pointer;
+  position: relative;
+  /* top: 4px; */
+  margin-left: 5px;
+  font-size: 18px;
+  color: #1890ff;
+  transition: all 0.3s;
+}
+.dynamic-delete-button:hover {
+  color: #777;
+}
+.dynamic-delete-button[disabled] {
+  cursor: not-allowed;
+  opacity: 0.5;
+}
+</style>

+ 68 - 0
src/views/room/modules/checkIn/PayOrRefundModal.vue

@@ -0,0 +1,68 @@
+<template>
+  <j-modal
+      :title="title"
+      :width="width"
+      :visible="visible"
+      switchFullscreen
+      @ok="handleOk"
+      :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
+      @cancel="handleCancel"
+      cancelText="关闭"
+  >
+    <pay-or-refund
+        ref="realForm"
+        @ok="submitCallback"
+        :disabled="disableSubmit"
+        :showYinshou="showYinshou"
+    ></pay-or-refund>
+  </j-modal>
+</template>
+
+<script>
+import PayOrRefund from '@views/room/modules/checkIn/PayOrRefund'
+export default {
+  name: 'PayOrRefundModal',
+  components: {
+    PayOrRefund,
+  },
+  data() {
+    return {
+      title: "",
+      width: 800,
+      visible: false,
+      disableSubmit: false,
+      showYinshou: true,
+      //是退款
+      isRefund:false,
+    };
+  },
+  methods: {
+    add(record) {
+      this.visible = true;
+      this.$nextTick(() => {
+        this.$refs.realForm.add(record);
+      });
+    },
+    edit(record) {
+      this.visible = true;
+      this.$nextTick(() => {
+        this.$refs.realForm.edit(record);
+      });
+    },
+    close() {
+      this.$emit("close");
+      this.visible = false;
+    },
+    handleOk() {
+      this.$refs.realForm.submitForm();
+    },
+    submitCallback() {
+      this.$emit("ok");
+      this.visible = false;
+    },
+    handleCancel() {
+      this.close();
+    },
+  },
+};
+</script>

+ 196 - 65
src/views/room/modules/checkIn/RefundModal.vue

@@ -11,120 +11,251 @@
 <!--    <refund ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></refund>-->
     <a-table
         :columns="columns"
-        :data-source="feesList"
+        :data-source="feeList"
         :pagination="false"
         :scroll="{ y: 160 }"
         rowKey="id"
+        style="text-align: center"
     >
+      <template slot="payType" slot-scope="text, record, index">
+        {{ getPayTypeText(text) }}
+      </template>
       <template slot="subjectType" slot-scope="text, record, index">
         {{ getSubjectTypeText(text,record) }}
       </template>
       <template slot="roomId" slot-scope="text, record, index">
         {{ getRoomName(text) }}
       </template>
+      <template slot="prerefund" slot-scope="text, record, index">
+        <a-input-number v-model="record.prerefund"></a-input-number>
+      </template>
     </a-table>
+    <a-form-model>
+      <a-row  style="display: flex; ">
+        <a-col :span="16" style="flex: 4">
+          <a-form-model-item style="margin-bottom: 0px;" label="合计"></a-form-model-item>
+        </a-col>
+        <a-col :span="4" style="flex: 2.5">
+        <a-form-model-item label="支付金额:" style="display: flex; margin-bottom: 0px;">
+            {{ allFeeMoney }}
+          </a-form-model-item>
+        </a-col>
+        <a-col :span="4" style="flex: 1">
+        <a-form-model-item label="退款金额:"  style="display: flex; margin-bottom: 0px;">
+            {{ allReturnFee }}
+          </a-form-model-item>
+        </a-col>
+      </a-row>
+
+    </a-form-model>
   </j-modal>
 </template>
 
 <script>
+import { postAction } from '@api/manage'
+import Refund from './Refund'
+
 const columns = [
-  // {
-  //     title: "",
-  //     dataIndex: "key",
-  //     width: 20,
-  //   },
   {
     title: '房间号',
-    dataIndex: 'roomId',
+    dataIndex: 'roomName',
+    width: 80,
+    align: 'center',
+    // scopedSlots: { customRender: 'roomId' }
+  },
+  {
+    title: '支付类型',
+    dataIndex: 'payType',
+    align: 'center',
     width: 80,
-    scopedSlots: { customRender: 'roomId' }
+    scopedSlots: { customRender: 'payType' }
   },
   {
     title: '费项',
     dataIndex: 'subjectType',
-    width: 160,
+    align: 'center',
+    width: 100,
     scopedSlots: { customRender: 'subjectType' }
   },
   {
     title: '入账日期',
     dataIndex: 'dayTime',
+    align: 'center',
     width: 110,
     customRender: function (text, record) {
-      return record.dayTime.substring(0, 10)
+      return record.createTime.substring(0, 10)
     }
   },
   {
-    title: '单价',
+    title: '支付金额',
     dataIndex: 'id',
-    // width: 60,
+    align: 'center',
+// width: 60,
     customRender: function (text, record) {
       return record.money
     }
   },
   {
-    title: '优惠价',
-    dataIndex: 'money',
-    // width: 60,
+  title: '本次退款',
+  dataIndex: 'prerefund',
+    align: 'center',
+    scopedSlots: { customRender: 'prerefund' }
   },
   {
-    title: '数量',
-    dataIndex: 'feeType',
-    width: 60,
-    customRender: function (text) {
-      return 1
-    }
-  },
-  {
-    title: '小计',
-    dataIndex: 'livingOrderId',
-    // width: 60,
-    customRender: function (text, record) {
-      return record.money
-    }
+    title: '已退款',
+    align: 'center',
+    dataIndex: 'returnMoney',
   }
 ]
 
-  import Refund from './Refund'
-  export default {
-    name: 'RefundModal',
-    components: {
-      Refund
+export default {
+  name: 'RefundModal',
+  components: {
+    Refund
+  },
+  data () {
+    return {
+      title:'退款',
+      width:800,
+      visible: false,
+      disableSubmit: false,
+      payTypeList: [],
+      columns,
+      model: [],
+      feeList: [],
+      allFeeMoney: 0,
+      allReturnFee: 0
+    }
+  },
+  methods: {
+    add(record) {
+      this.visible = true
+      this.$nextTick(() => {
+        this.$refs.realForm.add(record);
+      })
+    },
+    edit(record) {
+      this.visible = true
+      this.model = record;
+      this.getFee()
+    },
+    close() {
+      this.$emit('close');
+      this.visible = false;
+    },
+    handleOk() {
+      let refundFeeList = []
+      if (this.feeList.some(e => e.money - e.returnMoney < e.prerefund)) {
+        this.$message.warning('退款金额不能小于当前余额')
+        return
+      }
+      this.feeList.forEach(e => {
+        console.log(e.prerefund)
+        debugger
+        if (e.prerefund === 0 || e.prerefund === null) { return }
+        let refundFee = {
+          livingOrderId: e.livingOrderId,
+          money: e.prerefund,
+          returnFeeId: e.id,
+          returnItem: true,
+          feeType: e.feeType,
+          subjectType: 13,
+          hotelId: e.hotelId
+        }
+        refundFeeList.push(refundFee)
+      })
+      if (refundFeeList.length === 0) {
+        this.$message.warning('未检测出需要退款的账单')
+        return
+      }
+      postAction('/business/busOrderFee/refundBatch', refundFeeList)
+          .then(resp => {
+            if (resp.result === true) {
+              this.$message.success('退款成功')
+              this.$emit('ok')
+              this.visible = false
+            } else {
+              this.$message.warning('退款失败')
+            }
+          })
+    },
+    handleCancel() {
+      this.close()
     },
-    data () {
-      return {
-        title:'',
-        width:800,
-        visible: false,
-        disableSubmit: false
+    getSubjectTypeText(text, record) {
+      var msg = ''
+      if (text == 1) {
+        msg = '押金'
+      } else if (text == 2) {
+        msg = '预收房费'
+      } else if (text == 3) {
+        msg = '每日房费'
+      } else if (text == 4) {
+        msg = '优惠金额'
+      } else if (text == 5) {
+        msg = '结账收款'
+      } else if (text == 6) {
+        msg = '商品-' + record.feeGoodVo.name
+      } else if (text == 7) {
+        msg = '点餐'
+      } else if (text == 8) {
+        msg = '夜审房费'
+      } else if (text == 9) {
+        msg = '会议室'
+      } else if (text == 10) {
+        msg = '手工房费'
+      } else if (text == 11) {
+        msg = '水电煤抄表'
+      } else if (text == 12) {
+        msg = '赔偿费'
+      } else if (text == 13) {
+        msg = '退单结账'
       }
+      return msg
     },
-    methods: {
-      add (record) {
-        this.visible=true
-        this.$nextTick(()=>{
-          this.$refs.realForm.add(record);
+    getRoomName(id) {
+      var index = this.model.livingRoomIds.findLastIndex((t) => t.roomId == id)
+      var find = this.model.livingRoomIds[index]
+      return find ? find.roomName : ''
+    },
+    getPayTypeText(text) {
+      var find = this.payTypeList.find((t) => t.id == text)
+      return find ? find.name : ''
+    },
+    getFee() {
+      let ids = []
+      this.model.forEach(e => {
+        ids.push(e.livingOrder.id)
+      })
+      postAction('/business/busOrderFee/refundList', ids).then((res) => {
+        let feeList = []
+        let returnFeeList = []
+        res.result.forEach(e => {
+          if (e.returnItem === true) {
+            returnFeeList.push(e)
+          } else {
+            e.returnMoney = 0
+            e.prerefund = 0
+            var room = this.model.filter(room => room.roomId === e.roomId)
+            e.roomName = room[0].roomName
+            feeList.push(e)
+          }
         })
-      },
-      edit (record) {
-        this.visible=true
-        this.$nextTick(()=>{
-          this.$refs.realForm.edit(record);
+        this.feeList = feeList
+        console.log(this.feeList)
+        if (returnFeeList.length === 0) {
+          return
+        }
+        this.allFeeMoney = 0
+        this.allReturnFee = 0
+        this.feeList.forEach(e => {
+          let returnMoney = returnFeeList.filter(ele => e.id === ele.returnFeeId).reduce((accumulator, ele) => accumulator + ele.money, 0)
+          e.returnMoney = returnMoney;
+          this.allFeeMoney += e.money;
+          this.allReturnFee += returnMoney;
         })
-      },
-      close () {
-        this.$emit('close');
-        this.visible = false;
-      },
-      handleOk () {
-        this.$refs.realForm.submitForm();
-      },
-      submitCallback(){
-        this.$emit('ok');
-        this.visible = false;
-      },
-      handleCancel () {
-        this.close()
-      }
+      })
     }
   }
+}
 </script>