tj
2025-06-05 bba272999cc546f65781bf3d20245a3f819af67f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
<template>
  <div>
    <!-- 列表页面 -->
 
    <div class="page-container" v-if="showEdit == 0">
      <!-- 查询条件 -->
      <div class="search-section">
        <el-form :inline="true" :model="queryForm" size="small" class="demo-form-inline">
          <el-form-item label="日志日期" prop="daily_date">
            <el-date-picker
              v-model="queryForm.daily_date"
              type="date"
              placeholder="输入日期"
              size="small"
              value-format="YYYY-MM-DD"
              @change="handleDailyDate"
            />
          </el-form-item>
 
          <el-form-item label="所属项目" prop="project_id">
            <el-select v-model="queryForm.project_id" placeholder="所属项目" clearable filterable>
              <el-option v-for="item in projectInfoArr" :key="item.id" :label="item.project_name" :value="item.id" />
            </el-select>
          </el-form-item>
 
          <el-form-item label="关键字">
            <el-input v-model="queryForm.keyword" placeholder="日志内容/备注" clearable filterable />
          </el-form-item>
 
          <el-form-item label="日志类型">
            <el-select v-model="queryForm.daily_type" placeholder="日志类型" clearable filterable>
              <el-option v-for="item in dailyTypeArr" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
 
          <el-form-item label="日志状态">
            <el-select v-model="queryForm.daily_status" placeholder="日志状态" clearable filterable>
              <el-option v-for="item in dailyStatusArr" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
 
          <el-form-item label="提交状态">
            <el-select v-model="queryForm.is_commit" placeholder="提交状态" clearable filterable>
              <el-option v-for="item in dailyCommitArr" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
 
          <el-form-item label="确认状态">
            <el-select v-model="queryForm.is_confirm" placeholder="确认状态" clearable filterable>
              <el-option v-for="item in dailyConfirmArr" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
 
          <el-form-item>
            <el-button type="primary" @click="search">查询</el-button>
            <!-- <el-button type="primary" v-if="commitFlag==0"  @click="add">新增</el-button> -->
            <!-- <el-button type="primary" v-if="commitFlag == 0 && uncommitCount == 0" @click="addBatch"
              >批量新增</el-button
            > -->
            <!-- <el-tooltip v-if="commitFlag==0 && pointDailyDateSize!=0 "  effect="dark" content="会根据当前日志日期批量提交所有数据"> -->
            <el-button type="primary" v-if="commitFlag == 0 && pointDailyDateSize != 0" @click="handleActualHoursBatch"
              >工时确认</el-button
            >
            <el-tooltip v-if="commitFlag == 0" effect="dark" content="会根据当前日志日期批量提交所有数据">
              <el-button type="primary" v-if="commitFlag == 0 && pointDailyDateSize != 0" @click="commitBatch"
                >提交</el-button
              >
            </el-tooltip>
 
            <el-button type="primary" v-if="commitFlag == 1" @click="handleSupplementary">补录</el-button>
          </el-form-item>
        </el-form>
      </div>
      <!-- 表格 -->
      <div class="main-section">
        <div class="calendar-section">
          <el-calendar v-model="calendarForm.calendarDate">
            <template #date-cell="{ data }">
              <div class="calendarClass">
                <p>
                  {{ data.day.split('-').slice(1).join('-') }}
                  {{ data.isSelected ? '✔️' : '' }}
                </p>
                <p class="unCommitClass" v-if="currentDateData(data.day) && currentDateData(data.day).is_commit == '0'">
                  未提交
                </p>
                <p class="commitClass" v-if="currentDateData(data.day) && currentDateData(data.day).is_commit == '1'">
                  已提交
                </p>
              </div>
            </template>
          </el-calendar>
          <!-- {{ calendarForm.calendarDate }} -->
          <p>填写日志当天之前如果有未提交的则不可填写!!!请先提交之前的日志</p>
        </div>
        <div class="table-section">
          <el-table
            :data="tableData"
            v-loading="loading"
            width="100%"
            :row-class-name="rowClassName"
            table-layout="auto"
            size="mini"
          >
            <el-table-column type="index" :index="indexMethod" label="序号" fixed="left" width="60px"></el-table-column>
            <!-- 动态生成表格列 -->
            <el-table-column
              v-for="column in tableColumns"
              :key="column.prop"
              :prop="column.prop"
              :label="column.label"
              :min-width="column.minWidth"
              :fixed="column.fixed"
              :width="column.width"
            >
              <!-- <template #default="{ row }">
                <span v-html="formatColumnContent(row,row[column.prop])"></span>
              </template> -->
            </el-table-column>
 
            <!--
              <el-table-column label="操作栏" fixed="right"  width="300px">
                <template #default="scope" >
 
                <el-button type="text" :disabled="scope.row.is_commit==1 " size="small" round @click="handleEdit(scope.row)">编辑</el-button>
                  <el-button type="text" :disabled="scope.row.is_commit==1" size="small" round @click="handleDelete(scope.row)">删除</el-button>
 
                  <el-button type="text" size="small" :disabled="scope.row.is_commit==1" round @click="handleActualHours(scope.row)">工时确认</el-button>
                  <el-tooltip content="填完工时后需提交,提交之后不可改" placement="top">
                    <el-button type="text" :disabled="scope.row.is_confirm==1||scope.row.is_commit==1 " size="small" round @click="handleCommit(scope.row)">提交</el-button>
                  </el-tooltip>
 
                </template>
 
              </el-table-column> -->
          </el-table>
 
          <div class="demo-pagination-block">
            <!-- <div class="demonstration">All combined</div> -->
            <el-pagination
              v-model:current-page="currentPage"
              v-model:page-size="pageSize"
              :page-sizes="[10, 20, 30]"
              :small="small"
              :disabled="disabled"
              :background="background"
              layout="total, sizes, prev, pager, next, jumper"
              :total="totalSize"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>
      </div>
    </div>
 
    <!-- 编辑页面 -->
    <diary-add
      v-if="showEdit == 1"
      @editClose="editClose"
      :editId="editDiaryId"
      :editDailyDate="editDailyDate"
      :actualHourFlag="actualHourFlag"
    ></diary-add>
 
    <diary-add-batch
      v-if="showEdit == 2"
      :editDailyDate="editDailyDate"
      :comfirmFlag="comfirmFlag"
      @editClose="editClose"
    ></diary-add-batch>
 
    <diary-add
      v-if="showEdit == 3"
      @editClose="editClose"
      :editId="editDiaryId"
      :editDailyDate="editDailyDate"
      :actualHourFlag="actualHourFlag"
    ></diary-add>
 
    <diary-extra
      v-if="showEdit == 4"
      @editClose="editClose"
      :editId="editDiaryId"
      :editDailyDate="editDailyDate"
      :actualHourFlag="actualHourFlag"
    ></diary-extra>
  </div>
