attendance.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <scTable ref="xGridTable" batchDel :apiObj="$API.tower.attendance" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns">
  3. <template #default_imgText="{ row, column }">
  4. <template v-if="formatCertificate(row, column)">
  5. <el-button type="primary" link @click="handlePreview(row, column)">{{ XEUtils.get(formatCertificate(row, column), "certificateNo") }}</el-button>
  6. </template>
  7. </template>
  8. <template #action="{ row }">
  9. <el-button type="primary" link @click="table_del(row)">
  10. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  11. </el-button>
  12. </template>
  13. </scTable>
  14. <file-viewer v-if="showViewer" ref="viewerRef" @closed="showViewer = false"></file-viewer>
  15. </template>
  16. <script setup>
  17. import moment from "moment";
  18. import XEUtils from "xe-utils";
  19. import API from "@/api";
  20. import TOOL from "@/utils/tool";
  21. import { mapFormItemSelect, mapFormItemDatePicker } from "@/components/scTable/helper";
  22. import { dataSource } from "@/utils/basicDic";
  23. import { folderKeyDic } from "@/views/dataMock/tower/main";
  24. const formatCertificate = (row, { field }) => XEUtils.find(XEUtils.get(XEUtils.toStringJSON(XEUtils.get(row, "person.features")), "certificate", []), item => item.type == XEUtils.get(folderKeyDic, field));
  25. const proConfig = reactive({
  26. span: 5,
  27. storageKey: "PROJECT",
  28. resetValue: TOOL.data.get("PROJECT_ID"),
  29. optionProps: { label: "projectName", value: "fpiId" },
  30. events: {
  31. change: data => XEUtils.assign(formConfig.data, { ...data, mountedId: null })
  32. }
  33. })
  34. const mountedConfig = reactive({
  35. api: {
  36. key: "tower.mounted",
  37. query: {
  38. projectId: computed(() => formConfig.data.projectId),
  39. projectIdNot: 1
  40. }
  41. },
  42. slot: {
  43. style: { float: "right", paddingLeft: "6px", color: "#8492a6" }
  44. },
  45. optionProps: { label: "mountedName", value: "id", slot: ({ data }) => XEUtils.get(XEUtils.find(TOOL.data.get("PROJECT"), item => item.fpiId === data.projectId), "projectName") },
  46. events: {
  47. change: data => XEUtils.assign(formConfig.data, data)
  48. }
  49. })
  50. const datetimerangeConfig = reactive({
  51. span: 7,
  52. resetValue: () => [moment().startOf("month").format("YYYY-MM-DD HH:mm:ss"), moment().add(1, "hour").format("YYYY-MM-DD HH:mm:ss")],
  53. props: {
  54. type: "datetimerange",
  55. startPlaceholder: "开始时间",
  56. endPlaceholder: "结束时间",
  57. format: "YYYY-MM-DD HH:mm"
  58. }
  59. })
  60. const toolbarConfig = reactive({
  61. enabled: true,
  62. print: false
  63. })
  64. const formConfig = reactive({
  65. data: {
  66. projectId: TOOL.data.get("PROJECT_ID"),
  67. projectIdNot: 1,
  68. recordType: "TCM_RECORD_ENTER",
  69. createTime: [moment().startOf("month").format("YYYY-MM-DD HH:mm:ss"), moment().add(1, "hour").format("YYYY-MM-DD HH:mm:ss")]
  70. },
  71. items: [
  72. mapFormItemSelect("projectId", "所属项目", proConfig),
  73. mapFormItemSelect("mountedId", "设备安装点", mountedConfig),
  74. mapFormItemDatePicker("createTime", "监测时间", datetimerangeConfig)
  75. ]
  76. })
  77. const paramsColums = reactive([
  78. { column: "projectId" },
  79. { column: "projectIdNot" },
  80. { column: "mountedId" },
  81. { column: "recordType" },
  82. { column: "createTimeBegin", field: "createTime[0]" },
  83. { column: "createTimeEnd", field: "createTime[1]" }
  84. ])
  85. const columns = reactive([
  86. { type: "checkbox", fixed: "left", width: 40 },
  87. { type: "seq", fixed: "left", width: 60 },
  88. { type: "html", field: "person.name", title: "人员姓名", minWidth: 100, sortable: true },
  89. { type: "html", field: "person.idCard", title: "身份证号", minWidth: 160, sortable: true },
  90. { type: "html", field: "person.phoneNumber", title: "手机号", minWidth: 160, sortable: true },
  91. { type: "html", field: "createTime", title: "打卡时间", minWidth: 160, sortable: true },
  92. { type: "html", field: "projectName", title: "项目名称", minWidth: 160, sortable: true, formatter: ({ cellValue, row }) => cellValue || XEUtils.get(XEUtils.find(TOOL.data.get("PROJECT"), item => item.fpiId == row.projectId), "projectName") },
  93. { type: "html", field: "groundName", title: "工地场区", minWidth: 160, sortable: true },
  94. { type: "html", field: "mountedName", title: "设备安装点", minWidth: 160, sortable: true },
  95. { field: "facerec/towerCrane_zs", title: "特种作业证", minWidth: 140, align: "center", slots: { default: "default_imgText" } },
  96. { type: "html", field: "dataSource", title: "数据来源", fixed: "right", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(dataSource, cellValue, cellValue) },
  97. { title: "操作", fixed: "right", width: 120, align: "center", slots: { default: "action" } }
  98. ])
  99. // 显示隐藏 筛选表单
  100. const xGridTable = ref();
  101. const toggleFormEnabled = () => xGridTable.value.toggleFormEnabled();
  102. const refreshTable = () => {
  103. xGridTable.value.reloadColumn(columns);
  104. xGridTable.value.searchData();
  105. }
  106. const showViewer = ref(false);
  107. const viewerRef = ref();
  108. const handlePreview = (row, { field }) => {
  109. showViewer.value = true;
  110. nextTick(() => viewerRef.value.init(XEUtils.get(row, `person.folders.${field}.entities[0]`)));
  111. }
  112. const table_del = ({ id }) => {
  113. ElMessageBox.confirm("是否确认删除该考勤记录?", "删除警告", {
  114. type: "warning",
  115. confirmButtonText: "确定",
  116. cancelButtonText: "取消"
  117. }).then(() => {
  118. API.tower.attendance.del({ id }).then(() => {
  119. ElMessage.success("操作成功");
  120. refreshTable();
  121. });
  122. });
  123. }
  124. </script>