<!-- 委员会意见与建议列表 -->
<template>
  <div class="autoBox box1" style="position: relative; background: #f5f5f5">
    <div class="center" style="margin-top: -20px">
      <div class="left">
        <div class="centerLeft1">
          <div class="top">
            <div class="top1"></div>
            <div class="top2"></div>
            <div class="allApplication">
              <span>{{ $t("common.comments1") }}</span>
            </div>
            <div @click="back" class="more">
              <span>{{ "<" }}{{ $t("common.return") }}</span>
            </div>
          </div>
          <div class="tab">
            <div
              style="
                color: #2c558a;
                margin-top: 20px;
                padding-bottom: 10px;
                font-weight: 700;
              "
            >
              <div
                class="newsTitle"
                :class="titleIndex == 3 ? 'title1' : 'title2'"
                @click="changeTitle(3)"
              >
                {{ $t("common.proposed") }}
              </div>
              <div
                class="newsTitle"
                :class="
                  islogin ? (titleIndex == 2 ? 'title1' : 'title2') : 'title1'
                "
                @click="changeTitle(2)"
              >
                {{ $t("common.received") }}
              </div>
            </div>
            <div class="input">
              <el-input
                @clear="reset"
                @change="searchTitle"
                style="width: 261px; margin-left: 8px; margin-top: 6px"
                v-model="search"
                clearable
                :placeholder="$t('common.pleaseInput')"
              >
                <i slot="prefix" class="el-input__icon el-icon-search"></i>
              </el-input>
            </div>
          </div>
          <div class="nav">
            <!-- 我提交的 -->
            <div
              style="padding: 5px 0 0 0"
              class="cursor"
              v-show="islogin && titleIndex == 3"
            >
              <div v-if="showNav" style="width: 100%">
                <div
                  style="
                    color: #333;
                    font-size: 16px;
                    margin-bottom: 10px;
                    line-height: 29px;
                  "
                >
                  <ul>
                    <li
                      @click="submitComments(item)"
                      v-for="(item, index) in suggestionList"
                      :key="index"
                      class="content"
                    >
                      <el-card>
                        <div class="list">
                          <span class="title">{{ item.title }}</span>
                          <p class="center">{{ item.abstractInfo }}</p>
                          <span style="color: rgba(0, 0, 0, 0.65)">{{
                            item.createDate
                          }}</span>
                        </div>
                      </el-card>
                    </li>
                  </ul>
                </div>
              </div>

               <div v-else style="margin-left: 516px; margin-top: 220px">
                <el-empty :description="$t('common.noData')"></el-empty>
              </div>
            </div>
            <!--我接收的-->
            <div
              style="padding: 5px 0 0 0"
              class="cursor"
              v-show="islogin && titleIndex == 2"
            >
              <div v-if="showNav" style="width: 100%">
                <div
                  style="
                    color: #333;
                    font-size: 16px;
                    margin-bottom: 10px;
                    line-height: 29px;
                  "
                >
                  <ul>
                    <li
                      @click="receiveComment(item)"
                      v-for="(item, index) in receiveCommentsList"
                      :key="index"
                      class="content"
                    >
                      <el-card>
                        <div class="list">
                          <span class="title">{{ item.title }}</span>
                          <p class="center">{{ item.abstractInfo }}</p>
                          <span style="color: rgba(0, 0, 0, 0.65)">{{
                            item.createDate
                          }}</span>
                        </div>
                      </el-card>
                    </li>
                  </ul>
                </div>
              </div>

              <div v-else style="margin-left: 516px; margin-top: 220px">
                <el-empty :description="$t('common.noData')"></el-empty>
              </div>
            </div>
          </div>
          <!-- 分页 -->
          <div class="pag">
            <el-pagination
              type="index"
              background
              layout="prev, pager, next"
              :page-size="3"
              :total="total - 0"
              @current-change="handleCurrentChange"
            ></el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getOpinionTheSuggestionList } from "@/api/committee/committeeWorkSpace";
