<template>
  <div class="bgColor">
    <div slot="content" class="scroll-wrapper">
      <div class="demo">
        <div class="header">工时（一级目录）</div>
        <div class="scroll-list-wrap">
          <cube-scroll
            :data="items"
          >
            <div class="conentBox">
              <div
                class="conent"
                v-for="(item, index) in items"
                @click="toDetail(item)"
                :key="index"
              >
                <div class="head">
                  <p>
                    <span>{{ item.workName }}<span v-if="item.workUnit">（{{ item.workUnit }}）</span></span>
                  </p>
                </div>
              </div>
              <div class="wushuju" v-show="wushuju">
                <img src="./../../static/images/wushuju.svg" alt />
                <p>暂无数据</p>
              </div>
            </div>
            <template v-if="customPullDown" slot="pulldown" slot-scope="props">
              <div
                v-if="props.pullDownRefresh"
                class="cube-pulldown-wrapper"
                :style="props.pullDownStyle"
              >
                <div
                  v-show="props.beforePullDown"
                  class="before-trigger"
                  :style="{ paddingTop: props.bubbleY + 'px' }"
                >
                  <span
                    :class="{
                      rotate: props.bubbleY > pullDownRefreshThreshold - 40
                    }"
                    >↓</span
                  >
                </div>
                <div class="after-trigger" v-show="!props.beforePullDown">
                  <div v-show="props.isPullingDown" class="loading">
                    <cube-loading></cube-loading>
                  </div>
                  <div v-show="!props.isPullingDown" class="text">
                    <span class="refresh-text">更新成功</span>
                  </div>
                </div>
              </div>
            </template>
          </cube-scroll>
        </div>
      </div>
    </div>
    <load-ing v-if="!items.length && !wushuju"></load-ing>
  </div>
</template>
<script>
import Vue from "vue";
import CubePage from "../components/cube-page.vue";
import SwitchOption from "../components/switch-option";
import InputOption from "../components/input-option";
import SelectOption from "../components/select-option";
import LoadIng from "./loading.vue";
export default {
  data() {
    return {
      hcData: {},
      modelsData: {}, //点击弹窗的那一项数据
      // 弹窗model
      models: {
        disjunctor: false
      },
      valConfig: JSON.parse(localStorage.getItem("valConfig")) - 0, //报修主体
      items: [],
      pullDownRefresh: true,
      pullDownRefreshThreshold: 60,
      pullDownRefreshStop: 40,
      pullDownRefreshTxt: "Refresh success",
      pullUpLoad: true,
      pullUpLoadThreshold: 0,
      pullUpLoadMoreTxt: "加载更多",
      pullUpLoadNoMoreTxt: "没有更多数据",
      customPullDown: true,
      wushuju: false,
      sum: 1000,
      idx: 0,
      stateClass: "",
      loadShow: true,
      searching: false
    };
  },
  components: {
    CubePage,
    SwitchOption,
    InputOption,
    SelectOption,
    LoadIng,
  },
  methods: {
    // 弹窗
    toDetail(item) {
      this.$router.push({
        path: `/main/WorkHourManagementTwo/${this.$route.params.incidentId}/${this.$route.params.summaryId}/${item.id}/${item.workName}/${item.workUnit}/${this.$route.params.processInstanceId}`
      });
    },
    // 获取列表
    getData() {
      if (this.searching) {
        this.idx = 0;
      }
      let postData = {
        idx: this.idx,
        sum: this.sum,
        workHourManagement: {
          treeLevel: 1
        }
      };
      this.$http
        .post(
          "service/bpm/data/fetchDataList/workHourManagement",
          postData
        )
        .then((res) => {
          if(res.status == 200){
            if (res.data.list.length > 0) {
              this.wushuju = false;
              if (this.searching) {
                this.items = res.data.list;
              } else {
                this.items = this.items.concat(res.data.list);
              }
            } else {
              this.wushuju = true;
            }
          }else{
            this.$createDialog({
              type: "alert",
              title: "操作失败",
              content: "请求失败!",
              icon: "cubeic-wrong"
            }).show();
          }
          this.loadShow = false;
        });
    },
  },
  created() {
    // this.$route.params.data
    // this.getParamsState();
    this.getData(this.idx, this.sum);
  }
};
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
.scroll-list-wrap {
  /* height: 350px */
  height: 90vh;
  /* border: 1px solid rgba(0, 0, 0, 0.1) */
  border-radius: 5px;
  transform: rotate(0deg); // fix 子元素超出边框圆角部分不隐藏的问题
  // overflow: hidden;
  padding-top: 0.88rem;
}

