<template>
  <div class="modifysend">
    <!-- <van-tabs :active="active" @change="getSelectedLoudong"> -->
    <!-- <van-tab title="全部" name=""> </van-tab>
      <van-tab
        v-for="(
          item, index
        ) in dic_SelectList.rectification_management_update_type"
        :title="item.label"
        :name="item.value"
        :key="index"
      >
      </van-tab>
    </van-tabs> -->
    <!-- 
    <div class="top-add" @click="goNavigator()">
      <i class="iconfont icon-xinzeng"></i>
      <span class="txt">新增整改</span>
    </div> -->

    <div class="info-findRectificationManagementInOutList">
      <van-list
        v-model="isUpLoading"
        :finished="upFinished"
        :immediate-check="false"
        :offset="10"
        finished-text="加载完成"
        @load="onLoadList"
      >
        <div class="info-item" v-for="item in recordList" :key="item.id">
          <div class="info-bottom" v-if="item.recheckId">
            <div class="left"></div>
            <div class="right">
              <span class="normal-tip yd h-bg"> 多次整改 </span>
            </div>
          </div>
          <div class="info-top">
            <div
              class="left"
              @click="jumpPageDetails(item.finishType, item.id)"
            >
              <img
                :src="
                  item.infoMorePictureUrl != null &&
                  item.infoMorePictureUrl.length > 0
                    ? BASE_URI +
                      '/FileController/download/' +
                      item.infoMorePictureUrl[0]
                    : ''
                "
                alt=""
              />
            </div>
            <div
              class="right"
              @click="jumpPageDetails(item.finishType, item.id)"
            >
              <p class="tit">
                {{ item.info }}
              </p>
              <p class="txt">
                处理时间：{{ !item.finishTime ? "暂无" : item.finishTime }}
              </p>
              <p class="txt">
                确认时间：{{
                  !item.checkTime || item.checkTime == "null"
                    ? "暂无"
                    : item.checkTime
                }}
              </p>
              <p
                class="txt"
                v-if="item.finishState == 1 && item.finishType == 4"
              >
                确认结果：已完成整改
              </p>
              <p
                class="txt"
                v-if="item.finishState != 1 && item.finishType == 4"
              >
                确认结果：未完成整改
              </p>

              <!-- <p class="txt">确认时间：{{ item.checkTime }}</p> -->
            </div>
          </div>
          <div class="info-bottom">
            <div class="left" style="width: 80%">
              <i class="iconfont icon-shijian"></i>
              <span>
                {{ item.updateAddress }}
              </span>
            </div>
            <div class="right">
              <span
                v-if="item.finishType == 2"
                class="normal-tip yd h-bg pending-btn"
              >
                待处理
              </span>
              <span
                v-if="item.finishType == 3"
                class="normal-tip yd h-bg accepted-btn"
              >
                待确认
              </span>
              <span
                v-if="item.finishType == 4"
                class="normal-tip yd h-bg processed-btn"
              >
                已完成
              </span>
              <span
                v-if="item.finishType == 5"
                class="normal-tip yd h-bg processed-btn"
              >
                已退回
              </span>
            </div>
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>
      <script>
