<template>
  <view class="region-picker uni-picker">
    <view @click="handleOpenSelect">
      <view class="dropdown">
        <view class="d-text">{{cityName}}</view>
        <image src="/static/images/icon/down.png" />
      </view>
    </view>
    <cityPicker :column="column" :default-value="defaultValue" :mask-close-able="maskCloseAble" @confirm="confirm" @cancel="cancel" :visible="visible"/>
  </view>
</template>

<script>
	export default {
		props: {
			isClearSelect: {
				type: Boolean,
				default: () => false
			}
		},
		data() {
			return {
        visible: false,
        maskCloseAble: true,
        str: '',
        defaultValue: '110101',
        column: 3,
        cityName: '行政区划',
        adcd: ''
			}
		},
    watch: {
      isClearSelect(newVal) {
        if (newVal) {
          this.cityName = '行政区划'
        }
      }
    },
    methods: {
      // 展开省市区选项
      handleOpenSelect() {
        this.visible = true
      },
      cancel () {
        this.visible = false
      },
      confirm (val) {
        console.log(val)
        this.str = JSON.stringify(val)
        this.cityName = val.name
        this.adcd = val.code
        this.visible = false
        this.$emit('trigge-method', this.adcd)
      }
    }
	}
</script>

<style lang="scss" scoped>
</style>