<template>
  <div class="rech">
    <el-form :model="refund" inline :label-width="formWidth">
      <el-form-item prop="rechPhone" label="手机号码:">
        <div class="form-width-ms">
          <el-input
            style="padding-left:0px;"
            oninput="this.value=this.value.replace(/\D/g,'')"
            pattern="[0-9]*"
            maxlength="11"
            v-model="refund.mobilePhone"
            @change="memberOne"
            @blur="memberOne"
          >
            <el-button
              size="mini"
              slot="append"
              icon="el-icon-search"
              @click="openMember"
            ></el-button>
          </el-input>
        </div>
      </el-form-item>
      <el-form-item prop="vipName" label="会员名字:">
        <div class="form-width-ms">{{ refund.memberName }}</div>
      </el-form-item>
      <el-form-item prop="rechPhone" label="身份证号:">
        <div class="form-width-ms">
          <el-input
            style="padding-left:0px;"
            placeholder="请输入会员身份证号"
            pattern="[0-9]*"
            maxlength="18"
            v-model="refund.manageIdentity"
          ></el-input>
        </div>
      </el-form-item>
      <el-form-item
        v-show="sessionStorageData.allowdebt"
        prop="vipName"
        label="以往欠款:"
        v-if="refund.debtMoney > 0"
      >
        <div class="form-width-ms">
          <span>{{ refund.debtMoney }}</span>
          <el-button
            size="mini"
            type="text"
            @click="openMoney()"
            v-show="refund.debtMoney != 0"
            >去还款</el-button
          >
        </div>
      </el-form-item>
      <br />
      <el-form-item prop="rechNumber" label="充值编码:">
        <div class="form-width-ms" @click="openRec()">
          <div
            style="cursor: pointer;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;"
            :title="refund.rechargeTypeNum"
            v-show="refund.rechargeTypeName != ''"
          >
            <span>{{ refund.rechargeTypeNum }}</span>
          </div>
          <el-button
            v-show="refund.rechargeTypeName == ''"
            :disabled="refund.memberName == ''"
            size="mini"
            type="text"
            >选择</el-button
          >
        </div>
      </el-form-item>
      <el-form-item prop="rechNumber" label="充值账户:">
        <div class="form-width-ms" @click="openRec()">
          <div
            style="cursor: pointer;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;"
            :title="refund.rechargeTypeName"
            v-show="refund.rechargeTypeName != ''"
          >
            <span>{{ refund.rechargeTypeName }}</span>
          </div>
          <el-button
            v-show="refund.rechargeTypeName == ''"
            :disabled="refund.memberName == ''"
            size="mini"
            type="text"
            >选择</el-button
          >
        </div>
      </el-form-item>
      <el-form-item prop="rechDate" label="账户余额:">
        <div class="form-width-ms">
          <span v-if="refund.cardRestMoney" class="text-red text-price">{{
            refund.cardRestMoney
          }}</span>
          <span v-if="refund.giftConsumeMoney" class="text-cyan"> 赠送: </span>
          <span v-if="refund.giftConsumeMoney" class="text-red text-price">{{
            refund.giftConsumeMoney
          }}</span>
        </div>
      </el-form-item>
      <br />
      <el-form-item label="赔偿金额:">
        <div class="form-width-ms">
          <div
            class="form-width-ms"
            v-if="!recCompensationShow"
            @click="openRecCompensation"
          >
            <span class="text-red text-price">{{
              refund.recCompensation
            }}</span>
          </div>
          <el-input
            type="number"
            v-else
            v-focus
            @change="endRecCompensation"
            @blur="endRecCompensation"
            v-model="refund.recCompensation"
          ></el-input>
        </div>
      </el-form-item>
      <el-form-item
        prop="give"
        label="计划退款:"
        v-show="sessionStorageData.refundCard"
      >
        <div class="form-width-ms">{{ refund.refundMoneys }}</div>
      </el-form-item>
      <el-form-item label="实际退款:">
        <div class="form-width-ms">
          <el-input
            type="number"
            v-focus
            @change="endRecRefundMoney"
            @blur="endRecRefundMoney"
            v-model="refund.refundMoney"
          ></el-input>
        </div>
      </el-form-item>
      <el-form-item label="赠送退款:">
        <div class="form-width-ms">
          <el-input
            type="number"
            :disabled="sessionStorageData.refundRechargeType != 1"
            v-focus
            v-model="refund.refundGiftMoney"
          ></el-input>
        </div>
      </el-form-item>
      <br />
      <el-form-item label="帐户操作:">
        <div class="form-width-ms">
          <el-button
            style="display:inline-block;"
            size="mini"
            :disabled="refund.rechargeTypeNum == ''"
            @click="sumRefundMoney"
            v-if="sessionStorageData.refundCard"
            >计算退款</el-button
          >
          <el-button
            style="display:inline-block;"
            size="mini"
            :disabled="refund.rechargeTypeNum == ''"
            @click="recQuery((recDialog = true))"
            >单据</el-button
          >
          <el-button
            style="display:inline-block;"
            size="mini"
            :disabled="refund.rechargeTypeNum == ''"
            @click="(recMonthCashDialog = true), (month = new Date())"
            >消费记录</el-button
          >
        </div>
      </el-form-item>
      <el-form-item label="收款银行:">
        <div class="form-width-ms">
          <div
            class="form-width-ms"
            v-if="refundTypeShow"
            @click="openRefundType"
          >
            {{ refundType }}
          </div>
          <el-input
            v-else
            v-focus
            @change="endRefundType"
            @blur="endRefundType"
            v-model="refundType"
          ></el-input>
        </div>
      </el-form-item>
      <el-form-item label="收款账户:">
        <div class="form-width-ms">
          <div
            class="form-width-ms"
            v-if="refundTypeShow1"
            @click="openRefundAccount"
          >
            {{ refundAccount }}
          </div>
          <el-input
            v-else
            v-focus
            @blur="endRefundAccount"
            @change="endRefundAccount"
            v-model="refundAccount"
          ></el-input>
        </div>
      </el-form-item>
      <br />
      <el-form-item label="收款人:">
        <div class="form-width-ms">
          <el-input v-focus v-model="payee"></el-input>
        </div>
      </el-form-item>
      <el-form-item prop="cause" label="退款备注:">
        <div class="form-width-ms">
          <el-input
            style="width:482px"
            v-model="refundReason"
            ref="refundReasonInput"
            type="textarea"
            placeholder="请填写退款原因"
            maxlength="200"
            :autosize="{ minRows: 1.5, maxRows: 20 }"
            show-word-limit
          >
          </el-input>
        </div> </el-form-item
      ><br />
      <el-form-item prop="cause" label="上传文件:" required>
        <el-upload
          multiple
          :http-request="uploadFile"
          :auto-upload="false"
          style="max-width:800px"
          class="upload-demo"
          name="fileList"
          ref="upload"
          list-type="picture"
          action=""
          :with-credentials="true"
          :file-list="fileList"
          :on-success="onSuccess"
        >
          <el-button slot="trigger" size="mini" type="primary"
            >选取文件</el-button
          >
          <span slot="tip" class="el-upload__tip"
            >上传充值退的附件，大小不超过10M，可以上传多个</span
          >
        </el-upload>
      </el-form-item>
      <div class=" flex justify-start align-start flex-wrap padding-top">
        <staffsles ref="staffsles" @staffslesData="staffslesData"></staffsles>
        <admin ref="admin" @adminData="adminData"></admin>
        <manager ref="manager" @managerData="managerData"></manager>
      </div>
      <div style="max-width:920px" class="text-center padding-top">
        <el-button size="mini" type="info" @click="reset">重 置</el-button>
        <el-button
          size="mini"
          type="primary"
          plain
          @click="openRefundList((refDialogVisible = true), (re_check = false))"
          v-role="5005001"
          >列 表</el-button
        >
        <el-button
          size="mini"
          type="primary"
          @click="submit((loading = true))"
          :loading="loading"
          v-role="5005002"
          >提 交</el-button
        >
      </div>
    </el-form>

    <!-- 充值退列表 -->
    <el-dialog
      :close-on-click-modal="false"
      v-dialogDrag
      title="充值退列表"
      :visible.sync="refDialogVisible"
      width="80vw"
      :close="close"
    >
      <div
        style="display: flex;justify-content: space-between;"
        class="margin-bottom-xs"
      >
        <div>
          <selec
            v-if="headOffice == 1"
            ref="selec"
            @selecData="selecData"
          ></selec>
          <el-button size="mini" type="primary" @click="searchDialog = true"
            >条件搜索</el-button
          >
          <el-button
            size="mini"
            type="success"
            @click="getOrder((refreshtext = true))"
            >刷新</el-button
          >
        </div>
        <div>
          <!-- 状态 0:添加/1:送审/2:回收/3:审核/4:反审核 -->
          <el-button
            type="danger"
            size="mini"
            @click="delOrder()"
            v-if="radiorefValueList.state == 0"
            >删除</el-button
          >
          <el-button
            @click="detail()"
            :disabled="radiorefValueList.state == undefined"
            size="mini"
            type="primary"
            plain
            >明细</el-button
          >
          <el-button
            @click="editOrder((title = '修改'))"
            :disabled="
              radiorefValueList.state == undefined ||
                radiorefValueList.state == 5 ||
                radiorefValueList.state == 1 ||
                radiorefValueList.state == 3
            "
            size="mini"
            type="primary"
            plain
            v-role="5005003"
            >修改</el-button
          >
          <el-button
            @click="SendAudit"
            size="mini"
            type="primary"
            :disabled="
              radiorefValueList.state == 3 ||
                radiorefValueList.state == 5 ||
                radiorefValueList.state == 1 ||
                radiorefValueList.state == undefined
            "
            v-role="5005004"
            >送审</el-button
          >
          <el-button
            @click="recycle"
            size="mini"
            type="primary"
            :disabled="
              radiorefValueList.state == 0 ||
                radiorefValueList.state == 5 ||
                radiorefValueList.state == 2 ||
                radiorefValueList.state == 3 ||
                radiorefValueList.state == 4 ||
                radiorefValueList.state == undefined
            "
            plain
            v-role="5005005"
            >回收</el-button
          >
          <el-button
            v-if="headOffice == 1"
            @click="audit"
            size="mini"
            type="primary"
            :disabled="
              radiorefValueList.state == 2 ||
                radiorefValueList.state == 5 ||
                radiorefValueList.state == 3 ||
                radiorefValueList.state == 0 ||
                radiorefValueList.state == 4 ||
                radiorefValueList.state == undefined
            "
            v-role="5005006"
            >审核</el-button
          >
          <el-button
            v-if="headOffice == 1"
            @click="backAudit"
            size="mini"
            type="primary"
            :disabled="
              radiorefValueList.state == 0 ||
                radiorefValueList.state == 5 ||
                radiorefValueList.state == 1 ||
                radiorefValueList.state == 2 ||
                radiorefValueList.state == 4 ||
                radiorefValueList.state == undefined
            "
            v-role="5005007"
            >反审核</el-button
          >
          <el-button
            v-if="headOffice == 1"
            style="margin-right:20px"
            @click="print((printDialogVisible = true))"
            :disabled="radiorefValueList.state != 3"
            size="mini"
            type="success"
            v-role="5005008"
            >打印
          </el-button>
        </div>
      </div>
      <el-table
        :data="list"
        ref="refLists"
        max-height="600"
        @row-click="clickRow"
        :highlight-current-row="true"
        :header-cell-style="{
          background: 'linear-gradient(#6cb3ff, #1873d4)',
          color: '#eeeeee'
        }"
        :default-sort="{ prop: 'refundDate', order: 'descending' }"
      >
        <el-table-column
          label="选择"
          width="55"
          align="center"
          sortable
          type="index"
        >
          <template slot-scope="scope">
            <el-radio
              v-model="radiorefValue"
              :label="scope.row.id"
              @change.native="scope.row;"
              >{{ null }}</el-radio
            >
          </template>
        </el-table-column>
        <el-table-column
          label="状态"
          width="76"
          align="center"
          sortable
          type="index"
        >
          <template slot-scope="scope">
            <el-tag
              size="medium"
              effect="dark"
              :type="
                scope.row.state == 0
                  ? 'info'
                  : '' || scope.row.state == 1
                  ? 'primary'
                  : '' || scope.row.state == 2
                  ? 'info'
                  : '' || scope.row.state == 3
                  ? 'success'
                  : '' || scope.row.state == 4
                  ? 'warning'
                  : scope.row.state == 5
                  ? 'primary'
                  : ''
              "
            >
              <span v-show="scope.row.state == 0">新创建</span>
              <span v-show="scope.row.state == 1">已送审</span>
              <span v-show="scope.row.state == 2">已回收</span>
              <span v-show="scope.row.state == 3">已审核</span>
              <span v-show="scope.row.state == 4">反审核</span>
              <span v-show="scope.row.state == 5">已作废</span>
              <span v-show="scope.row.state == null">未划分</span>
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          min-width="120"
          prop="refundNum"
          label="退款单号"
        ></el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          min-width="105"
          prop="refundDate"
          label="退款时间"
        ></el-table-column>
        <el-table-column
          align="center"
          min-width="80"
          prop="memberName"
          label="会员"
        ></el-table-column>
        <el-table-column
          align="center"
          min-width="120"
          prop="mobilePhone"
          label="手机号码"
        ></el-table-column>
        <el-table-column
          align="center"
          min-width="80"
          prop="refundMoney"
          label="退款金额"
        ></el-table-column>
        <el-table-column
          align="center"
          min-width="80"
          prop="compensation"
          label="补偿金额"
        ></el-table-column>
        <el-table-column
          align="center"
          min-width="80"
          prop="inputBy"
          label="录单人"
        ></el-table-column>
        <el-table-column
          align="center"
          show-overflow-tooltip
          min-width="100"
          prop="storeName"
          label="门店名称"
        ></el-table-column>
        <el-table-column
          align="center"
          min-width="80"
          prop="auditBy"
          label="审核人"
        ></el-table-column>
        <el-table-column align="center" min-width="80" label="总计退款">
          <template slot-scope="scope">{{
            scope.row.refundMoney + scope.row.compensation
          }}</template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top:15px;">
        <!-- 分页组件 -->
        <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>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      v-dialogDrag
      :title="title"
      :visible.sync="formDialog"
      width="80%"
      :before-close="handleClose"
    >
      <div style="overflow: auto; height: 65vh; width:100%">
        <el-form :model="refund" inline :label-width="formWidth">
          <el-form-item prop="rechPhone" label="手机号码:">
            <label slot="label">手&nbsp;&nbsp;机&nbsp;&nbsp;号</label>
            <div class="form-width-ms">
              <div v-if="title == '明细'">{{ refund.mobilePhone }}</div>
              <el-input
                v-else
                oninput="this.value=this.value.replace(/\D/g,'')"
                pattern="[0-9]*"
                maxlength="11"
                v-model="refund.mobilePhone"
                @change="memberOne"
                @blur="memberOne"
              >
                <el-button
                  size="mini"
                  slot="append"
                  icon="el-icon-search"
                  @click="openMember"
                ></el-button>
              </el-input>
            </div>
          </el-form-item>
          <el-form-item prop="vipName" label="会员名字:">
            <div class="form-width-ms">{{ refund.memberName }}</div>
          </el-form-item>
          <el-form-item prop="vipName" label="身份证号:">
            <div class="form-width-ms">
              <div v-if="title == '明细'">{{ refund.manageIdentity }}</div>
              <el-input
                v-else
                v-model="refund.manageIdentity"
                maxlength="18"
                pattern="[0-9]*"
              ></el-input>
            </div>
          </el-form-item>
          <br />
          <el-form-item prop="rechNumber" label="充值编码:">
            <div class="form-width-ms">
              <div v-if="title == '明细'">{{ refund.rechargeTypeNum }}</div>
              <div v-else @click="openRec()">
                <span v-if="refund.rechargeTypeName">{{
                  refund.rechargeTypeNum
                }}</span>
                <el-button
                  v-else
                  :disabled="refund.memberName == ''"
                  type="text"
                  >选择</el-button
                >
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="rechNumber" label="充值账户:">
            <div class="form-width-ms">
              <div v-if="title == '明细'">{{ refund.rechargeTypeName }}</div>
              <div v-else @click="openRec()">
                <span v-if="refund.rechargeTypeName">{{
                  refund.rechargeTypeName
                }}</span>
                <el-button
                  v-else
                  :disabled="refund.memberName == ''"
                  type="text"
                  >选择</el-button
                >
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="rechDate" label="账户余额:">
            <div class="form-width-ms">{{ refund.cardRestMoney }}</div>
          </el-form-item>
          <br />
          <el-form-item prop="give" label="赠送退款:">
            <div class="form-width-ms">
              <el-input
                type="number"
                :disabled="sessionStorageData.refundRechargeType != 1"
                v-focus
                v-model="refund.refundGiftMoney"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item label="赔偿金额:">
            <div class="form-width-ms">
              <el-input
                type="number"
                v-focus
                @change="endRecCompensation"
                @blur="endRecCompensation"
                v-model="refund.recCompensation"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item
            prop="refundMoneys"
            label="计划退款:"
            v-if="sessionStorageData.refundCard && title == '修改'"
          >
            <div class="form-width-ms">{{ refund.refundMoneys }}</div>
          </el-form-item>
          <el-form-item label="实际退款:">
            <div class="form-width-ms">
              <el-input
                type="number"
                v-focus
                @change="endRecRefundMoney"
                @blur="endRecRefundMoney"
                v-model="refund.refundMoney"
              ></el-input>
            </div>
          </el-form-item>
          <br />
          <el-form-item label="帐户操作:" v-if="title == '修改'">
            <div>
              <el-button
                style="display:inline-block;"
                size="mini"
                @click="sumRefundMoney"
                v-show="sessionStorageData.refundCard"
                >计算退款</el-button
              >
              <el-button
                style="display:inline-block;"
                size="mini"
                @click="recQuery((recDialog = true))"
                >单据</el-button
              >
              <el-button
                style="display:inline-block;"
                size="mini"
                @click="recCashQuery((recCashDialog = true))"
                >消费记录</el-button
              >
            </div>
          </el-form-item>
          <el-form-item label="收款银行:">
            <div class="form-width-ms">
              <div v-if="title == '明细'">{{ refundType }}</div>
              <div v-else>
                <el-input v-model="refundType"></el-input>
              </div>
            </div>
          </el-form-item>
          <el-form-item label="收款账户:">
            <div class="form-width-ms">
              <div v-if="title == '明细'">{{ refundAccount }}</div>
              <div v-else>
                <el-input v-model="refundAccount"></el-input>
              </div>
            </div>
          </el-form-item>
          <br />
          <el-form-item label="收款人:">
            <div class="form-width-ms">
              <el-input v-focus ref="payeeInput" v-model="payee"></el-input>
            </div>
          </el-form-item>
          <el-form-item prop="cause" label="退款备注:">
            <div class="form-width-ms">
              <div v-if="title == '明细'">{{ refundReason }}</div>
              <el-input
                v-else
                style="width:555px"
                v-model="refundReason"
                ref="refundReasonInput"
                type="textarea"
                placeholder="请填写退款原因"
                maxlength="200"
                :autosize="{ minRows: 2, maxRows: 20 }"
                show-word-limit
              ></el-input>
            </div> </el-form-item
          ><br />
          <el-form-item prop="cause" label="附带文件:" required>
            <div
              v-show="title == '明细'"
              v-for="(item, index) in fileList"
              :key="index"
            >
              <div style="width:100px;cursor: pointer; margin:0 5px;">
                <el-image
                  @click="openImg(item, (openImageDialog = true))"
                  :src="item.url"
                >
                  <div slot="error" class="image-slot">
                    <div
                      title="点击下载文件"
                      style="cursor: pointer;width:300px;"
                      @click="directDown(item)"
                    >
                      {{ item.fileName }}
                    </div>
                  </div>
                </el-image>
              </div>
            </div>
            <div v-if="title == '修改'">
              <el-upload
                multiple
                :auto-upload="false"
                :http-request="uploadFile"
                style="width:800px"
                class="upload-demo"
                name="fileList"
                ref="uploads"
                list-type="picture"
                action=""
                :file-list="fileList"
                :on-success="onSuccess"
              >
                <el-button slot="trigger" size="mini" type="primary"
                  >选取文件</el-button
                >
                <span slot="tip" class="el-upload__tip"
                  >上传充值退的附件，大小不超过10M，可以上传多个</span
                >
              </el-upload>
            </div>
          </el-form-item>
          <div
            class="padding-left-lg margin-left-xs flex justify-start align-start flex-wrap padding-top"
          >
            <staffsles
              ref="staffsles"
              @staffslesData="staffslesData"
            ></staffsles>
            <admin ref="admin" @adminData="adminData"></admin>
            <manager ref="manager" @managerData="managerData"></manager>
          </div>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer" v-if="title == '修改'">
        <el-button size="mini" type="primary" plain @click="formDialog = false"
          >取消</el-button
        >
        <el-button size="mini" type="primary" @click="confirmEdit()"
          >确定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      v-dialogDrag
      title="打印"
      :visible.sync="printDialogVisible"
      width="60%"
    >
      <div id="printService" class="printDiv">
        <div
          style="font-size:14px; text-align: center;width:100%;boder-bottom:1px solid #999;margin-bottom:5px;"
        >
          充值退记录单
        </div>
        <hr />
        <el-form :model="printForm" :inline="true">
          <el-form-item label="">
            <div class="span" style="wdith:120px">
              {{ printForm.storeName }}
            </div>
          </el-form-item>
          <el-form-item label="">
            {{ printForm.refundDate }} </el-form-item
          ><br />
          <el-form-item label="单号:">
            {{ printForm.refundNum }} </el-form-item
          ><br />
          <el-form-item label="会员手机号:">
            <div>
              {{ printForm.memberName }}/{{ printForm.mobilePhone }}
            </div> </el-form-item
          ><br />
          <el-form-item label="名称/类别:">
            <div>
              {{ printForm.rechargeTypeName }}
              <span v-if="printForm.type == 0">/ 赠送卡</span>
              <span v-if="printForm.type == 1">/ 折扣卡</span>
            </div>
          </el-form-item>
          <br />
          <el-form-item label="续充金额:">
            <div style="width:40px">{{ printForm.cardRechargeMoney }}</div>
          </el-form-item>
          <el-form-item label="赠送余额:">
            <div style="width:40px">
              {{ printForm.cardGiftMoney }}
            </div> </el-form-item
          ><br />
          <el-form-item label="实退金额:">
            <div>{{ printForm.recRefundMoney }}</div>
          </el-form-item>
          <br />
          <br />
          <el-form-item label="签名:">
            <!-- <div style="height:30px;width:150px;border-bottom:1px solid #333"> </div> --> </el-form-item
          ><br />
          <el-form-item label="服务热线:">
            {{ printForm.telephone }} </el-form-item
          ><br />
          <el-form-item label="打印时间:">
            {{ 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="'#printService'"
          >打 印</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      v-dialogDrag
      title="图片预览"
      :visible.sync="openImageDialog"
    >
      <el-image
        style="height: 60vh;width:100%"
        :src="url"
        :fit="fit"
      ></el-image>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          plain
          @click="openImageDialog = false"
          >取 消</el-button
        >
        <el-button
          size="mini"
          type="primary"
          @click="confirmImage((openImageDialog = false))"
          >下 载</el-button
        >
      </span>
    </el-dialog>
    <el-dialog title="搜索" :visible.sync="searchDialog">
      <el-form :model="searchForm">
        <el-form-item label="单据号搜索:" label-width="120px">
          <div class="searchDiv">
            <el-input
              size="medium"
              v-model="searchForm.refundNum"
              placeholder="输入要查询的单据号"
              clearable
            >
            </el-input>
          </div>
        </el-form-item>
        <el-form-item label="会员名字搜索:" label-width="120px">
          <div class="searchDiv">
            <el-input
              size="medium"
              v-model="searchForm.memberName"
              placeholder="输入要查询的会员名字"
              clearable
            >
            </el-input>
          </div>
        </el-form-item>
        <el-form-item label="手机号搜索:" label-width="120px">
          <div class="searchDiv">
            <el-input
              maxlength="11"
              size="medium"
              v-model="searchForm.mobilePhone"
              placeholder="输入要查询的11位会员手机号"
              oninput="this.value=this.value.replace(/\D/g,'')"
              pattern="[0-9]*"
              clearable
            ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="单据日期搜索:" label-width="120px">
          <div class="block">
            <el-date-picker
              @change="changeDate"
              size="large"
              v-model="date"
              type="daterange"
              :default-time="['00:00:01', '23:59:59']"
              value-format="yyyy-MM-dd HH:mm:ss"
              align="center"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            >
            </el-date-picker>
          </div>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          plain
          @click="searchDialog = false"
          >取 消</el-button
        >
        <el-button
          type="primary"
          size="mini"
          @click="search((searchDialog = false))"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      v-dialogDrag
      title="帐户充值记录"
      :visible.sync="recDialog"
    >
      <el-table :data="recLists" max-height="550" stripe>
        <el-table-column
          prop="docNum"
          label="充值单号"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="date"
          label="充值时间"
          align="center"
          min-width="160"
        ></el-table-column>
        <el-table-column
          prop="projectName"
          label="充值名称"
          align="center"
          min-width="100"
        >
          <template>
            <div>{{ refund.rechargeTypeName }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="docNumType"
          label="类别"
          align="center"
          min-width="100"
        >
          <template slot-scope="scope">
            <div v-show="scope.row.docNumType == 'card_repay'">还款单</div>
            <div v-show="scope.row.docNumType == 'card_recharge'">充值单</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="money"
          label="成交金额"
          align="center"
          min-width="100"
        ></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" plain @click="recDialog = false"
          >关闭</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      v-dialogDrag
      title="帐户充值消费记录"
      :visible.sync="recCashDialog"
    >
      <el-table :data="recCashLists" max-height="550" stripe>
        <el-table-column
          prop="docNum"
          label="交易单号"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="inputDate"
          label="充值时间"
          align="center"
          min-width="160"
        ></el-table-column>
        <el-table-column
          prop="projectName"
          label="充值名称"
          align="center"
          min-width="100"
        >
          <template>
            <div>{{ refund.rechargeTypeName }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="docType"
          label="类别"
          align="center"
          min-width="100"
        >
          <template slot-scope="scope">
            <div v-show="scope.row.docType == 'card_use'">购疗程</div>
            <div v-show="scope.row.docType == 'store_cash'">收银卡付</div>
            <div v-show="scope.row.docType == 'promotion'">促销卡付</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="tradeMoney"
          label="交易金额"
          align="center"
          min-width="100"
        ></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          plain
          @click="recCashDialog = false"
          >关闭</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      v-dialogDrag
      title="选择月份"
      :visible.sync="recMonthCashDialog"
    >
      <span class="demonstration">选择日期( 月 ):</span>
      <br />
      <br />
      <el-date-picker
        style="width:200px"
        v-model="month"
        format="yyyy年 MM月"
        type="month"
        value-format="yyyyMM"
        placeholder="选择日期"
      ></el-date-picker>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          plain
          @click="recMonthCashDialog = false"
          >关闭</el-button
        >
        <el-button size="mini" type="primary" @click="recCashQuery()"
          >确定</el-button
        >
      </span>
    </el-dialog>
    <repayment ref="repayment" @repaymentData="memberOne"></repayment>
    <member ref="member" @memberData="memberData"></member>
    <detail ref="detail" @detailData="detailData"></detail>
    <rec ref="rec" @recTypeData="recData"></rec>
  </div>
</template>

<script>
import repayment from "@/components/repayment/index.vue";
import detail from "./components/detail.vue";
import { partten } from "../../../../partten/index.js";
import {
  storeMemberOne,
  recAccountList,
  recAccountCashList,
  addRefOrder,
  refOrderPage,
  editRefOrder,
  refOrderSendAudit,
  refOrderRevokeAudit,
  repayPage,
  refpage,
  recDocList,
  refOrderRecDocList,
  refOrderUnAudit,
  refOrderAudit,
  refOrderDownload,
  debtPage,
  addrepay,
  refundRechargeMoney,
  listByMember,
  selectOne,
  refundDel
} from "@/api/eashier.js";
import member from "@/components/member/index";
import admin from "@/components/staffList/admin/index";
import manager from "@/components/staffList/manager/index";
import staffsles from "@/components/staffList/staff/index";
import selec from "@/components/store/select/index";
import rec from "@/components/recharge/index";
export default {
  components: {
    staffsles,
    manager,
    admin,
    repayment,
    member,
    detail,
    selec,
    rec
  },
  data() {
    return {
      headOffice: sessionStorage.getItem("headOffice") * 1,
      printDialogVisible: false, //打印弹窗开关
      recMonthCashDialog: false,
      refDialogVisible: false,
      recCashDialog: false,
      recDialog: false,
      re_check: false,
      recRefundMoneyShow: false,
      recCompensationShow: false,
      addStaffDialog: false,
      editStaffDialog: false,
      manageStaffDialog: false,
      openImageDialog: false,
      pageNum: 1, // 当前页码
      pageSize: 10, // 每页的数据条数,
      addAtion: "",
      editAtion: "",
      month: null,
      refundTypeShow: false,
      refundTypeShow1: false,
      refundTypeShow2: false,
      formDialog: false,
      debtMoneyForm: {},
      title: "", //弹窗标题

      radiorefValue: "",
      radiorefValueList: {},
      formData: {},
      fit: "contain",
      url: "",
      urlForm: {},
      refund: {
        mobilePhone: null,
        memberName: "",
        memberId: "",
        rechargeTypeName: "",
        refundMoney: null,
        recCompensation: 0,

        type: 0,
        debtMoney: 0
      },
      sessionStorageData: {}, //门店参数集合
      refundType: "",
      refundAccount: null,
      payee: "",
      refundReason: "",
      fileList: [],
      recLists: [],
      recCashLists: [],
      fileLists: [],
      printForm: {
        date: "",
        recharge: "",
        number: null,
        storeId: "",
        memberName: "",
        mobilePhone: null,
        money: null,
        backMoney: null,
        numMoney: null,
        numMoneys: null,
        telephone: "",
        printDate: new Date()
      },
      formWidth: "120px",
      staffList: [],
      loading: false,
      staffLists: [{ brandNumber: "", staffName: "", ratio: 100 }],
      managerList: [{ brandNumber: "", staffName: "", ratio: 100 }],
      adminList: [{ brandNumber: "", staffName: "", ratio: 100 }],
      editStaffRatioIndex: -1,
      fileData: "",
      vip: {}, //会员信息
      refreshtext: false, //搜索判断字符
      searchDialog: false, //搜索弹窗开关
      searchTrue: false, //搜索判断
      date: [],
      searchForm: {
        //搜索表单
        memberName: "",
        refundNum: "",
        mobilePhone: ""
      },
      openCollNumber: 0,
      queryForm: {
        pageNum: 10,
        pageNum: 1,
        type: 0
      },
      total: 0,
      list: [],
      pickerOptions: {
        //组件限制方法
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      }
    };
  },
  methods: {
    openRec() {
      if(this.refund.memberName == '')return this.$alert("会员ID不能为空 " , "提示", {
        confirmButtonText: "确定",
        confirmButtonClass: "confirmbtnFalses",
        type: "warning",
        center: true,
        callback: (action) => {},
      });
      this.$refs.rec.show(this.refund);
    },
    recData(v) {
      delete v.card;
      delete v.state;
      console.log(v);
      if(this.sessionStorageData.refundRechargeType != 1 && v.giftConsumeMoney){
        this.refund.refundGiftMoney = v.giftConsumeMoney
      }
      v = JSON.parse(JSON.stringify(v).replace(/id/g, "recAccountId"));
      if (this.sessionStorageData.refundCard) {
        v.refundMoneys = 0;
        v.refundMoney = 0;
      } else {
        v.refundMoney = v.cardRestMoney;
      }
      v.recCompensation = 0;
      this.refund = Object.assign(this.refund, v);
    },
    openImg(item) {
      console.log(item);
      this.url = item.url;
      this.urlForm = item;
    },
    selecData(v) {
      this.queryForm.storeList = v;
      this.getOrder();
    },
    detailData() {
      this.getOrder();
    },
    close() {
      this.refDialogVisible = false;
      this.openCollNumber = 0;
    },

    toStaff() {
      this.openCollNumber = 0;
      var that = this;
      setTimeout(() => {
        that.$refs.staffsles.show(that.staffLists);
        that.$refs.manager.show(that.managerList);
        that.$refs.admin.show(that.adminList);
      }, 500);
    },
    toStaffs() {
      let form = { ...this.refund };
      this.refund = JSON.parse(JSON.stringify(form));
      this.openCollNumber = 1;
      var that = this;
      setTimeout(() => {
        that.$refs.staffsles.show(that.refund.staffLists);
        that.$refs.manager.show(that.refund.managerList);
        that.$refs.admin.show(that.refund.adminList);
      }, 500);
    },
    //员工占比返回方法
    staffslesData(v) {
      if (this.openCollNumber == 0) {
        this.staffLists = [...v];
      } else {
        this.refund.staffLists = [...v];
      }
    },
    //高管占比返回方法
    managerData(v) {
      console.log(v);
      if (this.openCollNumber == 0) {
        this.managerList = [...v];
      } else {
        this.refund.managerList = [...v];
      }
    },
    //管理员占比返回方法
    adminData(v) {
      console.log(v);
      console.log(this.openCollNumber);
      if (this.openCollNumber == 0) {
        this.adminList = [...v];
      } else {
        this.refund.adminList = [...v];
        console.log(this.refund);
      }
    },
    recQuery() {
      recDocList({
        recAccountId: this.refund.recAccountId,
        cardRestMoney: this.refund.cardRestMoney,
        cardRechargeMoney: this.refund.cardRechargeMoney
      }).then(res => {
        if (res.code == "000000") {
          this.recLists = res.rows;
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    //查询当前充值帐户的消费记录
    recCashQuery() {
      let page = {
        accountId: this.refund.recAccountId,
        inputDate: this.formatTime(this.month, "YYYY-MM-DD hh:mm:ss"),
        memberId: this.refund.memberId,
        memberName: this.refund.memberName,
        docTypes: ["card_use", "store_cash", "card_use"],
        pageNum: 1,
        pageSize: 100
      };
      listByMember(page).then(res => {
        if (res.code == "000000") {
          this.recCashLists = res.pageInfo.list;
          setTimeout(() => {
            this.recMonthCashDialog = false;
          }, 100);
          this.recCashDialog = true;
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },

    sumRefundMoney() {
      var that = this;
      let page = {
        recAccountId: that.refund.recAccountId,
        cardRestMoney: that.refund.cardRestMoney,
        cardRechargeMoney: that.refund.cardRechargeMoney,
        docTypes: ["store_cash"],
        type: that.refund.type
      };

      that.refund.docTypes = ["store_cash"];
      refundRechargeMoney(that.refund).then(res => {
        if (res.code == "000000") {
          that.refund.refundMoneys = res.data;
          that.refund.refundMoney = res.data;
          that.$message.success({
            message: "计算成功 , 计划退款 ¥" + res.data
          });
          console.log(JSON.parse(JSON.stringify(this.refund)));
          let form = { ...this.refund };
          this.refund = {};
          this.refund = form;
        } else {
          that.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    //时间改变方法
    changeDate() {
      this.searchForm.startTime = this.date[0];
      this.searchForm.endTime = this.date[1];
    },
    //搜索方法
    search() {
      //条件搜索
      this.searchForm = Object.assign(this.searchForm, this.queryForm);
      refOrderPage(this.searchForm).then(res => {
        if (res.code == "000000") {
          this.list = res.pageInfo.list;
          this.total = res.pageInfo.total;
          this.refreshtext = true;
          if (res.pageInfo.total == 0) {
            this.$message({
              message: "没有找到符合条件的单据"
            });
          }
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    openMoney() {
      this.$refs.repayment.show(this.vip);
    },
    //关闭弹窗前的回调方法
    handleClose() {
      this.formDialog = false;
      this.refund = {
        manageStaffName: "",
        rechargeTypeName: "",
        recCompensation: 0,
        refundMoney: 0
      };
      this.refundType = "";
      this.refundAccount = "";
      this.payee = "";
      this.refundReason = "";
      this.loading = false;
      this.fileList = [];
      this.recLists = [];
      this.staffLists = [{ brandNumber: "", staffName: "", ratio: 100 }];
      this.managerList = [{ brandNumber: "", staffName: "", ratio: 100 }];
      this.adminList = [{ brandNumber: "", staffName: "", ratio: 100 }];
    },
    //重置清空
    reset() {
      Object.assign(this.$data, this.$options.data.call(this));
      this.setPage();
    },

    //提交信息
    submit() {
      let staffLists = [];
      this.staffLists.forEach(item => {
        let items = {
          id: item.id,
          staffName: item.staffName,
          brandNumber: item.brandNumber,
          identityCard: item.identityCard,
          ratio: item.ratio
        };

        staffLists.push(items);
      });
      let salesmens = [];
      this.managerList.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.refund.salesmens = salesmens;
      this.fileData = new FormData();
      this.$refs.upload.submit();
      delete this.refund.debtMoney;
      delete this.refund.lastConsumeTime;
      this.refund.staffLists = staffLists;
      this.refund.recRefundMoney = this.refund.refundMoney;
      this.fileData.append("type", 0);
      this.fileData.append("memberId", this.refund.memberId);
      this.fileData.append("memberName", this.refund.memberName);
      this.fileData.append("mobilePhone", this.refund.mobilePhone);
      this.fileData.append("compensation ", this.refund.recCompensation);
      this.fileData.append("refundMoney", this.refund.refundMoney);
      this.fileData.append("refundGiftMoney", this.refund.refundGiftMoney);
      this.fileData.append("refundType", this.refundType);
      this.fileData.append("refundAccount", this.refundAccount);
      this.fileData.append("payee", this.payee);
      this.fileData.append("refundReason", this.refundReason);
      this.fileData.append("rechargeRequest", JSON.stringify(this.refund));
      addRefOrder(this.fileData).then(res => {
        this.loading = false;
        if (res.code == "000000") {
          this.$message.success({
            message: res.message
          });
          this.reset();
        } else {
          this.loading = false;
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
          // this.reset();
        }
      });
    },
    //上传附件
    onSuccess(esponse, file, fileList) {
      if (esponse.code == "000000") {
        this.$message.success({
          message: esponse.message
        });
        this.refund = {};
      } else {
        this.$message.error({
          message: esponse.message
        });
      }
    },
    //打开选择会员弹窗
    openMember() {
      this.$refs.member.show(this.vip);
    },
    //选中会员返回方法
    memberData(v) {
      this.refund.mobilePhone = v.mobilePhone;
      this.memberOne();
    },
    //查询会员信息
    memberOne() {
      let mobilePhone = this.refund.mobilePhone;
      Object.assign(this.$data, this.$options.data.call(this));
      if (partten.phoneNum.test(mobilePhone)) {
        storeMemberOne({
          mobilePhone: mobilePhone
        }).then(res => {
          this.refund.mobilePhone = mobilePhone;
          if (res.code == "000000") {
            this.vip = res.data;
            this.refund.memberName = res.data.memberName;
            this.refund.memberId = res.data.id;
            this.refund.debtMoney = res.data.debtMoney;
            debtPage({
              memberId: res.data.id,
              storeId: res.data.storeId,
              state: 0,
              pageSize: 100,
              pageNum: 1
            }).then(res => {
              if (res.code == "000000") {
                this.debtMoneyForm.debtMoneyList = res.pageInfo.list;
              }
            });
          } else {
            this.reset();
            this.$alert(res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: action => {}
            });
          }
        });
      } else {
        this.$message.info({
          message: "请输入正确的手机号"
        });
      }
    },

    endRecRefundMoney() {
      if ((this.recRefundMoneyShow = true)) {
        if (this.refund.refundMoney > this.refund.cardRestMoney) {
          this.$message.error({
            message: "退款金额不能大于账户余额"
          });
        } else {
          this.recRefundMoneyShow = false;
        }
      } else {
        this.recCompensationShow = true;
      }
    },
    openRecCompensation() {
      this.recCompensationShow = true;
    },
    endRecCompensation() {
      this.recCompensationShow = false;
    },
    //修改收款银行/人/账户
    openRefundType() {
      this.refundTypeShow = false;
      this.$nextTick(() => {
        this.$refs.refundTypeInput.focus();
        this.$refs.refundTypeInput.select();
      });
    },
    endRefundType() {
      if ((this.refundTypeShow = false)) {
        this.refundTypeShow = true;
      }
    },
    openRefundAccount() {
      this.$nextTick(() => {
        this.$refs.refundAccountInput.focus();
        this.$refs.refundAccountInput.select();
        this.refundTypeShow1 = false;
      });
    },
    endRefundAccount() {
      if ((this.refundTypeShow1 = false)) {
        this.refundTypeShow1 = true;
      }
    },
    openPayee() {
      this.refundTypeShow2 = false;
      this.$nextTick(() => {
        this.$refs.payeeInput.focus();
        this.$refs.payeeInput.select();
      });
    },
    endPayee() {
      this.refundTypeShow2 = true;
      this.$nextTick(() => {
        this.$refs.refundReasonInput.focus();
        this.$refs.refundReasonInput.select();
      });
    },

    clickRow(row) {
      this.radiorefValue = row.id;
      this.radiorefValueList = row;
    },
    openRefundList() {
      this.radiorefValue = "";
      this.radiorefValueList = {};
      this.getOrder();
      if (this.headOffice == 1) {
        this.$nextTick(() => {
          this.$refs.selec.show();
        });
      }
    },
    getOrder() {
      refOrderPage(this.queryForm).then(res => {
        if (res.code == "000000") {
          this.list = res.pageInfo.list;
          this.total = res.pageInfo.total;
          if (this.refreshtext == true) {
            this.$message.success({
              message: "已刷新最新数据"
            });
            this.refreshtext = false;
            this.searchTrue = false;
          }
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    //明细方法
    detail() {
      this.$refs.detail.show(this.radiorefValueList, "明细");
    },

    confirmImage() {
      let url = {
        fileName: this.urlForm.fileName,
        filePath: this.urlForm.filePath
      };
      refOrderDownload(url).then(res => {
        //console.log(res);
        let blob = new Blob([res]);
        var a = document.createElement("a");
        var url = window.URL.createObjectURL(blob);
        a.href = url;
        a.download = this.urlForm.fileName;
        a.click();
        window.URL.revokeObjectURL(url);
      });
    },
    directDown(item) {
      let url = {
        fileName: item.fileName,
        filePath: item.filePath
      };
      refOrderDownload(url).then(res => {
        //console.log(res);
        let blob = new Blob([res]);
        var a = document.createElement("a");
        var url = window.URL.createObjectURL(blob);
        a.href = url;
        a.download = item.fileName;
        a.click();
        window.URL.revokeObjectURL(url);
      });
    },
    delOrder() {
      refundDel({ id: this.radiorefValueList.id }).then(res => {
        if (res.code == "000000") {
          this.$message.success({
            message: res.message
          });
          this.getOrder();
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    //修改
    editOrder() {
      refpage({
        refundNum: this.radiorefValueList.refundNum,
        refundOrderId: this.radiorefValueList.id,
        storeId: this.radiorefValueList.storeId
      }).then(res => {
        if (res.code == "000000") {
          this.formDialog = true;
          if (res.pageInfo.total == 0) {
            this.$alert("未找到相关明细", "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: action => {}
            });
          } else {
            this.refund = res.pageInfo.list[0];
            this.refund.refundMoneys = this.refund.recRefundMoney;
            this.refund.refundMoney = this.refund.recRefundMoney;
            this.refundType = this.radiorefValueList.refundType;
            this.refundAccount = this.radiorefValueList.refundAccount;
            this.payee = this.radiorefValueList.payee;
            this.refundReason = this.radiorefValueList.refundReason;
            let staffLists = [];
            res.pageInfo.list[0].entities.forEach(item => {
              let items = {
                ratio: item.saleRatio,
                staffNames: item.brandNumber + "--" + item.saleStaffName,
                id: item.saleStaffId,
                staffName: item.saleStaffName,
                brandNumber: item.brandNumber,
                identityCard: item.saleIdentityCard
              };
              staffLists.push(items);
            });
            this.refund.staffLists = staffLists;
            this.fileList = res.pageInfo.list[0].fileLists;
            this.fileList.forEach(item => {
              item.url = partten.https + item.filePath + "/" + item.fileName;
            });
            selectOne({
              type: 4,
              orderNum: this.refund.refundNum,
              storeId: this.radiorefValueList.storeId
            }).then(res => {
              if (res.code == "000000") {
                let managerList = [];
                let adminList = [];
                res.rows.forEach(item => {
                  if (item.staffType == 0) {
                    item.staffNames = item.brandNumber + "--" + item.staffName;
                    managerList.push(item);
                  }
                  if (item.staffType == 1) {
                    item.staffNames = item.brandNumber + "--" + item.staffName;
                    adminList.push(item);
                  }
                });
                if (managerList.length == 0) {
                  managerList.push({ ratio: 100 });
                }
                if (adminList.length == 0) {
                  adminList.push({ ratio: 100 });
                }
                if (this.refund.staffLists.length == 0) {
                  this.refund.staffLists.push({ ratio: 100 });
                }
                this.refund.managerList = managerList;
                this.refund.adminList = adminList;
                this.toStaffs();
              } else {
                this.$alert(res.message, "加载门店高管", {
                  confirmButtonText: "确定",
                  confirmButtonClass: "confirmbtnFalses",
                  type: "warning",
                  center: true,
                  callback: action => {}
                });
              }
            });
            this.fileList = [];
          }
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    //自定义文件上传拦截方法
    uploadFile(file) {
      this.fileData.append("fileList", file.file);
    },
    confirmEdit() {
      this.fileData = new FormData();
      let staffLists = [];
      this.refund.staffLists.forEach(item => {
        let items = {
          id: item.id,
          staffName: item.staffName,
          brandNumber: item.brandNumber,
          identityCard: item.identityCard,
          ratio: item.ratio
        };
        staffLists.push(items);
      });
      this.refund.recRefundMoney = this.refund.refundMoney;
      if (this.$refs.uploads) {
        this.$refs.uploads.submit();
      }
      let salesmens = [];
      this.refund.managerList.forEach(item => {
        if (item.id) {
          item.staffType = 0;
          salesmens.push(item);
        }
      });
      this.refund.adminList.forEach(item => {
        if (item.id) {
          item.staffType = 1;
          salesmens.push(item);
        }
      });
      this.refund.salesmens = salesmens;
      this.refund.staffLists = staffLists;
      delete this.refund.debtMoney;
      delete this.refund.lastConsumeTime;
      delete this.refund.entities;
      this.fileData.append("type", 0);
      this.fileData.append("refundNum", this.refund.refundNum);
      this.fileData.append("memberId", this.refund.memberId);
      this.fileData.append("memberName", this.refund.memberName);
      this.fileData.append("mobilePhone", this.refund.mobilePhone);
      this.fileData.append("refundMoney", this.refund.refundMoney);
      this.fileData.append("refundGiftMoney", this.refund.refundGiftMoney);
      this.fileData.append("compensation", this.refund.recCompensation);
      // this.fileData.append("recRefundMoney ", (this.refund.recCompensation+this.refund.refundMoney).toFixed(2)*1);
      this.fileData.append("refundType", this.refundType);
      this.fileData.append("refundAccount", this.refundAccount);
      this.fileData.append("payee", this.payee);
      this.fileData.append("refundReason", this.refundReason);
      this.fileData.append("rechargeRequest", JSON.stringify(this.refund));
      this.fileData.append("id", this.radiorefValueList.id);
      editRefOrder(this.fileData).then(res => {
        if (res.code == "000000") {
          this.formDialog = false;
          this.$message.success({
            message: res.message
          });
          this.getOrder();
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    //送审
    SendAudit() {
      if (this.radiorefValue == "") {
        this.$message.info({
          message: "请先选择一行数据，再进行操作！"
        });
      } else {
        // this.$confirm("确认把该单据送审吗？", "提示", {
        //   confirmButtonText: "确定",
        //   cancelButtonText: "取消",
        //   type: "warning",
        //   cancelButtonClass: "cancelbtnFalses",
        //   confirmButtonClass: "confirmbtnFalses"
        // })
        //   .then(() => {})
        //   .catch(() => {});
        refOrderSendAudit({
          id: this.radiorefValueList.id
        }).then(res => {
          if (res.code == "000000") {
            this.$message.success({
              message: res.message
            });
            this.getOrder();
            this.radiorefValueList.state = 1;
          } else {
            this.$alert(res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: action => {}
            });
          }
        });
      }
    },
    //回收
    recycle() {
      if (this.radiorefValue == "") {
        this.$message.info({
          message: "请先选择一行数据，再进行操作！"
        });
      } else {
        // this.$confirm("确认把该单据回收吗？", "提示", {
        //   confirmButtonText: "确定",
        //   cancelButtonText: "取消",
        //   type: "warning",
        //   cancelButtonClass: "cancelbtnFalses",
        //   confirmButtonClass: "confirmbtnFalses"
        // })
        //   .then(() => {})
        //   .catch(() => {});
        refOrderRevokeAudit({
          id: this.radiorefValueList.id
        }).then(res => {
          if (res.code == "000000") {
            this.$message.success({
              message: res.message
            });
            this.getOrder();
            this.radiorefValueList.state = 2;
          } else {
            this.$alert(res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: action => {}
            });
          }
        });
      }
    },
    //审核
    audit() {
      if (this.radiorefValue == "") {
        this.$message.info({
          message: "请先选择一行数据，再进行操作！"
        });
      } else {
        this.$confirm("确认单据通过审核吗？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          cancelButtonClass: "cancelbtnFalses",
          confirmButtonClass: "confirmbtnFalses"
        })
          .then(() => {
            //console.log(123);
            refOrderAudit({
              id: this.radiorefValueList.id
            }).then(res => {
              if (res.code == "000000") {
                this.$message.success({
                  message: res.message
                });
                this.getOrder();
                this.radiorefValueList.state = 3;
              } else {
                this.$alert(res.message, "提示", {
                  confirmButtonText: "确定",
                  confirmButtonClass: "confirmbtnFalses",
                  type: "warning",
                  center: true,
                  callback: action => {}
                });
              }
            });
          })
          .catch(() => {});
      }
    },
    //反审核
    backAudit() {
      if (this.radiorefValue == "") {
        this.$message.info({
          message: "请先选择一行数据，再进行操作！"
        });
      } else {
        this.$confirm("确认要反审核吗？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          cancelButtonClass: "cancelbtnFalses",
          confirmButtonClass: "confirmbtnFalses"
        })
          .then(() => {
            refOrderUnAudit({
              id: this.radiorefValueList.id
            }).then(res => {
              if (res.code == "000000") {
                this.$message.success({
                  message: res.message
                });
                this.getOrder();
                this.radiorefValueList.state = 4;
              } else {
                this.$alert(res.message, "提示", {
                  confirmButtonText: "确定",
                  confirmButtonClass: "confirmbtnFalses",
                  type: "warning",
                  center: true,
                  callback: action => {}
                });
              }
            });
          })
          .catch(() => {});
      }
    },
    print() {
      refpage({
        refundNum: this.radiorefValueList.refundNum,
        storeId: this.radiorefValueList.storeId
      }).then(res => {
        //console.log(res);
        if (res.code == "000000") {
          this.printForm = res.pageInfo.list[0];
          this.printForm.printDate = new Date();
          this.printForm.telephone = JSON.parse(
            sessionStorage.getItem("storeInfo")
          ).telephone;
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: action => {}
          });
        }
      });
    },
    //分页方法
    handleSizeChange(val) {
      //   //console.log(`每页 ${val} 条`);
      this.queryForm.pageSize = val;
      if (this.searchTrue == true) {
        this.search();
      } else {
        this.getOrder();
      }
    },
    handleCurrentChange(val) {
      //   //console.log(`当前页: ${val}`);
      this.queryForm.pageNum = val;
      if (this.searchTrue == true) {
        this.search();
      } else {
        this.getOrder();
      }
    },
    setPage() {
      Object.assign(this.$data, this.$options.data.call(this));
      this.toStaff();
      this.sessionStorageData = JSON.parse(
        sessionStorage.getItem("sessionStorageData")
      );
      console.log('sessionStorageData',this.sessionStorageData)
    }
  },
  created() {
    this.setPage();
  },
  watch: {
    refDialogVisible(val, oldVal) {
      if (val == false && oldVal == true) {
        this.reset();
      }
    }
  }
};
</script>

<style>
.rech {
  min-height: 200px;
  background: white;
  margin: 0 auto;
  padding: 10px;
  padding-bottom: 80px;
}

/* .rech .el-form-item__content div {
  display: inline-block;
} */

.refunFoot {
  min-width: 350px;
  width: 350px;
  min-height: 200px;
  padding-right: 20px;
  border-right: 1px solid #dddddd;
}

.refunFoot1 {
  padding-top: 5px;
  margin-left: 100px;
  text-align: center;
}

.refunFoot1 .el-button {
  margin-bottom: 20px;
}

.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 3px 0 0;
}

.printDiv {
  width: 230px;
  margin: 0 auto;
}

.upload-demo ul {
  width: 350px;
}

.rech .el-table .cell {
  overflow: visible;
}
</style>
