|
@@ -6,7 +6,13 @@
|
|
|
<main class="disaster-precaution-container__main">
|
|
<main class="disaster-precaution-container__main">
|
|
|
<div class="disaster-precaution">
|
|
<div class="disaster-precaution">
|
|
|
<header class="disaster-precaution__header">
|
|
<header class="disaster-precaution__header">
|
|
|
- <el-button type="primary" class="disaster-precaution__header--button" :icon="Plus" @click="handleCreateTask">
|
|
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ class="disaster-precaution__header--button"
|
|
|
|
|
+ :icon="Plus"
|
|
|
|
|
+ @click="handleCreateTask"
|
|
|
|
|
+ v-if="taskManagementPermissions"
|
|
|
|
|
+ >
|
|
|
创建检查任务单
|
|
创建检查任务单
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<Search
|
|
<Search
|
|
@@ -14,12 +20,12 @@
|
|
|
:searchData="searchData"
|
|
:searchData="searchData"
|
|
|
@update:searchData="handleSearch"
|
|
@update:searchData="handleSearch"
|
|
|
/>
|
|
/>
|
|
|
- <div class="batch-operation--div fadeIn" v-show="selectionItems.length > 0">
|
|
|
|
|
|
|
+ <div class="batch-operation--div fadeIn" v-show="selectionItems.length > 0 && taskManagementPermissions">
|
|
|
<span>已选{{ selectionItems.length }}项</span>
|
|
<span>已选{{ selectionItems.length }}项</span>
|
|
|
<div class="batch-operation--div--button">
|
|
<div class="batch-operation--div--button">
|
|
|
- <el-button type="success" v-show="isBatchPublish" @click="handleBatchPublish">批量发布</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" v-show="isBatchPublish" @click="handleBatchPublish">批量发布</el-button>
|
|
|
<el-button type="primary" v-show="isBatchWithdraw" @click="handleBatchWithdraw">批量撤回</el-button>
|
|
<el-button type="primary" v-show="isBatchWithdraw" @click="handleBatchWithdraw">批量撤回</el-button>
|
|
|
- <el-button type="danger" @click="handleBatchDelete">批量删除</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" v-show="isBatchDelete" @click="handleBatchDelete">批量删除</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</header>
|
|
</header>
|
|
@@ -33,31 +39,31 @@
|
|
|
>
|
|
>
|
|
|
<template #taskName="scope">
|
|
<template #taskName="scope">
|
|
|
<div class="task-name--div">
|
|
<div class="task-name--div">
|
|
|
- <el-tooltip :content="scope.row.taskName" placement="top" effect="light">
|
|
|
|
|
- <span>{{ scope.row.taskName }}</span>
|
|
|
|
|
|
|
+ <el-tooltip :content="scope.row.name" placement="top" effect="light">
|
|
|
|
|
+ <span>{{ scope.row.name }}</span>
|
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
|
- <img :src="OverdueIcon" alt="overdue" v-if="scope.row.isOverdue === OVERDUE_STATUS.OVERDUE" />
|
|
|
|
|
|
|
+ <img :src="OverdueIcon" alt="overdue" v-if="scope.row.overdue" />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
- <template #taskType="scope">
|
|
|
|
|
- <span>{{ TASK_TYPE_MAP[scope.row.taskType] }}</span>
|
|
|
|
|
|
|
+ <template #inspectType="scope">
|
|
|
|
|
+ <span>{{ INSPECT_TYPE_MAP[scope.row.inspectType] }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
- <template #activeStatus="scope">
|
|
|
|
|
|
|
+ <template #effectStatus="scope">
|
|
|
<div class="active-status--div">
|
|
<div class="active-status--div">
|
|
|
<div
|
|
<div
|
|
|
class="dot"
|
|
class="dot"
|
|
|
- :style="{ backgroundColor: ACTIVE_STATUS_COLOR[scope.row.activeStatus as ACTIVE_STATUS] }"
|
|
|
|
|
|
|
+ :style="{ backgroundColor: ACTIVE_STATUS_COLOR[scope.row.effectStatus as ACTIVE_STATUS] }"
|
|
|
></div>
|
|
></div>
|
|
|
- <span>{{ ACTIVE_STATUS_MAP[scope.row.activeStatus] }}</span>
|
|
|
|
|
|
|
+ <span>{{ ACTIVE_STATUS_MAP[scope.row.effectStatus] }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<template #taskStage="scope">
|
|
<template #taskStage="scope">
|
|
|
- <span>{{ TASK_STAGE_MAP[scope.row.taskStage] }}</span>
|
|
|
|
|
|
|
+ <span>{{ TASK_STAGE_MAP[scope.row.taskState] }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template #action="scope">
|
|
<template #action="scope">
|
|
|
<ActionButton
|
|
<ActionButton
|
|
|
text="编辑"
|
|
text="编辑"
|
|
|
- v-if="scope.row.activeStatus === ACTIVE_STATUS.NOT_EFFECTIVE"
|
|
|
|
|
|
|
+ v-if="scope.row.effectStatus === ACTIVE_STATUS.NOT_EFFECTIVE && taskManagementPermissions"
|
|
|
@click="handleEditTask(scope.row.id)"
|
|
@click="handleEditTask(scope.row.id)"
|
|
|
/>
|
|
/>
|
|
|
<ActionButton text="查看" @click="handleViewTask(scope.row.id)" />
|
|
<ActionButton text="查看" @click="handleViewTask(scope.row.id)" />
|
|
@@ -66,21 +72,24 @@
|
|
|
:popconfirm="{
|
|
:popconfirm="{
|
|
|
title: '确定要发布?',
|
|
title: '确定要发布?',
|
|
|
}"
|
|
}"
|
|
|
- v-if="scope.row.activeStatus === ACTIVE_STATUS.NOT_EFFECTIVE"
|
|
|
|
|
|
|
+ v-if="scope.row.effectStatus === ACTIVE_STATUS.NOT_EFFECTIVE && taskManagementPermissions"
|
|
|
|
|
+ @confirm="handlePublishTask(scope.row.id)"
|
|
|
/>
|
|
/>
|
|
|
<ActionButton
|
|
<ActionButton
|
|
|
text="撤回"
|
|
text="撤回"
|
|
|
:popconfirm="{
|
|
:popconfirm="{
|
|
|
title: '确定要撤回?',
|
|
title: '确定要撤回?',
|
|
|
}"
|
|
}"
|
|
|
- v-else-if="scope.row.activeStatus === ACTIVE_STATUS.ACTIVE"
|
|
|
|
|
|
|
+ v-else-if="scope.row.effectStatus === ACTIVE_STATUS.ACTIVE && taskManagementPermissions"
|
|
|
|
|
+ @confirm="handleWithdrawTask(scope.row.id)"
|
|
|
/>
|
|
/>
|
|
|
<ActionButton
|
|
<ActionButton
|
|
|
text="删除"
|
|
text="删除"
|
|
|
:popconfirm="{
|
|
:popconfirm="{
|
|
|
title: '确定要删除?',
|
|
title: '确定要删除?',
|
|
|
}"
|
|
}"
|
|
|
- v-if="scope.row.activeStatus === ACTIVE_STATUS.NOT_EFFECTIVE"
|
|
|
|
|
|
|
+ v-if="scope.row.effectStatus === ACTIVE_STATUS.NOT_EFFECTIVE && taskManagementPermissions"
|
|
|
|
|
+ @confirm="handleDeleteTask(scope.row.id)"
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
</BasicTable>
|
|
</BasicTable>
|
|
@@ -96,11 +105,16 @@
|
|
|
import ActionButton from '@/components/ActionButton.vue';
|
|
import ActionButton from '@/components/ActionButton.vue';
|
|
|
import Search from '@/views/disaster/components/Search.vue';
|
|
import Search from '@/views/disaster/components/Search.vue';
|
|
|
import useTableConfig from '@/hooks/useTableConfigHook';
|
|
import useTableConfig from '@/hooks/useTableConfigHook';
|
|
|
- import { getTaskManagementListData } from '@/api/disaster-precaution';
|
|
|
|
|
- import type { TaskManagementListResponse } from '@/types/disaster-precaution';
|
|
|
|
|
|
|
+ import {
|
|
|
|
|
+ getTaskManagementList,
|
|
|
|
|
+ deleteTaskManagementItem,
|
|
|
|
|
+ withdrawTaskManagementItem,
|
|
|
|
|
+ publishTaskManagementItem,
|
|
|
|
|
+ } from '@/api/disaster-precaution';
|
|
|
|
|
+ import type { TaskManagementListQuery, TaskManagementListResponse } from '@/types/disaster-precaution';
|
|
|
import OverdueIcon from '@/assets/svg/overdue.svg';
|
|
import OverdueIcon from '@/assets/svg/overdue.svg';
|
|
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
|
|
- import { OVERDUE_STATUS, TASK_TYPE_MAP, TASK_STAGE_MAP } from './src/constants/task-execution';
|
|
|
|
|
|
|
+ import { INSPECT_TYPE_MAP, TASK_STAGE_MAP } from './src/constants/task-execution';
|
|
|
import { ACTIVE_STATUS, ACTIVE_STATUS_COLOR, ACTIVE_STATUS_MAP } from '@/views/disaster/constant';
|
|
import { ACTIVE_STATUS, ACTIVE_STATUS_COLOR, ACTIVE_STATUS_MAP } from '@/views/disaster/constant';
|
|
|
import {
|
|
import {
|
|
|
TABLE_OPTIONS_MANAGEMENT,
|
|
TABLE_OPTIONS_MANAGEMENT,
|
|
@@ -108,23 +122,46 @@
|
|
|
TASK_MANAGEMENT_SEARCH_CONFIG,
|
|
TASK_MANAGEMENT_SEARCH_CONFIG,
|
|
|
TABLE_MANAGEMENT_HEIGHT_DEFAULT,
|
|
TABLE_MANAGEMENT_HEIGHT_DEFAULT,
|
|
|
TABLE_MANAGEMENT_HEIGHT_BATCH_OPERATION,
|
|
TABLE_MANAGEMENT_HEIGHT_BATCH_OPERATION,
|
|
|
|
|
+ TABLE_MANAGEMENT_HEIGHT_NOT_PERMISSION,
|
|
|
} from './src/config';
|
|
} from './src/config';
|
|
|
import { useRouter } from 'vue-router';
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
+ import type { QueryPageRequest } from '@/types/disaster';
|
|
|
|
|
+ import { DISASTER_PERMISSIONS } from '@/views/disaster/constant';
|
|
|
|
|
+ import { useUserInfoHook } from '@/views/disaster/hooks/userInfo';
|
|
|
|
|
+
|
|
|
|
|
+ const { permissions } = useUserInfoHook();
|
|
|
|
|
+
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
const searchData = reactive({
|
|
const searchData = reactive({
|
|
|
- taskType: '',
|
|
|
|
|
- activeStatus: '',
|
|
|
|
|
- taskStage: '',
|
|
|
|
|
|
|
+ inspectType: '',
|
|
|
|
|
+ effectStatus: '',
|
|
|
|
|
+ taskState: '',
|
|
|
});
|
|
});
|
|
|
- const handleSearch = (data: any) => {
|
|
|
|
|
- console.log(data);
|
|
|
|
|
|
|
+ const { tableConfig, pagination } = useTableConfig(TASK_MANAGEMENT_TABLE_COLUMNS, TABLE_OPTIONS_MANAGEMENT);
|
|
|
|
|
+ let taskManagementListQuery: QueryPageRequest<TaskManagementListQuery> = {
|
|
|
|
|
+ pageNumber: pagination.pageNumber,
|
|
|
|
|
+ pageSize: pagination.pageSize,
|
|
|
|
|
+ queryParam: {},
|
|
|
|
|
+ };
|
|
|
|
|
+ const handleSearch = () => {
|
|
|
|
|
+ taskManagementListQuery.queryParam = {};
|
|
|
|
|
+ if (searchData.inspectType !== '') {
|
|
|
|
|
+ taskManagementListQuery.queryParam.inspectType = searchData.inspectType;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (searchData.effectStatus !== '') {
|
|
|
|
|
+ taskManagementListQuery.queryParam.effectStatus = searchData.effectStatus;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (searchData.taskState !== '') {
|
|
|
|
|
+ taskManagementListQuery.queryParam.taskState = searchData.taskState;
|
|
|
|
|
+ }
|
|
|
getTableData();
|
|
getTableData();
|
|
|
};
|
|
};
|
|
|
const selectionItems = ref<any[]>([]);
|
|
const selectionItems = ref<any[]>([]);
|
|
|
const isBatchPublish = ref(false);
|
|
const isBatchPublish = ref(false);
|
|
|
const isBatchWithdraw = ref(false);
|
|
const isBatchWithdraw = ref(false);
|
|
|
|
|
+ const isBatchDelete = ref(false);
|
|
|
const getSelectionIds = (option: ACTIVE_STATUS) => {
|
|
const getSelectionIds = (option: ACTIVE_STATUS) => {
|
|
|
- return selectionItems.value.filter((item) => item.activeStatus === option).map((item) => item.id);
|
|
|
|
|
|
|
+ return selectionItems.value.filter((item) => item.effectStatus === option).map((item) => item.id);
|
|
|
};
|
|
};
|
|
|
const handleSelectionChange = (selection: any[]) => {
|
|
const handleSelectionChange = (selection: any[]) => {
|
|
|
selectionItems.value = selection;
|
|
selectionItems.value = selection;
|
|
@@ -132,6 +169,7 @@
|
|
|
isBatchPublish.value = Boolean(publishIds.length);
|
|
isBatchPublish.value = Boolean(publishIds.length);
|
|
|
const withdrawIds = getSelectionIds(ACTIVE_STATUS.ACTIVE);
|
|
const withdrawIds = getSelectionIds(ACTIVE_STATUS.ACTIVE);
|
|
|
isBatchWithdraw.value = Boolean(withdrawIds.length);
|
|
isBatchWithdraw.value = Boolean(withdrawIds.length);
|
|
|
|
|
+ isBatchDelete.value = Boolean(selectionItems.value.length === publishIds.length);
|
|
|
};
|
|
};
|
|
|
const openMessageBox = (title: string) => {
|
|
const openMessageBox = (title: string) => {
|
|
|
return ElMessageBox.confirm('', title, {
|
|
return ElMessageBox.confirm('', title, {
|
|
@@ -149,29 +187,56 @@
|
|
|
const confirmed = await openMessageBox('确认发布任务吗?');
|
|
const confirmed = await openMessageBox('确认发布任务吗?');
|
|
|
if (!confirmed) return;
|
|
if (!confirmed) return;
|
|
|
const publishIds = getSelectionIds(ACTIVE_STATUS.NOT_EFFECTIVE);
|
|
const publishIds = getSelectionIds(ACTIVE_STATUS.NOT_EFFECTIVE);
|
|
|
- ElMessage.success('批量发布成功');
|
|
|
|
|
- getTableData();
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ await publishTaskManagementItem(publishIds);
|
|
|
|
|
+ ElMessage.success('批量发布成功');
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ getTableData();
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
const handleBatchWithdraw = async () => {
|
|
const handleBatchWithdraw = async () => {
|
|
|
const confirmed = await openMessageBox('确认撤回已发布任务吗?');
|
|
const confirmed = await openMessageBox('确认撤回已发布任务吗?');
|
|
|
if (!confirmed) return;
|
|
if (!confirmed) return;
|
|
|
const withdrawIds = getSelectionIds(ACTIVE_STATUS.ACTIVE);
|
|
const withdrawIds = getSelectionIds(ACTIVE_STATUS.ACTIVE);
|
|
|
- ElMessage.success('批量撤回成功');
|
|
|
|
|
- getTableData();
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ await withdrawTaskManagementItem(withdrawIds);
|
|
|
|
|
+ ElMessage.success('批量撤回成功');
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ getTableData();
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
const basicTableRef = ref<InstanceType<typeof BasicTable>>();
|
|
const basicTableRef = ref<InstanceType<typeof BasicTable>>();
|
|
|
const handleBatchDelete = async () => {
|
|
const handleBatchDelete = async () => {
|
|
|
const confirmed = await openMessageBox('删除后任务不可恢复,确认删除吗?');
|
|
const confirmed = await openMessageBox('删除后任务不可恢复,确认删除吗?');
|
|
|
if (!confirmed) return;
|
|
if (!confirmed) return;
|
|
|
const deleteIds = getSelectionIds(ACTIVE_STATUS.NOT_EFFECTIVE);
|
|
const deleteIds = getSelectionIds(ACTIVE_STATUS.NOT_EFFECTIVE);
|
|
|
|
|
+ await deleteTaskManagementItem(deleteIds);
|
|
|
ElMessage.success('批量删除成功');
|
|
ElMessage.success('批量删除成功');
|
|
|
getTableData();
|
|
getTableData();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const defaultPath = '/disaster-prevention/disaster-precaution/task-item';
|
|
|
|
|
|
|
+ const handlePublishTask = async (id: number) => {
|
|
|
|
|
+ await publishTaskManagementItem(id);
|
|
|
|
|
+ getTableData();
|
|
|
|
|
+ ElMessage.success('发布成功');
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleWithdrawTask = async (id: number) => {
|
|
|
|
|
+ await withdrawTaskManagementItem(id);
|
|
|
|
|
+ getTableData();
|
|
|
|
|
+ ElMessage.success('撤回成功');
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleDeleteTask = async (id: number) => {
|
|
|
|
|
+ await deleteTaskManagementItem(id);
|
|
|
|
|
+ getTableData();
|
|
|
|
|
+ ElMessage.success('删除成功');
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const defaultName = 'disaster-precaution-task-item';
|
|
|
const handleCreateTask = () => {
|
|
const handleCreateTask = () => {
|
|
|
router.push({
|
|
router.push({
|
|
|
- name: defaultPath,
|
|
|
|
|
|
|
+ name: defaultName,
|
|
|
query: {
|
|
query: {
|
|
|
operate: 'create',
|
|
operate: 'create',
|
|
|
},
|
|
},
|
|
@@ -179,18 +244,17 @@
|
|
|
};
|
|
};
|
|
|
const handleEditTask = (id: number) => {
|
|
const handleEditTask = (id: number) => {
|
|
|
router.push({
|
|
router.push({
|
|
|
- name: defaultPath,
|
|
|
|
|
|
|
+ name: defaultName,
|
|
|
query: { operate: 'edit', id },
|
|
query: { operate: 'edit', id },
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
const handleViewTask = (id: number) => {
|
|
const handleViewTask = (id: number) => {
|
|
|
router.push({
|
|
router.push({
|
|
|
- name: defaultPath,
|
|
|
|
|
|
|
+ name: defaultName,
|
|
|
query: { id },
|
|
query: { id },
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
const tableData = ref<TaskManagementListResponse[]>([]);
|
|
const tableData = ref<TaskManagementListResponse[]>([]);
|
|
|
- const { tableConfig, pagination } = useTableConfig(TASK_MANAGEMENT_TABLE_COLUMNS, TABLE_OPTIONS_MANAGEMENT);
|
|
|
|
|
const handleSizeChange = (value: number) => {
|
|
const handleSizeChange = (value: number) => {
|
|
|
pagination.pageSize = value;
|
|
pagination.pageSize = value;
|
|
|
getTableData();
|
|
getTableData();
|
|
@@ -201,17 +265,26 @@
|
|
|
};
|
|
};
|
|
|
const getTableData = async () => {
|
|
const getTableData = async () => {
|
|
|
tableConfig.loading = true;
|
|
tableConfig.loading = true;
|
|
|
- const res = await getTaskManagementListData();
|
|
|
|
|
- tableData.value = res;
|
|
|
|
|
- pagination.total = tableData.value.length;
|
|
|
|
|
|
|
+ const res = await getTaskManagementList(taskManagementListQuery);
|
|
|
|
|
+ tableData.value = res.records;
|
|
|
|
|
+ pagination.total = res.totalRow;
|
|
|
tableConfig.loading = false;
|
|
tableConfig.loading = false;
|
|
|
};
|
|
};
|
|
|
|
|
+ const taskManagementPermissions = ref<Boolean>(false);
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getTableData();
|
|
getTableData();
|
|
|
|
|
+ taskManagementPermissions.value = Boolean(
|
|
|
|
|
+ permissions.find((item: { code: string }) => item.code === DISASTER_PERMISSIONS.TASK_MANAGEMENT),
|
|
|
|
|
+ );
|
|
|
|
|
+ tableConfig.height = taskManagementPermissions.value
|
|
|
|
|
+ ? TABLE_MANAGEMENT_HEIGHT_DEFAULT
|
|
|
|
|
+ : TABLE_MANAGEMENT_HEIGHT_NOT_PERMISSION;
|
|
|
});
|
|
});
|
|
|
watch(
|
|
watch(
|
|
|
() => selectionItems.value.length,
|
|
() => selectionItems.value.length,
|
|
|
(newLength) => {
|
|
(newLength) => {
|
|
|
|
|
+ // 如果没有权限,则不显示批量操作
|
|
|
|
|
+ if (!taskManagementPermissions.value) return;
|
|
|
if (newLength > 0) {
|
|
if (newLength > 0) {
|
|
|
tableConfig.height = TABLE_MANAGEMENT_HEIGHT_BATCH_OPERATION;
|
|
tableConfig.height = TABLE_MANAGEMENT_HEIGHT_BATCH_OPERATION;
|
|
|
} else {
|
|
} else {
|