25 changed files with 437 additions and 68 deletions
@ -0,0 +1,54 @@
|
||||
<template> |
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> |
||||
<BasicForm @register="registerForm" /> |
||||
</BasicModal> |
||||
</template> |
||||
<script lang="ts" setup name="FileConfigModal"> |
||||
import { ref, computed, unref } from 'vue' |
||||
import { BasicModal, useModalInner } from '@/components/Modal' |
||||
import { BasicForm, useForm } from '@/components/Form' |
||||
import { formSchema } from './ficleConfig.data' |
||||
import { createFileConfigApi, getFileConfigApi, updateFileConfigApi } from '@/api/infra/fileConfig' |
||||
|
||||
const emit = defineEmits(['success', 'register']) |
||||
const isUpdate = ref(true) |
||||
const rowId = ref() |
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ |
||||
labelWidth: 100, |
||||
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 getFileConfigApi(data.record.id) |
||||
rowId.value = res.id |
||||
setFieldsValue({ ...res }) |
||||
} |
||||
}) |
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增文件配置' : '编辑文件配置')) |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
const values = await validate() |
||||
setModalProps({ confirmLoading: true }) |
||||
if (unref(isUpdate)) { |
||||
await updateFileConfigApi(values) |
||||
} else { |
||||
await createFileConfigApi(values) |
||||
} |
||||
closeModal() |
||||
emit('success') |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }) |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,178 @@
|
||||
import { BasicColumn, FormSchema, useRender } from '@/components/Table' |
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
||||
|
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '编号', |
||||
dataIndex: 'id', |
||||
width: 100 |
||||
}, |
||||
{ |
||||
title: '配置名', |
||||
dataIndex: 'name', |
||||
width: 180 |
||||
}, |
||||
{ |
||||
title: '存储器', |
||||
dataIndex: 'storage', |
||||
width: 100, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDict(text, DICT_TYPE.INFRA_FILE_STORAGE) |
||||
} |
||||
}, |
||||
{ |
||||
title: '主配置', |
||||
dataIndex: 'master', |
||||
width: 180, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDict(text, DICT_TYPE.INFRA_BOOLEAN_STRING) |
||||
} |
||||
}, |
||||
{ |
||||
title: '备注', |
||||
dataIndex: 'remark', |
||||
width: 180 |
||||
}, |
||||
{ |
||||
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: 'storage', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getIntDictOptions(DICT_TYPE.INFRA_FILE_STORAGE) |
||||
}, |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '创建时间', |
||||
field: 'createTime', |
||||
component: 'RangePicker', |
||||
colProps: { span: 8 } |
||||
} |
||||
] |
||||
|
||||
export const formSchema: FormSchema[] = [ |
||||
{ |
||||
label: '编号', |
||||
field: 'id', |
||||
show: false, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '配置名', |
||||
field: 'name', |
||||
required: true, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '存储器', |
||||
field: 'storage', |
||||
component: 'Select', |
||||
required: true, |
||||
dynamicDisabled: ({ values }) => !!values.id, |
||||
componentProps: { |
||||
options: getIntDictOptions(DICT_TYPE.INFRA_FILE_STORAGE) |
||||
} |
||||
}, |
||||
{ |
||||
label: '基础路径', |
||||
field: 'config.basePath', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage >= 10 && values.storage <= 12, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '主机地址', |
||||
field: 'config.host', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage >= 11 && values.storage <= 12, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '主机端口', |
||||
field: 'config.port', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage >= 11 && values.storage <= 12, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '用户名', |
||||
field: 'config.username', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage >= 11 && values.storage <= 12, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '密码', |
||||
field: 'config.password', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage >= 11 && values.storage <= 12, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '连接模式', |
||||
field: 'config.basePath', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage === 11, |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: [ |
||||
{ lable: '主动模式', key: 'Active', value: 'Active' }, |
||||
{ lable: '被动模式', key: 'Passive', value: 'Passive' } |
||||
] |
||||
} |
||||
}, |
||||
{ |
||||
label: '节点地址', |
||||
field: 'config.endpoint', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage === 20, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '存储 bucket', |
||||
field: 'config.bucket', |
||||
required: true, |
||||
ifShow: ({ values }) => values.storage === 20, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: 'accessKey', |
||||
field: 'config.accessKey', |
||||
ifShow: ({ values }) => values.storage === 20, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: 'accessSecret', |
||||
field: 'config.accessSecret', |
||||
ifShow: ({ values }) => values.storage === 20, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '自定义域名', |
||||
field: 'config.domain', |
||||
required: true, |
||||
component: 'Input' |
||||
}, |
||||
{ |
||||
label: '备注', |
||||
field: 'remark', |
||||
component: 'InputTextArea' |
||||
} |
||||
] |
@ -1,3 +1,100 @@
|
||||
<template> |
||||
<div>开发中</div> |
||||
<div> |
||||
<BasicTable @register="registerTable"> |
||||
<template #toolbar> |
||||
<a-button type="primary" :preIcon="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'), onClick: handleEdit.bind(null, record) }, |
||||
{ icon: IconEnum.TEST, label: t('action.test'), onClick: handleTest.bind(null, record) }, |
||||
{ icon: IconEnum.AUTH, label: '主配置', onClick: handleMaster.bind(null, record) }, |
||||
{ |
||||
icon: IconEnum.DELETE, |
||||
color: 'error', |
||||
label: t('action.delete'), |
||||
popConfirm: { |
||||
title: t('common.delMessage'), |
||||
placement: 'left', |
||||
confirm: handleDelete.bind(null, record) |
||||
} |
||||
} |
||||
]" |
||||
/> |
||||
</template> |
||||
</template> |
||||
</BasicTable> |
||||
<PostModal @register="registerModal" @success="reload()" /> |
||||
</div> |
||||
</template> |
||||
<script lang="ts" setup name="FileConfig"> |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { useModal } from '@/components/Modal' |
||||
import PostModal from './FileConfigModal.vue' |
||||
import { IconEnum } from '@/enums/appEnum' |
||||
import { BasicTable, useTable, TableAction } from '@/components/Table' |
||||
import { deleteFileConfigApi, getFileConfigPageApi, testFileConfigApi, updateFileConfigMasterApi } from '@/api/infra/fileConfig' |
||||
import { columns, searchFormSchema } from './ficleConfig.data' |
||||
|
||||
const { t } = useI18n() |
||||
const { createConfirm, createMessage, createSuccessModal } = useMessage() |
||||
const [registerModal, { openModal }] = useModal() |
||||
|
||||
const [registerTable, { reload }] = useTable({ |
||||
title: '文件配置列表', |
||||
api: getFileConfigPageApi, |
||||
columns, |
||||
formConfig: { |
||||
labelWidth: 120, |
||||
schemas: searchFormSchema |
||||
}, |
||||
useSearchForm: true, |
||||
showTableSetting: true, |
||||
showIndexColumn: false, |
||||
actionColumn: { |
||||
width: 240, |
||||
title: t('common.action'), |
||||
dataIndex: 'action', |
||||
fixed: 'right' |
||||
} |
||||
}) |
||||
|
||||
function handleCreate() { |
||||
openModal(true, { |
||||
isUpdate: false |
||||
}) |
||||
} |
||||
|
||||
function handleEdit(record: Recordable) { |
||||
openModal(true, { |
||||
record, |
||||
isUpdate: true |
||||
}) |
||||
} |
||||
|
||||
async function handleTest(record: Recordable) { |
||||
const res = await testFileConfigApi(record.id) |
||||
createSuccessModal({ content: res }) |
||||
} |
||||
|
||||
function handleMaster(record: Recordable) { |
||||
createConfirm({ |
||||
title: '主配置', |
||||
iconType: 'warning', |
||||
content: '是否确认修改配置编号为"' + record.id + '"的数据项为主配置?', |
||||
async onOk() { |
||||
await updateFileConfigMasterApi(record.id) |
||||
createMessage.success('配置成功') |
||||
} |
||||
}) |
||||
} |
||||
|
||||
async function handleDelete(record: Recordable) { |
||||
await deleteFileConfigApi(record.id) |
||||
createMessage.success(t('common.delSuccessText')) |
||||
reload() |
||||
} |
||||
</script> |
||||
|
Reference in new issue