style: lint格式化文件
This commit is contained in:
@ -1,165 +1,161 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> {{ t('新增按钮') }} </a-button>
|
||||
</template>
|
||||
<template #action2="{ record }">
|
||||
<SetPrintTemplate
|
||||
v-if="record.code.includes(PrintButton.CODE)"
|
||||
:row="record"
|
||||
:hasMetaFormId="hasMetaFormId"
|
||||
>
|
||||
<Icon icon="ant-design:setting-outlined" style="cursor: pointer" />
|
||||
</SetPrintTemplate>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
icon: 'clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleEdit.bind(null, record),
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除'),
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> {{ t('新增按钮') }} </a-button>
|
||||
</template>
|
||||
<template #action2="{ record }">
|
||||
<SetPrintTemplate v-if="record.code.includes(PrintButton.CODE)" :row="record" :hasMetaFormId="hasMetaFormId">
|
||||
<Icon icon="ant-design:setting-outlined" style="cursor: pointer" />
|
||||
</SetPrintTemplate>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
icon: 'clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleEdit.bind(null, record)
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除'),
|
||||
confirm: handleDelete.bind(null, record)
|
||||
}
|
||||
}
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
|
||||
<MenuButtonModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
<MenuButtonModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||||
import MenuButtonModal from './MenuButtonModal.vue';
|
||||
import SetPrintTemplate from './SetPrintTemplate.vue';
|
||||
import { getMenuButtonById } from '/@/api/system/menu';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { PrintButton } from '/@/enums/printEnum';
|
||||
const { t } = useI18n();
|
||||
const props = {
|
||||
menuId: { type: String, default: '' },
|
||||
hasMetaFormId: { type: Boolean, default: false },
|
||||
};
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('按钮名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: t('地址'),
|
||||
dataIndex: 'url',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: t('请求方式'),
|
||||
dataIndex: 'method',
|
||||
width: 180,
|
||||
format: (text: string | number) => {
|
||||
if (text === 0) return 'GET';
|
||||
else if (text === 1) return 'POST';
|
||||
else if (text === 2) return 'PUT';
|
||||
else return 'DELETE';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('设置'),
|
||||
dataIndex: 'action2',
|
||||
width: 100,
|
||||
},
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: { TableAction, BasicTable, MenuButtonModal, Icon, SetPrintTemplate },
|
||||
props,
|
||||
emits: ['success', 'register'],
|
||||
setup(props) {
|
||||
let btnData = reactive<MenuButtonModel[]>([]);
|
||||
const [registerTable, { getDataSource, setTableData, updateTableDataRecord }] = useTable({
|
||||
title: t('按钮列表'),
|
||||
dataSource: btnData,
|
||||
api: getMenuButtonById,
|
||||
beforeFetch: (params) => {
|
||||
//发送请求默认新增 左边树结构所选机构id
|
||||
return { ...params, id: props.menuId };
|
||||
import { defineComponent, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||||
import MenuButtonModal from './MenuButtonModal.vue';
|
||||
import SetPrintTemplate from './SetPrintTemplate.vue';
|
||||
import { getMenuButtonById } from '/@/api/system/menu';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { PrintButton } from '/@/enums/printEnum';
|
||||
const { t } = useI18n();
|
||||
const props = {
|
||||
menuId: { type: String, default: '' },
|
||||
hasMetaFormId: { type: Boolean, default: false }
|
||||
};
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('按钮名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left'
|
||||
},
|
||||
columns,
|
||||
pagination: false,
|
||||
striped: false,
|
||||
useSearchForm: false,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
showIndexColumn: false,
|
||||
canResize: false,
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: t('操作'),
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' },
|
||||
fixed: undefined,
|
||||
{
|
||||
title: t('编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100
|
||||
},
|
||||
});
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
});
|
||||
}
|
||||
function handleSuccess({ isUpdate, record }) {
|
||||
if (isUpdate) {
|
||||
updateTableDataRecord(record.key, record);
|
||||
} else {
|
||||
const dataSource = getDataSource();
|
||||
dataSource.push(record);
|
||||
setTableData(dataSource);
|
||||
{
|
||||
title: t('地址'),
|
||||
dataIndex: 'url',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: t('请求方式'),
|
||||
dataIndex: 'method',
|
||||
width: 180,
|
||||
format: (text: string | number) => {
|
||||
if (text === 0) return 'GET';
|
||||
else if (text === 1) return 'POST';
|
||||
else if (text === 2) return 'PUT';
|
||||
else return 'DELETE';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: t('设置'),
|
||||
dataIndex: 'action2',
|
||||
width: 100
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
const dataSource = getDataSource();
|
||||
setTableData(dataSource.filter((x) => x.key !== record.key));
|
||||
}
|
||||
return {
|
||||
PrintButton,
|
||||
registerTable,
|
||||
handleCreate,
|
||||
registerModal,
|
||||
handleEdit,
|
||||
handleSuccess,
|
||||
handleDelete,
|
||||
getDataSource,
|
||||
t,
|
||||
};
|
||||
},
|
||||
});
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: { TableAction, BasicTable, MenuButtonModal, Icon, SetPrintTemplate },
|
||||
props,
|
||||
emits: ['success', 'register'],
|
||||
setup(props) {
|
||||
let btnData = reactive<MenuButtonModel[]>([]);
|
||||
const [registerTable, { getDataSource, setTableData, updateTableDataRecord }] = useTable({
|
||||
title: t('按钮列表'),
|
||||
dataSource: btnData,
|
||||
api: getMenuButtonById,
|
||||
beforeFetch: (params) => {
|
||||
//发送请求默认新增 左边树结构所选机构id
|
||||
return { ...params, id: props.menuId };
|
||||
},
|
||||
columns,
|
||||
pagination: false,
|
||||
striped: false,
|
||||
useSearchForm: false,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
showIndexColumn: false,
|
||||
canResize: false,
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: t('操作'),
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' },
|
||||
fixed: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isUpdate: false
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true
|
||||
});
|
||||
}
|
||||
function handleSuccess({ isUpdate, record }) {
|
||||
if (isUpdate) {
|
||||
updateTableDataRecord(record.key, record);
|
||||
} else {
|
||||
const dataSource = getDataSource();
|
||||
dataSource.push(record);
|
||||
setTableData(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
const dataSource = getDataSource();
|
||||
setTableData(dataSource.filter((x) => x.key !== record.key));
|
||||
}
|
||||
return {
|
||||
PrintButton,
|
||||
registerTable,
|
||||
handleCreate,
|
||||
registerModal,
|
||||
handleEdit,
|
||||
handleSuccess,
|
||||
handleDelete,
|
||||
getDataSource,
|
||||
t
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,136 +1,136 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> {{ t('新增表格') }} </a-button>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
icon: 'clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleEdit.bind(null, record),
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除'),
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> {{ t('新增表格') }} </a-button>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
icon: 'clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleEdit.bind(null, record)
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除'),
|
||||
confirm: handleDelete.bind(null, record)
|
||||
}
|
||||
}
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
|
||||
<MenuColumnModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
<MenuColumnModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, reactive } from 'vue';
|
||||
import { defineComponent, reactive } from 'vue';
|
||||
|
||||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||||
import MenuColumnModal from './MenuColumnModal.vue';
|
||||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||||
import MenuColumnModal from './MenuColumnModal.vue';
|
||||
|
||||
import { getMenuColumnById } from '/@/api/system/menu';
|
||||
import { getMenuColumnById } from '/@/api/system/menu';
|
||||
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
const props = {
|
||||
menuId: { type: String, default: '' },
|
||||
};
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('表格列名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('表格列编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100,
|
||||
},
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: { TableAction, BasicTable, MenuColumnModal },
|
||||
props,
|
||||
emits: ['success', 'register'],
|
||||
setup(props) {
|
||||
let btnData = reactive<MenuButtonModel[]>([]);
|
||||
|
||||
const [registerTable, { getDataSource, setTableData, updateTableDataRecord }] = useTable({
|
||||
title: t('表格字段列表'),
|
||||
dataSource: btnData,
|
||||
api: getMenuColumnById,
|
||||
beforeFetch: (params) => {
|
||||
//发送请求默认新增 左边树结构所选机构id
|
||||
return { ...params, menuId: props.menuId };
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
const props = {
|
||||
menuId: { type: String, default: '' }
|
||||
};
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('表格列名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left'
|
||||
},
|
||||
columns,
|
||||
pagination: false,
|
||||
striped: false,
|
||||
useSearchForm: false,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
showIndexColumn: false,
|
||||
canResize: false,
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: t('操作'),
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' },
|
||||
fixed: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
});
|
||||
}
|
||||
|
||||
function handleSuccess({ isUpdate, record }) {
|
||||
if (isUpdate) {
|
||||
updateTableDataRecord(record.key, record);
|
||||
} else {
|
||||
const dataSource = getDataSource();
|
||||
dataSource.push(record);
|
||||
setTableData(dataSource);
|
||||
{
|
||||
title: t('表格列编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
const dataSource = getDataSource();
|
||||
setTableData(dataSource.filter((x) => x.key !== record.key));
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: { TableAction, BasicTable, MenuColumnModal },
|
||||
props,
|
||||
emits: ['success', 'register'],
|
||||
setup(props) {
|
||||
let btnData = reactive<MenuButtonModel[]>([]);
|
||||
|
||||
return {
|
||||
registerTable,
|
||||
handleCreate,
|
||||
registerModal,
|
||||
handleEdit,
|
||||
handleSuccess,
|
||||
handleDelete,
|
||||
getDataSource,
|
||||
t,
|
||||
};
|
||||
},
|
||||
});
|
||||
const [registerTable, { getDataSource, setTableData, updateTableDataRecord }] = useTable({
|
||||
title: t('表格字段列表'),
|
||||
dataSource: btnData,
|
||||
api: getMenuColumnById,
|
||||
beforeFetch: (params) => {
|
||||
//发送请求默认新增 左边树结构所选机构id
|
||||
return { ...params, menuId: props.menuId };
|
||||
},
|
||||
columns,
|
||||
pagination: false,
|
||||
striped: false,
|
||||
useSearchForm: false,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
showIndexColumn: false,
|
||||
canResize: false,
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: t('操作'),
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' },
|
||||
fixed: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isUpdate: false
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true
|
||||
});
|
||||
}
|
||||
|
||||
function handleSuccess({ isUpdate, record }) {
|
||||
if (isUpdate) {
|
||||
updateTableDataRecord(record.key, record);
|
||||
} else {
|
||||
const dataSource = getDataSource();
|
||||
dataSource.push(record);
|
||||
setTableData(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
const dataSource = getDataSource();
|
||||
setTableData(dataSource.filter((x) => x.key !== record.key));
|
||||
}
|
||||
|
||||
return {
|
||||
registerTable,
|
||||
handleCreate,
|
||||
registerModal,
|
||||
handleEdit,
|
||||
handleSuccess,
|
||||
handleDelete,
|
||||
getDataSource,
|
||||
t
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,136 +1,136 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> {{ t('新增表单项') }} </a-button>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
icon: 'clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleEdit.bind(null, record),
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除'),
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> {{ t('新增表单项') }} </a-button>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
icon: 'clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleEdit.bind(null, record)
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除'),
|
||||
confirm: handleDelete.bind(null, record)
|
||||
}
|
||||
}
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
|
||||
<MenuFormModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
<MenuFormModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, reactive } from 'vue';
|
||||
import { defineComponent, reactive } from 'vue';
|
||||
|
||||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||||
import MenuFormModal from './MenuFormModal.vue';
|
||||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||||
import MenuFormModal from './MenuFormModal.vue';
|
||||
|
||||
import { getMenuFormById } from '/@/api/system/menu';
|
||||
import { getMenuFormById } from '/@/api/system/menu';
|
||||
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
const props = {
|
||||
menuId: { type: String, default: '' },
|
||||
};
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('表单项名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('表单项编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100,
|
||||
},
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: { TableAction, BasicTable, MenuFormModal },
|
||||
props,
|
||||
emits: ['success', 'register'],
|
||||
setup(props) {
|
||||
let btnData = reactive<MenuButtonModel[]>([]);
|
||||
|
||||
const [registerTable, { getDataSource, setTableData, updateTableDataRecord }] = useTable({
|
||||
title: t('表单项列表'),
|
||||
dataSource: btnData,
|
||||
api: getMenuFormById,
|
||||
beforeFetch: (params) => {
|
||||
//发送请求默认新增 左边树结构所选机构id
|
||||
return { ...params, menuId: props.menuId };
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
const props = {
|
||||
menuId: { type: String, default: '' }
|
||||
};
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('表单项名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left'
|
||||
},
|
||||
columns,
|
||||
pagination: false,
|
||||
striped: false,
|
||||
useSearchForm: false,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
showIndexColumn: false,
|
||||
canResize: false,
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: t('操作'),
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' },
|
||||
fixed: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
});
|
||||
}
|
||||
|
||||
function handleSuccess({ isUpdate, record }) {
|
||||
if (isUpdate) {
|
||||
updateTableDataRecord(record.key, record);
|
||||
} else {
|
||||
const dataSource = getDataSource();
|
||||
dataSource.push(record);
|
||||
setTableData(dataSource);
|
||||
{
|
||||
title: t('表单项编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
const dataSource = getDataSource();
|
||||
setTableData(dataSource.filter((x) => x.key !== record.key));
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: { TableAction, BasicTable, MenuFormModal },
|
||||
props,
|
||||
emits: ['success', 'register'],
|
||||
setup(props) {
|
||||
let btnData = reactive<MenuButtonModel[]>([]);
|
||||
|
||||
return {
|
||||
registerTable,
|
||||
handleCreate,
|
||||
registerModal,
|
||||
handleEdit,
|
||||
handleSuccess,
|
||||
handleDelete,
|
||||
getDataSource,
|
||||
t,
|
||||
};
|
||||
},
|
||||
});
|
||||
const [registerTable, { getDataSource, setTableData, updateTableDataRecord }] = useTable({
|
||||
title: t('表单项列表'),
|
||||
dataSource: btnData,
|
||||
api: getMenuFormById,
|
||||
beforeFetch: (params) => {
|
||||
//发送请求默认新增 左边树结构所选机构id
|
||||
return { ...params, menuId: props.menuId };
|
||||
},
|
||||
columns,
|
||||
pagination: false,
|
||||
striped: false,
|
||||
useSearchForm: false,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
showIndexColumn: false,
|
||||
canResize: false,
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: t('操作'),
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' },
|
||||
fixed: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isUpdate: false
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true
|
||||
});
|
||||
}
|
||||
|
||||
function handleSuccess({ isUpdate, record }) {
|
||||
if (isUpdate) {
|
||||
updateTableDataRecord(record.key, record);
|
||||
} else {
|
||||
const dataSource = getDataSource();
|
||||
dataSource.push(record);
|
||||
setTableData(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
const dataSource = getDataSource();
|
||||
setTableData(dataSource.filter((x) => x.key !== record.key));
|
||||
}
|
||||
|
||||
return {
|
||||
registerTable,
|
||||
handleCreate,
|
||||
registerModal,
|
||||
handleEdit,
|
||||
handleSuccess,
|
||||
handleDelete,
|
||||
getDataSource,
|
||||
t
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,111 +1,111 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: t('按钮名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: t('编码'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
field: 'url',
|
||||
label: t('地址'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'method',
|
||||
label: t('请求方式'),
|
||||
component: 'Select',
|
||||
defaultValue: 1,
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: 'GET', value: 0 },
|
||||
{ label: 'POST', value: 1 },
|
||||
{ label: 'PUT', value: 2 },
|
||||
{ label: 'DELETE', value: 3 },
|
||||
],
|
||||
},
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuButtonModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
actionColOptions: {
|
||||
span: 23,
|
||||
import { defineComponent, ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: t('按钮名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: t('编码'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
resetFields();
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
rowId.value = data.record.key;
|
||||
|
||||
setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
{
|
||||
field: 'url',
|
||||
label: t('地址'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'method',
|
||||
label: t('请求方式'),
|
||||
component: 'Select',
|
||||
defaultValue: 1,
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: 'GET', value: 0 },
|
||||
{ label: 'POST', value: 1 },
|
||||
{ label: 'PUT', value: 2 },
|
||||
{ label: 'DELETE', value: 3 }
|
||||
]
|
||||
},
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
}
|
||||
});
|
||||
];
|
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('新增按钮') : t('编辑按钮')));
|
||||
export default defineComponent({
|
||||
name: 'MenuButtonModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
actionColOptions: {
|
||||
span: 23
|
||||
}
|
||||
});
|
||||
|
||||
closeModal();
|
||||
emit('success', { isUpdate: unref(isUpdate), record: { ...values, key: rowId.value } });
|
||||
} catch (error) {
|
||||
setModalProps({ confirmLoading: false });
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
resetFields();
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
rowId.value = data.record.key;
|
||||
|
||||
setFieldsValue({
|
||||
...data.record
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('新增按钮') : t('编辑按钮')));
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
|
||||
closeModal();
|
||||
emit('success', { isUpdate: unref(isUpdate), record: { ...values, key: rowId.value } });
|
||||
} catch (error) {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
return { registerModal, registerForm, getTitle, handleSubmit, t };
|
||||
}
|
||||
}
|
||||
|
||||
return { registerModal, registerForm, getTitle, handleSubmit, t };
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,83 +1,83 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: t('表格列名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: t('表格列编码'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuButtonModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
actionColOptions: {
|
||||
span: 23,
|
||||
import { defineComponent, ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: t('表格列名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
resetFields();
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
rowId.value = data.record.key;
|
||||
|
||||
setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
{
|
||||
field: 'code',
|
||||
label: t('表格列编码'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
}
|
||||
});
|
||||
];
|
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('新增表格列') : t('编辑表格列')));
|
||||
export default defineComponent({
|
||||
name: 'MenuButtonModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
actionColOptions: {
|
||||
span: 23
|
||||
}
|
||||
});
|
||||
|
||||
closeModal();
|
||||
emit('success', { isUpdate: unref(isUpdate), record: { ...values, key: rowId.value } });
|
||||
} catch (error) {
|
||||
setModalProps({ confirmLoading: false });
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
resetFields();
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
rowId.value = data.record.key;
|
||||
|
||||
setFieldsValue({
|
||||
...data.record
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('新增表格列') : t('编辑表格列')));
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
|
||||
closeModal();
|
||||
emit('success', { isUpdate: unref(isUpdate), record: { ...values, key: rowId.value } });
|
||||
} catch (error) {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
return { registerModal, registerForm, getTitle, handleSubmit, t };
|
||||
}
|
||||
}
|
||||
|
||||
return { registerModal, registerForm, getTitle, handleSubmit, t };
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,424 +1,408 @@
|
||||
<template>
|
||||
<BasicDrawer
|
||||
v-bind="$attrs"
|
||||
@register="registerDrawer"
|
||||
showFooter
|
||||
destroyOnClose
|
||||
:title="getTitle"
|
||||
width="50%"
|
||||
@ok="handleSubmit"
|
||||
@visible-change="
|
||||
() => {
|
||||
activeKey = '1';
|
||||
}
|
||||
"
|
||||
>
|
||||
<a-tabs v-model:activeKey="activeKey">
|
||||
<a-tab-pane key="1" :tab="t('菜单信息')">
|
||||
<BasicForm @register="registerForm" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="2" :tab="t('按钮信息')">
|
||||
<ButtonTable
|
||||
:menuId="rowId"
|
||||
:hasMetaFormId="hasMetaFormId"
|
||||
ref="buttonTable"
|
||||
v-if="activeKey"
|
||||
/>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="3" :tab="t('表格信息')">
|
||||
<ColumnTable :menuId="rowId" ref="columnTable" v-if="activeKey" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="4" :tab="t('表单信息')">
|
||||
<FormTable :menuId="rowId" ref="formTable" v-if="activeKey" />
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</BasicDrawer>
|
||||
<BasicDrawer
|
||||
v-bind="$attrs"
|
||||
@register="registerDrawer"
|
||||
showFooter
|
||||
destroyOnClose
|
||||
:title="getTitle"
|
||||
width="50%"
|
||||
@ok="handleSubmit"
|
||||
@visible-change="
|
||||
() => {
|
||||
activeKey = '1';
|
||||
}
|
||||
"
|
||||
>
|
||||
<a-tabs v-model:activeKey="activeKey">
|
||||
<a-tab-pane key="1" :tab="t('菜单信息')">
|
||||
<BasicForm @register="registerForm" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="2" :tab="t('按钮信息')">
|
||||
<ButtonTable :menuId="rowId" :hasMetaFormId="hasMetaFormId" ref="buttonTable" v-if="activeKey" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="3" :tab="t('表格信息')">
|
||||
<ColumnTable :menuId="rowId" ref="columnTable" v-if="activeKey" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="4" :tab="t('表单信息')">
|
||||
<FormTable :menuId="rowId" ref="formTable" v-if="activeKey" />
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</BasicDrawer>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, computed } from 'vue';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
||||
import { BasicColumn } from '/@/components/Table';
|
||||
import { defineComponent, ref, computed } from 'vue';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
||||
import { BasicColumn } from '/@/components/Table';
|
||||
|
||||
import ButtonTable from './ButtonTable.vue';
|
||||
import ColumnTable from './ColumnTable.vue';
|
||||
import FormTable from './FormTable.vue';
|
||||
import {
|
||||
getMenuTree,
|
||||
addMenu,
|
||||
updateMenu,
|
||||
getMenuButtonById,
|
||||
getMenuColumnById,
|
||||
getMenuFormById,
|
||||
} from '/@/api/system/menu';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { getSubSystemList } from '/@/api/system/subSystem';
|
||||
import ButtonTable from './ButtonTable.vue';
|
||||
import ColumnTable from './ColumnTable.vue';
|
||||
import FormTable from './FormTable.vue';
|
||||
import { getMenuTree, addMenu, updateMenu, getMenuButtonById, getMenuColumnById, getMenuFormById } from '/@/api/system/menu';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { MenuButtonModel } from '/@/api/system/menuButton/model';
|
||||
import { getSubSystemList } from '/@/api/system/subSystem';
|
||||
|
||||
import { usePermissionStore } from '/@/store/modules/permission';
|
||||
const { t } = useI18n();
|
||||
import { usePermissionStore } from '/@/store/modules/permission';
|
||||
const { t } = useI18n();
|
||||
|
||||
const isUpdate = ref<boolean>(false);
|
||||
const componentType = ref<number>(0);
|
||||
const hasMetaFormId = ref(false);
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'title',
|
||||
label: t('菜单名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
label: t('组件名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: t('编码'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
field: 'sortCode',
|
||||
label: t('排序'),
|
||||
component: 'InputNumber',
|
||||
required: true,
|
||||
},
|
||||
|
||||
{
|
||||
field: 'parentId',
|
||||
label: t('上级菜单'),
|
||||
component: 'MenuSelect',
|
||||
colProps: { lg: 24, md: 24 },
|
||||
},
|
||||
{
|
||||
field: 'systemId',
|
||||
label: t('所属系统'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
fieldNames: {
|
||||
label: 'name',
|
||||
value: 'id',
|
||||
const isUpdate = ref<boolean>(false);
|
||||
const componentType = ref<number>(0);
|
||||
const hasMetaFormId = ref(false);
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'title',
|
||||
label: t('菜单名称'),
|
||||
component: 'Input',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
label: t('组件名称'),
|
||||
component: 'Input',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: t('编码'),
|
||||
component: 'Input',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
field: 'sortCode',
|
||||
label: t('排序'),
|
||||
component: 'InputNumber',
|
||||
required: true
|
||||
},
|
||||
getPopupContainer: () => document.body,
|
||||
allowClear: false,
|
||||
},
|
||||
colProps: { lg: 24, md: 24 },
|
||||
dynamicDisabled: ({ values }) => {
|
||||
return values.parentId ? true : false;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'path',
|
||||
label: t('路由地址'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: { lg: 24, md: 24 },
|
||||
helpMessage: '如果是外链新开窗口,在此输入地址!',
|
||||
dynamicDisabled: ({ values }) => {
|
||||
return values.componentType === 1;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'outLink',
|
||||
label: t('是否外链'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('是'), value: 1 },
|
||||
{ label: t('否'), value: 0 },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'icon',
|
||||
label: t('图标'),
|
||||
component: 'IconPicker',
|
||||
},
|
||||
|
||||
{
|
||||
field: 'component',
|
||||
label: t('组件路径'),
|
||||
component: 'Input',
|
||||
colProps: { lg: 24, md: 24 },
|
||||
required: true,
|
||||
ifShow: ({ values }) => {
|
||||
return values.outLink === 0 && values.componentType === 0;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'iframeSrc',
|
||||
label: t('外链地址'),
|
||||
component: 'Input',
|
||||
colProps: { lg: 24, md: 24 },
|
||||
required: true,
|
||||
helpMessage: '如果是外链内嵌,在此输入地址!',
|
||||
ifShow: ({ values }) => {
|
||||
return values.outLink == 1;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
label: t('备注'),
|
||||
component: 'InputTextArea',
|
||||
colProps: { lg: 24, md: 24 },
|
||||
},
|
||||
{
|
||||
field: 'menuType',
|
||||
label: t('页面/菜单'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('页面'), value: 1 },
|
||||
{ label: t('菜单'), value: 0 },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'enabledMark',
|
||||
label: t('状态'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('启用'), value: 1 },
|
||||
{ label: t('禁用'), value: 0 },
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
field: 'display',
|
||||
label: t('是否显示'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('是'), value: 1 },
|
||||
{ label: t('否'), value: 0 },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'componentType', //隐藏组件
|
||||
label: t('是否自定义'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('是'), value: 1 },
|
||||
{ label: t('否'), value: 0 },
|
||||
],
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
];
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('按钮名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: t('地址'),
|
||||
dataIndex: 'url',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: t('请求方式'),
|
||||
dataIndex: 'method',
|
||||
width: 180,
|
||||
format: (text: string | number) => {
|
||||
if (text === 0) return 'GET';
|
||||
else if (text === 1) return 'POST';
|
||||
else if (text === 2) return 'PUT';
|
||||
else return 'DELETE';
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: {
|
||||
BasicDrawer,
|
||||
BasicForm,
|
||||
FormTable,
|
||||
|
||||
ButtonTable,
|
||||
ColumnTable,
|
||||
},
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const permissionStore = usePermissionStore();
|
||||
const { notification } = useMessage();
|
||||
const rowId = ref('');
|
||||
const activeKey = ref('1');
|
||||
const buttonTable = ref();
|
||||
const columnTable = ref();
|
||||
const formTable = ref();
|
||||
const buttonDatas = ref<MenuButtonModel[]>([]);
|
||||
const columnDatas = ref<MenuButtonModel[]>([]);
|
||||
const formDatas = ref<MenuButtonModel[]>([]);
|
||||
const systemId = ref('1');
|
||||
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { lg: 12, md: 24 },
|
||||
});
|
||||
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
resetFields();
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (isUpdate.value) {
|
||||
rowId.value = data.record.id;
|
||||
if (data.record && data.record.meta && data.record.meta.formId) {
|
||||
hasMetaFormId.value = true;
|
||||
}
|
||||
componentType.value = data.record.componentType;
|
||||
if (data.record.outLink == 1) {
|
||||
data.record.url = data.record.component;
|
||||
}
|
||||
if (data.record.parentId) {
|
||||
data.record.systemId = null;
|
||||
}
|
||||
setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
getMenuButtonById({ id: data.record.id }).then((res) => {
|
||||
buttonDatas.value = res;
|
||||
});
|
||||
getMenuColumnById({ menuId: data.record.id }).then((res) => {
|
||||
columnDatas.value = res;
|
||||
});
|
||||
getMenuFormById({ menuId: data.record.id }).then((res) => {
|
||||
formDatas.value = res;
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
componentType.value = 0;
|
||||
setFieldsValue({
|
||||
menuType: 1,
|
||||
enabledMark: 1,
|
||||
outLink: 0,
|
||||
display: 1,
|
||||
componentType: 0,
|
||||
systemId: '1',
|
||||
});
|
||||
}
|
||||
const treeData = await getMenuTree();
|
||||
|
||||
const system = await getSubSystemList();
|
||||
|
||||
updateSchema([
|
||||
{
|
||||
{
|
||||
field: 'parentId',
|
||||
componentProps: ({ formModel }) => {
|
||||
return {
|
||||
getPopupContainer: () => document.body,
|
||||
onChange: (v) => {
|
||||
findParentSystem(treeData, treeData, v);
|
||||
formModel.systemId = systemId.value;
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('上级菜单'),
|
||||
component: 'MenuSelect',
|
||||
colProps: { lg: 24, md: 24 }
|
||||
},
|
||||
{
|
||||
field: 'systemId',
|
||||
componentProps: { options: system },
|
||||
},
|
||||
{
|
||||
field: 'outLink',
|
||||
dynamicDisabled: () => {
|
||||
return isUpdate.value && componentType.value == 1;
|
||||
label: t('所属系统'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
fieldNames: {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
},
|
||||
getPopupContainer: () => document.body,
|
||||
allowClear: false
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'path',
|
||||
dynamicDisabled: () => {
|
||||
return isUpdate.value && componentType.value == 1;
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
const getTitle = computed(() => (!isUpdate.value ? t('新增菜单') : t('编辑菜单')));
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
if (values.outLink == 1) {
|
||||
values.component = values.url;
|
||||
}
|
||||
values.buttonList = buttonTable.value
|
||||
? buttonTable.value.getDataSource()
|
||||
: buttonDatas.value;
|
||||
values.columnList = columnTable.value
|
||||
? columnTable.value.getDataSource()
|
||||
: columnDatas.value;
|
||||
values.formList = formTable.value ? formTable.value.getDataSource() : formDatas.value;
|
||||
setDrawerProps({ confirmLoading: true });
|
||||
// TODO custom api
|
||||
if (!isUpdate.value) {
|
||||
//false 新增
|
||||
await addMenu(values);
|
||||
notification.success({
|
||||
message: t('提示'),
|
||||
description: t('新增菜单成功'),
|
||||
}); //提示消息
|
||||
} else {
|
||||
values.id = rowId.value;
|
||||
await updateMenu(values);
|
||||
notification.success({
|
||||
message: t('提示'),
|
||||
description: t('修改菜单成功'),
|
||||
}); //提示消息
|
||||
}
|
||||
await permissionStore.buildRoutesAction();
|
||||
closeDrawer();
|
||||
emit('success');
|
||||
} catch (error) {
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
function findParentSystem(treeData, tempTree, id) {
|
||||
for (let i = 0; i < treeData.length; i++) {
|
||||
let o = treeData[i];
|
||||
|
||||
if (o.id == id) {
|
||||
systemId.value = o.systemId;
|
||||
if (o.parentId) {
|
||||
findParentSystem(tempTree, tempTree, o.parentId);
|
||||
} else {
|
||||
break;
|
||||
colProps: { lg: 24, md: 24 },
|
||||
dynamicDisabled: ({ values }) => {
|
||||
return values.parentId ? true : false;
|
||||
}
|
||||
} else if (o.children?.length > 0) {
|
||||
findParentSystem(o.children, tempTree, id);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'path',
|
||||
label: t('路由地址'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: { lg: 24, md: 24 },
|
||||
helpMessage: '如果是外链新开窗口,在此输入地址!',
|
||||
dynamicDisabled: ({ values }) => {
|
||||
return values.componentType === 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'outLink',
|
||||
label: t('是否外链'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('是'), value: 1 },
|
||||
{ label: t('否'), value: 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'icon',
|
||||
label: t('图标'),
|
||||
component: 'IconPicker'
|
||||
},
|
||||
|
||||
{
|
||||
field: 'component',
|
||||
label: t('组件路径'),
|
||||
component: 'Input',
|
||||
colProps: { lg: 24, md: 24 },
|
||||
required: true,
|
||||
ifShow: ({ values }) => {
|
||||
return values.outLink === 0 && values.componentType === 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'iframeSrc',
|
||||
label: t('外链地址'),
|
||||
component: 'Input',
|
||||
colProps: { lg: 24, md: 24 },
|
||||
required: true,
|
||||
helpMessage: '如果是外链内嵌,在此输入地址!',
|
||||
ifShow: ({ values }) => {
|
||||
return values.outLink == 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
label: t('备注'),
|
||||
component: 'InputTextArea',
|
||||
colProps: { lg: 24, md: 24 }
|
||||
},
|
||||
{
|
||||
field: 'menuType',
|
||||
label: t('页面/菜单'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('页面'), value: 1 },
|
||||
{ label: t('菜单'), value: 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'enabledMark',
|
||||
label: t('状态'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('启用'), value: 1 },
|
||||
{ label: t('禁用'), value: 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
field: 'display',
|
||||
label: t('是否显示'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('是'), value: 1 },
|
||||
{ label: t('否'), value: 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'componentType', //隐藏组件
|
||||
label: t('是否自定义'),
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: t('是'), value: 1 },
|
||||
{ label: t('否'), value: 0 }
|
||||
]
|
||||
},
|
||||
show: false
|
||||
}
|
||||
}
|
||||
return {
|
||||
registerDrawer,
|
||||
registerForm,
|
||||
getTitle,
|
||||
hasMetaFormId,
|
||||
handleSubmit,
|
||||
buttonTable,
|
||||
rowId,
|
||||
columnTable,
|
||||
formTable,
|
||||
activeKey,
|
||||
t,
|
||||
};
|
||||
},
|
||||
});
|
||||
];
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: t('按钮名称'),
|
||||
dataIndex: 'name',
|
||||
width: 100,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: t('编码'),
|
||||
dataIndex: 'code',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: t('地址'),
|
||||
dataIndex: 'url',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
title: t('请求方式'),
|
||||
dataIndex: 'method',
|
||||
width: 180,
|
||||
format: (text: string | number) => {
|
||||
if (text === 0) return 'GET';
|
||||
else if (text === 1) return 'POST';
|
||||
else if (text === 2) return 'PUT';
|
||||
else return 'DELETE';
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuDrawer',
|
||||
components: {
|
||||
BasicDrawer,
|
||||
BasicForm,
|
||||
FormTable,
|
||||
|
||||
ButtonTable,
|
||||
ColumnTable
|
||||
},
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const permissionStore = usePermissionStore();
|
||||
const { notification } = useMessage();
|
||||
const rowId = ref('');
|
||||
const activeKey = ref('1');
|
||||
const buttonTable = ref();
|
||||
const columnTable = ref();
|
||||
const formTable = ref();
|
||||
const buttonDatas = ref<MenuButtonModel[]>([]);
|
||||
const columnDatas = ref<MenuButtonModel[]>([]);
|
||||
const formDatas = ref<MenuButtonModel[]>([]);
|
||||
const systemId = ref('1');
|
||||
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { lg: 12, md: 24 }
|
||||
});
|
||||
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
resetFields();
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (isUpdate.value) {
|
||||
rowId.value = data.record.id;
|
||||
if (data.record && data.record.meta && data.record.meta.formId) {
|
||||
hasMetaFormId.value = true;
|
||||
}
|
||||
componentType.value = data.record.componentType;
|
||||
if (data.record.outLink == 1) {
|
||||
data.record.url = data.record.component;
|
||||
}
|
||||
if (data.record.parentId) {
|
||||
data.record.systemId = null;
|
||||
}
|
||||
setFieldsValue({
|
||||
...data.record
|
||||
});
|
||||
getMenuButtonById({ id: data.record.id }).then((res) => {
|
||||
buttonDatas.value = res;
|
||||
});
|
||||
getMenuColumnById({ menuId: data.record.id }).then((res) => {
|
||||
columnDatas.value = res;
|
||||
});
|
||||
getMenuFormById({ menuId: data.record.id }).then((res) => {
|
||||
formDatas.value = res;
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
componentType.value = 0;
|
||||
setFieldsValue({
|
||||
menuType: 1,
|
||||
enabledMark: 1,
|
||||
outLink: 0,
|
||||
display: 1,
|
||||
componentType: 0,
|
||||
systemId: '1'
|
||||
});
|
||||
}
|
||||
const treeData = await getMenuTree();
|
||||
|
||||
const system = await getSubSystemList();
|
||||
|
||||
updateSchema([
|
||||
{
|
||||
field: 'parentId',
|
||||
componentProps: ({ formModel }) => {
|
||||
return {
|
||||
getPopupContainer: () => document.body,
|
||||
onChange: (v) => {
|
||||
findParentSystem(treeData, treeData, v);
|
||||
formModel.systemId = systemId.value;
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'systemId',
|
||||
componentProps: { options: system }
|
||||
},
|
||||
{
|
||||
field: 'outLink',
|
||||
dynamicDisabled: () => {
|
||||
return isUpdate.value && componentType.value == 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'path',
|
||||
dynamicDisabled: () => {
|
||||
return isUpdate.value && componentType.value == 1;
|
||||
}
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
const getTitle = computed(() => (!isUpdate.value ? t('新增菜单') : t('编辑菜单')));
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
if (values.outLink == 1) {
|
||||
values.component = values.url;
|
||||
}
|
||||
values.buttonList = buttonTable.value ? buttonTable.value.getDataSource() : buttonDatas.value;
|
||||
values.columnList = columnTable.value ? columnTable.value.getDataSource() : columnDatas.value;
|
||||
values.formList = formTable.value ? formTable.value.getDataSource() : formDatas.value;
|
||||
setDrawerProps({ confirmLoading: true });
|
||||
// TODO custom api
|
||||
if (!isUpdate.value) {
|
||||
//false 新增
|
||||
await addMenu(values);
|
||||
notification.success({
|
||||
message: t('提示'),
|
||||
description: t('新增菜单成功')
|
||||
}); //提示消息
|
||||
} else {
|
||||
values.id = rowId.value;
|
||||
await updateMenu(values);
|
||||
notification.success({
|
||||
message: t('提示'),
|
||||
description: t('修改菜单成功')
|
||||
}); //提示消息
|
||||
}
|
||||
await permissionStore.buildRoutesAction();
|
||||
closeDrawer();
|
||||
emit('success');
|
||||
} catch (error) {
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
function findParentSystem(treeData, tempTree, id) {
|
||||
for (let i = 0; i < treeData.length; i++) {
|
||||
let o = treeData[i];
|
||||
|
||||
if (o.id == id) {
|
||||
systemId.value = o.systemId;
|
||||
if (o.parentId) {
|
||||
findParentSystem(tempTree, tempTree, o.parentId);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (o.children?.length > 0) {
|
||||
findParentSystem(o.children, tempTree, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
registerDrawer,
|
||||
registerForm,
|
||||
getTitle,
|
||||
hasMetaFormId,
|
||||
handleSubmit,
|
||||
buttonTable,
|
||||
rowId,
|
||||
columnTable,
|
||||
formTable,
|
||||
activeKey,
|
||||
t
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,83 +1,83 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: t('表单项名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: t('表单项编码'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MenuButtonModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
actionColOptions: {
|
||||
span: 23,
|
||||
import { defineComponent, ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
const { t } = useI18n();
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: t('表单项名称'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
resetFields();
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
rowId.value = data.record.key;
|
||||
|
||||
setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
{
|
||||
field: 'code',
|
||||
label: t('表单项编码'),
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
}
|
||||
});
|
||||
];
|
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('新增表单项') : t('编辑表单项')));
|
||||
export default defineComponent({
|
||||
name: 'MenuButtonModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
actionColOptions: {
|
||||
span: 23
|
||||
}
|
||||
});
|
||||
|
||||
closeModal();
|
||||
emit('success', { isUpdate: unref(isUpdate), record: { ...values, key: rowId.value } });
|
||||
} catch (error) {
|
||||
setModalProps({ confirmLoading: false });
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
resetFields();
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
rowId.value = data.record.key;
|
||||
|
||||
setFieldsValue({
|
||||
...data.record
|
||||
});
|
||||
} else {
|
||||
rowId.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('新增表单项') : t('编辑表单项')));
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
|
||||
closeModal();
|
||||
emit('success', { isUpdate: unref(isUpdate), record: { ...values, key: rowId.value } });
|
||||
} catch (error) {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
return { registerModal, registerForm, getTitle, handleSubmit, t };
|
||||
}
|
||||
}
|
||||
|
||||
return { registerModal, registerForm, getTitle, handleSubmit, t };
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,422 +1,373 @@
|
||||
<template>
|
||||
<span @click.stop="open"
|
||||
><slot></slot>
|
||||
<ModalPanel
|
||||
:visible="data.visible"
|
||||
:width="1100"
|
||||
:title="t('API配置')"
|
||||
@submit="submit"
|
||||
@close="close"
|
||||
>
|
||||
<NodeHead class="mb-3 mt-3 ml-3" :nodeName="t('API配置')" />
|
||||
<div class="form-box">
|
||||
<div class="label"><em class="text-red-600">*</em>{{ t('打印模板') }}:</div>
|
||||
<a-select
|
||||
class="flex"
|
||||
v-model:value="data.printId"
|
||||
style="width: 100%"
|
||||
placeholder="请选择打印模板"
|
||||
@change="submitPrintId"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="(item, index) in data.printData"
|
||||
:key="index"
|
||||
:value="item.id"
|
||||
:disabled="item.enabledMark == 0"
|
||||
>
|
||||
{{ item.name }}</a-select-option
|
||||
>
|
||||
</a-select>
|
||||
</div>
|
||||
<div class="form-box">
|
||||
<div class="item">
|
||||
<div class="label"><em class="text-red-600">*</em>{{ t('接口名称') }}:</div>
|
||||
<a-input
|
||||
v-model:value="data.config.name"
|
||||
:placeholder="t('点击选择接口')"
|
||||
disabled
|
||||
style="width: 100%"
|
||||
class="flex"
|
||||
>
|
||||
<template #suffix>
|
||||
<Icon icon="ant-design:ellipsis-outlined" />
|
||||
</template>
|
||||
</a-input>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label"><em class="text-red-600">*</em>{{ t('请求方法') }}:</div>
|
||||
<a-input
|
||||
v-model:value="data.config.method"
|
||||
disabled
|
||||
:placeholder="t('请求方法')"
|
||||
class="flex"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #suffix>
|
||||
<Icon icon="ant-design:ellipsis-outlined" />
|
||||
</template>
|
||||
</a-input>
|
||||
</div>
|
||||
</div>
|
||||
<a-tabs v-if="data.visible" class="padding">
|
||||
<a-tab-pane :key="item.key" :tab="item.title" v-for="item in data.apiParams">
|
||||
<a-table
|
||||
:dataSource="item.tableInfo"
|
||||
:columns="apiConfigColumns"
|
||||
:pagination="false"
|
||||
:scroll="{ y: '260px' }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'assignmentType'">
|
||||
<a-select
|
||||
v-model:value="record.assignmentType"
|
||||
style="width: 100%"
|
||||
:placeholder="t('请选择赋值类型')"
|
||||
>
|
||||
<a-select-option :value="bind.value" v-for="bind in bindType" :key="bind.value">
|
||||
{{ bind.label }}
|
||||
</a-select-option>
|
||||
<span @click.stop="open"
|
||||
><slot></slot>
|
||||
<ModalPanel :visible="data.visible" :width="1100" :title="t('API配置')" @submit="submit" @close="close">
|
||||
<NodeHead class="mb-3 mt-3 ml-3" :nodeName="t('API配置')" />
|
||||
<div class="form-box">
|
||||
<div class="label"><em class="text-red-600">*</em>{{ t('打印模板') }}:</div>
|
||||
<a-select class="flex" v-model:value="data.printId" style="width: 100%" placeholder="请选择打印模板" @change="submitPrintId">
|
||||
<a-select-option v-for="(item, index) in data.printData" :key="index" :value="item.id" :disabled="item.enabledMark == 0"> {{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'value'">
|
||||
<a-tree-select
|
||||
v-if="record.assignmentType === 'data'"
|
||||
v-model:value="record.config"
|
||||
show-search
|
||||
style="width: 100%"
|
||||
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||
placeholder="Please select"
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:tree-data="data.formConfigData"
|
||||
:field-names="{
|
||||
children: 'children',
|
||||
label: 'title',
|
||||
value: 'key',
|
||||
}"
|
||||
/>
|
||||
<a-input
|
||||
v-else
|
||||
v-model:value="record.value"
|
||||
:placeholder="record.type ? t('请填写值') : t('请先选择赋值类型后再配置值')"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</ModalPanel>
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-box">
|
||||
<div class="item">
|
||||
<div class="label"><em class="text-red-600">*</em>{{ t('接口名称') }}:</div>
|
||||
<a-input v-model:value="data.config.name" :placeholder="t('点击选择接口')" disabled style="width: 100%" class="flex">
|
||||
<template #suffix>
|
||||
<Icon icon="ant-design:ellipsis-outlined" />
|
||||
</template>
|
||||
</a-input>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label"><em class="text-red-600">*</em>{{ t('请求方法') }}:</div>
|
||||
<a-input v-model:value="data.config.method" disabled :placeholder="t('请求方法')" class="flex" style="width: 100%">
|
||||
<template #suffix>
|
||||
<Icon icon="ant-design:ellipsis-outlined" />
|
||||
</template>
|
||||
</a-input>
|
||||
</div>
|
||||
</div>
|
||||
<a-tabs v-if="data.visible" class="padding">
|
||||
<a-tab-pane :key="item.key" :tab="item.title" v-for="item in data.apiParams">
|
||||
<a-table :dataSource="item.tableInfo" :columns="apiConfigColumns" :pagination="false" :scroll="{ y: '260px' }">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'assignmentType'">
|
||||
<a-select v-model:value="record.assignmentType" style="width: 100%" :placeholder="t('请选择赋值类型')">
|
||||
<a-select-option :value="bind.value" v-for="bind in bindType" :key="bind.value">
|
||||
{{ bind.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'value'">
|
||||
<a-tree-select
|
||||
v-if="record.assignmentType === 'data'"
|
||||
v-model:value="record.config"
|
||||
show-search
|
||||
style="width: 100%"
|
||||
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||
placeholder="Please select"
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:tree-data="data.formConfigData"
|
||||
:field-names="{
|
||||
children: 'children',
|
||||
label: 'title',
|
||||
value: 'key'
|
||||
}"
|
||||
/>
|
||||
<a-input v-else v-model:value="record.value" :placeholder="record.type ? t('请填写值') : t('请先选择赋值类型后再配置值')" />
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</ModalPanel>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { NodeHead, ModalPanel } from '/@/components/ModalPanel/index';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { ApiConfig, InputParamItem } from '/@/components/ApiConfig/src/interface';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { TreeProps, notification } from 'ant-design-vue';
|
||||
import { PrintBasicData, PrintButtonRowItem, PrintConfigData } from '/@/model/generator/print';
|
||||
import {
|
||||
addPrintConfig,
|
||||
getDesignInfo,
|
||||
getDesignPrintList,
|
||||
getPrintConfigInfo,
|
||||
} from '/@/api/system/generator/print';
|
||||
import { camelCaseString } from '/@/utils/event/design';
|
||||
const { t } = useI18n();
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
row: PrintButtonRowItem;
|
||||
hasMetaFormId: Boolean;
|
||||
}>(),
|
||||
{},
|
||||
);
|
||||
const bindType = ref([
|
||||
{
|
||||
label: t('值'),
|
||||
value: 'value',
|
||||
},
|
||||
]);
|
||||
let emits = defineEmits(['close']);
|
||||
let data: {
|
||||
visible: boolean;
|
||||
printId: string;
|
||||
printData: Array<PrintBasicData>;
|
||||
config: ApiConfig;
|
||||
formConfigData: TreeProps['treeData'];
|
||||
apiParams: Array<{ key: string; title: string; tableInfo: Array<InputParamItem> }>;
|
||||
} = reactive({
|
||||
visible: false,
|
||||
printId: '',
|
||||
printData: [],
|
||||
formConfigData: [],
|
||||
config: {
|
||||
id: '',
|
||||
name: '',
|
||||
method: '',
|
||||
requestParamsConfigs: [], //Query Params
|
||||
requestHeaderConfigs: [], //Header
|
||||
requestBodyConfigs: [], //Body
|
||||
},
|
||||
apiParams: [
|
||||
{
|
||||
key: '1',
|
||||
title: 'Query Params',
|
||||
tableInfo: [],
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
title: 'Header',
|
||||
tableInfo: [],
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
title: 'Body',
|
||||
tableInfo: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
function setApiConfig() {
|
||||
data.apiParams[0].tableInfo = data.config.requestParamsConfigs;
|
||||
|
||||
data.apiParams[1].tableInfo = data.config.requestHeaderConfigs;
|
||||
|
||||
data.apiParams[2].tableInfo = data.config.requestBodyConfigs;
|
||||
}
|
||||
async function submitPrintId(id) {
|
||||
let res = await getDesignInfo(id);
|
||||
if (res) {
|
||||
data.config = JSON.parse(res.apiConfig);
|
||||
setApiConfig();
|
||||
}
|
||||
}
|
||||
async function open() {
|
||||
data.visible = true;
|
||||
try {
|
||||
if (props.hasMetaFormId) {
|
||||
bindType.value = [
|
||||
{
|
||||
import { NodeHead, ModalPanel } from '/@/components/ModalPanel/index';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { ApiConfig, InputParamItem } from '/@/components/ApiConfig/src/interface';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { TreeProps, notification } from 'ant-design-vue';
|
||||
import { PrintBasicData, PrintButtonRowItem, PrintConfigData } from '/@/model/generator/print';
|
||||
import { addPrintConfig, getDesignInfo, getDesignPrintList, getPrintConfigInfo } from '/@/api/system/generator/print';
|
||||
import { camelCaseString } from '/@/utils/event/design';
|
||||
const { t } = useI18n();
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
row: PrintButtonRowItem;
|
||||
hasMetaFormId: Boolean;
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
const bindType = ref([
|
||||
{
|
||||
label: t('值'),
|
||||
value: 'value',
|
||||
},
|
||||
{
|
||||
label: t('表单数据'),
|
||||
value: 'data',
|
||||
},
|
||||
];
|
||||
}
|
||||
let res = await getDesignPrintList();
|
||||
data.printData = res;
|
||||
let info = await getPrintConfigInfo(getButtonCode(), props.row.menuId);
|
||||
if (info.enabledMark == null) {
|
||||
// notification.warning({
|
||||
// message: t('提示'),
|
||||
// description: t('当前功能未绑定打印模板,请绑定后再进行模板打印。'),
|
||||
// });
|
||||
if (props.hasMetaFormId && info.formJson) {
|
||||
let formConfig = JSON.parse(info.formJson);
|
||||
let formType = 1;
|
||||
if (info.formType == 0) {
|
||||
//表单类型:0 系统表单 1 自定义表单
|
||||
formType = 0;
|
||||
}
|
||||
let arr = getSchemasConfig(formConfig.formJson.list, formType);
|
||||
data.formConfigData = arr;
|
||||
value: 'value'
|
||||
}
|
||||
} else {
|
||||
if (info.enabledMark == 0) {
|
||||
notification.warning({
|
||||
message: t('提示'),
|
||||
description: t('找不到打印模板,请联系管理员。'),
|
||||
});
|
||||
} else {
|
||||
if (props.hasMetaFormId && info.formJson) {
|
||||
let formConfig = JSON.parse(info.formJson);
|
||||
let formType = 1;
|
||||
if (info.formType == 0) {
|
||||
//表单类型:0 系统表单 1 自定义表单
|
||||
formType = 0;
|
||||
]);
|
||||
let emits = defineEmits(['close']);
|
||||
let data: {
|
||||
visible: boolean;
|
||||
printId: string;
|
||||
printData: Array<PrintBasicData>;
|
||||
config: ApiConfig;
|
||||
formConfigData: TreeProps['treeData'];
|
||||
apiParams: Array<{ key: string; title: string; tableInfo: Array<InputParamItem> }>;
|
||||
} = reactive({
|
||||
visible: false,
|
||||
printId: '',
|
||||
printData: [],
|
||||
formConfigData: [],
|
||||
config: {
|
||||
id: '',
|
||||
name: '',
|
||||
method: '',
|
||||
requestParamsConfigs: [], //Query Params
|
||||
requestHeaderConfigs: [], //Header
|
||||
requestBodyConfigs: [] //Body
|
||||
},
|
||||
apiParams: [
|
||||
{
|
||||
key: '1',
|
||||
title: 'Query Params',
|
||||
tableInfo: []
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
title: 'Header',
|
||||
tableInfo: []
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
title: 'Body',
|
||||
tableInfo: []
|
||||
}
|
||||
let arr = getSchemasConfig(formConfig.formJson.list, formType);
|
||||
data.formConfigData = arr;
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
if (info.schemaId) {
|
||||
data.printId = info.schemaId;
|
||||
}
|
||||
if (info.apiConfig) {
|
||||
data.config = JSON.parse(info.apiConfig);
|
||||
function setApiConfig() {
|
||||
data.apiParams[0].tableInfo = data.config.requestParamsConfigs;
|
||||
|
||||
data.apiParams[1].tableInfo = data.config.requestHeaderConfigs;
|
||||
|
||||
data.apiParams[2].tableInfo = data.config.requestBodyConfigs;
|
||||
}
|
||||
async function submitPrintId(id) {
|
||||
let res = await getDesignInfo(id);
|
||||
if (res) {
|
||||
data.config = JSON.parse(res.apiConfig);
|
||||
setApiConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
function close() {
|
||||
data.visible = false;
|
||||
emits('close');
|
||||
}
|
||||
function getButtonCode() {
|
||||
let buttonCode = props.row.code;
|
||||
if (props.row.code.includes(':')) {
|
||||
let arr = props.row.code.split(':');
|
||||
arr.shift();
|
||||
buttonCode = arr.join('');
|
||||
}
|
||||
return buttonCode;
|
||||
}
|
||||
async function submit() {
|
||||
// 提交配置
|
||||
async function open() {
|
||||
data.visible = true;
|
||||
try {
|
||||
if (props.hasMetaFormId) {
|
||||
bindType.value = [
|
||||
{
|
||||
label: t('值'),
|
||||
value: 'value'
|
||||
},
|
||||
{
|
||||
label: t('表单数据'),
|
||||
value: 'data'
|
||||
}
|
||||
];
|
||||
}
|
||||
let res = await getDesignPrintList();
|
||||
data.printData = res;
|
||||
let info = await getPrintConfigInfo(getButtonCode(), props.row.menuId);
|
||||
if (info.enabledMark == null) {
|
||||
// notification.warning({
|
||||
// message: t('提示'),
|
||||
// description: t('当前功能未绑定打印模板,请绑定后再进行模板打印。'),
|
||||
// });
|
||||
if (props.hasMetaFormId && info.formJson) {
|
||||
let formConfig = JSON.parse(info.formJson);
|
||||
let formType = 1;
|
||||
if (info.formType == 0) {
|
||||
//表单类型:0 系统表单 1 自定义表单
|
||||
formType = 0;
|
||||
}
|
||||
let arr = getSchemasConfig(formConfig.formJson.list, formType);
|
||||
data.formConfigData = arr;
|
||||
}
|
||||
} else {
|
||||
if (info.enabledMark == 0) {
|
||||
notification.warning({
|
||||
message: t('提示'),
|
||||
description: t('找不到打印模板,请联系管理员。')
|
||||
});
|
||||
} else {
|
||||
if (props.hasMetaFormId && info.formJson) {
|
||||
let formConfig = JSON.parse(info.formJson);
|
||||
let formType = 1;
|
||||
if (info.formType == 0) {
|
||||
//表单类型:0 系统表单 1 自定义表单
|
||||
formType = 0;
|
||||
}
|
||||
let arr = getSchemasConfig(formConfig.formJson.list, formType);
|
||||
data.formConfigData = arr;
|
||||
}
|
||||
|
||||
let submitData: PrintConfigData = {
|
||||
apiConfig: JSON.stringify(data.config),
|
||||
buttonCode: getButtonCode(),
|
||||
buttonId: props.row.id,
|
||||
menuId: props.row.menuId,
|
||||
schemaId: data.printId,
|
||||
};
|
||||
try {
|
||||
let res = await addPrintConfig(submitData);
|
||||
if (res) {
|
||||
close();
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
function getSchemasConfig(list, formType) {
|
||||
const arr: TreeProps['treeData'] = [];
|
||||
if (list && list.length > 0) {
|
||||
list.forEach((ele1) => {
|
||||
if (['card', 'Card', 'tab', 'grid'].includes(ele1.type)) {
|
||||
if (ele1.layout && ele1.layout.length > 0) {
|
||||
ele1.layout.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele2.list, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (['one-for-one'].includes(ele1.type) || ['form'].includes(ele1.type)) {
|
||||
if (ele1.children && ele1.children.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele1.children, formType));
|
||||
}
|
||||
} else if (['table-layout'].includes(ele1.type)) {
|
||||
if (ele1.layout && ele1.layout.length > 0) {
|
||||
ele1.layout.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
ele2.list.forEach((ele3) => {
|
||||
if (ele3.children && ele3.children.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele3.children, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (['Card', 'Tab'].includes(ele1.component)) {
|
||||
if (ele1.children && ele1.children.length > 0) {
|
||||
ele1.children.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele2.list, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (ele1.component === 'TableLayout') {
|
||||
if (ele1.children && ele1.children.length > 0) {
|
||||
ele1.children.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
ele2.list.forEach((ele3) => {
|
||||
if (ele3.children && ele3.children.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele3.children, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (ele1.component == 'SubForm') {
|
||||
} else {
|
||||
if (ele1.type && ele1.label && ele1.bindField && !disableTypes.includes(ele1.type)) {
|
||||
let bindField = formType == 0 ? camelCaseString(ele1.bindField) : ele1.bindField;
|
||||
arr.push({
|
||||
title: ele1.label ? ele1.label : bindField,
|
||||
key: bindField,
|
||||
children: [],
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
if (info.schemaId) {
|
||||
data.printId = info.schemaId;
|
||||
}
|
||||
if (info.apiConfig) {
|
||||
data.config = JSON.parse(info.apiConfig);
|
||||
setApiConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
// 去除不能选择的表单字段
|
||||
const visitorsBookType = 'opinion'; //意见簿类型
|
||||
const titleType = 'title'; //标题类型
|
||||
const dividerType = 'divider'; //分割线类型
|
||||
const infoType = 'info'; //信息体
|
||||
const autoCodeType = 'auto-code'; //编码
|
||||
const buttonType = 'button'; //按钮
|
||||
// 标题,分割线、信息体,按钮,编码,意见簿,只允许查看权限
|
||||
const disableTypes = [
|
||||
visitorsBookType,
|
||||
titleType,
|
||||
dividerType,
|
||||
infoType,
|
||||
autoCodeType,
|
||||
buttonType,
|
||||
'qrcode', //二维码组件
|
||||
];
|
||||
function close() {
|
||||
data.visible = false;
|
||||
emits('close');
|
||||
}
|
||||
function getButtonCode() {
|
||||
let buttonCode = props.row.code;
|
||||
if (props.row.code.includes(':')) {
|
||||
let arr = props.row.code.split(':');
|
||||
arr.shift();
|
||||
buttonCode = arr.join('');
|
||||
}
|
||||
return buttonCode;
|
||||
}
|
||||
async function submit() {
|
||||
// 提交配置
|
||||
|
||||
const apiConfigColumns = [
|
||||
{
|
||||
title: t('API入参名称'),
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('API入参类型'),
|
||||
dataIndex: 'dataType',
|
||||
key: 'dataType',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('赋值类型'),
|
||||
dataIndex: 'assignmentType',
|
||||
key: 'assignmentType',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('赋值配置'),
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
let submitData: PrintConfigData = {
|
||||
apiConfig: JSON.stringify(data.config),
|
||||
buttonCode: getButtonCode(),
|
||||
buttonId: props.row.id,
|
||||
menuId: props.row.menuId,
|
||||
schemaId: data.printId
|
||||
};
|
||||
try {
|
||||
let res = await addPrintConfig(submitData);
|
||||
if (res) {
|
||||
close();
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
function getSchemasConfig(list, formType) {
|
||||
const arr: TreeProps['treeData'] = [];
|
||||
if (list && list.length > 0) {
|
||||
list.forEach((ele1) => {
|
||||
if (['card', 'Card', 'tab', 'grid'].includes(ele1.type)) {
|
||||
if (ele1.layout && ele1.layout.length > 0) {
|
||||
ele1.layout.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele2.list, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (['one-for-one'].includes(ele1.type) || ['form'].includes(ele1.type)) {
|
||||
if (ele1.children && ele1.children.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele1.children, formType));
|
||||
}
|
||||
} else if (['table-layout'].includes(ele1.type)) {
|
||||
if (ele1.layout && ele1.layout.length > 0) {
|
||||
ele1.layout.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
ele2.list.forEach((ele3) => {
|
||||
if (ele3.children && ele3.children.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele3.children, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (['Card', 'Tab'].includes(ele1.component)) {
|
||||
if (ele1.children && ele1.children.length > 0) {
|
||||
ele1.children.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele2.list, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (ele1.component === 'TableLayout') {
|
||||
if (ele1.children && ele1.children.length > 0) {
|
||||
ele1.children.forEach((ele2) => {
|
||||
if (ele2.list && ele2.list.length > 0) {
|
||||
ele2.list.forEach((ele3) => {
|
||||
if (ele3.children && ele3.children.length > 0) {
|
||||
arr.push(...getSchemasConfig(ele3.children, formType));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (ele1.component == 'SubForm') {
|
||||
} else {
|
||||
if (ele1.type && ele1.label && ele1.bindField && !disableTypes.includes(ele1.type)) {
|
||||
let bindField = formType == 0 ? camelCaseString(ele1.bindField) : ele1.bindField;
|
||||
arr.push({
|
||||
title: ele1.label ? ele1.label : bindField,
|
||||
key: bindField,
|
||||
children: []
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
// 去除不能选择的表单字段
|
||||
const visitorsBookType = 'opinion'; //意见簿类型
|
||||
const titleType = 'title'; //标题类型
|
||||
const dividerType = 'divider'; //分割线类型
|
||||
const infoType = 'info'; //信息体
|
||||
const autoCodeType = 'auto-code'; //编码
|
||||
const buttonType = 'button'; //按钮
|
||||
// 标题,分割线、信息体,按钮,编码,意见簿,只允许查看权限
|
||||
const disableTypes = [
|
||||
visitorsBookType,
|
||||
titleType,
|
||||
dividerType,
|
||||
infoType,
|
||||
autoCodeType,
|
||||
buttonType,
|
||||
'qrcode' //二维码组件
|
||||
];
|
||||
|
||||
const apiConfigColumns = [
|
||||
{
|
||||
title: t('API入参名称'),
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: t('API入参类型'),
|
||||
dataIndex: 'dataType',
|
||||
key: 'dataType',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: t('赋值类型'),
|
||||
dataIndex: 'assignmentType',
|
||||
key: 'assignmentType',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: t('赋值配置'),
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
align: 'center'
|
||||
}
|
||||
];
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.form-box {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.form-box {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
}
|
||||
.item {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 100px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
.label {
|
||||
width: 100px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.flex {
|
||||
flex: 1;
|
||||
}
|
||||
.flex {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.padding {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
.padding {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user