You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

374 lines
10 KiB

<template>
<ContentWrap style="align-items: center; display: flex; padding: 25px 0;">
<!-- 搜索工作栏 -->
<el-form
class="formClass"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="108px"
>
<el-form-item label="任务标题" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入任务标题"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<!-- <el-form-item label="任务状态" prop="taskType">
<el-select
v-model="queryParams.status"
placeholder="请选择任务状态"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.TASK_STATE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item> -->
<el-form-item label="任务类型" prop="taskType">
<el-select
v-model="queryParams.taskType"
placeholder="请选择任务类型"
clearable
class="!w-240px"
>
<el-option
v-for="dict in taskTypeList"
:key="dict.id"
:label="dict.tagName"
:value="dict.id"
/>
</el-select>
</el-form-item>
<el-form-item label="任务时间" prop="startDate">
<el-date-picker
v-model="queryParams.startDate"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-220px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
v-hasPermi="['system:task-info:create']"
@click="push({ path: '/task/create' })"
>
<Icon icon="ep:plus" class="mr-5px" /> 创建任务
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['system:task-info:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" :cell-style="{'text-align': 'left'}">
<el-table-column label="任务名称" align="left" prop="title" width="200"/>
<el-table-column label="任务类型" align="left" prop="taskType">
<template #default="scope">
<el-tag>{{ scope.row.taskTypeName }}</el-tag>
</template>
</el-table-column>
<el-table-column label="发布部门" align="left" prop="deptName" />
<el-table-column label="任务状态" align="left" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.TASK_STATE" :value="scope.row.status" />
</template>
</el-table-column>
<!-- <el-table-column label="执行周期" align="center" prop="execCycle">
<template #default="scope">
<dict-tag :type="DICT_TYPE.TASK_EXEC_TIME" :value="scope.row.execCycle" />
</template>
</el-table-column> -->
<!-- <el-table-column label="任务优先级" align="center" prop="priority">
<template #default="scope">
<dict-tag :type="DICT_TYPE.TASK_PRIORITY" :value="scope.row.priority" />
</template>
</el-table-column> -->
<el-table-column
label="开始时间"
align="center"
prop="startDate"
:formatter="dateFormatter3"
/>
<el-table-column
label="结束时间"
align="center"
prop="endDate"
:formatter="dateFormatter3"
/>
<!-- <el-table-column
label="任务创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/> -->
<el-table-column label="创建人" align="left" prop="createName" />
<!-- <el-table-column label="父任务id" align="center" prop="parentId" />
<el-table-column label="父子任务类型" align="center" prop="parentType">
<template #default="scope">
<dict-tag :type="DICT_TYPE.TASK_TYPE_PARENT" :value="scope.row.parentType" />
</template>
</el-table-column> -->
<!-- <el-table-column label="执行到第几" align="center" prop="taskStep" /> -->
<el-table-column label="执法对象" align="left" min-width="50px">
<template #default="scope">
<el-button link type="primary" @click="
push({
path: 'create',
query: {
id: scope.row.id
}
})
">
<el-Tag type="success">{{scope.row.enterpriseIdes.length}}</el-Tag>&nbsp;
</el-button>&nbsp;
</template>
</el-table-column>
<el-table-column label="" align="center" min-width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="
push({
path: 'create',
query: {
id: scope.row.id
}
})
"
v-hasPermi="['system:task-info:update']"
>
详情
</el-button>
<el-button
link
type="primary"
@click="taskExec(scope.row)"
v-if="scope.row.status == 1"
v-hasPermi="['system:task-info:update']"
>
立即执行
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['system:task-info:delete']"
v-if="scope.row.status == 1"
>
删除
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['system:task-info:audit']"
v-if="scope.row.status == 0"
>
审核
</el-button>
<!-- <el-button link type="primary" @click="openForm(scope.row.id)"> 详情 </el-button> -->
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<TaskInfoForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter3 } from '@/utils/formatTime'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { TaskInfoApi, TaskInfoVO } from '@/api/system/taskinfo'
import TaskInfoForm from './TaskInfoForm.vue'
import { TagLibraryApi } from '@/api/system/taglibrary'
/** 任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。 列表 */
defineOptions({ name: 'TaskList' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const { push } = useRouter()
const loading = ref(true) // 列表的加载中
const list = ref<TaskInfoVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const taskTypeMap=ref()
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
title: undefined,
description: undefined,
execCycle: undefined,
taskType: undefined,
priority: undefined,
status: undefined,
startDate: [],
endDate: [],
createTime: [],
createBy: undefined,
updateBy: undefined,
parentId: undefined,
parentType: undefined,
taskStep: undefined,
taskTotal: undefined
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
const taskTypeList:any = ref([])
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await TaskInfoApi.getTaskInfoPage(queryParams)
list.value = data.list
total.value = data.total
//任务标签
const params = {
tagType: 2
}
const tag = await TagLibraryApi.getTagLibraryPage(params)
taskTypeList.value = tag[0].children
} finally {
loading.value = false
}
}
// 立即执行
const taskExec = async (data) => {
loading.value = true
try {
await TaskInfoApi.taskExec(data)
message.success(t('common.createSuccess'))
getList()
} finally {
loading.value = false
}
}
//选择任务中企业范围
const selectEnterprise = async (id: number) => {}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
await TaskInfoApi.deleteTaskInfo(id)
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await TaskInfoApi.exportTaskInfo(queryParams)
download.excel(data, '任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<style scoped lang="scss">
.formClass {
display: grid;
grid-template-columns: 1fr 1fr 1fr 2fr;
grid-template-rows: 1fr;
align-items: center;
:deep(.el-form-item) {
margin: 0 !important;
}
}
</style>