初始化项目
This commit is contained in:
55
web-vue/packages/erp/api/erp/account.ts
Normal file
55
web-vue/packages/erp/api/erp/account.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
*/
|
||||
import { defHttp } from '@jeesite/core/utils/http/axios';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
|
||||
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
|
||||
import { UploadFileParams } from '@jeesite/types/axios';
|
||||
import { AxiosProgressEvent } from 'axios';
|
||||
|
||||
const { ctxPath, adminPath } = useGlobSetting();
|
||||
|
||||
export interface ErpAccount extends BasicModel<ErpAccount> {
|
||||
createTime?: string; // 记录时间
|
||||
accountId?: string; // 账户标识
|
||||
accountName: string; // 账户名称
|
||||
accountType: string; // 账户类型
|
||||
accountCode: string; // 账户卡号
|
||||
initialBalance: number; // 初始余额
|
||||
currentBalance: number; // 当前余额
|
||||
isActive: string; // 是否激活
|
||||
updateTime?: string; // 更新时间
|
||||
}
|
||||
|
||||
export const erpAccountList = (params?: ErpAccount | any) =>
|
||||
defHttp.get<ErpAccount>({ url: adminPath + '/erp/account/list', params });
|
||||
|
||||
export const erpAccountListAll = (params?: ErpAccount | any) =>
|
||||
defHttp.get<ErpAccount[]>({ url: adminPath + '/erp/account/listAll', params });
|
||||
|
||||
export const erpAccountListData = (params?: ErpAccount | any) =>
|
||||
defHttp.post<Page<ErpAccount>>({ url: adminPath + '/erp/account/listData', params });
|
||||
|
||||
export const erpAccountForm = (params?: ErpAccount | any) =>
|
||||
defHttp.get<ErpAccount>({ url: adminPath + '/erp/account/form', params });
|
||||
|
||||
export const erpAccountSave = (params?: any, data?: ErpAccount | any) =>
|
||||
defHttp.postJson<ErpAccount>({ url: adminPath + '/erp/account/save', params, data });
|
||||
|
||||
export const erpAccountImportData = (
|
||||
params: UploadFileParams,
|
||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
|
||||
) =>
|
||||
defHttp.uploadFile<UploadApiResult>(
|
||||
{
|
||||
url: ctxPath + adminPath + '/erp/account/importData',
|
||||
onUploadProgress,
|
||||
},
|
||||
params,
|
||||
);
|
||||
|
||||
export const erpAccountDelete = (params?: ErpAccount | any) =>
|
||||
defHttp.get<ErpAccount>({ url: adminPath + '/erp/account/delete', params });
|
||||
51
web-vue/packages/erp/api/erp/category.ts
Normal file
51
web-vue/packages/erp/api/erp/category.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
*/
|
||||
import { defHttp } from '@jeesite/core/utils/http/axios';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
|
||||
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
|
||||
import { UploadFileParams } from '@jeesite/types/axios';
|
||||
import { AxiosProgressEvent } from 'axios';
|
||||
|
||||
const { ctxPath, adminPath } = useGlobSetting();
|
||||
|
||||
export interface ErpCategory extends BasicModel<ErpCategory> {
|
||||
createTime?: string; // 记录时间
|
||||
categoryId?: string; // 分类标识
|
||||
parentName: string; // 父级名称
|
||||
categoryName: string; // 分类名称
|
||||
categoryType: string; // 分类类型
|
||||
sortOrder: number; // 排序序号
|
||||
isActive: string; // 是否启用
|
||||
updateTime?: string; // 更新时间
|
||||
}
|
||||
|
||||
export const erpCategoryList = (params?: ErpCategory | any) =>
|
||||
defHttp.get<ErpCategory>({ url: adminPath + '/erp/category/list', params });
|
||||
|
||||
export const erpCategoryListData = (params?: ErpCategory | any) =>
|
||||
defHttp.post<Page<ErpCategory>>({ url: adminPath + '/erp/category/listData', params });
|
||||
|
||||
export const erpCategoryForm = (params?: ErpCategory | any) =>
|
||||
defHttp.get<ErpCategory>({ url: adminPath + '/erp/category/form', params });
|
||||
|
||||
export const erpCategorySave = (params?: any, data?: ErpCategory | any) =>
|
||||
defHttp.postJson<ErpCategory>({ url: adminPath + '/erp/category/save', params, data });
|
||||
|
||||
export const erpCategoryImportData = (
|
||||
params: UploadFileParams,
|
||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
|
||||
) =>
|
||||
defHttp.uploadFile<UploadApiResult>(
|
||||
{
|
||||
url: ctxPath + adminPath + '/erp/category/importData',
|
||||
onUploadProgress,
|
||||
},
|
||||
params,
|
||||
);
|
||||
|
||||
export const erpCategoryDelete = (params?: ErpCategory | any) =>
|
||||
defHttp.get<ErpCategory>({ url: adminPath + '/erp/category/delete', params });
|
||||
149
web-vue/packages/erp/views/erp/account/form.vue
Normal file
149
web-vue/packages/erp/views/erp/account/form.vue
Normal file
@@ -0,0 +1,149 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<BasicDrawer
|
||||
v-bind="$attrs"
|
||||
:showFooter="true"
|
||||
:okAuth="'erp:account:edit'"
|
||||
@register="registerDrawer"
|
||||
@ok="handleSubmit"
|
||||
width="70%"
|
||||
>
|
||||
<template #title>
|
||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
||||
<span> {{ getTitle.value }} </span>
|
||||
</template>
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicDrawer>
|
||||
</template>
|
||||
<script lang="ts" setup name="ViewsErpAccountForm">
|
||||
import { ref, unref, computed } from 'vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicForm, FormSchema, useForm } from '@jeesite/core/components/Form';
|
||||
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
|
||||
import { ErpAccount, erpAccountSave, erpAccountForm } from '@jeesite/erp/api/erp/account';
|
||||
import { formatToDateTime } from '@jeesite/core/utils/dateUtil';
|
||||
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
|
||||
const { t } = useI18n('erp.account');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<ErpAccount>({} as ErpAccount);
|
||||
|
||||
const getTitle = computed(() => ({
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
value: record.value.isNewRecord ? t('新增账户') : t('编辑账户'),
|
||||
}));
|
||||
|
||||
const inputFormSchemas: FormSchema<ErpAccount>[] = [
|
||||
{
|
||||
label: t('基本信息'),
|
||||
field: 'basicInfo',
|
||||
component: 'FormGroup',
|
||||
colProps: { md: 24, lg: 24 },
|
||||
},
|
||||
{
|
||||
label: t('账户名称'),
|
||||
field: 'accountName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 100,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('账户类型'),
|
||||
field: 'accountType',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 12,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('账户卡号'),
|
||||
field: 'accountCode',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 32,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('初始余额'),
|
||||
field: 'initialBalance',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 10,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('当前余额'),
|
||||
field: 'currentBalance',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 10,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('是否激活'),
|
||||
field: 'isActive',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 12,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<ErpAccount>({
|
||||
labelWidth: 120,
|
||||
schemas: inputFormSchemas,
|
||||
baseColProps: { md: 24, lg: 12 },
|
||||
});
|
||||
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
setDrawerProps({ loading: true });
|
||||
await resetFields();
|
||||
const res = await erpAccountForm(data);
|
||||
record.value = (res.erpAccount || {}) as ErpAccount;
|
||||
record.value.__t = new Date().getTime();
|
||||
await setFieldsValue(record.value);
|
||||
setDrawerProps({ loading: false });
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const data = await validate();
|
||||
setDrawerProps({ confirmLoading: true });
|
||||
const params: any = {
|
||||
isNewRecord: record.value.isNewRecord,
|
||||
accountId: record.value.accountId || data.accountId,
|
||||
};
|
||||
|
||||
data[record.value.isNewRecord ? 'createTime' : 'updateTime'] = formatToDateTime(new Date());
|
||||
|
||||
// console.log('submit', params, data, record);
|
||||
const res = await erpAccountSave(params, data);
|
||||
showMessage(res.message);
|
||||
setTimeout(closeDrawer);
|
||||
emit('success', data);
|
||||
} catch (error: any) {
|
||||
if (error && error.errorFields) {
|
||||
showMessage(error.message || t('common.validateError'));
|
||||
}
|
||||
console.log('error', error);
|
||||
} finally {
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
221
web-vue/packages/erp/views/erp/account/list.vue
Normal file
221
web-vue/packages/erp/views/erp/account/list.vue
Normal file
@@ -0,0 +1,221 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #tableTitle>
|
||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
||||
<span> {{ getTitle.value }} </span>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<a-button type="default" :loading="loading" @click="handleExport()">
|
||||
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
|
||||
</a-button>
|
||||
<a-button type="primary" @click="handleForm({})" v-auth="'erp:account:edit'">
|
||||
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
|
||||
</a-button>
|
||||
</template>
|
||||
<template #bizScopeKey="{ record, text, value }">
|
||||
<a @click="handleForm({ accountId: record.accountId })" :title="value">
|
||||
{{ text }}
|
||||
</a>
|
||||
</template>
|
||||
<template #bankCard="{ text }">
|
||||
{{ desensitizeBankCard(text) }}
|
||||
</template>
|
||||
</BasicTable>
|
||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="ViewsErpAccountList">
|
||||
import { onMounted, ref, unref } from 'vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
|
||||
import { ErpAccount, erpAccountList } from '@jeesite/erp/api/erp/account';
|
||||
import { erpAccountDelete, erpAccountListData } from '@jeesite/erp/api/erp/account';
|
||||
import { useDrawer } from '@jeesite/core/components/Drawer';
|
||||
import { useModal } from '@jeesite/core/components/Modal';
|
||||
import { FormProps } from '@jeesite/core/components/Form';
|
||||
import InputForm from './form.vue';
|
||||
import { desensitizeBankCard } from '@jeesite/core/utils/desensitize';
|
||||
|
||||
const { t } = useI18n('erp.account');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<ErpAccount>({} as ErpAccount);
|
||||
|
||||
const getTitle = {
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
value: meta.title || t('账户管理'),
|
||||
};
|
||||
const loading = ref(false);
|
||||
|
||||
const searchForm: FormProps<ErpAccount> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('账户名称'),
|
||||
field: 'accountName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('账户类型'),
|
||||
field: 'accountType',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('是否激活'),
|
||||
field: 'isActive',
|
||||
component: 'Input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<ErpAccount>[] = [
|
||||
{
|
||||
title: t('记录时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 150,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('账户名称'),
|
||||
dataIndex: 'accountName',
|
||||
key: 'a.account_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
slot: 'bizScopeKey',
|
||||
},
|
||||
{
|
||||
title: t('账户类型'),
|
||||
dataIndex: 'accountType',
|
||||
key: 'a.account_type',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('账户卡号'),
|
||||
dataIndex: 'accountCode',
|
||||
key: 'a.account_code',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
slot: 'bankCard',
|
||||
},
|
||||
{
|
||||
title: t('初始余额'),
|
||||
dataIndex: 'initialBalance',
|
||||
key: 'a.initial_balance',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('当前余额'),
|
||||
dataIndex: 'currentBalance',
|
||||
key: 'a.current_balance',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('是否激活'),
|
||||
dataIndex: 'isActive',
|
||||
key: 'a.is_active',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 150,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const actionColumn: BasicColumn<ErpAccount> = {
|
||||
width: 160,
|
||||
align: 'center',
|
||||
actions: (record: ErpAccount) => [
|
||||
{
|
||||
icon: 'i-clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleForm.bind(this, { accountId: record.accountId }),
|
||||
auth: 'erp:account:edit',
|
||||
},
|
||||
{
|
||||
icon: 'i-ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除账户?'),
|
||||
confirm: handleDelete.bind(this, record),
|
||||
},
|
||||
auth: 'erp:account:edit',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const [registerTable, { reload, getForm }] = useTable<ErpAccount>({
|
||||
api: erpAccountListData,
|
||||
beforeFetch: (params) => {
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
actionColumn: actionColumn,
|
||||
formConfig: searchForm,
|
||||
showTableSetting: true,
|
||||
useSearchForm: true,
|
||||
canResize: true,
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
const res = await erpAccountList();
|
||||
record.value = (res.erpAccount || {}) as ErpAccount;
|
||||
await getForm().setFieldsValue(record.value);
|
||||
});
|
||||
|
||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
||||
|
||||
function handleForm(record: Recordable) {
|
||||
openDrawer(true, record);
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
loading.value = true;
|
||||
const { ctxAdminPath } = useGlobSetting();
|
||||
await downloadByUrl({
|
||||
url: ctxAdminPath + '/erp/account/exportData',
|
||||
params: getForm().getFieldsValue(),
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
const params = { accountId: record.accountId };
|
||||
const res = await erpAccountDelete(params);
|
||||
showMessage(res.message);
|
||||
await handleSuccess(record);
|
||||
}
|
||||
|
||||
async function handleSuccess(record: Recordable) {
|
||||
await reload({ record });
|
||||
}
|
||||
</script>
|
||||
118
web-vue/packages/erp/views/erp/account/select.ts
Normal file
118
web-vue/packages/erp/views/erp/account/select.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
||||
import { erpAccountListData } from '@jeesite/erp/api/erp/account';
|
||||
|
||||
const { t } = useI18n('erp.account');
|
||||
|
||||
const modalProps = {
|
||||
title: t('账户选择'),
|
||||
};
|
||||
|
||||
const searchForm: FormProps<ErpAccount> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('账户名称'),
|
||||
field: 'accountName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('账户类型'),
|
||||
field: 'accountType',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('是否激活'),
|
||||
field: 'isActive',
|
||||
component: 'Input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<ErpAccount>[] = [
|
||||
{
|
||||
title: t('记录时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 230,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
},
|
||||
{
|
||||
title: t('账户名称'),
|
||||
dataIndex: 'accountName',
|
||||
key: 'a.account_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('账户类型'),
|
||||
dataIndex: 'accountType',
|
||||
key: 'a.account_type',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('账户卡号'),
|
||||
dataIndex: 'accountCode',
|
||||
key: 'a.account_code',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('初始余额'),
|
||||
dataIndex: 'initialBalance',
|
||||
key: 'a.initial_balance',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('当前余额'),
|
||||
dataIndex: 'currentBalance',
|
||||
key: 'a.current_balance',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('是否激活'),
|
||||
dataIndex: 'isActive',
|
||||
key: 'a.is_active',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: BasicTableProps = {
|
||||
api: erpAccountListData,
|
||||
beforeFetch: (params) => {
|
||||
params['isAll'] = true;
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
formConfig: searchForm,
|
||||
rowKey: 'accountId',
|
||||
};
|
||||
|
||||
export default {
|
||||
modalProps,
|
||||
tableProps,
|
||||
itemCode: 'accountId',
|
||||
itemName: 'accountId',
|
||||
isShowCode: false,
|
||||
};
|
||||
140
web-vue/packages/erp/views/erp/category/form.vue
Normal file
140
web-vue/packages/erp/views/erp/category/form.vue
Normal file
@@ -0,0 +1,140 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<BasicDrawer
|
||||
v-bind="$attrs"
|
||||
:showFooter="true"
|
||||
:okAuth="'erp:category:edit'"
|
||||
@register="registerDrawer"
|
||||
@ok="handleSubmit"
|
||||
width="70%"
|
||||
>
|
||||
<template #title>
|
||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
||||
<span> {{ getTitle.value }} </span>
|
||||
</template>
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicDrawer>
|
||||
</template>
|
||||
<script lang="ts" setup name="ViewsErpCategoryForm">
|
||||
import { ref, unref, computed } from 'vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicForm, FormSchema, useForm } from '@jeesite/core/components/Form';
|
||||
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
|
||||
import { ErpCategory, erpCategorySave, erpCategoryForm } from '@jeesite/erp/api/erp/category';
|
||||
import { formatToDateTime } from '@jeesite/core/utils/dateUtil';
|
||||
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
|
||||
const { t } = useI18n('erp.category');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<ErpCategory>({} as ErpCategory);
|
||||
|
||||
const getTitle = computed(() => ({
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
value: record.value.isNewRecord ? t('新增分类') : t('编辑分类'),
|
||||
}));
|
||||
|
||||
const inputFormSchemas: FormSchema<ErpCategory>[] = [
|
||||
{
|
||||
label: t('基本信息'),
|
||||
field: 'basicInfo',
|
||||
component: 'FormGroup',
|
||||
colProps: { md: 24, lg: 24 },
|
||||
},
|
||||
{
|
||||
label: t('父级名称'),
|
||||
field: 'parentName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 32,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('分类名称'),
|
||||
field: 'categoryName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 50,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('分类类型'),
|
||||
field: 'categoryType',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 12,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('排序序号'),
|
||||
field: 'sortOrder',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 18,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('是否启用'),
|
||||
field: 'isActive',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 12,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<ErpCategory>({
|
||||
labelWidth: 120,
|
||||
schemas: inputFormSchemas,
|
||||
baseColProps: { md: 24, lg: 12 },
|
||||
});
|
||||
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
setDrawerProps({ loading: true });
|
||||
await resetFields();
|
||||
const res = await erpCategoryForm(data);
|
||||
record.value = (res.erpCategory || {}) as ErpCategory;
|
||||
record.value.__t = new Date().getTime();
|
||||
await setFieldsValue(record.value);
|
||||
setDrawerProps({ loading: false });
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const data = await validate();
|
||||
setDrawerProps({ confirmLoading: true });
|
||||
const params: any = {
|
||||
isNewRecord: record.value.isNewRecord,
|
||||
categoryId: record.value.categoryId || data.categoryId,
|
||||
};
|
||||
|
||||
data[record.value.isNewRecord ? 'createTime' : 'updateTime'] = formatToDateTime(new Date());
|
||||
|
||||
// console.log('submit', params, data, record);
|
||||
const res = await erpCategorySave(params, data);
|
||||
showMessage(res.message);
|
||||
setTimeout(closeDrawer);
|
||||
emit('success', data);
|
||||
} catch (error: any) {
|
||||
if (error && error.errorFields) {
|
||||
showMessage(error.message || t('common.validateError'));
|
||||
}
|
||||
console.log('error', error);
|
||||
} finally {
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
208
web-vue/packages/erp/views/erp/category/list.vue
Normal file
208
web-vue/packages/erp/views/erp/category/list.vue
Normal file
@@ -0,0 +1,208 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #tableTitle>
|
||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
||||
<span> {{ getTitle.value }} </span>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<a-button type="default" :loading="loading" @click="handleExport()">
|
||||
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
|
||||
</a-button>
|
||||
<a-button type="primary" @click="handleForm({})" v-auth="'erp:category:edit'">
|
||||
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
|
||||
</a-button>
|
||||
</template>
|
||||
<template #bizScopeKey="{ record, text, value }">
|
||||
<a @click="handleForm({ categoryId: record.categoryId })" :title="value">
|
||||
{{ text }}
|
||||
</a>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="ViewsErpCategoryList">
|
||||
import { onMounted, ref, unref } from 'vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
|
||||
import { ErpCategory, erpCategoryList } from '@jeesite/erp/api/erp/category';
|
||||
import { erpCategoryDelete, erpCategoryListData } from '@jeesite/erp/api/erp/category';
|
||||
import { useDrawer } from '@jeesite/core/components/Drawer';
|
||||
import { useModal } from '@jeesite/core/components/Modal';
|
||||
import { FormProps } from '@jeesite/core/components/Form';
|
||||
import InputForm from './form.vue';
|
||||
|
||||
const { t } = useI18n('erp.category');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<ErpCategory>({} as ErpCategory);
|
||||
|
||||
const getTitle = {
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
value: meta.title || t('分类管理'),
|
||||
};
|
||||
const loading = ref(false);
|
||||
|
||||
const searchForm: FormProps<ErpCategory> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('分类名称'),
|
||||
field: 'categoryName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('分类类型'),
|
||||
field: 'categoryType',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('是否启用'),
|
||||
field: 'isActive',
|
||||
component: 'Input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<ErpCategory>[] = [
|
||||
{
|
||||
title: t('记录时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 150,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('父级名称'),
|
||||
dataIndex: 'parentName',
|
||||
key: 'a.parent_name',
|
||||
sorter: true,
|
||||
width: 200,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('分类名称'),
|
||||
dataIndex: 'categoryName',
|
||||
key: 'a.category_name',
|
||||
sorter: true,
|
||||
width: 200,
|
||||
align: 'left',
|
||||
slot: 'bizScopeKey',
|
||||
},
|
||||
{
|
||||
title: t('分类类型'),
|
||||
dataIndex: 'categoryType',
|
||||
key: 'a.category_type',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('排序序号'),
|
||||
dataIndex: 'sortOrder',
|
||||
key: 'a.sort_order',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('是否启用'),
|
||||
dataIndex: 'isActive',
|
||||
key: 'a.is_active',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 150,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const actionColumn: BasicColumn<ErpCategory> = {
|
||||
width: 160,
|
||||
align: 'center',
|
||||
actions: (record: ErpCategory) => [
|
||||
{
|
||||
icon: 'i-clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleForm.bind(this, { categoryId: record.categoryId }),
|
||||
auth: 'erp:category:edit',
|
||||
},
|
||||
{
|
||||
icon: 'i-ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除分类?'),
|
||||
confirm: handleDelete.bind(this, record),
|
||||
},
|
||||
auth: 'erp:category:edit',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const [registerTable, { reload, getForm }] = useTable<ErpCategory>({
|
||||
api: erpCategoryListData,
|
||||
beforeFetch: (params) => {
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
actionColumn: actionColumn,
|
||||
formConfig: searchForm,
|
||||
showTableSetting: true,
|
||||
useSearchForm: true,
|
||||
canResize: true,
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
const res = await erpCategoryList();
|
||||
record.value = (res.erpCategory || {}) as ErpCategory;
|
||||
await getForm().setFieldsValue(record.value);
|
||||
});
|
||||
|
||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
||||
|
||||
function handleForm(record: Recordable) {
|
||||
openDrawer(true, record);
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
loading.value = true;
|
||||
const { ctxAdminPath } = useGlobSetting();
|
||||
await downloadByUrl({
|
||||
url: ctxAdminPath + '/erp/category/exportData',
|
||||
params: getForm().getFieldsValue(),
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
const params = { categoryId: record.categoryId };
|
||||
const res = await erpCategoryDelete(params);
|
||||
showMessage(res.message);
|
||||
await handleSuccess(record);
|
||||
}
|
||||
|
||||
async function handleSuccess(record: Recordable) {
|
||||
await reload({ record });
|
||||
}
|
||||
</script>
|
||||
110
web-vue/packages/erp/views/erp/category/select.ts
Normal file
110
web-vue/packages/erp/views/erp/category/select.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
||||
import { erpCategoryListData } from '@jeesite/erp/api/erp/category';
|
||||
|
||||
const { t } = useI18n('erp.category');
|
||||
|
||||
const modalProps = {
|
||||
title: t('分类选择'),
|
||||
};
|
||||
|
||||
const searchForm: FormProps<ErpCategory> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('分类名称'),
|
||||
field: 'categoryName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('分类类型'),
|
||||
field: 'categoryType',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('是否启用'),
|
||||
field: 'isActive',
|
||||
component: 'Input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<ErpCategory>[] = [
|
||||
{
|
||||
title: t('记录时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 230,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
},
|
||||
{
|
||||
title: t('父级名称'),
|
||||
dataIndex: 'parentName',
|
||||
key: 'a.parent_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('分类名称'),
|
||||
dataIndex: 'categoryName',
|
||||
key: 'a.category_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('分类类型'),
|
||||
dataIndex: 'categoryType',
|
||||
key: 'a.category_type',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('排序序号'),
|
||||
dataIndex: 'sortOrder',
|
||||
key: 'a.sort_order',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('是否启用'),
|
||||
dataIndex: 'isActive',
|
||||
key: 'a.is_active',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: BasicTableProps = {
|
||||
api: erpCategoryListData,
|
||||
beforeFetch: (params) => {
|
||||
params['isAll'] = true;
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
formConfig: searchForm,
|
||||
rowKey: 'categoryId',
|
||||
};
|
||||
|
||||
export default {
|
||||
modalProps,
|
||||
tableProps,
|
||||
itemCode: 'categoryId',
|
||||
itemName: 'categoryId',
|
||||
isShowCode: false,
|
||||
};
|
||||
Reference in New Issue
Block a user