|
@@ -0,0 +1,612 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <el-row :gutter="20">
|
|
|
|
|
+ <!-- 左侧部门树 -->
|
|
|
|
|
+ <DeptTree @node-click="handleDeptNodeClick" v-model:collapsed="isLeftContentCollapsed" />
|
|
|
|
|
+ <el-col :span="isLeftContentCollapsed ? 24 : 20" :xs="24">
|
|
|
|
|
+ <ContentWrap>
|
|
|
|
|
+ <!-- 搜索工作栏 -->
|
|
|
|
|
+ <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true">
|
|
|
|
|
+ <el-form-item label="地址" prop="address">
|
|
|
|
|
+ <el-input placeholder="请输入地址" v-model="queryParams.address" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="queryParams.status"
|
|
|
|
|
+ placeholder="请选择状态"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ style="width: 180px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="dict in getStrDictOptions(DICT_TYPE.QHSE_HAZARD_STATUS)"
|
|
|
|
|
+ :key="dict.value"
|
|
|
|
|
+ :label="dict.label"
|
|
|
|
|
+ :value="dict.value"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <el-button @click="handleAdd" type="primary"
|
|
|
|
|
+ ><Icon icon="ep:plus" class="mr-5px" />新增</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-button @click="handleQuery"
|
|
|
|
|
+ ><Icon icon="ep:search" class="mr-5px" /> {{ t('devicePerson.search') }}</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-button @click="resetQuery"
|
|
|
|
|
+ ><Icon icon="ep:refresh" class="mr-5px" /> {{ t('devicePerson.reset') }}</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-button @click="handleExport" type="success" plain :loading="exportLoading"
|
|
|
|
|
+ ><Icon icon="ep:download" class="mr-5px" /> 导出</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ </ContentWrap>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 列表 -->
|
|
|
|
|
+ <ContentWrap class="flex-1 overflow-hidden mt-15px">
|
|
|
|
|
+ <el-table
|
|
|
|
|
+ v-loading="loading"
|
|
|
|
|
+ :data="list"
|
|
|
|
|
+ :stripe="true"
|
|
|
|
|
+ height="calc(85vh - 130px)"
|
|
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-table-column :label="t('monitor.serial')" width="70" align="center">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ {{ scope.$index + 1 }}
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column label="PTW编号" align="center" prop="ptwNo" width="100" />
|
|
|
|
|
+ <el-table-column label="PTW序号" align="center" prop="ptwXh" width="100" />
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column label="时间" align="center" show-overflow-tooltip>
|
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
|
+ {{ formatDate(row.ptwTime) }}
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column label="作业票类型" align="center">
|
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
|
+ <dict-tag :type="DICT_TYPE.QHSE_PTW_TYPE" :value="row.ptwType" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column label="作业分级" align="center">
|
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
|
+ <dict-tag :type="DICT_TYPE.QHSE_PTW_GRADE" :value="row.ptwGrade" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="作业地点"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ prop="workLocation"
|
|
|
|
|
+ show-overflow-tooltip
|
|
|
|
|
+ />
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="作业内容"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ prop="workContent"
|
|
|
|
|
+ show-overflow-tooltip
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="作业人员"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ prop="workPerson"
|
|
|
|
|
+ show-overflow-tooltip
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column label="监护人" align="center" prop="guardian" show-overflow-tooltip />
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="作业负责人"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ prop="workDuty"
|
|
|
|
|
+ show-overflow-tooltip
|
|
|
|
|
+ />
|
|
|
|
|
+ <el-table-column label="部门" align="center" prop="deptName" show-overflow-tooltip />
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column label="附件" align="center">
|
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
|
+ <el-link
|
|
|
|
|
+ v-if="row.file"
|
|
|
|
|
+ :underline="false"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ @click="viewFile(row.file)"
|
|
|
|
|
+ >查看</el-link
|
|
|
|
|
+ >
|
|
|
|
|
+ <span v-else>-</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column prop="createTime" label="创建时间" align="center" min-width="150">
|
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
|
+ {{ formatDate(row.createTime) }}
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="备注"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ prop="remark"
|
|
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ :label="t('devicePerson.operation')"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ fixed="right"
|
|
|
|
|
+ min-width="150px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <el-button link type="primary" @click="handleEdit(scope.row)"> 编辑 </el-button>
|
|
|
|
|
+ <el-button link type="danger" @click="handleDelete(scope.row.id)"> 删除 </el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ </el-table>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 分页 -->
|
|
|
|
|
+ <Pagination
|
|
|
|
|
+ :total="total"
|
|
|
|
|
+ v-model:page="queryParams.pageNo"
|
|
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
|
|
+ @pagination="getList"
|
|
|
|
|
+ />
|
|
|
|
|
+ </ContentWrap>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 新增/编辑证书对话框 -->
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ :title="dialogTitle"
|
|
|
|
|
+ v-model="dialogVisible"
|
|
|
|
|
+ width="600px"
|
|
|
|
|
+ destroy-on-close
|
|
|
|
|
+ @close="closeDialog"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-form
|
|
|
|
|
+ ref="formRef"
|
|
|
|
|
+ :model="formData"
|
|
|
|
|
+ :rules="formRules"
|
|
|
|
|
+ label-width="120px"
|
|
|
|
|
+ v-loading="formLoading"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-form-item label="序号" prop="ptwXh">
|
|
|
|
|
+ <el-input v-model="formData.ptwXh" placeholder="请输入序号" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="作业内容" prop="workContent">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ type="textarea"
|
|
|
|
|
+ :rows="2"
|
|
|
|
|
+ v-model="formData.workContent"
|
|
|
|
|
+ placeholder="请输入作业内容"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="作业分级" prop="ptwGrade">
|
|
|
|
|
+ <el-select v-model="formData.ptwGrade" placeholder="请选择作业分级">
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in getDictOptions(DICT_TYPE.QHSE_PTW_GRADE)"
|
|
|
|
|
+ :key="item.value"
|
|
|
|
|
+ :label="item.label"
|
|
|
|
|
+ :value="item.value"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 作业票类型 -->
|
|
|
|
|
+ <el-form-item label="作业票类型" prop="ptwType">
|
|
|
|
|
+ <el-select v-model="formData.ptwType" placeholder="请选择作业票类型">
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in getDictOptions(DICT_TYPE.QHSE_PTW_TYPE)"
|
|
|
|
|
+ :key="item.value"
|
|
|
|
|
+ :label="item.label"
|
|
|
|
|
+ :value="item.value"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="作业地点" prop="ptwXh">
|
|
|
|
|
+ <el-input v-model="formData.workLocation" placeholder="请输入作业地点" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="作业人员" prop="workPerson">
|
|
|
|
|
+ <el-input v-model="formData.workPerson" placeholder="请输入作业人员" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="监护人" prop="guardian">
|
|
|
|
|
+ <el-input v-model="formData.guardian" placeholder="请输入监护人" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="作业负责人" prop="workDuty">
|
|
|
|
|
+ <el-input v-model="formData.workDuty" placeholder="请输入作业负责人" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="附件" prop="file">
|
|
|
|
|
+ <UploadFile
|
|
|
|
|
+ v-model="formData.file"
|
|
|
|
|
+ :file-type="['doc', 'docx', 'xls', 'xlsx', 'pdf', 'jpg', 'png', 'jpeg']"
|
|
|
|
|
+ :limit="3"
|
|
|
|
|
+ :file-size="100"
|
|
|
|
|
+ class="min-w-80px"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ type="textarea"
|
|
|
|
|
+ v-model="formData.remark"
|
|
|
|
|
+ :rows="2"
|
|
|
|
|
+ placeholder="请输入备注"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <el-button @click="closeDialog">取 消</el-button>
|
|
|
|
|
+ <el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+
|
|
|
|
|
+ <el-dialog v-model="dialogFileView" title="附件" width="500">
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-for="(file, index) in fileList"
|
|
|
|
|
+ :key="index"
|
|
|
|
|
+ class="flex items-center justify-between mt-5"
|
|
|
|
|
+ >
|
|
|
|
|
+ <span class="file-name-text">{{ extractFileName(file) }}</span>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <el-button link type="primary" @click="viewFileInfo(file)">
|
|
|
|
|
+ <Icon icon="ep:view" class="mr-2px" />查看</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-button link type="primary" @click="handleDownload(file)">
|
|
|
|
|
+ <Icon icon="ep:download" class="mr-2px" />下载</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <div class="dialog-footer mt-10">
|
|
|
|
|
+ <el-button type="primary" @click="dialogFileView = false"> 确认 </el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+
|
|
|
|
|
+ <FilePreviewDialog
|
|
|
|
|
+ v-model="filePreviewVisible"
|
|
|
|
|
+ :title="filePreviewTitle"
|
|
|
|
|
+ :urls="filePreviewUrls"
|
|
|
|
|
+ />
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script setup lang="ts">
|
|
|
|
|
+import { QHSEPtwApi } from '@/api/pms/qhse/index'
|
|
|
|
|
+import DeptTree from '@/views/system/user/DeptTree2.vue'
|
|
|
|
|
+import { handleTree } from '@/utils/tree'
|
|
|
|
|
+import * as DeptApi from '@/api/system/dept'
|
|
|
|
|
+import { ElMessageBox, ElMessage } from 'element-plus'
|
|
|
|
|
+const deptList2 = ref<Tree[]>([]) // 树形结构
|
|
|
|
|
+import { formatDate } from '@/utils/formatTime'
|
|
|
|
|
+
|
|
|
|
|
+import UploadFile from '@/components/UploadFile/src/UploadFile.vue'
|
|
|
|
|
+import FilePreviewDialog from '@/components/FilePreview/src/FilePreviewDialog.vue'
|
|
|
|
|
+import { DICT_TYPE, getStrDictOptions, getDictOptions } from '@/utils/dict'
|
|
|
|
|
+
|
|
|
|
|
+defineOptions({ name: 'IotQHSEPTW' })
|
|
|
|
|
+
|
|
|
|
|
+const loading = ref(true) // 列表的加载中
|
|
|
|
|
+const formLoading = ref(false) // 表单加载中
|
|
|
|
|
+const submitLoading = ref(false) // 提交按钮加载中
|
|
|
|
|
+const exportLoading = ref(false) // 导出按钮加载中
|
|
|
|
|
+const isLeftContentCollapsed = ref(false)
|
|
|
|
|
+
|
|
|
|
|
+const { t } = useI18n()
|
|
|
|
|
+
|
|
|
|
|
+const list = ref([]) // 列表的数据
|
|
|
|
|
+const total = ref(0) // 列表的总页数
|
|
|
|
|
+const queryParams = reactive({
|
|
|
|
|
+ pageNo: 1,
|
|
|
|
|
+ pageSize: 10,
|
|
|
|
|
+ deptId: '',
|
|
|
|
|
+ address: ''
|
|
|
|
|
+})
|
|
|
|
|
+const queryFormRef = ref(null) // 搜索的表单
|
|
|
|
|
+
|
|
|
|
|
+// 对话框相关
|
|
|
|
|
+const dialogVisible = ref(false)
|
|
|
|
|
+const dialogTitle = ref('')
|
|
|
|
|
+const isEdit = ref(false)
|
|
|
|
|
+
|
|
|
|
|
+// 文件预览
|
|
|
|
|
+const filePreviewVisible = ref(false)
|
|
|
|
|
+const filePreviewTitle = ref('文件预览')
|
|
|
|
|
+const filePreviewUrls = ref<string[]>([])
|
|
|
|
|
+
|
|
|
|
|
+// 表单相关
|
|
|
|
|
+const formRef = ref()
|
|
|
|
|
+const formData = ref({
|
|
|
|
|
+ deptId: '',
|
|
|
|
|
+ workDuty: '',
|
|
|
|
|
+ workPerson: '',
|
|
|
|
|
+ guardian: '',
|
|
|
|
|
+ workLocation: '',
|
|
|
|
|
+ workContent: '',
|
|
|
|
|
+ ptwXh: '',
|
|
|
|
|
+ ptwGrade: '',
|
|
|
|
|
+ ptwType: '',
|
|
|
|
|
+ file: '',
|
|
|
|
|
+ remark: ''
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+// 表单验证规则
|
|
|
|
|
+const formRules = {
|
|
|
|
|
+ deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
|
|
|
|
|
+ workDuty: [{ required: true, message: '作业负责人不能为空', trigger: 'blur' }],
|
|
|
|
|
+ workPerson: [{ required: true, message: '作业人员不能为空', trigger: 'blur' }],
|
|
|
|
|
+ guardian: [{ required: true, message: '监护人不能为空', trigger: 'blur' }],
|
|
|
|
|
+ workLocation: [{ required: true, message: '作业地点不能为空', trigger: 'blur' }],
|
|
|
|
|
+ workContent: [{ required: true, message: '作业内容不能为空', trigger: 'blur' }],
|
|
|
|
|
+ ptwXh: [{ required: true, message: '作业票编号不能为空', trigger: 'blur' }],
|
|
|
|
|
+ ptwGrade: [{ required: true, message: '作业票等级不能为空', trigger: 'blur' }],
|
|
|
|
|
+ ptwType: [{ required: true, message: '作业票类型不能为空', trigger: 'blur' }],
|
|
|
|
|
+ file: [{ required: true, message: '附件不能为空', trigger: 'blur' }]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 查询列表 */
|
|
|
|
|
+const getList = async () => {
|
|
|
|
|
+ loading.value = true
|
|
|
|
|
+ try {
|
|
|
|
|
+ const data = await QHSEPtwApi.getPtwList(queryParams)
|
|
|
|
|
+ list.value = data.list
|
|
|
|
|
+ total.value = data.total
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const downloadFile = (response) => {
|
|
|
|
|
+ // 创建 blob 对象
|
|
|
|
|
+ const blob = new Blob([response], {
|
|
|
|
|
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 获取文件名
|
|
|
|
|
+ let fileName = 'PTW.xlsx'
|
|
|
|
|
+ const disposition = response.headers ? response.headers['content-disposition'] : ''
|
|
|
|
|
+ if (disposition) {
|
|
|
|
|
+ const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/
|
|
|
|
|
+ const matches = filenameRegex.exec(disposition)
|
|
|
|
|
+ if (matches != null && matches[1]) {
|
|
|
|
|
+ fileName = matches[1].replace(/['"]/g, '')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 创建下载链接
|
|
|
|
|
+ const url = window.URL.createObjectURL(blob)
|
|
|
|
|
+ const link = document.createElement('a')
|
|
|
|
|
+ link.href = url
|
|
|
|
|
+ link.setAttribute('download', fileName)
|
|
|
|
|
+
|
|
|
|
|
+ // 触发下载
|
|
|
|
|
+ document.body.appendChild(link)
|
|
|
|
|
+ link.click()
|
|
|
|
|
+
|
|
|
|
|
+ // 清理
|
|
|
|
|
+ document.body.removeChild(link)
|
|
|
|
|
+ window.URL.revokeObjectURL(url)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const handleExport = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ exportLoading.value = true
|
|
|
|
|
+ const response = await QHSEPtwApi.exportPtw(queryParams)
|
|
|
|
|
+ downloadFile(response)
|
|
|
|
|
+ exportLoading.value = false
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ ElMessage.error('导出失败,请重试')
|
|
|
|
|
+ console.error('导出错误:', error)
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ exportLoading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 首页处理部门被点击 */
|
|
|
|
|
+const handleDeptNodeClick = async (row) => {
|
|
|
|
|
+ queryParams.deptId = row.id
|
|
|
|
|
+ await getList()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 搜索按钮操作 */
|
|
|
|
|
+const handleQuery = () => {
|
|
|
|
|
+ queryParams.pageNo = 1
|
|
|
|
|
+ getList()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 重置按钮操作 */
|
|
|
|
|
+const resetQuery = () => {
|
|
|
|
|
+ queryParams.deptId = ''
|
|
|
|
|
+ queryFormRef.value?.resetFields()
|
|
|
|
|
+ handleQuery()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 显示新增对话框
|
|
|
|
|
+const handleAdd = () => {
|
|
|
|
|
+ isEdit.value = false
|
|
|
|
|
+ dialogTitle.value = '新增'
|
|
|
|
|
+ resetForm()
|
|
|
|
|
+ dialogVisible.value = true
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 显示编辑对话框
|
|
|
|
|
+const handleEdit = (row) => {
|
|
|
|
|
+ isEdit.value = true
|
|
|
|
|
+ dialogTitle.value = '修改'
|
|
|
|
|
+
|
|
|
|
|
+ formData.value = {
|
|
|
|
|
+ ...row,
|
|
|
|
|
+ // 确保日期字段正确处理
|
|
|
|
|
+ issueDate: row.issueDate ? ensureMillisecondTimestamp(row.issueDate) : null,
|
|
|
|
|
+ validityPeriod: row.validityPeriod ? ensureMillisecondTimestamp(row.validityPeriod) : null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ dialogVisible.value = true
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 确保时间戳是毫秒级的
|
|
|
|
|
+const ensureMillisecondTimestamp = (timestamp) => {
|
|
|
|
|
+ let time = Number(timestamp)
|
|
|
|
|
+ if (time < 10000000000) {
|
|
|
|
|
+ // 秒级时间戳转为毫秒级
|
|
|
|
|
+ return time * 1000
|
|
|
|
|
+ }
|
|
|
|
|
+ return time
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//删除证书
|
|
|
|
|
+const handleDelete = async (id: number) => {
|
|
|
|
|
+ ElMessageBox.confirm('确定要删除该条记录吗?', '提示', {
|
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ type: 'warning'
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ await QHSEPtwApi.deletePtw(id)
|
|
|
|
|
+ ElMessage.success('删除成功')
|
|
|
|
|
+ getList()
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error(error)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ // 取消操作
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 重置表单
|
|
|
|
|
+const resetForm = () => {
|
|
|
|
|
+ formData.value = {
|
|
|
|
|
+ deptId: '',
|
|
|
|
|
+ workDuty: '',
|
|
|
|
|
+ workPerson: '',
|
|
|
|
|
+ guardian: '',
|
|
|
|
|
+ workLocation: '',
|
|
|
|
|
+ workContent: '',
|
|
|
|
|
+ ptwXh: '',
|
|
|
|
|
+ ptwGrade: '',
|
|
|
|
|
+ ptwType: '',
|
|
|
|
|
+ file: '',
|
|
|
|
|
+ remark: ''
|
|
|
|
|
+ }
|
|
|
|
|
+ formRef.value?.clearValidate()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 关闭对话框
|
|
|
|
|
+const closeDialog = () => {
|
|
|
|
|
+ dialogVisible.value = false
|
|
|
|
|
+ resetForm()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 提交表单
|
|
|
|
|
+const submitForm = async () => {
|
|
|
|
|
+ if (!formRef.value) return
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ await formRef.value.validate()
|
|
|
|
|
+ submitLoading.value = true
|
|
|
|
|
+
|
|
|
|
|
+ // 准备提交数据
|
|
|
|
|
+ const submitData = {
|
|
|
|
|
+ ...formData.value
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (isEdit.value) {
|
|
|
|
|
+ // 编辑
|
|
|
|
|
+ await QHSEPtwApi.updatePtw(submitData)
|
|
|
|
|
+ ElMessage.success('编辑成功')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 新增
|
|
|
|
|
+ await QHSEPtwApi.createPtw(submitData)
|
|
|
|
|
+ ElMessage.success('新增成功')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ dialogVisible.value = false
|
|
|
|
|
+ getList()
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error(error)
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ submitLoading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 下载文件函数
|
|
|
|
|
+const handleDownload = async (url) => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const response = await fetch(url)
|
|
|
|
|
+ const blob = await response.blob()
|
|
|
|
|
+ const downloadUrl = window.URL.createObjectURL(blob)
|
|
|
|
|
+
|
|
|
|
|
+ const link = document.createElement('a')
|
|
|
|
|
+ link.href = downloadUrl
|
|
|
|
|
+ link.download = url.split('/').pop() // 自动获取文件名:ml-citation{ref="3" data="citationList"}
|
|
|
|
|
+ link.click()
|
|
|
|
|
+
|
|
|
|
|
+ URL.revokeObjectURL(downloadUrl)
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('下载失败:', error)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+let dialogFileView = ref(false)
|
|
|
|
|
+let fileList = ref([])
|
|
|
|
|
+const viewFile = (file) => {
|
|
|
|
|
+ fileList.value = file.split(',')
|
|
|
|
|
+ dialogFileView.value = true
|
|
|
|
|
+ // window.open(file)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const viewFileInfo = (file) => {
|
|
|
|
|
+ window.open(
|
|
|
|
|
+ 'http://doc.deepoil.cc:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(file))
|
|
|
|
|
+ )
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const extractFileName = (url: string): string => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 移除查询参数和哈希
|
|
|
|
|
+ const cleanUrl = url.split('?')[0].split('#')[0]
|
|
|
|
|
+ // 获取最后一个斜杠后的内容
|
|
|
|
|
+ const parts = cleanUrl.split('/')
|
|
|
|
|
+ const fileName = parts[parts.length - 1]
|
|
|
|
|
+ // URL 解码
|
|
|
|
|
+ return decodeURIComponent(fileName) || url
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ // 如果解析失败,返回原始 URL
|
|
|
|
|
+ return url
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+onMounted(async () => {
|
|
|
|
|
+ getList()
|
|
|
|
|
+ deptList2.value = handleTree(await DeptApi.getSimpleDeptList())
|
|
|
|
|
+})
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+::deep(.el-tree--highlight-current) {
|
|
|
|
|
+ height: 200px !important;
|
|
|
|
|
+}
|
|
|
|
|
+::deep(.el-transfer-panel__body) {
|
|
|
|
|
+ height: 700px !important;
|
|
|
|
|
+}
|
|
|
|
|
+.image-preview {
|
|
|
|
|
+ margin-top: 10px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|