| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <view class="container">
- <!-- 头部添加打卡时间区域 -->
- <view class="add">
- <view class="icon" @click="handleAdd">
- <img src="../../static/add.png">
- </view>
- <view class="title" @click="handleAdd">
- 添加打卡时间
- </view>
- <view class="none"></view>
- </view>
- <!-- 打卡时间列表 -->
- <view class="list">
- <uni-swipe-action>
- <!-- 每一个时间段区域 -->
- <uni-swipe-action-item :auto-close="true" :right-options="options" @click="onClick(index)"
- v-for="(item,index) in list" :key="index">
- <view class="box" @click="handleEdit(item)">
- <view class="left">
- <view class="week">
- <view class="key">
- 星期
- </view>
- <view class="value">
- {{item.selectedWeeks}}
- </view>
- </view>
- <view class="week">
- <view class="key">
- 时段
- </view>
- <view class="value">
- <span v-for="(item_time,index_time) in item.list" :key="index_time">
- {{item_time.startTime}}-{{item_time.endTime}}
- </span>
- </view>
- </view>
- </view>
- <view class="right">
- <img src="../../static/right.png">
- </view>
- </view>
- </uni-swipe-action-item>
- </uni-swipe-action>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- list: [
- // {
- // id: 1,
- // week: "周一,周二,周三,周四,周五,周六,周日",
- // time: "09:00-17:00、20:00-21:00、22:00-23:00"
- // },
- // {
- // id: 2,
- // week: "周一,周二,周三,周四,周五,周六,周日",
- // time: "09:00-17:00"
- // },
- // {
- // id: 3,
- // week: "周一,周二,周三,周四,周五,周六,周日",
- // time: "12:00-17:00"
- // },
- // {
- // id: 4,
- // week: "周一,周二,周三,周四,周五,周六,周日",
- // time: "09:00-17:00、20:00-21:00、22:00-23:00"
- // },
- ],
- options: [{
- text: '删除',
- style: {
- backgroundColor: '#D43030'
- }
- }],
- }
- },
- onShow() {
- let ruleTime = uni.getStorageSync("ruleTime")
- if (ruleTime) {
- this.list = ruleTime
- }
- },
- methods: {
- // 点击添加打卡时间回调 跳转到添加页面
- handleAdd() {
- uni.navigateTo({
- url: `/pages/setPunchTime/setPunchTime?flag=1`
- })
- },
- // 点击每一个时间段回调 跳转到编辑页面
- handleEdit(item) {
- let info = JSON.stringify(item)
- uni.navigateTo({
- url: `/pages/setPunchTime/setPunchTime?flag=2&info=${info}`
- })
- },
- // 点击右侧删除按钮回调
- onClick(index) {
- // console.log(index);
- uni.showModal({
- title: '提示',
- content: '确定删除该打卡时间吗?',
- success: (res) => {
- if (res.confirm) {
- uni.showToast({
- title: "删除成功",
- icon: 'success'
- })
- this.list.splice(index, 1)
- uni.setStorageSync("ruleTime", this.list)
- } else if (res.cancel) {}
- }
- });
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- padding-top: 20rpx;
- .add {
- display: flex;
- margin: 0 auto;
- width: 690rpx;
- height: 87rpx;
- line-height: 87rpx;
- border-radius: 14rpx;
- background-color: #fff;
- .icon {
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- img {
- width: 36rpx;
- height: 36rpx;
- }
- }
- .title {
- flex: 3;
- font-size: 30rpx;
- color: #0082FC;
- }
- .none {
- flex: 5;
- }
- }
- .list {
- margin-top: 20rpx;
- padding-bottom: 30rpx;
- .box {
- display: flex;
- margin: 0 auto;
- margin-bottom: 20rpx;
- width: 690rpx;
- height: 132rpx;
- border-radius: 14rpx;
- background-color: #fff;
- .left {
- flex: 5;
- display: flex;
- flex-direction: column;
- margin-left: 17rpx;
- .week {
- flex: 1;
- display: flex;
- align-items: center;
- font-size: 24rpx;
- .key {
- flex: 1;
- margin-left: 8rpx;
- color: #A6A6A6;
- }
- .value {
- flex: 5;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- }
- }
- .right {
- flex: 2;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- img {
- margin-right: 20rpx;
- width: 20rpx;
- height: 30rpx;
- }
- }
- }
- }
- }
- // 解决左滑区域突出问题
- ::v-deep .uni-swipe_button-group {
- margin-bottom: 20rpx;
- }
- </style>
|