<!--我的志愿列表-->
<script>
import StaticConstant from "@/common/StaticConstant";
import ApiConstant from "@/common/ApiConstant";
import Request from '@/common/request'

let request = new Request()
export default {
  name: "fillVolunteer-list",
  data() {
    return {
      volunteerList: [],//志愿单列表
    }
  },
  onShow() {
    this.getVolunteerList()
  },
  methods: {
    /*获取志愿单列表*/
    getVolunteerList() {
      request.get(ApiConstant.Volunteer.volunteerPage, {}).then(r => {
        console.log(r)
        if (r.success) {
          this.volunteerList = r.result
        }
      }).catch(err => {
      }).finally(() => {
      });
    },
    clickEdit(e){
      console.log('编辑')
      console.log(e)
      uni.navigateTo({
        url: 'detail?volunteerId='+e
      })
    },
    clickDelete(e){
      let that = this
      console.log('删除')
      console.log(e)
      uni.showModal({
        title:'提示',
        content: '确认要删除当前志愿表吗?',
        confirmText: '确定',
        cancelText: '取消',
        success:function (res){
          if (res.confirm) {
            that.deleteVolunteer(e)
          }
        }
      });
    },
    /*确认删除志愿表*/
    deleteVolunteer(e){
      let that = this
      request.delete(ApiConstant.Volunteer.volunteerDelete,{id:e}).then(res => {
        if (res.success) {
          setTimeout(function () {
            uni.showToast({title: '删除成功', icon: "none"});
            that.getVolunteerList()
          }, 1000)
          setTimeout(function () {
            that.getVolunteerList()
          }, 1500)
        }else{
          setTimeout(function () {
            uni.showToast({title: res.message, icon: "none"});
          }, 500)
        }
      }).catch(err => {
      }).finally(() => {
      });
    },
    clickDownload(e){
      //下载
      uni.showToast({title: '目前仅支持PC端下载', icon: "none"});
    }
  }
}
</script>

<template>
  <!--志愿信息列表-->
  <div style="border-top: 1px solid #f5f6f8">
    <div class="volunteerDiv" v-for="(item,index) in volunteerList" :key="item.id">
      <view class="uni-flex frow" style="padding: 15rpx;">
        <view class="flex-item-6" @click="clickEdit(item.id)">
          <view class="uni-flex uni-row">
            <view class="flex-item t_item">
              <text style="font-size: 30rpx;font-weight: 600">{{ item.volunteerName }}</text>
            </view>
          </view>
          <view class="uni-flex uni-row">
            <view class="flex-item t_item" style="color:#c1c4cc">
              <text>更新：</text>
              <text v-if="item.updateTime">{{ item.updateTime }}</text>
              <text v-else>{{ item.createTime }}</text>
            </view>

          </view>
          <view class="uni-flex uni-row">
            <view class="flex-item t_item">
              <text>{{ item.userScoreInfo.cognitioPolyclinic }}&nbsp;&nbsp;|&nbsp;&nbsp;{{ item.userScoreInfo.professionalCategory }}</text>
<!--              <image v-if="item.state=='1'" src="/static/icons/cuti/done-active.png" style="width: 32rpx;height: 32rpx;margin-bottom: -5rpx"/>-->
            </view>
          </view>
        </view>
        <view class="flex-item-4">
          <view class="options">
            <view class="uni-flex frow">
              <view class="flex-item-33">
                <div class="img">
                  <!--style="border-right: 1px solid #c5c5c5;"-->
                  <image @click="clickEdit(item.id)" src="/static/icons/cuti/edit.png" style="width: 50rpx;height: 50rpx"/>
                </div>
              </view>
              <view class="flex-item-33">
                <div class="img">
                  <image @click="clickDelete(item.id)" src="/static/icons/cuti/delete.png" style="width: 50rpx;height: 50rpx"/>
                </div>
              </view>
              <view class="flex-item-33">
                <div class="img">
                  <image @click="clickDownload(item.id)" src="/static/icons/cuti/file-download.png" style="width: 50rpx;height: 50rpx"/>
                </div>
              </view>
            </view>
          </view>
        </view>

      </view>

    </div>
  </div>
</template>

<style scoped lang="scss">
.volunteerDiv {
  background-color: white;
  margin-bottom: 30rpx;
  padding: 20rpx;
}

.t_item {
  margin-bottom: 15rpx;
}

.options{
  margin: 45rpx auto 50rpx 0rpx;
}

.img{
  height: 40rpx;
  padding: 0 40rpx;
}
.img image{
  //margin: -8rpx 40rpx 0rpx 0rpx;
}

</style>
