<template>
  <div class="page-contain list-contain">
    <top-nav title="重要进展"
             :showQuery="false"></top-nav>
    <div v-if="dataList.length"
         class="data-list">
      <div v-for="(item, index) in dataList"
           :key="index"
           class="collapse-box">
        <div class="top">
          <div class="row title">
            <span class="fb">{{item.theme}}</span>
            <div @click="handleExtend(index)"
                 class="fc8CEE">
              <span v-if="item.isExtend">收起</span>
              <span v-else>更多</span>
              <van-icon :name="item.isExtend?'arrow-up':'arrow-down' " />
            </div>
          </div>
          <template v-if="item.isExtend">
            <div class="row pt10">
              <span>记录日期：{{item.workTitle}}</span>
            </div>
            <div class="row ptb20">
              <span>提交人员：{{item.creater}}</span>
            </div>
            <div class="row pb10">
              <span>批阅状态：{{item.reviewStatusKey}}</span>
            </div>
            <div class="row">
              <span>提交时间：{{item.createDateFormat}}</span>
            </div>
          </template>
        </div>
      </div>
    </div>
    <van-empty v-if="!dataList.length && showNoData"
               description="暂无数据！" />
  </div>
</template>

<script>

export default {
  name: 'project-progress',

  created () {
    this.projectId = this.$route.params.projectId
    this.getProjectWork()
  },
  methods: {

    getProjectWork () {
      let param = {
        currPage: 1,
        pageSize: 999,
        queryParam: {
          projectId: this.projectId,
          reportBigType: 'projectReport'
        }
      }
      this.$axios.post({
        domain: 'crmUrl',
        url: 'project.projectWorklist',
        data: param,
        requestType: 'body',
        isShow: true,
        success: function (res) {
          if (res.errorCode === 200) {
            this.dataList = res.data.records || []
            this.dataList.forEach(item => {
              this.$set(item, 'isExtend', true)
            })
          } else {
            this.$toast({ type: 'fail', message: res.msg })
          }
        }.bind(this),
        error: function (err) {
          this.$toast({ type: 'fail', message: err, duration: 3000 })
        }.bind(this),
        complete: function () {
          this.showNoData = true;
        }.bind(this)
      })
    },
    handleExtend (index) {
      this.dataList[index].isExtend = !this.dataList[index].isExtend
    }
  },
  data () {
    return {
      projectId: '',
      dataList: [],
      showNoData: false,
    }
  }
}
</script>

<style scoped  lang="scss">
</style>
