<template>
  <div class="exp-form">
    <van-collapse v-model="activeNames">
      <van-collapse-item title="基础信息" name="1">
        <van-field v-model="form.tradePartnerName" label="合作方名称" readonly />
        <van-field v-model="form.tradePartnerCode" label="合作方名编码" readonly />
        <van-field v-model="form.shortname" label="合作方简称" readonly />
        <van-field v-model="form.contryStr" label="国别" readonly :formatter="formatter"/>
        <van-field v-model="form.proviceStr" label="省份" readonly :formatter="formatterProvice"/>
        <van-field v-model="form.addr" label="地址" readonly />
        <van-field v-model="form.postcode" label="邮编" readonly />
        <van-field v-model="form.contact" label="联系人" readonly />
        <van-field v-model="form.telephone" label="电话" readonly />
        <van-field v-model="form.mobil" label="手机" readonly />
        <van-field v-model="form.fax" label="传真" readonly />
        <van-field v-model="form.email" label="电子邮件" readonly />
        <van-field v-model="form.artno" label="企业代码" readonly />
        <van-field v-model="form.artperson" label="法定代表人" readonly />
        <van-field v-model="form.taxno" label="税务登记号" readonly />
        <van-field v-model="form.tpTypeListStrDic" label="客商类别" readonly />
        <van-field v-model="form.tpStyle" label="客商性质" readonly />
        <van-field v-model="form.sfhAddr" label="收发货地点" readonly />
        <van-field v-model="form.remark" 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 = 'bas/Partner/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.contryStr = form.value.contry
      form.value.proviceStr = form.value.provice
    } else {
      showFailToast('操作失败！' + response.data.msg);
    }
  })
}

const tableDataMx = ref([])

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

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

  return form.value.proviceStr
}
const dictList = ref({})
const dictData = () => {
  var url = 'framework/Common/querySelectorList'
  var param = {
    type: JSON.stringify(['PROVINCE_CODE' ,'COUNTRY_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>