import {
  findRectificationManagementInOutList,
  getByCodes,
  getSelectUserTwo,
} from "../../service/modify-handle.js";
import auth from "@/service/auth";
// import Base from "@/pages/base/base";
export default {
  data() {
    return {
      active: "",
      upFinished: false,
      finishStateList: [
        { value: 2, text: "待处理" },
        { value: 3, text: "待确认" },
        { value: 4, text: "已完成" },
      ],
      range: [],
      isCheckList: [],
      loudongList: [
        { name: "1", title: "待派单" },
        { name: "2,3,4", title: "已派单" },
      ],
      BASE_URI: this.$constant.BASE_URI,
      dic_key: ["rectification_management_update_type"],
      dic_SelectList: {},
      recordList: [],
      params: {
        openUser: auth.currUser().id,
        updatedBy: auth.currUser().id,
        pageNum: 1,
        pageSize: 10,
        // finishTypeMore: 2,
        // updateType: 1,
      },
      totalPage: 1,
      allData: [],
      findRectificationManagementInOutList: [
        {
          title: "关于组织2020年无锡市服务业提质增效资金项目申报的通知",
          name: "无锡 XXXX有限公司",
          date: "2020-09-18 19:34:06",
          type: "1",
        },
        {
          title:
            "关于组织2020年无锡市服务业提质增效资金项目申报的通知关于组织2020年无锡市服务业提质增效资金项目申报的通知",
          name: "无锡 XXXX有限公司",
          date: "2020-09-18 19:34:06",
          type: "2",
        },
      ],
    };
  },

  mounted() {
    this.getByCodes();
  },

  methods: {
    onLoadList() {
      this.params.pageNum += 1;
      this.isDownLoading = false;
      this.selectData();
    },
    bindDateChange(e) {
      let that = this;
      that.params.needFinishTime = e.detail.value;
    },
    getIsCheckList(e) {
      let that = this;
      that.isCheckList = e.detail.value;
    },
    selectDengjiyuan(e) {
      this.form.finishUserName = e[e.length - 1].name;
      this.form.finishUser = e[e.length - 1].id;
      this.$forceUpdate();
    },
    async getSelectUserTwo(key) {
      let that = this;
      console.log(that.isCheckList);
      if (that.isCheckList.length == 0) {
        that.$showToast("请先选择要派发的整改");
        return;
      }
      let departmentList = await getSelectUserTwo("");
      that.range = tools.transData(
        departmentList.data,
        "id",
        "parentid",
        "children"
      );
      that.$refs[key]._show();
      that.$forceUpdate();
    },
    selectDengjiyuan(e) {
      var names = [];
      var ids = [];

      for (var p in e) {
        if (e[p].type == "u") {
          names.push(e[p].name);
          ids.push(e[p].id);
        }
      }

      this.form.xinxidengji = names.join(",");
      this.form.manageMessengerId = ids.join(",");
    },
    getSelectedLoudong(event) {
      console.log(event);
      let that = this;
      // that.active = event.detail.name;
      that.params.updateType = event == "null" ? "" : event;
      that.selectData();
    },
    // goNavigator(id) {
    //   uni.navigateTo({
    //     url: "/pages/subPackages/modifyReport/add",
    //   });
    // },
    jumpPageDetails(type, id) {
      console.log(id);
      if (type == 3) {
        this.$router.push("/modifyHandleDetail?id=" + id);
      } else {
        this.$router.push("/modifyHandleDetail?id=" + id);
      }
    },
    async getByCodes() {
      let that = this;
      let data = await getByCodes(JSON.stringify(this.dic_key));

      that.dic_SelectList.rectification_management_update_type = JSON.parse(
        data.rectification_management_update_type.dictValue
      );
      that.active = "null";
      console.log("that.activethat.activethat.active", that.active);
      that.selectData();
      that.$forceUpdate();
    },
    // auth.currUser().id
    selectData() {
      const _this = this;
      findRectificationManagementInOutList(this.params).then((res) => {
        if (res) {
          console.log("我到底是不是人");
          res.rows.forEach((e) => {
            e.needFinishTime = this.$common.transServDate(e.needFinishTime);
            e.checkTime = !e.checkTime
              ? "暂无"
              : this.$common.transServDate(e.checkTime);
            e.updateAddress =
              e.updateAddress && e.updateAddress.length > 0
                ? e.updateAddress.replace("江苏省无锡市", "")
                : e.updateAddress;
            e.infoMorePictureUrl =
              e.infoMorePictureUrl && e.infoMorePictureUrl.length > 0
                ? e.infoMorePictureUrl.split(",")
                : [];
            console.log(e.infoMorePictureUrl);
          });

          console.log("我到底是不是人", res.rows.length);
          if (res.rows.length != 0) {
            this.recordList = [...this.recordList, ...res.rows];
          }

          if (this.recordList.length == res.total) {
            debugger;
            this.upFinished = true;
          }
        }
      });
    },
    getItemJson: function (item) {
      const fileUrls = item.fileUrl !== "" ? JSON.parse(item.fileUrl) : [];
      console.log(fileUrls);
      item.fileUrl = fileUrls;
      item.createdAt = this.$common.transServDate(item.createdAt);
      //   console.log(item.status);
      //   console.log(this.dic_SelectList.REPAIR_STATUS);
      //   let index = this.dic_SelectList.REPAIR_STATUS.findIdex((e)=>e.value==item.status)
      //   item.statusName = this.dic_SelectList.REPAIR_STATUS[index];
      return item;
    },
    /**
     *
     */
    quickSelect(item) {
      if (this.quickSleced.val && this.quickSleced.val === item.val) {
        this.quickSleced = {};
      } else {
        this.quickSleced = item;
      }
    },
    /**
     * 上传文件
     */
    afterRead(file) {
      console.log(file);
    },
    /**
     * 设置状态样式
     */
    setStatusStyle(status) {
      let statusClass = null;
      switch (status) {
        case "unAcceptance":
          statusClass = "pending-btn";
          break;
        case "acceptance":
          statusClass = "accepted-btn";
          break;
        case "processed":
          statusClass = "processed-btn";
          break;
        case "evaluated":
          statusClass = "evaluated-btn";
          break;
      }
      return statusClass;
    },
  },
  /**
   * 过滤器
   */
  filters: {
    /**
     * 状态：0、待受理 1、已受理 2、已处理  3、已评价
     */
    statusFilter(val) {
      let res = null;
      switch (val) {
        case "unAcceptance":
          res = "待处理";
          break;
        case "acceptance":
          res = "已受理";
          break;
        case "processed":
          res = "已处理";
          break;
        case "evaluated":
          res = "已评价";
          break;
      }
      return res;
    },
  },
};
</script>
      <style lang="scss" type="text/scss" scoped>
