<template>
  <view class="main">
    <view style="background: #fff">
      <!--    顶部标题-->
      <view class="pageTitle">{{
          detailObj.SETTLEMENT_TYPE===1?`${detailObj.SERVERPART_NAME}-${topDetail.SERVERPARTSHOP_NAME || ''}年度结算表`:
          `${detailObj.SERVERPART_NAME}-${topDetail.SERVERPARTSHOP_NAME || ''}-${$moment(detailObj.ENDDATE).format('YYYYMM')}月度结算表`
        }}</view>
      <!--  顶部详情-->
      <view class="detailBox">

        <view class="detailRow">
          <view class="detailAllItem">
            <span class="label">商家名称：</span>
            <span class="value">{{topDetail.MERCHANTS_NAME || ''}}</span>
          </view>
        </view>

        <view class="detailRow">
          <view class="detailAllItem">
            <span class="label">合同总金额：</span>
            <span class="value">{{topDetail.RENTFEE ? $util.getMoney(topDetail.RENTFEE  / 10000)+'万元':''}}</span>
          </view>
        </view>

        <view class="detailRow">
          <view class="detailItem">
            <span class="label">税率：</span>
            <span class="value">{{topDetail.TaxRate ? `${topDetail.TaxRate}%` : '-'}}</span>
          </view>
          <view class="detailItem">
            <span class="label">期除税收入：</span>
            <span class="value">{{topDetail.MINTURNOVER ? `${$util.getMoney(topDetail.MINTURNOVER / 10000)}万元` : ''}}</span>
          </view>
        </view>


        <view class="detailRow">
          <view class="detailItem">
            <span class="label">履约保证金：</span>
            <span class="value">{{topDetail.SECURITYDEPOSIT ? $util.getMoney(topDetail.SECURITYDEPOSIT  / 10000)+'万元':''}}</span>
          </view>
          <view class="detailItem">
            <span class="label">提成比例：</span>
            <span class="value">{{topDetail.GUARANTEERATIO ? `${topDetail.GUARANTEERATIO}%` : '-'}}</span>
          </view>
        </view>

        <view class="detailRow">
          <view class="detailItem">
            <span class="label">结算模式：</span>
            <span class="value">{{detailObj.SETTLEMENT_MODES?SETTLEMENT_MODESObj[detailObj.SETTLEMENT_MODES] : ''}}</span>
          </view>
          <view class="detailItem">
            <span class="label">项目期数：</span>
            <span class="value">{{detailObj.CURRENT_PERIOD || ''}}</span>
          </view>
        </view>

        <view class="detailRow" v-if="topDetail.DecorateDesc && topDetail.DecorateDesc!=='-'">
          <view class="detailAllItem">
            <span class="label">装修期：</span>
            <span class="value">{{topDetail.DecorateDesc || ''}}</span>
          </view>
        </view>

        <view class="detailRow">
          <view class="detailItem">
            <span class="label">开始时间：</span>
            <span class="value">{{detailObj.STARTDATE || ''}}</span>
          </view>
          <view class="detailItem">
            <span class="label">结束日期：</span>
            <span class="value">{{detailObj.ENDDATE || ''}}</span>
          </view>
        </view>
      </view>
    </view>

<!--    月度的结算数据-->
    <view class="tableBox" v-if="detailObj.SETTLEMENT_TYPE!==1 && !(detailObj.Approvalstate>0)">
      <view class="smallTitle">结算数据</view>

      <view class="tableRow">
        <view class="rowItemBox">
          <view class="allRowItem">
            <span class="label">期限：</span>
            <span class="value">{{`${detailObj.STARTDATE}-${detailObj.ENDDATE}`}}</span>
          </view>
        </view>

        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">本月营收：</span>
            <span class="value">{{actuaryData.CurMonthRevenue?`${numeral(actuaryData.CurMonthRevenue).format('0,0.00')}`:'-'}}</span>
          </view>
          <view class="rowItem">
            <span class="label">累计营业额：</span>
            <span class="value">{{actuaryData.REVENUEDAILY_AMOUNTTotal?`${numeral(actuaryData.REVENUEDAILY_AMOUNTTotal).format('0,0.00')}`:'-'}}</span>
          </view>

<!--          <view class="allRowItem">-->
<!--            <span class="label">累计营业额：</span>-->
<!--            <span class="value">{{actuaryData.REVENUEDAILY_AMOUNTTotal?`${$util.getMoney(actuaryData.REVENUEDAILY_AMOUNTTotal)}`:''}}</span>-->
<!--          </view>-->
        </view>

        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">移动支付：</span>
            <span class="value">{{actuaryData.MOBILEPAY_AMOUNT?`${numeral(actuaryData.MOBILEPAY_AMOUNT).format('0,0.00')}`:'-'}}</span>
          </view>
          <view class="rowItem">
            <span class="label">移动冲正：</span>
            <span class="value">{{actuaryData.MOBILEPAY_CORRECT?`${numeral(actuaryData.MOBILEPAY_CORRECT).format('0,0.00')}`:'-'}}</span>
          </view>
        </view>

        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">现金交易：</span>
            <span class="value">{{actuaryData.CASHPAY_AMOUNT?`${numeral(actuaryData.CASHPAY_AMOUNT).format('0,0.00')}`:'-'}}</span>
          </view>
          <view class="rowItem">
            <span class="label">现金冲正：</span>
            <span class="value">{{actuaryData.CASHPAY_CORRECT?`${numeral(actuaryData.CASHPAY_CORRECT).format('0,0.00')}`:'-'}}</span>
          </view>
        </view>

        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">提成金额：</span>
            <span class="value">{{actuaryData.GUARANTEERATIOAMOUNT?`${numeral(actuaryData.GUARANTEERATIOAMOUNT).format('0,0.00')}`:'-'}}</span>
          </view>
          <view class="rowItem">
            <span class="label">提成收入：</span>
            <span class="value">{{actuaryData.GUARANTEERATIOINCOME?`${numeral(actuaryData.GUARANTEERATIOINCOME).format('0,0.00')}`:'-'}}</span>
          </view>
        </view>
      </view>
    </view>
