<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="actuaryData.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?`${$util.getMoney(actuaryData.CurMonthRevenue)}`:'-'}}</span>
          </view>
          <view class="rowItem">
            <span class="label">累计营业额：</span>
            <span class="value">{{actuaryData.REVENUEDAILY_AMOUNTTotal?`${$util.getMoney(actuaryData.REVENUEDAILY_AMOUNTTotal)}`:'-'}}</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?`${$util.getMoney(actuaryData.MOBILEPAY_AMOUNT)}`:'-'}}</span>
          </view>
          <view class="rowItem">
            <span class="label">移动冲正：</span>
            <span class="value">{{actuaryData.MOBILEPAY_CORRECT?`${$util.getMoney(actuaryData.MOBILEPAY_CORRECT)}`:'-'}}</span>
          </view>
        </view>

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

        <view class="rowItemBox">
          <view class="rowItem">
            <span class="label">提成金额：</span>
            <span class="value">{{actuaryData.GUARANTEERATIOAMOUNT?`${$util.getMoney(actuaryData.GUARANTEERATIOAMOUNT)}`:'-'}}</span>
          </view>
          <view class="rowItem">
            <span class="label">提成收入：</span>
            <span class="value">{{actuaryData.GUARANTEERATIOINCOME?`${$util.getMoney(actuaryData.GUARANTEERATIOINCOME)}`:'-'}}</span>
          </view>
        </view>
      </view>
    </view>
    <!--    月度的精算数据-->
    <view class="tableBox" v-if="actuaryData.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?`${$util.getMoney(actuaryData.CurMonthRevenue)}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.CurMonthRevenueTEXT?monthNewCalibration.CurMonthRevenueTEXT:'-'}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">累计营业额：</view>
          <view class="beforeItem">{{actuaryData.REVENUEDAILY_AMOUNTTotal?`${$util.getMoney(actuaryData.REVENUEDAILY_AMOUNTTotal)}`:'-'}}</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?`${$util.getMoney(actuaryData.MOBILEPAY_AMOUNT)}`:'-'}}</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?`${$util.getMoney(actuaryData.MOBILEPAY_CORRECT)}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.MOBILEPAY_CORRECTTEXT || ''}}</view>
        </view>

        <view class="comparedItem">
          <view class="compareLabel">现金交易：</view>
          <view class="beforeItem">{{actuaryData.CASHPAY_AMOUNT?`${$util.getMoney(actuaryData.CASHPAY_AMOUNT)}`:'-'}}</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?`${$util.getMoney(actuaryData.CASHPAY_CORRECT)}`:'-'}}</view>
          <view class="afterItem">{{monthNewCalibration.CASHPAY_CORRECTTEXT || '0'}}</view>
        </view>

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

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

    <!--    流程-->
    <view class="progressBox" >
      <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>


  </view>
</template>
<script>
import request from '@/util/index.js'
import numeral from "numeral";
import Store from "../../store/store";

export default {
  name: "monthDetail",
  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){
    if (query.id) {
      this.isPush = true
      await this.handleGetPageDetail(query.id)
    }else{
      if(query.obj){
        this.detailObj = JSON.parse(query.obj)
      }
    }
    if(query.staticMonth){
      this.staticMonth = this.$moment(query.staticMonth ).format('YYYYMM')
    }
    // 拿到顶部数据
    await this.handleGetDetailDifference()
    // 月度数据
    // 拿到月度精算数据
    await this.handleGetActuaryData()
    if (this.detailObj.BusinessApprovalId) {
      // 精算数据
      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.closeApplyFor()
    this.closeShowSelect()
  },
  methods:{
    // 推送拿到进入页面的初始参数
    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 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()
    },

    async handleGetDetail(){
      console.log('this.detailObj',this.detailObj)
      uni.showLoading({
        title: '请求月度精算数据...'
      })
      const data = await request.$webGet('EShangApiMain/BusinessProcess/GetBUSINESSAPPROVALDetail',{BUSINESSAPPROVALId: this.detailObj.BusinessApprovalId})
      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 = this.$util.getMoney(this.monthNewCalibration.REVENUEDAILY_AMOUNTTotal)
      this.monthNewCalibration.CurMonthRevenueTEXT = this.$util.getMoney(this.monthNewCalibration.CurMonthRevenue)
      this.monthNewCalibration.MOBILEPAY_AMOUNTTEXT = numeral(this.$util.getMoney(this.monthNewCalibration.MOBILEPAY_AMOUNT + (this.monthNewCalibration.MOBILEPAY_CORRECT || 0))).format('0,0.00')
      this.monthNewCalibration.MOBILEPAY_CORRECTTEXT = this.$util.getMoney(this.monthNewCalibration.MOBILEPAY_CORRECT)
      this.monthNewCalibration.CASHPAY_AMOUNTTEXT = numeral(this.$util.getMoney(this.monthNewCalibration.CASHPAY_AMOUNT + (this.monthNewCalibration.CASHPAY_CORRECT || 0))).format('0,0.00')
      this.monthNewCalibration.CASHPAY_CORRECTTEXT = this.$util.getMoney(this.monthNewCalibration.CASHPAY_CORRECT)
      this.monthNewCalibration.GUARANTEERATIOAMOUNTTEXT = this.$util.getMoney(this.monthNewCalibration.GUARANTEERATIOAMOUNT)
      this.monthNewCalibration.GUARANTEERATIOINCOMETEXT = this.$util.getMoney(this.monthNewCalibration.GUARANTEERATIOINCOME)
      console.log('this.newCalibration2', this.monthNewCalibration)
      uni.hideLoading()
    },
    // 流程 下一环节 等数据
    async handleGetProgress(){
      if(!this.detailObj.BusinessApprovalId){
        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.BusinessApprovalId
      }
      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: 4rpx 8rpx;
        margin-top: 24rpx;
        border-radius: 8rpx;
        background: #1890FF;
        color: #fff;
      }
    }
  }


  .uniPopupApplyFor{
    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;
            }
          }
        }

      }
    }

    .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: 4rpx 8rpx;
        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: 4rpx 8rpx;
          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>
