<template>
  <div class="exp-form">
    <van-collapse v-model="activeNames">
      <van-collapse-item title="基础信息" name="1">
        <van-field v-model="form.prepaymentNo" label="退款编号" readonly />
        <van-field v-model="form.retreatDt" label="退款日期" readonly />
        <van-field v-model="form.payMthStr" label="退款方式" readonly :formatter="formatter"/>
        <van-field v-model="form.tradePartnerCode" label="客户编码" readonly />
        <van-field v-model="form.tradePartnerName" label="客户名称" readonly />
        <van-field v-model="form.procAmt" label="退款金额" readonly />
        <van-field v-model="form.receiptCode" label="收款收条号" readonly />
        <van-field v-model="form.subReceiptCode" label="子收条号" readonly />
        <van-field v-model="form.accountNo" label="收款账号" readonly />
        <van-field v-model="form.bankNo" label="开户联行号" readonly />
        <van-field v-model="form.bankNm" label="开户行" readonly />
        <van-field v-model="form.payProvStr" label="省" readonly :formatter="formatterProvice"/>
        <van-field v-model="form.payCity" label="市" readonly />
        <van-field v-model="form.remarks" label="备注" readonly />
      </van-collapse-item>

    </van-collapse>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
import { useRouter, useRoute } from 'vue-router'
	import { showToast, showDialog, showLoadingToast, showSuccessToast, closeToast } from 'vant'
const { proxy } = getCurrentInstance()

import {
  useWorkflowStore
} from "@/stores/workflow"

import { AddressList , PickerGroup ,showFailToast } from 'vant';
const workflow = useWorkflowStore()
const route = useRoute()
onMounted(() => {
  workflow.setWorkId(route.query.workId);
  getTableData()
  dictData()
})

const activeNames = ref(['1'])

const form = ref({
  id: '',
  signReqNm: '',
  signDt: '',
  otherInformation: '',
  estProfit: null,
  ProcessInstanceSts: '',

  addDeptName: '',
  addTime: '',
  workModel: {
    flowStatusName: ''
  }
})

const getTableData = () => {
  var url = 'sal/SalPrepayRetreat/queryByWorkId'

  var param = {
    id: workflow.workId
  }

  proxy.$axios.get(url, param).then((response:any) => {
    if (response.data.code == '0') {
      form.value = response.data.data
      form.value.payMthStr = form.value.payMth
      form.value.payProvStr = form.value.payProv
    } else {
      showFailToast('操作失败！' + response.data.msg);
    }
  })
}

const tableDataMx = ref([])

const formatter = () => {
  var re = ''
  if (dictList.value.COM_PAY_MTH){
    for (var i =0 ; i < dictList.value.COM_PAY_MTH.length ; i++){
      if (form.value.payMth == dictList.value.COM_PAY_MTH[i].dicCode){
        re =  dictList.value.COM_PAY_MTH[i].dicName
        form.value.payMthStr = re
        break;
      }
    }
  }
  return form.value.payMthStr
}
const formatterProvice = () => {
  var re = ''
  if (dictList.value.PROVINCE_CODE){
    for (var i =0 ; i < dictList.value.PROVINCE_CODE.length ; i++){
      if (form.value.payProv == dictList.value.PROVINCE_CODE[i].dicCode){
        re =  dictList.value.PROVINCE_CODE[i].dicName
        form.value.payProvStr = re
        break;
      }
    }
  }
  return form.value.payProvStr
}
const dictList = ref({})
const dictData = () => {
  var url = 'framework/Common/querySelectorList'
  var param = {
    type: JSON.stringify([ 'MEASURING_UNIT' ,'COM_PAY_MTH' , 'PROVINCE_CODE'])
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      dictList.value = response.data.data
    } else {
      showFailToast('操作失败！' + response.data.msg);
    }
  })

}


</script>

<style lang="scss" scoped>
.exp-form {
  background: #f7f8fa;
  padding-bottom: 20px;
}
.padd{
  padding: 3px;
}


.van-collapse-item {
  padding: 10px;
  border-radius: 45px !important;

  .van-cell--clickable {
    border-radius: 10px 10px 0 0;
  }
}

:deep .van-cell {
  border-radius: 10px 10px 0 0;
}

:deep .van-collapse-item__wrapper {
  border-radius: 0 0 10px 10px;
}
</style>
