checkIn.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. <template>
  2. <page-meta root-font-size="system" />
  3. <view class="attendance-page">
  4. <view class="header">
  5. <text class="title">我的考勤记录</text>
  6. <picker mode="selector" :range="timeRanges" @change="onTimeRangeChange">
  7. <view class="picker">
  8. {{ selectedTimeRange }}/切换
  9. </view>
  10. </picker>
  11. </view>
  12. <!-- 今日签到信息区域 -->
  13. <view class="todayCheckIn" v-if="todayInfoShow">
  14. <view class="check-in-container">
  15. <text class="todayAttTitle">今日签到信息</text>
  16. <view class="info-row">
  17. <view>
  18. <text class="ygoa-icon icon-date"></text>
  19. <text class="value">日期:</text>
  20. </view>
  21. <text class="label">{{ todayData.day }}</text>
  22. </view>
  23. <view class="info-row">
  24. <view>
  25. <text class="ygoa-icon icon-day"></text>
  26. <text class="value">晨签时间:</text>
  27. </view>
  28. <text class="label">{{ todayData.startTime || '未打卡' }} </text>
  29. </view>
  30. <view class="info-row">
  31. <view>
  32. <text class="ygoa-icon icon-night"></text>
  33. <text class="value">晚签时间:</text>
  34. </view>
  35. <text class="label">{{ todayData.endTime || '未打卡' }} </text>
  36. </view>
  37. </view>
  38. <!-- 分界线 -->
  39. <view class="divider"></view>
  40. <!-- 打卡记录 -->
  41. <!-- <view class="container">
  42. <view class="header">
  43. <text class="clockRecordTitle">打卡记录</text>
  44. </view>
  45. <view class="content" style="height: 41vh;">
  46. <z-paging :fixed="false" :default-page-size="pSize" default-page-no="1" @query="queryData" ref="paging">
  47. <view class="clockRecord" v-for="clockRecord in clockRecords" :key="clockRecord.date">
  48. <text class="date">{{ clockRecord.date }}</text>
  49. <view class="shifts">
  50. <view class="shift">
  51. <text class="shift-label">晨签:</text>
  52. <text class="shift-time">{{ clockRecord.morning||'没有该记录'}}</text>
  53. </view>
  54. <view class="shift">
  55. <text class="shift-label">晚签:</text>
  56. <text class="shift-time">{{ clockRecord.evening ||'没有该记录'}}</text>
  57. </view>
  58. </view>
  59. </view>
  60. </z-paging>
  61. </view>
  62. </view> -->
  63. <!-- 日历板块 -->
  64. <template>
  65. <view class="calendar-content">
  66. <view>
  67. <uni-calendar class="uni-calendar--hook" :selected="calenderData" :showMonth="true" @change="changeDate"
  68. @monthSwitch="monthSwitch" />
  69. </view>
  70. </view>
  71. </template>
  72. </view>
  73. <!-- 周,月数据统计区域 -->
  74. <view class="statistics" v-if="chartShow">
  75. <view class="statistic-card">
  76. <view class="statistic-title">{{ selectedTimeRange }}考勤统计</view>
  77. <view class="statistic-item">
  78. <view>
  79. <text class="ygoa-icon icon-attendance"></text>
  80. <text class="label">出勤:</text>
  81. </view>
  82. <text class="value">{{ attendanceCount }}</text>
  83. </view>
  84. <view class="statistic-item">
  85. <view>
  86. <text class="ygoa-icon icon-goOut"></text>
  87. <text class="label">外出:</text>
  88. </view>
  89. <text class="value">{{ goOutCount }}</text>
  90. </view>
  91. <view class="statistic-item">
  92. <view>
  93. <text class="ygoa-icon icon-late"></text>
  94. <text class="label">迟到:</text>
  95. </view>
  96. <text class="value">{{ lateCount }}</text>
  97. </view>
  98. <view class="statistic-item">
  99. <view>
  100. <text class="ygoa-icon icon-leaveEarly"></text>
  101. <text class="label">早退:</text>
  102. </view>
  103. <text class="value">{{ leaveEarlyCount }}</text>
  104. </view>
  105. <view class="statistic-item">
  106. <view>
  107. <text class="ygoa-icon icon-absenteeism"></text>
  108. <text class="label">缺勤:</text>
  109. </view>
  110. <text class="value">{{ absenteeismCount }}</text>
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 图表区域 -->
  115. <view class="chart-container" v-if="chartShow">
  116. <view class="">
  117. <text class="chart-title">考勤趋势图</text>
  118. <view class="charts-box">
  119. <qiun-data-charts :type="chartsType" :opts="opts" :chartData="chartData" />
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. </template>
  125. <script setup lang="ts">
  126. import {ref,onMounted,reactive} from 'vue';
  127. import {checkAttendance,getMyTotalCount,getMyQDQtAttendance,getMyTotalMonthCount} from '@/api/mine.js'
  128. import {useUserStore} from '@/store/user.js';
  129. const userStore = useUserStore();
  130. // 创建一个响应式对象记录今天的考勤数据
  131. const todayData = reactive({
  132. day: '', // 当前日期
  133. startTime: '', // 晨签到时间
  134. endTime: '', // 晚签到时间
  135. })
  136. // 控制今日签到信息和图表显示的状态
  137. const todayInfoShow = ref(true) // 今日签到信息是否显示
  138. const chartShow = ref(false) // 图表是否显示
  139. // 图表类型的响应式引用
  140. const chartsType = ref('')
  141. // 图表要填充的数据
  142. const chartData = ref({})
  143. // 图表配置选项
  144. const opts = ref({
  145. color: ["#EE6666", "#FAC858", "#FC8452", "#73C0DE", "#3CA272", "#1890FF", "#91CB74", "#9A60B4",
  146. "#ea7ccc"
  147. ], // 设定图表颜色
  148. padding: [15, 15, 0, 5],
  149. enableScroll: false, // 禁用滚动
  150. legend: {}, // 图例设置
  151. xAxis: {
  152. disableGrid: true // 禁用网格线
  153. },
  154. yAxis: {
  155. data: [{
  156. min: 0 // y轴最小值
  157. }]
  158. },
  159. extra: {
  160. column: {
  161. type: "group",
  162. width: 30,
  163. activeBgColor: "#000000",
  164. activeBgOpacity: 0.08
  165. }
  166. }
  167. });
  168. // 时间范围选择数组
  169. const timeRanges = ref(['日', '周', '月']);
  170. const selectedTimeRange = ref('日'); // 初始化选择的时间范围为“日”
  171. // 考勤相关统计数据
  172. const attendanceCount = ref(0); // 出勤次数
  173. const goOutCount = ref(0); // 外出次数
  174. const lateCount = ref(0); // 迟到次数
  175. const leaveEarlyCount = ref(0); // 早退次数
  176. const absenteeismCount = ref(0); // 缺勤次数
  177. //用户id
  178. const userId = userStore.user.useId; //拿到用户id
  179. //当前周的周一日期
  180. const thisMondayDate = ref('');
  181. onMounted(() => {
  182. initAttData(); //初始化日考勤数据
  183. });
  184. //初始化考勤数据
  185. function initAttData() {
  186. const nowDate = new Date();
  187. todayData.day = formatDate(nowDate);
  188. getthisMondayDate(nowDate);
  189. getDayAttData();
  190. initCalenderData();
  191. }
  192. //格式化日期
  193. function formatDate(date) {
  194. const year = date.getFullYear(); // 获取年份
  195. const month = date.getMonth() + 1; // 获取月份
  196. const day = date.getDate(); // 获取日期
  197. // 格式化月份和日期为两位数
  198. const formattedMonth = month < 10 ? '0' + month : month;
  199. const formattedDay = day < 10 ? '0' + day : day;
  200. return `${year}-${formattedMonth}-${formattedDay}`;
  201. }
  202. //获取日考勤数据
  203. function getDayAttData() {
  204. const params = {
  205. universalid: userId,
  206. rizi: todayData.day
  207. }
  208. checkAttendance(params).then(res => {
  209. if ("success" == res.returnMsg) {
  210. //数据初始化
  211. todayData.startTime = '';
  212. todayData.endTime = '';
  213. if (res.returnParams.list.length == 0) {
  214. return
  215. }
  216. const attList = res.returnParams.list;
  217. const filteredRecord1 = attList.filter(item => item.att_type_id === '1');
  218. const time1 = filteredRecord1.reduce((latest, current) => {
  219. const latestTime = new Date(latest.att_time);
  220. const currentTime = new Date(current.att_time);
  221. return (currentTime < latestTime) ? current : latest;
  222. });
  223. const filteredRecord2 = attList.filter(item => item.att_type_id === '2');
  224. const time2 = filteredRecord2.reduce((latest, current) => {
  225. const latestTime = new Date(latest.att_time);
  226. const currentTime = new Date(current.att_time);
  227. return (currentTime > latestTime) ? current : latest;
  228. });
  229. if (time1 !== undefined) {
  230. todayData.startTime = time1.att_time.split(' ')[1];
  231. }
  232. if (time2 !== undefined) {
  233. todayData.endTime = time2.att_time.split(' ')[1];
  234. }
  235. }
  236. })
  237. }
  238. //打卡历史记录(日历版)
  239. //日历表数据
  240. const calenderData = ref([])
  241. // 初始化此月日历数据
  242. function initCalenderData() {
  243. const params = {
  244. type: 2, //设置时间区间
  245. universalid: userId,
  246. ks_att_time: todayData.day.slice(0, 8) + '01',
  247. js_att_time: todayData.day,
  248. pSize: parseInt(todayData.day.slice(8, 10), 10),//当前天数
  249. p: 1
  250. }
  251. getCalenderData(params)
  252. }
  253. //日历数据的刷新
  254. function getCalenderData(params){
  255. getMyQDQtAttendance(params).then(({ returnParams }) => {
  256. //定义一个数组用于接收日历data
  257. const thisCalenderData=[]
  258. returnParams.list.forEach(item => {
  259. if ((!item.type.includes('1') || !item.type.includes('2'))&&item.att_date.slice(0, 10)!==todayData.day) {
  260. const calenderDataInfo = {
  261. date: item.att_date.slice(0, 10),
  262. info: '缺卡'
  263. }
  264. thisCalenderData.push(calenderDataInfo)
  265. }
  266. });
  267. calenderData.value=thisCalenderData
  268. })
  269. }
  270. //日历点击日期切换事件
  271. function changeDate(e) {
  272. // console.log('changeDate: ',e);
  273. console.log("3:calenderData.value " + JSON.stringify(calenderData.value));
  274. todayData.day = e.fulldate
  275. getDayAttData()
  276. }
  277. //传入年份月份,返回此月天数
  278. function getDaysInMonth(year, month) {
  279. const date = new Date(year, month - 1, 1);
  280. // 将日期设置为下一个月的第0天,即当前月的最后一天
  281. date.setMonth(date.getMonth() + 1);
  282. date.setDate(0);
  283. // 返回当前月的最后一天的日期,即该月的天数
  284. return date.getDate();
  285. }
  286. //月份切换事件
  287. function monthSwitch(e) {
  288. // console.log('monthSwitch: ', e);
  289. const days=getDaysInMonth(e.year,e.month);
  290. const params = {
  291. type: 2, //设置时间区间
  292. universalid: userId,
  293. ks_att_time: e.year+'-'+e.month+'-' + '01',
  294. js_att_time: e.year+'-'+e.month+'-' +days,
  295. pSize: days,
  296. p: 1
  297. }
  298. getCalenderData(params);
  299. }
  300. // //打卡历史记录(下拉刷新版)
  301. // const paging = ref(null)
  302. // const pSize = ref(5)
  303. // function complete(list, total, pageNo) {
  304. // if (pageNo == 1) {
  305. // paging.value.complete(list);
  306. // return
  307. // }
  308. // // 防止重复获取最后一次信息
  309. // if (pSize.value * pageNo < total) {
  310. // paging.value.complete(list)
  311. // } else {
  312. // paging.value.complete([])
  313. // }
  314. // }
  315. // //日考勤历史记录
  316. // const clockRecords = ref([])
  317. // const totalPage = ref(0)
  318. // //获取日考勤历史(下拉刷新)
  319. // function getDayAttHistory() {
  320. // const params = {
  321. // type: 1, //不设时间区间
  322. // universalid: userId,
  323. // ks_att_time: '',
  324. // js_att_time: '',
  325. // pSize: pSize.value,
  326. // p: 1
  327. // }
  328. // getMyQDQtAttendance(params).then(({ returnParams }) => {
  329. // totalPage.value = Math.ceil(returnParams.total / pSize.value)
  330. // const list = returnParams.list.map(item => {
  331. // return {
  332. // date: item.att_date.substring(0, 10),
  333. // morning: item.time.split(',')[item.type.split(',').indexOf("1")],
  334. // evening: item.time.split(',')[item.type.split(',').indexOf("2")],
  335. // }
  336. // });
  337. // clockRecords.value = list;
  338. // complete(clockRecords.value, returnParams.total, returnParams.current)
  339. // })
  340. // }
  341. // // 刷新
  342. // function queryData(pageNo, pSize, queryType) {
  343. // switch (queryType) {
  344. // case 0: // 下拉刷新
  345. // case 1: // 初始加载
  346. // getDayAttHistory()
  347. // break
  348. // case 3: // 上拉加载
  349. // scrollQuery(pageNo, pSize)
  350. // break
  351. // default: // 默认刷新
  352. // getDayAttHistory()
  353. // break
  354. // }
  355. // }
  356. // //上拉加载事件
  357. // function scrollQuery(pageNo, pSize) {
  358. // const params = {
  359. // type: 1, //不设时间区间
  360. // universalid: userId,
  361. // ks_att_time: '',
  362. // js_att_time: '',
  363. // pSize: pSize,
  364. // p: pageNo
  365. // }
  366. // getMyQDQtAttendance(params).then(({ returnParams }) => {
  367. // const list = returnParams.list.map(item => {
  368. // return {
  369. // date: item.att_date.substring(0, 10),
  370. // morning: item.time.split(',')[item.type.split(',').indexOf("1")],
  371. // evening: item.time.split(',')[item.type.split(',').indexOf("2")],
  372. // }
  373. // });
  374. // if (pageNo <= totalPage.value) {
  375. // clockRecords.value.push(...list);
  376. // }
  377. // complete(list, returnParams.total, pageNo)
  378. // })
  379. // }
  380. // 日周月时间范围切换事件
  381. function onTimeRangeChange(event) {
  382. const selectedIndex = event.detail.value;
  383. selectedTimeRange.value = timeRanges.value[selectedIndex]; // 设置选择的时间范围(日周月)
  384. // 根据选择的时间范围更新展示内容
  385. switch (selectedTimeRange.value) {
  386. case '日':
  387. getDayAttData();
  388. showDay(); // 显示今日考勤
  389. break;
  390. case '周':
  391. chartsType.value = 'pie'; // 设置图表类型为饼图
  392. fetchWeekAttData().then(message => {
  393. console.log(message);
  394. showWeekAndMonth();
  395. updateChart(message);
  396. })
  397. .catch(error => {
  398. console.error(error);
  399. });
  400. break;
  401. case '月':
  402. chartsType.value = 'column'; // 设置图表类型为柱状图
  403. fetchMonthAttData();
  404. showWeekAndMonth();
  405. // fetchMonthAttData().then(message => {
  406. // console.log('message', message);
  407. // showWeekAndMonth();
  408. // updateChart(message);
  409. // })
  410. // .catch(error => {
  411. // console.error(error);
  412. // });
  413. break;
  414. }
  415. };
  416. // 显示今日考勤数据
  417. function showDay() {
  418. todayInfoShow.value = true; // 显示今日签到信息
  419. chartShow.value = false; // 隐藏图表
  420. }
  421. // 显示周或者月考勤
  422. function showWeekAndMonth() {
  423. todayInfoShow.value = false; // 隐藏今日签到信息
  424. chartShow.value = true; // 显示图表
  425. }
  426. //计算本周周一日期
  427. function getthisMondayDate(today) {
  428. const dayOfWeek = today.getDay(); // 0 (周日) 到 6 (周六)
  429. const dayOfMonth = today.getDate();
  430. // 计算本周周一的日期
  431. const offset = dayOfWeek === 0 ? -6 : 1; // 如果今天是周日,则偏移量为-6,否则为1
  432. const thisMonday = new Date(today);
  433. thisMonday.setDate(dayOfMonth - dayOfWeek + offset);
  434. thisMondayDate.value = formatDate(thisMonday);
  435. }
  436. //获取周考勤记录
  437. function fetchWeekAttData() {
  438. return new Promise((resolve, reject) => {
  439. const params = {
  440. staffId: userId,
  441. start_date: thisMondayDate.value,
  442. end_date: todayData.day
  443. }
  444. getMyTotalCount(params).then(res => {
  445. const myWeekAttData = res.returnParams;
  446. const mockData = {
  447. series: [{
  448. data: [
  449. {
  450. "name": "缺勤",
  451. "value": myWeekAttData.type6,
  452. "labelText": "缺勤:" + myWeekAttData.type6 + "次"
  453. },
  454. {
  455. "name": "迟到",
  456. "value": myWeekAttData.type4,
  457. "labelText": "迟到:" + myWeekAttData.type4 + "次"
  458. },
  459. {
  460. "name": "早退",
  461. "value": myWeekAttData.type5,
  462. "labelText": "早退:" + myWeekAttData.type5 + "次"
  463. },
  464. {
  465. "name": "出勤",
  466. "value": myWeekAttData.attDays,
  467. "labelText": "出勤:" + myWeekAttData.attDays + "次"
  468. },
  469. {
  470. "name": "外出",
  471. "value": myWeekAttData.type2,
  472. "labelText": "外出:" + myWeekAttData.type2 + "次"
  473. },
  474. {
  475. "name": "公休",
  476. "value": myWeekAttData.type1,
  477. "labelText": "公休:" + myWeekAttData.type1 + "次"
  478. },
  479. // {
  480. // "name": "未排班",
  481. // "value": myWeekAttData.type3,
  482. // "labelText": "未排班:" + myWeekAttData.type3 + "次"
  483. // }
  484. ]
  485. }],
  486. };
  487. // const weekData = mockData.series[0].data;
  488. attendanceCount.value = myWeekAttData.attDays;
  489. goOutCount.value = myWeekAttData.type2;
  490. lateCount.value = myWeekAttData.type4;
  491. leaveEarlyCount.value = myWeekAttData.type5;
  492. absenteeismCount.value = myWeekAttData.type6;
  493. resolve(mockData)
  494. }).catch(error => {
  495. reject(error)
  496. })
  497. })
  498. }
  499. // 获取月考勤记录
  500. function fetchMonthAttData() {
  501. //数据初始化
  502. attendanceCount.value = 0;
  503. goOutCount.value = 0;
  504. lateCount.value = 0;
  505. leaveEarlyCount.value = 0;
  506. absenteeismCount.value = 0;
  507. const params = {
  508. staffId: userId,
  509. now_date: todayData.day
  510. }
  511. getMyTotalMonthCount(params).then(res=>{
  512. const myMonthAttData = res.returnParams;
  513. let data1 = []; // 收集 type6 的值
  514. let data2 = []; // 收集 type4 的值
  515. let data3 = []; // 收集 type5 的值
  516. console.log('attendanceCount: ',attendanceCount.value);
  517. // 遍历 myMonthAttData 并收集指定类型的值
  518. myMonthAttData.forEach(item => {
  519. data1.push(item.type6);
  520. data2.push(item.type4);
  521. data3.push(item.type5);
  522. attendanceCount.value += item.attDays;
  523. goOutCount.value += item.type2;
  524. lateCount.value += item.type4;
  525. leaveEarlyCount.value += item.type5;
  526. absenteeismCount.value += item.type6;
  527. // console.log('attendanceCount: ',attendanceCount.value,typeof myMonthAttData.attDays );
  528. });
  529. console.log('data1',data1);
  530. // 定义一个常量数组生成器
  531. const generateWeekArray = n => Array.from({ length: n }, (_, i) => `第${i + 1}周`);
  532. let categoriesArr=generateWeekArray(4)
  533. console.log(categoriesArr);
  534. const mockData = {
  535. categories:  categoriesArr,
  536. series: [{
  537. name: "缺勤",
  538. data: data1
  539. }, {
  540. name: "迟到",
  541. data: data2
  542. }, {
  543. name: "早退",
  544. data: data3
  545. }]
  546. };
  547. updateChart(mockData)
  548. })
  549. // return new Promise((resolve, reject) => {
  550. // const weekNodeList = [];// 存储近月每周的周一,周天日期
  551. // weekNodeList.unshift(thisMondayDate.value, todayData.day);
  552. // while (weekNodeList.length !== 8) {
  553. // const weekNode = getOneDaysAgo(weekNodeList[0]);
  554. // weekNodeList.unshift(weekNode);
  555. // weekNodeList.unshift(getSixDaysAgo(weekNode));
  556. // }
  557. // const data1 = [];
  558. // const data2 = [];
  559. // const data3 = [];
  560. // const dataFetchPromises = []; // 存储所有数据请求的promise
  561. // for (let i = 0; i < weekNodeList.length - 1; i += 2) {
  562. // const params = {
  563. // staffId: userId,
  564. // start_date: weekNodeList[i],
  565. // end_date: weekNodeList[i + 1]
  566. // };
  567. // const fetchPromise = getMyTotalCount(params).then(res => {
  568. // // for (const type in res.returnParams) {
  569. // // console.log('type', type);
  570. // // }
  571. // console.log('res.returnParams', res.returnParams);
  572. // data1.push(res.returnParams.type6);
  573. // data2.push(res.returnParams.type4);
  574. // data3.push(res.returnParams.type5);
  575. // });
  576. // dataFetchPromises.push(fetchPromise);
  577. // }
  578. // // 等待所有数据请求完成
  579. // Promise.all(dataFetchPromises).then(() => {
  580. // const params = {
  581. // staffId: userId,
  582. // start_date: weekNodeList[0],
  583. // end_date: weekNodeList[weekNodeList.length - 1]
  584. // };
  585. // return getMyTotalCount(params);
  586. // }).then(res => {
  587. // const myMonthAttData = res.returnParams;
  588. // // console.log(data1); // 打印data1检查内容
  589. // resolve(mockData);
  590. // }).catch(error => {
  591. // reject(error);
  592. // });
  593. // });
  594. }
  595. //获取六天前的日期
  596. function getSixDaysAgo(dateStr) {
  597. const date = new Date(dateStr);
  598. date.setDate(date.getDate() - 6);
  599. return date.toISOString().split('T')[0]; // 返回格式为'YYYY-MM-DD'的字符串
  600. }
  601. //获取一天前的日期
  602. function getOneDaysAgo(dateStr) {
  603. const date = new Date(dateStr);
  604. date.setDate(date.getDate() - 1);
  605. return date.toISOString().split('T')[0]; // 返回格式为'YYYY-MM-DD'的字符串
  606. }
  607. // 更新图表数据
  608. function updateChart(res) {
  609. chartData.value = JSON.parse(JSON.stringify(res)); // 更新图表数据
  610. }
  611. </script>
  612. <style lang="scss" scoped>
  613. // @import "@/static/font/ygoa/iconfont.css";
  614. .ygoa-icon {
  615. margin-right: 0.5rem;
  616. font-size: calc(2rem + 0px) !important;
  617. vertical-align: middle;
  618. /* 确保图标与文本竖直居中 */
  619. }
  620. .attendance-page {
  621. padding: 20px;
  622. background-color: #f9f9f9;
  623. ::v-deep .calendar-content {
  624. margin: -20px;
  625. margin-top: 20px;
  626. .uni-calendar__header {
  627. .uni-calendar__header-text {
  628. font-size: calc(14px + .5*(1rem - 16px)) !important;
  629. }
  630. .uni-calendar__backtoday {
  631. padding: 2px 8px 2px 10px !important;
  632. font-size: calc(0.75rem + 0px) !important;
  633. }
  634. }
  635. .uni-calendar__box {
  636. .uni-calendar__weeks {
  637. .uni-calendar__weeks-day {
  638. .uni-calendar__weeks-day-text {
  639. font-size: calc(14px + .5*(1rem - 16px)) !important;
  640. }
  641. }
  642. .uni-calendar__weeks-item {
  643. .uni-calendar-item__weeks-box-item {
  644. .uni-calendar-item__weeks-box-circle {
  645. width: calc(8px + .5*(1rem - 16px)) !important;
  646. height: calc(8px + .5*(1rem - 16px)) !important;
  647. top: calc(5px - .25*(1rem - 16px)) !important;
  648. right: calc(5px - .25*(1rem - 16px)) !important;
  649. }
  650. .uni-calendar-item__weeks-box-text {
  651. font-size: calc(14px + .5*(1rem - 16px)) !important;
  652. }
  653. .uni-calendar-item__weeks-lunar-text {
  654. font-size: calc(12px + .5*(1rem - 16px)) !important;
  655. }
  656. }
  657. }
  658. }
  659. }
  660. }
  661. }
  662. .header {
  663. display: flex;
  664. justify-content: space-between;
  665. align-items: center;
  666. margin-bottom: 20px;
  667. .clockRecordTitle {
  668. font-size: calc(1.25rem + 0px) !important;
  669. margin: auto;
  670. }
  671. }
  672. .title {
  673. font-size: calc(1.5rem + 0px) !important;
  674. font-weight: bold;
  675. color: #333;
  676. }
  677. .picker {
  678. border: 1px solid #3498db;
  679. border-radius: 5px;
  680. padding: 10px;
  681. background-color: #ecf6fc;
  682. color: #3498db;
  683. }
  684. .statistics {
  685. // display: flex;
  686. justify-content: center;
  687. }
  688. .statistic-card {
  689. background: white;
  690. border-radius: 10px;
  691. padding: 20px;
  692. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  693. /* width: 100%; */
  694. max-width: 600px;
  695. }
  696. .statistic-title {
  697. text-align: center;
  698. font-size: calc(1.25rem + 0px) !important;
  699. font-weight: bold;
  700. color: #333;
  701. }
  702. .statistic-item {
  703. display: flex;
  704. justify-content: space-between;
  705. border-bottom: 1px solid #eee;
  706. padding: 10px 0;
  707. }
  708. .label {
  709. color: #666;
  710. }
  711. .value {
  712. font-size: calc(1.125rem + 0px) !important;
  713. font-weight: bold;
  714. line-height: calc(2rem + 0px) !important;
  715. color: #333;
  716. }
  717. .label {
  718. font-size: calc(1rem + 0px) !important;
  719. line-height: calc(2rem + 0px) !important;
  720. }
  721. .chart-container {
  722. margin-top: 20px;
  723. }
  724. .chart-title {
  725. font-size: calc(1.25rem + 0px) !important;
  726. font-weight: bold;
  727. text-align: center;
  728. margin-bottom: 10px;
  729. color: #333;
  730. }
  731. .charts-box {
  732. width: 100%;
  733. height: 300px;
  734. }
  735. .todayCheckIn {
  736. background-color: #ffffff;
  737. padding: 20px;
  738. margin: auto -20px; //抵消父级padding
  739. box-sizing: border-box;
  740. border-radius: 10px;
  741. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  742. }
  743. .check-in-container {
  744. width: 100%;
  745. height: 100%;
  746. display: flex;
  747. flex-direction: column;
  748. align-items: center;
  749. justify-content: center;
  750. }
  751. .todayAttTitle {
  752. font-size: calc(1.375rem + 0px) !important;
  753. font-weight: bold;
  754. margin-bottom: 20px;
  755. }
  756. .info-row {
  757. width: 100%;
  758. display: flex;
  759. align-items: center;
  760. justify-content: space-between;
  761. margin-bottom: 10px;
  762. }
  763. .icon {
  764. width: 50rpx;
  765. height: 50rpx;
  766. margin-right: 20rpx;
  767. vertical-align: middle;
  768. /* 确保图标与文本竖直居中 */
  769. }
  770. .clockRecord {
  771. margin-bottom: 20px;
  772. padding: 10px;
  773. border: 1px solid #ccc;
  774. border-radius: 8px;
  775. }
  776. .date {
  777. font-size: 16px;
  778. font-weight: bold;
  779. margin-bottom: 5px;
  780. }
  781. .name {
  782. font-size: 14px;
  783. color: #666;
  784. margin-bottom: 10px;
  785. }
  786. .divider {
  787. border-bottom: 5px dashed #ccc; //虚线
  788. margin: 10px 0;
  789. }
  790. .shift-label {
  791. font-size: 14px;
  792. color: #333;
  793. }
  794. .shift-time {
  795. font-size: 14px;
  796. color: #333;
  797. }
  798. </style>