2022-05-29 12:32:21 +00:00
|
|
|
import { ModelNameEnum } from 'models/types';
|
2022-04-28 06:34:55 +00:00
|
|
|
import ChartOfAccounts from 'src/pages/ChartOfAccounts.vue';
|
2023-02-21 06:21:32 +00:00
|
|
|
import CommonForm from 'src/pages/CommonForm/CommonForm.vue';
|
2022-04-20 06:38:47 +00:00
|
|
|
import Dashboard from 'src/pages/Dashboard/Dashboard.vue';
|
2022-04-25 10:37:25 +00:00
|
|
|
import GetStarted from 'src/pages/GetStarted.vue';
|
2023-02-21 06:21:32 +00:00
|
|
|
import ImportWizard from 'src/pages/ImportWizard.vue';
|
2022-05-01 04:45:47 +00:00
|
|
|
import InvoiceForm from 'src/pages/InvoiceForm.vue';
|
2022-04-27 12:02:43 +00:00
|
|
|
import ListView from 'src/pages/ListView/ListView.vue';
|
2022-05-02 05:31:11 +00:00
|
|
|
import PrintView from 'src/pages/PrintView/PrintView.vue';
|
2022-04-27 12:02:43 +00:00
|
|
|
import QuickEditForm from 'src/pages/QuickEditForm.vue';
|
2022-05-12 14:59:56 +00:00
|
|
|
import Report from 'src/pages/Report.vue';
|
2022-04-26 10:12:33 +00:00
|
|
|
import Settings from 'src/pages/Settings/Settings.vue';
|
2023-01-09 07:03:26 +00:00
|
|
|
import {
|
|
|
|
createRouter,
|
|
|
|
createWebHistory,
|
|
|
|
RouteLocationRaw,
|
2023-02-21 06:42:06 +00:00
|
|
|
RouteRecordRaw,
|
2023-01-09 07:03:26 +00:00
|
|
|
} from 'vue-router';
|
2018-06-27 14:36:42 +00:00
|
|
|
|
2023-02-21 05:34:35 +00:00
|
|
|
function getCommonFormItems(): RouteRecordRaw[] {
|
|
|
|
return [
|
2023-02-21 06:42:06 +00:00
|
|
|
ModelNameEnum.Shipment,
|
|
|
|
ModelNameEnum.PurchaseReceipt,
|
2023-02-21 06:21:32 +00:00
|
|
|
ModelNameEnum.JournalEntry,
|
2023-02-21 05:34:35 +00:00
|
|
|
ModelNameEnum.Payment,
|
|
|
|
ModelNameEnum.StockMovement,
|
|
|
|
ModelNameEnum.Item,
|
|
|
|
].map((schemaName) => {
|
|
|
|
return {
|
|
|
|
path: `/edit/${schemaName}/:name`,
|
|
|
|
name: `${schemaName}Form`,
|
|
|
|
components: {
|
|
|
|
default: CommonForm,
|
|
|
|
edit: QuickEditForm,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
default: (route) => {
|
|
|
|
route.params.schemaName = schemaName;
|
|
|
|
return {
|
|
|
|
schemaName,
|
|
|
|
name: route.params.name,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-04-20 10:41:27 +00:00
|
|
|
const routes: RouteRecordRaw[] = [
|
2019-07-25 09:50:48 +00:00
|
|
|
{
|
|
|
|
path: '/',
|
2021-11-24 09:08:13 +00:00
|
|
|
component: Dashboard,
|
2019-07-25 09:50:48 +00:00
|
|
|
},
|
2019-12-21 14:46:50 +00:00
|
|
|
{
|
|
|
|
path: '/get-started',
|
2021-11-24 09:08:13 +00:00
|
|
|
component: GetStarted,
|
2019-12-21 14:46:50 +00:00
|
|
|
},
|
2023-02-21 05:34:35 +00:00
|
|
|
...getCommonFormItems(),
|
2018-06-27 14:36:42 +00:00
|
|
|
{
|
2022-05-01 04:45:47 +00:00
|
|
|
path: '/edit/:schemaName/:name',
|
2019-10-11 09:55:50 +00:00
|
|
|
name: 'InvoiceForm',
|
|
|
|
components: {
|
|
|
|
default: InvoiceForm,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: QuickEditForm,
|
2019-10-11 09:55:50 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
default: true,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
2019-10-11 09:55:50 +00:00
|
|
|
},
|
|
|
|
{
|
2023-01-04 12:23:42 +00:00
|
|
|
path: '/list/:schemaName/:pageTitle?',
|
2018-10-10 18:51:03 +00:00
|
|
|
name: 'ListView',
|
2019-10-11 09:55:50 +00:00
|
|
|
components: {
|
|
|
|
default: ListView,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: QuickEditForm,
|
2019-10-04 20:18:10 +00:00
|
|
|
},
|
2019-10-11 09:55:50 +00:00
|
|
|
props: {
|
2021-11-24 09:08:13 +00:00
|
|
|
default: (route) => {
|
2023-01-04 12:23:42 +00:00
|
|
|
const { schemaName } = route.params;
|
|
|
|
const pageTitle = route.params.pageTitle ?? '';
|
2022-04-20 10:41:27 +00:00
|
|
|
|
2023-01-04 12:23:42 +00:00
|
|
|
const filters = {};
|
|
|
|
const filterString = route.query.filters;
|
|
|
|
if (typeof filterString === 'string') {
|
|
|
|
Object.assign(filters, JSON.parse(filterString));
|
2022-03-10 06:36:37 +00:00
|
|
|
}
|
|
|
|
|
2019-10-11 09:55:50 +00:00
|
|
|
return {
|
2022-04-27 12:02:43 +00:00
|
|
|
schemaName,
|
2021-11-24 09:08:13 +00:00
|
|
|
filters,
|
2023-01-04 12:23:42 +00:00
|
|
|
pageTitle,
|
2019-10-11 09:55:50 +00:00
|
|
|
};
|
|
|
|
},
|
2022-04-28 06:34:55 +00:00
|
|
|
edit: (route) => {
|
|
|
|
return route.query;
|
|
|
|
},
|
2021-11-24 09:08:13 +00:00
|
|
|
},
|
2018-06-27 14:36:42 +00:00
|
|
|
},
|
2018-10-15 12:05:01 +00:00
|
|
|
{
|
2022-05-01 04:45:47 +00:00
|
|
|
path: '/print/:schemaName/:name',
|
2018-10-15 12:05:01 +00:00
|
|
|
name: 'PrintView',
|
|
|
|
component: PrintView,
|
2021-11-24 09:08:13 +00:00
|
|
|
props: true,
|
2018-10-22 18:10:22 +00:00
|
|
|
},
|
2018-06-27 14:36:42 +00:00
|
|
|
{
|
2022-05-18 07:04:33 +00:00
|
|
|
path: '/report/:reportClassName',
|
2018-06-27 14:36:42 +00:00
|
|
|
name: 'Report',
|
|
|
|
component: Report,
|
2021-11-24 09:08:13 +00:00
|
|
|
props: true,
|
2018-10-10 10:32:56 +00:00
|
|
|
},
|
2019-02-18 05:42:04 +00:00
|
|
|
{
|
2019-12-23 08:26:41 +00:00
|
|
|
path: '/chart-of-accounts',
|
2019-02-18 05:42:04 +00:00
|
|
|
name: 'Chart Of Accounts',
|
2019-10-13 21:18:18 +00:00
|
|
|
components: {
|
|
|
|
default: ChartOfAccounts,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: QuickEditForm,
|
2019-10-13 21:18:18 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
default: true,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
|
|
|
},
|
2023-02-02 08:12:09 +00:00
|
|
|
{
|
|
|
|
path: '/import-wizard',
|
|
|
|
name: 'Import Wizard',
|
|
|
|
component: ImportWizard,
|
|
|
|
},
|
2022-05-05 10:44:26 +00:00
|
|
|
{
|
2021-11-24 09:08:13 +00:00
|
|
|
path: '/settings',
|
|
|
|
name: 'Settings',
|
2022-10-12 08:35:18 +00:00
|
|
|
components: {
|
|
|
|
default: Settings,
|
|
|
|
edit: QuickEditForm,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
default: true,
|
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
2021-11-24 09:08:13 +00:00
|
|
|
},
|
2018-10-10 18:51:03 +00:00
|
|
|
];
|
2018-06-27 14:36:42 +00:00
|
|
|
|
2022-04-20 06:38:47 +00:00
|
|
|
const router = createRouter({ routes, history: createWebHistory() });
|
2019-10-03 13:46:12 +00:00
|
|
|
|
|
|
|
export default router;
|