<template>
  <div class="common-box" style="margin-top: 20px; height: 263px">
    <div class="sys-container">
      <div
        v-for="(item, index) in sysData"
        :key="index"
        class="sys-item"
        @click="openSetPage"
      >
        <svg-icon
          :icon-class="item.icon"
          alt=""
          class="sys-item-img"
          size="60"
          style="margin-left: 35%"
        />
        <el-row>
          <el-col :span="12">
            <h3
              v-if="userStore.user.canSetPermission"
              class="sys-item-title"
              @click="gotoUserPage"
            >
              {{ item.menuName }}
            </h3>
          </el-col>
          <el-col :span="12">
            <h3
              v-if="userStore.user.canSetMessageOrg"
              class="sys-item-title"
              @click="gotoMessageOrgPage"
            >
              消息组织管理
            </h3>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <h3
              v-if="userStore.user.setRoles"
              class="sys-item-title"
              @click="gotoRolsePage"
            >
              角色管理
            </h3>
          </el-col>
          <el-col :span="12">
            <h3
              v-if="userStore.user.canSetIP"
              class="sys-item-title"
              @click="openDrawer"
            >
              配置IP地址
            </h3>
          </el-col>
          <el-col :span="12">
            <h3
              v-if="userStore.user.canFileShare"
              class="sys-item-title"
              @click="gotoFilesPage"
            >
              文件管理
            </h3>
          </el-col>
        </el-row>
      </div>
    </div>
    <el-drawer
      v-model="drawerVisible"
      :destroy-on-close="true"
      title="配置IP地址"
    >
      <Addresss @finish="saveAddressFinish" />
    </el-drawer>
  </div>
</template>

<script lang="ts" setup>
import { useUserStore } from "@/store";
import Addresss from "@/views/sets/address.vue";

const userStore = useUserStore();

const sysData = ref<any[]>([{ menuName: "用户管理", icon: "set" }]);

const openSetPage = () => {};

const drawerVisible = ref(false);
const openDrawer = () => {
  drawerVisible.value = true;
};
const saveAddressFinish = () => {
  drawerVisible.value = false;
};

const router = useRouter();
const gotoUserPage = () => {
  router.push("/users");
};

const gotoRolsePage = () => {
  router.push("/roles");
};


const gotoFilesPage = () => {
  router.push("/files");
};

const gotoMessageOrgPage = () => {
  router.push("/messageOrg");
};
</script>

<style lang="scss" scoped>
.sys-container {
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.sys-item {
  min-width: 150px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: left;

  .sys-item-img {
    width: 50px;
  }

  .sys-item-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 5px;
    cursor: pointer;
    white-space: nowrap;
  }
}

//.sys-item:hover {
//  background-color: #87cefa;
//  cursor: pointer;
//}
</style>
