😎格式化代码

This commit is contained in:
zuohuaijun 2024-10-31 19:01:59 +08:00
parent 81ce1a5328
commit 402125b814
6 changed files with 701 additions and 717 deletions

View File

@ -29,8 +29,4 @@
<ProjectReference Include="..\Plugins\Admin.NET.Plugin.GoView\Admin.NET.Plugin.GoView.csproj" /> <ProjectReference Include="..\Plugins\Admin.NET.Plugin.GoView\Admin.NET.Plugin.GoView.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Entity\" />
</ItemGroup>
</Project> </Project>

View File

@ -45,7 +45,7 @@
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" /> <PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
<PackageReference Include="SSH.NET" Version="2024.1.0" /> <PackageReference Include="SSH.NET" Version="2024.1.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.7" /> <PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.7" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1113" /> <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1114" />
<PackageReference Include="UAParser" Version="3.1.47" /> <PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" /> <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup> </ItemGroup>

View File

@ -71,7 +71,7 @@
"vue-router": "^4.4.5", "vue-router": "^4.4.5",
"vue-signature-pad": "^3.0.2", "vue-signature-pad": "^3.0.2",
"vue3-tree-org": "^4.2.2", "vue3-tree-org": "^4.2.2",
"vxe-pc-ui": "^4.2.34", "vxe-pc-ui": "^4.2.35",
"vxe-table": "^4.7.59", "vxe-table": "^4.7.59",
"vxe-table-plugin-element": "^4.0.4", "vxe-table-plugin-element": "^4.0.4",
"vxe-table-plugin-export-xlsx": "^4.0.7", "vxe-table-plugin-export-xlsx": "^4.0.7",

View File

@ -24,7 +24,7 @@ declare type MittType<T = any> = {
openShareTagsView?: string; openShareTagsView?: string;
onTagsViewRefreshRouterView?: T; onTagsViewRefreshRouterView?: T;
onCurrentContextmenuClick?: T; onCurrentContextmenuClick?: T;
submitRefreshFk?:T submitRefreshFk?: T;
}; };
// mitt 参数类型定义 // mitt 参数类型定义

View File

