<template>
  <div class="collection">
    <div class="flex justify-start align-start flex-wrap padding-top">
      <el-form :model="form" :inline="true" label-width="80px">
        <el-form-item label="手机号码:">
          <div class="form-width-ms flex">
            <el-input oninput="this.value=this.value.replace(/\D/g,'')" style="height:100%" pattern="[0-9]*" maxlength="11" v-model="form.mobilePhone" @change="query">
              <el-button size="mini" slot="append" icon="el-icon-search"  @click="openMember"></el-button>
            </el-input>
            <el-button icon="el-icon-circle-plus-outline" type="text" @click="openAddMember" ></el-button>
          </div>
        </el-form-item>
        <el-form-item label="会员名称:">
          <div class="form-width-ms">
            <span v-if="form.memberName">
              <span>{{ form.memberName }}</span>
              <i v-if="form.sex==1" class="el-icon-male text-blue"></i>
              <i v-if="form.sex==0" class="el-icon-female text-pink"></i>
            </span>
            <el-button size="mini" type="text" v-show="form.memberName" @click="routePush">详情</el-button>
          </div>
        </el-form-item>
        <el-form-item v-if="sessionStorageData.recDebt&&debtMoneys" label="以往欠款:">
          <div class="form-width-ms">
            {{ debtMoneys }}
            <el-button size="mini" type="text" @click="openMoney()" v-show="debtMoneys != 0">去还款</el-button>
          </div>
        </el-form-item>
        <el-form-item label="业务时间:" v-if="isAddition==1">
          <div class="form-width-ms">
            <el-date-picker ref="recDate" class="form-width-ms" v-model="form.additionDate" :picker-options="pickerOptions" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择日期">
            </el-date-picker>
          </div>
        </el-form-item>
        <br />
        <el-form-item label="充值方式:">
          <div class="form-width-ms flex align-center text-cyan">
            <el-radio-group v-model="liftType" size="mini" style="padding-top:3px;" @change="radioChange">
              <el-radio-button :label="0" title="标准充值">标准</el-radio-button>
              <el-radio-button :label="1" title="升卡" >升</el-radio-button>
              <el-radio-button :label="2" title="降卡" >降</el-radio-button>
            </el-radio-group>
          </div>
        </el-form-item>
        <el-form-item label="会员账户:">
          <div class="form-width-ms">
            <el-select v-model="form.recName" v-if="liftType!=0" placeholder="请选择" default-first-option filterable @change="recChange" clearable>
              <el-option v-for="(item,index) in recList" :key="index" :label="item.rechargeTypeName" :value="item.rechargeTypeId">
              </el-option>
            </el-select>
            <div v-else>标准充值</div>
          </div>
        </el-form-item>
        <el-form-item label="充值类别:">
          <div class="form-width-ms" @click="openRec(liftType)">
            <el-button v-if="!form.rechargeTypeName" size="mini" type="text">选择</el-button>
            <div class="text-cut" :title="form.rechargeTypeName" v-else>
              <span>{{ form.rechargeTypeName }}</span>
              <i class="el-icon-edit text-cyan"></i>
            </div>
          </div>
        </el-form-item>
        <br />
        <el-form-item label="标准金额:">
          <div class="form-width-ms">
            <span class="text-red text-price">{{ form.rechargeAmount }}</span>
          </div>
        </el-form-item>
        <el-form-item label="待付金额:">
          <div class="form-width-ms">
            <span class="text-green text-price">{{ form.debtMoney?form.debtMoney.toFixed(2)*1:0 }}</span>
          </div>
        </el-form-item>
        <el-form-item label="实付金额:">
          <div class="form-width-ms">
            <span class="text-red text-price">{{ form.collectionAmount }}</span>
          </div>
        </el-form-item>
        <br />
        <el-form-item label="充前金额:">
          <div class="form-width-ms">
            <span class="text-red text-price">{{ form.beforeMoney }}</span>
          </div>
        </el-form-item>
        <el-form-item label="充前赠送:">
          <div class="form-width-ms">
            <span class="text-red text-price">{{ form.giftBeforeMoney }}</span>
          </div>
        </el-form-item>
        <el-form-item v-show="sessionStorageData.recharge">
          <div style="margin-left: 28px">
            <el-checkbox style="display: inline-block" @change="checkintegral" v-model="form.integralCheckbox">
              使用积分| 总积分:{{ integral }}
            </el-checkbox>
            <div v-show="form.integralCheckbox" style="color: red; display: inline-block">
              | 可用积分:
              <span v-show="!integralShow">{{ consumeIntegral }}</span>
              <input v-model="consumeIntegral" v-show="integralShow" style="width: 60px; height: 28px" type="text" />
              | 可兑换金额: ¥{{ integralMoney }}
            </div>
          </div>
        </el-form-item>
        <div v-show="sessionStorageData.recharge">
          <el-form-item label="充后金额:">
            <div class="form-width-ms">
              <span class="text-red text-price">{{ form.afterMoney?(form.afterMoney).toFixed(2)*1:0 }}</span>
            </div>
          </el-form-item>
          <el-form-item label="充后赠送:">
            <div class="form-width-ms">
              <span class="text-red text-price" v-if="giftAfterShow">{{ form.giftAfterMoney }}</span>
            </div>
          </el-form-item>
          <el-form-item label="备注说明:">
            <el-input v-model="form.description" type="textarea" placeholder="请填写说明" style="width: 300px" maxlength="200" :autosize="{ minRows: 1.5, maxRows: 3 }" show-word-limit></el-input>
          </el-form-item>
        </div>
        <el-form-item label="充后金额:" v-show="!sessionStorageData.recharge">
          <div class="form-width-ms">
            <span class="text-red text-price">{{ form.afterMoney?(form.afterMoney).toFixed(2)*1:0 }}</span>
          </div>
        </el-form-item>
        <br>
        <el-form-item label="充后赠送:" v-show="!sessionStorageData.recharge">
          <div class="form-width-ms">
            <span class="text-red text-price" v-if="giftAfterShow">{{ form.giftAfterMoney }}</span>
          </div>
        </el-form-item>
        <el-form-item label="备注说明:" v-show="!sessionStorageData.recharge">
          <el-input v-show="!sessionStorageData.recharge" v-model="form.description" type="textarea" placeholder="请填写说明" style="width: 400px" maxlength="200" :autosize="{ minRows: 1.5, maxRows: 3 }" show-word-limit></el-input>
        </el-form-item>
      </el-form>
      <div style="width: 280px" class="border-radius-10 border margin-right-xs  bg-white padding-xs">
        <el-table :data="payLists" :summary-method="getSummaries" show-summary max-height="400">
          <el-table-column align="center" prop="payName" label="支付方式" min-width="100"></el-table-column>
          <el-table-column align="center" prop="payMoney" fixed="right" label="本次支付" min-width="80">
            <template slot-scope="scope">
              <div class="form-input-width" v-if="!scope.row.isShow" @click="editPay(scope.row, scope.$index)">
                {{ scope.row.payMoney }}
                <i class="el-icon-edit text-cyan"></i>
              </div>
              <el-input v-else v-focus size="samll" v-on:input="scope.row.payMoney = scope.row.payMoney.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3')" @blur="endEdit(scope.row)" @change="endEdit(scope.row)" v-model="scope.row.payMoney" class="form-input-width-xs" type="number"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="colle" :class="sessionStorageData.recharge?'colleInt':'colle'">
      <el-collapse v-model="activeName" @change="collChange($event)">
        <el-collapse-item title="员工/门店管理层/高管业绩" name="员工">
          <div class="flex justify-center align-start flex-wrap margin-top-xs" style="width:100%">
            <staffsles ref="staffsles" @staffslesData="staffslesData"></staffsles>
            <admin ref="admin" @adminData="adminData"></admin>
            <manager ref="manager" @managerData="managerData"></manager>
          </div>
        </el-collapse-item>
      </el-collapse>
    </div>
    <div class="text-center colle-but padding-bottom-xs">
      <el-button size="mini" type="info" plain @click="empty">清空</el-button>
      <el-button size="mini" v-if="isAddition==0" type="primary" @click="isAddition = 1" v-role="5003005">补单</el-button>
      <el-button size="mini" v-else type="success" @click="isAddition = 0">充值</el-button>
      <el-button size="mini" type="primary" plain @click="getList(listDialogVisible = true)" v-role="5003001">列表 </el-button>
      <el-button size="mini" type="primary" :loading="saveloading" @click="save()" v-role="5003002">提交</el-button>
    </div>
    <div>
      <!-- 保存列表弹窗 -->
      <el-dialog :close-on-click-modal="false" v-dialogDrag title="充值" :visible.sync="listDialogVisible" width="80%" :close="close">
        <div class="flex justify-between  padding-bottom-xs">
          <div>
            <el-date-picker style="width: 200px" v-model="selectDate" @change="getList" format="yyyy年 MM月" type="month" placeholder="选择日期"></el-date-picker>
            <selec v-if="headOffice==1" ref="selec" @selecData="selecData"></selec>
          </div>
          <div class="flex">
            <div class="form-width-m padding-right-xs">
              <el-input size="medium" v-model="queryForm.rechargeNum" placeholder="输入单据号" clearable @change="getList">
              </el-input>
            </div>
            <div class="form-width-m padding-right-xs">
              <el-input size="medium" v-model="queryForm.memberName" placeholder="输入会员名字" clearable @change="getList">
              </el-input>
            </div>
            <div class="form-width-m padding-right-xs">
              <el-input size="medium" v-model="queryForm.mobilePhone" placeholder="输入会员手机号" oninput="this.value=this.value.replace(/\D/g,'')" pattern="[0-9]*" maxlength="11" clearable @change="getList"></el-input>
            </div>
            <el-button size="mini" type="primary" plain @click="getList()">搜索</el-button>
          </div>
        </div>
        <div style="max-height: 65vh; overflow: auto">
          <el-table :data="pageInfo.lists" ref="pageInfo.lists"  max-height="550" :header-cell-style="{
              background: 'linear-gradient(#6cb3ff, #1873d4)',
              color: '#eeeeee'
            }" :row-style="changeRowBgColorByIsPay">
            <el-table-column prop="tag" label="状态" width="70" fixed="left">
              <template slot-scope="scope">
                <el-tag :type="scope.row.isCancel == 1 ? 'primary' : 'success'">{{ scope.row.isCancel==0?'正常':'作废' }}</el-tag>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="storeName" label="门店" min-width="70"></el-table-column>
            <el-table-column align="center" show-overflow-tooltip prop="rechargeNum" label="单号" min-width="140"></el-table-column>
            <el-table-column align="center" show-overflow-tooltip prop="rechargeDate" label="日期" min-width="140"></el-table-column>
            <el-table-column align="center" prop="isAddition" label="补单" min-width="50">
              <template slot-scope="scope"><span class="text-red" v-show="scope.row.isAddition == 0">否</span><span class="text-green" v-show="scope.row.isAddition == 1">是</span></template>
            </el-table-column>
            <el-table-column align="center" prop="mobilePhone" label="手机号码" min-width="100"><template slot-scope="scope">
                <div>{{ scope.row.mobilePhone | phone }}</div>
              </template></el-table-column>
            <el-table-column align="center" prop="memberName" label="会员名称" min-width="90"></el-table-column>
            <el-table-column align="center" prop="rechargeTypeName" show-overflow-tooltip label="充值类别" min-width="120"></el-table-column>
            <el-table-column align="center" prop="beforeMoney" label="充前金额" min-width="70"></el-table-column>
            <el-table-column align="center" prop="collectionCashAmount" label="实付金额" min-width="70"></el-table-column>
            <el-table-column align="center" prop="debtMoney" label="欠款" min-width="70"></el-table-column>
            <el-table-column align="center" prop="afterMoney" label="充后金额" min-width="70"></el-table-column>
            <el-table-column align="center" prop="storeName" show-overflow-tooltip label="所属门店" min-width="100"></el-table-column>
            <el-table-column align="center" prop="inputBy" label="录单人" min-width="70"></el-table-column>
            <!-- <el-table-column fixed="right" label="账户操作" align="center" width="90" v-if="sessionStorageData.allowValid == 1">
              <template slot-scope="scope">
                <el-button size="mini" type="success" :disabled="scope.row.isCancel === 1" @click="openPostpone(scope.row, (postponeDialog = true))" v-role="5003004">账户延期
                </el-button>
              </template>
            </el-table-column> -->
            <el-table-column prop="tag" label="状态" width="70" fixed="right">
              <template slot-scope="scope">
                <el-tag :type="scope.row.isCancel == 1 ? 'primary' : 'success'">{{ scope.row.isCancel==0?'正常':'作废' }}</el-tag>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="明细" align="center" width="76">
              <template slot-scope="scope" fixed="right">
                <el-button @click="detail(scope.row)" size="mini" type="primary" plain v-role="5003003">明细</el-button>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="作废" align="center" width="76">
              <template slot-scope="scope" fixed="right">
                <el-button @click="recCancel(scope.row)" size="mini" type="primary" :disabled="scope.row.isCancel === 1" v-role="5003003">作废</el-button>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="打印" align="center" width="76">
              <template slot-scope="scope" fixed="right">
                <el-button size="mini" type="success" :disabled="scope.row.isCancel === 1" @click="print(scope.row, (printDialogVisible = true))" v-role="5003004">打印</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="block" style="margin-top: 10px">
            <!-- 分页组件 -->
            <el-pagination align="left" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="queryForm.pageNum" :page-sizes="[10, 20, 30, 40, 50]" :page-size="queryForm.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" type="primary" @click="close">关闭</el-button>
        </span>
      </el-dialog>
      <el-dialog title="账户明细" :visible.sync="postponeDialog" :modal-append-to-body="true">
        <el-form :model="postponeForm">
          <el-form-item label="会员名称:" label-width="120px">
            {{ postponeForm.memberName }}
          </el-form-item>
          <el-form-item label="账户名称:" label-width="120px">
            <div class="searchDiv">
              {{ postponeForm.rechargeTypeName }}
            </div>
          </el-form-item>
          <el-form-item label="可用金额:" label-width="120px">
            <div class="searchDiv">
              {{ postponeForm.cardConsumeMoney }}
            </div>
          </el-form-item>
          <el-form-item label="可用赠送金额:" label-width="120px">
            <div class="searchDiv">
              {{ postponeForm.giftConsumeMoney }}
            </div>
          </el-form-item>
          <el-form-item label="账户到期日:" label-width="120px">
            <div class="form-width-ms">
              <span v-show="!recDateShow" @click="openDate((recDateShow = true))">{{ postponeForm.endTime }}
                <el-button class="el-icon-edit" type="text" size="mini">修改</el-button>
              </span>
              <el-date-picker size="mini" @blur="recDateShow = false" v-show="recDateShow" ref="recDate" v-model="postponeForm.endTime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
            </div>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" type="primary" plain @click="postponeDialog = false">取 消</el-button>
          <el-button type="primary" size="mini" @click="endPostpone((postponeDialog = false))">确 定</el-button>
        </span>
      </el-dialog>
    </div>
    <!-- 注册 -->
    <!-- add form -->
    <div>
      <el-dialog :close-on-click-modal="false" v-dialogDrag title="打印" :visible.sync="printDialogVisible" width="60%">
        <div id="printTest" class="printDiv">
          <div class="text-center">
            充值
          </div>
          <br />
          <hr />
          <el-form :model="printForm">
            <!-- <br />
            <el-form-item label="门店:">
              <div>{{ printForm.storeName }}</div>
            </el-form-item><br />
            <el-form-item label="时间:"> {{ printForm.rechargeDate }} </el-form-item><br />
            <el-form-item label="单号:">
              {{ printForm.rechargeNum }} </el-form-item><br />
            <el-form-item label="会员:">
              <div>
                {{ printForm.memberName }}/{{ printForm.mobilePhone ? (printForm.mobilePhone.substring(3, 0)) + '****' + (printForm.mobilePhone.substring(7)) : '******'}}
              </div>
            </el-form-item><br />
            <el-form-item label="录单:">
              <div>
                {{ printForm.inputBy }}
              </div>
            </el-form-item><br />
            <el-form-item label="充值类别:">
              <div>{{ printForm.rechargeTypeName }}</div>
            </el-form-item>
            <br />
            <el-form-item label="上次余额:">
              <div class="flex justify-start align-center">
                <div style="width: 40px">{{ printForm.beforeMoney }}</div>
                <div><span>赠送:</span><span>{{ printForm.giftBeforeMoney }}</span></div>
              </div>
            </el-form-item>
            <br />
            <el-form-item label="本次余额:">
              <div class="flex justify-start align-center">
                <div style="width: 40px">{{ printForm.afterMoney }}</div>
                <div><span>赠送:</span><span>{{ printForm.giftAfterMoney }}</span></div>
              </div>
            </el-form-item>
            <hr class="margin-top margin-bottom">
            <div class="print-table">
              <div class="flex justify-start align-center">
                <div class="text-left" style="width: 50%;height:30px;">付款方式</div>
                <div class="text-left" style="width: 50%;height:30px;">支付金额</div>
              </div>
              <div class="flex justify-start align-center" v-for="(item,index) in printForm.payLists" :key="index">
                <div class="text-left" style="width: 50%;height:30px;">{{item.payName}}</div>
                <div class="text-left" style="width: 50%;height:30px;">{{item.payMoney}}</div>
              </div>
            </div> -->
            <div class="box1">
              <p class="font-w">门 店：</p> <span>{{ printForm.storeName }}</span>
            </div>
            <div class="box1">
              <p class="font-w">日 期：</p><span>{{ printForm.rechargeDate }}</span>
            </div>
            <div class="box1">
              <p class="font-w">单据号：</p><span>{{ printForm.rechargeNum }}</span> 
            </div>
            <div class="box1">
              <p class="font-w">收银员：</p> <span>{{ printForm.inputNum }}</span> 
            </div>
            <div class="box1">
              <p class="font-w">姓 名：</p><span>{{ printForm.memberName }}</span> 
            </div>
            <div class="box1">
              <p class="font-w">手机号：</p><span>{{ printForm.mobilePhone }}</span> 
            </div>
            <hr style="margin-top:10px"/>
            <div class="print-project">
              <ul>
                <li class="project-top">
                  <p>类别</p>
                  <p>金额</p>
                  <p>余额</p>
                </li>
                <li class="project-top-del">
                  <p>{{ printForm.rechargeTypeName }}</p>
                  <p>{{ printForm.collectionCashAmount }}</p>
                  <p>{{ printForm.afterMoney }}</p>
                </li>
              </ul>
            </div>
            <hr style="margin-top:10px"/>
                <div class="print-project">
                  <ul>
                    <li class="project-top">
                      <p>付款方式</p>
                      <p>金额</p>
                    </li>
                    <li v-for="(item,index) in printForm.payLists " :key="index" class="project-top-del">
                      <p>{{ item.payName }}</p>
                      <p> {{ item.payMoney }}</p>
                    </li>
                  </ul>
                </div>
            <br />
            <div style="height:50px"></div>
            <div class="box1">
              <p class="font-w">签名：</p>
            </div>
            <div class="box1">
              <p class="font-w">服务热线：</p> <span>{{ printForm.telephone }}</span>
            </div>
            <div class="box1">
              <p class="font-w"></p> <span>{{ printForm.printDate | dateFormat }}</span>
            </div>
            <!-- <el-form-item label="签名:">
            </el-form-item><br />
            <el-form-item label="服务热线:">
              {{ printForm.telephone }} </el-form-item><br />
            <el-form-item>
              {{ printForm.printDate | dateFormat }}
            </el-form-item> -->
            <br /><br />
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" type="primary" plain @click="printDialogVisible = false">取 消</el-button>
          <el-button size="mini" type="primary" v-print="'#printTest'">打 印</el-button>
          <!-- <el-button size="mini" type="primary" v-print="print">打 印</el-button> -->
        </span>
      </el-dialog>
    </div>
    <addmember ref="addmember" @editData="memberAdd" @addUserConfirm="addUserConfirm"></addmember>
    <member ref="member" @memberData="memberData"></member>
    <rectype ref="rectype" @recTypeData="recTypeData"></rectype>
    <repayment ref="repayment" @repaymentData="query"></repayment>
    <updo ref="updo" @recTypeData="recTypeData"></updo>
    <detail ref="detail" @detailData="detailData"></detail>
    <trading ref="trading" :mobilePhone='form.mobilePhone'/>
    <record-details ref="recordDetails"/>
    <rechargeDetail ref="rechargeDetail"/>
  </div>
