Browse Source

提交任务

master
parent
commit
e6c7dbc38e
  1. 12
      src/api/enterprises/index.ts
  2. 4
      src/api/system/taskinfo/index.ts
  3. 9
      src/components/Pagination/index.vue
  4. 2
      src/layout/Layout.vue
  5. 12
      src/layout/components/TagsView/src/TagsView.vue
  6. 2
      src/router/modules/remaining.ts
  7. 6
      src/store/modules/app.ts
  8. 61
      src/views/system/taglibrary/form.vue
  9. 79
      src/views/system/taglibrary/index.vue
  10. 465
      src/views/task/create.vue

12
src/api/enterprises/index.ts

@ -22,31 +22,31 @@ export interface EnterprisesVO {
export const EnterprisesApi = { export const EnterprisesApi = {
// 查询企业分页 // 查询企业分页
getEnterprisesPage: async (params: any) => { getEnterprisesPage: async (params: any) => {
return await request.get({ url: `/system/enterprises/page`, params }) return await request.get({ url: `/system/enterprise/page`, params })
}, },
// 查询企业详情 // 查询企业详情
getEnterprises: async (id: number) => { getEnterprises: async (id: number) => {
return await request.get({ url: `/system/enterprises/get?id=` + id }) return await request.get({ url: `/system/enterprise/get?id=` + id })
}, },
// 新增企业 // 新增企业
createEnterprises: async (data: EnterprisesVO) => { createEnterprises: async (data: EnterprisesVO) => {
return await request.post({ url: `/system/enterprises/create`, data }) return await request.post({ url: `/system/enterprise/create`, data })
}, },
// 修改企业 // 修改企业
updateEnterprises: async (data: EnterprisesVO) => { updateEnterprises: async (data: EnterprisesVO) => {
return await request.put({ url: `/system/enterprises/update`, data }) return await request.put({ url: `/system/enterprise/update`, data })
}, },
// 删除企业 // 删除企业
deleteEnterprises: async (id: number) => { deleteEnterprises: async (id: number) => {
return await request.delete({ url: `/system/enterprises/delete?id=` + id }) return await request.delete({ url: `/system/enterprise/delete?id=` + id })
}, },
// 导出企业 Excel // 导出企业 Excel
exportEnterprises: async (params) => { exportEnterprises: async (params) => {
return await request.download({ url: `/system/enterprises/export-excel`, params }) return await request.download({ url: `/system/enterprise/export-excel`, params })
}, },
} }

4
src/api/system/taskinfo/index.ts

@ -30,12 +30,12 @@ export const TaskInfoApi = {
}, },
// 新增任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。 // 新增任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。
createTaskInfo: async (data: TaskInfoVO) => { createTaskInfo: async (data) => {
return await request.post({ url: `/system/task-info/create`, data }) return await request.post({ url: `/system/task-info/create`, data })
}, },
// 修改任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。 // 修改任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。
updateTaskInfo: async (data: TaskInfoVO) => { updateTaskInfo: async (data) => {
return await request.put({ url: `/system/task-info/update`, data }) return await request.put({ url: `/system/task-info/update`, data })
}, },

9
src/components/Pagination/index.vue

@ -5,12 +5,13 @@
v-model:current-page="currentPage" v-model:current-page="currentPage"
v-model:page-size="pageSize" v-model:page-size="pageSize"
:background="true" :background="true"
:page-sizes="[10, 20, 30, 50, 100]" :page-sizes="showPageSize?[10, 20, 30, 50, 100]:[pageSize]"
:pager-count="pagerCount" :pager-count="pagerCount"
:total="total" :total="total"
:small="isSmall" :small="isSmall"
class="float-right mb-15px mt-15px" class="float-right mb-15px mt-15px"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
v-bind="$attrs"
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
/> />
@ -50,7 +51,11 @@ const props = defineProps({
pagerCount: { pagerCount: {
type: Number, type: Number,
default: document.body.clientWidth < 992 ? 5 : 7 default: document.body.clientWidth < 992 ? 5 : 7
} },
showPageSize:{
type:Boolean,
default:true
}
}) })
const emit = defineEmits(['update:page', 'update:limit', 'pagination']) const emit = defineEmits(['update:page', 'update:limit', 'pagination'])

2
src/layout/Layout.vue

@ -58,8 +58,6 @@ export default defineComponent({
{renderLayout()} {renderLayout()}
<Backtop></Backtop> <Backtop></Backtop>
<Setting></Setting>
</section> </section>
) )
} }

