用uni-app写一个申请请假列表的页面

<template>
    <view class="leave-list">
        <view class="searchh-bar">
            <input type="text" name="" id="" placeholder="请输入搜索内容" />
            <button>一键清空</button>
        </view>
        <!-- 列表开始 -->
        <view class="list">
            <view class="item" v-for="(item, index) in leaveList" :key="index">
                <view class="top">
                    <view class="left">{{ item.startTiom }} {{ item.name }}</view>
                    <view class="right">
                        <uni-icons type="compose" size="24" color="#00aaff"></uni-icons>
                        <uni-icons type="trash" size="24" color="#ff0000" @tap="removeAll(item._id)"></uni-icons>
                    </view>
                </view>
                <view class="reson">
                    {{ item.reason }}
                </view>
                <view class="attachment">
                    <view class="title">附件</view>
                    <image v-for="(k,i) in item.imgs" :key="k" :src="k" mode=""></image>
                </view>
                <view class="time">时间:{{ item.createTime }}-{{ item.endTime }}</view>
                <view class="refuse" v-if="item.status == 2">
                    <view class="title">
                        驳回理由:
                    </view>
                    <view class="reason">
                        {{ item.refuseReason }}
                    </view>
                </view>
                <view v-if="item.status == 0" class="status primary-status">待审核</view>
                <view v-else-if="item.status == 1" class="status success-status">通过</view>
                <view v-else="item.status == 2" class="status error-status">不通过</view>
                </view>
            </view>
            <view class="garden" @tap="Toask">
                <text>+</text>
            </view>
        </view>

</template>

<script>
export default {
    data() {
        return {
            leaveList: [],
            userInfo:[]
        };
    },
    onShow() {
        this.getLeaveList();
    },
    methods: {
        //定义一个请求请假列表的方法 uniCloud.callFunction
        getLeaveList() {
            uniCloud.callFunction({
                name: 'get-leave-list',
                data:{
                    name:uni.getStorageSync("user").name
                },
                success: (res) => {
                    console.log(res);
                    this.leaveList = res.result.leaveList.data;
                }
            });
        },
        getuserInfo(){
            
        },
        Toask(){
            uni.navigateTo({
                url:"/pages/ask/ask"
            })
        },
        //删除请假记录
        removeAll(id){
            console.log(id)
            uni.showModal({
                title:"确定删除请假申请?",
                confirmText:"删除",
                confirmColor:"red",
                success: (res) => {
                    console.log(res)
                    if(res.confirm){
                        uniCloud.callFunction({
                            name:"del_leave",
                            data:{
                                delId:id
                            },
                            success: (res) => {
                                if(res.result.code==200){
                                    uni.showToast({
                                        title:"删除成功"
                                    })
                                    this.getLeaveList();
                                }
                            }
                        })
                        console.log("删除成功")
                    }
                }
            })
        }
    }
};
</script>
<!-- scoped 样式的作用域 只对这个页面样式有效 -->
<style scoped lang="scss">
.leave-list {
    .garden{
        position: fixed;
        bottom: 10px;
        right: 10px;
        width: 50px;
        height: 50px;
        background-color: #00aaff;
        border-radius: 50%;
        text-align: center;
        line-height:50px;
        text{
            font-size: 40px;
            color: #ffffff;
        }
    }
    background-color: #dfdfdf;
    //padding: 15px;
    .searchh-bar {
        display: flex;
        border-bottom: 1px solid gray;
        padding-bottom: 10px;
        padding: 15px 15px;
        input {
            border: 1px solid gray;
            background-color: white;
            border-radius: 5px;
            height: 35px;
            flex: 1;
            margin-right: 8px;
            margin-left: 5px;
        }
        button {
            background-color: #ff0000;
            color: white;
            height: 35px;
            line-height: 35px;
            width: 70px;
            padding: 0;
            font-size: 24rpx;
        }
    }
    .list {
        
        padding: 15px;
        .item {
            position: relative;
            background-color: white;
            border-radius: 10px;
            margin-bottom: 10px;
            padding: 10px;
        }
        .top {
            display: flex;
            justify-content: space-between;
            .left {
                font-size: 34rpx;
                font-weight: bold;
            }
        }
        .reson {
            color: #999;
            margin: 10px 0;
        }
        .attachment {
            .title {
                color: #999;
                margin-bottom: 6px;
            }
            image {
                width: 150rpx;
                height: 150rpx;
            }
        }
        .time {
            color: #00aaff;
        }
    }
    .refuse{
        .title{
            color: #ff5500;
            margin-top: 10px;
            font-weight: bold;
        }
        .reason{
            color: #999;
            }
        }
        .status{
            position: absolute;
            bottom: 20px;
            right: 10px;
            background-color: #00ff00;
            color: #ffffff;
            width: 120rpx;
            text-align: center;
            padding: 5px 0;
            //旋转
            transform: rotate(-45deg);
    }
    .primary-status{
        background-color: #00aaff;
    }
    .error-status{
        background-color: #ff0000;
    }
}
</style>
 

当然可以!以下是一个使用uni-app和Vue编的用户登录页面示例: 首先,创建一个新的uni-app项目,命名为`login`。 在`login`项目的`pages`文件夹中创建一个名为`Login`的页面: ``` <template> <view class="container"> <view class="form-group"> <input v-model="username" type="text" placeholder="用户名" /> </view> <view class="form-group"> <input v-model="password" type="password" placeholder="密码" /> </view> <button @click="login">登录</button> </view> </template> <script> export default { data() { return { username: '', password: '' }; }, methods: { login() { // 在这里编登录逻辑 if (this.username === 'admin' && this.password === 'password') { uni.showToast({ title: '登录成功', icon: 'success' }); // 登录成功后跳转到其他页面 uni.navigateTo({ url: '/pages/home/home' }); } else { uni.showToast({ title: '用户名或密码错误', icon: 'none' }); } } } }; </script> <style scoped> .container { margin-top: 100px; display: flex; flex-direction: column; align-items: center; } .form-group { margin-bottom: 20px; } input { width: 300px; height: 40px; border: 1px solid #ccc; border-radius: 4px; padding: 0 10px; } button { width: 100px; height: 40px; background-color: #007aff; color: #fff; border-radius: 4px; border: none; } </style> ``` 在上述代码中,我们创建了一个包含用户名和密码输入框以及登录按钮的登录页面。当点击登录按钮时,会触发`login`方法进行登录逻辑的处理。在这个示例中,我们简单地验证用户名和密码是否为预设的值(admin/password),如果匹配成功,则显示登录成功消息,并跳转到其他页面;如果不匹配,则显示用户名或密码错误的消息。 请注意,这个示例只是一个简单的登录页面示例,实际的登录逻辑可能会更加复杂。你可以根据自己的需求进行相应的修改和扩展。 希望对你有所帮助!如有任何问题,请随时向我提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值