</template>
<script>
import rechargeDetail from './detail.vue'
import detail from "./components/detail.vue";
import repayment from "@/components/repayment/index.vue";
import rectype from "@/components/recharge/type/index";
import updo from "@/components/recharge/updo/index";
import recordDetails from './components/record-details.vue'
import { ctlist, recpage, selectById, editRecAccount } from "@/api/eashier.js";
import {
  storeMemberOne,
  addrec,
  upgrade,
  recAccountOne,
  recCancel,
  storeOne,
  recAccountList,
  recTypeOne,
  debtPage,
} from "@/api/eashier.js";
import addmember from "@/components/member/edit/index";
import admin from "@/components/staffList/admin/index";
import manager from "@/components/staffList/manager/index";
import staffsles from "@/components/staffList/staff/index";
import member from "@/components/member/index";
import selec from "@/components/store/select/index";
import Template from "../../discount-coupon/issue/components/template.vue";
export default {
  name:"collectionList",
  components: {
    member,
    selec,
    staffsles,
    manager,
    admin,
    repayment,
    addmember,
    rectype,
    updo,
    detail,
    Template,
    recordDetails,
    rechargeDetail,
  },
  data() {
    return {
      giveType:undefined,
      printDialogVisible: false, //打印弹窗开关
      listDialogVisible: false,
      postponeDialog: false,
      refreshtext: false, //搜索判断字符
      headOffice: sessionStorage.getItem("headOffice") * 1,
      isShow: false,
      selectNumber: 0,
      isAddition: 0,
      saveloading: false,
      recDateShow: false,
      postponeForm: {},
      sessionStorageData: {}, //门店参数集合
      detailForm: {},
      activeName: ["员工"],
      integral: 0,
      consumeIntegral: 0,
      integralMoney: 0,
      liftType: 0,
      debtMoneys: 0,
      recList: [],
      printForm: {
        number: null,
        storeId: null,
        staffId: null,
        memberName: null,
        mobilePhone: null,
        type: "",
        amount: null,
        cardOver: null,
        cardOvers: null,
        sonMoney: null,
        sonMoneys: null,
        telephone: "",
        printDate: new Date(),
      },
      queryForm: {
        //查询对象
        pageNum: 1, // 当前页码
        pageSize: 10, // 每页的数据条数,
      },
      selectDate: new Date(),
      total: 0, //分页总条数
      pageInfo: {
        lists: [],
      },
      giftAfterShow: true, //重新展示充值赠送后金额
      payLists: [], //现付列表
      staffLists: [{ brandNumber: "", staffName: "", ratio: 100 }],
      managerLists: [{ brandNumber: "", staffName: "", ratio: 100 }],
      adminList: [{ brandNumber: "", staffName: "", ratio: 100 }],
      staffList: [],
      managerList: [],
      form: {
        mobilePhone: null,
        memberName: null,
        sex: null,
        collectionCashAmount: null,
        beforeMoney: 0,
        description: null,
        rechargeTypeName: null,
        integralCheckbox: false,
        debtMoney: null,
        additionDate: null,
        rechargeAmount: 0,
        debtMoney: 0,
        afterMoney:0,
        giftAfterMoney: 0,
        giftBeforeMoney: 0,
        collectionAmount: 0,
      },
      integralShow: false,
      typeList: {},
      afterMoney: "",
      vip: {}, //会员信息
      idList: {},
      money: null,
      date: [],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
      },
      beforeMoney: 0,
      afterMoney: 0,
    };
  },
  methods: {
    addUserConfirm(phone){
      this.form.mobilePhone = phone
      this.query()
    },
    routePush(){
      this.$refs.trading.dialogFormVisible = true
    },
    close() {
      this.listDialogVisible = false;
    },
    collChange(e) {
      if (e.indexOf("员工")) {
        this.$refs.staffsles.show(this.staffLists);
        this.$refs.manager.show(this.managerLists);
        this.$refs.admin.show(this.adminList);
      }
    },
    //员工占比返回方法
    staffslesData(v) {
      this.staffLists = [...v];
    },
    //高管占比返回方法
    managerData(v) {
      this.managerLists = [...v];
    },
    //管理员占比返回方法
    adminData(v) {
      this.adminList = [...v];
    },
    openMoney() {
      this.$refs.repayment.show(this.vip);
    },
    recChange(v) {
      if (v) {
        if (this.liftType != 0) {
          this.form.frechargeTypeId = v;
          this.recList.forEach((item) => {
            if (item.rechargeTypeId == v) {
              this.form.ids = item.id;
              this.form.rawRechargeTypeId = item.rechargeTypeId;
            }
          });
        }
        recTypeOne({ id: v }).then((res) => {
          if (res.code == "000000") {
            this.selectNumber = 0;
            this.recTypeData(res.data, 0);
          } else {
            this.$alert(res.message, "查询充值类别明细", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
          }
        });
      } else {
        this.gSetForm();
      }
    },
    gSetForm() {
      let form = {};
      form.memberId = this.form.memberId;
      form.mobilePhone = this.form.mobilePhone;
      form.memberName = this.form.memberName;
      form.rechargeAmount = 0;
      form.beforeMoney = 0;
      form.giftBeforeMoney = 0;
      form.afterMoney = 0;
      form.giftAfterMoney = 0;
      form.collectionCashAmount = 0;
      form.collectionAmount = 0;
      form.debtMoney = 0;
      this.form = form;
    },
    radioChange(v) {
      if (v != 0) {
        this.getRecList();
      }
      if(this.form.rechargeTypeName){
        this.form.rechargeTypeName=""
      }
    },
    openRec(number) {
      console.log(number);
      this.selectNumber = number;
      if (number == 0) {
        this.$refs.rectype.show();
      } else {
        let form = { id: this.form.frechargeTypeId };
        this.$refs.updo.show(form, number);
      }
    },
 
    recTypeData(v, number) {
      this.giveType = v.giveType
      this.form.liftType = this.liftType;
      if (v.rawCardId) {
        this.form.rawCardId = v.rawCardId;
        this.form.liftCardId = v.liftCardId;
        this.idList.rechargeTypeId = v.rawCardId;
      } else {
        this.idList.rechargeTypeId = v.id;
      }
      this.form.rechargeTypeNum = v.rechargeTypeNum;
      //标准 充值账号选择
      recAccountOne(this.idList).then((res) => {
        if (res.data != undefined && res.data.state == 0) {
          this.$message.error({
            message: "账户已锁定, 不允许使用 ! ",
          });
        } else {
          if (res.code == "000000" || res.code == "200004") {
            this.form.rechargeAmount = v.rechargeMoney;
            if (number == 0) {
              this.form.rechargeTypeName = "";
            } else {
              this.form.rechargeTypeName = v.rechargeTypeName;
            }
            this.form.rechargeTypeId = v.id;
            this.form.discount = v.discount;
            this.form.typeRatio = v.typeRatio;
            this.form.donateType = v.donateType;
            this.form.giftMoney = v.giftMoney;
            this.form.collectionAmount = 0;
            this.form.collectionCashAmount = 0;
            if (this.liftType == 0) {
              this.form.beforeMoney = 0;
              this.form.giftBeforeMoney = 0;
              this.form.giftAfterMoney = 0;
              this.form.afterMoney = 0;
            }
            if (!this.form.integralMoney) {
              this.form.integralMoney = 0;
            }
            if (res.code == "000000") {
              //有账号
              this.form.rechargeAccountId = res.data.id;
              if (this.liftType == 0) {
                this.form.beforeMoney = res.data.cardRestMoney;
                this.form.giftBeforeMoney = res.data.cardGiftMoney;
              } else {
                this.form.beforeMoney =
                  (res.data.cardRestMoney + this.form.beforeMoney).toFixed(2) *
                  1;
                this.form.giftBeforeMoney =
                  (res.data.cardGiftMoney + this.form.giftBeforeMoney).toFixed(
                    2
                  ) * 1;
              }
              if (
                res.data.cardRestMoney == 0 &&
                (res.data.firstCharge == "0" ||
                  res.data.firstCharge == 0 ||
                  res.data.firstCharge == null)
              ) {
                this.form.rechargeAmount = v.firstAmount;
              }
            } else {
              if (v.firstAmount) {
                this.form.rechargeAmount = v.firstAmount;
              } else {
                this.form.rechargeAmount = v.rechargeMoney;
              }
            }
            this.form.debtMoney =
              (
                this.form.rechargeAmount -
                this.form.collectionCashAmount -
                this.form.integralMoney
              ).toFixed(2) * 1;
            if (this.form.debtMoney < 0) {
              this.form.debtMoney = 0;
            }
            this.form.afterMoney =
              this.form.rechargeAmount + this.form.beforeMoney;
 
            if (!v.giftMoney) {
              v.giftMoney = 0;
              if (!this.form.giftBeforeMoney) {
                this.form.giftBeforeMoney = 0;
              }
              this.form.giftAfterMoney =
                this.form.giftBeforeMoney + v.giftMoney;
            } else {
              if (!this.form.giftBeforeMoney) {
                this.form.giftBeforeMoney = 0;
              }
              let giftMoney = 0;
              if (v.donateType == 1) {
                giftMoney =
                  ((v.giftMoney * this.form.rechargeAmount) / 100).toFixed(2) *
                  1;
              } else {
                giftMoney = v.giftMoney;
              }
              this.form.giftAfterMoney =
                (this.form.giftBeforeMoney + giftMoney).toFixed(2) * 1;
            }
            if (this.sessionStorageData.recharge == true) {
              if (this.form.integralCheckbox == true) {
                let list = JSON.parse(
                  sessionStorage.getItem("sessionStorageData")
                ).excIntegralByMoney.split(":");
                if (this.integralMoney >= this.form.debtMoney) {
                  this.integralMoney = this.form.debtMoney;
                  this.consumeIntegral =
                    this.form.debtMoney * (list[0] / list[1]);
                }
              }
            }
            if (number == 0) {
              this.beforeMoney = this.form.beforeMoney;
              this.afterMoney = this.form.afterMoney;
            }
            if (this.liftType != 0) {
              this.afterMoney = this.afterMoney + this.form.afterMoney;
              this.beforeMoney = this.beforeMoney + this.form.beforeMoney;
            }
          } else {
            this.$alert(res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
            this.form.rechargeAccountId = "";
            this.form.beforeMoney = 0;
            this.form.giftBeforeMoney = 0;
            if (!v.giftMoney) {
              v.giftMoney = 0;
              this.form.giftAfterMoney =
                (this.form.giftBeforeMoney + v.giftMoney).toFixed(2) * 1;
            } else {
              this.form.giftAfterMoney =
                (this.form.giftBeforeMoney + v.giftMoney).toFixed(2) * 1;
            }
          }
        }
        let form = { ...this.form };
        this.form = {};
        this.form = form;
        // console.log("🚀 ~ file: collectionList.vue ~ line 747 ~ recAccountOne ~ this.form", this.form)
      });
    },
    //打开选择会员弹窗
    openMember() {
      this.$refs.member.show(this.vip);
    }, 
    //选中会员返回方法
    memberData(v) {
      this.form.mobilePhone = v.mobilePhone;
      this.query();
    },
    //上传文件方法
    fileData(v) {
      //console.log(v);
    },
    //返回当前行的下标
    tableRowClassName({ row, rowIndex }) {
      row.index = rowIndex;
    },
    openDate() {
      this.$nextTick(() => {
        this.$refs.recDate.focus();
      });
    },
    //打印方法
    print(row) {
      storeOne({
        id: row.storeId,
      }).then((res) => {
        if (res.code == "000000") {
          //console.log(res);
          row.telephone = res.data.telephone;
          row.printDate = new Date();
          this.printForm = row;
        }
      });
    },
    checkintegral(row) {
      if (this.form.rechargeTypeName != "") {
        let list = JSON.parse(
          sessionStorage.getItem("sessionStorageData")
        ).excIntegralByMoney.split(":");
 
        if (row == true) {
          if (this.integralMoney >= this.form.debtMoney) {
            this.integralMoney = this.form.debtMoney;
            this.consumeIntegral = this.form.debtMoney * (list[0] / list[1]);
          }
          this.form.debtMoney =
           ( this.form.rechargeAmount * 1 - this.integralMoney).toFixed(2)*1;
          if (this.form.debtMoney < 0) {
            this.form.debtMoney = 0;
          }
        } else {
          this.form.debtMoney = this.form.rechargeAmount * 1;
          if (this.form.debtMoney < 0) {
            this.form.debtMoney = 0;
          }
          storeMemberOne({
            mobilePhone: this.form.mobilePhone,
            storeId: sessionStorage.getItem("parentId"),
          }).then((res) => {
            if (this.sessionStorageData.recharge == true) {
              this.integral = res.data.integral;
              this.integralMoney = res.data.integralMoney;
              this.consumeIntegral = res.data.consumeIntegral;
            } else {
              this.integral = 0;
              this.integralMoney = 0;
              this.consumeIntegral = 0;
            }
          });
        }
        this.num();
      }
    },
 
    //输入手机号是查询
    //查询方法
    query() {
      // var number = partten.phoneNum;
      var mobilePhone = this.form.mobilePhone;
      this.empty();
      // if (!number.test(mobilePhone)) {
      //   this.$message.info({
      //     message: "请输入正确的手机号 ! ",
      //   });
      // } else {
        storeMemberOne({
          mobilePhone: mobilePhone,
          storeId: sessionStorage.getItem("parentId"),
        }).then((res) => {
          this.form.mobilePhone = mobilePhone;
          if (res.data != undefined && res.data.state == 0) {
            this.$message.error({
              message: "账户已锁定, 不允许使用 ! ",
            });
            this.$alert("账户已锁定, 不允许使用 !", "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
          } else {
            if (res.code == "000000" || res.code == "200004") {
              if (res.code == "000000") {
                var idList = {
                  storeId: res.data.storeId,
                  memberId: res.data.id,
                };
                this.idList = idList;
                // 会员id 门店id 充值类别id
                this.vip = res.data;
                this.form.card = res.data.card;
                this.form.memberId = res.data.id;
                this.form.memberName = res.data.memberName;
                this.debtMoneys = res.data.debtMoney;
                this.form.sex = res.data.sex;
                this.getRecList();
                if (res.data.memberIdentityCard != "") {
                  this.form.memberIdentityCard = res.data.memberIdentityCard;
                } else {
                  this.form.memberIdentityCard = "";
                }
                if (this.sessionStorageData.recharge == true) {
                  this.consumeIntegral = res.data.consumeIntegral;
                  this.integral = res.data.integral;
                  this.integralMoney = res.data.integralMoney;
                } else {
                  this.consumeIntegral = 0;
                  this.integral = 0;
                  this.integralMoney = 0;
                }
              } else {
                this.empty();
                if (res.code == "200004") {
                  this.$confirm(res.message + ",请先注册!", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    cancelButtonClass: "cancelbtnFalses",
                    confirmButtonClass: "confirmbtnFalses",
                    type: "warning",
                  }).then(() => {
                    this.openAddMember();
                  });
                } else {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定",
                    confirmButtonClass: "confirmbtnFalses",
                    type: "warning",
                    center: true,
                    callback: (action) => {},
                  });
                }
              }
            } else {
              this.form.rechargeAccountId = "";
              this.form.beforeMoney = 0;
              this.form.giftBeforeMoney = 0;
              if (this.typeList.giftMoney == null) {
                this.typeList.giftMoney = 0;
                this.form.giftAfterMoney =
                  (this.form.giftBeforeMoney + this.typeList.giftMoney).toFixed(
                    2
                  ) * 1;
              } else {
                this.form.giftAfterMoney =
                  (this.form.giftBeforeMoney + this.typeList.giftMoney).toFixed(
                    2
                  ) * 1;
              }
              this.$alert("查询会员信息 : " + res.message, "提示", {
                confirmButtonText: "确定",
                confirmButtonClass: "confirmbtnFalses",
                type: "warning",
                center: true,
                callback: (action) => {},
              });
            }
          }
        });
      // }
    },
    openAddMember() {
      this.$refs.addmember.show("添加");
    },
    memberAdd(v) {
      this.form.mobilePhone = v.mobilePhone;
      this.query();
    },
    //选择金额.`
    editPay(row, index) {
      if (row.payMoney * 1 < 0) {
        row.payMoney = 0;
      }
      row.payMoney = row.payMoney.toFixed(2) * 1;
      if (this.form.rechargeTypeName) {
        row.payMoney = (this.form.debtMoney + row.payMoney).toFixed(2) * 1;
        row.isShow = true;
        var form = {
          ...row,
        };
        var payLists = [...this.payLists];
        payLists[index] = form;
        this.payLists = [];
        this.payLists = payLists;
      } else {
        this.$message.info({
          message: "请先选择充值类别!",
        });
      }
    },
    endEdit(row) {
      row.payMoney = row.payMoney * 1;
      row.isShow = false;
      this.num();
      let integralMoney = this.integralMoney;
      if (this.form.integralCheckbox == false) {
        integralMoney = 0;
      }
      if (this.form.rechargeAmount == null) {
        this.form.rechargeAmount = 0;
      }
      this.form.debtMoney =
        (this.form.rechargeAmount -
        this.form.collectionCashAmount -
        integralMoney).toFixed(2)*1;
      if (this.form.debtMoney < 0) {
        this.form.debtMoney = 0;
      }
      this.form.afterMoney =
        this.form.collectionCashAmount + this.form.beforeMoney + integralMoney;
      if (
        this.form.debtMoney * 1 >
        (
          (this.form.rechargeAmount *
            this.sessionStorageData.recDebtRatio *
            1) /
          100
        ).toFixed(2) *
          1
      ) {
        this.$message.warning({
          message:
            "本次支付金额最多可以欠款 : " +
            (
              (this.form.rechargeAmount *
                this.sessionStorageData.recDebtRatio *
                1) /
              100
            ).toFixed(2) *
              1,
        });
      }
    },
 
    empty() {
      Object.assign(this.$data, this.$options.data.call(this));
      this.setPage();
    },
    setStaffRatio() {
      var that = this;
      setTimeout(() => {
        that.$refs.manager.show(that.managerLists);
        that.$refs.staffsles.show(that.staffLists);
        that.$refs.admin.show(that.adminList);
      }, 500);
    },
 
    //提交
    //保存确定方法
    save() {
      this.num();
      var staffList = [];
      this.staffLists.forEach((item) => {
        if (item.id) {
          delete item.ratioShow;
          staffList.push(item);
        }
      });
      this.form.staffLists = staffList;
      var payLists = [];
      this.payLists.forEach((item) => {
        delete item.collectionType;
        delete item.isShow;
        delete item.state;
        if (item.payMoney * 1 > 0) {
          payLists.push(item);
        }
      });
      this.form.payLists = payLists;
      if (this.form.integralCheckbox == true) {
        this.form.consumeIntegral = this.consumeIntegral;
        this.form.integralMoney = this.integralMoney;
        this.form.integral = this.integral;
        this.form.collectionIntegralAmount = this.form.integralMoney;
        this.form.integral = this.form.consumeIntegral;
      } else {
        this.form.collectionIntegralAmount = 0;
        this.form.integral = 0;
        this.form.consumeIntegral = 0;
        this.form.integralMoney = 0;
      }
      this.form.debtMoney =
        (
          this.form.rechargeAmount -
          this.form.collectionCashAmount -
          this.form.integralMoney
        ).toFixed(2) * 1;
      if (this.form.debtMoney < 0) {
        this.form.debtMoney = 0;
      }
      if (this.form.debtMoney > 0) {
        this.form.isDebt = 1;
      } else {
        this.form.isDebt = 0;
        this.form.debtMoney = 0;
      }
      if (this.form.integralCheckbox == true) {
        this.form.integralCheckbox = 1;
      } else {
        this.form.integralCheckbox = 0;
      }
      let salesmens = [];
      this.managerLists.forEach((item) => {
        if (item.id) {
          item.staffType = 0;
          salesmens.push(item);
        }
      });
      this.adminList.forEach((item) => {
        if (item.id) {
          item.staffType = 1;
          salesmens.push(item);
        }
      });
      this.form.salesmens = salesmens;
      delete this.form.rechargeDate;
      delete this.form.consumeIntegral;
      delete this.form.integralMoney;
      delete this.form.integralCheckbox;
      this.form.memberId = this.vip.id;
      this.form.isAddition = this.isAddition;
      if (!this.form.additionDate && this.isAddition == 1) {
        this.saveloading = false;
        this.$alert("请选择业务日期", "提示", {
          confirmButtonText: "确定",
          confirmButtonClass: "confirmbtnFalses",
          type: "warning",
          center: true,
          callback: (action) => {},
        });
      } else {
        let useMoney =
          (
            this.sessionStorageData.recDebtRatio *
            0.01 *
            this.form.rechargeAmount
          ).toFixed(2) * 1;
        if (this.sessionStorageData.recDebt == true) {
          if (this.form.debtMoney > useMoney) {
            this.saveloading = false;
            this.$alert("本次充值最多可以欠款 " + useMoney, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
          } else {
            var that = this;
            if (staffList.length == 0) {
              this.$confirm("没有选择员工是否保存?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                cancelButtonClass: "cancelbtnFalses",
                confirmButtonClass: "confirmbtnFalses",
                type: "warning",
              }).then(() => {
                this.addrec();
              });
            } else {
              this.addrec();
            }
          }
        } else {
          var that = this;
          if (staffList.length == 0) {
            this.$confirm("没有选择员工是否保存?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              cancelButtonClass: "cancelbtnFalses",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
            }).then(() => {
              this.addrec();
            });
          } else {
            this.addrec();
          }
        }
      }
      // setTimeout(() => {
      //   this.saveloading = false;
      // }, 3000);
    },
    addrec() {
      // setTimeout(() => {
      //   this.saveloading = false;
      // }, 3000);
      if (this.liftType == 0) {
        this.form.giveType = this.giveType
        this.$confirm('是否发送短信?', '短信', {
          distinguishCancelAndClose: true,
          confirmButtonText: '是',
          cancelButtonText: '否'
        }).then(()=>{
          this.form.isSendSms = 1
          this.saveloading = true
          addrec(this.form).then((res) => {
            this.saveloading = false;
            if (res.code == "000000") {
              this.empty();
              this.$message.success({
                message: res.message,
              });
              this.$refs.rechargeDetail.show()
            } else {
              this.$alert(res.message, "提示", {
                confirmButtonText: "确定",
                confirmButtonClass: "confirmbtnFalses",
                type: "warning",
                center: true,
                callback: (action) => {
                  
                },
              });
            }
          });
        }).catch(()=>{
          this.form.isSendSms = 0
          this.saveloading = true 
          addrec(this.form).then((res) => {
            this.saveloading = false;
            if (res.code == "000000") {
              this.empty();
              this.$message.success({
                message: res.message,
              });
              this.$refs.rechargeDetail.show()
            } else {
              this.$alert(res.message, "提示", {
                confirmButtonText: "确定",
                confirmButtonClass: "confirmbtnFalses",
                type: "warning",
                center: true,
                callback: (action) => {
                  
                },
              });
            }
          });
        })
      } else {
        this.$confirm('是否发送短信?', '短信', {
          distinguishCancelAndClose: true,
          confirmButtonText: '是',
          cancelButtonText: '否'
        }).then(()=>{
          this.form.isSendSms = 1
          this.saveloading = true
          upgrade(this.form).then((res) => {
          this.saveloading = false;
          if (res.code == "000000") {
            this.empty();
            this.$message.success({
              message: res.message,
            });
            this.$refs.rechargeDetail.show()
          } else {
            this.$alert(res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
          }
        });
        }).catch(()=>{
          this.form.isSendSms = 0
          this.saveloading = true
          upgrade(this.form).then((res) => {
            this.saveloading = false;
            if (res.code == "000000") {
              this.empty();
              this.$message.success({
                message: res.message,
              });
              this.$refs.rechargeDetail.show()
            } else {
              this.$alert(res.message, "提示", {
                confirmButtonText: "确定",
                confirmButtonClass: "confirmbtnFalses",
                type: "warning",
                center: true,
                callback: (action) => {},
              });
            }
          });
        })
      }
    },
    selecData(v) {
      this.queryForm.storeList = v;
      this.getList();
    },
    //列表
    getList() {
      this.listDialogVisible = true;
      if (this.headOffice == 1) {
        this.$nextTick(() => {
          this.$refs.selec.show();
        });
      }
      this.queryForm.selectDate = this.formatTime(this.selectDate, "YYYYMM");
      recpage(this.queryForm).then((res) => {
        if (res.code == "000000") {
          res.pageInfo.list.forEach((item) => {
            item.entities.forEach((items) => {
              items.editStaffRatioShow = false;
            });
          });
          res.pageInfo.lists = res.pageInfo.list;
          this.pageInfo = res.pageInfo;
          this.total = res.pageInfo.total;
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => {},
          });
        }
      });
    },
    changeRowBgColorByIsPay({ row, rowIndex }) {
      let stylejson = {};
      if (row.isCancel === 1) {
        stylejson.background = "#eee";
        return stylejson;
      } else {
        return "";
      }
    },
    detail(row) {
      this.$refs.detail.show(row);
    },
    detailData() {
      this.getList();
    },
 
    openPostpone(row) {
      selectById({
        id: row.rechargeAccountId,
      }).then((res) => {
        if (res.code == "000000") {
          this.postponeForm = res.data;
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => {},
          });
        }
      });
    },
    endPostpone() {
      var form = {
        id: this.postponeForm.id,
        endTime: this.postponeForm.endTime,
      };
      editRecAccount(form).then((res) => {
        if (res.code == "000000") {
          this.$message.success({
            message: res.message,
          });
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => {},
          });
        }
        this.getList();
      });
    },
    //充值单作废
    recCancel(row) {
      this.$confirm("此操作将作废这张单, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        cancelButtonClass: "cancelbtnFalses",
        confirmButtonClass: "confirmbtnFalses",
        type: "warning",
      }).then(() => {
        delete row.payLists;
        delete row.entities;
 
        row.isCancel = 1;
        recCancel(row).then((res) => {
          //console.log(res);
          if (row.code == "000000") {
            this.$message.success({
              message: res.message,
            });
            this.getList();
            this.$message({
              type: "success",
              message: "已作废!",
            });
          } else {
            this.$alert(res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {
                this.getList();
              },
            });
          }
        });
      });
    },
    getCtList() {
      ctlist({ id: "" }).then((res) => {
        if (res.code == "000000") {
          var list = [];
          res.rows.forEach((item) => {
            let items = {
              payId: item.id,
              payMoney: 0,
              payName: item.collectionTypeName,
              isShow: false,
            };
            list.push(items);
          });
          this.payLists = list;
        } else {
          this.$alert("现付列表" + res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => {},
          });
        }
      });
      var that = this;
      setTimeout(() => {
        that.$refs.staffsles.show(that.staffLists);
      }, 1000);
    },
    getRecList() {
      if (this.form.memberId) {
        recAccountList({
          memberId: this.form.memberId,
 
        }).then((res) => {
          if (res.code == "000000") {
            this.recList = res.rows;
            let form = {
        pageSize: 99,
        memberId: this.form.memberId,
        state: 0,
        storeId: sessionStorage.getItem("storeId"),
      };
      //获取欠款列表
      debtPage(form).then((res) => {
        if (res.code == "000000") {
          var klist=res.pageInfo.list
           klist.forEach((item)=>{
               this.recList.forEach((items,index)=>{
                      if(item.tradeName==items.rechargeTypeName){
                          this.recList.splice(index,1)
                          
                      }
                })
        })
        console.log("🚀 ~ file: collectionList.vue ~ line 586 ~ this.recList.forEach ~ this.recList", this.recList)
        }else{

        }
      })
          } else {
            this.$alert("查询会员充值卡: " + res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
          }
        });
      }
    },
    //指定列求和
    //数组按对应字段合计返回方法
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        if (column.property == "payMoney") {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              sums[index] = "--";
            }
          }, 0);
          sums[index] += " ";
        } else {
          sums[index] = "--";
        }
      });
      return sums;
    },
    //求和
    num() {
      var num = 0;
      var form = { ...this.form };
      this.payLists.forEach((item) => {
        num += item.payMoney * 1;
      });
      form.collectionCashAmount = num;
      if (form.integralCheckbox == true) {
        form.collectionAmount = form.collectionCashAmount + this.integralMoney;
      } else {
        form.collectionAmount = form.collectionCashAmount;
      }
      let giftMoney = 0;
      if (form.donateType == 1) {
        giftMoney =
          ((form.giftMoney * form.collectionCashAmount) / 100).toFixed(2) * 1;
      } else {
        giftMoney = form.giftMoney;
      }
      form.giftAfterMoney = (form.giftBeforeMoney + giftMoney).toFixed(2) * 1;
      this.giftAfterShow = false;
      this.form = {};
      this.form = { ...form };
      this.giftAfterShow = true;
    },
    //分页方法
    handleSizeChange(val) {
      //   //console.log(`每页 ${val} 条`);
      this.queryForm.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      //   //console.log(`当前页: ${val}`);
      this.queryForm.pageNum = val;
      this.getList();
    },
    setPage() {
      this.setStaffRatio();
      this.getCtList();
      this.sessionStorageData = JSON.parse(
        sessionStorage.getItem("sessionStorageData")
      );
    },
  },
  created() {
    this.setPage();
  },
};
</script>
<style scoped>
.print-project{
  width:100%
}
.project-top-del p:nth-child(1){
  width:110px;
}
.project-top-del p{
  display:inline-block;
  width:40px
}
.project-top p{
  /* font-weight: bold; */
  display:inline-block;
  width:40px
}
.project-top p:nth-child(1){
  width:110px;
}
.font-w{
  /* font-weight: bold; */
  display:inline-block;
}
::v-deep .el-input__inner{
  height: 38px;
}
.collection {
  background: white;
  margin-left: 25px;
}
 
