<template>
  <div class="main_box">
    <navbar :title="pageTitle"></navbar>
    <div class="wrapper">
      <div class="container-list">
        <div class="grid_item">
          <div class="grid_item_top">
            <div class="icon_box">
              <van-icon name="wap-home" class="grid_item_top_icon"></van-icon>
              <!-- <img
                    src="@/images/home/wdwg.png"
                    alt=""
                    style="width: 25px; height: 25px"
                    class="grid_item_top_icon"
                  /> -->
            </div>
            <div class="grid_item_top_title">
              <span v-if="item.activeTab == '0' && item.activeBtn == '0'"
                >{{ item.town }}-{{ item.village }}</span
              >
              <span v-if="item.activeTab == '0' && item.activeBtn == '1'"
                >{{ item.town }}</span
              >
              <span v-if="item.activeTab == '1'">{{
                item.gridName
              }}</span>
              <span v-if="item.activeTab == '2'">{{
                item.shapeName
              }}</span>
            </div>
          </div>
          <!-- 行政网格 -->
              <div class="grid_item_middle" v-if="item.activeTab == '0'">
                <div class="grid_item_middle_item">
                  <div class="middle_title">总行行政网格</div>
                  <div
                    class="middle_num"
                    @click="showNameDetail('总行行政网格', item.gridName)"
                  >
                    {{ item.gridName || "--" }}
                  </div>
                </div>
                <div class="line"></div>
                <div class="grid_item_middle_item">
                  <div class="middle_title">支行行政网格</div>
                  <div
                    class="middle_num"
                    @click="showNameDetail('支行行政网格', item.gridName2)"
                  >
                    {{ item.gridName2 || "--" }}
                  </div>
                </div>
                <div class="line"></div>
                <div class="grid_item_middle_item">
                  <div class="middle_title">归属支行</div>
                  <div
                    class="middle_num"
                    @click="showNameDetail('归属支行', item.deptName)"
                  >
                    {{ item.deptName || "--" }}
                  </div>
                </div>
              </div>
              <!-- 自定义名单 -->
              <div class="grid_item_middle" v-if="item.activeTab == '1'">
                <div class="grid_item_middle_item">
                  <div class="middle_title">网格类型</div>
                  <div class="middle_num">{{ item.gridType || "--" }}</div>
                </div>
                <div class="line"></div>
                <div class="grid_item_middle_item">
                  <div class="middle_title">归属支行</div>
                  <div
                    class="middle_num"
                    @click="showNameDetail('归属支行', item.deptName)"
                  >
                    {{ item.deptName || "--" }}
                  </div>
                </div>
                <div class="line"></div>
                <div class="grid_item_middle_item">
                  <div class="middle_title">归属网点</div>
                  <div
                    class="middle_num"
                    @click="showNameDetail('归属网点', item.outletsName)"
                  >
                    {{ item.outletsName || "--" }}
                  </div>
                </div>
              </div>
              <!-- 自定义地图 -->
              <div class="grid_item_middle" v-if="item.activeTab == '2'">
                <div class="grid_item_middle_item">
                  <div class="middle_title">区域类型</div>
                  <div class="middle_num" @click="showNameDetail('区域类型', item.shapeType)">{{ item.shapeType || "--" }}</div>
                </div>
                <div class="line"></div>
                <div class="grid_item_middle_item">
                  <div class="middle_title">网格名称</div>
                  <div
                    class="middle_num"
                    @click="showNameDetail('网格名称', item.gridName)"
                  >
                    {{ item.gridName || "--" }}
                  </div>
                </div>
                <div class="line"></div>
                <div class="grid_item_middle_item">
                  <div class="middle_title">归属支行</div>
                  <div
                    class="middle_num"
                    @click="showNameDetail('归属支行', item.deptName)"
                  >
                    {{ item.deptName || "--" }}
                  </div>
                </div>
              </div>
              <div class="grid_item_bottom">
                <div class="grid_item_bottom_item" v-if="item.activeTab == '0' || item.activeTab == '2'">
                  <span class="bottom_item_left">归属网点：</span>
                  <span class="bottom_item_right" @click="showNameDetail('归属网点', item.outletsName)">{{ item.outletsName }}</span>
                </div>
                <div class="grid_item_bottom_item" v-if="item.activeTab == '1'">
                  <span class="bottom_item_left">网格创建者：</span>
                  <span>{{ item.createBy }}</span>
                </div>
                <div class="grid_item_bottom_item">
                  <span class="bottom_item_left">归属客户经理：</span>
                  <span class="bottom_item_right" @click="showNameDetail('归属客户经理', item.userName)">{{ item.userName }}</span>
                </div>
                <div class="grid_item_bottom_item">
                  <span class="bottom_item_left">统计日期：</span>
                  <span>{{ item.dt }}</span>
                </div>
              </div>
        </div>
      </div>
      <div class="content-box">
        <div class="item-box" v-for="(i, index) in tableColumn" :key="index">
          <span class="item-left">{{ i.label }}</span>
          <span class="item-right">{{ item[i.prop] }}</span>
        </div>
      </div>
    </div>
    <van-dialog
      class-name="myDialog"
      v-model="showDialog"
      :title="title + '详情'"
      confirm-button-text="关闭"
      confirm-button-color=""
    >
      <div class="content">
        <div class="my-title">{{ title }}名称:</div>
        <div class="grid-box">
          <div v-for="(item, index) in nameDetail" :key="index" class="item">
            <span class="index">{{ index + 1 }}</span>
            <span class="branch-name">{{ item }}</span>
          </div>
        </div>
      </div>
    </van-dialog>
  </div>
