<template>
  <div class="reportHistory">
    <div class="list">
      <div
        class="list-row"
        v-for="(item, index) in pageList"
        :key="index"
        @click="jumpDetailsPage(item, item.id)"
      >
        <div class="cell_1 width100">
          <div class="width100 height44rpx mb8rpx">
            <div class="report_title" @click="jumpDetailsPage(item, item.id)">
              走访类型：

              {{ getDicType(item.interviewType) }}
            </div>
          </div>
          <div class="width100 height40rpx mb8rpx">
            <div class="second_title height40rpx width100">
              是否需要处理：
              {{ item.isStatus == "1" ? "否" : "是" }}
            </div>
          </div>
          <div class="width100 height40rpx mb8rpx border_bottom_f5f5f5">
            <div class="second_title height40rpx" style="width: 100%">
              公司名称：{{ item.companyName ? item.companyName : "未知企业" }}
            </div>
          </div>
          <div
            class="width60 float_left list_date height40rpx lh40rpx margint8rpx"
          >
            {{ item.interviewTime }}
          </div>
          <div
            class="width40 float_left margint8rpx"
            v-if="
              !(
                (item.handleUserName || item.handleUserName == 'null') &&
                (item.handleResult || item.handleResult == 'null')
              )
            "
          >
            <van-button
              color="#1D18BC"
              class="colorfffff height40rpx float_right"
              size="mini"
              v-if="item.isStatus == 2"
              @click="openHandleReportDialog(item)"
            >
              处理登记
            </van-button>
          </div>
        </div>
      </div>
      <div class="list-row" v-if="pageList.length == 0">
        <van-empty
          class="disblock marginauto"
          style="background: white"
          description="暂无数据"
        />
      </div>
      <handle-report ref="handleReport" @changeActive="getInterviewList()" />
    </div>
  </div>
</template>

<script>
import vanTab from "../../../../wxcomponents/weapp/dist/tab/index";
import vanTabs from "../../../../wxcomponents/weapp/dist/tabs/index";
import vanButton from "../../../../wxcomponents/weapp/dist/button/index";
import vanEmpty from "../../../../wxcomponents/weapp/dist/empty/index";
import vanDivider from "../../../../wxcomponents/weapp/dist/divider/index";
import handleReport from "./handlereport.vue";
import { getInterviewList, getByCodes } from "@/js_sdk/http.js";
const form = {
  status: [],
  chaoxiang: [],
  statusArray: [],
  chaoxiangArray: [],
  zaitiTypeArray: [],
  roomSize1: "",
  roomSize2: "",
  guidePrice1: "",
  guidePrice2: "",
  loupan_value: null,
  groupIds: null,
  pageNum: 1,
  dic_key: ["interviewType"],
  dic_SelectList: {},
  pageSize: 10,
  total: 0,
  mnpBuildingIds: "",
};

export default {
  components: {
    vanTab,
    vanTabs,
    vanEmpty,
    vanDivider,
    vanButton,
    handleReport,
  },
  name: "reportHistoryr.vue",
  data() {
    return {
      dic_key: ["interviewType"],
      dic_SelectList: {},
      pageList: [],
      search: {
        pageSize: 10,
        pageNum: 1,
      },
    };
  },
  mounted() {
    this.getInterviewList();
    this.getByCodes();

    // this.findYuanQuList()
    // this.getByCodes()
  },
  onLoad() {
    this.getInterviewList();
  },
  methods: {
    jumpDetailsPage(item, id) {
      if (item.isStatus == 2 && !item.handleUserName && !item.handleResult) {
        return;
      }
      uni.navigateTo({
        url:
          "/pages/subPackages/companyreport/components/reportDetails?id=" + id,
      });
    },
    changeActive() {
      this.$emit("changeActive");
      // const token = uni.getStorageSync("laocui_user_info");
      // this.search.createdBy = JSON.parse(token).user.id;
      this.getInterviewList();
      this.getByCodes();
    },
    async getByCodes() {
      let data = await getByCodes(JSON.stringify(this.dic_key));
      this.dic_SelectList = this.$common.handleDicList(data);
      this.dic_SelectList.interviewType[0].id;
    },
    getDicType(value) {
      if (!value) return;

      let interviewType = this.dic_SelectList.interviewType;
      console.log(interviewType);
      let index = interviewType.findIndex((e) => e.value == value);
      if (index != -1) return interviewType[index].label;
    },
    async getMoreListData() {
      let that = this;

      that.search.pageNum = that.search.pageNum + 1;
      let list = await getInterviewList(that.search);

      if (list.rows == 0) {
        that.$showToast("没有更多数据了");
      } else {
        list.rows.forEach((e) => {
          that.pageList.push(e);
        });
      }
    },

    async getInterviewList() {
      // const token = uni.getStorageSync("laocui_user_info");
      // this.search.createdBy = JSON.parse(token).user.id;
      this.search.pageNum = 1;
      this.search.pageSize = 10;
      this.search.total = 0;
      let data = await getInterviewList(this.search);
      this.pageList = data.rows;
    },
    openHandleReportDialog(item) {
      this.$refs.handleReport.openDianlog(item);
    },
  },
};
</script>

<style lang="scss">
/deep/.van-cell {
  padding: 0 0 0 28rpx !important;
}
.inputClass {
  padding: 0 0 0 28rpx !important;
}
.reportHistory {
  .search_btn {
    margin-left: 18rpx;
    width: calc(100% - 18rpx);
    height: 60rpx;
  }
  .reset_btn {
    color: #2628a9 !important;
    width: 100%;
    height: 60rpx;
  }
  .list-row {
    width: calc(100% - 64rpx);
    padding: 32rpx;
    background: #ffffff;
    margin-bottom: 16rpx;
    display: flex;
    //height: 278rpx;
    border-radius: 8rpx 8rpx 8rpx 8rpx;
  }
  .second_title {
    float: left;
    width: 50%;

    font-size: 28rpx;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #777777;
  }

  .list {
    width: calc(100% - 64rpx);

    margin: 32rpx;
  }

  .form {
    width: calc(100% - 128rpx);
    margin: 32rpx;
    background: #ffffff;
    padding: 32rpx;

    .label {
      height: 53rpx;
      line-height: 53rpx;
    }
  }

  .checklist-box {
    margin: 0 !important;
    margin-right: 16rpx !important;
  }

  .labelcolmt26 {
    input {
      border-radius: 8rpx 8rpx 8rpx 8rpx;
      border: 2rpx solid #cccccc;
      text-align: center;
    }
    .van-col {
      margin-top: 26rpx !important;
    }

    label {
      color: #333333;
      font-size: 30rpx;
      margin-top: 10rpx !important;
    }

    .uni-data-checklist {
      margin-top: -10rpx !important;
    }
  }

  .status {
    .uni-data-checklist {
      margin-top: 0rpx !important;
    }

    label {
      color: #333333;
      font-size: 30rpx;
      padding-right: 0rpx !important;
    }
  }
}
</style>
