<template>
  <u-sticky class="shadow-default" bgColor="#fff" style="top: 0">
    <u-navbar :titleStyle="{ color: '#000' }" :autoBack="true" title="选择接收人" :placeholder="true" :safeAreaInsetTop="true" bgColor="#fff">
      <template #left>
        <view class="u-navbar__content__left__item">
          <u-icon name="arrow-left" size="20" color="#000"></u-icon>
        </view>
      </template>
      <template #right>
        <view class="u-navbar__content__right__item">
          <u-icon name="more-dot-fill" size="20" color="#000"></u-icon>
        </view>
      </template>
    </u-navbar>
  </u-sticky>

  <oa-scroll
    customClass="record-container scroll-height"
    :isSticky="false"
    :customStyle="{
      //#ifdef APP-PLUS || MP-WEIXIN
      height: 'calc(100vh - 44px)',
      //#endif
    }"
    :refresherLoad="false"
    :refresherEnabled="false"
    :refresherDefaultStyle="'none'"
    :refresherThreshold="44"
    :lowerThreshold="44"
    :refresherBackground="'#f5f6f7'"
    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  >
    <template #default>
      <uni-mall-list v-if="dataList.length > 0" :dataList="dataList" :defaultHeadList="defaultHeadList" @change="handleChange" @submit="handleSubmit"></uni-mall-list>
    </template>
  </oa-scroll>
</template>

<script setup>
/*----------------------------------依赖引入-----------------------------------*/
import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
/*----------------------------------接口引入-----------------------------------*/
import { deptUserTreeSelect } from "@/api/system/user.js";
/*----------------------------------组件引入-----------------------------------*/
import uniMallList from "./components/mall-list.vue";
/*----------------------------------store引入-----------------------------------*/
/*----------------------------------公共方法引入-----------------------------------*/
import { storageSystem } from "@/utils/storage"; // 公共方法引用
/*----------------------------------公共变量-----------------------------------*/
const { proxy } = getCurrentInstance();
/*----------------------------------变量声明-----------------------------------*/
const state = reactive({
  defaultHeadList: { label: "通讯录", id: "18AF75C3-330A-53AC-270E-EAD060BC0E1A" },
  dataList: [],
});
const { defaultHeadList, dataList } = toRefs(state);

function init() {
  deptUserTreeSelect({ pageNum: "1", pageSize: "10000" }).then((res) => {
    state.dataList = JSON.parse(JSON.stringify(res.data).replace(/value/g, "id"))[0].children;
  });
}

function handleChange(item) {
  //   if (item.type === "user") {
  //     uni.navigateTo({
  //       url: "/pages/datails/datails?user=" + JSON.stringify(item),
  //     });
  //   }
}

function handleSubmit(event) {
  proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
  uni.$emit("UserMall", event); //将值存储监听器
}

onReady(() => {});

onShow(() => {});

onLoad((options) => {
  init();
});

onUnload(() => {});
</script>

<style></style>