import Screen from "@/components/screen";
export default {
  name: "CommitteeCommentsAndSuggestions",
  props: ["isDistinguish"],
  components: {
    Screen,
  },
  data() {
    return {
      titleIndex: 3,
      islogin: true,
      commentContent: "",
      search: "",
      screen1s: {
        value: "common.type",
        item: [],
      },
      screen1def: null,
      screen2Item: null,
      receiveCommentsList: [],
      suggestionList: [],
      total: "",
      pageNo: "",
      showNav: null,
    };
  },
  watch: {
    "$i18n.locale"() {},
    CountryId() {},
  },
  mounted() {
    window.scrollTo(0, 0);
    this.initData();
  },
  destroyed() {},
  methods: {
    initData() {
      this.toObtainListViews();
    },

    // 获取意见列表
    toObtainListViews() {
      var params = this.titleIndex;
      var pageNo = this.pageNo ? this.pageNo : "1";
      var queryConditions = this.search ? this.search : "";
      if (params == "3") {
        getOpinionTheSuggestionList(params, pageNo, queryConditions).then(
          (res) => {
            var data = res.data;
            if (JSON.stringify(data) !== "{}") {
              this.suggestionList = res.data.nrcApplyQuerys;
              this.total = res.data.page.totalCount;
              this.showNav = true;
            } else {
              this.showNav = false;
            }
          }
        );
      } else if (params == "2") {
        getOpinionTheSuggestionList(params, pageNo, queryConditions).then(
          (res) => {
            var data = res.data;
            if (JSON.stringify(data) !== "{}") {
              this.receiveCommentsList = res.data.nrcApplyQuerys;
              this.total = res.data.page.totalCount;
              this.showNav = true;
            } else {
              this.showNav = false;
            }
          }
        );
      }
    },

    handleCurrentChange(val) {
      this.pageNo = val;
      this.toObtainListViews();
    },
    // 提交
    submitComments(item) {
      var params = {
        name: "submitComment",
        type: false,
        category: "3",
        id: item.id,
      };
      this.$emit("applicationType", params);
    },
    // 接收
    receiveComment(item) {
      console.log(item);
      var params = {
        name: "receiveComment",
        type: false,
        category: "2",
        id: item.id,
      };
      this.$emit("applicationType", params);
    },

    // 搜索
    searchTitle() {
      this.toObtainListViews();
    },
    reset() {
      this.toObtainListViews();
    },
    back() {
      var params = {
        name: "workspace",
        type: false,
      };
      this.$emit("applicationType", params);
    },
    screenBack() {},
    changeTitle(i) {
      this.titleIndex = i;
      this.toObtainListViews();
    },
  },
};
</script>
<style scoped>
.newsTitle {
  display: inline-block;
  /* width: 46%; */
  width: 100px;
  padding: 0 5px;
  height: 40px;
  text-align: center;
  line-height: 40px;
  border-radius: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title1 {
  background: #286fcf;
  color: #fff;
}
.title2 {
  background: #e9eef2;
  color: #286fcf;
}
.box1 {
  padding: 0 0 20px 0;
  position: absolute;
}
.center {
  display: flex;
}
.topImg img {
  display: inline-block;
  width: 1200px;
  height: 324px;
}
.centerLeft1 {
  height: 900px;
  width: 1200px;
  border-radius: 0px;
  background: #fff;
}
.centerLeft1 .tab {
  position: absolute;
  right: 100px;
  top: 70px;
  display: flex;
  align-items: center;
}
.centerLeft1 .nav {
  position: absolute;
  top: 139px;
  left: 19px;
}
.nav .content {
  width: 1160px;
  height: 187px;
  margin: 30px 0;
}
.list .title {
  font-family: "PingFang SC";
  font-style: normal;
  font-weight: 700;
  font-size: 20px;
  line-height: 22px;
  align-items: center;
  color: rgba(0, 0, 0, 0.85);
  font-feature-settings: "tnum" on, "lnum" on;
}
.list .center {
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  font-size: 14px;
  text-indent: 2em;
}
.left {
  position: relative;
}
.top .top1 {
  position: absolute;
  width: 5.5px;
  height: 10.5px;
  left: 20px;
  top: 35px;
  background: #376ac7;
  z-index: 1;
}
.top .top2 {
  position: absolute;
  width: 5.5px;
  height: 15px;
  left: 20px;
  top: 35px;
  background: #83bd50;
}
.top .allApplication {
  position: absolute;
  height: 22px;
  left: 34px;
  top: 31px;
}
.top .allApplication span {
  font-family: "PingFang SC";
  font-style: normal;
  font-weight: 600;
  font-size: 16px;
  line-height: 22px;
  color: #375586;
}
.top .notice {
  position: absolute;
  height: 22px;
  left: 160px;
  top: 32px;
}
.top .notice span {
  font-family: "PingFang SC";
  font-style: normal;
  font-weight: 600;
  font-size: 16px;
  line-height: 22px;
  color: rgba(10, 10, 10, 0.85);
}
.top .more {
  position: absolute;
  height: 16px;
  right: 21px;
  top: 31px;
}
.top .more span {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-size: 14px;
  line-height: 16px;
  color: #4790f7;
}
.pag {
  position: absolute;
  bottom: 0;
  right: 0;
}
</style>