<template>
  <div class="picker-wrap">
    <div
      class="picker-wrap-txt"
      :class="{ placeholder: !String(pickerValShow) }"
      @click="show = true"
    >
      {{ pickerValShow || placeholder }}
    </div>
    <cr-popup v-model="show" position="bottom" get-container="body">
      <cr-area ref="area" :list="areaList" @cancel="onCancel" @confirm="onConfirm" />
    </cr-popup>
  </div>
</template>

<script>
import popupPickerMixin from "../mixins/popupPicker.mixin.js";
import areaList from "@qg/cherry-ui/src/area/demo/china";
export default {
  name: "PopupAreaPicker",
  mixins: [popupPickerMixin],
  data() {
    return {
      refName: "area",
      areaList
    };
  },
  methods: {
    handleResult(res) {
      let valShow = [];
      let val = [];
      res.forEach(item => {
        valShow.push(item.name);
        val.push(item.code);
      });
      this.pickerValShow = valShow.join(",");
      this.pickerVal = val;
    }
  }
};
</script>
<style lang="less">
.picker-wrap {
  width: 100%;
  &-txt {
    height: 24px;
    color: #333;
    font-size: 14px;
  }
  .placeholder {
    color: #ccc;
  }
}
</style>
