Browse Source

Merge pull request 'feat:集团配置' (#21) from YKS into master

Reviewed-on: http://120.26.116.243:3000/root/alert-front/pulls/21
pull/25/head
chenjiale 2 months ago
parent
commit
3e9cb3698a
  1. 4
      pnpm-lock.yaml
  2. 39
      src/api/system/unit/Company.ts
  3. 79
      src/views/system/unit/Company/Company.ts
  4. 63
      src/views/system/unit/Company/CompanyModal.vue
  5. 89
      src/views/system/unit/Company/index.vue

4
pnpm-lock.yaml

@ -1400,25 +1400,21 @@ packages:
resolution: {integrity: sha512-2hBHEtCjnBTeuLvDAlHRCqsuFQSyAhTQs9vbZEVBTV8ap35pDI1ukPbIVFFCWNvL/KE7xRor5YZFvfyGCfvLnA==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.4.0':
resolution: {integrity: sha512-u7zy0Ygzl7O5Gvr9TSNSQj+DBzvMJC7rXfyQNgZ13KwkhgJ8z0z+gt2AO4RPd01rZioMQ2/TA24XGGg4xqhd0Q==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-x64-gnu@4.4.0':
resolution: {integrity: sha512-VvpAdh5SgewmWo8sa5QPYG8aSKH9hU2Kr5+3of0GzBI/8n8PBqhLyvF0DbO+zDW8j5IM8NDebv82MpHrZaD0Cw==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.4.0':
resolution: {integrity: sha512-3g6jaXxXVFaDnFoMn2+E3ludGcXFfEr6lDn+S1lh9Qe0JcL9sPt1wGh0g2cKIlb6OakNOFopZqJ5Yub9F7gQlA==}
cpu: [x64]
os: [linux]
libc: [musl]
'@rollup/rollup-win32-arm64-msvc@4.4.0':
resolution: {integrity: sha512-jnoDRkg5Ve6Y1qx2m1+ehouOLQ4ddc15/iQSfFjcDUL6bqLdJJ5c4CKfUy/C6W1oCU4la+hMkveE9GG7ECN7dg==}

39
src/api/system/unit/Company.ts

@ -0,0 +1,39 @@
import { defHttp } from '@/utils/http/axios'
export interface CompanyVO {
id?: number
name: string // 集团名称
short: string // 集团简称
status: number // 状态
createTime: Date // 创建时间
}
export interface CompanyPageReqVO {
name?: string
status?: number
}
// 查询集团列表
export function getCompanyPage(params: CompanyPageReqVO) {
return defHttp.get({ url: '/system/Company/page', params })
}
// 查询集团详情
export function getCompany(id: number) {
return defHttp.get({ url: `/system/Company/get?id=${id}` })
}
// 新增集团
export function createCompany(data: CompanyVO) {
return defHttp.post({ url: '/system/Company/create', data })
}
// 修改集团
export function updateCompany(params: CompanyVO) {
return defHttp.put({ url: '/system/Company/update', data: params })
}
// 删除集团
export function deleteCompany(id: number) {
return defHttp.delete({ url: `/system/Company/delete?id=${id}` })
}

79
src/views/system/unit/Company/Company.ts

@ -0,0 +1,79 @@
import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
export const columns: BasicColumn[] = [
{
title: '集团名称',
dataIndex: 'name',
width: 260,
},
{
title: '集团简称',
dataIndex: 'shortName', // 注意:后端是 shortName,不是 short!
width: 60,
},
{
title: '状态',
dataIndex: 'status',
width: 180,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS)
},
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 180,
customRender: ({ text }) => {
return useRender.renderDate(text)
},
},
]
export const searchFormSchema: FormSchema[] = [
{
label: '集团名称',
field: 'name',
component: 'Input',
colProps: { span: 8 },
},
{
label: '状态',
field: 'status',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS),
},
colProps: { span: 8 },
},
]
export const formSchema: FormSchema[] = [
{
label: '编号',
field: 'id',
show: false,
component: 'Input',
},
{
label: '集团名称',
field: 'name',
required: true,
component: 'Input',
},
{
label: '集团简称',
field: 'shortName', // 注意:后端是 shortName,不是 short!
required: true,
component: 'Input',
},
{
label: '集团状态',
field: 'status',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS),
},
},
]

63
src/views/system/unit/Company/CompanyModal.vue

@ -0,0 +1,63 @@
<script lang="ts" setup>
import { ref, unref } from 'vue'
import { formSchema } from './Company'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { BasicForm, useForm } from '@/components/Form'
import { BasicModal, useModalInner } from '@/components/Modal'
import { createCompany, getCompany, updateCompany } from '@/api/system/unit/Company'
defineOptions({ name: 'CompanyModal' })
const emit = defineEmits(['success', 'register'])
const { t } = useI18n()
const { createMessage } = useMessage()
const isUpdate = ref(true)
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
labelWidth: 120,
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: { span: 23 },
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields()
setModalProps({ confirmLoading: false })
isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) {
const res = await getCompany(data.record.id)
setFieldsValue({ ...res })
}
})
async function handleSubmit() {
try {
const values = await validate()
setModalProps({ confirmLoading: true })
if (unref(isUpdate))
await updateCompany(values)
else
await createCompany(values)
closeModal()
emit('success')
createMessage.success(t('common.saveSuccessText'))
}
finally {
setModalProps({ confirmLoading: false })
}
}
</script>
<template>
<BasicModal
v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" @register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm" />
</BasicModal>
</template>
./Company
@/api/system/unit/Company

89
src/views/system/unit/Company/index.vue

@ -0,0 +1,89 @@
<script lang="ts" setup>
import CompanyModal from './CompanyModal.vue'
import { columns, searchFormSchema } from './Company'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { useModal } from '@/components/Modal'
import { IconEnum } from '@/enums/appEnum'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { deleteCompany, getCompanyPage } from '@/api/system/unit/Company'
defineOptions({ name: 'UnitCompany' })
const { t } = useI18n()
const { createMessage } = useMessage()
const [registerModal, { openModal }] = useModal()
// expandAll, collapseAll
const [register, { getForm, reload }] = useTable({
title: '集团列表',
api: getList,
columns,
rowKey: 'id',
formConfig: { labelWidth: 120, schemas: searchFormSchema },
pagination: true,
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 140,
title: t('common.action'),
dataIndex: 'action',
fixed: 'right',
},
})
async function getList() {
const res = await getCompanyPage(getForm().getFieldsValue() as any)
return res
}
function handleCreate() {
openModal(true, { isUpdate: false })
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true })
}
async function handleDelete(record: Recordable) {
await deleteCompany(record.id)
createMessage.success(t('common.delSuccessText'))
reload()
}
</script>
<template>
<div>
<BasicTable @register="register">
<template #toolbar>
<a-button v-auth="['system:unit:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:unit:update', onClick: handleEdit.bind(null, record) },
{
icon: IconEnum.DELETE,
danger: true,
label: t('action.delete'),
auth: 'system:unit:delete',
popConfirm: {
title: t('common.delMessage'),
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</template>
</BasicTable>
<CompanyModal @register="registerModal" @success="reload()" />
</div>
</template>
./Company
@/api/system/unit/Company
Loading…
Cancel
Save