12
src/layout/components/TagsView/src/TagsView.vue

@ -18,7 +18,6 @@ const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('tags-view') const prefixCls = getPrefixCls('tags-view')
const { t } = useI18n() const { t } = useI18n()
const { currentRoute, push, replace } = useRouter() const { currentRoute, push, replace } = useRouter()
const permissionStore = usePermissionStore() const permissionStore = usePermissionStore()
@ -54,7 +53,7 @@ const selectedTag = ref<RouteLocationNormalizedLoaded>()
// tag // tag
const addTags = () => { const addTags = () => {
const { name } = unref(currentRoute) const { name,meta } = unref(currentRoute)
if (name) { if (name) {
selectedTag.value = unref(currentRoute) selectedTag.value = unref(currentRoute)
tagsViewStore.addView(unref(currentRoute)) tagsViewStore.addView(unref(currentRoute))
@ -369,10 +368,11 @@ watch(
:size="12" :size="12"
class="mr-5px" class="mr-5px"
/> />
{{ <!-- {{-->
t(item?.meta?.title as string) + <!-- t(item?.meta?.title as string) +-->
(item?.meta?.titleSuffix ? ` (${item?.meta?.titleSuffix})` : '') <!-- (item?.meta?.titleSuffix ? ` (${item?.meta?.titleSuffix})` : '')-->
}} <!-- }}-->
{{ item?.meta?.title }}
<Icon <Icon
:class="`${prefixCls}__item--close`" :class="`${prefixCls}__item--close`"
:size="12" :size="12"

2
src/router/modules/remaining.ts

@ -62,7 +62,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
component: () => import('@/views/Home/Index.vue'), component: () => import('@/views/Home/Index.vue'),
name: 'Index', name: 'Index',
meta: { meta: {
title: t('router.home'), title: '首页',
icon: 'ep:home-filled', icon: 'ep:home-filled',
noCache: false, noCache: false,
affix: true affix: true

6
src/store/modules/app.ts

@ -55,8 +55,8 @@ export const useAppStore = defineStore('app', {
hamburger: true, // 折叠图标 hamburger: true, // 折叠图标
screenfull: true, // 全屏图标 screenfull: true, // 全屏图标
search: true, // 搜索图标 search: true, // 搜索图标
size: true, // 尺寸图标 size: false, // 尺寸图标
locale: true, // 多语言图标 locale: false, // 多语言图标
message: true, // 消息图标 message: true, // 消息图标
tagsView: true, // 标签页 tagsView: true, // 标签页
tagsViewImmerse: false, // 标签页沉浸 tagsViewImmerse: false, // 标签页沉浸
@ -77,7 +77,7 @@ export const useAppStore = defineStore('app', {
// 左侧菜单边框颜色 // 左侧菜单边框颜色
leftMenuBorderColor: 'inherit', leftMenuBorderColor: 'inherit',
// 左侧菜单背景颜色 // 左侧菜单背景颜色
leftMenuBgColor: '#001529', leftMenuBgColor: '#409eff',
// 左侧菜单浅色背景颜色 // 左侧菜单浅色背景颜色
leftMenuBgLightColor: '#0f2438', leftMenuBgLightColor: '#0f2438',
// 左侧菜单选中背景颜色 // 左侧菜单选中背景颜色

61
src/views/system/taglibrary/TagLibraryForm.vue → src/views/system/taglibrary/form.vue

@ -7,11 +7,10 @@
label-width="100px" label-width="100px"
v-loading="formLoading" v-loading="formLoading"
> >
<el-form-item label="类型" prop="tagType"> <el-form-item label="类型" prop="tagType">
<el-select v-model="formData.tagType" placeholder="请选择1、企业标签2、执法标签"> <el-select v-model="formData.tagType" placeholder="请选择1、企业标签2、执法标签">
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.TAG_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.TAG_TYPE)"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
@ -20,12 +19,7 @@
</el-form-item> </el-form-item>
<el-form-item label="父标签的ID" prop="tagName"> <el-form-item label="父标签的ID" prop="tagName">
<el-select <el-select v-model="formData.parentId" placeholder="请选择标签" filterable clearable>
v-model="formData.parentId"
placeholder="请选择标签"
filterable
clearable
>
<!-- 使用递归方法生成多层级选项 --> <!-- 使用递归方法生成多层级选项 -->
<template v-for="option in list" :key="option.id"> <template v-for="option in list" :key="option.id">
<el-option <el-option
@ -48,12 +42,10 @@
<el-form-item label="标签的名称" prop="tagName"> <el-form-item label="标签的名称" prop="tagName">
<el-input v-model="formData.tagName" placeholder="请输入标签的名称" /> <el-input v-model="formData.tagName" placeholder="请输入标签的名称" />
</el-form-item> </el-form-item>
<el-form-item label="排序" prop="sort"> <el-form-item label="排序" prop="sort">
<el-input v-model="formData.sort" placeholder="排序" /> <el-input v-model="formData.sort" placeholder="排序" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
@ -65,9 +57,8 @@
import { TagLibraryApi, TagLibraryVO } from '@/api/system/taglibrary' import { TagLibraryApi, TagLibraryVO } from '@/api/system/taglibrary'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
/** 企业标签 表单 */ /** 企业标签 表单 */
defineOptions({ name: 'TagLibraryForm' }) defineOptions({ name: 'Form' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -75,7 +66,6 @@ const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({ const formData = ref({
tagId: undefined, tagId: undefined,
tagName: undefined, tagName: undefined,
@ -86,48 +76,35 @@ const formData = ref({
}) })
const formRules = reactive({ const formRules = reactive({
tagName: [{ required: true, message: '标签的名称不能为空', trigger: 'blur' }], tagName: [{ required: true, message: '标签的名称不能为空', trigger: 'blur' }],
tagLevel: [{ required: true, message: '标签层级(一级、二级、三级)不能为空', trigger: 'blur' }], tagLevel: [{ required: true, message: '标签层级(一级、二级、三级)不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
tagName: undefined,
parentTagId: undefined,
tagLevel: undefined,
tagType: undefined,
createTime: [],
})
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (params) => {
// //
levelList() await levelList()
dialogVisible.value = true dialogVisible.value = true
dialogTitle.value = t('action.' + type) dialogTitle.value = params.id ? '修改' : '创建'
formType.value = type
resetForm() resetForm()
// //
if (id) { if (params.id) {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await TagLibraryApi.getTagLibrary(id) formData.value = await TagLibraryApi.getTagLibrary(params.id)
console.log('formData.value=>', formData.value)
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} }
formData.value.tagType = params.tagType
} }
const list:any = ref([]) const list: any = ref([])
const levelList =async ()=>{ const levelList = async () => {
const data = await TagLibraryApi.getTagLibraryPage(queryParams) const data = await TagLibraryApi.getTagLibraryPage(formData.value.id)
list.value = data list.value = data
} }
@ -142,11 +119,11 @@ const submitForm = async () => {
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as unknown as TagLibraryVO const data = formData.value as unknown as TagLibraryVO
if (formType.value === 'create') { if (data.id) {
await TagLibraryApi.createTagLibrary(data) await TagLibraryApi.updateTagLibrary(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await TagLibraryApi.updateTagLibrary(data) await TagLibraryApi.createTagLibrary(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
dialogVisible.value = false dialogVisible.value = false
@ -169,4 +146,4 @@ const resetForm = () => {
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }
</script> </script>

79
src/views/system/taglibrary/index.vue

@ -26,24 +26,10 @@
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="类型" prop="tagType">
<el-select
v-model="queryParams.tagType"
placeholder="请选择1、企业标签2、执法标签"
clearable
class="!w-240px"
>
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <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 @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button <el-button type="primary" plain @click="openForm()">
type="primary"
plain
@click="openForm('create')"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增 <Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button> </el-button>
<el-button <el-button
@ -62,41 +48,41 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-tree <el-tree
:data="list" :data="list"
node-key="id" node-key="id"
:props="treeProps" :props="treeProps"
highlight-current highlight-current
default-expand-all default-expand-all
@node-click="handleNodeClick" @node-click="handleNodeClick"
> >
<template #default="{ node, data }"> <template #default="{ node, data }">
<span>{{ node.label }}{{ data.tagName }}</span> <span>{{ node.label }}{{ data.tagName }}</span>
<el-tag size="small" type="info">层级: {{ data.tagLevel }}</el-tag> <el-tag size="small" type="info">层级: {{ data.tagLevel }}</el-tag>
<!-- <el-tag size="small" :type="data.tag_type === 1 ? 'success' : 'warning'"> <!-- <el-tag size="small" :type="data.tag_type === 1 ? 'success' : 'warning'">
{{ data.tag_type === 1 ? '企业标签' : '执法标签' }} {{ data.tag_type === 1 ? '企业标签' : '执法标签' }}
</el-tag> --> </el-tag> -->
<el-button type="text" @click="openForm('update', data.id)"><el-icon><EditPen /></el-icon></el-button> <el-button type="text" @click="openForm(data.id)"
<el-button type="text" @click="handleDelete(data.id)"><el-icon><DeleteFilled /></el-icon></el-button> ><el-icon><EditPen /></el-icon
</template> ></el-button>
</el-tree> <el-button type="text" @click="handleDelete(data.id)"
><el-icon><DeleteFilled /></el-icon
></el-button>
</template>
</el-tree>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<TagLibraryForm ref="formRef" @success="getList" /> <TagForm ref="tagFormRef" @success="getList" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import { TagLibraryApi, TagLibraryVO } from '@/api/system/taglibrary/index' import { TagLibraryApi, TagLibraryVO } from '@/api/system/taglibrary/index'
import TagLibraryForm from './TagLibraryForm.vue' import TagForm from './form.vue'
/** 企业标签 列表 */ /** 企业标签 列表 */
defineOptions({ name: 'TagLibrary' }) defineOptions({ name: 'TagLibrary' })
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) // const loading = ref(true) //
const list = ref<TagLibraryVO[]>([]) // const list = ref<TagLibraryVO[]>([]) //
const total = ref(0) // const total = ref(0) //
@ -107,11 +93,11 @@ const queryParams = reactive({
parentId: undefined, parentId: undefined,
tagLevel: undefined, tagLevel: undefined,
tagType: undefined, tagType: undefined,
createTime: [], createTime: []
}) })
const route = useRoute()
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
@ -124,8 +110,8 @@ const getList = async () => {
} }
const treeProps = ref({ const treeProps = ref({
label: "tag_name", // label: 'tag_name', //
children: "children", // children: 'children' //
}) })
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -141,14 +127,12 @@ const resetQuery = () => {
} }
const handleNodeClick = (node) => { const handleNodeClick = (node) => {
console.log("当前点击的标签:", node); console.log('当前点击的标签:', node)
} }
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const tagFormRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (id?: number) => {
formRef.value.open(type, id) tagFormRef.value.open({ id, tagType: queryParams.tagType })
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
@ -181,6 +165,7 @@ const handleExport = async () => {
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
queryParams.tagType = route.fullPath.split('/').pop()
getList() getList()
}) })
</script> </script>

465
src/views/task/create.vue

@ -1,9 +1,470 @@
<template> <template>
<ContentWrap > 创建任务 </ContentWrap> <ContentWrap title="基本信息">
<section class="taskForm">
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="auto">
<el-form-item label="标题" prop="title">
<el-input v-model="formData.title" placeholder="请输入任务标题" />
</el-form-item>
<el-form-item label="时间周期" prop="planTime">
<el-date-picker
v-model="formData.planTime"
type="daterange"
value-format="x"
range-separator="至"
start-placeholder="选择任务计划开始时间"
end-placeholder="选择任务计划结束时间"
/>
</el-form-item>
<el-form-item label="类型" prop="taskType">
<el-select v-model="formData.taskType" placeholder="请选择任务类型">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.TASK_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="执行周期" prop="execCycle" v-if="formData.taskType == 2">
<el-select v-model="formData.execCycle" placeholder="请选择执行周期">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.TASK_EXEC_TIME)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="优先级" prop="priority">
<el-select v-model="formData.priority" placeholder="请选择任务优先级">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.TASK_PRIORITY)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="标签" prop="tags" style="width: 100%">
<el-tree-select
v-model="formData.tags"
:data="tagList"
check-strictly
:render-after-expand="false"
placeholder="请选择标签"
node-key="id"
show-checkbox
multiple
:props="{
label: 'tagName'
}"
/>
</el-form-item>
<el-form-item label="描述" prop="description" style="width: 100%">
<el-input
type="textarea"
v-model="formData.description"
:autosize="{
minRows: 3
}"
placeholder="请输入描述"
/>
</el-form-item>
</el-form>
</section>
</ContentWrap>
<ContentWrap title="执行范围">
<template #header> </template>
<section class="select-area" v-loading="loading">
<section>
<el-form :model="enterprise.queryParams" ref="queryFormRef" :inline="true" label-width="0">
<el-form-item label="" prop="enterprisesName">
<el-input
v-model="enterprise.queryParams.enterprisesName"
placeholder="请输入企业名称"
clearable
@keyup.enter="handleQuery"
class="!w-180px"
/>
</el-form-item>
<el-form-item label="" prop="type">
<el-select
v-model="enterprise.queryParams.type"
placeholder="请选择企业类型"
clearable
@change="handleQuery"
@clear="handleQuery"
class="!w-180px"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.ENTERPRISES_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="" prop="region">
<el-select
v-model="enterprise.queryParams.region"
placeholder="请选择企业所属区域"
clearable
@clear="handleQuery"
@change="handleQuery"
class="!w-180px"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.ENTERPRISES_AREA)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery">
<Icon icon="ep:search" class="mr-5px" /> 搜索
</el-button>
<el-button @click="resetQuery" class="mr-10px">
<Icon icon="ep:refresh" class="mr-5px" /> 重置 </el-button
><el-button-group>
<el-button type="primary" @click="selectAll()"> 选择全部 </el-button>
<el-button type="danger" @click="cancelAll()"> 排除全部 </el-button>
</el-button-group>
</el-form-item>
</el-form>
<section class="enterprise-area">
<section
v-for="enterprise in enterprise.list"
:key="enterprise.id"
class="enterprise flex flex-col justify-around"
>
<section class="flex justify-between">
<span>
{{ enterprise.enterprisesName }}
</span>
<section class="flex gap-5px">
<DictTag :type="DICT_TYPE.ENTERPRISES_AREA" :value="Number(enterprise.region)" />
<DictTag :type="DICT_TYPE.ENTERPRISES_TYPE" :value="Number(enterprise.type)" />
</section>
<el-button
type="primary"
size="small"
plain
@click="selectEnterprise(enterprise)"
v-show="formData.enterprises.findIndex((e) => e.id == enterprise.id) == -1"
>
选择
</el-button>
<el-button
type="danger"
size="small"
plain
@click="checkEnterprise(enterprise)"
v-show="formData.enterprises.findIndex((e) => e.id == enterprise.id) > -1"
>
排除
</el-button>
</section>
</section>
</section>
<pagination
v-show="enterprise.total > 0"
:total="enterprise.total"
:show-page-size="false"
size="small"
v-model:page="enterprise.queryParams.pageNo"
v-model:limit="enterprise.queryParams.pageSize"
@pagination="getEnterPriseList"
/>
</section>
<section>
<section class="check-area">
<section v-for="item in formData.enterprises" :key="item.id" class="isChecked">
<el-tooltip :content="item.enterprisesName" placement="top">
<span>
{{ item.enterprisesName }}
</span>
</el-tooltip>
<el-icon @click="checkEnterprise(item)"><Close /></el-icon>
</section>
<el-empty
description="待选择"
v-if="formData.enterprises?.length == 0"
class="w-100% h-100%"
/>
</section>
<section class="total">
<el-tag type="primary" size="large" class="font-800">
共选择
<count-to :end-val="formData.enterprises.length" />
家企业
</el-tag></section
>
</section>
</section>
</ContentWrap>
<ContentWrap>
<el-button type="primary" @click="submitForm"> </el-button>
</ContentWrap>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import { TagLibraryApi } from '@/api/system/taglibrary'
import { EnterprisesApi, EnterprisesVO } from '@/api/enterprises'
import { TaskInfoApi } from '@/api/system/taskinfo'
defineOptions({ name: 'CreateTask' }) defineOptions({ name: 'CreateTask' })
const loading = ref(false)
const formData = ref({
id: undefined,
title: undefined,
description: undefined,
execCycle: undefined,
taskType: undefined,
priority: undefined,
status: undefined,
startDate: undefined,
endDate: undefined,
createBy: undefined,
updateBy: undefined,
parentId: undefined,
parentType: undefined,
taskStep: undefined,
taskTotal: undefined,
planTime: [],
tags: [],
enterprises: ref<any>([])
})
const message = useMessage() //
const formRules = reactive({
title: [{ required: true, message: '任务标题不能为空', trigger: 'blur' }],
taskType: [
{
required: true,
message: '任务类型不能为空',
trigger: 'change'
}
],
planTime: [{ required: true, message: '时间周期不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
const tagList = ref([])
const queryFormRef = ref() //
const enterprise = ref({
list: ref<EnterprisesVO[]>(),
queryParams: reactive({
pageNo: 1,
pageSize: 9,
enterprisesName: undefined,
type: undefined,
region: undefined,
registrationNumber: undefined
}),
total: ref(0)
})
/** 搜索按钮操作 */
const handleQuery = () => {
enterprise.value.queryParams.pageNo = 1
getEnterPriseList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/**
* 获取标签列表
*/
function getTagList() {
TagLibraryApi.getTagLibraryPage({}).then((res) => {
tagList.value = res
})
}
/**
* 获取企业列表
*/
async function getEnterPriseList() {
loading.value = true
try {
const data = await EnterprisesApi.getEnterprisesPage(enterprise.value.queryParams)
enterprise.value.list = data.list
enterprise.value.total = data.total
} finally {
loading.value = false
}
}
/**
* 全选
*/
async function selectAll() {
loading.value = true
const data = enterprise.value.queryParams
data.pageNo = -1
const res = await EnterprisesApi.getEnterprisesPage(enterprise.value.queryParams)
const arr = [...formData.value.enterprises, ...res.list]
formData.value.enterprises = uniqueFunc(arr, 'id')
loading.value = false
}
/**
* 取消全选
*/
async function cancelAll() {
loading.value = true
const data = enterprise.value.queryParams
data.pageNo = -1
const { list } = await EnterprisesApi.getEnterprisesPage(enterprise.value.queryParams)
if (list) {
formData.value.enterprises = formData.value.enterprises.filter((e) => {
return !list.some((r) => e.id == r.id)
})
}
loading.value = false
}
/**
* 单选企业
* @param enterprise
*/
function selectEnterprise(enterprise) {
formData.value.enterprises.push(enterprise)
}
/**
* 单选取消
* @param enterprise
*/
function checkEnterprise(enterprise) {
formData.value.enterprises = formData.value.enterprises.filter((e) => e.id != enterprise.id)
}
/**
* 数组去重
* @param arr
* @param uniId 唯一id
* @returns
*/
function uniqueFunc(arr, uniId) {
const res = new Map()
return arr.filter((item) => !res.has(item[uniId]) && res.set(item[uniId], 1))
}
/**
* 提交表单
*/
async function submitForm() {
const validate = await unref(formRef).validate()
console.log(validate, formData.value)
if (validate) {
const data = formData.value
data.enterprises = formData.value.enterprises.map((i) => i.id)
data.startDate = data.planTime[0]
data.endDate = data.planTime[1]
if (data.id) {
} else {
TaskInfoApi.createTaskInfo(data).then(() => {
message.success('操作成功')
})
}
}
}
getEnterPriseList()
getTagList()
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss">
::v-deep(.taskForm .el-form) {
display: flex;
flex-flow: row wrap;
justify-content: space-around;
gap: 10px;
.el-form-item {
width: calc(50% - 10px);
display: flex;
align-items: flex-start;
}
}
.enterprise-area {
flex: 1;
gap: 10px;
height: 450px;
.enterprise {
cursor: pointer;
box-shadow: 0 0 1px 1px #eaeaea;
border-radius: 6px;
padding: 10px;
transition: 0.2s all;
margin-bottom: 5px;
&:hover {
box-shadow: 0 0 1px 1px #ccc;
}
}
}
.check-area {
border: 1px dashed #ccc;
border-radius: 6px;
overflow: hidden;
overflow-y: scroll;
height: 550px;
max-height: 550px;
scroll-behavior: smooth;
padding: 10px;
display: flex;
flex-flow: row wrap;
gap: 10px;
align-content: flex-start;
&::-webkit-scrollbar {
width: 3px;
height: 100%;
padding: 2px;
}
&::-webkit-scrollbar-thumb {
background-color: #ccc;
border-radius: 5px;
}
.isChecked {
width: calc(100% / 4 - 10px);
height: 50px;
color: #fff;
background-color: var(--el-color-primary);
padding: 5px 10px;
box-shadow: 0px 0px 1px 1px #ccc;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
}
}
.total {
width: 100%;
margin-top: 10px;
text-align: right;
}
.select-area {
display: grid;
grid-template-rows: 1fr;
grid-template-columns: 1fr 1.5fr;
height: 600px;
grid-gap: 20px;
::v-deep(.select-area .el-form) {
margin-bottom: 15px;
.el-form-item {
margin-right: 10px;
margin-bottom: 10px;
}
}
}
</style>

Loading…
Cancel
Save