<template>
  <div class="repair">
    <div class="top-add" @click="goNavigator()">
      <i class="iconfont icon-xinzeng"></i>
      <span class="txt">新增案卷</span>
    </div>
    <div class="info-findRectificationManagementInOutList">
      <div
        class="info-item"
        v-for="item in recordList"
        :key="item.id"
        @click="jumpPageDetails(item.id)"
      >
        <div class="info-top">
          <div class="left">
            {{ JSON.stringify(item) }}
            <img
              :src="
                item.infoMorePictureUrl != null &&
                item.infoMorePictureUrl.length > 0
                  ? BASE_URI +
                    '/FileController/download/' +
                    item.infoMorePictureUrl[0]
                  : ''
              "
              alt=""
            />
          </div>
          <div class="right">
            <p class="tit chaochuyincang">
              {{ item.info }}
            </p>
            <p class="txt">{{ item.createdAt }}</p>
          </div>
        </div>
        <div class="info-bottom">
          <div class="left">
            <i class="iconfont icon-shijian"></i>
            <span>
              {{ item.updateAddress }}
            </span>
          </div>
          <div class="right">
            <span
              v-if="item.status == 'unAcceptance'"
              class="normal-tip yd h-bg"
              >待派单</span
            >
            <span v-else class="normal-tip yd z-bg">已派单</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
  <script>
import {
  findRectificationManagementInOutList,
  getByCodes,
  getUserLocalStorageInfo,
} from "@/js_sdk/http.js";
// import Base from "@/pages/base/base";
export default {
  data() {
    return {
      BASE_URI: this.$constant.BASE_URI,
      dic_key: ["REPAIR_STATUS"],
      dic_SelectList: {},
      recordList: [],
      params: {
        openUser: getUserLocalStorageInfo().user.id,
        pageNum: 1,
        pageSize: 10,
        // groupId: "870261874875170816",
        // createdBy: '877225455206268928' // auth.currUser().id
      },
      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() {
    // if (window.history && window.history.pushState) {
    //   // 向历史记录中插入了当前页
    //   history.pushState(null, null, document.URL);
    //   window.addEventListener("popstate", this.goBack, false);
    // }
  },
  onLoad() {
    this.getByCodes();
  },
  onShow() {
    this.selectData();
  },

  methods: {
    goNavigator(id) {
      uni.navigateTo({
        url: "/pages/subPackages/modifyReport/add",
      });
    },
    jumpPageDetails(id) {
      console.log(id);
      uni.navigateTo({
        url: "/pages/subPackages/modifyReport/detail?id=" + id,
      });
    },
    async getByCodes() {
      let that = this;
      let data = await getByCodes(JSON.stringify(this.dic_key));
      that.dic_SelectList = that.$common.handleDicList(data);
      that.selectData();
    },
    // auth.currUser().id
    selectData() {
      const _this = this;
      findRectificationManagementInOutList(this.params).then((res) => {
        if (res) {
          res.rows.forEach((e) => {
            e.createdAt = this.$common.transServDate(e.createdAt);
            e.updateAddress = e.updateAddress.replace("江苏省无锡市", "");
            e.infoMorePictureUrl =
              e.infoMorePictureUrl.length > 0
                ? e.infoMorePictureUrl.split(",")
                : [];
            console.log(e.infoMorePictureUrl);
          });

          this.recordList = res.rows;
        }
      });
    },
    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>
.repair {
  .top-add {
    background-color: #fff;
    padding: 30rpx;
    margin-bottom: 20rpx;
    text-align: right;
    box-shadow: 0rpx 5rpx 10rpx 0rpx rgba(0, 0, 0, 0.05);
    i {
      font-size: 36rpx;
      color: $text6;
      margin-right: 15rpx;
    }
    .txt {
      font-size: 32rpx;
      color: $text6;
    }
  }

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

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