|
|
@@ -40,7 +40,7 @@
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="select-box--item">
|
|
|
- <span>上传日期范围:</span>
|
|
|
+ <span>计划日期范围:</span>
|
|
|
<el-date-picker v-model="uploadDateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
|
|
|
end-placeholder="结束日期" value-format="YYYY-MM-DD" format="YYYY-MM-DD" />
|
|
|
</div>
|
|
|
@@ -55,23 +55,102 @@
|
|
|
<div class="batch-table">
|
|
|
<BasicTable ref="basicTableRef" :tableData="tableData" :tableConfig="tableConfig"
|
|
|
@update:pageSize="handleSizeChange" @update:pageNumber="handleCurrentChange">
|
|
|
- <template #actionContent="scope">
|
|
|
+ <!-- <template #actionContent="scope">
|
|
|
<span class="action-content" @click="activityRegistration(scope.row.id)">
|
|
|
{{ scope.row.actionContent || '-'}}
|
|
|
</span>
|
|
|
- </template>
|
|
|
+ </template> -->
|
|
|
<template #action="scope">
|
|
|
<div class="action-container--div" style="justify-content: left">
|
|
|
- <ActionButton text="编辑" @click="handleEdit(scope.row.id)" />
|
|
|
- <ActionButton text="删除" :popconfirm="{
|
|
|
+ <ActionButton text="编辑" v-if="scope.row.status === 1" @click="handleEdit(scope.row.id)" />
|
|
|
+ <ActionButton text="删除" v-if="scope.row.status === 1" :popconfirm="{
|
|
|
title: '确定要删除?',
|
|
|
}" @confirm="handleDelete(scope.row.id)" />
|
|
|
<ActionButton text="查看" @click="handleView(scope.row.id)" />
|
|
|
+ <ActionButton text="下发" @click="handleDispatch(scope.row.id)" v-if="scope.row.status === 1"/>
|
|
|
+ <ActionButton text="活动报名" @click="activityRegistration(scope.row.id)" v-if="scope.row.status !== 1"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
</BasicTable>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ v-model="showIssueDialog"
|
|
|
+ title="安全文化活动下发"
|
|
|
+ width="500px"
|
|
|
+ destroy-on-close
|
|
|
+ @open="onIssueDialogOpen"
|
|
|
+ >
|
|
|
+ <el-form ref="issueFormRef" :model="issueForm" :rules="issueRules" label-width="140px">
|
|
|
+ <el-form-item label="具体负责人部门" prop="rectificationDepartmentId">
|
|
|
+ <el-cascader
|
|
|
+ v-model="issueForm.rectificationDepartmentId"
|
|
|
+ :options="issueDeptTree"
|
|
|
+ :props="cascaderDeptProp"
|
|
|
+ :show-all-levels="false"
|
|
|
+ placeholder="请选择具体负责人部门"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ style="width: 100%"
|
|
|
+ @change="onIssueDeptChange"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="具体负责人" prop="rectificationResponsibleUserId">
|
|
|
+ <el-select
|
|
|
+ v-model="issueForm.rectificationResponsibleUserId"
|
|
|
+ placeholder="选择具体负责人"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="user in issueUserList"
|
|
|
+ :key="user.id"
|
|
|
+ :label="user.realname ?? user.username"
|
|
|
+ :value="user.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="计划开始日期:" prop="startDate">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="issueForm.startDate"
|
|
|
+ type="date"
|
|
|
+ placeholder="请选择计划开始日期"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ format="YYYY-MM-DD"
|
|
|
+ style="width: 100%"
|
|
|
+ :disabled-date="(date: Date) => {
|
|
|
+ if (issueForm.endDate) {
|
|
|
+ return date > new Date(issueForm.endDate);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="计划结束日期:" prop="endDate">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="issueForm.endDate"
|
|
|
+ type="date"
|
|
|
+ placeholder="请选择计划结束日期"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ format="YYYY-MM-DD"
|
|
|
+ style="width: 100%"
|
|
|
+ :disabled-date="(date: Date) => {
|
|
|
+ if (issueForm.startDate) {
|
|
|
+ return date < new Date(issueForm.startDate);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="showIssueDialog = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="handleIssueSave">保存</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
</main>
|
|
|
<BatchImport v-if="batchImportVisible" :visible="batchImportVisible" :import-api-url="importApiUrl"
|
|
|
:template-url="templateUrl" template-name="下载模板" :show-template="false" @close="batchImportVisible = false"
|
|
|
@@ -91,6 +170,7 @@ import {
|
|
|
safetyCultureActivityManagementFilePage,
|
|
|
deleteSafetyCultureActivityManagement,
|
|
|
getAllDepartments,
|
|
|
+ activityDistribution,
|
|
|
type safetyCultureFileQuery,
|
|
|
type safetyCultureFilePageQuery,
|
|
|
} from '@/api/safety-culture';
|
|
|
@@ -100,10 +180,38 @@ import BatchImport from '@/components/batch-import/BatchImport.vue';
|
|
|
import { useGlobSetting } from '@/hooks/setting';
|
|
|
import urlJoin from 'url-join';
|
|
|
import { http } from '@/utils/http/axios';
|
|
|
-
|
|
|
+import { queryAvailableUserList } from '@/api/production-safety/responsibility-implementation';
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
+/** 下发弹窗:点击下发打开弹窗,弹窗内部门用 queryAllDeptTree、负责人用 queryAvailableUserList,点击保存才触发下发接口 */
|
|
|
+const showIssueDialog = ref(false);
|
|
|
+const distributionId = ref<number>(0);
|
|
|
+const issueFormRef = ref();
|
|
|
+const issueForm = ref({
|
|
|
+ rectificationDepartmentId: undefined as number | undefined,
|
|
|
+ rectificationResponsibleUserId: undefined as number | undefined,
|
|
|
+ rectificationResponsiblePersonName: '' as string,
|
|
|
+ startDate: '' as string,
|
|
|
+ endDate: '' as string,
|
|
|
+});
|
|
|
+const issueRules = {
|
|
|
+ rectificationDepartmentId: [{ required: true, message: '请选择整改责任部门', trigger: 'change' }],
|
|
|
+ rectificationResponsibleUserId: [{ required: true, message: '请选择整改负责人', trigger: 'change' }],
|
|
|
+ startDate: [{ required: true, message: '请选择计划开始日期', trigger: 'change' }],
|
|
|
+ endDate: [{ required: true, message: '请选择计划结束日期', trigger: 'change' }],
|
|
|
+};
|
|
|
+/** 下发弹窗部门树,与新增隐患台账复查人员所属部门一致(getAllDepartments 取第一级 children) */
|
|
|
+const cascaderDeptProp = {
|
|
|
+ checkStrictly: true,
|
|
|
+ expandTrigger: 'hover' as const,
|
|
|
+ value: 'id',
|
|
|
+ label: 'deptName',
|
|
|
+ emitPath: false,
|
|
|
+};
|
|
|
+const issueDeptTree = ref<DeptTree[]>([]);
|
|
|
+const issueUserList = ref<Array<{ id: number; realname?: string; username?: string }>>([]);
|
|
|
+
|
|
|
// 表格
|
|
|
const basicTableRef = ref<InstanceType<typeof BasicTable>>();
|
|
|
|
|
|
@@ -388,6 +496,77 @@ const activityRegistration = async (id: number) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+const onIssueDialogOpen = async () => {
|
|
|
+ try {
|
|
|
+ const [deptRes, userRes] = await Promise.all([
|
|
|
+ getAllDepartments(),
|
|
|
+ queryAvailableUserList({ pageNumber: 1, pageSize: 9999, queryParam: {} }),
|
|
|
+ ]);
|
|
|
+ const fullTree = (deptRes as DeptTree[]) ?? [];
|
|
|
+ issueDeptTree.value = Array.isArray(fullTree) && fullTree[0]?.children ? fullTree[0].children : [];
|
|
|
+ issueUserList.value = (userRes as any)?.records ?? [];
|
|
|
+ } catch (e) {
|
|
|
+ console.error('获取部门/用户列表失败:', e);
|
|
|
+ ElMessage.error(e?.message || e?.data || '加载部门或负责人列表失败');
|
|
|
+ issueDeptTree.value = [];
|
|
|
+ issueUserList.value = [];
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const onIssueDeptChange = () => {
|
|
|
+ issueForm.value.rectificationResponsibleUserId = undefined;
|
|
|
+ issueForm.value.rectificationResponsiblePersonName = '';
|
|
|
+};
|
|
|
+
|
|
|
+const handleDispatch = (id: number) => {
|
|
|
+ distributionId.value = id;
|
|
|
+ showIssueDialog.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+/** 从部门树中根据 id 查找部门名称 */
|
|
|
+function findDeptNameById(nodes: DeptTree[] | undefined, id: number): string {
|
|
|
+ if (!nodes?.length) return '';
|
|
|
+ for (const n of nodes) {
|
|
|
+ if (n.id === id) return n.deptName ?? '';
|
|
|
+ if (n.children?.length) {
|
|
|
+ const found = findDeptNameById(n.children, id);
|
|
|
+ if (found) return found;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+};
|
|
|
+
|
|
|
+const handleIssueSave = async () => {
|
|
|
+ await issueFormRef.value?.validate?.().catch(() => {});
|
|
|
+ const { rectificationDepartmentId, rectificationResponsibleUserId } = issueForm.value;
|
|
|
+ if (rectificationDepartmentId == null || rectificationResponsibleUserId == null) {
|
|
|
+ ElMessage.warning('请选择整改责任部门和整改负责人');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!issueForm.value.startDate || !issueForm.value.endDate) {
|
|
|
+ ElMessage.warning('请选择计划开始日期和计划结束日期');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const selectedUser = issueUserList.value.find((u) => u.id === rectificationResponsibleUserId);
|
|
|
+ const personName = selectedUser?.realname ?? selectedUser?.username ?? '';
|
|
|
+ const deptName = findDeptNameById(issueDeptTree.value, rectificationDepartmentId);
|
|
|
+ try {
|
|
|
+ await activityDistribution({
|
|
|
+ id: distributionId.value,
|
|
|
+ specificDeptId: String(rectificationDepartmentId),
|
|
|
+ specificPersonId: String(rectificationResponsibleUserId),
|
|
|
+ startTime: issueForm.value.startDate,
|
|
|
+ endTime: issueForm.value.endDate,
|
|
|
+ });
|
|
|
+ ElMessage.success('下发成功');
|
|
|
+ showIssueDialog.value = false;
|
|
|
+ getTableData();
|
|
|
+ } catch (e) {
|
|
|
+ console.error('下发失败:', e);
|
|
|
+ ElMessage.error(e?.message || e?.data || '下发失败,请重试');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
loadDeptNameMap().finally(() => {
|
|
|
getTableData();
|