/**模板
 *
 */
import addressAnalysis from '@/blocks/addressAnalysis/index.addressAnalysis.vue' // 地址解析
export default {
  components: { addressAnalysis },
  data() {
    return {
      addressAnalysisShow: false,
      addressType: 'consignor',
      addressData: {
        address: '',
        longitude: '',
        latitude:'',
      }, // 新增修改时带过去的经纬度、地址信息
      addressSearchData: {}, // 列表点击地址解析时的查询传参
    }
  },
  methods: {
    mapPase(type, selectedRowKeys) {
      this.addressData = {}

      if (selectedRowKeys.length > 0) {
        if (type == 'consignor') {
          let cargoOwnerIds = selectedRowKeys.map((str) => {
            return {
              cargoOwnerId: str,
            }
          })
          this.addressSearchData = { cargoOwnerIds, search: '' }
        }
        this.addressType = type
      }
      this.addressAnalysisShow = true
    },
    addressBack() {
      let formName = ''
      this.addressAnalysisShow = false
      if (this.addressType == 'consignor') {
        formName = 'main'
      }
      this.$nextTick(() => {
        this.$refs[formName + 'Table'].reload().then(() => {})
      })
      //supplier=供应商,shipper=发货方
    },
    onShowMap(form) {

      this.addressSearchData = {}
      this.addressData = {}
      this.addressAnalysisShow = true
      let obj = form.getFieldsValue(['address', 'longitude', 'latitude'])
      if (obj.address) {
        this.addressData = obj
      } else {
        this.addressData = {}
      }
    },
    onMapReturnData(data) {
      let form = this.$refs.formDetails.form()
      form.setFieldsValue(data)
      this.addressAnalysisShow = false
    },
  },
}
