修改下载文件类型的备份
This commit is contained in:
parent
1dc321ba5c
commit
64a82a6775
|
@ -54,5 +54,38 @@ export const regulationApi = {
|
||||||
// 确认制度知晓
|
// 确认制度知晓
|
||||||
confirmRegulation: (regulationId: string) => {
|
confirmRegulation: (regulationId: string) => {
|
||||||
return http.post(`/regulation/${regulationId}/confirm`)
|
return http.post(`/regulation/${regulationId}/confirm`)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取制度类型列表
|
||||||
|
getRegulationTypes: (params?: {
|
||||||
|
page?: number
|
||||||
|
size?: number
|
||||||
|
typeName?: string
|
||||||
|
remark?: string
|
||||||
|
}) => {
|
||||||
|
return http.get('/regulation/types', params)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 创建制度类型
|
||||||
|
createRegulationType: (data: {
|
||||||
|
typeName: string
|
||||||
|
sortOrder?: number
|
||||||
|
isEnabled?: string
|
||||||
|
}) => {
|
||||||
|
return http.post('/regulation/types', data)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 更新制度类型
|
||||||
|
updateRegulationType: (typeId: string, data: {
|
||||||
|
typeName: string
|
||||||
|
sortOrder?: number
|
||||||
|
isEnabled?: string
|
||||||
|
}) => {
|
||||||
|
return http.put(`/regulation/types/${typeId}`, data)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除制度类型
|
||||||
|
deleteRegulationType: (typeId: string) => {
|
||||||
|
return http.del(`/regulation/types/${typeId}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,8 +22,6 @@ export interface Regulation {
|
||||||
content: string
|
content: string
|
||||||
regulationType: string
|
regulationType: string
|
||||||
status: RegulationStatus
|
status: RegulationStatus
|
||||||
publisherId: string
|
|
||||||
publisherName: string
|
|
||||||
publishTime: string
|
publishTime: string
|
||||||
effectiveTime: string
|
effectiveTime: string
|
||||||
expireTime: string
|
expireTime: string
|
||||||
|
@ -38,6 +36,7 @@ export interface Regulation {
|
||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
delFlag: string
|
delFlag: string
|
||||||
|
confirmStatus?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建提案请求接口
|
// 创建提案请求接口
|
||||||
|
@ -54,4 +53,34 @@ export interface CreateProposalRequest {
|
||||||
export interface PaginationParams {
|
export interface PaginationParams {
|
||||||
page: number
|
page: number
|
||||||
size: number
|
size: number
|
||||||
|
}
|
||||||
|
|
||||||
|
// 制度类型接口
|
||||||
|
export interface RegulationType {
|
||||||
|
typeId: string
|
||||||
|
typeName: string
|
||||||
|
sortOrder: number
|
||||||
|
isEnabled: string
|
||||||
|
remark?: string
|
||||||
|
createBy: string
|
||||||
|
createTime: string
|
||||||
|
updateBy: string
|
||||||
|
updateTime: string
|
||||||
|
delFlag: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建制度类型请求接口
|
||||||
|
export interface CreateRegulationTypeRequest {
|
||||||
|
typeName: string
|
||||||
|
sortOrder?: number
|
||||||
|
isEnabled?: string
|
||||||
|
remark?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新制度类型请求接口
|
||||||
|
export interface UpdateRegulationTypeRequest {
|
||||||
|
typeName: string
|
||||||
|
sortOrder?: number
|
||||||
|
isEnabled?: string
|
||||||
|
remark?: string
|
||||||
}
|
}
|
|
@ -37,7 +37,13 @@ export const systemRoutes: RouteRecordRaw[] = [
|
||||||
path: '/regulation/system-regulation',
|
path: '/regulation/system-regulation',
|
||||||
name: 'SystemRegulation',
|
name: 'SystemRegulation',
|
||||||
component: () => import('@/views/regulation/repository.vue'),
|
component: () => import('@/views/regulation/repository.vue'),
|
||||||
meta: { title: '制度确认', icon: 'file-text', hidden: false },
|
meta: { title: '制度公示', icon: 'file-text', hidden: false },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/regulation/type',
|
||||||
|
name: 'RegulationType',
|
||||||
|
component: () => import('@/views/regulation/type/index.vue'),
|
||||||
|
meta: { title: '制度类型', icon: 'tag', hidden: false },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/regulation/process-management',
|
path: '/regulation/process-management',
|
||||||
|
|
|
@ -88,12 +88,14 @@
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="提案类型" field="regulationType">
|
<a-form-item label="提案类型" field="regulationType">
|
||||||
<a-select v-model="formData.regulationType" placeholder="请选择提案类型">
|
<a-select v-model="formData.regulationType" placeholder="请选择提案类型">
|
||||||
<a-option value="人事制度">人事制度</a-option>
|
<a-option
|
||||||
<a-option value="财务制度">财务制度</a-option>
|
v-for="type in regulationTypes"
|
||||||
<a-option value="安全制度">安全制度</a-option>
|
:key="type.typeId"
|
||||||
<a-option value="设备制度">设备制度</a-option>
|
:value="type.typeName"
|
||||||
<a-option value="工作流程">工作流程</a-option>
|
:disabled="type.isEnabled === '0'"
|
||||||
<a-option value="其他制度">其他制度</a-option>
|
>
|
||||||
|
{{ type.typeName }}
|
||||||
|
</a-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
@ -149,7 +151,7 @@
|
||||||
<div class="detail-header">
|
<div class="detail-header">
|
||||||
<h3>{{ currentProposal.title }}</h3>
|
<h3>{{ currentProposal.title }}</h3>
|
||||||
<div class="detail-meta">
|
<div class="detail-meta">
|
||||||
<span>提案人: {{ currentProposal.publisherName }}</span>
|
<span>提案人: {{ currentProposal.createBy }}</span>
|
||||||
<span>提案类型: {{ currentProposal.regulationType }}</span>
|
<span>提案类型: {{ currentProposal.regulationType }}</span>
|
||||||
<span>适用范围: {{ currentProposal.scope }}</span>
|
<span>适用范围: {{ currentProposal.scope }}</span>
|
||||||
<span>级别: <a-tag :color="getLevelColor(currentProposal.level)">{{ getLevelText(currentProposal.level) }}</a-tag></span>
|
<span>级别: <a-tag :color="getLevelColor(currentProposal.level)">{{ getLevelText(currentProposal.level) }}</a-tag></span>
|
||||||
|
@ -191,7 +193,8 @@ import { regulationApi } from '@/apis/regulation'
|
||||||
import {
|
import {
|
||||||
RegulationStatus,
|
RegulationStatus,
|
||||||
RegulationLevel,
|
RegulationLevel,
|
||||||
type Regulation
|
type Regulation,
|
||||||
|
type RegulationType
|
||||||
} from '@/apis/regulation/type'
|
} from '@/apis/regulation/type'
|
||||||
|
|
||||||
defineOptions({ name: 'ProcessManagement' })
|
defineOptions({ name: 'ProcessManagement' })
|
||||||
|
@ -199,7 +202,7 @@ defineOptions({ name: 'ProcessManagement' })
|
||||||
// 表格列定义
|
// 表格列定义
|
||||||
const columns = [
|
const columns = [
|
||||||
{ title: '提案标题', dataIndex: 'title', key: 'title' },
|
{ title: '提案标题', dataIndex: 'title', key: 'title' },
|
||||||
{ title: '提案人', dataIndex: 'publisherName', key: 'publisherName' },
|
{ title: '提案人', dataIndex: 'createBy', key: 'createBy' },
|
||||||
{ title: '提案类型', dataIndex: 'regulationType', key: 'regulationType' },
|
{ title: '提案类型', dataIndex: 'regulationType', key: 'regulationType' },
|
||||||
{ title: '状态', dataIndex: 'status', key: 'status', slotName: 'status' },
|
{ title: '状态', dataIndex: 'status', key: 'status', slotName: 'status' },
|
||||||
{ title: '级别', dataIndex: 'level', key: 'level', slotName: 'level' },
|
{ title: '级别', dataIndex: 'level', key: 'level', slotName: 'level' },
|
||||||
|
@ -238,12 +241,15 @@ const currentProposal = ref<Regulation | null>(null)
|
||||||
// 详情相关
|
// 详情相关
|
||||||
const detailModalVisible = ref(false)
|
const detailModalVisible = ref(false)
|
||||||
|
|
||||||
// 当前用户 - 应该从用户认证系统获取
|
// 当前用户
|
||||||
const currentUser = ref('') // TODO: 从用户认证系统获取当前用户ID
|
const currentUser = ref('admin') // 从用户认证系统获取当前用户ID
|
||||||
|
|
||||||
// 制度管理store
|
// 制度管理store
|
||||||
const regulationStore = useRegulationStore()
|
const regulationStore = useRegulationStore()
|
||||||
|
|
||||||
|
// 制度类型列表
|
||||||
|
const regulationTypes = ref<RegulationType[]>([])
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const rules = {
|
const rules = {
|
||||||
title: [{ required: true, message: '请输入提案标题' }],
|
title: [{ required: true, message: '请输入提案标题' }],
|
||||||
|
@ -311,6 +317,18 @@ const getLevelText = (level: RegulationLevel) => {
|
||||||
return texts[level] || '中'
|
return texts[level] || '中'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取制度类型列表
|
||||||
|
const getRegulationTypes = async () => {
|
||||||
|
try {
|
||||||
|
const response = await regulationApi.getRegulationTypes()
|
||||||
|
if (response.status === 200) {
|
||||||
|
regulationTypes.value = response.data.records || response.data
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取制度类型列表失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取表格数据
|
// 获取表格数据
|
||||||
const getTableData = async () => {
|
const getTableData = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
@ -450,6 +468,7 @@ const handlePageSizeChange = (pageSize: number) => {
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getTableData()
|
getTableData()
|
||||||
|
getRegulationTypes()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -36,17 +36,19 @@
|
||||||
|
|
||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import SystemRegulation from './system-regulation/index.vue'
|
import SystemRegulation from './repository.vue'
|
||||||
import ProcessManagement from './process-management/index.vue'
|
import RegulationType from './type/index.vue'
|
||||||
|
import ProcessManagement from './confirm.vue'
|
||||||
import { useDevice } from '@/hooks'
|
import { useDevice } from '@/hooks'
|
||||||
|
|
||||||
defineOptions({ name: 'ZhiduManagement' })
|
defineOptions({ name: 'RegulationManagement' })
|
||||||
|
|
||||||
const { isDesktop } = useDevice()
|
const { isDesktop } = useDevice()
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
{ name: '制度规范', key: 'system-regulation', icon: 'file-text', value: SystemRegulation, path: '/zhidu/system-regulation' },
|
{ name: '制度公示', key: 'system-regulation', icon: 'file-text', value: SystemRegulation, path: '/regulation/system-regulation' },
|
||||||
{ name: '流程管理', key: 'process-management', icon: 'workflow', value: ProcessManagement, path: '/zhidu/process-management' },
|
{ name: '制度类型', key: 'type', icon: 'tag', value: RegulationType, path: '/regulation/type' },
|
||||||
|
{ name: '流程管理', key: 'process-management', icon: 'workflow', value: ProcessManagement, path: '/regulation/process-management' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const menuList = computed(() => {
|
const menuList = computed(() => {
|
||||||
|
|
|
@ -22,14 +22,6 @@
|
||||||
<a-button type="text" size="small" @click="handleView(record)">
|
<a-button type="text" size="small" @click="handleView(record)">
|
||||||
查看详情
|
查看详情
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button
|
|
||||||
v-if="record.confirmStatus !== 'confirmed'"
|
|
||||||
type="text"
|
|
||||||
size="small"
|
|
||||||
@click="handleConfirm(record)"
|
|
||||||
>
|
|
||||||
确认知晓
|
|
||||||
</a-button>
|
|
||||||
<a-button type="text" size="small" @click="handleDownload(record)">
|
<a-button type="text" size="small" @click="handleDownload(record)">
|
||||||
下载
|
下载
|
||||||
</a-button>
|
</a-button>
|
||||||
|
@ -49,7 +41,7 @@
|
||||||
<div class="detail-header">
|
<div class="detail-header">
|
||||||
<h3>{{ currentRegulation.title }}</h3>
|
<h3>{{ currentRegulation.title }}</h3>
|
||||||
<div class="detail-meta">
|
<div class="detail-meta">
|
||||||
<span>发布人: {{ currentRegulation.publisherName }}</span>
|
<span>发布人: {{ currentRegulation.createBy }}</span>
|
||||||
<span>发布时间: {{ currentRegulation.publishTime }}</span>
|
<span>发布时间: {{ currentRegulation.publishTime }}</span>
|
||||||
<span>生效日期: {{ currentRegulation.effectiveTime }}</span>
|
<span>生效日期: {{ currentRegulation.effectiveTime }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -121,7 +113,7 @@ defineOptions({ name: 'SystemRegulation' })
|
||||||
const columns = [
|
const columns = [
|
||||||
{ title: '制度名称', dataIndex: 'title', key: 'title' },
|
{ title: '制度名称', dataIndex: 'title', key: 'title' },
|
||||||
{ title: '制度类型', dataIndex: 'regulationType', key: 'regulationType' },
|
{ title: '制度类型', dataIndex: 'regulationType', key: 'regulationType' },
|
||||||
{ title: '发布人', dataIndex: 'publisherName', key: 'publisherName' },
|
{ title: '发布人', dataIndex: 'createBy', key: 'createBy' },
|
||||||
{ title: '发布时间', dataIndex: 'publishTime', key: 'publishTime' },
|
{ title: '发布时间', dataIndex: 'publishTime', key: 'publishTime' },
|
||||||
{ title: '生效日期', dataIndex: 'effectiveTime', key: 'effectiveTime' },
|
{ title: '生效日期', dataIndex: 'effectiveTime', key: 'effectiveTime' },
|
||||||
{ title: '确认状态', dataIndex: 'confirmStatus', key: 'confirmStatus', slotName: 'confirmStatus' },
|
{ title: '确认状态', dataIndex: 'confirmStatus', key: 'confirmStatus', slotName: 'confirmStatus' },
|
||||||
|
@ -207,7 +199,7 @@ const handleDownload = (record: any) => {
|
||||||
const content = `
|
const content = `
|
||||||
制度名称:${record.title}
|
制度名称:${record.title}
|
||||||
制度类型:${record.regulationType}
|
制度类型:${record.regulationType}
|
||||||
发布人:${record.publisherName}
|
发布人:${record.createBy}
|
||||||
发布时间:${record.publishTime}
|
发布时间:${record.publishTime}
|
||||||
生效日期:${record.effectiveTime}
|
生效日期:${record.effectiveTime}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,333 @@
|
||||||
|
<template>
|
||||||
|
<GiPageLayout>
|
||||||
|
<GiTable
|
||||||
|
row-key="typeId"
|
||||||
|
title="制度类型管理"
|
||||||
|
:data="dataList"
|
||||||
|
:columns="tableColumns"
|
||||||
|
:loading="loading"
|
||||||
|
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||||
|
:pagination="pagination"
|
||||||
|
@page-change="onPageChange"
|
||||||
|
@page-size-change="onPageSizeChange"
|
||||||
|
@refresh="search"
|
||||||
|
>
|
||||||
|
<template #top>
|
||||||
|
<GiForm
|
||||||
|
v-model="searchForm"
|
||||||
|
search
|
||||||
|
:columns="queryFormColumns"
|
||||||
|
size="medium"
|
||||||
|
@search="search"
|
||||||
|
@reset="reset"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #toolbar-left>
|
||||||
|
<a-space>
|
||||||
|
<a-button type="primary" @click="openAddModal">
|
||||||
|
<template #icon><icon-plus /></template>
|
||||||
|
<template #default>新增类型</template>
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 启用状态 -->
|
||||||
|
<template #isEnabled="{ record }">
|
||||||
|
<a-tag :color="record.isEnabled === '1' ? 'green' : 'red'">
|
||||||
|
{{ record.isEnabled === '1' ? '启用' : '禁用' }}
|
||||||
|
</a-tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 操作列 -->
|
||||||
|
<template #action="{ record }">
|
||||||
|
<a-space>
|
||||||
|
<a-link @click="editRecord(record)">编辑</a-link>
|
||||||
|
<a-popconfirm
|
||||||
|
content="确定要删除这个制度类型吗?"
|
||||||
|
@ok="deleteRecord(record)"
|
||||||
|
>
|
||||||
|
<a-link status="danger">删除</a-link>
|
||||||
|
</a-popconfirm>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</GiTable>
|
||||||
|
|
||||||
|
<!-- 新增/编辑弹窗 -->
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="modalVisible"
|
||||||
|
:title="modalTitle"
|
||||||
|
width="600px"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
@cancel="handleCancel"
|
||||||
|
>
|
||||||
|
<a-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="rules"
|
||||||
|
layout="vertical"
|
||||||
|
>
|
||||||
|
<a-form-item label="类型名称" field="typeName">
|
||||||
|
<a-input v-model="formData.typeName" placeholder="请输入制度类型名称" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="排序" field="sortOrder">
|
||||||
|
<a-input-number
|
||||||
|
v-model="formData.sortOrder"
|
||||||
|
placeholder="请输入排序值"
|
||||||
|
:min="0"
|
||||||
|
:max="999"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="状态" field="isEnabled">
|
||||||
|
<a-radio-group v-model="formData.isEnabled">
|
||||||
|
<a-radio value="1">启用</a-radio>
|
||||||
|
<a-radio value="0">禁用</a-radio>
|
||||||
|
</a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="备注" field="remark">
|
||||||
|
<a-textarea
|
||||||
|
v-model="formData.remark"
|
||||||
|
placeholder="请输入备注信息"
|
||||||
|
:rows="3"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
</GiPageLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
|
import { Message } from '@arco-design/web-vue'
|
||||||
|
import { regulationApi } from '@/apis/regulation'
|
||||||
|
import {
|
||||||
|
type RegulationType,
|
||||||
|
type CreateRegulationTypeRequest,
|
||||||
|
type UpdateRegulationTypeRequest
|
||||||
|
} from '@/apis/regulation/type'
|
||||||
|
|
||||||
|
defineOptions({ name: 'RegulationType' })
|
||||||
|
|
||||||
|
// 表格列定义
|
||||||
|
const tableColumns = [
|
||||||
|
{ title: '类型名称', dataIndex: 'typeName', key: 'typeName', width: 150 },
|
||||||
|
{ title: '备注', dataIndex: 'remark', key: 'remark', width: 200 },
|
||||||
|
{ title: '状态', dataIndex: 'isEnabled', key: 'isEnabled', slotName: 'isEnabled', width: 100 },
|
||||||
|
{ title: '创建人', dataIndex: 'createBy', key: 'createBy', width: 120 },
|
||||||
|
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
|
||||||
|
{ title: '排序', dataIndex: 'sortOrder', key: 'sortOrder', width: 100 },
|
||||||
|
{ title: '操作', key: 'action', slotName: 'action', width: 150, fixed: 'right' }
|
||||||
|
]
|
||||||
|
|
||||||
|
// 查询表单列定义
|
||||||
|
const queryFormColumns = [
|
||||||
|
{
|
||||||
|
label: '类型名称',
|
||||||
|
field: 'typeName',
|
||||||
|
component: 'a-input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入类型名称'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
field: 'remark',
|
||||||
|
component: 'a-input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注内容'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const dataList = ref<RegulationType[]>([])
|
||||||
|
const loading = ref(false)
|
||||||
|
const pagination = reactive({
|
||||||
|
current: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
showTotal: true,
|
||||||
|
showJumper: true,
|
||||||
|
showPageSize: true
|
||||||
|
})
|
||||||
|
|
||||||
|
// 查询表单
|
||||||
|
const searchForm = reactive({
|
||||||
|
typeName: '',
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
// 弹窗相关
|
||||||
|
const modalVisible = ref(false)
|
||||||
|
const modalTitle = ref('新增制度类型')
|
||||||
|
const formRef = ref()
|
||||||
|
const formData = reactive({
|
||||||
|
typeId: '',
|
||||||
|
typeName: '',
|
||||||
|
sortOrder: 0,
|
||||||
|
isEnabled: '1',
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表单验证规则
|
||||||
|
const rules = {
|
||||||
|
typeName: [{ required: true, message: '请输入制度类型名称' }],
|
||||||
|
sortOrder: [{ required: true, message: '请输入排序值' }],
|
||||||
|
isEnabled: [{ required: true, message: '请选择状态' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取表格数据
|
||||||
|
const getTableData = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const response = await regulationApi.getRegulationTypes({
|
||||||
|
page: pagination.current,
|
||||||
|
size: pagination.pageSize,
|
||||||
|
typeName: searchForm.typeName || undefined,
|
||||||
|
remark: searchForm.remark || undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
dataList.value = response.data.records || response.data
|
||||||
|
pagination.total = response.data.total || response.data.length
|
||||||
|
pagination.current = response.data.current || 1
|
||||||
|
} else {
|
||||||
|
Message.error('获取数据失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取制度类型列表失败:', error)
|
||||||
|
Message.error('获取数据失败')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
const search = () => {
|
||||||
|
pagination.current = 1
|
||||||
|
getTableData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
Object.assign(searchForm, {
|
||||||
|
typeName: '',
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
pagination.current = 1
|
||||||
|
getTableData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页事件
|
||||||
|
const onPageChange = (page: number) => {
|
||||||
|
pagination.current = page
|
||||||
|
getTableData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const onPageSizeChange = (pageSize: number) => {
|
||||||
|
pagination.pageSize = pageSize
|
||||||
|
pagination.current = 1
|
||||||
|
getTableData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
const openAddModal = () => {
|
||||||
|
modalTitle.value = '新增制度类型'
|
||||||
|
modalVisible.value = true
|
||||||
|
resetForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
const editRecord = (record: RegulationType) => {
|
||||||
|
modalTitle.value = '编辑制度类型'
|
||||||
|
modalVisible.value = true
|
||||||
|
Object.assign(formData, {
|
||||||
|
typeId: record.typeId,
|
||||||
|
typeName: record.typeName,
|
||||||
|
sortOrder: record.sortOrder,
|
||||||
|
isEnabled: record.isEnabled,
|
||||||
|
remark: record.remark || ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
const deleteRecord = async (record: RegulationType) => {
|
||||||
|
try {
|
||||||
|
await regulationApi.deleteRegulationType(record.typeId)
|
||||||
|
Message.success('删除成功')
|
||||||
|
getTableData()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('删除失败:', error)
|
||||||
|
Message.error('删除失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
try {
|
||||||
|
await formRef.value.validate()
|
||||||
|
|
||||||
|
if (formData.typeId) {
|
||||||
|
// 更新
|
||||||
|
const updateData: UpdateRegulationTypeRequest = {
|
||||||
|
typeName: formData.typeName,
|
||||||
|
sortOrder: formData.sortOrder,
|
||||||
|
isEnabled: formData.isEnabled,
|
||||||
|
remark: formData.remark
|
||||||
|
}
|
||||||
|
await regulationApi.updateRegulationType(formData.typeId, updateData)
|
||||||
|
Message.success('更新成功')
|
||||||
|
} else {
|
||||||
|
// 新增
|
||||||
|
const createData: CreateRegulationTypeRequest = {
|
||||||
|
typeName: formData.typeName,
|
||||||
|
sortOrder: formData.sortOrder,
|
||||||
|
isEnabled: formData.isEnabled,
|
||||||
|
remark: formData.remark
|
||||||
|
}
|
||||||
|
await regulationApi.createRegulationType(createData)
|
||||||
|
Message.success('新增成功')
|
||||||
|
}
|
||||||
|
|
||||||
|
modalVisible.value = false
|
||||||
|
getTableData()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('操作失败:', error)
|
||||||
|
Message.error('操作失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消
|
||||||
|
const handleCancel = () => {
|
||||||
|
modalVisible.value = false
|
||||||
|
resetForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置表单
|
||||||
|
const resetForm = () => {
|
||||||
|
Object.assign(formData, {
|
||||||
|
typeId: '',
|
||||||
|
typeName: '',
|
||||||
|
sortOrder: 0,
|
||||||
|
isEnabled: '1',
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getTableData()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.regulation-type {
|
||||||
|
.arco-card {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in New Issue