</template>
 
<script>
import { ref, reactive, onMounted, watch } from 'vue'
import { ElMessageBox, ElMessage, ElNotification } from 'element-plus'
import projectInfo from '@/model/projectInfo'
import projectDaily from '@/model/projectDaily'
import ProjectDailyMain from '@/model/projectDailyMain'
import sysDictItemModel from '@/model/sysDictItem'
import { getDefaultDate,
  getYesterdayDate,
  getStartAndEndOfWeek,
  getPreviousWeekDates,
  getPreviousFriday,
  getDayOfWeek } from '@/utils/dateUtils'
import DiaryAdd from './diary-add'
import DiaryAddBatch from './diary-add-batch'
import DiaryExtra from './diary-extra'
 
export default {
  components: {
    DiaryAdd,
    DiaryAddBatch,
    DiaryExtra,
  },
 
  setup() {
    const dailyCalendarDateData = ref([])
 
    const editDiaryId = ref(1)
    const editDailyDate = ref('')
    const comfirmFlag = ref(false)
    const showEdit = ref(0)
    const actualHourFlag = ref(false)
    // 设置为当天或昨天都可以做修改
    const actualHourOpFlag = ref(false)
 
    const loading = ref(false)
 
    const currentPage = ref(1)
    const pageSize = ref(10)
    const totalSize = ref(100)
 
    const dailyTypeArr = ref([])
    const dailyStatusArr = ref([])
    const projectInfoArr = ref([])
    const dailyCommitArr = ref([])
    const dailyConfirmArr = ref([])
 
    const resultPage = ref({})
    const tableData = ref([])
    const commitFlag = ref(1)
    const pointDailyDateSize = ref(0)
    const uncommitCount = ref(0)
 
    const queryForm = reactive({
      keyword: '',
      daily_type: '',
      daily_status: '',
      daily_date: getDefaultDate(),
      project_id: '',
      is_commit: '',
      is_confirm: '',
      page: 1,
      count: 10,
    })
 
    const tableColumns = ref([
      // { label: '日期', prop: 'daily_date',minWidth:'120px'  ,width:''},
      { label: '所属项目', prop: 'project_name2', minWidth: '120', width: '120', fixed: 'left' },
      // { label: '任务', prop: 'task_name',minWidth:'120px' },
      { label: '状态', prop: 'daily_status_name', minWidth: '80', width: '80' },
      { label: '日志内容', prop: 'daily_content', minWidth: '300', width: '300' },
      { label: '计划用时', prop: 'estimated_hours', minWidth: '90', width: '90' },
      { label: '实际用时', prop: 'actual_hours', minWidth: '90', width: '90' },
      { label: '创建人', prop: 'create_user_name', minWidth: '80', width: '80' },
      { label: '提交状态', prop: 'daily_commit_name', minWidth: '100', width: '100' },
      { label: '确认状态', prop: 'daily_confirm_name', minWidth: '90', width: '90' },
      { label: '确认意见', prop: 'confirm_content', minWidth: '120', width: '120' },
      { label: '备注', prop: 'remark', minWidth: '100', width: '100' },
      // 其他列信
    ])
 
    onMounted(() => {
      // 初始化心思
      initData()
    })
 
    const initData = () => {
      getDiaryPage()
      getDailyMonthData()
      loadDictDitems()
      handleDailyDate()
      // 查看查询的日期有没有日志
      // 工时确认只能确认当天或昨天的内容
      actualHourOpFlag.value = false
      // 计划工时提醒
      estimateHourTip()
      // 让日历重新加载数据,根据日期的时间来拼接时分秒,否则老是会跳转到当天
      const date = queryForm.daily_date
      calendarForm.calendarDate = new Date(date)
    }
 
    const calendarForm = reactive({
      calendarDate: new Date(),
    })
 
    // 监听日历日期的变化
    watch(
      () => calendarForm.calendarDate,
      (newDate, oldDate) => {
        getDailyMonthData()
        const newDateStr = getFormatDateStr(newDate)
        queryForm.daily_date = newDateStr
      },
    )
 
    // 表单日期的变化
    watch(
      () => queryForm.daily_date,
      (newDate, oldDate) => {
        const currentDate = getFormatDate(newDate)
        calendarForm.calendarDate = currentDate
        // 重新加载日志信息
        // initData()
        getDiaryPage()
        handleDailyDate()
      },
    )
 
    // 表格数据的变化
    watch(
      () => tableData.value,
      (newData, oldData) => {
        if (tableData.value) {
          pointDailyDateSize.value = tableData.value.length
        } else {
          pointDailyDateSize.value = 0
        }
        console.log('commitFlag', commitFlag.value, 'pointDailyDateSize:', pointDailyDateSize.value)
      },
    )
 
    // 根据日期获取当天数据
    const currentDateData = currDate => {
      const data = dailyCalendarDateData.value.find(f => f.daily_date == currDate)
      return data
    }
 
    const getDailyMonthData = async () => {
      try {
        loading.value = true
        // 转换成年月日期
        const formattedDate = getFormatDateStr(calendarForm.calendarDate)
        const queryForm = {
          calendarDate: formattedDate,
        }
        const dailyCalendar = await ProjectDailyMain.getProjectDailyMainMonthPersonal(queryForm)
        dailyCalendarDateData.value = dailyCalendar
        // console.log(dailyCalendar)
        loading.value = false
      } catch (error) {
        loading.value = false
        if (error.code === 10020) {
        }
      }
    }
 
    /**
     * 将日期时间转换曾字符串yyyy-MM-dd
     */
    const getFormatDateStr = currentDate => {
      const year = currentDate.getFullYear()
      const month = (currentDate.getMonth() + 1).toString().padStart(2, '0') // 月份需要补零
      const day = currentDate.getDate().toString().padStart(2, '0') // 天数需要补零
      const formattedDate = `${year}-${month}-${day}`
      return formattedDate
    }
 
    const getFormatDate = currentDate => new Date(currentDate)
 
    const getDiaryPage = async () => {
      try {
        queryForm.page = currentPage.value
        queryForm.count = pageSize.value
 
        loading.value = true
        resultPage.value = await projectDaily.getProjectDailyPagePersonal(queryForm)
        tableData.value = resultPage.value.items
        totalSize.value = resultPage.value.total
 
        currentPage.value = resultPage.value.page
        pageSize.value = resultPage.value.count
 
        loading.value = false
      } catch (error) {
        loading.value = false
        if (error.code === 10020) {
          tableData.value = []
        }
      }
    }
 
    const search = () => {
      getDiaryPage()
    }
 
    // 根据字典类型查询字典
    const loadDictDitems = async () => {
      dailyTypeArr.value = await sysDictItemModel.getSysDictItemListByType('daily_type')
      dailyStatusArr.value = await sysDictItemModel.getSysDictItemListByType('daily_status')
      projectInfoArr.value = await projectInfo.getProjectInfoList('')
      dailyCommitArr.value = await sysDictItemModel.getSysDictItemListByType('daily_commit')
      dailyConfirmArr.value = await sysDictItemModel.getSysDictItemListByType('daily_confirm')
    }
 
    const handleDailyDate = async () => {
      if (queryForm.daily_date) {
        const dailyMain = await ProjectDailyMain.getProjectDailyMainByDailyDate(queryForm.daily_date)
        if (dailyMain) {
          commitFlag.value = dailyMain.is_commit
        } else {
          commitFlag.value = 0
        }
      }
 
      // 查找是否有未提交的,如果存在未提交的则不允许新增
      uncommitCount.value = await ProjectDailyMain.getProjectDailyMainUncommitCount({})
    }
 
    const handleEdit = row => {
      // 编辑操作
      editDiaryId.value = row.id
      showEdit.value = 1
      actualHourFlag.value = false
    }
 
    const handleDelete = async row => {
      let planHours = Number(row.estimated_hours)
      let actualHours = Number(row.actual_hours)
      const existHours = await projectDaily.getExistsHours(queryForm.daily_date, '')
 
      if (existHours) {
        planHours = Number(existHours.estimated_hours) - planHours
        actualHours = Number(existHours.actual_hours) - actualHours
      }
 
      if (planHours < 6) {
        ElMessage.error(`计划用时小于6小时不能删除,${queryForm.daily_date}的删除后计划工时数为${planHours}小时!`)
        return
      }
      if (actualHours < 6) {
        ElMessage.error(`实际用时小于6小时不能删除,${queryForm.daily_date}的删除后实际用时数为${actualHours}小时!`)
        return
      }
 
      // 删除操作
      // ElMessageBox.confirm('此操作将永久删除该日志,且该日的计划需要重新提交, 是否继续?', '提示', {
      ElMessageBox.confirm('此操作将永久删除该日志, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          const res = await projectDaily.deleteProjectDaily(row.id)
          if (res.code < window.MAX_SUCCESS_CODE) {
            initData()
            ElMessage.success(`${res.message}`)
          }
        })
        .catch(() => {
          // 用户点击取消按钮时执行的操作
          // 可以选择不做任何事情,也可以显示取消消息
          // ElMessage.info('操作已取消'); // 如果需要显示取消消息,可以取消注释
        })
    }
 
    // 提交
    const handleCommit = async row => {
      const esTime = await projectDaily.getDailyDatePlanTime(queryForm.daily_date, '')
      const acTime = await projectDaily.getDailyDateActualTime(queryForm.daily_date, '')
 
      // 计划或实际工时小于6小时不允许提交
 
      if (Number(esTime) < 6) {
        // 计划工时小于6小时不允许提交
        ElMessage.error('计划工时小于6小时不允许提交!')
        return
      }
      if (Number(acTime) < 6) {
        // 实际工时小于6小时不允许提交
        ElMessage.error('日志实际工时小于6小时不允许提交!')
        return
      }
 
      // 查看实际工时是否小6小时
      const mess = '此操作将提交该日志, 是否继续?'
      ElMessageBox.confirm(mess, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          const res = await projectDaily.commitProjectDaily(row.id)
          if (res.code < window.MAX_SUCCESS_CODE) {
            initData()
            ElMessage.success(`${res.message}`)
          }
        })
        .catch(() => {
          // 用户点击取消按钮时执行的操作
          // 可以选择不做任何事情,也可以显示取消消息
          // ElMessage.info('操作已取消'); // 如果需要显示取消消息,可以取消注释
        })
    }
 
    // 确认
    const handleConfirm = row => {
      ElMessageBox.confirm('此操作将确认该日志, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          const res = await projectDaily.confirmProjectDaily(row.id)
          if (res.code < window.MAX_SUCCESS_CODE) {
            initData()
            ElMessage.success(`${res.message}`)
          }
        })
        .catch(() => {
          // 用户点击取消按钮时执行的操作
          // 可以选择不做任何事情,也可以显示取消消息
          // ElMessage.info('操作已取消'); // 如果需要显示取消消息,可以取消注释
        })
    }
 
    // 未确认
 
    const handleUnConfirm = row => {
      ElMessageBox.confirm('此操作将该日志改为未确认, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          const res = await projectDaily.unConfirmProjectDaily(row.id)
          if (res.code < window.MAX_SUCCESS_CODE) {
            initData()
            ElMessage.success(`${res.message}`)
          }
        })
        .catch(() => {
          // 用户点击取消按钮时执行的操作
          // 可以选择不做任何事情,也可以显示取消消息
          // ElMessage.info('操作已取消'); // 如果需要显示取消消息,可以取消注释
        })
    }
 
    const handleSizeChange = val => {
      pageSize.value = val
      initData()
    }
 
    const handleCurrentChange = val => {
      currentPage.value = val
      initData()
    }
 
    const indexMethod = index => (currentPage.value - 1) * pageSize.value + index + 1
 
    // 子控部分
 
    const add = () => {
      editDiaryId.value = ''
      editDailyDate.value = queryForm.daily_date
      showEdit.value = 1
    }
 
    const addBatch = () => {
      editDiaryId.value = ''
      editDailyDate.value = queryForm.daily_date
      showEdit.value = 2
      comfirmFlag.value = false
    }
 
    // 批量编辑擦做做
    const handleEditBatch = () => {
      editDailyDate.value = queryForm.daily_date
      showEdit.value = 2
    }
 
    // 批量工时确认
    const handleActualHoursBatch = () => {
      editDailyDate.value = queryForm.daily_date
      showEdit.value = 2
      comfirmFlag.value = true
    }
 
    const commitBatch = async () => {
      try {
        if (!queryForm.daily_date) {
          ElMessage.error('日志日期不能为空!')
          return
        }
 
        const esTime = await projectDaily.getDailyDatePlanTime(queryForm.daily_date, '')
        const acTime = await projectDaily.getDailyDateActualTime(queryForm.daily_date, '')
 
        // 计划或实际工时小于6小时不允许提交
 
        if (Number(esTime) < 6) {
          // 计划工时小于6小时不允许提交
          ElMessage.error('计划工时小于6小时不允许提交!')
          return
        }
        if (Number(acTime) < 6) {
          // 实际工时小于6小时不允许提交
          ElMessage.error('日志实际工时小于6小时不允许提交!')
          return
        }
 
        const mess = `确认提交(${queryForm.daily_date})日志, 是否继续?`
 
        ElMessageBox.confirm(mess, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(async () => {
            const info = { daily_date: queryForm.daily_date }
            const res = await projectDaily.commitBatchProjectDaily(info)
 
            if (res.code < window.MAX_SUCCESS_CODE) {
              initData()
              ElMessage.success(`${res.message}`)
            }
          })
          .catch(() => {
            // 用户点击取消按钮时执行的操作
            // 可以选择不做任何事情,也可以显示取消消息
            // ElMessage.info('操作已取消'); // 如果需要显示取消消息,可以取消注释
          })
      } catch (error) {
        if (error.code === 10020) {
          ElMessage.error('请填写今日日志后提交')
        }
      }
    }
 
    const commitBatch2 = async () => {
      try {
        if (!queryForm.daily_date) {
          ElMessage.error('日志日期不能为空!')
          return
        }
 
        const acTime = await projectDaily.getDailyDateActualTime(queryForm.daily_date, '')
 
        let mess = `确认提交(${queryForm.daily_date})日志, 是否继续?`
        if (Number(acTime) < 6) {
          mess = `实际工时小于6小时!!!是否确认提交(${queryForm.daily_date})日志, 是否继续?`
        }
 
        ElMessageBox.confirm(mess, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(async () => {
            const info = { daily_date: queryForm.daily_date }
            const res = await projectDaily.commitBatchProjectDaily(info)
 
            if (res.code < window.MAX_SUCCESS_CODE) {
              initData()
              ElMessage.success(`${res.message}`)
            }
          })
          .catch(() => {
            // 用户点击取消按钮时执行的操作
            // 可以选择不做任何事情,也可以显示取消消息
            // ElMessage.info('操作已取消'); // 如果需要显示取消消息,可以取消注释
          })
      } catch (error) {
        if (error.code === 10020) {
          ElMessage.error('请填写今日日志后提交')
        }
      }
    }
 
    const editClose = () => {
      showEdit.value = 0
      editDiaryId.value = ''
      actualHourFlag.value = false
      initData()
    }
 
    const formatDate = date_str =>
      // if(date_str){
      //   return date_str.match(/\d{4}-\d{2}-\d{2}/)[0]; // 获取年月日部分
      // }else{
      //   return date_str
      // }
      `<div class='confirmed-row'>${date_str}</div>`
 
    const handleActualHours = row => {
      // 工时确认
      editDiaryId.value = row.id
      showEdit.value = 3
      actualHourFlag.value = true
    }
 
    const handleActualHoursDisabled = row => {
      const yesterday = getYesterdayDate()
      const today = getDefaultDate()
 
      // 编辑操作
      if (row.is_confirm === 1 && (row.daily_date == yesterday || row.daily_date == today)) {
        // 查看记录是否是今天和昨天的
        return false
      }
      return true
    }
 
    const handleActualHoursDisabled2 = row => {
      const yesterday = getYesterdayDate()
      const today = getDefaultDate()
      //  查看今天是周几
      const dayOfWweek = getDayOfWeek()
      // 查看上周五的日期
      const prevFriday = getPreviousFriday()
 
      if (row.is_confirm === 1) {
        // 已经确认过了则不可以编辑
        return true
      }
      if (
        row.is_confirm === 0
        && ((dayOfWweek == 'Monday' && prevFriday == row.daily_date) || row.daily_date == today)
      ) {
        // 未确认的情况下只可以改昨天和今天的,但是如果今天是周一的情况下,周五的也可以修改
        return false
      }
      if (row.is_confirm === 0 && (row.daily_date == yesterday || row.daily_date == today)) {
        // 未确认的情况下只可以改昨天和今天的
        return false
      }
      return true
    }
 
    /**
     * 日志补录功能
     */
    const handleSupplementary = () => {
      editDiaryId.value = ''
      editDailyDate.value = queryForm.daily_date
      showEdit.value = 4
      actualHourFlag.value = false
    }
 
    /**
     * 日志颜色区分
     */
    const rowClassName = ({ row }) => {
      if (row.supplementary_flag === 1) {
        return 'supplementary-row'
      }
      return 'no-supplementary-row'
    }
 
    /**
     * 表格内容自动换行
     */
    const formatColumnContent = (row, content) => content
 
    const estimateHourTip = async () => {
      // 如果评估工时小于6个小时,则提醒
 
      const esTime = await projectDaily.getDailyDatePlanTime(queryForm.daily_date, '')
      if (Number(esTime) < 6) {
        ElNotification({
          title: '计划工时不足提醒',
          message: '今日计划工时不足6小时!!!',
          duration: 0,
        })
      }
    }
 
    return {
      calendarForm,
      dailyCalendarDateData,
      currentDateData,
      uncommitCount,
 
      loading,
 
      projectInfoArr,
      dailyTypeArr,
      dailyStatusArr,
      dailyCommitArr,
      dailyConfirmArr,
 
      queryForm,
      tableData,
      search,
      handleEdit,
      handleDelete,
      handleCommit,
      handleConfirm,
      handleUnConfirm,
 
      indexMethod,
      currentPage,
      pageSize,
      totalSize,
 
      handleSizeChange,
      handleCurrentChange,
      handleActualHours,
      handleActualHoursDisabled,
      handleActualHoursDisabled2,
 
      // 日志部分
      editDiaryId,
      comfirmFlag,
      editClose,
      add,
      addBatch,
      handleEditBatch,
      handleActualHoursBatch,
      showEdit,
      formatDate,
      actualHourFlag,
 
      commitBatch,
      commitFlag,
      handleDailyDate,
      pointDailyDateSize,
 
      // 日志补录部分
      handleSupplementary,
      rowClassName,
      tableColumns,
      formatColumnContent,
 
      editDailyDate,
 
      // 工时提醒部分
      estimateHourTip,
    }
  },
}
</script>
 
<style scoped>
.demo-form-inline .el-input {
  --el-input-width: 220px;
}
 
.demo-form-inline .el-select--small .el-select__wrapper {
  gap: 4px;
  padding: 2px 8px;
  min-height: 24px;
  line-height: 20px;
  font-size: 12px;
  width: 220px;
}
.page-container {
  padding: 10px;
}
 
.search-section {
  margin-bottom: 10px;
  padding: 20px;
  /* background-color: #f5f5f5; */
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.main-section {
  display: flex;
  background: white;
}
.calendar-section {
  width: 30%;
}
.calendar {
  width: 100%;
}
.table-section {
  width: 70%;
  padding: 20px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.demo-pagination-block {
  margin-top: 10px;
}
.demo-pagination-block .demonstration {
  margin-bottom: 16px;
}
</style>
 
<style>
.supplementary-row {
  background-color: rgb(215, 218, 50) !important;
  width: 100%;
}
 
.no-supplementary-row {
  background-color: #f8f9fa !important;
}
 
.calendarClass {
  font-size: 14px;
}
 
.unCommitClass {
  color: red;
}
 
.commitClass {
  color: green;
}
</style>