attendance.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <scTable ref="xGridTable" batchDel :apiObj="$API.elevator.attendance" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns" v-bind="props.options">
  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 props = defineProps({
  26. options: { type: Object, default: () => {} },
  27. hideHandler: { type: Boolean, default: false }
  28. })
  29. const visible = computed(() => !props.hideHandler);
  30. const proConfig = reactive({
  31. span: 5,
  32. visible,
  33. storageKey: "PROJECT",
  34. resetValue: TOOL.data.get("PROJECT_ID"),
  35. optionProps: { label: "projectName", value: "fpiId" },
  36. events: {
  37. change: data => XEUtils.assign(formConfig.data, { ...data, mountedId: null })
  38. }
  39. })
  40. const mountedConfig = reactive({
  41. visible,
  42. api: {
  43. key: "elevator.mounted",
  44. query: {
  45. projectId: computed(() => formConfig.data.projectId),
  46. projectIdNot: 1
  47. }
  48. },
  49. slot: {
  50. style: { float: "right", paddingLeft: "6px", color: "#8492a6" }
  51. },
  52. optionProps: { label: "mountedName", value: "id", slot: ({ data }) => XEUtils.get(XEUtils.find(TOOL.data.get("PROJECT"), item => item.fpiId === data.projectId), "projectName") },
  53. events: {
  54. change: data => XEUtils.assign(formConfig.data, data)
  55. }
  56. })
  57. const datetimerangeConfig = reactive({
  58. span: 7,
  59. resetValue: () => [moment().startOf("month").format("YYYY-MM-DD HH:mm:ss"), moment().add(1, "hour").format("YYYY-MM-DD HH:mm:ss")],
  60. props: {
  61. type: "datetimerange",
  62. startPlaceholder: "开始时间",
  63. endPlaceholder: "结束时间",
  64. format: "YYYY-MM-DD HH:mm"
  65. }
  66. })
  67. const toolbarConfig = reactive({
  68. enabled: true,
  69. print: false
  70. })
  71. const formConfig = reactive({
  72. data: {
  73. projectId: TOOL.data.get("PROJECT_ID"),
  74. projectIdNot: 1,
  75. recordType: "ELEVATOR_RECORD_ENTER",
  76. createTime: [moment().startOf("month").format("YYYY-MM-DD HH:mm:ss"), moment().add(1, "hour").format("YYYY-MM-DD HH:mm:ss")]
  77. },
  78. items: [
  79. mapFormItemSelect("projectId", "所属项目", proConfig),
  80. mapFormItemSelect("mountedId", "设备安装点", mountedConfig),
  81. mapFormItemDatePicker("createTime", "监测时间", datetimerangeConfig)
  82. ]
  83. })
  84. const paramsColums = reactive([
  85. { column: "projectId" },
  86. { column: "projectIdNot" },
  87. { column: "mountedId" },
  88. { column: "recordType" },
  89. { column: "createTimeBegin", field: "createTime[0]" },
  90. { column: "createTimeEnd", field: "createTime[1]" }
  91. ])
  92. const columns = reactive([
  93. { visible: !props.hideHandler, type: "checkbox", fixed: "left", width: 40 },
  94. { type: "seq", fixed: "left", width: 60 },
  95. { type: "html", field: "person.name", title: "人员姓名", minWidth: 100, sortable: true },
  96. { type: "html", field: "person.idCard", title: "身份证号", minWidth: 160, sortable: true },
  97. { type: "html", field: "person.phoneNumber", title: "手机号", minWidth: 160, sortable: true },
  98. { type: "html", field: "createTime", title: "打卡时间", minWidth: 160, sortable: true },
  99. { 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") },
  100. { type: "html", field: "groundName", title: "工地场区", minWidth: 160, sortable: true },
  101. { type: "html", field: "mountedName", title: "设备安装点", minWidth: 160, sortable: true },
  102. { field: "facerec/elevator_zs", title: "特种作业证", minWidth: 140, align: "center", slots: { default: "default_imgText" } },
  103. { visible: !props.hideHandler, type: "html", field: "dataSource", title: "数据来源", fixed: "right", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(dataSource, cellValue, cellValue) },
  104. { visible: !props.hideHandler, title: "操作", fixed: "right", width: 120, align: "center", slots: { default: "action" } }
  105. ])
  106. // 显示隐藏 筛选表单
  107. const xGridTable = ref();
  108. const refreshTable = () => {
  109. xGridTable.value.reloadColumn(columns);
  110. xGridTable.value.searchData();
  111. }
  112. const showViewer = ref(false);
  113. const viewerRef = ref();
  114. const handlePreview = (row, { field }) => {
  115. showViewer.value = true;
  116. nextTick(() => viewerRef.value.init(XEUtils.get(row, `person.folders.${field}.entities[0]`)));
  117. }
  118. const table_del = ({ id }) => {
  119. ElMessageBox.confirm("是否确认删除该考勤记录?", "删除警告", {
  120. type: "warning",
  121. confirmButtonText: "确定",
  122. cancelButtonText: "取消"
  123. }).then(() => {
  124. API.elevator.attendance.del({ id }).then(() => {
  125. ElMessage.success("操作成功");
  126. refreshTable();
  127. });
  128. });
  129. }
  130. defineExpose({
  131. refreshTable
  132. })
  133. </script>