<template>
    <view v-show="show">
        <view class="item" @click="openModel(item)" hover-class="navigator-hover" v-for="item in list" :key="item.rowindex">
            <view class="title">{{ item.createdate || ' --' }}</view>
            <view class="row u-line-3">
                {{ item.content }}
            </view>
        </view>

        <u-modal :show="modleShow" confirmText="复制" cancelText="关闭" :showCancelButton="true" @cancel="onCancel"
            @confirm="onConfirm">
            <template slot="default">
                <view>
                    <view style="width: 100%;text-align: center;font-weight: bold;margin-bottom: 20px;">
                        {{ modle.createdate }}
                    </view>
                    <view style="word-break: break-all;">
                        {{ modle.content }}
                    </view>
                </view>
            </template>
        </u-modal>
    </view>
</template>

<script>
let paging = {}
export default {
    name: "uploadRecord",
    props: {
        w_deviceid: String
    },
    data() {
        return {
            show: false,
            uninitialized: true,
            list: [],
            "where": {
                "begindate": "",
                "enddate": ""
            },
            modle: {},
            modleShow: false
        }
    },
    methods: {
        getList(init = false) {
            if (init) paging = {
                pageNumber: 1,
                pageTotal: 1,
            };
            return new Promise((resolve) => {
                if (paging.pageNumber > paging.pageTotal) return resolve()
                this.$Http.basic({
                    "id": 20230701132202,
                    "content": {
                        "type": 1,
                        "w_deviceid": this.w_deviceid,
                        ...paging,
                        "where": this.where
                    }
                }).then(res => {
                    console.log('上传记录', res)
                    resolve(!this.cutoff(res.msg));
                    if (this.cutoff(res.msg)) return;
                    paging.pageNumber = res.pageNumber + 1;
                    paging.pageTotal = res.pageTotal;
                    this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data)
                })
            })
        },
        openModel(item) {
            this.modle = item;
            this.modleShow = true;

        },
        onCancel() {
            this.modleShow = false;
        },
        onConfirm() {
            let that = this;
            uni.setClipboardData({
                data: this.modle.content,
                complete: (res) => {
                    console.log("复制", res)
                    this.onCancel();
                },
            })
        }
    },
}
</script>

<style lang="scss" scoped>
.item {
    width: 355px;
    margin: 0 auto 10px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    box-sizing: border-box;

    .title {
        line-height: 21px;
        font-size: 15px;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: bold;
        color: #333333;
        margin-bottom: 10px;
    }

    .row {
        line-height: 17px;
        font-size: 12px;
        color: #666666;
        margin-bottom: 5px;
    }
}


/deep/.u-empty {
    z-index: 1 !important;
}
</style>