初始版本提交

This commit is contained in:
yaoyn
2024-02-05 09:15:37 +08:00
parent b52d4414be
commit 445292105f
1848 changed files with 236859 additions and 75 deletions

View File

@ -0,0 +1,3 @@
import { withInstall } from '/@/utils';
import categoryModal from './src/CategoryModal.vue';
export const CategoryModal = withInstall(categoryModal); //分类管理

View File

@ -0,0 +1,136 @@
<template>
<BasicModal @register="registerCategoryModal" v-bind="$attrs" wrapClassName="category-modal">
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleCreate">
<template #icon><PlusOutlined /></template>
{{ t('新增') }}
</a-button>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record),
},
{
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: t('是否确认删除'),
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</BasicTable>
</BasicModal>
<ChangeCategoryModal
:title="title"
:dicId="props.dicId"
@register="registerChangeModal"
@success="handleSuccess"
/>
</template>
<script lang="ts" setup>
import { BasicModal, useModal, useModalInner } from '/@/components/Modal';
import { PlusOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
import ChangeCategoryModal from './ChangeCategoryModal.vue';
import { getDicDetailList, deleteDicDetail } from '/@/api/system/dic';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
const props = defineProps({
dicId: String,
title: String,
});
const columns: BasicColumn[] = [
{
dataIndex: 'name',
title: t(props.title + '分类名称'),
},
{
dataIndex: 'code',
title: t(props.title + '分类编码'),
},
{
dataIndex: 'sortCode',
title: t('排序'),
width: 70,
},
{
dataIndex: 'enabledMark',
title: t('是否有效'),
customRender: ({ record }) => `${record.enabledMark ? t('有效') : t('无效')}`,
width: 100,
},
{
dataIndex: 'remark',
title: t('备注'),
},
];
const emits = defineEmits(['success', 'register']);
const { notification } = useMessage();
const [registerCategoryModal, { setModalProps }] = useModalInner(async (data) => {
setModalProps({
confirmLoading: false,
draggable: false,
title: data.title,
showOkBtn: false,
showCancelBtn: false,
destroyOnClose: true,
width: 800,
fixedHeight: true,
});
});
const [registerTable, { reload }] = useTable({
api: getDicDetailList,
beforeFetch: () => {
return { itemId: props.dicId };
},
rowKey: 'id',
columns,
showTableSetting: true,
bordered: true,
actionColumn: {
width: 80,
title: t('操作'),
dataIndex: 'action',
slots: { customRender: 'action' },
},
});
const [registerChangeModal, { openModal: openChangeModal }] = useModal();
const handleCreate = () => {
openChangeModal(true, { title: t('新增' + props.title + '分类') });
};
const handleEdit = (record) => {
openChangeModal(true, { title: t('修改' + props.title + '分类'), info: record });
};
const handleDelete = async (record) => {
await deleteDicDetail([record.id]);
notification.success({
message: t('提示'),
description: t('删除成功'),
});
emits('success');
reload();
};
const handleSuccess = () => {
emits('success');
reload();
};
</script>
<style lang="less" scoped>
:deep(.vben-basic-table-header__toolbar) {
justify-content: space-between;
}
</style>

View File

@ -0,0 +1,106 @@
<template>
<BasicModal @register="registerChangeModal" @ok="handleSubmit" v-bind="$attrs">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
import { useMessage } from '/@/hooks/web/useMessage';
import { addDicDetail, updateDicDetail } from '/@/api/system/dic';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
const props = defineProps({
dicId: String,
title: String,
});
const formSchema: FormSchema[] = [
{
field: 'name',
label: t(props.title + '分类名称'),
required: true,
component: 'Input',
componentProps: {
placeholder: t('请填写名称'),
},
colProps: { span: 24 },
},
{
field: 'code',
label: t(props.title + '分类编码'),
required: true,
component: 'Input',
componentProps: {
placeholder: t('请填写编码'),
},
colProps: { span: 24 },
},
{
field: 'sortCode',
label: t('排序'),
required: true,
component: 'InputNumber',
componentProps: {
style: { width: '100%' },
placeholder: t('请填写排序'),
},
colProps: { span: 24 },
},
{
label: t('备注'),
field: 'remark',
component: 'InputTextArea',
componentProps: {
placeholder: t('请填写备注'),
},
colProps: { span: 24 },
},
];
const { notification } = useMessage();
const editItemId = ref<string>('');
const emits = defineEmits(['success', 'register']);
const [registerChangeModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
editItemId.value = data.info?.id || '';
if (data.info) {
//编辑赋值
setFieldsValue(data.info);
}
console.log('editItemId', data.info, editItemId.value);
setModalProps({
confirmLoading: false,
canFullscreen: false,
draggable: false,
title: data.title,
destroyOnClose: true,
width: 450,
});
});
const [registerForm, { setFieldsValue, validate }] = useForm({
schemas: formSchema,
showActionButtonGroup: false,
labelCol: { span: 7 },
});
const handleSubmit = async () => {
const values = await validate();
values.itemId = props.dicId;
values.value = values.code;
if (editItemId.value) {
values.id = editItemId.value;
await updateDicDetail(values);
} else {
await addDicDetail(values);
}
closeModal();
emits('success');
notification.success({
message: t('提示'),
description: `${editItemId.value ? t('修改') : t('新增')}` + t('成功'),
});
};
</script>