<!--
 * @Author: liuzhenlin 461480418@qq.ocm
 * @Date: 2023-01-16 14:35:18
 * @LastEditors: liuzhenlin
 * @LastEditTime: 2023-02-16 16:44:27
 * @Description: file content
 * @FilePath: \oms\pages\schedule\components\supervise.vue
-->
<template>
  <view class="supervise-main">
    <!-- <u-tabs
      :list="list"
      @change="changeTabs"
      :current="curTabIndex - 1"
      :scrollable="false"
      :activeStyle="{
        color: '#323232',
        fontWeight: 'bold',
      }"
      :inactiveStyle="{
        color: '#969696',
      }"></u-tabs> -->
    <!-- 列表 -->
    <view class="data-scroll-wrap">
      <u-empty mode="list" text="暂无督办数据" v-if="followList.length == 0"></u-empty>
      <scroll-view v-else class="data-list" :scroll-top="scrollTop" :scroll-y="true" @scrolltolower="lower">
        <view class="todo-item" v-for="(v, i) in followList" :key="i" @click="showDesc(v)">
          <u-row>
            <u-col span="12">
              <view class="header">
                <!-- <u-row>
                  <u-col span="12">
                    <view class="flex_l">
                      <image class="todo-img" src="../../../static/images/todo-img.png" mode="scaleToFill" />
                      <text class="tit-txt flex_1">
                        {{ v.followTitle }}
                      </text>
                      <view class="do-status" :class="'status' + v.followStatus">
                        {{ setFollowStatus(v.followStatus) }}
                      </view>
                    </view>
                  </u-col>
                </u-row> -->
                <view class="content flex">
                  <text class="content-txt">
                    {{ v.followContent }}
                  </text>
                </view>
                <view class="content-footer flex1">
                  <text class="date">2022-12-15</text>
                </view>
              </view>
            </u-col>
          </u-row>
        </view>
        <u-loadmore :status="loadStatus" />
      </scroll-view>
    </view>
    <u-modal :show="showModal" :content="content" @confirm="showModal = false"></u-modal>
  </view>
</template>

<script>
  import followApi from '../../../api/customer'
  import to from 'await-to-js'
  export default {
    name: 'omsTodo',

    data() {
      return {
        curTabIndex: 1, //tabs状态
        loadStatus: '', //加载状态
        list: [
          {
            name: '我的待办',
            status: 1,
          },
          {
            name: '我发起的',
            status: 2,
          },
          {
            name: '我处理的',
            status: 3,
          },
        ],
        pageNum: 0,
        pageSize: 10,
        followList: [], //日志列表
        followTotal: 0, //列表元素数量
        showModal: false,
        content: '', //modal内容
      }
    },

    mounted() {
      this.getSuperviseData()
    },

    methods: {
      // 上拉滚动
      lower() {
        if (this.followList.length < this.followTotal && this.loadStatus != 'loading') {
          this.$u.throttle(this.getSuperviseData(), 2000, false)
        }
      },
      showDesc(v) {
        console.log(v.followDesc)
        if (v.followDesc) {
          this.showModal = true
          this.content = v.followDesc
        }
      },
      searchList() {
        this.pageNum = 0
        this.getSuperviseData(true)
      },
      async getSuperviseData(reset) {
        this.loadStatus = 'loading'
        this.pageNum++
        let params = {
          IsMyself: '1',
          pageNum: this.pageNum,
          pageSize: this.pageSize,
        }
        const [err, res] = await to(followApi.followList(params))
        if (err) {
          this.loadStatus = 'nomore'
          return
        }
        if (res && res.code == 200) {
          if (reset) {
            this.followList = res.data.list || []
          } else {
            this.followList = [...this.followList, ...(res.data.list || [])]
          }
          this.followTotal = res.data.total
          this.loadStatus = this.followList.length == this.followTotal ? 'nomore' : 'loadmore'
          console.log(this.loadStatus)
        } else {
          this.loadStatus = 'nomore'
        }
      },
      // 改变tab
      changeTabs(data) {
        console.log(data)
        this.curTabIndex = data.status
        this.searchList(true)
      },
      setFollowStatus(status) {
        let statusObj = {
          10: '待接收',
          20: '进行中',
          30: '已完成',
        }
        return statusObj[status]
      },
    },
  }
</script>

<style lang="scss" scoped>
  .supervise-main {
    height: 100%;
    .data-scroll-wrap {
      height: calc(100vh - 282rpx);
      padding: 30rpx 0;
      .data-list {
        width: 100%;
        height: 100%;
        background: #ffffff;
        overflow: auto;
        .todo-item {
          padding: 12rpx 40rpx 12rpx 46rpx;
          background: #f2f3f5;
          border-radius: 15rpx;
          margin-bottom: 32rpx;
          .tit-txt {
            font-size: 28rpx;
            font-weight: bold;
            color: #323232;
          }
          .content-txt {
            font-size: 28rpx;
            color: #646464;
          }
          .user-txt {
            font-size: 20rpx;
            color: #646464;
          }
          .header {
            .todo-img {
              flex: 0 0 24rpx;
              height: 24rpx;
              margin-right: 12rpx;
            }
            .do-status {
              width: 70rpx;
              height: 30rpx;
              border-radius: 0rpx 15rpx 0rpx 0rpx;
              text-align: center;
              line-height: 30rpx;
              font-size: 18rpx;
            }
          }
          .content {
            padding: 12rpx 0 12rpx 40rpx;
            font-size: 28rpx;
            color: #646464;
          }
          .content-footer {
            padding: 0 0 12rpx 40rpx;
            .date {
              font-size: 24rpx;
              color: #969696;
            }
            .user-img {
              width: 46rpx;
              height: 46rpx;
              border-radius: 50%;
              margin-right: 15rpx;
            }
          }
        }
        .status10 {
          color: #4096fb;
          background: rgba(64, 150, 251, 0.2);
        }
        .status20 {
          background: rgba(255, 184, 60, 0.2);
          color: #ffb83c;
        }
        .status30 {
          color: #fe6936;
          background: rgba(254, 105, 54, 0.2);
        }
      }
    }
  }
</style>