.foods-wrapper {
  .food-item {
    display: flex;

    /* padding: 18px */
    /* border-bottom: 1px solid rgba(7, 17, 27, 0.1) */
    /* border-top: 1px solid rgba(7, 17, 27, 0.1)!important */
    &:last-child {
      border-none();
      margin-bottom: 0;
    }

    .icon {
      flex: 0 0 57px;
      margin-right: 10px;
    }

    .food-content {
      flex: 1;

      .name {
        margin: 2px 0 8px 0;
        height: 14px;
        line-height: 14px;
        font-size: 14px;
        color: rgb(7, 17, 27);
      }

      .description, .extra {
        line-height: 10px;
        font-size: 10px;
        color: rgb(147, 153, 159);
      }

      .description {
        line-height: 12px;
        margin-bottom: 8px;
      }

      .extra {
        .count {
          margin-right: 12px;
        }
      }

      .price {
        font-weight: 700;
        line-height: 24px;

        .now {
          margin-right: 8px;
          font-size: 14px;
          color: rgb(240, 20, 20);
        }

        .old {
          text-decoration: line-through;
          font-size: 10px;
          color: rgb(147, 153, 159);
        }
      }

      .cartcontrol-wrapper {
        position: absolute;
        right: 0;
        bottom: 12px;

        .scroll-wrapper {
          .cube-pulldown-wrapper {
            .before-trigger {
              font-size: 30px;
              line-height: 30px;
              align-self: flex-end;

              span {
                display: inline-block;
                transition: all 0.3s;
                color: #666;

                &.rotate {
                  transform: rotate(180deg);
                }
              }
            }

            .after-trigger {
              .refresh-text {
                color: grey;
              }
            }
          }
        }
      }
    }
  }
}
</style>
<style lang="less" scoped>
.bgColor {
  background-color: white;
}
.food-item {
  border-top: 0.16rem rgb(238, 238, 238) solid;
}
.food-content {
  border-top: 0.01rem rgb(223, 222, 222) solid;
  border-bottom: 0.01rem rgb(223, 222, 222) solid;
}
.title {
  display: flex;
  justify-content: space-between;
  height: 0.7rem;
  line-height: 0.7rem;
  border-top: 0.01rem rgb(223, 222, 222) solid;
  padding: 0 0.24rem;
  border-bottom: 0.01rem rgb(223, 222, 222) solid;
}
.title i {
  font-size: 0.32rem;
  color: #005395;
}
.title div:nth-child(1) {
  font-size: 0.32rem;
}
.title div:nth-child(1) span {
  display: inline-block;
  margin-left: 0.08rem;
}
.title div:nth-child(2) {
  padding: 0.05rem 0.3rem;
  /* border: 0.01rem rgb(0,0,255) solid; */
  border-radius: 16px;
  /* color: rgb(0,0,255); */
  height: 0.25rem;
  line-height: 0.25rem;
  margin-top: 0.15rem;
  font-size: 0.24rem;
}
.weishouli {
  color: #991f00;
  border: 0.01rem #991f00 solid;
  background-color: #f4e8e5;
}
.bushouli {
  color: #666666;
  background-color: #eeeeee;
  border: 0.01rem #666666 solid;
}
.chulizhong {
  color: #003057;
  background-color: #e5eaee;
  border: 0.01rem #003057 solid;
}
.daipingjia {
  color: #825b00;
  background-color: #f2eee5;
  border: 0.01rem #825b00 solid;
}
.yijiejue {
  color: #40a19c;
  background-color: #ebf5f5;
  border: 0.01rem #40a19c solid;
}
.yichehui {
  color: #48a843;
  background-color: #ecf6ec;
  border: 0.01rem #48a843 solid;
}
.timeBox {
  display: flex;
  justify-content: space-between;
  font-size: 0.24rem;
  color: #999999;
  border-top: 0.01rem rgb(223, 222, 222) solid;
  height: 0.7rem;
  line-height: 0.7rem;
  padding: 0 0.24rem 0 0.64rem;
}
.wushuju {
  margin-top: 2.4rem;
  text-align: center;
  color: #999;
}
.wushuju img {
  width: 5.12rem;
  height: 2.84rem;
}
.demo {
  .header {
    width: 100%;
    height: 0.88rem;
    line-height: 0.88rem;
    text-align: center;
    color: #fff;
    font-size: 0.37rem;
    background: linear-gradient(#2e2f32, #414246);
    position: fixed;
    top: 0;
    z-index: 6;
  }
  .seatchHeader {
    width: 100%;
    background-color: #eee;
    padding: 0.16rem;
    overflow: hidden;
    position: fixed;
    top: 0.88rem;
    z-index: 6;
    box-sizing: border-box;
    .search {
      width: 100%;
      height: 0.56rem;
      font-size: 0.26rem;
      color: #b2b2b2;
      box-sizing: border-box;
      .searchInp {
        text-align: center;
        background-color: #fff;
        width: 100%;
        height: 100%;
        border-radius: 0.09rem;
        border: none;
        &:focus {
          outline: none;
        }
      }
    }
    .selectBtn {
      width: 1.2rem;
      height: 0.56rem;
      font-size: 0.32rem;
      color: #005395;
      border-color: #005395;
      background-color: #fff;
      border-radius: 0.09rem;
      &:focus {
        outline: none;
      }
    }
  }
}
.conentBox {
  width: 100%;
  .conent {
    font-size: 0.32rem;
    font-weight: 400;
    line-height: 0.45rem;
    border-bottom: 0.16rem solid #e5e5e5;
    .head {
      border-bottom: 0.01rem solid #e6e6e6;
      p {
        padding: 0.24rem 0.48rem;
        display: flex;
        justify-content: center;
        align-items: center;
        i {
          color: #00559d;
        }
        .btn {
          float: right;
        }
      }
    }
    .center {
      color: #333333;
      border-bottom: 0.01rem solid #e6e6e6;
      padding: 0.24rem 0.48rem;
      p {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .grayFont {
          color: #666;
        }
      }
    }
    .bottom {
      overflow: hidden;
      line-height: 0.86rem;
      border-bottom: 0.01rem solid #e6e6e6;
      font-size: 0.24rem;
      color: #999;
      padding: 0 0.24rem 0 0.48rem;
    }
  }
}
</style>
