<template>
  <van-sticky>
    <van-nav-bar>
      <template #left>
        <van-icon name="arrow-left" size="18" @click="onClickLeft" />
      </template>
      <template #title>
        <van-cell :title="toptitle"></van-cell>
      </template>
      <template #right>
        <span @click="onSelect"> 确定 </span>
      </template>
    </van-nav-bar>
  </van-sticky>
</template>
<script>
export default {
  name: "commontopbar",
};
</script>

<script setup>
import { computed, reactive } from "vue";
import { useRouter } from "vue-router";

const props = defineProps({
  showtype: String,
});
const emit = defineEmits(["commitSelect", "cancelSelect"]);

const router = useRouter();
let toptitle = computed(() => {
  if (props.showtype == "personList") {
    return "选择人员";
  }
  if (props.showtype == "addressList") {
    return "选择地点";
  }
  if (props.showtype == "deptList") {
    return "选择部门";
  }
  if (props.showtype == "unknow") {
    return "模块建设中";
  }
});
const onClickLeft = () => {
  // if (props.showtype == "personList" || props.showtype == "addressList") {
  //   emit("cancelSelect");
  // } else {
  //   history.back();
  // }
  emit("cancelSelect");
};
const onSelect = () => {
  emit("commitSelect");
};
</script>
<style scoped>
.van-nav-bar__title .van-cell {
  color: var(--van-gray-9); /* color: var(--van-primary-color); */
  font-size: var(--van-font-size-lg1);
}
</style>
