<template>
  <div class="rech padding-top-xs padding-left-xs">
    <el-form :model="refund" :inline="true" :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" v-if="debtMoneys!=0" prop="vipName" label="以往欠款:">
        <div class="form-width-ms">
          <span>{{debtMoneys}}</span>
          <el-button size="mini" type="text" @click="openMoney()" v-show="debtMoneys!=0">去还款</el-button>
        </div>
      </el-form-item>
      <br />
      <el-form-item prop="courseProjectNum" label="疗程编码:">
        <div class="form-width-ms">
          <div :title="refund.courseProjectNum" style="cursor: pointer;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" v-show="refund.courseProjectName!=''" @click="openAccountDialog=true">
            <span>{{refund.courseProjectNum}}</span>
          </div>
          <el-button v-show="refund.courseProjectName==''" :disabled="refund.memberName==''" size="mini" type="text" @click="openAccountDialog=true">选择</el-button>
        </div>
      </el-form-item>
      <el-form-item prop="courseProjectName" label="疗程账户:">
        <div class="form-width-ms">
          <div :title="refund.courseProjectName" style="cursor: pointer;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" v-show="refund.courseProjectName!=''" @click="openAccountDialog=true">
            <span>{{refund.courseProjectName}}</span>
          </div>
          <el-button v-show="refund.courseProjectName==''" :disabled="refund.memberName==''" size="mini" type="text" @click="openAccountDialog=true">选择</el-button>
        </div>
      </el-form-item>
      <el-form-item prop="paid" label="购买来源:">
        <div class="form-width-ms">
          <span v-if="refund.courseType=='0'">直接购买</span>
          <span v-else>促销购买</span>
        </div>
      </el-form-item>
      <br>
      <el-form-item prop="courseCount" label="购买次数:">
        <div class="form-width-ms">{{refund.courseCount}}</div>
      </el-form-item>
      <el-form-item prop="courseProjectMoney" label="成交金额:">
        <div class="form-width-ms">{{refund.courseProjectMoney}}</div>
      </el-form-item>
      <el-form-item prop="courseConsumeCount" label="可退次数:">
        <div class="form-width-ms">{{refund.courseConsumeCount}}</div>
      </el-form-item>
      <br />
      <el-form-item prop="courseCompensation" label="补偿金额:">
        <div class="form-width-ms">
          <el-input oninput="this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,2})\d*/,'$1$2$3')" pattern="[0-9]*\.?[0-9]{0,2}" v-model="refund.courseCompensation"></el-input>
        </div>
      </el-form-item>
      <el-form-item prop="refundNumber" label="退款次数:">
        <div class="form-width-ms">
          <el-input type="number" @change="endNum" @blur="endNum" pattern="[0-9]*" v-model="refund.refundNumber"></el-input>
        </div>
      </el-form-item>
      <!-- <el-form-item prop="paid"  label="扣除赠品:">
        <div class="form-width-ms">
          <div style="min-width:80px;cursor: pointer;height:30px" v-show="!giftMoneyShow" @click="openGiftMoneyShow"> {{giftMoney}}</div>
          <el-input oninput="this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,2})\d*/,'$1$2$3')" pattern="[0-9]*\.?[0-9]{0,2}" v-show="giftMoneyShow" ref="giftMoneyInput"  @change="giftMoneyShow=false"
            @blur="giftMoneyShow=false" v-model="giftMoney"></el-input>
        </div>
      </el-form-item> -->
      <el-form-item prop="summation" label="退款金额:">
        <div class="form-width-ms">
          <el-input oninput="this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,2})\d*/,'$1$2$3')" pattern="[0-9]*\.?[0-9]{0,2}" @change="endRefundMoney" @blur="endRefundMoney" v-model="refund.courseRefundMoney"></el-input>
        </div>
      </el-form-item>
      <br />
      <el-form-item label="收款银行:">
        <div class="form-width-ms">
          <div style="min-width:80px;cursor: pointer;height:30px" v-show="refundTypeShow" @click="openRefundType">{{refundType}}</div>
          <el-input v-show="!refundTypeShow" ref="refundTypeInput" @change="endRefundType" @blur="endRefundType" v-model="refundType"></el-input>
        </div>
      </el-form-item>
      <el-form-item label="收款账户:">
        <div class="form-width-ms">
          <div style="min-width:80px;cursor: pointer;height:30px" v-show="refundTypeShow1" @click="endRefundType">{{refundAccount}}</div>
          <el-input v-show="!refundTypeShow1" ref="refundAccountInput" @blur="endRefundAccount" @change="endRefundAccount" v-model="refundAccount"></el-input>
        </div>
      </el-form-item>
      <el-form-item label="收款人:">
        <div class="form-width-ms">
          <div style="min-width:80px;cursor: pointer;height:30px" v-show="refundTypeShow2" @click="endRefundAccount">{{payee}}</div>
          <el-input v-show="!refundTypeShow2" ref="payeeInput" @change="endPayee " @blur="endPayee" v-model="payee"></el-input>
        </div>
      </el-form-item>
      <br />
      <el-form-item prop="cause" label="退款备注:">
        <div>
          <el-input style="width:790px" 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" style="width:765px" class="upload-demo" :file-list="fileList" name="fileList" ref="upload" list-type="picture" action="" :with-credentials="true" :auto-upload="false">
          <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)" v-role='5006001'>列 表</el-button>
        <el-button size="mini" type="primary" @click="submit(loading=true)" :loading="loading" v-role='5006002'>提 交</el-button>
      </div>
    </el-form>
    <div class="dialogDiv">
      <!-- 选择账户 -->
      <el-dialog :close-on-click-modal="false" v-dialogDrag title="账户" :visible.sync="openAccountDialog" width="60%">
        <el-table :data="courseList" @row-click="radioRowCourse" max-height="550" @row-dblclick="confirCourse(openAccountDialog = false)">
          <el-table-column label="选择" width="50">
            <template slot-scope="scope">
              <el-radio v-model="radioValue" :label="scope.row.id" @change.native="(scope.row)">
              </el-radio>
            </template>
          </el-table-column>
          <el-table-column align="center" min-width="80" show-overflow-tooltip prop="courseProjectNum" label="项目编码"></el-table-column>
          <el-table-column align="center" prop="courseProjectName" show-overflow-tooltip min-width="120" label="账户名称">
          </el-table-column>
          <el-table-column align="center" prop="courseType" min-width="70" label="购买来源">
            <template slot-scope="scope">
              <div v-show="scope.row.courseType == '0'">直接购买</div>
              <div v-show="scope.row.courseType == '1'">活动促销</div>
              <div v-show="scope.row.courseType == '2'">促销赠送</div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="price" min-width="70" label="单价"></el-table-column>
          <el-table-column align="center" prop="courseRestPrice" min-width="70" label="剩余金额"></el-table-column>
          <el-table-column align="center" prop="courseRestCount" min-width="70" label="剩余次数"></el-table-column>
          <el-table-column align="center" prop="courseConsumePrice" min-width="70" label="可用金额"></el-table-column>
          <el-table-column align="center" prop="courseConsumeCount" min-width="70" label="可用次数"></el-table-column>
          <el-table-column align="center" prop="courseProjectMoney" min-width="70" label="成交金额"></el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" type="primary" plain @click="openAccountDialog = false">取 消</el-button>
          <el-button size="mini" type="primary" @click="confirCourse(openAccountDialog = false)">确 定
          </el-button>
        </span>
      </el-dialog>

      <!-- 疗程退列表 -->
      <el-dialog :close-on-click-modal="false" v-dialogDrag title="疗程退列表" :visible.sync="refDialogVisible" width="80%" :close="close">
        <div>
          <div style="display: flex;justify-content: space-between;margin-bottom:10px">
            <div>
              <el-button size="mini" type="primary" @click="(searchDialog=true)">条件搜索</el-button>
              <el-button size="mini" type="info" @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(formDialog=true,title='修改')" :disabled="radiorefValueList.state==undefined||radiorefValueList.state==1 || radiorefValueList.state==3 " size="mini" type="primary" plain v-role='5006003'>修改
              </el-button>
              <el-button @click="SendAudit" size="mini" type="primary" :disabled="radiorefValueList.state==3 ||radiorefValueList.state==1 ||radiorefValueList.state==undefined" v-role='5006004'>送审</el-button>
              <el-button @click="recycle" size="mini" type="primary" :disabled="radiorefValueList.state==0||radiorefValueList.state==2||radiorefValueList.state==3||radiorefValueList.state==4||radiorefValueList.state==undefined" plain v-role='5006005'>回收</el-button>
              <el-button v-if="headOffice==1" @click="audit" size="mini" type="primary" :disabled="radiorefValueList.state==2||radiorefValueList.state==3 || radiorefValueList.state==0|| radiorefValueList.state==4||radiorefValueList.state==undefined" v-role='5006006'>审核</el-button>
              <el-button v-if="headOffice==1" @click="backAudit" size="mini" type="primary" :disabled="radiorefValueList.state==0|| radiorefValueList.state==1||radiorefValueList.state==2|| radiorefValueList.state==4||radiorefValueList.state==undefined" v-role='5006007'>反审核</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='5006008'>打印
              </el-button>
            </div>
          </div>
          <el-table :data="pageInfo.refLists" ref="refLists" @row-click="clickRow" :highlight-current-row="true" max-height="550">
            <el-table-column label="状态" width="128" align="center" type="index">
              <template slot-scope="scope">
                <el-radio v-model="radiorefValue" :label="scope.row.id" @change.native="(scope.row)">
                </el-radio>
                <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':''">
                  <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==null">未划分</span>
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column align="center" show-overflow-tooltip min-width="100" prop="refundNum" label="退款单号"></el-table-column>
            <el-table-column align="center" show-overflow-tooltip min-width="105" prop="refundDate" sortable 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="100" 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="100" 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="pageNum" :page-sizes="[10,20,30,40,50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total"></el-pagination>
          </div>
        </div>
      </el-dialog>
      <el-dialog :close-on-click-modal="false" v-dialogDrag :title="title" :visible.sync="formDialog" width="80%" :before-close="handleClose">
        <div class="max-height-60">
          <el-form :model="refund" :inline="true" :label-width="formWidth">
            <el-form-item prop="rechPhone" label="手机号码:">
              <label slot="label">手&nbsp;&nbsp;机&nbsp;&nbsp;号</label>
              <div class="form-width-ms">
                <el-input size="mini" oninput="this.value=this.value.replace(/\D/g,'')" pattern="[0-9]*" v-model="refund.mobilePhone" maxlength="11" @blur="memberOne">
                </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>
            <br />
            <el-form-item prop="courseProjectNum" label="疗程编码:">
              <div class="form-width-ms">
                <div v-if="title=='明细'">
                  <span>{{refund.courseProjectNum}}</span>
                </div>
                <div v-else>
                  <span v-show="refund.courseProjectName!=''" @click="openAccountDialog=true">{{refund.courseProjectNum}}</span>
                  <el-button v-show="refund.courseProjectName==''" :disabled="refund.memberName==''" size="mini" type="text" @click="openAccountDialog=true">选择</el-button>
                </div>
              </div>
            </el-form-item>
            <el-form-item prop="courseProjectName" label="疗程账户:">
              <div class="form-width-ms">
                <div v-if="title=='明细'">
                  <span>{{refund.courseProjectName}}</span>
                </div>
                <div v-else>
                  <span v-show="refund.courseProjectName!=''" @click="openAccountDialog=true">{{refund.courseProjectName}}</span>
                  <el-button v-show="refund.courseProjectName==''" :disabled="refund.memberName==''" size="mini" type="text" @click="openAccountDialog=true">选择</el-button>
                </div>
              </div>
            </el-form-item>

            <el-form-item prop="paid" label="购买来源:">
              <div class="form-width-ms">
                <span v-if="refund.courseType=='0'">直接购买</span>
                <span v-else>促销购买</span>
              </div>
            </el-form-item>
            <br>
            <el-form-item prop="paid" label="购买次数:">
              <div class="form-width-ms">{{refund.courseCount}}</div>
            </el-form-item>
            <el-form-item prop="paid" label="成交金额:">
              <div class="form-width-ms">{{refund.courseProjectMoney}}</div>
            </el-form-item>
            <el-form-item prop="paid" label="可退次数:">
              <div class="form-width-ms">{{refund.courseConsumeCount}}</div>
            </el-form-item>
            <br>
            <el-form-item prop="paid" label="补偿金额:">
              <div class="form-width-ms">
                <div v-if="title=='明细'">
                  <span>{{refund.courseCompensation}}</span>
                </div>
                <div v-else>
                  <el-input oninput="this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,2})\d*/,'$1$2$3')" pattern="[0-9]*\.?[0-9]{0,2}" v-model="refund.courseCompensation">
                  </el-input>
                </div>
              </div>
            </el-form-item>

            <el-form-item prop="summation" label="退款金额:">
              <div class="form-width-ms">
                <div v-if="title=='明细'">
                  <span>{{refund.courseRefundMoney}}</span>
                </div>
                <div v-else>
                  <div style="min-width:80px;cursor: pointer;height:30px" v-show="courseRefundMoneyShow" @click="opencourseRefundMoneyShow">
                    {{refund.courseRefundMoney}}
                  </div>
                  <el-input oninput="this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,2})\d*/,'$1$2$3')" pattern="[0-9]*\.?[0-9]{0,2}" v-show="!courseRefundMoneyShow" ref="courseRefundMoneyInput" @change="courseRefundMoneyShow=false" @blur="courseRefundMoneyShow=false" v-model="refund.courseRefundMoney">
                  </el-input>
                </div>
              </div>
            </el-form-item>
            <br>

            <el-form-item label="收款银行:">
              <div class="form-width-ms">
                <div v-if="title=='明细'">{{refundType}}</div>
                <div v-else>
                  <div style="min-width:80px;cursor: pointer;height:30px" v-show="refundTypeShow" @click="openRefundType">{{refundType}}</div>
                  <el-input v-show="!refundTypeShow" ref="refundTypeInput" @change="endRefundType" @blur="endRefundType" 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>
                  <div style="min-width:80px;cursor: pointer;height:30px" v-show="refundTypeShow1" @click="endRefundType">{{refundAccount}}</div>
                  <el-input v-show="!refundTypeShow1" ref="refundAccountInput" @blur="endRefundAccount" @change="endRefundAccount" v-model="refundAccount">
                  </el-input>
                </div>
              </div>
            </el-form-item>
            <el-form-item label="收款人:">
              <div class="form-width-ms">
                <div v-if="title=='明细'">{{payee}}</div>
                <div v-else>
                  <div style="min-width:80px;cursor: pointer;height:30px" v-show="refundTypeShow2" @click="endRefundAccount">{{payee}}</div>
                  <el-input v-show="!refundTypeShow2" ref="payeeInput" @change="endPayee " @blur="endPayee" v-model="payee"></el-input>
                </div>
              </div>
            </el-form-item>
            <br>
            <el-form-item prop="cause" label="退款备注:">
              <div class="form-width-ms">
                <div v-if="title=='明细'">{{refundReason}}</div>
                <el-input v-else style="width:800px" 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>
              <div v-if="title=='明细'" v-for="(item,index) in  filesList" :key="index">
                <div style="width:100px;cursor: pointer; margin:0 5px;">
                  <el-image @click="openImage(item,openImageDialog=true)" :src='item.url'>
                    <div slot="error" class="image-slot">
                      <el-tooltip effect="dark" content="点击下载文件" placement="bottom">
                        <div style="cursor: pointer;" @click="directDown(item)">
                          {{item.fileName}}
                        </div>
                      </el-tooltip>
                    </div>
                  </el-image>
                </div>
              </div>
              <div v-if="title=='修改'">
                <el-upload multiple :http-request="uploadFile" style="width:765px" class="upload-demo" name="fileList" ref="uploads" list-type="picture" :before-upload="beforeupload" :action="editAtion" :data="formData" :with-credentials="true" :auto-upload="false">
                  <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="margin-left-xs padding-left-lg 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-show="title=='修改'">
          <el-button size="mini" type="primary" plain @click="handleClose">取消</el-button>
          <el-button size="mini" type="primary" @click="confirmEdit() ">确定</el-button>
        </span>
        <span slot="footer" class="dialog-footer" v-if="title=='明细'">
          <el-button size="mini" type="primary" plain @click="handleClose">关闭</el-button>
        </span>
      </el-dialog>
      <el-dialog :close-on-click-modal="false" v-dialogDrag title="图片预览" :visible.sync="openImageDialog">
        <el-image style="height: 60vh;" :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>
    </div>
    <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 style="width:64px">{{printForm.compensation}}</div>
          </el-form-item>
          <el-form-item label="退款金额:">
            <div>{{printForm.refundMoney}}</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 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 size="medium" v-model="searchForm.mobilePhone" placeholder="输入要查询的11位会员手机号" oninput="this.value=this.value.replace(/\D/g,'')" maxlength="11" 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>
    <repayment ref="repayment" @repaymentData="memberOne"></repayment>
    <member ref="member" @memberData="memberData"></member>
    <detail ref="detail" @detailData="detailData"></detail>

  </div>