.collectioncenter {
  margin-top: 15px;
  padding-left: 40px;
}
 
.collectioncenter table {
  margin: 10px auto;
}
 
.collectioncenter th:nth-child(1) {
  min-width: 78px;
}
 
.collectioncenter td {
  height: 25px;
  min-width: 68px;
  text-align: center;
  padding: 10px;
}
 
.collection .span {
  width: 100px;
  display: inline-block;
}
 
.type .el-radio__label {
  display: none;
}
 
/* .collection .el-input {
  width: 100px;
} */
.colljisuan {
  height: 38px;
  width: 100%;
  border-bottom: 1px solid #999999;
  position: relative;
  font-size: 14px;
  line-height: 35px;
}
 
.colljisuan span:nth-child(1) {
  position: absolute;
  left: 35px;
}
 
.colljisuan span:nth-child(2) {
  position: absolute;
  left: 235px;
}
 
.colle {
  padding: 10px 0px 10px 30px;
}
 
.colle .el-collapse-item,
.colle-but {
  max-width: 1100px;
}
 
.colle .el-collapse-item__header {
  border-bottom: 1px solid #999999;
}
.colleInt .el-collapse-item,
.colle-but {
  max-width: 1100px;
}
 
.collection > .el-date-picker__time-header {
  display: none !important;
}
 
.printDiv .el-form-item {
  margin-bottom: 0px;
}
 
.printDiv .el-form-item__label,
.el-form-item__content {
  font-size: 12px;
  color: black;
  font-family: "宋体";
  padding: 0 5px 0 0;
}
.printDiv {
  width: 280px;
  margin: 0 auto;
  color:#000000
}
/*去除页眉页脚*/
@page {
  size: auto; /* auto is the initial value */
  margin: 0mm; /* this affects the margin in the printer settings */
  padding: 0;
}
 
html {
  background-color: #ffffff;
  margin: 0; /* this affects the margin on the html before sending to printer */
}
@media print {
  /*设置要打印的区域*/
  #tablecontent {
    display: block;
    width: 100%;
    height: auto;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }
}
 
/*去除页眉页脚*/
</style>