</template>
<script>
import navbar from "@/components/navbar/navbar.vue";
import {} from "@/service/api/dataCenter.js";
import {
  privateColumns,
  publicColumns,
  privateColumnsNm,
  publicColumnsNm,
  privateColumnsMap,
  publicColumnsMap,
} from "./list";
import {
  Tab,
  Tabs,
  Icon,
  Button,
  Search,
  RadioGroup,
  Radio,
  List,
  PullRefresh,
  Dialog,
  Toast,
} from "vant";
export default {
  props: {},
  data() {
    return {
      item: {},
      pageTitle: "",
      tableColumn: [],
      showDialog: false,
      nameDetail: [],
      title: "",
    };
  },
  components: {
    navbar: navbar,
    VanTab: Tab,
    VanTabs: Tabs,
    VanIcon: Icon,
    VanButton: Button,
    VanSearch: Search,
    VanRadioGroup: RadioGroup,
    VanRadio: Radio,
    VanList: List,
    VanPullRefresh: PullRefresh,
    VanToast: Toast,
    [Dialog.Component.name]: Dialog.Component,
  },

  created() {
    const item = JSON.parse(sessionStorage.getItem("gridTotalInfo") || "{}");
    this.item = item;
    this.pageTitle = item.gridTitle;
    this.tableColumn =
      item.activeBtn == "0"
        ? item.activeTab == "0"
          ? privateColumns
          : item.activeTab == "1"
          ? privateColumnsNm
          : privateColumnsMap
        : item.activeTab == "0"
        ? publicColumns
        : item.activeTab == "1"
        ? publicColumnsNm
        : publicColumnsMap;
  },
  methods: {
    showNameDetail(title, nameDetail) {
      if (!nameDetail) return;
      this.showDialog = true;
      this.title = title;
      this.nameDetail = nameDetail.split(",");
    },
  },
};
</script>
<style lang="less" scoped>
.main_box {
  position: relative;
  .backTop {
    position: fixed;
    bottom: 150px;
    right: 15px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #4682ff;
    box-shadow: 0px -2px 6px 0px rgba(70, 130, 255, 1);
    color: #fff;
    transform: rotate(180deg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    .heng {
      display: block;
      width: 15px;
      border: 1px solid #fff;
    }
  }
  .wrapper {
    padding-top: 46px;
    min-height: 100vh;
    font-size: 16px;
    padding-bottom: 60px;
  }
}
.wrapper_top {
  background-color: #fff;
  padding: 15px 20px;
}

.radio_box {
  display: flex;
  align-items: center;
  margin: 15px 0 15px 15px;
}

.btn_box {
  padding: 8px 16px;
  background-color: #fff;
}

.isChecked {
  background-color: rgb(35, 114, 235);
  color: #fff;
  border-radius: 4px;
}
.grid_item {
  margin-top: 8px;
  padding: 10px 15px;
  background-color: #fff;
}
.grid_item_top {
  display: flex;
  align-items: center;
}
.icon_box {
  background-color: rgb(35, 114, 235);
  border-radius: 4px;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.grid_item_top_icon {
  font-size: 16px;
  color: #fff;
}
.grid_item_top_title {
  font-size: 16px;
  font-weight: 600;
  margin-left: 10px;
}
.grid_item_middle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgb(249, 249, 251);
  padding: 10px 15px;
  margin-top: 10px;
}
.grid_item_middle_item {
  width: 30%;
  text-align: center;
}
.middle_num {
  margin-top: 10px;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.middle_title {
  font-size: 12px;
}
.line {
  width: 1px;
  height: 30px;
  background-color: rgb(255, 255, 255);
  border: 1px solid rgb(218, 220, 224);
}
.grid_item_bottom {
  margin-top: 8px;
  font-size: 12px;
}
.grid_item_bottom_item {
  display: flex;
  align-items: center;
  margin-top: 5px;
  .branch-detail {
    color: #4886f8;
    margin-left: 5px;
  }
  .bottom_item_right {
    display: inline-block;
    max-width: calc(100% - 90px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.bottom_item_left {
  color: rgb(140, 140, 140);
}

.content-box {
  background: #fff;
  margin-top: 10px;
  // padding: 0 16px;
  .item-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 14px;
    height: 43px;
    border-bottom: 1px solid #ddd;
    &:last-child {
      border-bottom: none;
    }
    .item-left {
      color: #8c8c8c;
    }
    .item-right {
      color: #595959;
    }
  }
}
.myDialog {
  .content {
    padding: 5px 15px;
    .my-title {
      font-size: 14px;
      color: rgba(0, 0, 0, 0.45);
    }
    .item {
      margin: 8px 0;
      .index {
        display: inline-block;
        width: 16px;
        height: 16px;
        background: rgba(22, 132, 252, 1);
        color: #fff;
        border-radius: 4px;
        font-size: 14px;
        text-align: center;
        line-height: 16px;
      }
      .branch-name {
        font-size: 14px;
        color: rgba(0, 0, 0, 0.85);
        margin-left: 5px;
      }
    }
    .grid-box {
      max-height: 150px;
      overflow-y: auto;
    }
  }
  ::v-deep .van-button__content {
    color: #666;
  }
}
</style>