</template>

<script>
import repayment from "@/components/repayment/index.vue";
import { localPath } from "../../../api/api.js";
import { partten } from "../../../../partten/index.js";
import {
  storeMemberOne,
  couAccountList,
  couAccountRefundList,
  addRefOrder,
  refOrderPage,
  editRefOrder,
  refOrderSendAudit,
  refOrderRevokeAudit,
  refOrderUnAudit,
  refOrderAudit,
  repayPage,
  refpage,
  recDocList,
  refOrderRecDocList,
  refCourseList,
  refOrderDownload,
  debtPage,
  addrepay,
  refOrderPromotionPro,
  refundDel,
  selectOne,
} from "../../../api/eashier.js";
import { getCookie } from "../../../utils/utils.js";
import member from "@/components/member/index";
import detail from "./components/detail";
import admin from "@/components/staffList/admin/index";
import manager from "@/components/staffList/manager/index";
import staffsles from "@/components/staffList/staff/index";
export default {
  components: {
    staffsles,
    manager,
    admin,
    repayment,
    member,
    detail,
  },
  inject: ["reload"],
  data() {
    return {
      headOffice: sessionStorage.getItem("headOffice") * 1,
      printDialogVisible: false, //打印弹窗开关
      openAccountDialog: false,
      openMoneydialog: false,
      staffDialogVisible: false,
      addStaffDialog: false,
      editStaffDialog: false,
      manageStaffDialog: false,
      formWidth: "120px",
      refDialogVisible: false,
      courseCompensationShow: false,
      giftMoneyShow: false,
      courseRefundMoneyShow: false,
      refundTypeShow: false,
      refundTypeShow1: false,
      refundTypeShow2: false,
      formDialog: false,
      openImageDialog: false,
      promotionName: "",
      priceDifference: 0,
      consumeProject: [],
      refundConfirm: false,
      activeName: "员工",
      fit: "contain",
      url: "",
      title: "", //弹窗标题
      pageNum: 1, // 当前页码
      pageSize: 10, // 每页的数据条数,
      giftMoney: null,
      courseRefundMoney: null,
      editAtion: "",
      formData: {},
      fileData: "",
      filesList: [],
      fileList: [],
      editFileList: [],
      selectProject: [],
      promotionForm: {},
      pageInfo: {
        total: 0, //分页总条数 // 总条数

        refLists: [],
      },
      printForm: {
        date: "",
        item: "",
        number: null,
        storeId: "",
        memberName: "",
        mobilePhone: null,
        money: null,
        backMoney: null,
        numMoneys: "",
        numMoney: null,
        overbyitem: "",
        numMoneys: "",
        bymoney: null,
        num: null,
        tel: "",
        printDate: new Date(),
      },
      refund: {
        mobilePhone: null,
        memberName: "",
        memberId: "",
        courseProjectName: "",
        courseCompensation: 0,
        manageStaffName: "",
        refundNumber: null,
        courseRefundMoney: null,
        type: 0,
      },
      debtMoneys: 0,
      courseList: [],
      refundType: "",
      refundAccount: null,
      sessionStorageData: {}, //门店参数集合
      payee: "",
      refundReason: "",
      staffList: [],
      radioIndex: "",
      radiorefValue: "",
      radiorefValueList: {},
      radioValue: "",
      radioValueList: {},
      loading: false,
      staffLists: [{ brandNumber: "", staffName: "", ratio: 100 }],
      managerLists: [{ brandNumber: "", staffName: "", ratio: 100 }],
      adminList: [{ brandNumber: "", staffName: "", ratio: 100 }],
      editStaffRatioIndex: -1,
      multipleSelections: [],
      vip: {}, //会员信息
      refreshtext: false, //搜索判断字符
      searchDialog: false, //搜索弹窗开关
      searchTrue: false, //搜索判断
      date: "",
      searchForm: {
        //搜索表单
        memberName: "",
        refundNum: "",
        mobilePhone: "",
      },
      upNum: 0,
      downNum: 0,
      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: {
    //明细返回方法
    detailData(v) {
      this.getOrder();
    },
    endRefundMoney() {
      let money =
        (this.refund.courseConsumeCount * this.refund.price).toFixed(2) * 1;
      if (this.refund.courseRefundMoney * 1 > money) {
        this.$alert("退款金额不能大于: " + money, "提示", {
          confirmButtonText: "确定",
          confirmButtonClass: "confirmbtnFalses",
          type: "warning",
          center: true,
          callback: (action) => {},
        });
        this.refund.courseRefundMoney = money;
      } else {
        this.refund.refundNumber =
          (this.refund.courseRefundMoney / this.refund.price).toFixed(2) * 1;
        this.refund.refundNumber = parseInt(this.refund.refundNumber);
        this.upNum = this.refund.refundNumber;
        let form = { ...this.refund };
        this.refund = JSON.parse(JSON.stringify(form));
      }
    },
    endNum() {
      this.refund.refundNumber =
        (this.refund.courseRefundMoney / this.refund.price).toFixed(2) * 1;
      this.refund.refundNumber = parseInt(this.refund.refundNumber);
      this.upNum = this.refund.refundNumber;
    },
    endMoney() {
      let money =
        (this.refund.courseConsumeCount * this.refund.price).toFixed(2) * 1;
    },
    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.managerLists);
        that.$refs.admin.show(that.adminList);
      }, 500);
    },
    toStaffs() {
      this.openCollNumber = 1;
      var that = this;
      setTimeout(() => {
        that.$refs.staffsles.show(that.refund.staffLists);
        that.$refs.manager.show(that.refund.managerLists);
        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.managerLists = [...v];
        console.log(this.managerLists);
      } else {
        this.refund.managerLists = [...v];
      }
    },
    //管理员占比返回方法
    adminData(v) {
      console.log(v);
      if (this.openCollNumber == 0) {
        this.adminList = [...v];
      } else {
        this.refund.adminList = [...v];
      }
    },
    print() {
      //console.log(this.radiorefValueList);
      this.printForm = this.radiorefValueList;
      let refundMoney = 0;
      refCourseList({
        refundNum: this.radiorefValueList.refundNum,
        refundOrderId: this.radiorefValueList.id,
      }).then((res) => {
        //console.log(res);
        if (res.code == "000000") {
          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) => {},
          });
        }
      });
      //console.log(this.radiorefValueList);
    },
    //时间改变方法
    changeDate() {
      this.searchForm.startTime = this.date[0];
      this.searchForm.endTime = this.date[1];
    },
    //搜索方法
    search() {
      //条件搜索
      this.searchForm.pageNum = this.pageNum;
      this.searchForm.pageSize = this.pageSize;
      this.searchForm.type = 1;
      refOrderPage(this.searchForm).then((res) => {
        if (res.code == "000000") {
          if (res.rows.length == 0) {
            this.$message({
              message: "没有找到符合条件的单据",
            });
          }
          res.pageInfo.refLists = res.pageInfo.list;
          this.pageInfo = res.pageInfo;
          this.refreshtext = true;
        } else {
          this.$message.error({
            message: res.message,
          });
        }
      });
    },
    //关闭弹窗前的回调方法
    handleClose() {
      this.refund = {
        mobilePhone: null,
        memberName: "",
        memberId: "",
        courseProjectName: "",
        courseCompensation: 0,
        manageStaffName: "",
        refundNumber: null,
        courseRefundMoney: null,
        type: 0,
      };
      this.formDialog = false;
      this.refundReason = "";
      this.staffLists = [{ ratio: 100 }];
      this.managerLists = [{ ratio: 100 }];
      this.adminList = [{ ratio: 100 }];
      this.fileList = [];
      this.loading = false;
      this.payee = "";
      this.refundAccount = "";
      this.refundType = "";
      this.giftMoney = null;
    },
    //重置清空
    reset() {
      this.refund = {
        mobilePhone: null,
        memberName: "",
        memberId: "",
        courseProjectName: "",
        courseCompensation: 0,
        manageStaffName: "",
        refundNumber: null,
        courseRefundMoney: null,
        type: 0,
      };
      this.refundReason = "";
      this.staffLists = [{ ratio: 100 }];
      this.managerLists = [{ ratio: 100 }];
      this.adminList = [{ ratio: 100 }];
      this.fileList = [];
      this.loading = false;
      this.payee = "";
      this.refundAccount = "";
      this.refundType = "";
      this.giftMoney = null;
      this.toStaff();
    },

    //提交信息
    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.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.refund.salesmens = salesmens;
      this.fileData = new FormData();
      this.$refs.upload.submit();
      this.refund.staffLists = staffLists;
      delete this.refund.lastConsumeTime;
      delete this.refund.type;
      delete this.refund.courseNum;
      delete this.refund.card;
      delete this.refund.state;
      let courseListRequest = [];
      courseListRequest.push(this.refund);
      this.fileData.append("type", 1);
      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.courseCompensation);
      this.fileData.append("refundType", this.refundType);
      this.fileData.append("refundAccount", this.refundAccount);
      this.fileData.append("refundReason", this.refundReason);
      this.fileData.append("payee", this.payee);
      console.log(this.refund);
      this.fileData.append("refundMoney", this.refund.courseRefundMoney);
      this.fileData.append(
        "courseListRequest",
        JSON.stringify(courseListRequest)
      );
      console.log(this.refund);
      // return;
      addRefOrder(this.fileData).then((res) => {
        //console.log(res);
        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) => {},
          });
        }
      });
    },
    //上传附件
    //自定义文件上传拦截方法
    uploadFile(file) {
      this.fileData.append("fileList", file.file);
    },
    openMoney() {
      this.$refs.repayment.show(this.vip);
    },

    //打开选择会员弹窗
    openMember() {
      this.$refs.member.show(this.vip);
    },
    //选中会员返回方法
    memberData(v) {
      this.refund.mobilePhone = v.mobilePhone;
      this.memberOne();
    },

    //查询会员信息
    memberOne() {
      if (partten.phoneNum.test(this.refund.mobilePhone)) {
        storeMemberOne({
          mobilePhone: this.refund.mobilePhone,
          storeId: sessionStorage.getItem("parentId"),
        }).then((res) => {
          if (res.code == "000000") {
            this.refund.memberName = res.data.memberName;
            this.refund.memberId = res.data.memberId;
            this.debtMoneys = res.data.debtMoney;
            this.vip = res.data;
            let ids = {
              memberId: res.data.id,
              storeId: res.data.storeId,
            };
            couAccountRefundList(ids).then((res) => {
              //console.log(res.rows);
              this.courseList = res.rows;
            });
          } else {
            this.reset();
            this.$alert(res.message, "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
          }
        });
      } else {
        this.$message.info({
          message: "请输入正确的手机号",
        });
      }
    },
    radioRowCourse(row) {
      this.radioValue = row.id;
      this.radioValueList = row;
    },
    confirCourse() {
      var that = this;
      console.log(that.radioValueList);
      that.radioValueList = JSON.parse(
        JSON.stringify(that.radioValueList).replace(/id/g, "courseAccountId")
      );
      that.refund = Object.assign(that.refund, that.radioValueList);
      that.refund.refundNumber = null;

      let page = {
        memberId: that.radioValueList.memberId,
        storeId: that.radioValueList.storeId,
        accountId: that.radioValueList.courseAccountId,
      };
      debtPage(page).then((res) => {
        if (res.code == "000000") {
          if (res.pageInfo.total == 0) {
            console.log(that.refund);
            that.refund.courseRefundMoney =
              (that.refund.price * that.refund.courseConsumeCount).toFixed(2) *
              1;
            that.refund.refundNumber = that.refund.courseConsumeCount;
            if (this.radioValueList.courseType == "2") {
              that.refund.courseRefundMoney = 0;
              that.refund.price = 0;
            }
          } else {
            var form = res.pageInfo.list[0];
            let refundAccount = 0;
            refundAccount =
              (
                form.tradeMoney -
                form.debtMoney -
                (form.repayCount - that.refund.courseRestCount) *
                  that.refund.price
              ).toFixed(2) * 1;
            that.refund.courseRefundMoney = refundAccount;
            that.refund.refundNumber = that.refund.courseCount;
          }
        } else {
          that.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => {},
          });
        }
      });
      //如果是促销的话 就查询相关联的单据 进行选择
    },

    openGiftMoneyShow() {
      this.giftMoneyShow = true;
      this.$nextTick(() => {
        this.$refs.giftMoneyInput.focus();
      });
    },
    opencourseRefundMoneyShow() {
      this.courseRefundMoneyShow = true;
      this.$nextTick(() => {
        this.$refs.courseRefundMoneyInput.focus();
      });
    },

    //修改收款银行/人/账户
    openRefundType() {
      this.refundTypeShow = false;
      this.$nextTick(() => {
        this.$refs.refundTypeInput.focus();
      });
    },
    endRefundType() {
      this.refundTypeShow = true;

      this.$nextTick(() => {
        this.$refs.refundAccountInput.focus();
        this.refundTypeShow1 = false;
      });
    },
    endRefundAccount() {
      this.refundTypeShow1 = true;
      this.refundTypeShow2 = false;
      this.$nextTick(() => {
        this.$refs.payeeInput.focus();
      });
    },
    endPayee() {
      this.refundTypeShow2 = true;
      this.$nextTick(() => {
        this.$refs.refundReasonInput.focus();
      });
    },

    clickRow(row) {
      this.radiorefValue = row.id;
      this.radiorefValueList = row;
    },
    openRefundList() {
      this.radiorefValue = "";
      this.radiorefValueList = {};
      this.getOrder();
    },
    getOrder() {
      var page = {
        type: 1,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
      };
      refOrderPage(page).then((res) => {
        if (res.code == "000000") {
          res.pageInfo.refLists = res.pageInfo.list;
          this.pageInfo = res.pageInfo;
          if (this.refreshtext == true) {
            this.$message.success({
              message: "已刷新最新数据",
            });
            this.refreshtext = false;
            this.searchTrue = false;
          }
        }
      });
    },
    //明细
    //明细方法
    detail() {
      this.$refs.detail.show(this.radiorefValueList, "明细");
    },
    openImage(item) {
      this.url = item.url;
      this.urlForm = item;
      //console.log(item);
    },
    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() {
      refCourseList({
        refundNum: this.radiorefValueList.refundNum,
        refundOrderId: this.radiorefValueList.id,
      }).then((res) => {
        if (res.code == "000000") {
          this.reset();
          if (res.rows.length == 0) {
            this.$alert("未找到相关明细", "提示", {
              confirmButtonText: "确定",
              confirmButtonClass: "confirmbtnFalses",
              type: "warning",
              center: true,
              callback: (action) => {},
            });
          } else {
            delete res.rows[0].refundMoney;
            delete res.rows[0].compensation;
            this.refund = res.rows[0];
            this.refund.refundMoney = this.radiorefValueList.refundMoney;
            this.refund.compensation = this.radiorefValueList.compensation;
            this.refund.ids = this.radiorefValueList.id;
            this.refundType = this.radiorefValueList.refundType;
            this.refundAccount = this.radiorefValueList.refundAccount;
            this.payee = this.radiorefValueList.payee;
            this.refundReason = this.radiorefValueList.refundReason;
            let staffLists = [];
            res.rows[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);
            });
            if (staffLists.length == 0) {
              staffLists.push({ ratio: 100 });
            }
            this.refund.staffLists = staffLists;
            this.fileList = res.rows[0].fileLists;
            this.fileList.forEach((item) => {
              item.url = partten.https + item.filePath + "/" + item.fileName;
            });
            selectOne({
              type: 5,
              orderNum: this.refund.refundNum,
              storeId: this.radioListsValueList.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 });
                }
                this.refund.managerLists = managerList;
                this.refund.adminList = adminList;
                console.log(this.refund);
                this.toStaffs();
              } else {
                this.$alert(res.message, "加载门店高管", {
                  confirmButtonText: "确定",
                  confirmButtonClass: "confirmbtnFalses",
                  type: "warning",
                  center: true,
                  callback: (action) => {},
                });
              }
            });
            if (res.rows.length > 1) {
              let ids = {
                memberId: res.rows[0].memberId,
                storeId: res.rows[0].storeId,
              };
              couAccountList(ids).then((res) => {
                this.courseList = res.rows;
              });
            }
            let num = 0;
            let nums = 0;
            res.rows.forEach((item) => {
              num += item.courseRefundMoney * 1;
              nums += item.courseCompensation * 1;
            });
            this.refund.courseRefundMoney = num;
            this.refund.courseCompensation = nums;
          }
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => {},
          });
        }
      });
    },
    confirmEdit() {
      let num = 0;
      let staffLists = [];
      this.refund.staffLists.forEach((item) => {
        num += item.ratio * 1;
        let items = {
          id: item.id,
          staffName: item.staffName,
          brandNumber: item.brandNumber,
          identityCard: item.identityCard,
          ratio: item.ratio,
        };
        staffLists.push(items);
      });
      this.fileData = new FormData();
      let courseListRequest = [];
      console.log(this.$refs.uploads);
      if (this.$refs.uploads) {
        this.$refs.uploads.submit();
      }
      let salesmens = [];
      this.refund.managerLists.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.lastConsumeTime;
      delete this.refund.type;
      delete this.refund.courseNum;
      delete this.refund.card;
      delete this.refund.state;
      delete this.refund.entities;
      courseListRequest.push(this.refund);
      this.fileData.append("type", 1);
      this.fileData.append("refundNum", this.refund.refundNum);
      this.fileData.append("id", this.refund.ids);
      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.courseCompensation);
      this.fileData.append("refundType", this.refundType);
      this.fileData.append("refundAccount", this.refundAccount);
      this.fileData.append("refundReason", this.refundReason);

      this.fileData.append("payee", this.payee);
      this.fileData.append("compensation", this.refund.courseCompensation);
      this.fileData.append("refundMoney", this.refund.courseRefundMoney);
      this.fileData.append(
        "courseListRequest",
        JSON.stringify(courseListRequest)
      );
      editRefOrder(this.fileData).then((res) => {
        if (res.code == "000000") {
          this.$message.success({
            message: res.message,
          });
          this.formDialog = false;
          this.openRefundList();
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => {},
          });
        }
      });
    },
    beforeupload(file, fileList) {
      //console.log(file);
      this.editFileList = file;
    },
    //送审
    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(() => {
            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(() => {});
      }
    },
    //分页方法
    handleSizeChange(val) {
      //   //console.log(`每页 ${val} 条`);
      this.pageSize = val;
      if (this.searchTrue == true) {
        this.search();
      } else {
        this.getOrder();
      }
    },
    handleCurrentChange(val) {
      //   //console.log(`当前页: ${val}`);
      this.pageNum = val;
      if (this.searchTrue == true) {
        this.search();
      } else {
        this.getOrder();
      }
    },
  },
  created() {
    this.toStaff();
    this.editAtion = "/demay/ssm/refOrder/update";
    this.sessionStorageData = JSON.parse(
      sessionStorage.getItem("sessionStorageData")
    );
  },
  watch: {
    refDialogVisible(val, oldVal) {
      //console.log(val);
      if (val == false && oldVal == true) {
        this.reset();
      }
    },
  },
};
</script>

<style>
.rech {
  min-height: 200px;
  background: white;
  margin-left: 20px;
  padding-bottom: 50px;
}

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

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

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

.dialogDiv .el-radio__label {
  display: none;
}

.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>
