<template>
    <el-drawer append-to-body title="点评记录" :visible.sync="show" size="400px" direction="ltr"
        style="backdrop-filter: blur(4px);">
        <scroll-view scroll-y style="height: 100%;" @scrolltolower="getNext">
            <u-swipe-action>
                <u-swipe-action-item v-for="(item,index) in list" :key="item.id" class="ui-hover ui-flex-1"
                    :options="options1" @click="itemRemove(item,index)" :show="!!item.show">
                    <u-cell :title="item.student.student_name" @click="itemRemove(item, index)">
                        <view slot="icon" class="ui-mr10">
                            <image :src="
                                cartoonHeadImg ? item.student.student_cartoon_photo :
                                item.stuSchool.student_photo + '?x-image-process=style/square400'"
                                style="width: 40px;height: 40px;border-radius: 20px;">
                            </image>
                        </view>
            
                        <text slot="label" class="txt-muted">{{item.created_at}} </text>
                        <el-tag slot="value" plain :type="item.type == 1 ? '' : 'danger'">{{item.studentTab && item.studentTab.tab_name}}
                            {{item.score}}
                        </el-tag>
                    </u-cell>
                </u-swipe-action-item>
            </u-swipe-action>
            <ui-page-list ref="reflist" url="/mobile/studentTab/getstudentTabLog" v-model="list" :start="false"></ui-page-list>
        </scroll-view>
    </el-drawer>
</template>

<script>
    export default {
        props: {
            chooseClassId: {
                type: Number | String,
                default: ""
            },
            cartoonHeadImg : {
                default : true,
            },
            stuList: {
                type: Array,
                default: () => []
            },
        },
        data() {
            return {
                show: false,
                list: [],
                options1: [{
                    text: '撤销',
                    style: {
                        backgroundColor: '#FF0C0C',
                    }
                }]
            }
        },
        methods: {
            open() {
                this.show = true;
                this.list = []
                this.$nextTick(() => {
                    this.getList()
                })
            },
            getList() {
                this.$refs.reflist.fresh({
                    class_id: this.chooseClassId,
                    stu_school_id: this.stuList[0]
                })
            },
            getNext(e){
                this.$refs.reflist.next();
            },
            itemRemove(item) {
                this.$api.sendRequest({
                    confirm : {
                        title : '确认撤销',
                        message : '确定要撤销此记录吗？'
                    },
                    url: `/mobile/studentTab/delstudentTabLog`,
                    method: "post",
                    data: {
                        tab_log_id: item.id
                    },
                    success: res => {
                        console.log("aaaaaaaaaaa");
                        this.show = false
                        this.$emit('delSuccess')
                    },
                    complete: res => {
                        console.log(res, "resss");
                    }
                })

            }

        },

    }
</script>

<style>
</style>