Browse Source

feat(common): 优化考勤列表功能并添加请假功能

-重命名 clocking_list 方法为 clockingList,提高代码可读性
- 修改考勤列表筛选逻辑,使用 status 字段代替 type 字段
- 添加请假功能,包括请假按钮和请假提示框
- 实现请假请求提交和处理逻辑
- 优化页面初始化和数据加载流程
master
liutong 12 months ago
parent
commit
9ee96c8649
  1. 2
      api/common.js
  2. 120
      pages/common/my_attendance.vue

2
api/common.js

@ -59,7 +59,7 @@ export default {
//考勤列表 --分页
clocking_list(data) {
clockingList(data) {
let url = `/member/clocking_list`
return http.get(url, data).then(res => {
return res;

120
pages/common/my_attendance.vue

@ -3,6 +3,7 @@
<view class="main_box">
<fui-segmented-control
:values="optionTable"
:current="(Number(filteredData.status))"
type="text"
activeColor="#29d3b4"
color="#fff"
@ -10,10 +11,10 @@
</fui-segmented-control>
<view class="main_section">
<!--考勤-->
<!--全部-->
<scroll-view
class="section_1"
v-if="filteredData.type == '1'"
v-if="filteredData.status == '0'"
scroll-y="true"
:lower-threshold="lowerThreshold"
@scrolltolower="loadMoreData"
@ -95,10 +96,10 @@
</scroll-view>
<!--请假-->
<!--考勤-->
<scroll-view
class="section_1"
v-if="filteredData.type == '2'"
v-if="filteredData.status == '1'"
scroll-y="true"
:lower-threshold="lowerThreshold"
@scrolltolower="loadMoreData"
@ -180,10 +181,10 @@
</scroll-view>
<!--异常-->
<!--请假-->
<scroll-view
class="section_1"
v-if="filteredData.type == '3'"
v-if="filteredData.status == '2'"
scroll-y="true"
:lower-threshold="lowerThreshold"
@scrolltolower="loadMoreData"
@ -265,15 +266,20 @@
</scroll-view>
<!--请假按钮-->
<view class="section_btn">
<view class="btn">请假</view>
<view class="btn" @click="openShow()">请假</view>
</view>
</view>
<!-- 请假提示框-->
<fui-dialog :show="show" :content="content" maskClosable @click="onClick" @close="closeShow"></fui-dialog>
</view>
</template>
<script>
import commonApi from '@/api/common.js';
import marketApi from '@/api/market.js';
import AQTabber from "@/components/AQ/AQTabber.vue"
@ -286,6 +292,10 @@ export default {
return {
//tab
optionTable: [
{
id: 0,
name: '全部'
},
{
id: 1,
name: '考勤'
@ -293,13 +303,10 @@ export default {
{
id: 2,
name: '请假'
},
{
id: 3,
name: '异常'
}
],
loading:false,//
lowerThreshold: 100,//
isReachedBottom: false,//|true=|false=
@ -309,9 +316,18 @@ export default {
page:1,//
limit:10,//
total:10,//
type: '1',//1=,2=,3=
status:'0'//0 1 2
},
tableList:[],//
//
formData:{
date:'',//
},
//
show:false,//
content:'',//
}
},
onLoad(options) {},
@ -321,14 +337,34 @@ export default {
methods: {
//
async init(){
this.getCurrentDate()//
await this.getList();
},
//
getCurrentDate() {
let now = new Date();
let year = now.getFullYear();
let month = String(now.getMonth() + 1).padStart(2, '0'); // 0 1
let day = String(now.getDate()).padStart(2, '0');
let res = `${year}-${month}-${day}`
this.content = `${res} 是否确认请假?`
this.formData.date = res
},
//tag
async segmented(e) {
console.log(e)
//
await this.resetFilteredData()
this.filteredData.type = e.id//1=,2=,3=
//e.id|0 1 2
let status = e.id
this.filteredData.status = String(status)
await this.getList()
},
@ -368,7 +404,7 @@ export default {
this.tableList = []
}
let res = await marketApi.myClient(data)
let res = await commonApi.clockingList(data)
this.loading = false
this.isReachedBottom = false;
if (res.code != 1){
@ -379,23 +415,59 @@ export default {
return
}
this.tableList = this.tableList.concat(res.data.list.data); // 使 concat
this.tableList = this.tableList.concat(res.data.data); // 使 concat
console.log('列表',this.tableList)
this.filteredData.total = res.data.list.total
this.filteredData.total = res.data.data.total
this.filteredData.page++
},
this.countArr = {
type_0:res.data.count[0],
type_1:res.data.count[1],
type_2:res.data.count[2],
type_3:res.data.count[3],
max_count:res.data.gh.max_count,
lq_count:res.data.gh.lq_count,
//
openShow(){
this.show = true
},
//
closeShow(){
this.show = false
},
//
onClick(e){
console.log('xxx',e)
if(e.index == 0){
//
this.closeShow()
}else{
//
this.submitRest()
}
},
//
async submitRest() {
this.closeShow()
let param = {...this.formData}
let res = await commonApi.clockingRest(param)
if (res.code != 1) {
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
uni.showToast({
title: '操作成功',
icon: 'success'
})
//1s
setTimeout(() => {
this.segmented({id:0})//
}, 1500)
}
}
}

Loading…
Cancel
Save