安全考试

This commit is contained in:
Teo
2025-04-15 18:02:39 +08:00
parent 4bc12189dc
commit b7ba954b4a
17 changed files with 635 additions and 306 deletions

View File

@ -84,7 +84,7 @@ export interface ProjectTeamForemanResp {
* 班组id * 班组id
*/ */
id: string | number; id: string | number;
foremanList: foremanQuery[];
/** /**
* 班组名称 * 班组名称
*/ */
@ -94,7 +94,9 @@ export interface ProjectTeamForemanResp {
* 项目id * 项目id
*/ */
projectId: string | number; projectId: string | number;
}
export interface foremanQuery {
/** /**
* 班组长id * 班组长id
*/ */

View File

@ -61,3 +61,15 @@ export const delQuestionUserAnswer = (id: string | number | Array<string | numbe
method: 'delete' method: 'delete'
}); });
}; };
/**
* 上传线下考试试卷存储
* @param data
*/
export const uploadQuestionUserAnswer = (data: any) => {
return request({
url: '/safety/questionUserAnswer/upload/zip',
method: 'post',
data: data
});
};

View File

@ -1,33 +1,17 @@
export interface QuestionUserAnswerVO { export interface QuestionUserAnswerVO {
/**
* 主键id
*/
id: string | number;
/**
* 项目id
*/
projectId: string | number;
/**
* 用户id
*/
userId: string | number;
/**
* 题库id列表
*/
bankIdList: Array<string | number>;
/**
* 答案列表
*/
answerList: Array<string>;
/** /**
* 得分 * 得分
*/ */
score: number; score: number;
id: string | number;
file: string;
/**
* 考试类型1线上考试 2线下考试
*/
/**
* 考试时间(时间戳/秒)
*/
examTime: number;
/** /**
* 用时时间(时间戳/秒) * 用时时间(时间戳/秒)
@ -38,11 +22,6 @@ export interface QuestionUserAnswerVO {
* 及格线/总分格式60,100 * 及格线/总分格式60,100
*/ */
pass: string; pass: string;
/**
* 文件地址
*/
file: string;
} }
export interface QuestionUserAnswerForm extends BaseEntity { export interface QuestionUserAnswerForm extends BaseEntity {
@ -50,7 +29,7 @@ export interface QuestionUserAnswerForm extends BaseEntity {
* 主键id * 主键id
*/ */
id?: string | number; id?: string | number;
teamId?: string | number;
/** /**
* 项目id * 项目id
*/ */
@ -64,18 +43,23 @@ export interface QuestionUserAnswerForm extends BaseEntity {
/** /**
* 题库id列表 * 题库id列表
*/ */
bankIdList: Array<string | number>; bankId?: string | number;
/** /**
* 答案列表 * 答案列表
*/ */
answerList: Array<string>; answer?: string;
/** /**
* 得分 * 得分
*/ */
score?: number; score?: number;
/**
* 考试时间(时间戳/秒)
*/
examTime?: number;
/** /**
* 用时时间(时间戳/秒) * 用时时间(时间戳/秒)
*/ */
@ -93,45 +77,16 @@ export interface QuestionUserAnswerForm extends BaseEntity {
} }
export interface QuestionUserAnswerQuery extends PageQuery { export interface QuestionUserAnswerQuery extends PageQuery {
/**
* 项目id
*/
projectId?: string | number;
/** /**
* 用户id * 用户id
*/ */
userId?: string | number; userId?: string | number;
teamId?: string | number;
projectId?: string | number;
/** /**
* 题库id列表 * 考试类型1线上考试 2线下考试
*/ */
bankIdList: Array<string | number>; examType?: string;
/**
* 答案列表
*/
answerList: Array<string>;
/**
* 得分
*/
score?: number;
/**
* 用时时间(时间戳/秒)
*/
takeTime?: number;
/**
* 及格线/总分格式60,100
*/
pass?: string;
/**
* 文件地址
*/
file?: string;
/** /**
* 日期范围参数 * 日期范围参数

View File

@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { QuestionsCategoryVO, QuestionsCategoryForm, QuestionsCategoryQuery } from '@/api/safety/questionsCategory/types';
/**
* 查询题库类别列表
* @param query
* @returns {*}
*/
export const listQuestionsCategory = (query?: QuestionsCategoryQuery): AxiosPromise<QuestionsCategoryVO[]> => {
return request({
url: '/safety/questionsCategory/list',
method: 'get',
params: query
});
};
/**
* 查询题库类别详细
* @param id
*/
export const getQuestionsCategory = (id: string | number): AxiosPromise<QuestionsCategoryVO> => {
return request({
url: '/safety/questionsCategory/' + id,
method: 'get'
});
};
/**
* 新增题库类别
* @param data
*/
export const addQuestionsCategory = (data: QuestionsCategoryForm) => {
return request({
url: '/safety/questionsCategory',
method: 'post',
data: data
});
};
/**
* 修改题库类别
* @param data
*/
export const updateQuestionsCategory = (data: QuestionsCategoryForm) => {
return request({
url: '/safety/questionsCategory',
method: 'put',
data: data
});
};
/**
* 删除题库类别
* @param id
*/
export const delQuestionsCategory = (id: string | number | Array<string | number>) => {
return request({
url: '/safety/questionsCategory/' + id,
method: 'delete'
});
};

View File

@ -0,0 +1,41 @@
export interface QuestionsCategoryVO {
/**
* 题库类别
*/
categoryName: string;
id: string | number;
}
export interface QuestionsCategoryForm extends BaseEntity {
/**
* 主键id
*/
id?: string | number;
/**
* 项目id
*/
projectId?: string | number;
/**
* 题库类别
*/
categoryName?: string;
}
export interface QuestionsCategoryQuery extends PageQuery {
/**
* 项目id
*/
projectId?: string | number;
/**
* 题库类别
*/
categoryName?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@ -1,4 +1,4 @@
import request from '@/utils/request'; import request, { download } from '@/utils/request';
import { OssQuery, OssVO } from './types'; import { OssQuery, OssVO } from './types';
import { AxiosPromise } from 'axios'; import { AxiosPromise } from 'axios';
@ -26,3 +26,8 @@ export function delOss(ossId: string | number | Array<string | number>) {
method: 'delete' method: 'delete'
}); });
} }
// 下载OSS对象存储
export function downLoadOss(ossId: string | number | Array<string | number>) {
return download('/safety/questionUserAnswer/exportFile', { userIdList: ossId }, '安全考试.zip');
}

View File

@ -16,28 +16,12 @@
:list-type="isConstruction ? 'picture-card' : 'text'" :list-type="isConstruction ? 'picture-card' : 'text'"
:accept="accept" :accept="accept"
:drag="isDarg" :drag="isDarg"
:data="data"
> >
<slot>
<!-- 上传按钮 --> <!-- 上传按钮 -->
<el-button v-if="!isConstruction && !isImportInfo" type="primary">选取文件</el-button> <el-button v-if="!isConstruction && !isImportInfo" type="primary">选取文件</el-button>
<el-button v-if="isImportInfo" type="warning" plain icon="Edit">导入员工资料 </el-button> <el-button v-if="isImportInfo" type="warning" plain icon="Edit">导入员工资料 </el-button>
<el-icon v-if="isConstruction"><Plus /></el-icon>
<template #file="{ file }">
<div class="pdf" v-if="isConstruction">
<img src="@/assets/icons/svg/pdf.png" alt="" />
<el-text class="w-148px text-center" truncated>
<span>{{ file.name }}</span>
</el-text>
<div class="Shadow">
<a :href="file.url" target="_blank">
<el-icon class="mr"><View /></el-icon>
</a>
<a href="#">
<el-icon @click="handleDelete(file.ossId, 'ossId')"><Delete /></el-icon>
</a>
</div>
</div>
</template>
</el-upload>
<!-- 上传提示 --> <!-- 上传提示 -->
<div v-if="showTip" class="el-upload__tip"> <div v-if="showTip" class="el-upload__tip">
请上传 请上传
@ -65,6 +49,26 @@
</div> </div>
</li> </li>
</transition-group> </transition-group>
</slot>
<el-icon v-if="isConstruction"><Plus /></el-icon>
<template #file="{ file }">
<div class="pdf" v-if="isConstruction">
<img src="@/assets/icons/svg/pdf.png" alt="" />
<el-text class="w-148px text-center" truncated>
<span>{{ file.name }}</span>
</el-text>
<div class="Shadow">
<a :href="file.url" target="_blank">
<el-icon class="mr"><View /></el-icon>
</a>
<a href="#">
<el-icon @click="handleDelete(file.ossId, 'ossId')"><Delete /></el-icon>
</a>
</div>
</div>
</template>
</el-upload>
</div> </div>
</template> </template>
@ -93,7 +97,9 @@ const props = defineProps({
//ip地址 //ip地址
uploadUrl: propTypes.string.def('/resource/oss/upload'), uploadUrl: propTypes.string.def('/resource/oss/upload'),
//可拖拽上传 //可拖拽上传
isDarg: propTypes.bool.def(false) isDarg: propTypes.bool.def(false),
// 其他参数
data: propTypes.object.def({})
}); });
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -233,7 +239,6 @@ const uploadedSuccessfully = () => {
} }
if (number.value > 0 && uploadList.value.length === number.value) { if (number.value > 0 && uploadList.value.length === number.value) {
fileList.value = fileList.value.filter((f) => f.url !== undefined).concat(uploadList.value); fileList.value = fileList.value.filter((f) => f.url !== undefined).concat(uploadList.value);
console.log('🚀 ~ uploadedSuccessfully ~ fileList.value:', fileList.value);
uploadList.value = []; uploadList.value = [];
number.value = 0; number.value = 0;

View File

@ -234,6 +234,7 @@ const submitForm = () => {
machineryFormRef.value?.validate(async (valid: boolean) => { machineryFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
form.value.projectId = currentProject.value.id;
if (form.value.id) { if (form.value.id) {
await updateMachinery(form.value).finally(() => (buttonLoading.value = false)); await updateMachinery(form.value).finally(() => (buttonLoading.value = false));
} else { } else {

View File

@ -12,7 +12,7 @@
<el-option v-for="item in contractorOpt" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in contractorOpt" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="班组" prop="contractorId"> <el-form-item label="班组" prop="teamId">
<el-select v-model="queryParams.teamId" clearable placeholder="全部"> <el-select v-model="queryParams.teamId" clearable placeholder="全部">
<el-option v-for="item in ProjectTeam" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in ProjectTeam" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>

View File

@ -4,26 +4,13 @@
<div v-show="showSearch" class="mb-[10px]"> <div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover"> <el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true"> <el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="项目id" prop="projectId"> <el-form-item label="用户姓名" prop="userId">
<el-input v-model="queryParams.projectId" placeholder="请输入项目id" clearable @keyup.enter="handleQuery" /> <el-input v-model="queryParams.userId" placeholder="请输入用户姓名" clearable @keyup.enter="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="用户id" prop="userId"> <el-form-item label="班组" prop="teamId">
<el-input v-model="queryParams.userId" placeholder="请输入用户id" clearable @keyup.enter="handleQuery" /> <el-select v-model="queryParams.teamId" clearable placeholder="全部">
</el-form-item> <el-option v-for="item in ProjectTeam" :key="item.value" :label="item.label" :value="item.value" />
<el-form-item label="题库id列表" prop="bankId"> </el-select>
<el-input v-model="queryParams.bankId" placeholder="请输入题库id列表" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="答案列表" prop="answer">
<el-input v-model="queryParams.answer" placeholder="请输入答案列表" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="得分" prop="score">
<el-input v-model="queryParams.score" placeholder="请输入得分" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="用时时间" prop="takeTime">
<el-input v-model="queryParams.takeTime" placeholder="请输入用时时间" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="及格线/总分" prop="pass">
<el-input v-model="queryParams.pass" placeholder="请输入及格线/总分" clearable @keyup.enter="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
@ -38,26 +25,25 @@
<template #header> <template #header>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionUserAnswer:add']">新增 </el-button> <el-tooltip placement="top" effect="dark">
<template #content>
:上传压缩包内的文件夹名称需设置为姓名-身份证-满分-得分-及格分 <br />
例如:小明-5130112333654X-100-59-60
</template>
<file-upload
:limit="1"
v-model:model-value="filePath"
isImportInfo
:fileType="['zip']"
uploadUrl="/safety/questionUserAnswer/upload/zip"
:file-size="5000"
:data="{ projectId: currentProject.id }"
><el-button type="success" plain icon="Upload">上传线下安全考试</el-button></file-upload
>
</el-tooltip>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionUserAnswer:edit']" <el-button type="primary" plain icon="Download" :disabled="single" @click="handleDownload()">批量下载</el-button>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete()"
v-hasPermi="['safety:questionUserAnswer:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionUserAnswer:export']">导出 </el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -65,89 +51,61 @@
<el-table v-loading="loading" :data="questionUserAnswerList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="questionUserAnswerList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键id" align="center" prop="id" v-if="true" /> <el-table-column label="主键id" align="center" prop="id" v-if="false" />
<el-table-column label="项目id" align="center" prop="projectId" /> <el-table-column label="姓名" align="center" prop="userName" />
<el-table-column label="用户id" align="center" prop="userId" />
<el-table-column label="题库id列表" align="center" prop="bankId" />
<el-table-column label="答案列表" align="center" prop="answer" />
<el-table-column label="得分" align="center" prop="score" />
<el-table-column label="用时时间" align="center" prop="takeTime" />
<el-table-column label="及格线/总分" align="center" prop="pass" /> <el-table-column label="及格线/总分" align="center" prop="pass" />
<el-table-column label="文件地址" align="center" prop="file" /> <el-table-column label="得分" align="center" prop="score" />
<el-table-column label="计划时间" align="center" prop="examTime" />
<el-table-column label="用时时间" align="center" prop="takeTime" />
<el-table-column label="考试时间" align="center" prop="createTime" />
<el-table-column label="类型" align="center" prop="examType">
<template #default="scope">
<dict-tag :options="user_exam_type" :value="scope.row.examType" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-tooltip content="修改" placement="top"> <el-link type="primary" :underline="false" :href="scope.row.fileUrl[0]" target="_blank">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:questionUserAnswer:edit']"></el-button> <el-button link type="primary" icon="View">预览试卷</el-button>
</el-tooltip> </el-link>
<el-tooltip content="删除" placement="top">
<el-button <el-button link type="primary" icon="Download" @click="handleDownload(scope.row)">下载试卷</el-button>
link
type="primary"
icon="Delete"
@click="handleDelete(scope.row)"
v-hasPermi="['safety:questionUserAnswer:remove']"
></el-button>
</el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card> </el-card>
<!-- 添加或修改用户试卷存储对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="questionUserAnswerFormRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="项目id" prop="projectId">
<el-input v-model="form.projectId" placeholder="请输入项目id" />
</el-form-item>
<el-form-item label="用户id" prop="userId">
<el-input v-model="form.userId" placeholder="请输入用户id" />
</el-form-item>
<el-form-item label="题库id列表" prop="bankId">
<el-input v-model="form.bankId" placeholder="请输入题库id列表" />
</el-form-item>
<el-form-item label="答案列表" prop="answer">
<el-input v-model="form.answer" placeholder="请输入答案列表" />
</el-form-item>
<el-form-item label="得分" prop="score">
<el-input v-model="form.score" placeholder="请输入得分" />
</el-form-item>
<el-form-item label="用时时间" prop="takeTime">
<el-input v-model="form.takeTime" placeholder="请输入用时时间" />
</el-form-item>
<el-form-item label="及格线/总分" prop="pass">
<el-input v-model="form.pass" placeholder="请输入及格线/总分" />
</el-form-item>
<el-form-item label="文件地址" prop="file">
<file-upload v-model="form.file" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div> </div>
</template> </template>
<script setup name="QuestionUserAnswer" lang="ts"> <script setup name="QuestionUserAnswer" lang="ts">
import { import {
addQuestionUserAnswer,
delQuestionUserAnswer,
getQuestionUserAnswer,
listQuestionUserAnswer, listQuestionUserAnswer,
updateQuestionUserAnswer getQuestionUserAnswer,
delQuestionUserAnswer,
addQuestionUserAnswer,
updateQuestionUserAnswer,
uploadQuestionUserAnswer
} from '@/api/safety/questionUserAnswer'; } from '@/api/safety/questionUserAnswer';
import { QuestionUserAnswerForm, QuestionUserAnswerQuery, QuestionUserAnswerVO } from '@/api/safety/questionUserAnswer/types'; import { QuestionUserAnswerVO, QuestionUserAnswerQuery, QuestionUserAnswerForm } from '@/api/safety/questionUserAnswer/types';
import { downLoadOss } from '@/api/system/oss';
import download from '@/plugins/download';
import { useUserStoreHook } from '@/store/modules/user'; import { useUserStoreHook } from '@/store/modules/user';
import { blobValidate } from '@/utils/ruoyi';
import FileSaver from 'file-saver';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { user_exam_type } = toRefs<any>(proxy?.useDict('user_exam_type'));
// 获取用户 store // 获取用户 store
const userStore = useUserStoreHook(); const userStore = useUserStoreHook();
// 从 store 中获取项目列表和当前选中的项目 // 从 store 中获取项目列表和当前选中的项目
const currentProject = computed(() => userStore.selectedProject); const currentProject = computed(() => userStore.selectedProject);
const ProjectTeam = computed(() => userStore.ProjectTeamList);
const questionUserAnswerList = ref<QuestionUserAnswerVO[]>([]); const questionUserAnswerList = ref<QuestionUserAnswerVO[]>([]);
const buttonLoading = ref(false); const buttonLoading = ref(false);
const loading = ref(true); const loading = ref(true);
@ -156,7 +114,7 @@ const ids = ref<Array<string | number>>([]);
const single = ref(true); const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const filePath = ref<string>('');
const queryFormRef = ref<ElFormInstance>(); const queryFormRef = ref<ElFormInstance>();
const questionUserAnswerFormRef = ref<ElFormInstance>(); const questionUserAnswerFormRef = ref<ElFormInstance>();
@ -169,30 +127,30 @@ const initFormData: QuestionUserAnswerForm = {
id: undefined, id: undefined,
projectId: currentProject.value.id, projectId: currentProject.value.id,
userId: undefined, userId: undefined,
bankIdList: undefined, bankId: undefined,
answer: undefined, answer: undefined,
score: undefined, score: undefined,
examTime: undefined,
takeTime: undefined, takeTime: undefined,
pass: undefined, pass: undefined,
file: undefined file: undefined,
teamId: undefined
}; };
const data = reactive<PageData<QuestionUserAnswerForm, QuestionUserAnswerQuery>>({ const data = reactive<PageData<QuestionUserAnswerForm, QuestionUserAnswerQuery>>({
form: { ...initFormData }, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
projectId: currentProject.value.id,
userId: undefined, userId: undefined,
bankIdList: undefined, examType: undefined,
answer: undefined, teamId: undefined,
score: undefined, projectId: currentProject.value.id,
takeTime: undefined,
pass: undefined,
file: undefined,
params: {} params: {}
}, },
rules: { rules: {
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }] id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }],
userId: [{ required: true, message: '用户id不能为空', trigger: 'blur' }]
} }
}); });
@ -234,63 +192,48 @@ const resetQuery = () => {
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: QuestionUserAnswerVO[]) => { const handleSelectionChange = (selection: QuestionUserAnswerVO[]) => {
ids.value = selection.map((item) => item.id); ids.value = selection.map((item) => item.id);
single.value = selection.length != 1; single.value = selection.length == 0;
multiple.value = !selection.length; multiple.value = !selection.length;
}; };
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加用户试卷存储';
};
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row?: QuestionUserAnswerVO) => { // const handleUpdate = async (row?: QuestionUserAnswerVO) => {
reset(); // reset();
const _id = row?.id || ids.value[0]; // const _id = row?.id || ids.value[0];
const res = await getQuestionUserAnswer(_id); // const res = await getQuestionUserAnswer(_id);
Object.assign(form.value, res.data); // Object.assign(form.value, res.data);
dialog.visible = true; // dialog.visible = true;
dialog.title = '修改用户试卷存储'; // dialog.title = '修改用户试卷存储';
}; // };
/** 提交按钮 */
const submitForm = () => {
questionUserAnswerFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateQuestionUserAnswer(form.value).finally(() => (buttonLoading.value = false));
} else {
await addQuestionUserAnswer(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (row?: QuestionUserAnswerVO) => { const handleDownload = async (row?: QuestionUserAnswerVO) => {
const _ids = row?.id || ids.value; const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除用户试卷存储编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false)); const res = await downLoadOss(_ids);
await delQuestionUserAnswer(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
}; };
/** 导出按钮操作 */ // const fileWatch = watch(
const handleExport = () => { // () => filePath.value,
proxy?.download( // (nid, oid) => {
'safety/questionUserAnswer/export', // uploadQuestionUserAnswer({ file: filePath.value, projectId: currentProject.value.id }).then((res) => {
{ // console.log(res);
...queryParams.value // });
}, // }
`questionUserAnswer_${new Date().getTime()}.xlsx` // );
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value.id,
(nid, oid) => {
queryParams.value.projectId = nid;
form.value.projectId = nid;
getList();
}
); );
};
onUnmounted(() => {
listeningProject();
});
onMounted(() => { onMounted(() => {
getList(); getList();

View File

@ -0,0 +1,236 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="题库类别" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入题库类别" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionsCategory:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionsCategory:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionsCategory:remove']"
>删除</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" :data="questionsCategoryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" type="index" width="100" />
<el-table-column label="题库类别" align="center" prop="categoryName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:questionsCategory:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button
link
type="primary"
icon="Delete"
@click="handleDelete(scope.row)"
v-hasPermi="['safety:questionsCategory:remove']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改题库类别对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="questionsCategoryFormRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="题库类别" prop="categoryName">
<el-input v-model="form.categoryName" placeholder="请输入题库类别" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="QuestionsCategory" lang="ts">
import {
listQuestionsCategory,
getQuestionsCategory,
delQuestionsCategory,
addQuestionsCategory,
updateQuestionsCategory
} from '@/api/safety/questionsCategory';
import { QuestionsCategoryVO, QuestionsCategoryQuery, QuestionsCategoryForm } from '@/api/safety/questionsCategory/types';
import { useUserStoreHook } from '@/store/modules/user';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
// 获取用户 store
const userStore = useUserStoreHook();
// 从 store 中获取项目列表和当前选中的项目
const currentProject = computed(() => userStore.selectedProject);
const questionsCategoryList = ref<QuestionsCategoryVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const questionsCategoryFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: QuestionsCategoryForm = {
id: undefined,
projectId: currentProject.value.id,
categoryName: undefined
};
const data = reactive<PageData<QuestionsCategoryForm, QuestionsCategoryQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
projectId: currentProject.value.id,
categoryName: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }],
categoryName: [{ required: true, message: '题库类别不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询题库类别列表 */
const getList = async () => {
loading.value = true;
const res = await listQuestionsCategory(queryParams.value);
questionsCategoryList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
questionsCategoryFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: QuestionsCategoryVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加题库类别';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: QuestionsCategoryVO) => {
reset();
const _id = row?.id || ids.value[0];
const res = await getQuestionsCategory(_id);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改题库类别';
};
/** 提交按钮 */
const submitForm = () => {
questionsCategoryFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
form.value.projectId = currentProject.value.id;
if (form.value.id) {
await updateQuestionsCategory(form.value).finally(() => (buttonLoading.value = false));
} else {
await addQuestionsCategory(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: QuestionsCategoryVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除题库类别编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delQuestionsCategory(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value.id,
(nid, oid) => {
queryParams.value.projectId = nid;
form.value.projectId = nid;
getList();
}
);
onUnmounted(() => {
listeningProject();
});
onMounted(() => {
getList();
});
</script>

View File

@ -5,52 +5,56 @@
<el-col :span="12" style="text-align: left">填报人{{ safetyInspectionDetail?.creatorName }}</el-col> <el-col :span="12" style="text-align: left">填报人{{ safetyInspectionDetail?.creatorName }}</el-col>
<el-col :span="12" style="text-align: right">填报时间{{ safetyInspectionDetail?.createTime }}</el-col> <el-col :span="12" style="text-align: right">填报时间{{ safetyInspectionDetail?.createTime }}</el-col>
</el-row> </el-row>
<el-descriptions :column="2" border style="margin-top: 8px" label-width="160px"> <el-descriptions :column="2" border style="margin-top: 8px" label-width="160px" size="large">
<el-descriptions-item label-align="center" label="检查项目" :span="2">{{ currentProject?.name }} </el-descriptions-item> <el-descriptions-item label-align="center" label="检查项目" :span="2" class-name="zebra">{{ currentProject?.name }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="检查类型"> <el-descriptions-item label-align="center" label="检查类型" label-class-name="white">
<dict-tag :options="safety_inspection_check_type" :value="safetyInspectionDetail?.checkType" /> <dict-tag :options="safety_inspection_check_type" :value="safetyInspectionDetail?.checkType" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label-align="center" label="违章类型"> <el-descriptions-item label-align="center" label="违章类型" label-class-name="white">
<dict-tag :options="safety_inspection_violation_type" :value="safetyInspectionDetail?.violationType" /> <dict-tag :options="safety_inspection_violation_type" :value="safetyInspectionDetail?.violationType" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label-align="center" label="检查时间">{{ safetyInspectionDetail?.checkTime }} </el-descriptions-item> <el-descriptions-item label-align="center" label="检查时间" class-name="zebra">{{ safetyInspectionDetail?.checkTime }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="检查人">{{ safetyInspectionDetail?.correctorName }} </el-descriptions-item> <el-descriptions-item label-align="center" label="检查人" class-name="zebra">{{ safetyInspectionDetail?.creatorName }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="整改人">{{ safetyInspectionDetail?.correctorName }} </el-descriptions-item> <el-descriptions-item label-align="center" label="整改人" label-class-name="white">{{ safetyInspectionDetail?.correctorName }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="要求整改期限"> <el-descriptions-item label-align="center" label="要求整改期限" label-class-name="white">
{{ dayjs(safetyInspectionDetail?.rectificationDeadline).format('YYYY 年 MM 月 DD 日') }} {{ dayjs(safetyInspectionDetail?.rectificationDeadline).format('YYYY 年 MM 月 DD 日') }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<div class="table-title">巡检结果</div> <el-descriptions border direction="vertical" size="large">
<el-descriptions :column="2" border label-width="160px"> <el-descriptions-item label-align="center" label="巡检结果" class-name="none"></el-descriptions-item>
<el-descriptions-item label-align="center" label="内容" :span="2">{{ safetyInspectionDetail?.hiddenDanger }} </el-descriptions-item> </el-descriptions>
<el-descriptions-item label-align="center" label="检查附件" :span="2"> <el-descriptions :column="2" border label-width="160px" size="large">
<el-descriptions-item label-align="center" label="内容" :span="2" label-class-name="white">{{ safetyInspectionDetail?.hiddenDanger }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="检查附件" :span="2" label-class-name="white">
<el-space wrap> <el-space wrap>
<div v-for="item in checkFileList" :key="item.ossId"> <div v-for="item in checkFileList" :key="item.ossId">
<span v-if="['.png', '.jpg', '.jpeg'].includes(item.fileSuffix)"> <span v-if="['.png', '.jpg', '.jpeg'].includes(item.fileSuffix)">
<image-preview :src="item.url" width="200px" /> <image-preview :src="item.url" width="200px" />
</span> </span>
<span v-else> <span v-else>
<el-link :href="`${item.url}`" :underline="false" target="_blank"> <el-link :href="`${item.url}`" type="primary" :underline="false" target="_blank">
<span> {{ item.originalName }} </span> <span> {{ item.originalName }} </span>
</el-link> </el-link>
</span> </span>
</div> </div>
</el-space> </el-space>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label-align="center" label="检查状态" :span="2"> <el-descriptions-item label-align="center" label="检查状态" :span="2" label-class-name="white">
<el-steps style="max-width: 200px" :active="Number(safetyInspectionDetail?.status)" finish-status="success"> <el-steps style="max-width: 200px" :active="Number(safetyInspectionDetail?.status)" finish-status="success">
<el-step v-for="item in safety_inspection_type" :key="item.value" :title="item.label" /> <el-step v-for="item in safety_inspection_type" :key="item.value" :title="item.label" />
</el-steps> </el-steps>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<div class="table-title">整改情况</div> <el-descriptions border direction="vertical" size="large">
<el-descriptions :column="2" border label-width="160px"> <el-descriptions-item label-align="center" label="整改情况" class-name="none"></el-descriptions-item>
<el-descriptions-item label-align="center" label="班组">{{ safetyInspectionDetail?.teamName }} </el-descriptions-item> </el-descriptions>
<el-descriptions-item label-align="center" label="整改日期">{{ safetyInspectionDetail?.rectificationTime }} </el-descriptions-item> <el-descriptions :column="2" border label-width="160px" size="large">
<el-descriptions-item label-align="center" label="整改措施及完成情况" :span="2"> <el-descriptions-item label-align="center" label="班组" label-class-name="white">{{ safetyInspectionDetail?.teamName }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="整改日期" label-class-name="white">{{ safetyInspectionDetail?.rectificationTime }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="整改措施及完成情况" :span="2" label-class-name="white">
{{ safetyInspectionDetail?.measure }} {{ safetyInspectionDetail?.measure }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label-align="center" label="整改附件" :span="2"> <el-descriptions-item label-align="center" label="整改附件" :span="2" label-class-name="white">
<el-space wrap> <el-space wrap>
<div v-for="item in rectificationFileList" :key="item.ossId"> <div v-for="item in rectificationFileList" :key="item.ossId">
<span v-if="['.png', '.jpg', '.jpeg'].includes(item.fileSuffix)"> <span v-if="['.png', '.jpg', '.jpeg'].includes(item.fileSuffix)">
@ -64,12 +68,14 @@
</div> </div>
</el-space> </el-space>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions size="large">
<el-descriptions border direction="vertical" size="large">
<el-descriptions-item label-align="center" label="复查结果" class-name="none"></el-descriptions-item>
</el-descriptions> </el-descriptions>
<div class="table-title">复查结果</div> <el-descriptions :column="2" border label-width="160px" size="large">
<el-descriptions :column="2" border label-width="160px"> <el-descriptions-item label-align="center" label="复查人" label-class-name="white">{{ safetyInspectionDetail?.creatorName }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="复查">{{ safetyInspectionDetail?.creatorName }} </el-descriptions-item> <el-descriptions-item label-align="center" label="复查日期" label-class-name="white">{{ safetyInspectionDetail?.reviewTime }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="复查日期">{{ safetyInspectionDetail?.reviewTime }} </el-descriptions-item> <el-descriptions-item label-align="center" label="复查情况" :span="2" label-class-name="white">{{ safetyInspectionDetail?.review }} </el-descriptions-item>
<el-descriptions-item label-align="center" label="复查情况" :span="2">{{ safetyInspectionDetail?.review }} </el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-card> </el-card>
</template> </template>
@ -134,14 +140,14 @@ watch(
); );
</script> </script>
<style scoped> <style scoped lang="scss">
.table-title { :deep(.white) {
display: flex; background: #fff!important;
justify-content: center; }
align-items: flex-end; :deep(.none) {
height: 35px; display: none !important;
font-weight: bold; }
font-size: 16px; :deep(.zebra) {
padding-bottom: 4px; background: #f5f7fa;
} }
</style> </style>

View File

@ -86,7 +86,7 @@
</el-button> </el-button>
<!-- <el-button link type="success" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:safetyInspection:edit']">修改 </el-button> --> <!-- <el-button link type="success" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:safetyInspection:edit']">修改 </el-button> -->
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:safetyInspection:remove']"> <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:safetyInspection:remove']">
修改 删除
</el-button> </el-button>
</el-space> </el-space>
</template> </template>
@ -117,7 +117,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="整改人" prop="correctorId"> <el-form-item label="整改人" prop="correctorId">
<el-select v-model="form.correctorId" placeholder="请选择整改人" disabled> <el-select v-model="form.correctorId" placeholder="请选择整改人" :disabled="!form.teamId">
<el-option v-for="item in foremanOpt" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in foremanOpt" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -165,11 +165,11 @@ import { SafetyInspectionForm, SafetyInspectionQuery, SafetyInspectionVO } from
import { useUserStoreHook } from '@/store/modules/user'; import { useUserStoreHook } from '@/store/modules/user';
import SafetyInspectionDetailDialog from '@/views/safety/safetyInspection/component/SafetyInspectionDetailDialog.vue'; import SafetyInspectionDetailDialog from '@/views/safety/safetyInspection/component/SafetyInspectionDetailDialog.vue';
import { listProjectTeamForeman } from '@/api/project/projectTeam'; import { listProjectTeamForeman } from '@/api/project/projectTeam';
import { ProjectTeamForemanResp } from '@/api/project/projectTeam/types'; import { foremanQuery, ProjectTeamForemanResp } from '@/api/project/projectTeam/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { safety_inspection_violation_type, review_type, reply_type, safety_inspection_type, safety_inspection_check_type } = toRefs<any>( const { safety_inspection_violation_type, review_type, safety_inspection_type, safety_inspection_check_type } = toRefs<any>(
proxy?.useDict('safety_inspection_violation_type', 'review_type', 'reply_type', 'safety_inspection_type', 'safety_inspection_check_type') proxy?.useDict('safety_inspection_violation_type', 'review_type', 'safety_inspection_type', 'safety_inspection_check_type')
); );
// 获取用户 store // 获取用户 store
const userStore = useUserStoreHook(); const userStore = useUserStoreHook();
@ -252,8 +252,8 @@ const data = reactive<PageData<SafetyInspectionForm, SafetyInspectionQuery>>({
const { queryParams, form, rules } = toRefs(data); const { queryParams, form, rules } = toRefs(data);
const teamOpt = ref(); const teamOpt = ref([]);
const foremanOpt = ref(); const foremanOpt = ref([]);
const teamList = ref<ProjectTeamForemanResp[]>(); const teamList = ref<ProjectTeamForemanResp[]>();
/** 查询安全巡检工单列表 */ /** 查询安全巡检工单列表 */
const getList = async () => { const getList = async () => {
@ -268,16 +268,17 @@ const getList = async () => {
label: team.teamName, label: team.teamName,
value: team.id value: team.id
})); }));
foremanOpt.value = teamList.value.map((team: ProjectTeamForemanResp) => ({
label: team.foremanName,
value: team.foremanId
}));
loading.value = false; loading.value = false;
}; };
const changeForeman = (value: string | number) => { const changeForeman = (value: string | number) => {
const team = teamList.value.find((team) => team.id === value); const team = teamList.value.filter((team) => team.id === value)[0];
form.value.correctorId = team.foremanId; foremanOpt.value = team.foremanList?.map((foreman: foremanQuery) => ({
label: foreman.foremanName,
value: foreman.foremanId
}));
form.value.correctorId = '';
}; };
/** 展开安全巡检工单详情对话框操作 */ /** 展开安全巡检工单详情对话框操作 */
@ -342,6 +343,7 @@ const submitForm = () => {
safetyInspectionFormRef.value?.validate(async (valid: boolean) => { safetyInspectionFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
form.value.projectId = currentProject.value.id;
if (form.value.id) { if (form.value.id) {
await updateSafetyInspection(form.value).finally(() => (buttonLoading.value = false)); await updateSafetyInspection(form.value).finally(() => (buttonLoading.value = false));
} else { } else {
@ -374,6 +376,20 @@ const handleExport = () => {
); );
}; };
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value.id,
(nid, oid) => {
queryParams.value.projectId = nid;
form.value.projectId = nid;
getList();
}
);
onUnmounted(() => {
listeningProject();
});
onMounted(() => { onMounted(() => {
getList(); getList();
}); });

View File

@ -42,7 +42,7 @@
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label-align="center" label="附件" :span="3"> <el-descriptions-item label-align="center" label="附件" :span="3">
<el-space direction="vertical"> <el-space direction="vertical">
<el-link v-for="item in fileList" :key="item.ossId" :href="`${item.url}`" :underline="false" target="_blank"> <el-link v-for="item in fileList" :key="item.ossId" :href="`${item.url}`" type="primary" :underline="false" target="_blank">
<span> {{ item.originalName }} </span> <span> {{ item.originalName }} </span>
</el-link> </el-link>
</el-space> </el-space>

View File

@ -70,7 +70,7 @@
</el-card> </el-card>
<!-- 添加或修改安全日志对话框 --> <!-- 添加或修改安全日志对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="950px" append-to-body> <el-dialog :title="dialog.title" v-model="dialog.visible" width="950px" append-to-body>
<el-form ref="safetyLogFormRef" :model="form" :rules="rules" label-width="120px"> <el-form ref="safetyLogFormRef" :model="form" :rules="rules" label-width="250px">
<el-form-item label="发生日期" prop="dateOfOccurrence"> <el-form-item label="发生日期" prop="dateOfOccurrence">
<el-date-picker clearable v-model="form.dateOfOccurrence" type="date" value-format="YYYY-MM-DD" placeholder="请选择发生日期"> <el-date-picker clearable v-model="form.dateOfOccurrence" type="date" value-format="YYYY-MM-DD" placeholder="请选择发生日期">
</el-date-picker> </el-date-picker>
@ -283,6 +283,7 @@ const submitForm = () => {
safetyLogFormRef.value?.validate(async (valid: boolean) => { safetyLogFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
form.value.projectId = currentProject.value.id;
if (form.value.id) { if (form.value.id) {
await updateSafetyLog(form.value).finally(() => (buttonLoading.value = false)); await updateSafetyLog(form.value).finally(() => (buttonLoading.value = false));
} else { } else {
@ -315,6 +316,20 @@ const handleExport = () => {
); );
}; };
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value.id,
(nid, oid) => {
queryParams.value.projectId = nid;
form.value.projectId = nid;
getList();
}
);
onUnmounted(() => {
listeningProject();
});
onMounted(() => { onMounted(() => {
getList(); getList();
}); });

View File

@ -231,6 +231,7 @@ const submitForm = () => {
safetyWeeklyReportFormRef.value?.validate(async (valid: boolean) => { safetyWeeklyReportFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
form.value.projectId = currentProject.value.id;
if (form.value.id) { if (form.value.id) {
await updateSafetyWeeklyReport(form.value).finally(() => (buttonLoading.value = false)); await updateSafetyWeeklyReport(form.value).finally(() => (buttonLoading.value = false));
} else { } else {
@ -263,6 +264,20 @@ const handleExport = () => {
); );
}; };
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value.id,
(nid, oid) => {
queryParams.value.projectId = nid;
form.value.projectId = nid;
getList();
}
);
onUnmounted(() => {
listeningProject();
});
onMounted(() => { onMounted(() => {
getList(); getList();
}); });

View File

@ -268,6 +268,20 @@ const handleExport = () => {
); );
}; };
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value.id,
(nid, oid) => {
queryParams.value.projectId = nid;
form.value.projectId = nid;
getList();
}
);
onUnmounted(() => {
listeningProject();
});
onMounted(() => { onMounted(() => {
getList(); getList();
}); });