<!--    月度的精算数据-->
    <view class="tableBox" v-if="detailObj.SETTLEMENT_TYPE!==1 && detailObj.Approvalstate>0">
      <view class="comparedBox">
        <view class="comparedBoxTitleBox">
          <view class="beforeTitleBox" style="text-align: right">结算数据</view>
          <view class="afterTitleBox">精算数据</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel" style="width: 15%">期限：</view>
          <view class="beforeItem" style="width: 45%">{{`${detailObj.STARTDATE}-${detailObj.ENDDATE}`}}</view>
          <view class="afterItem"  :style="{color: detailObj.Approvalstate>0?'#faad14':'#1890ff'}">{{detailObj.Approvalstate>0?'已结算':'待结算'}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">本月营收：</view>
          <view class="beforeItem">{{actuaryData.CurMonthRevenue?`${numeral(actuaryData.CurMonthRevenue).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.CurMonthRevenueTEXT?monthNewCalibration.CurMonthRevenueTEXT:'-'}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">累计营业额：</view>
          <view class="beforeItem">{{actuaryData.REVENUEDAILY_AMOUNTTotal?`${numeral(actuaryData.REVENUEDAILY_AMOUNTTotal).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.REVENUEDAILY_AMOUNTTotalTEXT?monthNewCalibration.REVENUEDAILY_AMOUNTTotalTEXT:'-'}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">移动支付：</view>
          <view class="beforeItem">{{actuaryData.MOBILEPAY_AMOUNT?`${numeral(actuaryData.MOBILEPAY_AMOUNT).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">
            {{monthNewCalibration.MOBILEPAY_AMOUNTTEXT || ''}}
            <span v-if="monthNewCalibration.MOBILEPAY_CORRECT" style="color: red">({{monthNewCalibration.MOBILEPAY_CORRECT>0?'+':''}}{{monthNewCalibration.MOBILEPAY_CORRECTTEXT || ''}})</span>
          </view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">移动冲正：</view>
          <view class="beforeItem">{{actuaryData.MOBILEPAY_CORRECT?`${numeral(actuaryData.MOBILEPAY_CORRECT).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.MOBILEPAY_CORRECTTEXT || ''}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">现金交易：</view>
          <view class="beforeItem">{{actuaryData.CASHPAY_AMOUNT?`${numeral(actuaryData.CASHPAY_AMOUNT).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">
            {{monthNewCalibration.CASHPAY_AMOUNTTEXT || ''}}
            <span v-if="monthNewCalibration.CASHPAY_CORRECT" style="color: red">({{ monthNewCalibration.CASHPAY_CORRECT > 0 ? '+' : '' }}{{ monthNewCalibration.CASHPAY_CORRECTTEXT || '' }})</span>
          </view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">现金冲正：</view>
          <view class="beforeItem">{{actuaryData.CASHPAY_CORRECT?`${numeral(actuaryData.CASHPAY_CORRECT).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.CASHPAY_CORRECTTEXT || '0'}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">提成金额：</view>
          <view class="beforeItem">{{actuaryData.GUARANTEERATIOAMOUNT?`${numeral(actuaryData.GUARANTEERATIOAMOUNT).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.GUARANTEERATIOAMOUNTTEXT || ''}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">提成收入：</view>
          <view class="beforeItem">{{actuaryData.GUARANTEERATIOINCOME?`${numeral(actuaryData.GUARANTEERATIOINCOME).format('0,0.00')}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.GUARANTEERATIOINCOMETEXT || ''}}</view>
        </view>
      </view>
    </view>

    <!--    年度的结算数据-->
    <view class="tableBox" v-if="detailObj.SETTLEMENT_TYPE===1">
      <view class="smallTitle">结算数据</view>

      <view class="tableRow" v-for="(item,index) in yearDataList" :key="index">
        <view v-if="index!==yearDataList.length-1">
          <view class="rowItemBox">
            <view class="rowItem" style="width: 60%">
              <span class="label">期限：</span>
              <span class="value">{{item.PeriodDesc ||''}}</span>
            </view>
            <view class="rowItem" style="width: 40%">
              <span class="label">结算状态：</span>
              <span class="value" :style="{color: detailObj.Approvalstate>0?'#faad14':'#1890ff'}">{{detailObj.Approvalstate>0?'已结算':'待结算'}}</span>
            </view>
          </view>

          <view class="rowItemBox">
            <view class="rowItem">
              <span class="label">现金：</span>
              <span class="value">{{item.CashAmount?numeral(item.CashAmount).format('0,0.00'):'-'}}</span>
            </view>
            <view class="rowItem">
              <span class="label">微支付：</span>
              <span class="value">{{item.MobilePayAmount?numeral(item.MobilePayAmount).format('0,0.00'):'-'}}</span>
            </view>
          </view>

          <view class="rowItemBox">
            <view class="rowItem">
              <span class="label">营业额合计：</span>
              <span class="value">{{item.RevenueAmount?numeral(item.RevenueAmount).format('0,0.00'):'-'}}</span>
            </view>
            <view class="rowItem">
              <span class="label">驿达收款：</span>
              <span class="value">{{item.RoyaltyAmount?numeral(item.RoyaltyAmount).format('0,0.00'):'-'}}</span>
            </view>
          </view>

          <view class="rowItemBox">
            <view class="rowItem">
              <span class="label">营收费用合计：</span>
              <span class="value">{{item.ReceivableAmount?numeral(item.ReceivableAmount).format('0,0.00'):'-'}}</span>
            </view>
            <view class="rowItem">
              <span class="label">租金：</span>
              <span class="value">{{item.GuaranteeFee?numeral(item.GuaranteeFee).format('0,0.00'):'-'}}</span>
            </view>
          </view>
          <view class="rowItemBox">
            <view class="rowItem">
              <span class="label">退补款：</span>
              <span class="value">{{item.RefundSupplement?numeral(item.RefundSupplement).format('0,0.00'):'-'}}</span>
            </view>
            <view class="rowItem">
              <span class="label"></span>
              <span class="value"></span>
            </view>
          </view>

          <view class="getMoreBox" v-if="item.children && item.children.length>0" @click="handleShowChildren(item)">
            <image class="imgIcon" :style="{transform: item.children?'rotate(90deg)':'rotate(-90deg)'}" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/goMore.svg"/>
          </view>
        </view>
        <view v-else>
          <view class="comparedBox">
            <view class="comparedBoxTitleBox">
              <view class="beforeTitleBox" style="text-align: right">结算数据</view>
              <view class="afterTitleBox" v-if="yearDataListObj.level">精算数据</view>
            </view>

            <view class="comparedItem" >
              <view class="compareLabel" style="width: 20%">期限：</view>
              <view class="beforeItem" style="width: 40%">{{item.PeriodDesc ||''}}</view>
              <view class="afterItem" :style="{color: detailObj.Approvalstate>0?'#faad14':'#1890ff'}">{{detailObj.Approvalstate>0?'已结算':'待结算'}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel">营业额合计：</view>
              <view class="beforeItem">{{item.RevenueAmount?numeral(item.RevenueAmount).format('0,0.00'):'-'}}</view>
              <view class="afterItem">
                {{yearDataListObj.RevenueAmountTEXT?yearDataListObj.RevenueAmountTEXT:''}}
                <span style="color: red" v-if="yearDataListObj.CorrectAmount">({{yearDataListObj.CorrectAmount>0?'+':''}}{{yearDataListObj.CorrectAmountTEXT || ''}})</span>
              </view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">现金：</view>
              <view class="beforeItem">{{item.CashAmount?numeral(item.CashAmount).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.CashAmount?numeral(yearDataListObj.CashAmount).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">微支付：</view>
              <view class="beforeItem">{{item.MobilePayAmount?numeral(item.MobilePayAmount).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.MobilePayAmount?numeral(yearDataListObj.MobilePayAmount).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel">驿达收款：</view>
              <view class="beforeItem">{{item.RoyaltyAmount?numeral(item.RoyaltyAmount).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.RoyaltyAmount?numeral(yearDataListObj.RoyaltyAmount).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel">营收费用合计：</view>
              <view class="beforeItem">{{item.ReceivableAmount?numeral(item.ReceivableAmount).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.ReceivableAmount?numeral(yearDataListObj.ReceivableAmount).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">租金：</view>
              <view class="beforeItem">{{item.GuaranteeFee || item.GuaranteeFee===0?numeral(item.GuaranteeFee).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.GuaranteeFee?numeral(yearDataListObj.GuaranteeFee).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">物业费：</view>
              <view class="beforeItem">{{item.PropertyFee || item.PropertyFee===0?numeral(item.PropertyFee).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.PropertyFee || yearDataListObj.PropertyFee===0?numeral(yearDataListObj.PropertyFee).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">房租：</view>
              <view class="beforeItem">{{item.HouseRent || item.HouseRent===0?numeral(item.HouseRent).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.HouseRent || yearDataListObj.HouseRent===0?numeral(yearDataListObj.HouseRent).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">罚款：</view>
              <view class="beforeItem">{{item.BreachPenalty || item.BreachPenalty===0?numeral(item.BreachPenalty).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.BreachPenalty || yearDataListObj.BreachPenalty===0?numeral(yearDataListObj.BreachPenalty).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">电费：</view>
              <view class="beforeItem">{{item.ElectricityCharge || item.ElectricityCharge===0?numeral(item.ElectricityCharge).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.ElectricityCharge || yearDataListObj.ElectricityCharge===0?numeral(yearDataListObj.ElectricityCharge).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">水费：</view>
              <view class="beforeItem">{{item.WaterCharge || item.WaterCharge===0?numeral(item.WaterCharge).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.WaterCharge || yearDataListObj.WaterCharge===0?numeral(yearDataListObj.WaterCharge).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel" style="padding-left: 16rpx;box-sizing: border-box">其他：</view>
              <view class="beforeItem">{{item.OtherFee || item.OtherFee===0?numeral(item.OtherFee).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.OtherFee || yearDataListObj.OtherFee===0?numeral(yearDataListObj.OtherFee).format('0,0.00'):''}}</view>
            </view>

            <view class="comparedItem">
              <view class="compareLabel">退补款：</view>
              <view class="beforeItem">{{item.RefundSupplement?numeral(item.RefundSupplement).format('0,0.00'):'-'}}</view>
              <view class="afterItem">{{yearDataListObj.RefundSupplement?numeral(yearDataListObj.RefundSupplement).format('0,0.00'):''}}</view>
            </view>
          </view>

          <view class="getMoreBox" v-if="item.children && item.children.length>0" @click="handleShowChildren(item)">
            <image class="imgIcon" :style="{transform: item.children?'rotate(90deg)':'rotate(-90deg)'}" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/goMore.svg"/>
          </view>
        </view>

        <view v-if="item.children && item.children.length>0 && item.showChildren">
          <view class="line"></view>
          <view v-for="(subItem,subIndex) in item.children" :key="subIndex" style="padding-left: 32rpx" @click="handleToMonth(subItem)">
            <view class="rowItemBox">
              <view class="rowItem" style="width: 60%">
                <span class="label">期限：</span>
                <span class="value">{{subItem.PeriodDesc ||''}}</span>
              </view>
              <view class="rowItem" style="width: 40%">
                <span class="label">结算状态：</span>
                <span class="value" :style="{color: subItem.IsApplySuccess?'#faad14':'#1890ff'}">{{subItem.IsApplySuccess?'已结算':'待结算'}}</span>
                <image class="imgIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/goMore.svg"/>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">现金：</span>
                <span class="value">{{subItem.CashAmount?numeral(subItem.CashAmount).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">微支付：</span>
                <span class="value">{{subItem.MobilePayAmount?numeral(subItem.MobilePayAmount).format('0,0.00'):''}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">营业额合计：</span>
                <span class="value">{{subItem.RevenueAmount?numeral(subItem.RevenueAmount).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">驿达收款：</span>
                <span class="value">{{subItem.RoyaltyAmount?numeral(subItem.RoyaltyAmount).format('0,0.00'):''}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">营收费用合计：</span>
                <span class="value">{{subItem.ReceivableAmount?numeral(subItem.ReceivableAmount).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">租金：</span>
                <span class="value">{{subItem.GuaranteeFee?numeral(subItem.GuaranteeFee).format('0,0.00'):''}}</span>
              </view>
            </view>
            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">退补款：</span>
                <span class="value">{{subItem.RefundSupplement?numeral(subItem.RefundSupplement).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label"></span>
                <span class="value"></span>
              </view>
            </view>

            <view class="line" v-if="subIndex!==item.children.length-1"></view>
          </view>
        </view>

        <view class="line" v-if="index!==yearDataList.length-1"></view>
      </view>
    </view>

<!--    年度的精算数据-->
<!--    改变了显示样式 暂时隐藏-->
    <view class="tableBox" v-if="detailObj.SETTLEMENT_TYPE===1 && detailObj.Approvalstate>0 && false">
      <view class="smallTitle">精算数据</view>

      <view class="tableRow" v-for="(item,index) in yearDataListAfter" :key="index">
        <view class="rowItemBox">
          <view class="rowItem" style="width: 60%">
            <span class="label">期限：</span>
            <span class="value">{{item.PeriodDesc ||''}}</span>
          </view>
          <view class="rowItem" style="width: 40%">
            <span class="label">结算状态：</span>
            <span class="value" :style="{color: detailObj.Approvalstate>0?'#faad14':'#1890ff'}">{{detailObj.Approvalstate>0?'已结算':'待结算'}}</span>
          </view>
        </view>

        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">现金：</span>
            <span class="value">{{item.CashAmountTEXT || ''}}</span>
          </view>
          <view class="rowItem">
            <span class="label">微支付：</span>
            <span class="value">{{item.MobilePayAmountTEXT || ''}}</span>
          </view>
        </view>

        <view class="rowItemBox">
          <view class="rowItem" style="width: 60%">
            <span class="label">营业额合计：</span>
            <span class="value">{{item.RevenueAmountTEXT || ''}}</span>
          </view>
          <view class="rowItem" style="width: 40%">
            <span class="label">驿达收款：</span>
            <span class="value">{{item.RoyaltyAmountTEXT || ''}}</span>
          </view>
        </view>

        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">营收费用合计：</span>
            <span class="value">{{item.ReceivableAmountTEXT || ''}}</span>
          </view>
          <view class="rowItem">
            <span class="label">租金：</span>
            <span class="value">{{item.GuaranteeFeeTEXT || ''}}</span>
          </view>
        </view>
        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">退补款：</span>
            <span class="value">{{item.RefundSupplementTEXT || ''}}</span>
          </view>
          <view class="rowItem">
            <span class="label"></span>
            <span class="value"></span>
          </view>
        </view>

        <view class="getMoreBox" v-if="item.children && item.children.length>0" @click="handleShowChildrenAfter(item)">
          <image class="imgIcon" :style="{transform: item.children?'rotate(90deg)':'rotate(-90deg)'}" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/goMore.svg"/>
        </view>
        <view v-if="item.children && item.children.length>0 && item.showChildren">
          <view class="line"></view>
          <view v-for="(subItem,subIndex) in item.children" :key="subIndex" style="padding-left: 32rpx">
            <view class="rowItemBox">
              <view class="rowItem" style="width: 60%">
                <span class="label">期限：</span>
                <span class="value">{{subItem.PeriodDesc ||''}}</span>
              </view>
              <view class="rowItem" style="width: 40%">
                <span class="label">结算状态：</span>
                <span class="value" :style="{color: subItem.IsApplySuccess?'#faad14':'#1890ff'}">{{subItem.IsApplySuccess?'已结算':'待结算'}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">现金：</span>
                <span class="value">{{subItem.CashAmount?numeral(subItem.CashAmount).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">微支付：</span>
                <span class="value">{{subItem.MobilePayAmount?numeral(subItem.MobilePayAmount).format('0,0.00'):''}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">营业额合计：</span>
                <span class="value">{{subItem.RevenueAmount?numeral(subItem.RevenueAmount).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">驿达收款：</span>
                <span class="value">{{subItem.RoyaltyAmount?numeral(subItem.RoyaltyAmount).format('0,0.00'):''}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">营收费用合计：</span>
                <span class="value">{{subItem.ReceivableAmount?numeral(subItem.ReceivableAmount).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">租金：</span>
                <span class="value">{{subItem.GuaranteeFee?numeral(subItem.GuaranteeFee).format('0,0.00'):''}}</span>
              </view>
            </view>
            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">退补款：</span>
                <span class="value">{{subItem.RefundSupplement?numeral(subItem.RefundSupplement).format('0,0.00'):''}}</span>
              </view>
              <view class="rowItem">
                <span class="label"></span>
                <span class="value"></span>
              </view>
            </view>

            <view class="line" v-if="subIndex!==item.children.length-1"></view>
          </view>
        </view>

        <view class="line" v-if="index!==yearDataList.length-1 && yearDataListAfter.length!==1"></view>
      </view>
    </view>


<!--    按钮-->
    <view class="btnBox">

<!--      <view class="detailBox">-->
<!--        <view class="detailItem" style="display: flex;align-items: center">-->
<!--          <span class="label">下一环节审批人：</span>-->
<!--          <picker mode="selector" @change="changeNextPerson" :value="nextPersonIndex" range-key="ActDef_Name" :range="nextPerson">-->
<!--            <view class="uni-ellipsis">{{nextPersonIndex?nextPerson[nextPersonIndex].label:'请选择'}}</view>-->
<!--          </picker>-->
<!--        </view>-->
<!--        <view class="detailItem">-->
<!--          <span class="label">审核意见：</span>-->
<!--          <textarea placeholder="请输入您的意见" v-model="approveDesc" style="height: 60px"/>-->
<!--        </view>-->
<!--      </view>-->
      <view class="btnList">
        <view class="btnItem" v-if="detailObj.Approvalstate===0 || (detailObj.Approvalstate>0 && progressDetail.BUSINESSAPPROVAL_STATE===1000)" @click="handleShowApplyForPop">
          <view class="iconBox">
            <image class="itemIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/yj-btn.png"/>
          </view>
          <span>发起申请</span>
        </view>

        <view class="btnItem" v-if="detailObj.Approvalstate>0 && progressDetail.BUSINESSAPPROVAL_STATE!==9000 && isShowBtn && !detailObj.APPLY_PROCCESS" @click="handleShowPop(1)">
          <view class="iconBox">
            <image class="itemIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/sh-btn.png"/>
          </view>
          <span :style="{color: !isShowBtn?'#ADB2BF':''}">审核</span>
        </view>

        <view class="btnItem" v-if="detailObj.Approvalstate>0 && progressDetail.BUSINESSAPPROVAL_STATE!==9000 && isShowBtn && !detailObj.APPLY_PROCCESS" @click="handleShowPop(2)">
          <view class="iconBox">
            <image class="itemIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/bh-btn.png"/>
          </view>
          <span :style="{color: !isShowBtn?'#ADB2BF':''}">驳回</span>
        </view>
      </view>
    </view>

<!--    流程-->
    <view class="progressBox" v-if="detailObj.Approvalstate>0">
      <view class="progressTopBox">
        <span class="progressTitle">审批流程</span>
        <image class="getMoreIcon" :style="{transform: isShowProgress?'rotate(-180deg)':''}" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/downIconMore.png" @click="handleChangeShowProgress"/>
      </view>
      <view class="detailTopBox"  v-if="detailObj.Approvalstate>0 && isShowProgress">
        <view class="leftTop">
          <span class="label">申请人：</span>
          <span class="value">{{progressDetail.STAFF_NAME || ''}}</span>
        </view>
        <view class="rightTop">
          <span class="value">{{progressDetail.BUSINESS_STARTDATE || ''}}</span>
        </view>
      </view>

      <view class="detailTopBox"  v-if="detailObj.Approvalstate>0 && isShowProgress && progressDetail.BUSINESSAPPROVAL_STATE !== 9000">
        <view class="leftTop">
          <span class="label" style="color: red">待审核：</span>
          <span class="value">{{progressDetail.APPOVED_NAME || ''}}</span>
        </view>
      </view>

      <view class="progressList"  v-if="isShowProgress">
        <view class="progressItem" v-for="(item,index) in progressList" :key="index">
          <view class="progressItemTop">
            <view class="progressItemTopLeft">
              <image class="progressIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/right-ico.png"/>
              <span class="progressValue">{{`【${item.APPLYAPPROVE_NAME}】`}}</span>
            </view>
            <view class="progressItemTopRight">{{`${item.APPLYAPPROVE_DATE}`}}</view>
          </view>

          <view class="progressItemBottom">
            <view class="progressItemBottomLeft">{{item.STAFF_NAME}}: </view>
            <view class="progressItemBottomRight">{{`${item.APPLYAPPROVE_INFO}`}}</view>
          </view>
        </view>
      </view>
    </view>
<!--    驳回和审批的-->
    <UniPop :show="showPop" @hidePopup="closePop" type="middle" @touchmove.prevent round="true">
      <view class="uniPopup">
        <view class="uniPopupTop">
          <text class="uniPopupTitle">{{ showType===1?'审核':showType===2?'驳回':'' }}</text>
          <image @click="closePop" class="close" src="https://eshangtech.com/ShopICO/ahyd-BID/examine/close.svg"></image>
        </view>

        <view class="detailBox">
          <view class="detailItem" style="display: flex;align-items: center" v-if="showType===1 && progressObjDetail.NEXT_STATE!==9000">
            <span class="label">下一环节审批人：</span>
            <picker mode="selector" @change="changeNextPerson" :value="nextPersonIndex" range-key="label" :range="nextPerson">
              <view class="uni-ellipsis">{{nextPersonLabel?nextPersonLabel:'请选择'}}</view>
            </picker>
          </view>

          <view class="detailItem" style="display: flex;align-items: center" v-if="showType===2">
            <span class="label">回退状态：</span>
            <picker mode="selector" @change="changeReject" :value="rejectSelectIndex" range-key="label" :range="rejectDataList">
              <view class="uni-ellipsis">{{showRejectText?showRejectText:'请选择'}}</view>
            </picker>
          </view>

          <view class="detailItem">
            <span class="label">审核意见：</span>
            <textarea placeholder="请输入您的意见" v-model="approveDesc" style="height: 60px"/>
          </view>
        </view>

        <view class="btn">
          <span class="btnItem" @click="handleExamine(showType)">{{showType===1?'审核通过':showType===2?'驳回':''}}</span>
        </view>

      </view>
    </UniPop>

<!--    发起申请的-->
    <UniPop :show="isShowApplyFor" @hidePopup="closeApplyFor" type="middle" @touchmove.prevent round="true">
      <view class="uniPopupApplyFor">
        <view class="uniPopupTop">
          <text class="uniPopupTitle">发起申请</text>
          <image @click="closeApplyFor" class="close" src="https://eshangtech.com/ShopICO/ahyd-BID/examine/close.svg"></image>
        </view>


        <view class="detailBoxApplyFor">
          <view class="smallTitle">结算数据</view>

          <view class="tableRow">
            <view class="rowItemBox">
              <view class="allRowItem">
                <span class="label">期限：</span>
                <span class="value">{{`${detailObj.STARTDATE}-${detailObj.ENDDATE}`}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="allRowItem">
                <span class="label">累计营业额：</span>
                <span class="value">{{actuaryData.REVENUEDAILY_AMOUNTTotal?`${numeral(actuaryData.REVENUEDAILY_AMOUNTTotal).format('0,0.00')}`:''}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">移动支付：</span>
                <span class="value">{{actuaryData.MOBILEPAY_AMOUNT?`${numeral(actuaryData.MOBILEPAY_AMOUNT).format('0,0.00')}`:''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">移动冲正：</span>
                <span class="value">{{actuaryData.MOBILEPAY_CORRECT?`${numeral(actuaryData.MOBILEPAY_CORRECT).format('0,0.00')}`:'0'}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">现金交易：</span>
                <span class="value">{{actuaryData.CASHPAY_AMOUNT?`${numeral(actuaryData.CASHPAY_AMOUNT).format('0,0.00')}`:''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">现金冲正：</span>
                <span class="value">{{actuaryData.CASHPAY_CORRECT?`${numeral(actuaryData.CASHPAY_CORRECT).format('0,0.00')}`:'0'}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">提成金额：</span>
                <span class="value">{{actuaryData.GUARANTEERATIOAMOUNT?`${numeral(actuaryData.GUARANTEERATIOAMOUNT).format('0,0.00')}`:''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">提成收入：</span>
                <span class="value">{{actuaryData.GUARANTEERATIOINCOME?`${numeral(actuaryData.GUARANTEERATIOINCOME).format('0,0.00')}`:''}}</span>
              </view>
            </view>
          </view>
        </view>


        <view class="line" v-if="afterCalibration"></view>

        <view class="detailBoxApplyFor" v-if="afterCalibration">
          <view class="smallTitle">精算数据</view>

          <view class="tableRow">
            <view class="rowItemBox">
              <view class="allRowItem">
                <span class="label">期限：</span>
                <span class="value">{{`${detailObj.STARTDATE}-${detailObj.ENDDATE}`}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="allRowItem">
                <span class="label">累计营业额：</span>
                <span class="value">{{newCalibration.REVENUEDAILY_AMOUNTTotal?`${numeral(newCalibration.REVENUEDAILY_AMOUNTTotal).format('0,0.00')}`:''}}</span>
              </view>
            </view>

            <view class="rowItemBox" style="display: flex;justify-content: space-between;align-items: center">
              <view class="rowItemSpecial">
                <span class="label">移动支付：</span>
                <span class="value">
                  {{newCalibration.MOBILEPAY_AMOUNT?`${numeral(newCalibration.MOBILEPAY_AMOUNT + (newCalibration.MOBILEPAY_CORRECT || 0)).format('0,0.00')}` + `${newCalibration.MOBILEPAY_CORRECT?`(${newCalibration.MOBILEPAY_CORRECT>0?'+':''}${newCalibration.MOBILEPAY_CORRECT})`:''}` :''}}
                </span>
              </view>
              <view class="rowItemSpecial">
                <span class="label">移动冲正：</span>
                <span class="value">{{newCalibration.MOBILEPAY_CORRECT?`${numeral(newCalibration.MOBILEPAY_CORRECT).format('0,0.00')}`:'0'}}</span>
              </view>
            </view>

            <view class="rowItemBox" style="display: flex;justify-content: space-between;align-items: center">
              <view class="rowItemSpecial">
                <span class="label">现金交易：</span>
                <span class="value">{{newCalibration.CASHPAY_AMOUNT?`${numeral(newCalibration.CASHPAY_AMOUNT + (newCalibration.CASHPAY_CORRECT || 0)).format('0,0.00')}` + `${newCalibration.CASHPAY_CORRECT?`(${newCalibration.CASHPAY_CORRECT>0?'+':''}${newCalibration.CASHPAY_CORRECT})`:'' }` :''}}</span>
              </view>
              <view class="rowItemSpecial">
                <span class="label">现金冲正：</span>
                <span class="value">{{newCalibration.CASHPAY_CORRECT?`${numeral(newCalibration.CASHPAY_CORRECT).format('0,0.00')}`:'0'}}</span>
              </view>
            </view>

            <view class="rowItemBox">
              <view class="rowItem">
                <span class="label">提成金额：</span>
                <span class="value">{{newCalibration.GUARANTEERATIOAMOUNT?`${numeral(newCalibration.GUARANTEERATIOAMOUNT).format('0,0.00')}`:''}}</span>
              </view>
              <view class="rowItem">
                <span class="label">提成收入：</span>
                <span class="value">{{newCalibration.GUARANTEERATIOINCOME?`${numeral(newCalibration.GUARANTEERATIOINCOME).format('0,0.00')}`:''}}</span>
              </view>
            </view>
          </view>
        </view>


        <view class="goRightBox">
          <div class="commodityContent">
            <input class="color1" type="number" v-model="MobilePayCorrect"/>
            <div>
              <span class="ctitle">移动支付差额</span>
            </div>
          </div>
          <div class="commodityContent">
            <input class="color1" type="number" v-model="CashPayCorrect"/>
            <div>
              <span class="ctitle">现金支付差额</span>
            </div>
          </div>
        </view>
        <view class="btn">
          <span class="btnItem" @click="handleRecalibrate">重新校准</span>
          <span class="btnItem" style="margin-left: 16rpx" v-if="afterCalibration" @click="openShowSelect">发起申请</span>
        </view>

      </view>
    </UniPop>

<!--    -->
    <UniPop :show="isShowSelect" @hidePopup="closeShowSelect" :showIndex="6" type="middle" @touchmove.prevent round="true">
      <view class="uniPopupShowSelect">
        <view class="uniPopupTop">
          <text class="uniPopupTitle"></text>
          <image @click="closeShowSelect" class="close" src="https://eshangtech.com/ShopICO/ahyd-BID/examine/close.svg"></image>
        </view>

        <view class="uniPopupContent">
          <view class="contentItem">
            <view class="label">请选择下一阶段审批人</view>
            <picker class="pick" :value="nextPersonIndex" :range="nextPerson" range-key="label" @change="handleChangePerson">
              {{nextPersonValue? showLabel:'--请选择--'}}
            </picker>
          </view>

          <view class="contentItem" style="margin-top: 8px">
            <view class="label">审核意见</view>
            <view class="text-area-box">
              <textarea placeholder="请输入您的意见" v-model="approveDesc"/>
            </view>
          </view>

          <view class="btn">
            <span class="btnItem" @click="handleCreate">确认结算</span>
          </view>
        </view>
      </view>
    </UniPop>

  </view>
</template>
<script>
import request from '@/util/index.js'
import UniPop from '@/components/uni-popup.vue'
import Store from "../../store/store";
import {mapGetters} from "vuex";
import {wrapTreeNode} from "../../util/dateTime";
import numeral from "numeral";
export default {
  name: "detail",
  components: {UniPop},
  data() {
    return {
      detailObj:{},// 传入的详情数据
      staticMonth:'',// 外面查询时间的结束时间
      SETTLEMENT_MODESObj:{
        1000:"营收回款",
        2000: "资金返款",
        3000: "营收分润",
        4000: "组合分润",
        9998: "阶段提成",
        9999: "分段提成",
      },// 写死的枚举
      topDetail:{},// 顶部详情数据
      actuaryData:{},// 精算数据
      approveDesc:'已核对，拟同意！',// 审批意见
      nextPerson:[],// 下一环节审批人列表
      nextPersonIndex:'',// 下一环节审批人索引
      nextPersonLabel:'',// 下一环节审批人索引
      nextPersonValue:'',// 下一环节审批人的值
      showLabel:'',// 审核人的显示
      progressList: [],// 流程的数据
      showPop:false,// 悬浮框
      showType: 0,// 1审核 2 驳回
      progressDetail:{},// 进度详情
      rejectDataList:[],// 驳回的列表
      rejectSelectIndex: '',// 驳回索引
      rejectSelectValue: '',// 驳回的选择值
      showRejectText:'',// 驳回显示的文字
      isPending: false,// 接口是否进行中
      isShowBtn: false,// 判断是否显示按钮
      isShowApplyFor: false,// 发起申请的悬浮框
      MobilePayCorrect: 0,// 移动支付差额
      CashPayCorrect: 0,// 现金支付差额
      newCalibration: {},// 校准之后的数据
      afterCalibration: false,// 是否为校准之后
      lastMonthIsOver: false,// 判断上个月是否已经审结
      LastSettlementMonth: '',// 最近审结的月份
      isShowSelect: false,// 出现选人的悬浮框
      yearDataList:[],// 年度结算的悬浮框数据
      isAllMonthSuccess: true,// 判断是不是全部的月份都已经审结了
      allYearMonthDataList:[],//用来处理没完成的结算月度数据
      yearDataListAfter:[],// 年度精算数据
      yearDataListObj:[],// 年度精算数据 list也就一条
      isShowProgress: true,// 是否显示流程进度
      isPush: false,// 是否是推送
      progressObjDetail:{},// 流程详情
      monthId:'', // 月份审批二次进入发起申请的时候带的唯一id
      monthNewCalibration:{},// 月度精算过后 详情进入查看的值
      yearId:'',// 年度审批二次进入发起申请的时候带的id
    }
  },
  async onLoad(query){
    console.log('query',query)
    if (query.id) {
      this.isPush = true
      await this.handleGetPageDetail(query.id)
    }else{
      if(query.obj){
        this.detailObj = JSON.parse(query.obj)
      }
    }
    console.log('this.detailObj',this.detailObj)
    if(query.staticMonth){
      this.staticMonth = this.$moment(query.staticMonth ).format('YYYYMM')
      console.log('this.staticMonth',this.staticMonth)
    }
    // 拿到顶部数据
    await this.handleGetDetailDifference()
    if(this.detailObj.SETTLEMENT_TYPE===1){
      // 如果是年度的 就去请求年度的结算数据
     await this.handleGetYearSettlement()
      if (this.detailObj.Approvalstate > 0) {
        // 请求年度的精算数据
        await this.handleGetYearSettlementRight()
      }
    }else{
      // 月度数据
      // 拿到月度精算数据
      await this.handleGetActuaryData()
      if (this.detailObj.Approvalstate > 0) {
        // 精算数据
        await this.handleGetDetail()
      }
    }
    // 拿到流程数据
    await this.handleGetProgress()


  },
  onUnload(){

    // 因为返回不会卸载页面 但是详情返回列表下一次进来肯定全部重新判断的 所以只能这样
    this.detailObj = {}
    this.topDetail = {}
    this.actuaryData = {}
    this.yearDataListObj = {}
    this.newCalibration = {}
    this.progressDetail = {}
    this.nextPerson = []
    this.staticMonth = ''
    this.nextPersonIndex = ''
    this.nextPersonLabel = ''
    this.showLabel = ''
    this.approveDesc = ''
    this.progressList = []
    this.afterCalibration = false
    this.monthId = ''

    this.closePop()
    this.closeApplyFor()
    this.closeShowSelect()
  },
  computed: {
    ...mapGetters({'users':'getUser'}),
  },

  methods:{
    numeral,
    // 跳转月度详情页面
    handleToMonth(obj) {
      console.log('obj', obj)
      let id = obj.BUSINESSPROJECT_ID ? obj.BUSINESSPROJECT_ID : ''
      let res = {
        ...obj,
        STARTDATE: obj.StartDate ? this.$moment(obj.StartDate.replace('.', '-').replace('.', '-')).format('YYYY-MM-DD') : '',
        ENDDATE: obj.EndDate ? this.$moment(obj.EndDate.replace('.', '-').replace('.', '-')).format('YYYY-MM-DD') : '',
        SHOPROYALTY_ID: this.detailObj.SHOPROYALTY_ID || '',
        BUSINESSPROJECT_ID: this.detailObj.BUSINESSPROJECT_ID || '',
        SERVERPARTSHOP_ID: this.detailObj.SERVERPARTSHOP_ID || '',
        SERVERPART_ID: this.detailObj.SERVERPART_ID || '',
        SERVERPART_NAME: this.detailObj.SERVERPART_NAME || ''
      }
      let staticMonth = this.$moment(res.ENDDATE).endOf('months').format('YYYYMM')
      this.$util.toNextRoute('navigateTo', `/pages/settlementApproval/monthDetail?obj=${JSON.stringify(res)}&staticMonth=${staticMonth}&id=${id}`)
    },
    async handleGetDetail(){
      uni.showLoading({
        title: '请求月度精算数据...'
      })
      const data = await request.$webGet('EShangApiMain/BusinessProcess/GetBUSINESSAPPROVALDetail',{BUSINESSAPPROVALId: this.detailObj.BUSINESSAPPROVAL_ID})
      console.log('data', data)
      let id = data.Result_Data.BUSINESSPROCESS_ID
      const res = await request.$webGet('EShangApiMain/BusinessProject/GetBIZPSPLITMONTHDetail',{BIZPSPLITMONTHId: id})
      let obj = res.Result_Data
      const req = {
        BusinessProjectId: this.detailObj.BUSINESSPROJECT_ID,
        StatisticsMonth: this.staticMonth || (this.detailObj.SETTLEMENT_DATE ? this.$moment(this.detailObj.SETTLEMENT_DATE + (this.detailObj.SETTLEMENT_TYPE===1?'':'/01')).format('YYYYMM') : ''),
        ShopRoyaltyId: this.detailObj.SHOPROYALTY_ID,
        MobilePayCorrect: obj.MOBILEPAY_CORRECT || 0,
        CashPayCorrect: obj.CASHPAY_CORRECT || 0
      }
      const result = await request.$webGet('EShangApiMain/Finance/GetProjectPeriodIncome',req)
      console.log('Incomeresult',result)
      let bigObj = result.Result_Data.List[0]
      this.monthId = bigObj.bizpsplitMonthId
      this.monthNewCalibration = bigObj
      this.monthNewCalibration.REVENUEDAILY_AMOUNTTotalTEXT = numeral(this.monthNewCalibration.REVENUEDAILY_AMOUNTTotal).format('0,0.00')
      this.monthNewCalibration.CurMonthRevenueTEXT = numeral(this.monthNewCalibration.CurMonthRevenue).format('0,0.00')
      this.monthNewCalibration.MOBILEPAY_AMOUNTTEXT = numeral(this.monthNewCalibration.MOBILEPAY_AMOUNT + (this.monthNewCalibration.MOBILEPAY_CORRECT || 0)).format('0,0.00')
      this.monthNewCalibration.MOBILEPAY_CORRECTTEXT = numeral(this.monthNewCalibration.MOBILEPAY_CORRECT).format('0,0.00')
      this.monthNewCalibration.CASHPAY_AMOUNTTEXT = numeral(this.monthNewCalibration.CASHPAY_AMOUNT + (this.monthNewCalibration.CASHPAY_CORRECT || 0)).format('0,0.00')
      this.monthNewCalibration.CASHPAY_CORRECTTEXT = numeral(this.monthNewCalibration.CASHPAY_CORRECT).format('0,0.00')
      this.monthNewCalibration.GUARANTEERATIOAMOUNTTEXT = numeral(this.monthNewCalibration.GUARANTEERATIOAMOUNT).format('0,0.00')
      this.monthNewCalibration.GUARANTEERATIOINCOMETEXT = numeral(this.monthNewCalibration.GUARANTEERATIOINCOME).format('0,0.00')
      console.log('this.newCalibration2', this.monthNewCalibration)
      uni.hideLoading()
    },
    // 控制流程进度是否显示
    handleChangeShowProgress() {
      this.isShowProgress = !this.isShowProgress
    },
    // 请求年度的精算数据
    async handleGetYearSettlementRight(){
      const req = {
        BUSINESSPROJECT_ID: this.detailObj.BUSINESSPROJECT_ID,
        SHOPROYALTY_ID: this.detailObj.SHOPROYALTY_ID
      }
      uni.showLoading({
        title: '请求精算数据...'
      })
      const data = await request.$webGet('EShangApiMain/Finance/GetProjectPeriodAccount',req)
      let res = data.Result_Data
      // 页面显示的结算数据
      let resList = wrapTreeNode(res.ProjectPeriodList)
      console.log('resList222222', resList)
      // 年度的精算数据只取最后一条 所以处理 且不保留子级
      let result = [resList[resList.length - 1]]
      if (result && result.length > 0) {
        console.log('result33333', result)
        result.forEach(item => {
          item.level = 1
          item.showChildren = false
          item.CashAmountTEXT = numeral(item.CashAmount).format('0,0.00')
          item.MobilePayAmountTEXT = numeral(item.MobilePayAmount).format('0,0.00')
          item.RevenueAmountTEXT = numeral(item.RevenueAmount).format('0,0.00')
              // numeral(this.$util.getMoney(item.RevenueAmount)).format('0,0.00') + (item.CorrectAmount ? ('(' + (item.CorrectAmount > 0 ? '+' : '') + item.CorrectAmount + ')') : '')
          item.CorrectAmountTEXT = numeral(item.CorrectAmount).format('0,0.00')
          item.RoyaltyAmountTEXT = numeral(item.RoyaltyAmount).format('0,0.00')
          item.ReceivableAmountTEXT = numeral(item.ReceivableAmount).format('0,0.00')
          item.GuaranteeFeeTEXT = numeral(item.GuaranteeFee).format('0,0.00')
          item.RefundSupplementTEXT = numeral(item.RefundSupplement).format('0,0.00')
          item.children = null
        })
        this.yearDataListObj = result[0]
      }else{
        this.yearDataListObj = {}
      }
      this.yearDataListAfter = result
      this.yearId = result[0].RevenueConfirmId
      console.log('this.yearDataListAfter',this.yearDataListAfter)
      console.log('this.yearId',this.yearId)
      uni.hideLoading()
    },
    // 推送拿到进入页面的初始参数
    async handleGetPageDetail(id) {
      uni.showLoading({
        title: '请求用户数据...'
      })
      const req = {
        BusinessApprovalId: id,
        UserId: this.users.UserId
      }
      console.log('req',req)
      const data = await request.$webGet('EShangApiMain/BusinessProject/GetProjectAccountDetail',req)
      console.log('data',data)
      let res = data.Result_Data
      console.log('res',res)
      let obj = {
        ...res,
        Approvalstate: res.SETTLEMENT_STATE === 0 ? 0 : res.SETTLEMENT_STATE === 1 ? 9 : res.SETTLEMENT_STATE === 2 ? 1 : '',
        startTime: this.$moment(res.SETTLEMENT_DATE + (res.SETTLEMENT_TYPE === 1 ? '' : '/01')).startOf('months').format('YYYY-MM-DD'),
        endTime: this.$moment(res.SETTLEMENT_DATE + (res.SETTLEMENT_TYPE === 1 ? '' : '/01')).endOf('months').format('YYYY-MM-DD')
      }
      this.detailObj = obj
      this.staticMonth = this.$moment(obj.endTime).format('YYYYMM')
      console.log('this.detailObj',this.detailObj)
      uni.hideLoading()
    },
    // 拿到年度结算数据
    async handleGetYearSettlement(){
      const req = {
        BUSINESSPROJECT_ID: this.detailObj.BUSINESSPROJECT_ID,
        SHOPROYALTY_ID: this.detailObj.SHOPROYALTY_ID
      }
      uni.showLoading({
        title: '请求结算数据...'
      })
      const data = await request.$webGet('EShangApiMain/Finance/GetReconciliation',req)
      let res = data.Result_Data.List[0]
      console.log('res',res)
      // 页面显示的结算数据
      let resList = wrapTreeNode(res.ProjectPeriodList.children)
      if(resList && resList.length>0){
        resList.forEach(item=>{
          item.level = 1
          if(item.children && item.children.length>0){
            item.showChildren = false
            item.children.forEach(subItem=>{
              subItem.level = 2
            })
          }
        })
      }
      this.yearDataList = resList
      console.log('this',this.yearDataList)
      // 判断是否已经完成全部月度结算
      let other = res.ProjectPeriodList.node
      let isContinue = true
      if(!other.AllowApply){
        isContinue = false
      }
      this.isAllMonthSuccess = isContinue

      let list = wrapTreeNode([res.ProjectPeriodList.children[0]])
      this.allYearMonthDataList = list
      console.log('list',list)

      uni.hideLoading()
    },
    // 显示子级
    handleShowChildren(obj){
      let list = JSON.parse(JSON.stringify(this.yearDataList))
      list.forEach(item=>{
        if(item.ShopRoyalty_Id === obj.ShopRoyalty_Id && item.PeriodIndex === obj.PeriodIndex){
          item.showChildren = !item.showChildren
        }
      })
      this.yearDataList = list
    },
    // 完成全部的月度结算
    async handleSuccessAllMonth(list){
      uni.showLoading({
        title: '正在自动月度结算...'
      })
      let ShopRoyaltyIdStr = ''
      let minStartTime = ''
      let maxEndTime = ''
      console.log('list',list)
      if(list && list.length>0){
        // 拿到需要结算的月份  和 拆分数据
        list.forEach((item,index)=>{
          if (index === 0) {
            minStartTime = this.$moment(item.StartDate).format('YYYY-MM-DD')
            maxEndTime = this.$moment(item.EndDate).format('YYYY-MM-DD')
          }else{
            if (new Date(minStartTime).getTime() > new Date(this.$moment(item.StartDate).format('YYYY-MM-DD')).getTime()) {
              minStartTime = this.$moment(item.StartDate).format('YYYY-MM-DD')
            }
            if (new Date(maxEndTime).getTime() < new Date(this.$moment(item.EndDate).format('YYYY-MM-DD')).getTime()) {
              maxEndTime = this.$moment(item.EndDate).format('YYYY-MM-DD')
            }
          }

          if (ShopRoyaltyIdStr) {
            ShopRoyaltyIdStr += `,${item.ShopRoyalty_Id}`
          } else {
            ShopRoyaltyIdStr = `${item.ShopRoyalty_Id}`
          }
        })
        // 全部月度结算接口
        const monthReq = {
          ProjectId: this.detailObj.BUSINESSPROJECT_ID,
          ShopRoyaltyId: ShopRoyaltyIdStr,
          StartMonth: minStartTime ? this.$moment(minStartTime).format('YYYYMM') : '',
          EndMonth: maxEndTime ? this.$moment(maxEndTime).format('YYYYMM') : '',
          userId: this.users.UserId
        }
        console.log('monthReq',monthReq)

        const monthData = await request.$webGet('EShangApiMain/Finance/ApprovePeriodAccount',monthReq)
        uni.hideLoading()
        console.log('monthData',monthData)
        if (monthData.Result_Code === 100) {
          uni.showToast({
            title: monthData.Result_Desc,
            icon:'success',
            duration: 1000
          });
          // 重新计算一遍那些月份是否已经结算了
          await this.handleGetYearSettlement()
          // 自动等于点击一遍发起申请
          this.handleShowApplyForPop()
        }else{
          uni.showToast({
            title: monthData.Result_Desc,
            icon:'error',
            duration: 1000
          });
        }
      }
    },
    // 选择审批人
    handleChangePerson(e){
      console.log('e',e)
      console.log('this.nextPerson',this.nextPerson)
      this.nextPersonIndex = Number(e.target.value)
      let value = this.nextPerson[this.nextPersonIndex].value
      this.nextPersonValue = value
      this.showLabel = value.split('-')[0]
      console.log('nextPersonValue',this.nextPersonValue)
    },
    // 发起申请
    async handleCreate(){
      if(!this.nextPersonValue){
        uni.showToast({
          icon:'error',
          duration: 2000,
          title: '请选择审批人',
        });
        return
      }
      if(!this.approveDesc){
        uni.showToast({
          icon:'error',
          duration: 2000,
          title: '请输入审核意见',
        });
        return
      }


      console.log('this.detailObj',this.detailObj)
      console.log('this.newCalibration',this.newCalibration)
      console.log('users',this.users)
      // 判断是年度结算还是月度结算
      let _this = this
      if(this.detailObj.SETTLEMENT_TYPE===1){
        // // 年度
        // const req = {
        //   BusinessapprovalModel:{
        //     OPERATION_TYPE: '11',
        //     // BUSINESSPROCESS_ID:'',
        //     PROINST_ID: this.detailObj.SHOPROYALTY_ID,
        //     SERVERPART_ID: this.detailObj.SERVERPART_ID,
        //     SERVERPART_IDS: this.detailObj.SERVERPART_ID,
        //     BUSINESSPROCESS_NAME:'',
        //     BUSINESS_STARTDATE:'',
        //     BUSINESSAPPROVAL_STATE: 1000,
        //     BUSINESSAPPROVAL_DESC:'',
        //     STAFF_NAME:this.detailObj.UserName,
        //     STAFF_ID:this.detailObj.UserId,
        //     Serverpart_Name:'',
        //     SERVERPARTSHOP_ID:'',
        //     SERVERPARTSHOP_NAME:'',
        //     CORRECT_AMOUNT:'',
        //     APPOVED_IDS:'',
        //     APPOVED_NAME:''
        //   },
        //   RevenueconfirmModel: []
        // }
        //
        // // const data = await request.$webPost('EShangApiMain/Finance/ApplyAccountProinst', req)
      }else{
        // 月度
        console.log('this.nextPersonValue',this.nextPersonValue)
        let [APPOVED_NAME,APPOVED_IDS] = this.nextPersonValue.split('-')
        console.log('APPOVED_IDS',APPOVED_IDS)
        console.log('APPOVED_NAME',APPOVED_NAME)
        uni.showLoading({
          title: '正在发起申请...'
        })
        const req = {
          BusinessapprovalModel:{
            OPERATION_TYPE:'12',
            BUSINESSAPPROVAL_ID: this.detailObj.BUSINESSAPPROVAL_ID || '',
            BUSINESSPROCESS_NAME:`${this.detailObj.BUSINESSPROJECT_NAME}【${this.detailObj.startTime}-${this.detailObj.endTime}】月度结算`,
            PROINST_ID: this.detailObj.BUSINESSPROJECT_ID,
            SERVERPART_ID: this.detailObj.SERVERPART_ID,
            SERVERPART_NAME: this.detailObj.SERVERPART_NAME,
            STAFF_ID: this.users.UserId,
            STAFF_NAME: this.users.UserName,
            BUSINESS_STARTDATE: this.$moment().format('YYYY-MM-DD HH:mm:ss'),
            BUSINESSAPPROVAL_STATE: 1000,
            BUSINESSAPPROVAL_DESC:this.approveDesc,
            SERVERPART_IDS:  this.detailObj.SERVERPART_ID,
            MERCHANTS_ID: this.detailObj.MERCHANTS_ID,
            MERCHANTS_NAME: this.detailObj.MERCHANTS_NAME,
            SERVERPARTSHOP_ID: this.detailObj.SERVERPARTSHOP_ID,
            SERVERPARTSHOP_NAME: this.detailObj.SERVERPARTSHOP_NAME,
            APPOVED_IDS: APPOVED_IDS,
            APPOVED_NAME:APPOVED_NAME,
          },
          bizpsplitMonthModel:{
            ...this.newCalibration,
            SHOPROYALTY_ID: this.detailObj.SHOPROYALTY_ID,
            SERVERPARTSHOP_ID: this.detailObj.SERVERPARTSHOP_ID,
            SERVERPARTSHOP_NAME: this.detailObj.SERVERPARTSHOP_NAME,
            BUSINESS_TYPE: this.detailObj.BUSINESS_TYPE,
            Serverpart_Name: this.detailObj.SERVERPART_NAME,
            STARTDATE: this.detailObj.startTime,
            ENDDATE: this.detailObj.endTime,
            REVENUE_AMOUNT: this.newCalibration.CurMonthRevenue,
            ROYALTY_PRICE: this.newCalibration.GUARANTEERATIOAMOUNT,
            ROYALTY_THEORY: this.newCalibration.GUARANTEERATIOINCOME,
            MOBILEPAY_AMOUNT: this.newCalibration.MOBILEPAY_AMOUNT,
            CASHPAY_AMOUNT: this.newCalibration.CASHPAY_AMOUNT,
            ACCREVENUE_AMOUNT: this.newCalibration.REVENUEDAILY_AMOUNTTotal,
            ACCROYALTY_PRICE: this.newCalibration.ROYALTYTHEORYMUST,
            ACCROYALTY_THEORY: this.newCalibration.ROYALTYTHEORYOK,
            MOBILEPAY_CORRECT: this.newCalibration.MOBILEPAY_CORRECT,
            CASHPAY_CORRECT: this.newCalibration.CASHPAY_CORRECT,
            ACCOUNT_TYPE: 1000,
            BIZPSPLITMONTH_STATE: 2,
            BIZPSPLITMONTH_ID: this.monthId,
          }
        }
        console.log('req',req)
        // return
        const data = await request.$webPost('EShangApiMain/Finance/ApplyMonthAccountProinst', req)
        if (data.Result_Code === 100) {
          if (this.isPush) {
            uni.showToast({
              icon:'success',
              duration: 2000,
              title: data.Result_Desc,
            });
            setTimeout(()=>{
              uni.redirectTo({
                url: '/pages/settlementApproval/index'
              });
            },2000)
          }else{
            uni.showToast({
              icon:'success',
              duration: 2000,
              title: data.Result_Desc,
            });
            uni.setStorageSync('reolad','true')
            setTimeout(()=>{
              uni.navigateBack({
                delta: 1
              });
            },2000)
          }

        }else{
          uni.showToast({
            icon:'error',
            duration: 2000,
            title: data.Result_Desc,
          });
        }
        uni.hideLoading()
      }
    },
    // 重新校准
    async handleRecalibrate(){
      console.log('this.MobilePayCorrect',this.MobilePayCorrect)
      console.log('this.CashPayCorrect',this.CashPayCorrect)
      const req = {
        BusinessProjectId: this.detailObj.BUSINESSPROJECT_ID,
        StatisticsMonth: this.staticMonth || (this.detailObj.SETTLEMENT_DATE ? this.$moment(this.detailObj.SETTLEMENT_DATE + (this.detailObj.SETTLEMENT_TYPE===1?'':'/01')).format('YYYYMM') : ''),
        ShopRoyaltyId: this.detailObj.SHOPROYALTY_ID,
        MobilePayCorrect: this.MobilePayCorrect || 0,
        CashPayCorrect: this.CashPayCorrect || 0,
      }
      uni.showLoading({
        title: '请求精算数据...'
      })
      const data = await request.$webGet('EShangApiMain/Finance/GetProjectPeriodIncome', req)
      console.log('data',data)
      let res = data.Result_Data.List[0]
      this.newCalibration = res
      this.afterCalibration = true
      console.log('res',res)
      uni.hideLoading()
    },
    openShowSelect(){
      this.isShowSelect = true
    },
    // 关闭选人的悬浮框
    closeShowSelect(){
      this.isShowSelect = false
    },
    // 显示发起申请的悬浮框
    async handleShowApplyForPop(){
      let _this = this
      if(this.detailObj.SETTLEMENT_TYPE===2){
        // 月度
        if (this.lastMonthIsOver) {
          this.isShowApplyFor = true
        }else{
          uni.showModal({
            title: '系统检测',
            content: `${this.detailObj.SERVERPART_NAME}-${this.detailObj.SERVERPARTSHOP_NAME},项目期数内存在未审批月度结算！点击确定自动为您调整到${this.LastSettlementMonth}月进行审批？`,
            success: function (res) {
              if (res.confirm) {
                uni.setStorageSync('handleGetNewMonth','true')
                uni.setStorageSync('handleGetNewMonthObj',_this.detailObj)
                uni.setStorageSync('handleGetNewMonthTime',_this.LastSettlementMonth + '/01')
                uni.navigateBack({
                  delta: 1
                });
              } else if (res.cancel) {
                // uni.navigateBack({
                //   delta: 1
                // });
              }
            }
          });
        }
      }else{
        // 年度
        if(this.isAllMonthSuccess){
          // 可以进行年度发起申请 就跳转新页面
          this.handleGoYearSettlementPage()
        }else{
          uni.showModal({
            content:'请先完成全部月度结算！ 点击确认将自动进行结算！',
            success: async function (res) {
              if (res.confirm) {
                _this.handleSuccessAllMonth(_this.yearDataList)
              }
            }
          })
        }
      }
    },
    // 跳转去年度结算页面
    handleGoYearSettlementPage(){
      this.$util.toNextRoute('navigateTo', `/pages/settlementApproval/yearSettlement?obj=${JSON.stringify(this.detailObj)}&yearId=${this.yearId}`)
    },
    // 关闭发起申请的悬浮框
    closeApplyFor(){
      this.isShowApplyFor = false
    },

    // 获得顶部详情和差异数据
    async handleGetDetailDifference(){
      const req = {
        StartDate: this.detailObj.STARTDATE?this.$moment(this.detailObj.STARTDATE).format('YYYY-MM-DD'):'',
        EndDate: this.detailObj.ENDDATE?this.$moment(this.detailObj.ENDDATE).format('YYYY-MM-DD'):'',
        SHOPROYALTY_ID: this.detailObj.SHOPROYALTY_ID || '',
        BUSINESSPROJECT_ID: this.detailObj.BUSINESSPROJECT_ID || '',
        ACCOUNT_TYPE: 1000,
        SERVERPARTSHOP_ID: this.detailObj.SERVERPARTSHOP_ID,
        DataSourceType: 2,
        SERVERPART_ID: this.detailObj.SERVERPART_ID,
        STATISTICS_MONTH: this.staticMonth || (this.detailObj.SETTLEMENT_DATE ? this.$moment(this.detailObj.SETTLEMENT_DATE +(this.detailObj.SETTLEMENT_TYPE===1?'':'/01')).format('YYYYMM') : '')
      }
      console.log('this.staticMonth',this.staticMonth)
      console.log('req',req)
      uni.showLoading({
        title: '请求详情数据...'
      })
      const data = await request.$webGet('EShangApiMain/Revenue/GetRevenueReportByBIZPSPLITMONTH',req)
      console.log('data',data)
      let res = data.Result_Data.List
      if(res && res.length>0){
        let detailObj = res[0]
        this.topDetail = detailObj.RevenueRecognition
        console.log('this.topDetail',this.topDetail)
      }
      uni.hideLoading()
    },
    // 获取精算数据
    async handleGetActuaryData(){
      const req = {
        BusinessProjectId: this.detailObj.BUSINESSPROJECT_ID,
        StatisticsMonth: this.staticMonth || (this.detailObj.SETTLEMENT_DATE ? this.$moment(this.detailObj.SETTLEMENT_DATE + (this.detailObj.SETTLEMENT_TYPE===1?'':'/01')).format('YYYYMM') : ''),
        ShopRoyaltyId: this.detailObj.SHOPROYALTY_ID,
      }
      uni.showLoading({
        title: '请求精算数据...'
      })
      const data = await request.$webGet('EShangApiMain/Finance/GetProjectPeriodIncome', req)
      let res = data.Result_Data.List[0]
      console.log('res3232',res)
      this.actuaryData = res

      if(res.AllowSettlement===1){
        this.lastMonthIsOver = true
      }else if(res.AllowSettlement===2){
        this.lastMonthIsOver = false
        this.LastSettlementMonth = `${res.LastSettlementMonth}审结中月度结算正在审批中，请审结后再发起${req.StatisticsMonth}月度结算`
      }else{
        this.lastMonthIsOver = false
        if(res.LastSettlementState===0){
          // this.LastSettlementMonth =`请先进行${res.LastSettlementMonth}月度结算`
          this.LastSettlementMonth = res.LastSettlementMonth
        }else if(res.LastSettlementState===1){
          // this.LastSettlementMonth =`请先进行${res.LastSettlementMonth}月度结算`
          this.LastSettlementMonth = res.LastSettlementMonth
        }else if(res.LastSettlementState===2){
          // this.LastSettlementMonth =`请先进行${res.LastSettlementMonth}月度结算正在审批中，请审结后再发起下一个月度结算`
          this.LastSettlementMonth = res.LastSettlementMonth
        }
      }
      uni.hideLoading()
    },
    // 下一环节审批人
    changeNextPerson(e){
      console.log('e',e)
      let value = Number(e.target.value)
      this.nextPersonIndex = value
      this.nextPersonValue = this.nextPerson[value].value
      this.nextPersonLabel = this.nextPerson[value].label
    },
    // 驳回的选择
    changeReject(e){
      console.log('e',e)
      console.log('this.rejectDataList',this.rejectDataList)
      let res = JSON.parse(this.rejectDataList[Number(e.target.value)].value)
      console.log('res',res)
      this.showRejectText = res.APPROVALROUTE_NAME
      this.rejectSelectValue = res
    },
    closePop(){
      this.showPop = false
      this.showType = 0
      this.approveDesc = ''
      this.nextPersonIndex = ''
      this.nextPersonLabel = ''
      this.nextPersonValue = ''
      this.isPending = false
    },
    // 1审核 2驳回
    handleShowPop(type){
      if(!this.isShowBtn){
        uni.showToast({
          title: '无审批权限！',
          icon:'error',
          duration: 1000
        });
        return
      }
      this.showPop = true
      this.showType = type
      if(type===1){
        this.approveDesc = '已核对，拟同意！'
      }else{
        this.approveDesc = ''
      }
    },
    // 1审核 2驳回
    async handleExamine(type){
      if(this.isPending){
        return
      }
      this.isPending = true
      let req = {}
      let data = {}
      if(type===1){
        if(!this.approveDesc ){
          uni.showToast({
            title: '请输入审核意见',
            icon:'error',
            duration: 1000
          });
          return
        }
        if(!this.nextPersonValue && this.progressObjDetail.NEXT_STATE!==9000){
          uni.showToast({
            title: '请选择下一审批人',
            icon:'error',
            duration: 1000
          });
          return
        }
        uni.showLoading({
          title: '发起申请...'
        })
        let [APPOVED_NAME,APPOVED_IDS] = this.nextPersonValue.split('-')
        req = {
          businessApprovalID: this.detailObj.BUSINESSAPPROVAL_ID,
          curProinstState: this.progressDetail.BUSINESSAPPROVAL_STATE,
          approveedInfo: this.approveDesc ,
          approveedStaffId: Store.state.userData.UserId,
          approveedStaffName: Store.state.userData.UserName,
          nextId: APPOVED_IDS
        }
        if (this.detailObj.SETTLEMENT_TYPE === 2) {
          data = await request.$webGet('EShangApiMain/Finance/ApproveMonthAccountProinst', req)
        }else{
          data = await request.$webGet('EShangApiMain/Finance/ApproveAccountProinst', req)
        }
        console.log('data',data)
      }else if(type===2){
        if(!this.rejectSelectValue){
          uni.showToast({
            title: '请选择回退状态',
            icon:'error',
            duration: 1000
          });
          return
        }
        if(!this.approveDesc){
          uni.showToast({
            title: '请输入审核意见',
            icon:'error',
            duration: 1000
          });
          return
        }
        uni.showLoading({
          title: '发起申请...'
        })
        req = {
          businessApprovalID: this.detailObj.BUSINESSAPPROVAL_ID,
          approveedStaffId: this.rejectSelectValue.APPROVALSTAFF_ID,
          approveedStaffName: this.rejectSelectValue.APPROVALSTAFF_NAME,
          approveedInfo: this.approveDesc,
          targetProinstState: this.rejectSelectValue.APPROVALROUTE_STATE
        }
        if (this.detailObj.SETTLEMENT_TYPE === 2) {
          data = await request.$webGet('EShangApiMain/Finance/RejectMonthAccountProinst', req)
        }else{
          data = await request.$webGet('EShangApiMain/Finance/RejectAccountProinst', req)
        }
        console.log('data',data)
      }
      uni.hideLoading()
      if(data.Result_Code===100){
        uni.showToast({
          title: data.Result_Desc,
          icon:'none',
          duration: 2000
        });
        if (this.isPush) {
          setTimeout(()=>{
            uni.setStorageSync('reolad','true')
            uni.redirectTo({
              url: '/pages/settlementApproval/index'
            });
          },2000)
        }else{
          setTimeout(()=>{
            uni.setStorageSync('reolad','true')
            uni.navigateBack({
              delta: 1
            });
          },2000)
        }


      }else{
        uni.showToast({
          title: data.Result_Desc,
          icon:'error',
          duration: 2000
        });
      }
      this.isPending = false
    },
    // 流程 下一环节 等数据
    async handleGetProgress(){
      if(!this.detailObj.BUSINESSAPPROVAL_ID){
        const req = {
          OperationType: this.detailObj.SETTLEMENT_TYPE===1?'11':'12',
          CurState: 1000,
          IsValid: 1,
          ShowApprovalUser: true,
          ServerpartIds: this.detailObj.SERVERPART_ID || '',
          ShopIds: this.detailObj.SERVERPARTSHOP_ID || ''
        }
        const data = await request.$webGet('EShangApiMain/BusinessProcess/GetAPPROVALROUTEDetail', req)
        console.log('handleGetProgress',data)
        let res = data.Result_Data
        if(res.UserList && res.UserList.length>0){
          let list = []
          res.UserList.forEach(item=>{
            list.push({ label: item.USER_NAME, value: `${item.USER_NAME}-${item.USER_ID}` })
          })
          this.nextPerson = list
          if (list && list.length > 0 && list.length === 1) {
            this.nextPersonIndex = 0
            this.nextPersonValue = list[0].value
          }
        }
        return
      }
      const req = {
        BUSINESSAPPROVALId: this.detailObj.BUSINESSAPPROVAL_ID
      }
      uni.showLoading({
        title: '请求流程数据...'
      })
      const data = await request.$webGet('EShangApiMain/BusinessProcess/GetBUSINESSAPPROVALDetail', req)
      let res = data.Result_Data
      console.log('res',res)
      const secondReq = {
        OperationType: this.detailObj.SETTLEMENT_TYPE===1?'11':'12',
        CurState: res.BUSINESSAPPROVAL_STATE,
        IsValid: 1,
        ShowApprovalUser: true,
        ServerpartIds: this.detailObj.SERVERPART_ID || '',
        ShopIds: this.detailObj.SERVERPARTSHOP_ID || ''
      }
      const secondData = await request.$webGet('EShangApiMain/BusinessProcess/GetAPPROVALROUTEDetail', secondReq)
      this.progressObjDetail = secondData.Result_Data
      console.log('secondData',secondData)

      this.progressDetail = res
      console.log('Store.state.userData.UserId',Store.state.userData.UserId)
      console.log('res.APPOVED_IDS',res.APPOVED_IDS)
      if(Number(res.APPOVED_IDS) === Number(Store.state.userData.UserId)){
        this.isShowBtn = true
      }
      this.progressList = res.approveList
      this.progressList.unshift({
        APPLYAPPROVE_NAME: '服务区经营主管',
        APPLYAPPROVE_DATE:res.BUSINESS_STARTDATE,
        STAFF_NAME:res.STAFF_NAME,
        APPLYAPPROVE_INFO: res.BUSINESSAPPROVAL_DESC
      })
      let list = []
      if(res.UserList && res.UserList.length>0){
        res.UserList.forEach(item=>{
          // list.push({label: item.USER_NAME,value: item.USER_ID})
          list.push({label: item.USER_NAME,value: `${item.USER_NAME}-${item.USER_ID}`})
        })
      }

      this.nextPerson = list
      console.log('this.nextPerson',this.nextPerson)


      let rejectList = []
      if(res.rejectList && res.rejectList.length>0){
        res.rejectList.forEach((item) => {
          rejectList.push({ label: item.APPROVALROUTE_NAME, value: JSON.stringify(item) })
        })
      }

      this.rejectDataList = rejectList
      console.log('this.rejectDataList',this.rejectDataList)
      uni.hideLoading()
    }
  }
}
</script>

<style scoped lang="scss">
.main{
  .pageTitle{
    width: 100%;
    box-sizing: border-box;
    padding: 16rpx 16rpx 0;
    font-size: 32rpx;
  }
  .detailBox{
    width: 100%;
    box-sizing: border-box;
    padding: 0 16rpx 16rpx;
    margin-top: 16rpx;
    background: #fff;
    .detailRow{
      display: flex;
      align-items: center;
      justify-content: space-between;
      .detailItem{
        width: 50%;
        display: flex;
        justify-content: flex-start;
        .label{
          color: #ADB2BF;
          font-size: 26rpx;
        }
        .value{
          font-size: 26rpx;
        }
      }
      .detailAllItem{
        width: 100%;
        .label{
          color: #ADB2BF;
          font-size: 26rpx;
        }
      }
    }
  }

  .tableBox{
    margin-top: 24rpx;
    background: #fff;
    box-sizing: border-box;
    width: 100%;
    padding: 16rpx;
    .smallTitle{
      font-size: 26rpx;
      font-weight: 600;
      margin-bottom: 16rpx;
    }
    .line{
      height: 2rpx;
      width: 100%;
      background-color: #eee;
      margin-bottom: 18rpx;
      margin-top: 16rpx;
    }
    .rowItemBox{
      display: flex;
      .allRowItem{
        width: 100%;
        .label{
          color: #ADB2BF;
          font-size: 26rpx;
        }
        .value{
          font-size: 26rpx;
        }
      }
      .rowItem{
        width: 50%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        .label{
          color: #ADB2BF;
          font-size: 26rpx;
        }
        .value{
          font-size: 26rpx;
        }
        .imgIcon{
          width: 50rpx;
          height: 32rpx;
          border-radius: 50%;
        }
      }
    }
    .getMoreBox{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      .imgIcon{
        width: 50rpx;
        height: 32rpx;
        border-radius: 50%;
        transform: rotate(90deg);
      }
    }
    .compareBox{
      width: 100%;
      display: flex;
      .compareBoxItem{
        width: 50%;
        .smallTitle{
          font-size: 26rpx;
          font-weight: 600;
          margin-bottom: 16rpx;
        }
        .rowItemBox{
          display: flex;
          .allRowItem{
            width: 100%;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
          }
          .rowItem{
            width: 50%;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
            .imgIcon{
              width: 50rpx;
              height: 32rpx;
              border-radius: 50%;
            }
          }
        }
      }
    }


    .comparedBox{
      width: 100%;
      .comparedBoxTitleBox{
        margin-bottom: 16rpx;
        display: flex;
        align-items: center;
        .beforeTitleBox{
          width: 60%;
          font-size: 26rpx;
          font-weight: 600;
          text-align: left;
        }
        .afterTitleBox{
          width: 40%;
          font-size: 26rpx;
          font-weight: 600;
          text-align: right;
        }
      }
      .comparedItem{
        width: 100%;
        display: flex;
        align-items: center;
        margin-bottom: 12rpx;
        .compareLabel{
          width: 30%;
          color: #ADB2BF;
          font-size: 26rpx;
        }
        .beforeItem{
          width: 30%;
          font-size: 26rpx;
          text-align: right;
        }
        .afterItem{
          width: 40%;
          font-size: 26rpx;
          text-align: right;
        }
      }
    }
  }

  .btnBox{
    width: 100%;
    background: #fff;
    box-sizing: border-box;
    padding: 16rpx;
    margin-top: 24rpx;
    .detailTopBox{
      width: 100%;
      box-sizing: border-box;
      padding: 0 16rpx;
      display: flex;
      justify-content: space-between;
      .leftTop,.rightTop{
        display: flex;
        align-items: center;
        .label{
          color: #888;
        }
        .value{
          margin-left: 8rpx;
        }
      }
    }
    .detailBox{
      width: calc(100% - 32rpx);
      box-shadow: 0px 0 6rpx 2rpx rgb(234, 234, 234);
      background-color: #fff;
      border-radius: 8rpx;
      margin-left: 16rpx;
      box-sizing: border-box;
      padding: 16rpx;
      .detailItem{
        margin-bottom: 16rpx;
        .label{
          color: #888;
        }
        .value{

        }
      }
    }
    .btnList{
      width: 100%;
      box-sizing: border-box;
      padding: 32rpx 32rpx;
      display: flex;
      align-items: center;
      justify-content: space-around;
      .btnItem{
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        .iconBox{
          width: 100rpx;
          height: 100rpx;
          border-radius: 50%;
          overflow: hidden;
          .itemIcon{
            width: 100%;
            height: 100%;
          }
        }

      }
    }
  }

  .progressBox{
    width: 100%;
    box-sizing: border-box;
    padding: 32rpx;
    background: #fff;
    margin-top: 24rpx;
    .progressTopBox{
      width: 100%;
      position: relative;
      margin-bottom: 16rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .progressTitle{
      }
      .getMoreIcon{
        width: 30rpx;
        height: 30rpx;
      }

    }
    .detailTopBox{
      width: 100%;
      box-sizing: border-box;
      //padding: 0 16rpx;
      display: flex;
      justify-content: space-between;
      .leftTop,.rightTop{
        display: flex;
        align-items: center;
        .label{
          color: #888;
          font-size: 26rpx;
        }
        .value{
          margin-left: 8rpx;
          font-size: 26rpx;
        }
      }
    }
    .progressList{
      width: 100%;
      margin-top: 24rpx;
      .progressItem{
        width: 100%;
        .progressItemTop{
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .progressItemTopLeft{
            display: flex;
            align-items: center;
            .progressIcon{
              width: 20rpx;
              height: 20rpx;
            }
            .progressValue{
              font-size: 26rpx;
            }
          }
          .progressItemTopRight{
            font-size: 26rpx;
          }
        }
        .progressItemBottom{
          width: 100%;
          display: flex;
          align-items: center;
          .progressItemBottomLeft{
            font-size: 26rpx;
          }
          .progressItemBottomRight{
            flex: 1;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
          }
        }
      }
    }
  }

  .uniPopup{
    width: calc(100vw - 140rpx);
    height: 250px;
    box-sizing: border-box;
    padding: 32rpx 0;
    .uniPopupTop{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .uniPopupTitle{
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 32rpx;
        color: #160002;
        line-height: 44rpx;
        text-align: left;
        font-style: normal;
      }
      .close{
        width: 40rpx;
        height: 40rpx;
      }
    }

    .detailBox{
      margin-top: 24rpx;
      width: calc(100% - 32rpx);
      box-shadow: 0px 0 6rpx 2rpx rgb(234, 234, 234);
      background-color: #fff;
      border-radius: 8rpx;
      margin-left: 16rpx;
      box-sizing: border-box;
      padding: 16rpx;
      .detailItem{
        margin-bottom: 16rpx;
        .label{
          color: #888;
        }
      }
    }

    .btn{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      .btnItem{
        display: inline-block;
        padding: 6rpx 24rpx;
        margin-top: 24rpx;
        border-radius: 8rpx;
        background: #1890FF;
        color: #fff;
      }
    }
  }


  .uniPopupApplyFor{
    width: calc(100vw - 140rpx);
    height: 500px;
    box-sizing: border-box;
    padding: 32rpx 0;
    .uniPopupTop{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .uniPopupTitle{
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 32rpx;
        color: #160002;
        line-height: 44rpx;
        text-align: left;
        font-style: normal;
      }
      .close{
        width: 40rpx;
        height: 40rpx;
      }
    }

    .detailBoxApplyFor{
      .smallTitle{
        font-size: 26rpx;
        font-weight: 600;
        margin-bottom: 16rpx;
      }
      .tableRow{
        .rowItemBox{
          display: flex;
          .allRowItem{
            width: 100%;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
          }
          .rowItem{
            width: 50%;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
            .imgIcon{
              width: 50rpx;
              height: 32rpx;
              border-radius: 50%;
            }
          }
          .rowItemSpecial{
            display: flex;
            justify-content: flex-start;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
          }
        }

      }
    }

    .goRightBox{
      margin-top: 40rpx;
      display: flex;
      justify-content: space-around;
      .commodityContent {
        box-sizing: border-box;
        display: flex;
        align-items: center;
        width: 180rpx;
        justify-content: center;
        /* padding-top: 6rpx; */
        box-shadow: 0px 1rpx 8rpx 0.4rpx #ccc;
        flex-direction: column;
        border-radius: 4rpx;
        .color1{

        }
      }

      .commodityContent>div {
        background: url('/static/images/effective/sjjy_jb.png') no-repeat center;
        width: 100%;
        text-align: center;
        background-size: contain;
      }
      .commodityContent-cashpay {

        justify-content: flex-start;
        box-shadow: unset;
        display: flex;

      }
    }
    .btn{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      .btnItem{
        display: inline-block;
        padding: 6rpx 24rpx;
        margin-top: 24rpx;
        border-radius: 8rpx;
        background: #1890FF;
        color: #fff;
      }
    }

    .line{
      height: 2rpx;
      width: 100%;
      background-color: #eee;
      margin-bottom: 18rpx;
      margin-top: 16rpx;
    }
  }


  .uniPopupShowSelect{
    width: calc(100vw - 140rpx);
    height: 350px;
    box-sizing: border-box;
    padding: 32rpx 0;
    .uniPopupTop{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .uniPopupTitle{
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 32rpx;
        color: #160002;
        line-height: 44rpx;
        text-align: left;
        font-style: normal;
      }
      .close{
        width: 40rpx;
        height: 40rpx;
      }
    }

    .uniPopupContent{
      .contentItem{
        .label{
          font-size: 16px;
          font-weight: 600;
        }
        .text-area-box{
          width: 100%;
          background: #F2F4F5;
          border-radius: 8rpx;
          box-sizing: border-box;
          padding: 24rpx;
        }
      }
      .btn{
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        .btnItem{
          display: inline-block;
          padding: 6rpx 24rpx;
          margin-top: 24rpx;
          border-radius: 8rpx;
          background: #1890FF;
          color: #fff;
        }
      }
    }
  }

  .uniPopupYearApplyFor{
    width: calc(100vw - 140rpx);
    height: 480px;
    box-sizing: border-box;
    padding: 32rpx 0;
    .uniPopupTop{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .uniPopupTitle{
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 32rpx;
        color: #160002;
        line-height: 44rpx;
        text-align: left;
        font-style: normal;
      }
      .close{
        width: 40rpx;
        height: 40rpx;
      }
    }

    .detailBoxApplyFor{
      .smallTitle{
        font-size: 26rpx;
        font-weight: 600;
        margin-bottom: 16rpx;
      }
      .tableRow{
        .rowItemBox{
          display: flex;
          .allRowItem{
            width: 100%;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
          }
          .rowItem{
            width: 50%;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
            .imgIcon{
              width: 50rpx;
              height: 32rpx;
              border-radius: 50%;
            }
          }
          .rowItemSpecial{
            display: flex;
            justify-content: flex-start;
            .label{
              color: #ADB2BF;
              font-size: 26rpx;
            }
            .value{
              font-size: 26rpx;
            }
          }
        }
      }
    }
  }
}
</style>
