<template>
  <view class="todo-list">
    <u-empty mode="list" text="暂无记录" v-if="records.length == 0"></u-empty>
    <view v-else v-for="(v, k) in records" :key="i">
      <view class="follow-date">
        <u-text :bold="true" size="26rpx" :text="k"></u-text>
      </view>
      <view class="todo-item" v-for="item in records[k]" :key="item.id">
        <u-row>
          <u-col span="12">
            <view class="header">
              <u-row>
                <u-col span="12">
                  <view class="flex_l">
                    <text class="tit-txt text-ellipsis flex_1">
                      {{ item.opnPeople }} {{ item.opnType }}
                    </text>
                  </view>
                </u-col>
              </u-row>
              <view class="content flex">
                <text>{{ item.followContent }}</text>
              </view>
              <view class="content-footer flex1">
                <text class="date">{{ item.opnDate }}</text>
                <!-- <view class="flex flex-middle">
                  <text class="user-txt">联系人:{{ item.contactsName }}</text>
                </view> -->
              </view>
            </view>
          </u-col>
        </u-row>
      </view>
    </view>
  </view>
</template>

<script>
  import to from 'await-to-js'
  import api from '@/api/contract'
  export default {
    name: 'OmsContractDynamics',
    props: {
      contractId: {
        type: [String, Number],
        default: '0',
      },
    },
    data() {
      return {
        records: {},
      }
    },

    mounted() {
      this.fetchData()
      console.log('contractId', this.contractId)
    },

    methods: {
      async fetchData() {
        let params = {
          contractId: this.contractId,
          DaysBeforeToday: 9999,
        }
        const [err, res] = await to(api.getDynamicsList(params))
        if (err) return
        if (res.code == 200) this.records = res.data.list || []
      },
      formatType(val) {
        let str = ''
        if (val == 10) str = '电话'
        else if (val == 20) str = '邮件'
        else if (val == 30) str = '拜访'
        return str
      },
    },
  }
</script>

<style lang="scss" scoped>
  .todo-list {
    height: 100%;
    overflow: auto;
    .follow-date {
      padding: 20rpx 0 20rpx 20rpx;
    }
    .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 {
        padding: 10rpx 0;
        font-size: 28rpx;
        color: #646464;
      }
      .content-footer {
        padding: 0 0 12rpx 0;
        font-size: 24rpx;
        .date {
          color: #969696;
        }
        .user-img {
          width: 46rpx;
          height: 46rpx;
          border-radius: 50%;
          margin-right: 15rpx;
        }
      }
    }
  }
</style>
