| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588 |
- import { BasicColumn } from '/@/components/Table';
- import { FormSchema } from '/@/components/Table';
- import {
- getMenuList,
- getDictDataDropdown,
- getDatabaseList,
- getTableList,
- getColumnList,
- } from '/@/api/sys/admin';
- const apiDatabaseList = async (param: any) => {
- const result = await getDatabaseList(param);
- return result;
- };
- let currentCongidId = '';
- let tableList: any[] = [];
- const apiTableList = async (param: any) => {
- //const result = await getTableList(param);
- //return result;
- if (tableList.length === 0 || currentCongidId !== param) {
- //console.log(param);
- const result = await getTableList(param);
- tableList = result;
- } else {
- }
- currentCongidId = param;
- return tableList;
- };
- let currentTable = '';
- let columnList: any[] = [];
- const apiColumnList = async (param: any) => {
- //if (typeof param !== 'string') return [];
- if (columnList.length === 0 || currentTable !== param.e) {
- //console.log('param:' + param);
- const result = await getColumnList(param.configId, param.e);
- columnList = result;
- } else {
- }
- currentTable = param.e;
- return columnList;
- };
- const apiDictTypeDropDown = async () => {
- const result = await getDictDataDropdown('code_gen_create_type');
- return result;
- };
- export const codeShowColumns: BasicColumn[] = [
- {
- title: '库定位器',
- dataIndex: 'configId',
- },
- {
- title: '表名称',
- dataIndex: 'tableName',
- },
- {
- title: '业务名',
- dataIndex: 'busName',
- },
- {
- title: '命名空间',
- dataIndex: 'nameSpace',
- },
- {
- title: '作者姓名',
- dataIndex: 'authorName',
- },
- {
- title: '生成方式',
- dataIndex: 'generateType',
- slots: { customRender: 'generateType' },
- },
- ];
- export const codeFormSchema: FormSchema[] = [
- {
- field: 'id',
- label: 'Id',
- component: 'Input',
- show: false,
- },
- {
- field: 'configId',
- label: '库定位器',
- component: 'ApiSelect',
- componentProps: ({ formModel, formActionType }) => {
- return {
- api: apiDatabaseList,
- fieldNames: {
- label: 'configId',
- value: 'configId',
- },
- onChange: (e: any, option: any) => {
- formModel.tableName = undefined;
- formModel.dbType = option.dbType;
- formModel.connectionString = option.connectionString;
- const { updateSchema } = formActionType;
- updateSchema([
- {
- field: 'dbType',
- componentProps: {
- // api: apiTableList,
- // immediate: false,
- // params: e,
- //fieldNames: {
- // label: 'dbType',
- // value: 'dbType',
- //},
- },
- },
- {
- field: 'connectionString',
- componentProps: {
- // api: apiTableList,
- // immediate: false,
- // params: e,
- //fieldNames: {
- // label: 'connectionString',
- // value: 'connectionString',
- //},
- },
- },
- {
- field: 'tableName',
- componentProps: {
- api: apiTableList,
- immediate: false,
- params: e,
- fieldNames: {
- label: 'tableName',
- value: 'entityName',
- },
- },
- },
- ]);
- },
- };
- },
- },
- {
- field: 'dbType',
- label: '数据库类型',
- component: 'Input',
- dynamicDisabled: true,
- },
- {
- field: 'connectionString',
- label: '链接串',
- component: 'InputTextArea',
- dynamicDisabled: true,
- },
- {
- field: 'tableName',
- label: '生成表',
- component: 'ApiSelect',
- // componentProps: {
- // api: apiTableList,
- // fieldNames: {
- // label: 'tableName',
- // value: 'entityName',
- // },
- // },
- },
- {
- field: 'busName',
- label: '业务名',
- component: 'Input',
- required: true,
- },
- {
- field: 'menuPid',
- label: '父级菜单',
- component: 'ApiTreeSelect',
- componentProps: {
- api: getMenuList,
- fieldNames: {
- title: 'title',
- key: 'id',
- value: 'id',
- },
- getPopupContainer: () => document.body,
- },
- },
- {
- field: 'nameSpace',
- label: '命名空间',
- component: 'Input',
- required: true,
- defaultValue: 'Admin.NET.Application',
- },
- {
- field: 'authorName',
- label: '作者姓名',
- component: 'Input',
- required: true,
- defaultValue: 'one',
- },
- {
- field: 'generateType',
- label: '生成方式',
- component: 'ApiSelect',
- componentProps: {
- api: apiDictTypeDropDown,
- fieldNames: {
- label: 'label',
- value: 'value',
- },
- },
- defaultValue: '2',
- required: true,
- },
- ];
- // 表头
- export const columns = [
- {
- title: '字段',
- dataIndex: 'columnName',
- align: 'center',
- },
- {
- title: '描述',
- dataIndex: 'columnComment',
- align: 'center',
- width: 150,
- slots: {
- customRender: 'columnComment',
- },
- },
- {
- title: '类型',
- dataIndex: 'netType',
- align: 'center',
- },
- // {
- // title: 'java类型',
- // dataIndex: 'javaType',
- // slots: { customRender: 'javaType' }
- // },
- {
- title: '作用类型',
- dataIndex: 'effectType',
- align: 'center',
- slots: {
- customRender: 'effectType',
- },
- },
- {
- title: '字典',
- dataIndex: 'dictTypeCode',
- align: 'center',
- slots: {
- customRender: 'dictTypeCode',
- },
- },
- {
- title: '列表显示',
- align: 'center',
- dataIndex: 'whetherTable',
- slots: {
- customRender: 'whetherTable',
- },
- },
- {
- title: '增改',
- align: 'center',
- dataIndex: 'whetherAddUpdate',
- slots: {
- customRender: 'whetherAddUpdate',
- },
- },
- {
- title: '必填',
- align: 'center',
- dataIndex: 'whetherRequired',
- slots: {
- customRender: 'whetherRequired',
- },
- },
- {
- title: '是否是查询',
- align: 'center',
- dataIndex: 'queryWhether',
- slots: {
- customRender: 'queryWhether',
- },
- },
- {
- title: '查询方式',
- dataIndex: 'queryType',
- align: 'center',
- slots: {
- customRender: 'queryType',
- },
- },
- ];
- //外键
- export const fkFormSchema: FormSchema[] = [
- {
- field: 'configId',
- label: '库定位器',
- component: 'ApiSelect',
- componentProps: ({ formModel, formActionType }) => {
- return {
- api: apiDatabaseList,
- fieldNames: {
- label: 'configId',
- value: 'configId',
- },
- onChange: (e: any, option: any) => {
- formModel.tableName = option.tableName;
- formModel.dbType = option.dbType;
- formModel.connectionString = option.connectionString;
- const { updateSchema } = formActionType;
- const configId = e;
- console.log('dbchange' + configId);
- updateSchema([
- {
- field: 'tableName',
- label: '数据库表',
- component: 'ApiSelect',
- componentProps: ({ formModel, formActionType }) => {
- return {
- api: apiTableList,
- immediate: false,
- params: e,
- fieldNames: {
- label: 'tableName',
- value: 'tableName',
- },
- onChange: (e: any, option: any) => {
- formModel.columnName = undefined;
- formModel.entityName = option.entityName;
- const { updateSchema } = formActionType;
- console.log('tableNamechange' + configId);
- updateSchema({
- field: 'columnName',
- componentProps: {
- api: apiColumnList,
- immediate: false,
- fieldNames: {
- label: 'columnName',
- value: 'columnName',
- },
- params: { configId, e },
- onChange: (e: any, option: any) => {
- console.log(e + 'columnNamechange' + configId);
- formModel.columnNetType = option.netType;
- },
- },
- });
- },
- };
- },
- },
- ]);
- },
- };
- },
- },
- // {
- // field: 'tableName',
- // label: '数据库表',
- // component: 'ApiSelect',
- // componentProps: ({ formModel, formActionType }) => {
- // return {
- // api: apiTableList,
- // fieldNames: {
- // label: 'tableName',
- // value: 'tableName',
- // },
- // onChange: (e: any, option: any) => {
- // formModel.columnName = undefined;
- // formModel.entityName = option.entityName;
- // const { updateSchema } = formActionType;
- // updateSchema({
- // field: 'columnName',
- // componentProps: {
- // api: apiColumnList,
- // immediate: false,
- // fieldNames: {
- // label: 'columnName',
- // value: 'columnName',
- // },
- // params: e,
- // onChange: (e: any, option: any) => {
- // formModel.columnNetType = option.netType;
- // },
- // },
- // });
- // },
- // };
- // },
- // },
- {
- field: 'tableName',
- label: '数据库表',
- component: 'ApiSelect',
- },
- {
- field: 'columnName',
- label: '显示字段',
- component: 'ApiSelect',
- },
- {
- field: 'columnNetType',
- label: '字段类型',
- component: 'Input',
- show: false,
- },
- {
- field: 'entityName',
- label: '实体名称',
- component: 'Input',
- show: false,
- },
- ];
- //树形
- export const treeFormSchema: FormSchema[] = [
- {
- field: 'configId',
- label: '库定位器',
- component: 'ApiSelect',
- componentProps: ({ formModel, formActionType }) => {
- return {
- api: apiDatabaseList,
- fieldNames: {
- label: 'configId',
- value: 'configId',
- },
- onChange: (e: any, option: any) => {
- formModel.tableName = undefined;
- formModel.dbType = option.dbType;
- formModel.connectionString = option.connectionString;
- const { updateSchema } = formActionType;
- const configId = e;
- updateSchema([
- {
- field: 'tableName',
- label: '数据库表',
- component: 'ApiSelect',
- componentProps: ({ formModel, formActionType }) => {
- return {
- api: apiTableList,
- immediate: false,
- params: e,
- fieldNames: {
- label: 'tableName',
- value: 'tableName',
- },
- onChange: (e: any, option: any) => {
- formModel.columnName = undefined;
- formModel.entityName = option.entityName;
- const { updateSchema } = formActionType;
- updateSchema([
- {
- field: 'displayColumn',
- componentProps: {
- api: apiColumnList,
- immediate: false,
- params: { configId, e },
- fieldNames: {
- label: 'columnName',
- value: 'columnName',
- },
- },
- },
- {
- field: 'valueColumn',
- componentProps: {
- api: apiColumnList,
- immediate: false,
- params: { configId, e },
- fieldNames: {
- label: 'columnName',
- value: 'columnName',
- },
- },
- },
- {
- field: 'pidColumn',
- componentProps: {
- api: apiColumnList,
- immediate: false,
- params: { configId, e },
- fieldNames: {
- label: 'columnName',
- value: 'columnName',
- },
- },
- },
- ]);
- },
- };
- },
- },
- ]);
- },
- };
- },
- },
- // {
- // field: 'tableName',
- // label: '数据库表',
- // component: 'ApiSelect',
- // componentProps: ({ formModel, formActionType }) => {
- // return {
- // api: apiTableList,
- // fieldNames: {
- // label: 'tableName',
- // value: 'tableName',
- // },
- // onChange: (e: any, option: any) => {
- // formModel.columnName = undefined;
- // formModel.entityName = option.entityName;
- // const { updateSchema } = formActionType;
- // updateSchema([
- // {
- // field: 'displayColumn',
- // componentProps: {
- // api: apiColumnList,
- // immediate: false,
- // params: e,
- // fieldNames: {
- // label: 'columnName',
- // value: 'columnName',
- // },
- // },
- // },
- // {
- // field: 'valueColumn',
- // componentProps: {
- // api: apiColumnList,
- // immediate: false,
- // params: e,
- // fieldNames: {
- // label: 'columnName',
- // value: 'columnName',
- // },
- // },
- // },
- // {
- // field: 'pidColumn',
- // componentProps: {
- // api: apiColumnList,
- // immediate: false,
- // params: e,
- // fieldNames: {
- // label: 'columnName',
- // value: 'columnName',
- // },
- // },
- // },
- // ]);
- // },
- // };
- // },
- // },
- {
- field: 'tableName',
- label: '数据库表',
- component: 'ApiSelect',
- },
- {
- field: 'displayColumn',
- label: '显示文本字段',
- component: 'ApiSelect',
- },
- {
- field: 'valueColumn',
- label: '选择值字段',
- component: 'ApiSelect',
- },
- {
- field: 'pidColumn',
- label: '父级字段',
- component: 'ApiSelect',
- },
- {
- field: 'entityName',
- label: '实体名称',
- component: 'Input',
- show: false,
- },
- ];
|