.modifysend {
  .pending-btn {
    color: $fc;
    background-color: $red;
  }
  .accepted-btn {
    color: $fc;
    background-color: $color2;
  }
  .processed-btn {
    color: $fc;
    background-color: $orange;
  }
  .evaluated-btn {
    color: $fc;
    background-color: $green;
  }
  .btn-view {
    width: 100%;
    height: 100px;
    padding: 20px 10%;
    background-color: #ffffff;
    position: fixed;
    bottom: 0;
    left: 0;
  }
  .uni-select_2 {
    font-size: 22px;
    border: 2px solid #e5e5e5;
    box-sizing: border-box;
    border-radius: 8px;
    padding: 0 10px;
    padding-left: 20px;
    position: relative;
    display: flex;
    -webkit-user-select: none;
    user-select: none;
    flex-direction: row;
    align-items: center;
    border-bottom: solid 2px #e5e5e5;
    width: 100%;
    flex: 1;
    height: 70px;
    color: #6a6a6a;
  }
  .btn {
    width: 80%;
    height: 90px;
    border-radius: 50px 50px 50px 50px;
    background: #1d18bc;
    line-height: 90px;
    color: white;
  }
  .top-add {
    background-color: #fff;
    padding: 30px;
    text-align: right;
    box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.05);
    i {
      font-size: 36px;
      color: $text6;
      margin-right: 15px;
    }
    .txt {
      font-size: 32px;
      color: $text6;
    }
  }

  .info-findRectificationManagementInOutList {
    height: calc(100vh - 124px);
    overflow-y: auto;
    .info-item {
      background-color: #fff;
      padding: 20px 30px;
      margin-bottom: 20px;
      .info-top {
        @include flex;
        .left {
          width: 286px;
          height: 168px;
          font-size: 0;
          border-radius: 10px;
          overflow: hidden;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .right {
          align-self: flex-start;
          width: 380px;
          .tit {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 380px;
            font-size: 32px;
            line-height: 1.4;
            font-weight: bold;
            color: #333333;
            @include line-clamp;
            margin-bottom: 20px;
          }
          .txt {
            font-size: 28px;
            color: #666;
          }
        }
      }

      .info-bottom {
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px dashed #dbdbdb;
        @include flex;
        .left {
          i {
            font-size: 30px;
            color: #999999;
            margin-left: 10px;
          }
          span {
            font-size: 28px;
            color: #999999;
          }
        }
        .right {
        }
      }
    }
  }
}
</style>
      