施工人员黑名单后端逻辑优化,增加前端页面
This commit is contained in:
		
							
								
								
									
										163
									
								
								src/views/project/constructionBlacklist/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										163
									
								
								src/views/project/constructionBlacklist/index.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,163 @@ | ||||
| <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="userName"> | ||||
|               <el-input v-model="queryParams.userName" placeholder="请输入名字" clearable @keyup.enter="handleQuery" /> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="身份证号码" prop="sfzNumber" label-width="120"> | ||||
|               <el-input v-model="queryParams.sfzNumber" 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="danger" | ||||
|               plain | ||||
|               icon="Delete" | ||||
|               :disabled="multiple" | ||||
|               @click="handleDelete()" | ||||
|               v-hasPermi="['project:constructionBlacklist:remove']" | ||||
|               >删除 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | ||||
|         </el-row> | ||||
|       </template> | ||||
|  | ||||
|       <el-table v-loading="loading" :data="constructionBlacklistList" @selection-change="handleSelectionChange"> | ||||
|         <el-table-column type="selection" width="55" align="center" /> | ||||
|         <el-table-column label="序号" type="index" width="60" align="center" /> | ||||
|         <el-table-column label="名字" align="center" prop="userName" /> | ||||
|         <el-table-column label="身份证号码" align="center" prop="sfzNumber" /> | ||||
|         <el-table-column label="备注" align="center" prop="remark" /> | ||||
|         <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||
|           <template #default="scope"> | ||||
|             <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['project:constructionBlacklist:remove']"> | ||||
|               删除 | ||||
|             </el-button> | ||||
|           </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> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script setup name="ConstructionBlacklist" lang="ts"> | ||||
| import { delConstructionBlacklist, listConstructionBlacklist } from '@/api/project/constructionBlacklist'; | ||||
| import { ConstructionBlacklistForm, ConstructionBlacklistQuery, ConstructionBlacklistVO } from '@/api/project/constructionBlacklist/types'; | ||||
| import { useUserStoreHook } from '@/store/modules/user'; | ||||
|  | ||||
| const { proxy } = getCurrentInstance() as ComponentInternalInstance; | ||||
| // 获取用户 store | ||||
| const userStore = useUserStoreHook(); | ||||
| // 从 store 中获取项目列表和当前选中的项目 | ||||
| const currentProject = computed(() => userStore.selectedProject); | ||||
| const constructionBlacklistList = ref<ConstructionBlacklistVO[]>([]); | ||||
| 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 constructionBlacklistFormRef = ref<ElFormInstance>(); | ||||
|  | ||||
| const dialog = reactive<DialogOption>({ | ||||
|   visible: false, | ||||
|   title: '' | ||||
| }); | ||||
|  | ||||
| const initFormData: ConstructionBlacklistForm = { | ||||
|   projectId: currentProject.value.id, | ||||
|   userId: undefined, | ||||
|   remark: undefined | ||||
| }; | ||||
| const data = reactive<PageData<ConstructionBlacklistForm, ConstructionBlacklistQuery>>({ | ||||
|   form: { ...initFormData }, | ||||
|   queryParams: { | ||||
|     pageNum: 1, | ||||
|     pageSize: 10, | ||||
|     id: undefined, | ||||
|     projectId: currentProject.value.id, | ||||
|     userId: undefined, | ||||
|     userName: undefined, | ||||
|     sfzNumber: undefined, | ||||
|     params: {} | ||||
|   }, | ||||
|   rules: { | ||||
|     projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }], | ||||
|     userId: [{ required: true, message: '用户id不能为空', trigger: 'blur' }] | ||||
|   } | ||||
| }); | ||||
|  | ||||
| const { queryParams, form, rules } = toRefs(data); | ||||
|  | ||||
| /** 查询黑名单列表 */ | ||||
| const getList = async () => { | ||||
|   loading.value = true; | ||||
|   const res = await listConstructionBlacklist(queryParams.value); | ||||
|   constructionBlacklistList.value = res.rows; | ||||
|   total.value = res.total; | ||||
|   loading.value = false; | ||||
| }; | ||||
|  | ||||
| /** 取消按钮 */ | ||||
| const cancel = () => { | ||||
|   reset(); | ||||
|   dialog.visible = false; | ||||
| }; | ||||
|  | ||||
| /** 表单重置 */ | ||||
| const reset = () => { | ||||
|   form.value = { ...initFormData }; | ||||
|   constructionBlacklistFormRef.value?.resetFields(); | ||||
| }; | ||||
|  | ||||
| /** 搜索按钮操作 */ | ||||
| const handleQuery = () => { | ||||
|   queryParams.value.pageNum = 1; | ||||
|   getList(); | ||||
| }; | ||||
|  | ||||
| /** 重置按钮操作 */ | ||||
| const resetQuery = () => { | ||||
|   queryFormRef.value?.resetFields(); | ||||
|   handleQuery(); | ||||
| }; | ||||
|  | ||||
| /** 多选框选中数据 */ | ||||
| const handleSelectionChange = (selection: ConstructionBlacklistVO[]) => { | ||||
|   ids.value = selection.map((item) => item.id); | ||||
|   single.value = selection.length != 1; | ||||
|   multiple.value = !selection.length; | ||||
| }; | ||||
|  | ||||
| /** 删除按钮操作 */ | ||||
| const handleDelete = async (row?: ConstructionBlacklistVO) => { | ||||
|   const _ids = row?.id || ids.value; | ||||
|   await proxy?.$modal.confirm('是否确认删除黑名单编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false)); | ||||
|   await delConstructionBlacklist(_ids); | ||||
|   proxy?.$modal.msgSuccess('删除成功'); | ||||
|   await getList(); | ||||
| }; | ||||
|  | ||||
| onMounted(() => { | ||||
|   getList(); | ||||
| }); | ||||
| </script> | ||||
| @ -12,6 +12,11 @@ | ||||
|                 <el-option v-for="item in contractorOpt" :key="item.value" :label="item.label" :value="item.value" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="班组" prop="contractorId"> | ||||
|               <el-select v-model="queryParams.teamId" clearable placeholder="请选择班组"> | ||||
|                 <el-option v-for="item in projectTeamOpt" :key="item.value" :label="item.label" :value="item.value" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="工种" prop="typeOfWork"> | ||||
|               <el-select v-model="queryParams.typeOfWork" clearable placeholder="请选择工种"> | ||||
|                 <el-option v-for="item in type_of_work" :key="item.value" :label="item.label" :value="item.value" /> | ||||
| @ -71,16 +76,15 @@ | ||||
|             {{ getTeamName(scope.row.teamId) }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="状态" align="center" prop="status" /> | ||||
|         <el-table-column label="联系电话" align="center" prop="phone" /> | ||||
|         <el-table-column label="联系电话" align="center" prop="phone" min-width="120" /> | ||||
|         <el-table-column label="性别" align="center" prop="sex"> | ||||
|           <template #default="scope"> | ||||
|             <dict-tag :options="user_sex_type" :value="scope.row.sex" /> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="民族" align="center" prop="nation" /> | ||||
|         <el-table-column label="身份证号码" align="center" prop="sfzNumber" /> | ||||
|         <el-table-column label="工种" align="center" prop="typeOfWork"> | ||||
|         <el-table-column label="身份证号码" align="center" prop="sfzNumber" min-width="180" /> | ||||
|         <el-table-column label="工种" align="center" prop="typeOfWork" min-width="120"> | ||||
|           <template #default="scope"> | ||||
|             <dict-tag :options="type_of_work" :value="scope.row.typeOfWork" /> | ||||
|           </template> | ||||
| @ -90,11 +94,16 @@ | ||||
|             <dict-tag :options="user_clock_type" :value="scope.row.clock" /> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="入场时间" align="center" prop="entryDate" /> | ||||
|         <el-table-column label="离场时间" align="center" prop="leaveDate" /> | ||||
|         <el-table-column label="入场时间" align="center" prop="entryDate" min-width="180" /> | ||||
|         <el-table-column label="离场时间" align="center" prop="leaveDate" min-width="180" /> | ||||
|         <el-table-column label="薪水" align="center" prop="salary" /> | ||||
|         <el-table-column label="状态" align="center" prop="status"> | ||||
|           <template #default="scope"> | ||||
|             {{ scope.row.status == 0 ? '在职' : '离职' }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="备注" align="center" prop="remark" /> | ||||
|         <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||
|         <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" min-width="300"> | ||||
|           <template #default="scope"> | ||||
|             <el-space wrap> | ||||
|               <el-button link type="primary" icon="View" @click="handleShowDrawer(scope.row)" v-hasPermi="['project:constructionUser:query']"> | ||||
| @ -103,6 +112,9 @@ | ||||
|               <el-button link type="success" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['project:constructionUser:edit']"> | ||||
|                 修改 | ||||
|               </el-button> | ||||
|               <el-button link type="danger" icon="Avatar" @click="handleJoinBlacklist(scope.row)" v-hasPermi="['project:constructionBlacklist:add']"> | ||||
|                 黑名单 | ||||
|               </el-button> | ||||
|               <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['project:constructionUser:remove']"> | ||||
|                 删除 | ||||
|               </el-button> | ||||
| @ -271,7 +283,7 @@ import { listProjectTeam } from '@/api/project/projectTeam'; | ||||
| import { ContractorVO } from '@/api/project/contractor/types'; | ||||
| import { ProjectTeamVO } from '@/api/project/projectTeam/types'; | ||||
| import ConstructionUserDetail from '@/views/project/constructionUser/component/ConstructionUserDetail.vue'; | ||||
| import ProjectTypes from '@/utils/propTypes'; | ||||
| import { addConstructionBlacklist } from '@/api/project/constructionBlacklist'; | ||||
|  | ||||
| const { proxy } = getCurrentInstance() as ComponentInternalInstance; | ||||
| const { type_of_work, user_sex_type, user_clock_type } = toRefs<any>(proxy?.useDict('type_of_work', 'user_sex_type', 'user_clock_type')); | ||||
| @ -494,6 +506,17 @@ const submitForm = () => { | ||||
|   }); | ||||
| }; | ||||
|  | ||||
| /** 加入黑名单按钮操作 */ | ||||
| const handleJoinBlacklist = async (row?: ConstructionUserVO) => { | ||||
|   await proxy?.$modal.confirm('确认要将该员工加入黑名单吗?').finally(() => (loading.value = false)); | ||||
|   await addConstructionBlacklist({ | ||||
|     userId: row.id, | ||||
|     projectId: currentProject.value.id | ||||
|   }); | ||||
|   proxy?.$modal.msgSuccess('加入成功'); | ||||
|   await getList(); | ||||
| }; | ||||
|  | ||||
| /** 删除按钮操作 */ | ||||
| const handleDelete = async (row?: ConstructionUserVO) => { | ||||
|   const _ids = row?.id || ids.value; | ||||
|  | ||||
| @ -86,7 +86,7 @@ | ||||
|     <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> | ||||
|       <el-form ref="projectTeamMemberFormRef" :model="form" :rules="rules" label-width="80px"> | ||||
|         <el-form-item label="施工人员" prop="memberId"> | ||||
|           <el-select v-model="form.memberId" clearable placeholder="请选择人员"> | ||||
|           <el-select v-model="form.memberId" clearable placeholder="请选择人员" filterable> | ||||
|             <el-option v-for="item in userNotInTeamOpt" :key="item.value" :label="item.label" :value="item.value" /> | ||||
|             <pagination | ||||
|               size="small" | ||||
| @ -231,7 +231,8 @@ const userQueryParams = ref<ConstructionUserQuery>({ | ||||
|   pageNum: 1, | ||||
|   pageSize: 10, | ||||
|   orderByColumn: 'createTime', | ||||
|   isAsc: 'desc' | ||||
|   isAsc: 'desc', | ||||
|   projectId: currentProject.value.id | ||||
| }); | ||||
|  | ||||
| // 获取不在当前班组的成员 | ||||
|  | ||||
| @ -5,18 +5,18 @@ | ||||
|         <el-card shadow="hover"> | ||||
|           <el-form ref="queryFormRef" :model="queryParams" :inline="true"> | ||||
|             <el-form-item label="工种" prop="workType"> | ||||
|               <el-select v-model="queryParams.workType" placeholder="请选择工种" clearable > | ||||
|                 <el-option v-for="dict in type_of_work" :key="dict.value" :label="dict.label" :value="dict.value"/> | ||||
|               <el-select v-model="queryParams.workType" placeholder="请选择工种" clearable> | ||||
|                 <el-option v-for="dict in type_of_work" :key="dict.value" :label="dict.label" :value="dict.value" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="工资计算方式" prop="wageCalculationType" label-width="100px"> | ||||
|               <el-select v-model="queryParams.wageCalculationType" placeholder="请选择工资计算方式" clearable > | ||||
|                 <el-option v-for="dict in wageCalculationTypeList" :key="dict.value" :label="dict.label" :value="dict.value"/> | ||||
|               <el-select v-model="queryParams.wageCalculationType" placeholder="请选择工资计算方式" clearable> | ||||
|                 <el-option v-for="dict in wageCalculationTypeList" :key="dict.value" :label="dict.label" :value="dict.value" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="工资计量单位" prop="wageMeasureUnit" label-width="100px"> | ||||
|               <el-select v-model="queryParams.wageMeasureUnit" placeholder="请选择工资计量单位" clearable > | ||||
|                 <el-option v-for="dict in wage_measure_unit_type" :key="dict.value" :label="dict.label" :value="dict.value"/> | ||||
|               <el-select v-model="queryParams.wageMeasureUnit" placeholder="请选择工资计量单位" clearable> | ||||
|                 <el-option v-for="dict in wage_measure_unit_type" :key="dict.value" :label="dict.label" :value="dict.value" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item> | ||||
| @ -32,16 +32,20 @@ | ||||
|       <template #header> | ||||
|         <el-row :gutter="10" class="mb8"> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['project:workWage:add']">新增</el-button> | ||||
|             <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['project:workWage:add']">新增 </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['project:workWage:edit']">修改</el-button> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['project:workWage:edit']" | ||||
|               >修改 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['project:workWage:remove']">删除</el-button> | ||||
|             <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['project:workWage:remove']" | ||||
|               >删除 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['project:workWage:export']">导出</el-button> | ||||
|             <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['project:workWage:export']">导出 </el-button> | ||||
|           </el-col> | ||||
|           <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | ||||
|         </el-row> | ||||
| @ -49,28 +53,28 @@ | ||||
|  | ||||
|       <el-table v-loading="loading" :data="workWageList" @selection-change="handleSelectionChange"> | ||||
|         <el-table-column type="selection" width="55" align="center" /> | ||||
|         <el-table-column label="序号" align="center" type="index" width="60px"/> | ||||
|         <el-table-column label="序号" align="center" type="index" width="60px" /> | ||||
|         <!-- <el-table-column label="主键id" align="center" prop="id" v-if="true" /> --> | ||||
|         <!-- <el-table-column label="项目id" align="center" prop="projectId" /> --> | ||||
|         <el-table-column label="工种" align="center" prop="workType"> | ||||
|           <template #default="scope"> | ||||
|             <dict-tag :options="type_of_work" :value="scope.row.workType"/> | ||||
|             <dict-tag :options="type_of_work" :value="scope.row.workType" /> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="是否是特种兵" align="center" prop="isSpecialType" > | ||||
|         <el-table-column label="是否是特种兵" align="center" prop="isSpecialType"> | ||||
|           <template #default="scope"> | ||||
|             {{ scope.row.isSpecialType==1?'是':"否" }} | ||||
|             {{ scope.row.isSpecialType == 1 ? '是' : '否' }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="工资计算方式" align="center" prop="wageCalculationType" > | ||||
|         <el-table-column label="工资计算方式" align="center" prop="wageCalculationType"> | ||||
|           <template #default="scope"> | ||||
|             {{ scope.row.wageCalculationType==1?'计时':"计件" }} | ||||
|             {{ scope.row.wageCalculationType == 1 ? '计时' : '计件' }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="工资标准" align="center" prop="wage" /> | ||||
|         <el-table-column label="工资计量单位" align="center" prop="wageMeasureUnit"> | ||||
|           <template #default="scope"> | ||||
|             <dict-tag :options="wage_measure_unit_type" :value="scope.row.wageMeasureUnit"/> | ||||
|             <dict-tag :options="wage_measure_unit_type" :value="scope.row.wageMeasureUnit" /> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="创建时间" align="center" prop="createTime" /> | ||||
| @ -97,32 +101,17 @@ | ||||
|         </el-form-item> --> | ||||
|         <el-form-item label="工种" prop="workType"> | ||||
|           <el-select v-model="form.workType" placeholder="请选择工种"> | ||||
|             <el-option | ||||
|                 v-for="dict in type_of_work" | ||||
|                 :key="dict.value" | ||||
|                 :label="dict.label" | ||||
|                 :value="dict.value" | ||||
|             ></el-option> | ||||
|             <el-option v-for="dict in type_of_work" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="是否是特种兵 " prop="isSpecialType"> | ||||
|           <el-select v-model="form.isSpecialType" placeholder="请选择是否是特种兵"> | ||||
|             <el-option | ||||
|                 v-for="dict in isSpecialTypeList" | ||||
|                 :key="dict.value" | ||||
|                 :label="dict.label" | ||||
|                 :value="dict.value" | ||||
|             ></el-option> | ||||
|             <el-option v-for="dict in isSpecialTypeList" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="工资计算方式" prop="wageCalculationType"> | ||||
|           <el-select v-model="form.wageCalculationType" placeholder="请选择工资计算方式"> | ||||
|             <el-option | ||||
|                 v-for="dict in wageCalculationTypeList" | ||||
|                 :key="dict.value" | ||||
|                 :label="dict.label" | ||||
|                 :value="dict.value" | ||||
|             ></el-option> | ||||
|             <el-option v-for="dict in wageCalculationTypeList" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="工资标准" prop="wage"> | ||||
| @ -130,16 +119,11 @@ | ||||
|         </el-form-item> | ||||
|         <el-form-item label="工资计量单位" prop="wageMeasureUnit"> | ||||
|           <el-select v-model="form.wageMeasureUnit" placeholder="请选择工资计量单位"> | ||||
|             <el-option | ||||
|                 v-for="dict in wage_measure_unit_type" | ||||
|                 :key="dict.value" | ||||
|                 :label="dict.label" | ||||
|                 :value="dict.value" | ||||
|             ></el-option> | ||||
|             <el-option v-for="dict in wage_measure_unit_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="备注" prop="remark"> | ||||
|             <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> | ||||
|           <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|       <template #footer> | ||||
| @ -154,8 +138,9 @@ | ||||
|  | ||||
| <script setup name="WorkWage" lang="ts"> | ||||
| import { listWorkWage, getWorkWage, delWorkWage, addWorkWage, updateWorkWage } from '@/api/project/workWage'; | ||||
| import { WorkWageVO, WorkWageQuery, WorkWageForm,SpecialType } from '@/api/project/workWage/types'; | ||||
| import { WorkWageVO, WorkWageQuery, WorkWageForm, SpecialType } from '@/api/project/workWage/types'; | ||||
| import { useUserStoreHook } from '@/store/modules/user'; | ||||
|  | ||||
| const { proxy } = getCurrentInstance() as ComponentInternalInstance; | ||||
| const { type_of_work, wage_measure_unit_type } = toRefs<any>(proxy?.useDict('type_of_work', 'wage_measure_unit_type')); | ||||
| console.log(type_of_work); | ||||
| @ -175,15 +160,15 @@ const total = ref(0); | ||||
|  | ||||
| const queryFormRef = ref<ElFormInstance>(); | ||||
| const workWageFormRef = ref<ElFormInstance>(); | ||||
| const isSpecialTypeList=ref<Array<SpecialType>>([ | ||||
|   {label:"是",value:"1"}, | ||||
|   {label:"否",value:"2"} | ||||
| ]) | ||||
| const isSpecialTypeList = ref<Array<SpecialType>>([ | ||||
|   { label: '是', value: '1' }, | ||||
|   { label: '否', value: '2' } | ||||
| ]); | ||||
|  | ||||
| const wageCalculationTypeList=ref<Array<SpecialType>>([ | ||||
|   {label:"计时",value:"1"}, | ||||
|   {label:"计件",value:"2"} | ||||
| ]) | ||||
| const wageCalculationTypeList = ref<Array<SpecialType>>([ | ||||
|   { label: '计时', value: '1' }, | ||||
|   { label: '计件', value: '2' } | ||||
| ]); | ||||
| const dialog = reactive<DialogOption>({ | ||||
|   visible: false, | ||||
|   title: '' | ||||
| @ -197,10 +182,10 @@ const initFormData: WorkWageForm = { | ||||
|   wageCalculationType: undefined, | ||||
|   wage: undefined, | ||||
|   wageMeasureUnit: undefined, | ||||
|   remark: undefined, | ||||
| } | ||||
|   remark: undefined | ||||
| }; | ||||
| const data = reactive<PageData<WorkWageForm, WorkWageQuery>>({ | ||||
|   form: {...initFormData}, | ||||
|   form: { ...initFormData }, | ||||
|   queryParams: { | ||||
|     pageNum: 1, | ||||
|     pageSize: 10, | ||||
| @ -210,13 +195,10 @@ const data = reactive<PageData<WorkWageForm, WorkWageQuery>>({ | ||||
|     wageCalculationType: undefined, | ||||
|     wage: undefined, | ||||
|     wageMeasureUnit: undefined, | ||||
|     params: { | ||||
|     } | ||||
|     params: {} | ||||
|   }, | ||||
|   rules: { | ||||
|     id: [ | ||||
|       { required: true, message: "主键id不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }] | ||||
|   } | ||||
| }); | ||||
|  | ||||
| @ -229,55 +211,55 @@ const getList = async () => { | ||||
|   workWageList.value = res.rows; | ||||
|   total.value = res.total; | ||||
|   loading.value = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 取消按钮 */ | ||||
| const cancel = () => { | ||||
|   reset(); | ||||
|   dialog.visible = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 表单重置 */ | ||||
| const reset = () => { | ||||
|   form.value = {...initFormData}; | ||||
|   form.value = { ...initFormData }; | ||||
|   workWageFormRef.value?.resetFields(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 搜索按钮操作 */ | ||||
| const handleQuery = () => { | ||||
|   queryParams.value.pageNum = 1; | ||||
|   getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 重置按钮操作 */ | ||||
| const resetQuery = () => { | ||||
|   queryFormRef.value?.resetFields(); | ||||
|   handleQuery(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 多选框选中数据 */ | ||||
| const handleSelectionChange = (selection: WorkWageVO[]) => { | ||||
|   ids.value = selection.map(item => item.id); | ||||
|   ids.value = selection.map((item) => item.id); | ||||
|   single.value = selection.length != 1; | ||||
|   multiple.value = !selection.length; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 新增按钮操作 */ | ||||
| const handleAdd = () => { | ||||
|   reset(); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "添加工种薪水"; | ||||
| } | ||||
|   dialog.title = '添加工种薪水'; | ||||
| }; | ||||
|  | ||||
| /** 修改按钮操作 */ | ||||
| const handleUpdate = async (row?: WorkWageVO) => { | ||||
|   reset(); | ||||
|   const _id = row?.id || ids.value[0] | ||||
|   const _id = row?.id || ids.value[0]; | ||||
|   const res = await getWorkWage(_id); | ||||
|   Object.assign(form.value, res.data); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "修改工种薪水"; | ||||
| } | ||||
|   dialog.title = '修改工种薪水'; | ||||
| }; | ||||
|  | ||||
| /** 提交按钮 */ | ||||
| const submitForm = () => { | ||||
| @ -285,32 +267,36 @@ const submitForm = () => { | ||||
|     if (valid) { | ||||
|       buttonLoading.value = true; | ||||
|       if (form.value.id) { | ||||
|         await updateWorkWage(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await updateWorkWage(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } else { | ||||
|         await addWorkWage(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await addWorkWage(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } | ||||
|       proxy?.$modal.msgSuccess("操作成功"); | ||||
|       proxy?.$modal.msgSuccess('操作成功'); | ||||
|       dialog.visible = false; | ||||
|       await getList(); | ||||
|     } | ||||
|   }); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 删除按钮操作 */ | ||||
| const handleDelete = async (row?: WorkWageVO) => { | ||||
|   const _ids = row?.id || ids.value; | ||||
|   await proxy?.$modal.confirm('是否确认删除工种薪水编号为"' + _ids + '"的数据项?').finally(() => loading.value = false); | ||||
|   await proxy?.$modal.confirm('是否确认删除工种薪水编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false)); | ||||
|   await delWorkWage(_ids); | ||||
|   proxy?.$modal.msgSuccess("删除成功"); | ||||
|   proxy?.$modal.msgSuccess('删除成功'); | ||||
|   await getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 导出按钮操作 */ | ||||
| const handleExport = () => { | ||||
|   proxy?.download('project/workWage/export', { | ||||
|     ...queryParams.value | ||||
|   }, `workWage_${new Date().getTime()}.xlsx`) | ||||
| } | ||||
|   proxy?.download( | ||||
|     'project/workWage/export', | ||||
|     { | ||||
|       ...queryParams.value | ||||
|     }, | ||||
|     `workWage_${new Date().getTime()}.xlsx` | ||||
|   ); | ||||
| }; | ||||
|  | ||||
| onMounted(() => { | ||||
|   getList(); | ||||
|  | ||||
| @ -5,13 +5,13 @@ | ||||
|         <el-card shadow="hover"> | ||||
|           <el-form ref="queryFormRef" :model="queryParams" :inline="true"> | ||||
|             <el-form-item label="题目类别" prop="categoryType"> | ||||
|               <el-select v-model="queryParams.categoryType" placeholder="请选择题目类别" clearable > | ||||
|                 <el-option v-for="dict in safety_question_category_type" :key="dict.value" :label="dict.label" :value="dict.value"/> | ||||
|               <el-select v-model="queryParams.categoryType" placeholder="请选择题目类别" clearable> | ||||
|                 <el-option v-for="dict in safety_question_category_type" :key="dict.value" :label="dict.label" :value="dict.value" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="题目类型" prop="questionType"> | ||||
|               <el-select v-model="queryParams.questionType" placeholder="请选择题目类型" clearable > | ||||
|                 <el-option v-for="dict in safety_question_type" :key="dict.value" :label="dict.label" :value="dict.value"/> | ||||
|               <el-select v-model="queryParams.questionType" placeholder="请选择题目类型" clearable> | ||||
|                 <el-option v-for="dict in safety_question_type" :key="dict.value" :label="dict.label" :value="dict.value" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="题目内容" prop="questionContent"> | ||||
| @ -36,16 +36,20 @@ | ||||
|       <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:questionBank:add']">新增</el-button> | ||||
|             <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionBank:add']"> 新增 </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionBank:edit']">修改</el-button> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionBank:edit']" | ||||
|               >修改 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionBank:remove']">删除</el-button> | ||||
|             <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionBank:remove']" | ||||
|               >删除 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionBank:export']">导出</el-button> | ||||
|             <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionBank:export']">导出 </el-button> | ||||
|           </el-col> | ||||
|           <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | ||||
|         </el-row> | ||||
| @ -56,12 +60,12 @@ | ||||
|         <el-table-column label="主键id" align="center" prop="id" v-if="true" /> | ||||
|         <el-table-column label="题目类别" align="center" prop="categoryType"> | ||||
|           <template #default="scope"> | ||||
|             <dict-tag :options="safety_question_category_type" :value="scope.row.categoryType"/> | ||||
|             <dict-tag :options="safety_question_category_type" :value="scope.row.categoryType" /> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="题目类型" align="center" prop="questionType"> | ||||
|           <template #default="scope"> | ||||
|             <dict-tag :options="safety_question_type" :value="scope.row.questionType"/> | ||||
|             <dict-tag :options="safety_question_type" :value="scope.row.questionType" /> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="题目内容" align="center" prop="questionContent" /> | ||||
| @ -86,29 +90,19 @@ | ||||
|       <el-form ref="questionBankFormRef" :model="form" :rules="rules" label-width="80px"> | ||||
|         <el-form-item label="题目类别" prop="categoryType"> | ||||
|           <el-select v-model="form.categoryType" placeholder="请选择题目类别"> | ||||
|             <el-option | ||||
|                 v-for="dict in safety_question_category_type" | ||||
|                 :key="dict.value" | ||||
|                 :label="dict.label" | ||||
|                 :value="dict.value" | ||||
|             ></el-option> | ||||
|             <el-option v-for="dict in safety_question_category_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="题目类型" prop="questionType"> | ||||
|           <el-select v-model="form.questionType" placeholder="请选择题目类型"> | ||||
|             <el-option | ||||
|                 v-for="dict in safety_question_type" | ||||
|                 :key="dict.value" | ||||
|                 :label="dict.label" | ||||
|                 :value="dict.value" | ||||
|             ></el-option> | ||||
|             <el-option v-for="dict in safety_question_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="题目内容" prop="questionContent"> | ||||
|           <el-input v-model="form.questionContent" placeholder="请输入题目内容" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="选项" prop="options"> | ||||
|             <el-input v-model="form.options" type="textarea" placeholder="请输入内容" /> | ||||
|           <el-input v-model="form.options" type="textarea" placeholder="请输入内容" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="正确答案" prop="correctAnswer"> | ||||
|           <el-input v-model="form.correctAnswer" placeholder="请输入正确答案" /> | ||||
| @ -125,12 +119,16 @@ | ||||
| </template> | ||||
|  | ||||
| <script setup name="QuestionBank" lang="ts"> | ||||
| import { listQuestionBank, getQuestionBank, delQuestionBank, addQuestionBank, updateQuestionBank } from '@/api/safety/questionBank'; | ||||
| import { QuestionBankVO, QuestionBankQuery, QuestionBankForm } from '@/api/safety/questionBank/types'; | ||||
| import { addQuestionBank, delQuestionBank, getQuestionBank, listQuestionBank, updateQuestionBank } from '@/api/safety/questionBank'; | ||||
| import { QuestionBankForm, QuestionBankQuery, QuestionBankVO } from '@/api/safety/questionBank/types'; | ||||
| import { useUserStoreHook } from '@/store/modules/user'; | ||||
|  | ||||
| const { proxy } = getCurrentInstance() as ComponentInternalInstance; | ||||
| const { safety_question_type, safety_question_category_type } = toRefs<any>(proxy?.useDict('safety_question_type', 'safety_question_category_type')); | ||||
|  | ||||
| // 获取用户 store | ||||
| const userStore = useUserStoreHook(); | ||||
| // 从 store 中获取项目列表和当前选中的项目 | ||||
| const currentProject = computed(() => userStore.selectedProject); | ||||
| const questionBankList = ref<QuestionBankVO[]>([]); | ||||
| const buttonLoading = ref(false); | ||||
| const loading = ref(true); | ||||
| @ -154,10 +152,10 @@ const initFormData: QuestionBankForm = { | ||||
|   questionType: undefined, | ||||
|   questionContent: undefined, | ||||
|   options: undefined, | ||||
|   correctAnswer: undefined, | ||||
| } | ||||
|   correctAnswer: undefined | ||||
| }; | ||||
| const data = reactive<PageData<QuestionBankForm, QuestionBankQuery>>({ | ||||
|   form: {...initFormData}, | ||||
|   form: { ...initFormData }, | ||||
|   queryParams: { | ||||
|     pageNum: 1, | ||||
|     pageSize: 10, | ||||
| @ -166,28 +164,15 @@ const data = reactive<PageData<QuestionBankForm, QuestionBankQuery>>({ | ||||
|     questionContent: undefined, | ||||
|     options: undefined, | ||||
|     correctAnswer: undefined, | ||||
|     params: { | ||||
|     } | ||||
|     params: {} | ||||
|   }, | ||||
|   rules: { | ||||
|     id: [ | ||||
|       { required: true, message: "主键id不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     categoryType: [ | ||||
|       { required: true, message: "题目类别不能为空", trigger: "change" } | ||||
|     ], | ||||
|     questionType: [ | ||||
|       { required: true, message: "题目类型不能为空", trigger: "change" } | ||||
|     ], | ||||
|     questionContent: [ | ||||
|       { required: true, message: "题目内容不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     options: [ | ||||
|       { required: true, message: "选项不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     correctAnswer: [ | ||||
|       { required: true, message: "正确答案不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }], | ||||
|     categoryType: [{ required: true, message: '题目类别不能为空', trigger: 'change' }], | ||||
|     questionType: [{ required: true, message: '题目类型不能为空', trigger: 'change' }], | ||||
|     questionContent: [{ required: true, message: '题目内容不能为空', trigger: 'blur' }], | ||||
|     options: [{ required: true, message: '选项不能为空', trigger: 'blur' }], | ||||
|     correctAnswer: [{ required: true, message: '正确答案不能为空', trigger: 'blur' }] | ||||
|   } | ||||
| }); | ||||
|  | ||||
| @ -200,55 +185,55 @@ const getList = async () => { | ||||
|   questionBankList.value = res.rows; | ||||
|   total.value = res.total; | ||||
|   loading.value = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 取消按钮 */ | ||||
| const cancel = () => { | ||||
|   reset(); | ||||
|   dialog.visible = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 表单重置 */ | ||||
| const reset = () => { | ||||
|   form.value = {...initFormData}; | ||||
|   form.value = { ...initFormData }; | ||||
|   questionBankFormRef.value?.resetFields(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 搜索按钮操作 */ | ||||
| const handleQuery = () => { | ||||
|   queryParams.value.pageNum = 1; | ||||
|   getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 重置按钮操作 */ | ||||
| const resetQuery = () => { | ||||
|   queryFormRef.value?.resetFields(); | ||||
|   handleQuery(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 多选框选中数据 */ | ||||
| const handleSelectionChange = (selection: QuestionBankVO[]) => { | ||||
|   ids.value = selection.map(item => item.id); | ||||
|   ids.value = selection.map((item) => item.id); | ||||
|   single.value = selection.length != 1; | ||||
|   multiple.value = !selection.length; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 新增按钮操作 */ | ||||
| const handleAdd = () => { | ||||
|   reset(); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "添加题库"; | ||||
| } | ||||
|   dialog.title = '添加题库'; | ||||
| }; | ||||
|  | ||||
| /** 修改按钮操作 */ | ||||
| const handleUpdate = async (row?: QuestionBankVO) => { | ||||
|   reset(); | ||||
|   const _id = row?.id || ids.value[0] | ||||
|   const _id = row?.id || ids.value[0]; | ||||
|   const res = await getQuestionBank(_id); | ||||
|   Object.assign(form.value, res.data); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "修改题库"; | ||||
| } | ||||
|   dialog.title = '修改题库'; | ||||
| }; | ||||
|  | ||||
| /** 提交按钮 */ | ||||
| const submitForm = () => { | ||||
| @ -256,32 +241,36 @@ const submitForm = () => { | ||||
|     if (valid) { | ||||
|       buttonLoading.value = true; | ||||
|       if (form.value.id) { | ||||
|         await updateQuestionBank(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await updateQuestionBank(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } else { | ||||
|         await addQuestionBank(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await addQuestionBank(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } | ||||
|       proxy?.$modal.msgSuccess("操作成功"); | ||||
|       proxy?.$modal.msgSuccess('操作成功'); | ||||
|       dialog.visible = false; | ||||
|       await getList(); | ||||
|     } | ||||
|   }); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 删除按钮操作 */ | ||||
| const handleDelete = async (row?: QuestionBankVO) => { | ||||
|   const _ids = row?.id || ids.value; | ||||
|   await proxy?.$modal.confirm('是否确认删除题库编号为"' + _ids + '"的数据项?').finally(() => loading.value = false); | ||||
|   await proxy?.$modal.confirm('是否确认删除题库编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false)); | ||||
|   await delQuestionBank(_ids); | ||||
|   proxy?.$modal.msgSuccess("删除成功"); | ||||
|   proxy?.$modal.msgSuccess('删除成功'); | ||||
|   await getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 导出按钮操作 */ | ||||
| const handleExport = () => { | ||||
|   proxy?.download('safety/questionBank/export', { | ||||
|     ...queryParams.value | ||||
|   }, `questionBank_${new Date().getTime()}.xlsx`) | ||||
| } | ||||
|   proxy?.download( | ||||
|     'safety/questionBank/export', | ||||
|     { | ||||
|       ...queryParams.value | ||||
|     }, | ||||
|     `questionBank_${new Date().getTime()}.xlsx` | ||||
|   ); | ||||
| }; | ||||
|  | ||||
| onMounted(() => { | ||||
|   getList(); | ||||
|  | ||||
| @ -38,16 +38,26 @@ | ||||
|       <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:questionUserAnswer:add']">新增</el-button> | ||||
|             <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionUserAnswer:add']">新增 </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionUserAnswer:edit']">修改</el-button> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionUserAnswer:edit']" | ||||
|               >修改 | ||||
|             </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-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-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionUserAnswer:export']">导出 </el-button> | ||||
|           </el-col> | ||||
|           <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | ||||
|         </el-row> | ||||
| @ -70,7 +80,13 @@ | ||||
|               <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:questionUserAnswer:edit']"></el-button> | ||||
|             </el-tooltip> | ||||
|             <el-tooltip content="删除" placement="top"> | ||||
|               <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:questionUserAnswer:remove']"></el-button> | ||||
|               <el-button | ||||
|                 link | ||||
|                 type="primary" | ||||
|                 icon="Delete" | ||||
|                 @click="handleDelete(scope.row)" | ||||
|                 v-hasPermi="['safety:questionUserAnswer:remove']" | ||||
|               ></el-button> | ||||
|             </el-tooltip> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
| @ -103,7 +119,7 @@ | ||||
|           <el-input v-model="form.pass" placeholder="请输入及格线/总分" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="文件地址" prop="file"> | ||||
|           <file-upload v-model="form.file"/> | ||||
|           <file-upload v-model="form.file" /> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|       <template #footer> | ||||
| @ -117,11 +133,21 @@ | ||||
| </template> | ||||
|  | ||||
| <script setup name="QuestionUserAnswer" lang="ts"> | ||||
| import { listQuestionUserAnswer, getQuestionUserAnswer, delQuestionUserAnswer, addQuestionUserAnswer, updateQuestionUserAnswer } from '@/api/safety/questionUserAnswer'; | ||||
| import { QuestionUserAnswerVO, QuestionUserAnswerQuery, QuestionUserAnswerForm } from '@/api/safety/questionUserAnswer/types'; | ||||
| import { | ||||
|   addQuestionUserAnswer, | ||||
|   delQuestionUserAnswer, | ||||
|   getQuestionUserAnswer, | ||||
|   listQuestionUserAnswer, | ||||
|   updateQuestionUserAnswer | ||||
| } from '@/api/safety/questionUserAnswer'; | ||||
| import { QuestionUserAnswerForm, QuestionUserAnswerQuery, QuestionUserAnswerVO } from '@/api/safety/questionUserAnswer/types'; | ||||
| import { useUserStoreHook } from '@/store/modules/user'; | ||||
|  | ||||
| const { proxy } = getCurrentInstance() as ComponentInternalInstance; | ||||
|  | ||||
| // 获取用户 store | ||||
| const userStore = useUserStoreHook(); | ||||
| // 从 store 中获取项目列表和当前选中的项目 | ||||
| const currentProject = computed(() => userStore.selectedProject); | ||||
| const questionUserAnswerList = ref<QuestionUserAnswerVO[]>([]); | ||||
| const buttonLoading = ref(false); | ||||
| const loading = ref(true); | ||||
| @ -141,35 +167,32 @@ const dialog = reactive<DialogOption>({ | ||||
|  | ||||
| const initFormData: QuestionUserAnswerForm = { | ||||
|   id: undefined, | ||||
|   projectId: undefined, | ||||
|   projectId: currentProject.value.id, | ||||
|   userId: undefined, | ||||
|   bankId: undefined, | ||||
|   bankIdList: undefined, | ||||
|   answer: undefined, | ||||
|   score: undefined, | ||||
|   takeTime: undefined, | ||||
|   pass: undefined, | ||||
|   file: undefined, | ||||
| } | ||||
|   file: undefined | ||||
| }; | ||||
| const data = reactive<PageData<QuestionUserAnswerForm, QuestionUserAnswerQuery>>({ | ||||
|   form: {...initFormData}, | ||||
|   form: { ...initFormData }, | ||||
|   queryParams: { | ||||
|     pageNum: 1, | ||||
|     pageSize: 10, | ||||
|     projectId: undefined, | ||||
|     projectId: currentProject.value.id, | ||||
|     userId: undefined, | ||||
|     bankId: undefined, | ||||
|     bankIdList: undefined, | ||||
|     answer: undefined, | ||||
|     score: undefined, | ||||
|     takeTime: undefined, | ||||
|     pass: undefined, | ||||
|     file: undefined, | ||||
|     params: { | ||||
|     } | ||||
|     params: {} | ||||
|   }, | ||||
|   rules: { | ||||
|     id: [ | ||||
|       { required: true, message: "主键id不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }] | ||||
|   } | ||||
| }); | ||||
|  | ||||
| @ -182,55 +205,55 @@ const getList = async () => { | ||||
|   questionUserAnswerList.value = res.rows; | ||||
|   total.value = res.total; | ||||
|   loading.value = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 取消按钮 */ | ||||
| const cancel = () => { | ||||
|   reset(); | ||||
|   dialog.visible = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 表单重置 */ | ||||
| const reset = () => { | ||||
|   form.value = {...initFormData}; | ||||
|   form.value = { ...initFormData }; | ||||
|   questionUserAnswerFormRef.value?.resetFields(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 搜索按钮操作 */ | ||||
| const handleQuery = () => { | ||||
|   queryParams.value.pageNum = 1; | ||||
|   getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 重置按钮操作 */ | ||||
| const resetQuery = () => { | ||||
|   queryFormRef.value?.resetFields(); | ||||
|   handleQuery(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 多选框选中数据 */ | ||||
| const handleSelectionChange = (selection: QuestionUserAnswerVO[]) => { | ||||
|   ids.value = selection.map(item => item.id); | ||||
|   ids.value = selection.map((item) => item.id); | ||||
|   single.value = selection.length != 1; | ||||
|   multiple.value = !selection.length; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 新增按钮操作 */ | ||||
| const handleAdd = () => { | ||||
|   reset(); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "添加用户试卷存储"; | ||||
| } | ||||
|   dialog.title = '添加用户试卷存储'; | ||||
| }; | ||||
|  | ||||
| /** 修改按钮操作 */ | ||||
| const handleUpdate = async (row?: QuestionUserAnswerVO) => { | ||||
|   reset(); | ||||
|   const _id = row?.id || ids.value[0] | ||||
|   const _id = row?.id || ids.value[0]; | ||||
|   const res = await getQuestionUserAnswer(_id); | ||||
|   Object.assign(form.value, res.data); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "修改用户试卷存储"; | ||||
| } | ||||
|   dialog.title = '修改用户试卷存储'; | ||||
| }; | ||||
|  | ||||
| /** 提交按钮 */ | ||||
| const submitForm = () => { | ||||
| @ -238,32 +261,36 @@ const submitForm = () => { | ||||
|     if (valid) { | ||||
|       buttonLoading.value = true; | ||||
|       if (form.value.id) { | ||||
|         await updateQuestionUserAnswer(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await updateQuestionUserAnswer(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } else { | ||||
|         await addQuestionUserAnswer(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await addQuestionUserAnswer(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } | ||||
|       proxy?.$modal.msgSuccess("操作成功"); | ||||
|       proxy?.$modal.msgSuccess('操作成功'); | ||||
|       dialog.visible = false; | ||||
|       await getList(); | ||||
|     } | ||||
|   }); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 删除按钮操作 */ | ||||
| const handleDelete = async (row?: QuestionUserAnswerVO) => { | ||||
|   const _ids = row?.id || ids.value; | ||||
|   await proxy?.$modal.confirm('是否确认删除用户试卷存储编号为"' + _ids + '"的数据项?').finally(() => loading.value = false); | ||||
|   await proxy?.$modal.confirm('是否确认删除用户试卷存储编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false)); | ||||
|   await delQuestionUserAnswer(_ids); | ||||
|   proxy?.$modal.msgSuccess("删除成功"); | ||||
|   proxy?.$modal.msgSuccess('删除成功'); | ||||
|   await getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 导出按钮操作 */ | ||||
| const handleExport = () => { | ||||
|   proxy?.download('safety/questionUserAnswer/export', { | ||||
|     ...queryParams.value | ||||
|   }, `questionUserAnswer_${new Date().getTime()}.xlsx`) | ||||
| } | ||||
|   proxy?.download( | ||||
|     'safety/questionUserAnswer/export', | ||||
|     { | ||||
|       ...queryParams.value | ||||
|     }, | ||||
|     `questionUserAnswer_${new Date().getTime()}.xlsx` | ||||
|   ); | ||||
| }; | ||||
|  | ||||
| onMounted(() => { | ||||
|   getList(); | ||||
|  | ||||
| @ -44,16 +44,20 @@ | ||||
|       <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:questionsConfig:add']">新增</el-button> | ||||
|             <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionsConfig:add']"> 新增 </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionsConfig:edit']">修改</el-button> | ||||
|             <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionsConfig:edit']" | ||||
|               >修改 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionsConfig:remove']">删除</el-button> | ||||
|             <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionsConfig:remove']" | ||||
|               >删除 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionsConfig:export']">导出</el-button> | ||||
|             <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionsConfig:export']">导出 </el-button> | ||||
|           </el-col> | ||||
|           <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | ||||
|         </el-row> | ||||
| @ -77,7 +81,13 @@ | ||||
|               <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:questionsConfig:edit']"></el-button> | ||||
|             </el-tooltip> | ||||
|             <el-tooltip content="删除" placement="top"> | ||||
|               <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:questionsConfig:remove']"></el-button> | ||||
|               <el-button | ||||
|                 link | ||||
|                 type="primary" | ||||
|                 icon="Delete" | ||||
|                 @click="handleDelete(scope.row)" | ||||
|                 v-hasPermi="['safety:questionsConfig:remove']" | ||||
|               ></el-button> | ||||
|             </el-tooltip> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
| @ -127,11 +137,15 @@ | ||||
| </template> | ||||
|  | ||||
| <script setup name="QuestionsConfig" lang="ts"> | ||||
| import { listQuestionsConfig, getQuestionsConfig, delQuestionsConfig, addQuestionsConfig, updateQuestionsConfig } from '@/api/safety/questionsConfig'; | ||||
| import { QuestionsConfigVO, QuestionsConfigQuery, QuestionsConfigForm } from '@/api/safety/questionsConfig/types'; | ||||
| import { addQuestionsConfig, delQuestionsConfig, getQuestionsConfig, listQuestionsConfig, updateQuestionsConfig } from '@/api/safety/questionsConfig'; | ||||
| import { QuestionsConfigForm, QuestionsConfigQuery, QuestionsConfigVO } from '@/api/safety/questionsConfig/types'; | ||||
| import { useUserStoreHook } from '@/store/modules/user'; | ||||
|  | ||||
| const { proxy } = getCurrentInstance() as ComponentInternalInstance; | ||||
|  | ||||
| // 获取用户 store | ||||
| const userStore = useUserStoreHook(); | ||||
| // 从 store 中获取项目列表和当前选中的项目 | ||||
| const currentProject = computed(() => userStore.selectedProject); | ||||
| const questionsConfigList = ref<QuestionsConfigVO[]>([]); | ||||
| const buttonLoading = ref(false); | ||||
| const loading = ref(true); | ||||
| @ -151,6 +165,7 @@ const dialog = reactive<DialogOption>({ | ||||
|  | ||||
| const initFormData: QuestionsConfigForm = { | ||||
|   id: undefined, | ||||
|   projectId: currentProject.value.id, | ||||
|   singleChoice: undefined, | ||||
|   singleScore: undefined, | ||||
|   multipleChoice: undefined, | ||||
| @ -160,12 +175,13 @@ const initFormData: QuestionsConfigForm = { | ||||
|   fullMark: undefined, | ||||
|   passScore: undefined, | ||||
|   answerTime: undefined | ||||
| } | ||||
| }; | ||||
| const data = reactive<PageData<QuestionsConfigForm, QuestionsConfigQuery>>({ | ||||
|   form: {...initFormData}, | ||||
|   form: { ...initFormData }, | ||||
|   queryParams: { | ||||
|     pageNum: 1, | ||||
|     pageSize: 10, | ||||
|     projectId: currentProject.value.id, | ||||
|     singleChoice: undefined, | ||||
|     singleScore: undefined, | ||||
|     multipleChoice: undefined, | ||||
| @ -175,40 +191,19 @@ const data = reactive<PageData<QuestionsConfigForm, QuestionsConfigQuery>>({ | ||||
|     fullMark: undefined, | ||||
|     passScore: undefined, | ||||
|     answerTime: undefined, | ||||
|     params: { | ||||
|     } | ||||
|     params: {} | ||||
|   }, | ||||
|   rules: { | ||||
|     id: [ | ||||
|       { required: true, message: "主键id不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     singleChoice: [ | ||||
|       { required: true, message: "单选题不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     singleScore: [ | ||||
|       { required: true, message: "单选分数不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     multipleChoice: [ | ||||
|       { required: true, message: "多选题不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     multipleScore: [ | ||||
|       { required: true, message: "多选分数不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     estimate: [ | ||||
|       { required: true, message: "判断题不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     estimateScore: [ | ||||
|       { required: true, message: "判断分数不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     fullMark: [ | ||||
|       { required: true, message: "满分不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     passScore: [ | ||||
|       { required: true, message: "及格线不能为空", trigger: "blur" } | ||||
|     ], | ||||
|     answerTime: [ | ||||
|       { required: true, message: "答题最大时间不能为空", trigger: "blur" } | ||||
|     ] | ||||
|     id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }], | ||||
|     singleChoice: [{ required: true, message: '单选题不能为空', trigger: 'blur' }], | ||||
|     singleScore: [{ required: true, message: '单选分数不能为空', trigger: 'blur' }], | ||||
|     multipleChoice: [{ required: true, message: '多选题不能为空', trigger: 'blur' }], | ||||
|     multipleScore: [{ required: true, message: '多选分数不能为空', trigger: 'blur' }], | ||||
|     estimate: [{ required: true, message: '判断题不能为空', trigger: 'blur' }], | ||||
|     estimateScore: [{ required: true, message: '判断分数不能为空', trigger: 'blur' }], | ||||
|     fullMark: [{ required: true, message: '满分不能为空', trigger: 'blur' }], | ||||
|     passScore: [{ required: true, message: '及格线不能为空', trigger: 'blur' }], | ||||
|     answerTime: [{ required: true, message: '答题最大时间不能为空', trigger: 'blur' }] | ||||
|   } | ||||
| }); | ||||
|  | ||||
| @ -221,55 +216,55 @@ const getList = async () => { | ||||
|   questionsConfigList.value = res.rows; | ||||
|   total.value = res.total; | ||||
|   loading.value = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 取消按钮 */ | ||||
| const cancel = () => { | ||||
|   reset(); | ||||
|   dialog.visible = false; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 表单重置 */ | ||||
| const reset = () => { | ||||
|   form.value = {...initFormData}; | ||||
|   form.value = { ...initFormData }; | ||||
|   questionsConfigFormRef.value?.resetFields(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 搜索按钮操作 */ | ||||
| const handleQuery = () => { | ||||
|   queryParams.value.pageNum = 1; | ||||
|   getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 重置按钮操作 */ | ||||
| const resetQuery = () => { | ||||
|   queryFormRef.value?.resetFields(); | ||||
|   handleQuery(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 多选框选中数据 */ | ||||
| const handleSelectionChange = (selection: QuestionsConfigVO[]) => { | ||||
|   ids.value = selection.map(item => item.id); | ||||
|   ids.value = selection.map((item) => item.id); | ||||
|   single.value = selection.length != 1; | ||||
|   multiple.value = !selection.length; | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 新增按钮操作 */ | ||||
| const handleAdd = () => { | ||||
|   reset(); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "添加题库配置"; | ||||
| } | ||||
|   dialog.title = '添加题库配置'; | ||||
| }; | ||||
|  | ||||
| /** 修改按钮操作 */ | ||||
| const handleUpdate = async (row?: QuestionsConfigVO) => { | ||||
|   reset(); | ||||
|   const _id = row?.id || ids.value[0] | ||||
|   const _id = row?.id || ids.value[0]; | ||||
|   const res = await getQuestionsConfig(_id); | ||||
|   Object.assign(form.value, res.data); | ||||
|   dialog.visible = true; | ||||
|   dialog.title = "修改题库配置"; | ||||
| } | ||||
|   dialog.title = '修改题库配置'; | ||||
| }; | ||||
|  | ||||
| /** 提交按钮 */ | ||||
| const submitForm = () => { | ||||
| @ -277,32 +272,36 @@ const submitForm = () => { | ||||
|     if (valid) { | ||||
|       buttonLoading.value = true; | ||||
|       if (form.value.id) { | ||||
|         await updateQuestionsConfig(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await updateQuestionsConfig(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } else { | ||||
|         await addQuestionsConfig(form.value).finally(() =>  buttonLoading.value = false); | ||||
|         await addQuestionsConfig(form.value).finally(() => (buttonLoading.value = false)); | ||||
|       } | ||||
|       proxy?.$modal.msgSuccess("操作成功"); | ||||
|       proxy?.$modal.msgSuccess('操作成功'); | ||||
|       dialog.visible = false; | ||||
|       await getList(); | ||||
|     } | ||||
|   }); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 删除按钮操作 */ | ||||
| const handleDelete = async (row?: QuestionsConfigVO) => { | ||||
|   const _ids = row?.id || ids.value; | ||||
|   await proxy?.$modal.confirm('是否确认删除题库配置编号为"' + _ids + '"的数据项?').finally(() => loading.value = false); | ||||
|   await proxy?.$modal.confirm('是否确认删除题库配置编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false)); | ||||
|   await delQuestionsConfig(_ids); | ||||
|   proxy?.$modal.msgSuccess("删除成功"); | ||||
|   proxy?.$modal.msgSuccess('删除成功'); | ||||
|   await getList(); | ||||
| } | ||||
| }; | ||||
|  | ||||
| /** 导出按钮操作 */ | ||||
| const handleExport = () => { | ||||
|   proxy?.download('safety/questionsConfig/export', { | ||||
|     ...queryParams.value | ||||
|   }, `questionsConfig_${new Date().getTime()}.xlsx`) | ||||
| } | ||||
|   proxy?.download( | ||||
|     'safety/questionsConfig/export', | ||||
|     { | ||||
|       ...queryParams.value | ||||
|     }, | ||||
|     `questionsConfig_${new Date().getTime()}.xlsx` | ||||
|   ); | ||||
| }; | ||||
|  | ||||
| onMounted(() => { | ||||
|   getList(); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user