@ -1,7 +1,6 @@
<template> <template>
<div class="sys-codeGenConfig-container"> <div class="sys-codeGenConfig-container">
<vxe-modal v-model="state.isShowDialog" title="生成配置" :width="800" :height="350" show-footer show-zoom resize fullscreen <vxe-modal v-model="state.isShowDialog" title="生成配置" :width="800" :height="350" show-footer show-zoom resize fullscreen @close="cancel">
@close="cancel">
<template #default> <template #default>
<vxe-grid ref="xGrid" class="xGrid-table-style" v-bind="options"> <vxe-grid ref="xGrid" class="xGrid-table-style" v-bind="options">
<template #drag_default="{}"> <template #drag_default="{}">
@ -10,21 +9,17 @@
</span> </span>
</template> </template>
<template #effectType="{ row, $index }"> <template #effectType="{ row, $index }">
<vxe-select v-model="row.effectType" class="m-2" style="width: 70%" placeholder="Select" transfer <vxe-select v-model="row.effectType" class="m-2" style="width: 70%" placeholder="Select" transfer :disabled="judgeColumns(row)" @change="effectTypeChange(row, $index)" filterable>
:disabled="judgeColumns(row)" @change="effectTypeChange(row, $index)" filterable> <vxe-option v-for="item in state.effectTypeList" :key="item.code" :label="item.value" :value="item.code" />
<vxe-option v-for="item in state.effectTypeList" :key="item.code" :label="item.value"
:value="item.code" />
</vxe-select> </vxe-select>
<vxe-button v-if="row.effectType === 'ApiTreeSelect' || row.effectType === 'fk'" style="width: 30%" <vxe-button v-if="row.effectType === 'ApiTreeSelect' || row.effectType === 'fk'" style="width: 30%" icon="vxe-icon-edit" @click="effectTypeChange(row, $index)">修改</vxe-button>
icon="vxe-icon-edit" @click="effectTypeChange(row, $index)">修改</vxe-button>
</template> </template>
<template #columnComment="{ row }"> <template #columnComment="{ row }">
<vxe-input v-model="row.columnComment" autocomplete="off" /> <vxe-input v-model="row.columnComment" autocomplete="off" />
</template> </template>
<template #dictType="{ row }"> <template #dictType="{ row }">
<vxe-select v-model="row.dictTypeCode" class="m-2" :disabled="effectTypeEnable(row)" filterable transfer> <vxe-select v-model="row.dictTypeCode" class="m-2" :disabled="effectTypeEnable(row)" filterable transfer>
<vxe-option v-for="item in state.dictTypeCodeList" :key="item.code" :label="item.name" <vxe-option v-for="item in state.dictTypeCodeList" :key="item.code" :label="item.name" :value="item.code" />
:value="item.code" />
</vxe-select> </vxe-select>
</template> </template>
<template #whetherTable="{ row }"> <template #whetherTable="{ row }">
@ -41,18 +36,15 @@
<vxe-tag v-else status="info"></vxe-tag> <vxe-tag v-else status="info"></vxe-tag>
</template> </template>
<template #queryWhether="{ row }"> <template #queryWhether="{ row }">
<vxe-switch readonly v-model="row.queryWhether" open-label="" close-label="" :openValue="true" <vxe-switch readonly v-model="row.queryWhether" open-label="是" close-label="否" :openValue="true" :closeValue="false"></vxe-switch>
:closeValue="false"></vxe-switch>
</template> </template>
<template #queryType="{ row }"> <template #queryType="{ row }">
<vxe-select v-model="row.queryType" class="m-2" placeholder="Select" :disabled="!row.queryWhether" <vxe-select v-model="row.queryType" class="m-2" placeholder="Select" :disabled="!row.queryWhether" filterable transfer>
filterable transfer>
<vxe-option v-for="item in state.queryTypeList" :key="item.code" :label="item.value" :value="item.code" /> <vxe-option v-for="item in state.queryTypeList" :key="item.code" :label="item.value" :value="item.code" />
</vxe-select> </vxe-select>
</template> </template>
<template #verification="{ row }"> <template #verification="{ row }">
<vxe-button status="primary" plain v-if="row.columnKey === 'False' && !row.whetherCommon" <vxe-button status="primary" plain v-if="row.columnKey === 'False' && !row.whetherCommon" @click="openVerifyDialog(row)">校验规则{{ row.ruleCount }}</vxe-button>
@click="openVerifyDialog(row)">校验规则{{ row.ruleCount }}</vxe-button>
<span v-else></span> <span v-else></span>
</template> </template>
</vxe-grid> </vxe-grid>
@ -67,26 +59,28 @@
<treeDialog ref="treeDialogRef" @submitRefreshFk="submitRefreshFk" /> <treeDialog ref="treeDialogRef" @submitRefreshFk="submitRefreshFk" />
<verifyDialog ref="verifyDialogRef" @submitVerify="submitVerifyOk" /> <verifyDialog ref="verifyDialogRef" @submitVerify="submitVerifyOk" />
</div> </div>
</template> </template>
<script lang="ts" setup name="sysCodeGenConfig"> <script lang="ts" setup name="sysCodeGenConfig">
import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'; import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
import mittBus from '/@/utils/mitt'; import mittBus from '/@/utils/mitt';
import fkDialog from '/@/views/system/codeGen/component/fkDialog.vue'; import Sortable from 'sortablejs';
import treeDialog from '/@/views/system/codeGen/component/treeDialog.vue'; import { VxeGridInstance, VxeGridProps } from 'vxe-pc-ui';
import verifyDialog from '/@/views/system/codeGen/component/verifyDialog.vue';
import { getAPI } from '/@/utils/axios-utils'; import fkDialog from '/@/views/system/codeGen/component/fkDialog.vue';
import { SysCodeGenConfigApi, SysConstApi, SysDictDataApi, SysDictTypeApi, SysEnumApi } from '/@/api-services/api'; import treeDialog from '/@/views/system/codeGen/component/treeDialog.vue';
import { VxeGridInstance, VxeGridProps } from 'vxe-pc-ui'; import verifyDialog from '/@/views/system/codeGen/component/verifyDialog.vue';
import Sortable from 'sortablejs';
// import { CodeGenConfig } from '/@/api-services/models/code-gen-config'; import { getAPI } from '/@/utils/axios-utils';
const xGrid = ref<VxeGridInstance<any>>(); import { SysCodeGenConfigApi, SysConstApi, SysDictDataApi, SysDictTypeApi, SysEnumApi } from '/@/api-services/api';
const emits = defineEmits(['handleQuery']); // import { CodeGenConfig } from '/@/api-services/models/code-gen-config';
const fkDialogRef = ref();
const treeDialogRef = ref(); const xGrid = ref<VxeGridInstance<any>>();
const verifyDialogRef = ref(); const emits = defineEmits(['handleQuery']);
const state = reactive({ const fkDialogRef = ref();
const treeDialogRef = ref();
const verifyDialogRef = ref();
const state = reactive({
isShowDialog: false, isShowDialog: false,
loading: false, loading: false,
dbData: [] as any, dbData: [] as any,
@ -97,9 +91,10 @@
allConstSelector: [] as any, allConstSelector: [] as any,
allEnumSelector: [] as any, allEnumSelector: [] as any,
sortable: undefined as any, sortable: undefined as any,
}); });
//
const options = reactive<VxeGridProps>({ //
const options = reactive<VxeGridProps>({
id: 'genConfigDialog', id: 'genConfigDialog',
height: 'auto', height: 'auto',
keepSource: true, keepSource: true,
@ -225,9 +220,9 @@
}, },
], ],
editConfig: { trigger: 'click', mode: 'row', showStatus: true }, editConfig: { trigger: 'click', mode: 'row', showStatus: true },
}); });
const rowDrop = () => { const rowDrop = () => {
const el = document.querySelector('.xGrid-table-style .vxe-table--body tbody') as HTMLElement; const el = document.querySelector('.xGrid-table-style .vxe-table--body tbody') as HTMLElement;
state.sortable = Sortable.create(el, { state.sortable = Sortable.create(el, {
animation: 300, animation: 300,
@ -261,10 +256,10 @@
xGrid.value?.updateData(); xGrid.value?.updateData();
}, },
}); });
}; };
// //
onMounted(async () => { onMounted(async () => {
// //
var res = await getAPI(SysDictDataApi).apiSysDictDataDataListCodeGet('code_gen_effect_type'); var res = await getAPI(SysDictDataApi).apiSysDictDataDataListCodeGet('code_gen_effect_type');
state.effectTypeList = res.data.result; state.effectTypeList = res.data.result;
@ -291,22 +286,23 @@
tableData[data.index] = data; tableData[data.index] = data;
xGrid.value?.loadData(tableData); xGrid.value?.loadData(tableData);
}); });
}); });
// //
const submitRefreshFk = (data: any) => { const submitRefreshFk = (data: any) => {
let tableData = xGrid.value?.getData() || []; let tableData = xGrid.value?.getData() || [];
tableData[data.index] = data; tableData[data.index] = data;
xGrid.value?.reloadData(tableData); xGrid.value?.reloadData(tableData);
}; };
onUnmounted(() => { //
onUnmounted(() => {
// mittBus.off('submitRefresh', () => {}); // mittBus.off('submitRefresh', () => {});
mittBus.off('submitRefreshFk', () => { }); mittBus.off('submitRefreshFk', () => {});
}); });
// //
const effectTypeChange = (data: any, index: number) => { const effectTypeChange = (data: any, index: number) => {
let value = data.effectType; let value = data.effectType;
if (value === 'fk') { if (value === 'fk') {
openFkDialog(data, index); openFkDialog(data, index);
@ -322,10 +318,10 @@
data.dictTypeCode = ''; data.dictTypeCode = '';
state.dictTypeCodeList = state.allEnumSelector; state.dictTypeCodeList = state.allEnumSelector;
} }
}; };
// //
const handleQuery = async (row: any) => { const handleQuery = async (row: any) => {
state.loading = true; state.loading = true;
var res = await getAPI(SysCodeGenConfigApi).apiSysCodeGenConfigListGet(undefined, row.id); var res = await getAPI(SysCodeGenConfigApi).apiSysCodeGenConfigListGet(undefined, row.id);
var data = res.data.result ?? []; var data = res.data.result ?? [];
@ -348,54 +344,54 @@
}); });
xGrid.value?.loadData(data); xGrid.value?.loadData(data);
state.loading = false; state.loading = false;
}; };
// //
function judgeColumns(data: any) { function judgeColumns(data: any) {
return data.whetherCommon == true || data.columnKey === 'True'; return data.whetherCommon == true || data.columnKey === 'True';
} }
function effectTypeEnable(data: any) { function effectTypeEnable(data: any) {
var lst = ['Radio', 'Select', 'Checkbox', 'ConstSelector', 'EnumSelector']; var lst = ['Radio', 'Select', 'Checkbox', 'ConstSelector', 'EnumSelector'];
return lst.indexOf(data.effectType) === -1; return lst.indexOf(data.effectType) === -1;
} }
// //
const openDialog = async (addRow: any) => { const openDialog = async (addRow: any) => {
state.isShowDialog = true; state.isShowDialog = true;
nextTick(async () => { nextTick(async () => {
await handleQuery(addRow); await handleQuery(addRow);
rowDrop(); rowDrop();
}); });
}; };
// //
const openFkDialog = (addRow: any, index: number) => { const openFkDialog = (addRow: any, index: number) => {
addRow.index = index; addRow.index = index;
fkDialogRef.value.openDialog(addRow); fkDialogRef.value.openDialog(addRow);
}; };
const openTreeDialog = (addRow: any, index: number) => { const openTreeDialog = (addRow: any, index: number) => {
addRow.index = index; addRow.index = index;
treeDialogRef.value.openDialog(addRow); treeDialogRef.value.openDialog(addRow);
}; };
// //
const openVerifyDialog = (row: any) => { const openVerifyDialog = (row: any) => {
// handleQuery(addRow); // handleQuery(addRow);
// state.isShowDialog = true; // state.isShowDialog = true;
verifyDialogRef.value.openDialog(row); verifyDialogRef.value.openDialog(row);
}; };
// //
const submitVerifyOk = (data: any) => { const submitVerifyOk = (data: any) => {
let tableData = xGrid.value?.getData() || []; let tableData = xGrid.value?.getData() || [];
for (let i = 0; i < tableData.length; i++) { for (let i = 0; i < tableData.length; i++) {
if (tableData[i].id == data.id) { if (tableData[i].id == data.id) {
tableData[i].rules = data.rules; tableData[i].rules = data.rules;
tableData[i].ruleCount = data.ruleCount; tableData[i].ruleCount = data.ruleCount;
// //
let rules = new Array(); let rules = new Array();
if (data.rules != '' && data.rules !== null) { if (data.rules != '' && data.rules !== null) {
rules = JSON.parse(data.rules); rules = JSON.parse(data.rules);
@ -410,28 +406,27 @@
} }
} }
xGrid.value?.reloadData(tableData); xGrid.value?.reloadData(tableData);
}; };
// //
const closeDialog = () => { const closeDialog = () => {
emits('handleQuery'); emits('handleQuery');
cancel(); cancel();
}; };
// //
const cancel = () => { const cancel = () => {
xGrid.value?.loadData([]); xGrid.value?.loadData([]);
state.isShowDialog = false; state.isShowDialog = false;
if (state.sortable) { if (state.sortable) {
state.sortable.destroy(); state.sortable.destroy();
} }
}; };
// //
const submit = async () => { const submit = async () => {
state.loading = true; state.loading = true;
let lst = xGrid.value?.getData() || []; let lst = xGrid.value?.getData() || [];
// console.log(lst);
let ignoreFields = ['remoteVerify', 'anyRule', 'columnKey']; let ignoreFields = ['remoteVerify', 'anyRule', 'columnKey'];
lst.forEach((item: any) => { lst.forEach((item: any) => {
// //
@ -447,15 +442,15 @@
await getAPI(SysCodeGenConfigApi).apiSysCodeGenConfigUpdatePost(lst); await getAPI(SysCodeGenConfigApi).apiSysCodeGenConfigUpdatePost(lst);
state.loading = false; state.loading = false;
closeDialog(); closeDialog();
}; };
// //
defineExpose({ openDialog }); defineExpose({ openDialog });
</script> </script>
<style lang="scss" scoped>
.xGrid-table-style .drag-btn { <style lang="scss" scoped>
.xGrid-table-style .drag-btn {
cursor: move; cursor: move;
font-size: 20px; font-size: 20px;
} }
</style> </style>

View File

@ -1,20 +1,17 @@
<template> <template>
<div class="sys-dbTable-container"> <div class="sys-dbTable-container">
<vxe-modal v-model="state.visible" title="增加表" :width="800" :height="350" resize show-footer show-confirm-button <vxe-modal v-model="state.visible" title="增加表" :width="800" :height="350" resize show-footer show-confirm-button show-cancel-button show-zoom fullscreen @close="cancel">
show-cancel-button show-zoom fullscreen @close="cancel">
<template #default> <template #default>
<el-divider content-position="left" style="margin: 10px 0 18px 0">数据表信息</el-divider> <el-divider content-position="left" style="margin: 10px 0 18px 0">数据表信息</el-divider>
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto"> <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
<el-row> <el-row>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="表名称" prop="tableName" <el-form-item label="表名称" prop="tableName" :rules="[{ required: true, message: '名称不能为空', trigger: 'blur' }]">
:rules="[{ required: true, message: '名称不能为空', trigger: 'blur' }]">
<el-input v-model.lazy.trim="state.ruleForm.tableName" placeholder="表名称" clearable /> <el-input v-model.lazy.trim="state.ruleForm.tableName" placeholder="表名称" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="描述" prop="description" <el-form-item label="描述" prop="description" :rules="[{ required: true, message: '描述不能为空', trigger: 'blur' }]">
:rules="[{ required: true, message: '描述不能为空', trigger: 'blur' }]">
<el-input v-model.lazy.trim="state.ruleForm.description" placeholder="描述" clearable type="textarea" /> <el-input v-model.lazy.trim="state.ruleForm.description" placeholder="描述" clearable type="textarea" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -40,16 +37,13 @@
</span> </span>
</template> </template>
<template #isPrimarykey="{ row }"> <template #isPrimarykey="{ row }">
<vxe-switch readonly v-model="row.isPrimarykey" open-label="" close-label="" :openValue="1" <vxe-switch readonly v-model="row.isPrimarykey" open-label="是" close-label="否" :openValue="1" :closeValue="0"></vxe-switch>
:closeValue="0"></vxe-switch>
</template> </template>
<template #isIdentity="{ row }"> <template #isIdentity="{ row }">
<vxe-switch readonly v-model="row.isIdentity" open-label="" close-label="" :openValue="1" <vxe-switch readonly v-model="row.isIdentity" open-label="是" close-label="否" :openValue="1" :closeValue="0"></vxe-switch>
:closeValue="0"></vxe-switch>
</template> </template>
<template #isNullable="{ row }"> <template #isNullable="{ row }">
<vxe-switch readonly v-model="row.isNullable" open-label="" close-label="" :openValue="1" <vxe-switch readonly v-model="row.isNullable" open-label="是" close-label="否" :openValue="1" :closeValue="0"></vxe-switch>
:closeValue="0"></vxe-switch>
</template> </template>
<template #operate="{ row }"> <template #operate="{ row }">
<vxe-button mode="text" status="error" icon="vxe-icon-delete" @click="deleteRow(row)" /> <vxe-button mode="text" status="error" icon="vxe-icon-delete" @click="deleteRow(row)" />
@ -63,32 +57,31 @@
</template> </template>
</vxe-modal> </vxe-modal>
</div> </div>
</template> </template>
<script lang="tsx" setup name="sysAddTable"> <script lang="tsx" setup name="sysAddTable">
import { nextTick, reactive, ref } from 'vue'; import { nextTick, reactive, ref } from 'vue';
import { ElMessage, dayjs } from 'element-plus'; import { ElMessage, dayjs } from 'element-plus';
import { VxeGridInstance, VxeGridProps } from 'vxe-table'; import { VxeGridInstance, VxeGridProps } from 'vxe-table';
import { Rank } from '@element-plus/icons-vue'; import Sortable from 'sortablejs';
import Sortable from 'sortablejs'; import { dataTypeList } from '../database';
import { dataTypeList } from '../database';
import { getAPI } from '/@/utils/axios-utils'; import { getAPI } from '/@/utils/axios-utils';
import { SysDatabaseApi } from '/@/api-services/api'; import { SysDatabaseApi } from '/@/api-services/api';
import { UpdateDbTableInput } from '/@/api-services/models'; import { UpdateDbTableInput } from '/@/api-services/models';
const xGrid = ref<VxeGridInstance>(); const xGrid = ref<VxeGridInstance>();
let initTime: any; let initTime: any;
const emits = defineEmits(['addTableSubmitted']); const emits = defineEmits(['addTableSubmitted']);
const ruleFormRef = ref(); const ruleFormRef = ref();
const state = reactive({ const state = reactive({
visible: false, visible: false,
ruleForm: {} as UpdateDbTableInput, ruleForm: {} as UpdateDbTableInput,
sortable: undefined as any, sortable: undefined as any,
}); });
// //
const options = reactive<VxeGridProps>({ const options = reactive<VxeGridProps>({
id: 'sysAddTable', id: 'sysAddTable',
height: 'auto', height: 'auto',
autoResize: true, autoResize: true,
@ -137,7 +130,7 @@
minWidth: 100, minWidth: 100,
editRender: { name: '$switch', props: { openValue: 1, closeValue: 0, openLabel: '是', closeLabel: '否', immediate: true } }, editRender: { name: '$switch', props: { openValue: 1, closeValue: 0, openLabel: '是', closeLabel: '否', immediate: true } },
slots: { slots: {
default: "isPrimarykey" default: 'isPrimarykey',
}, },
}, },
{ {
@ -146,7 +139,7 @@
minWidth: 100, minWidth: 100,
editRender: { name: '$switch', props: { openValue: 1, closeValue: 0, openLabel: '是', closeLabel: '否' } }, editRender: { name: '$switch', props: { openValue: 1, closeValue: 0, openLabel: '是', closeLabel: '否' } },
slots: { slots: {
default: "isIdentity" default: 'isIdentity',
}, },
}, },
{ {
@ -166,7 +159,7 @@
minWidth: 100, minWidth: 100,
editRender: { name: '$switch', props: { openValue: 1, closeValue: 0, openLabel: '是', closeLabel: '否' } }, editRender: { name: '$switch', props: { openValue: 1, closeValue: 0, openLabel: '是', closeLabel: '否' } },
slots: { slots: {
default: "isNullable" default: 'isNullable',
}, },
}, },
{ {
@ -189,7 +182,7 @@
showOverflow: true, showOverflow: true,
fixed: 'right', fixed: 'right',
slots: { slots: {
default: "operate", default: 'operate',
}, },
}, },
], ],
@ -213,35 +206,35 @@
}, },
editConfig: { trigger: 'click', mode: 'row', showStatus: true }, editConfig: { trigger: 'click', mode: 'row', showStatus: true },
exportConfig: { exportConfig: {
remote: false, //使 remote: false, // 使
filename: `数据列信息导出_${dayjs().format('YYMMDDHHmmss')}`, filename: `数据列信息导出_${dayjs().format('YYMMDDHHmmss')}`,
exportMethod: ({ options }) => handleExport(options), // exportMethod: ({ options }) => handleExport(options), //
}, },
printConfig: { sheetName: '' }, printConfig: { sheetName: '' },
proxyConfig: { proxyConfig: {
props: { props: {
list: 'data.result.items', // list: 'data.result.items', //
// result: 'data.result.items', // // result: 'data.result.items', //
total: 'data.result.total', total: 'data.result.total',
message: 'data.message', message: 'data.message',
}, },
ajax: { ajax: {
query: () => Promise.resolve(), // query: () => Promise.resolve(), //
}, },
}, },
}); });
// //
const openDialog = (row: any) => { const openDialog = (row: any) => {
state.ruleForm = row; state.ruleForm = row;
state.visible = true; state.visible = true;
ruleFormRef.value?.resetFields(); ruleFormRef.value?.resetFields();
nextTick(() => { nextTick(() => {
rowDrop(); rowDrop();
}); });
}; };
const rowDrop = () => { const rowDrop = () => {
const el = document.querySelector('.xGrid-table-style .vxe-table--body tbody') as HTMLElement; const el = document.querySelector('.xGrid-table-style .vxe-table--body tbody') as HTMLElement;
state.sortable = Sortable.create(el, { state.sortable = Sortable.create(el, {
animation: 300, animation: 300,
@ -270,36 +263,36 @@
xGrid.value?.updateData(); xGrid.value?.updateData();
}, },
}); });
}; };
// //
const closeDialog = () => { const closeDialog = () => {
emits('addTableSubmitted', state.ruleForm.tableName ?? ''); emits('addTableSubmitted', state.ruleForm.tableName ?? '');
cancel(); cancel();
}; };
// //
const cancel = () => { const cancel = () => {
xGrid.value?.loadData([]); xGrid.value?.loadData([]);
state.visible = false; state.visible = false;
clearTimeout(initTime); clearTimeout(initTime);
if (state.sortable) { if (state.sortable) {
state.sortable.destroy(); state.sortable.destroy();
} }
}; };
// () // ()
const handleExport = async (opts: any) => { const handleExport = async (opts: any) => {
console.log(opts); console.log(opts);
options.loading = true; options.loading = true;
// var res = await getAPI(SysLogExApi).apiSysLogExExportPost(state.queryParams as any, { responseType: 'blob' }); // var res = await getAPI(SysLogExApi).apiSysLogExExportPost(state.queryParams as any, { responseType: 'blob' });
options.loading = false; options.loading = false;
// VXETable.saveFile({ filename: getFileName(res.headers), type: 'xlsx', content: res.data as any }); // VXETable.saveFile({ filename: getFileName(res.headers), type: 'xlsx', content: res.data as any });
return Promise.resolve(); return Promise.resolve();
}; };
// //
const submit = () => { const submit = () => {
ruleFormRef.value.validate(async (valid: boolean) => { ruleFormRef.value.validate(async (valid: boolean) => {
if (!valid) return; if (!valid) return;
const tableData = xGrid.value?.getTableData().fullData ?? []; const tableData = xGrid.value?.getTableData().fullData ?? [];
@ -319,10 +312,10 @@
await getAPI(SysDatabaseApi).apiSysDatabaseAddTablePost(params); await getAPI(SysDatabaseApi).apiSysDatabaseAddTablePost(params);
closeDialog(); closeDialog();
}); });
}; };
// //
const addPrimaryColumn = async () => { const addPrimaryColumn = async () => {
const fullData = xGrid.value?.getTableData().fullData; const fullData = xGrid.value?.getTableData().fullData;
const colIndex = (fullData?.length ?? 0) + 1; const colIndex = (fullData?.length ?? 0) + 1;
const temp = await xGrid.value?.insertAt( const temp = await xGrid.value?.insertAt(
@ -342,10 +335,10 @@
-1 -1
); );
if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName'); if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName');
}; };
// //
const addColumn = async () => { const addColumn = async () => {
const fullData = xGrid.value?.getTableData().fullData; const fullData = xGrid.value?.getTableData().fullData;
const colIndex = (fullData?.length ?? 0) + 1; const colIndex = (fullData?.length ?? 0) + 1;
const temp = await xGrid.value?.insertAt( const temp = await xGrid.value?.insertAt(
@ -365,10 +358,10 @@
-1 -1
); );
if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName'); if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName');
}; };
// //
const addTenantColumn = async () => { const addTenantColumn = async () => {
const fullData = xGrid.value?.getTableData().fullData; const fullData = xGrid.value?.getTableData().fullData;
const colIndex = (fullData?.length ?? 0) + 1; const colIndex = (fullData?.length ?? 0) + 1;
const temp = await xGrid.value?.insertAt( const temp = await xGrid.value?.insertAt(
@ -388,10 +381,10 @@
-1 -1
); );
if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName'); if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName');
}; };
// //
const addBaseColumn = async () => { const addBaseColumn = async () => {
const fileds = [ const fileds = [
{ dataType: 'varchar', name: 'Code', desc: '编码', length: 64 }, { dataType: 'varchar', name: 'Code', desc: '编码', length: 64 },
{ dataType: 'varchar', name: 'Name', desc: '名称', length: 64 }, { dataType: 'varchar', name: 'Name', desc: '名称', length: 64 },
@ -429,17 +422,17 @@
colIndex++; colIndex++;
} }
if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName'); if (temp && temp.row) await xGrid.value?.setEditCell(temp?.row, 'dbColumnName');
}; };
// //
const deleteRow = (row: any) => { const deleteRow = (row: any) => {
const fullData = xGrid.value?.getTableData().fullData; const fullData = xGrid.value?.getTableData().fullData;
fullData?.filter((e: any) => e.orderNo > row.orderNo)?.forEach((e: any) => (e.orderNo = e.orderNo - 1)); fullData?.filter((e: any) => e.orderNo > row.orderNo)?.forEach((e: any) => (e.orderNo = e.orderNo - 1));
xGrid.value?.remove(row); xGrid.value?.remove(row);
}; };
// //
const deleteSelected = () => { const deleteSelected = () => {
const selected = xGrid.value?.getCheckboxRecords(); const selected = xGrid.value?.getCheckboxRecords();
const fullData = xGrid.value?.getTableData().fullData; const fullData = xGrid.value?.getTableData().fullData;
// //
@ -448,23 +441,23 @@
} }
// //
xGrid.value?.removeCheckboxRow(); xGrid.value?.removeCheckboxRow();
}; };
// //
defineExpose({ openDialog }); defineExpose({ openDialog });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.sys-dbTable-container :deep(.el-dialog__body) {} .sys-dbTable-container :deep(.el-dialog__body) {
}
.xGrid-table-style .drag-btn { .xGrid-table-style .drag-btn {
cursor: move; cursor: move;
font-size: 20px; font-size: 20px;
} }
.xGrid-table-style .vxe-body--row.sortable-ghost, .xGrid-table-style .vxe-body--row.sortable-ghost,
.xGrid-table-style .vxe-body--row.sortable-chosen { .xGrid-table-style .vxe-body--row.sortable-chosen {
background-color: #e40000 !important; background-color: #e40000 !important;
} }
</style> </style>