♻️ Refactoring code. 增加参数管理和文件管理

This commit is contained in:
aeizzz 2023-02-08 10:45:56 +08:00
parent d594dda9a2
commit 5721bde085
17 changed files with 831 additions and 46 deletions

39
src/api/admin/file.ts Normal file
View File

@ -0,0 +1,39 @@
import request from "/@/utils/request"
export function fetchList(query?: Object) {
return request({
url: '/admin/sys-file/page',
method: 'get',
params: query
})
}
export function addObj(obj?: Object) {
return request({
url: '/admin/sys-file',
method: 'post',
data: obj
})
}
export function getObj(id?: string) {
return request({
url: '/admin/sys-file/' + id,
method: 'get'
})
}
export function delObj(id?: string) {
return request({
url: '/admin/sys-file/' + id,
method: 'delete'
})
}
export function putObj(obj?: Object) {
return request({
url: '/admin/sys-file',
method: 'put',
data: obj
})
}

39
src/api/admin/param.ts Normal file
View File

@ -0,0 +1,39 @@
import request from "/@/utils/request"
export function fetchList(query?: Object) {
return request({
url: '/admin/param/page',
method: 'get',
params: query
})
}
export function addObj(obj?: Object) {
return request({
url: '/admin/param',
method: 'post',
data: obj
})
}
export function getObj(id?: string) {
return request({
url: '/admin/param/' + id,
method: 'get'
})
}
export function delObj(id?: string) {
return request({
url: '/admin/param/' + id,
method: 'delete'
})
}
export function putObj(obj?: Object) {
return request({
url: '/admin/param',
method: 'put',
data: obj
})
}

View File

@ -21,14 +21,14 @@ export interface BasicTableProps {
// loading
loading?: Boolean
selectObjs?: any[]
selectObjs?: any[],
descs?: string
ascs?: string
}
export interface Pagination {
// 排序字段
order?: string
// 是否升序
asc?: boolean
// 当前页码
current?: number
// 每页数
@ -50,8 +50,6 @@ export function useTable(options?: BasicTableProps) {
queryForm: {},
dataList: [],
pagination: {
order: '',
asc: false,
current: 1,
size: 10,
total: 0,
@ -60,7 +58,9 @@ export function useTable(options?: BasicTableProps) {
} as Pagination,
dataListSelections: [],
loading: false,
selectObjs: []
selectObjs: [],
descs: '',
ascs: ''
}
const mergeDefaultOptions = (options: any, props: any): BasicTableProps => {
@ -83,8 +83,8 @@ export function useTable(options?: BasicTableProps) {
...state.queryForm,
current: state.pagination?.current,
size: state.pagination?.size,
order: state.pagination?.order,
asc: state.pagination?.asc,
descs: state.descs,
ascs: state.ascs
}).then(res => {
state.dataList = state.isPage ? res.data.records : res.data
state.pagination!.total = state.isPage ? res.data.total : 0
@ -114,20 +114,6 @@ export function useTable(options?: BasicTableProps) {
query();
};
// 排序
const sortChangeHandle = (data: any) => {
const { prop, order } = data
if (prop && order) {
state.pagination!.order = prop
state.pagination!.asc = order === 'ascending'
} else {
state.pagination!.order = ''
}
query()
}
const getDataList = () => {
state.pagination!.current = 1
query()
@ -143,7 +129,6 @@ export function useTable(options?: BasicTableProps) {
getDataList,
sizeChangeHandle,
currentChangeHandle,
sortChangeHandle,
downBlobFile
}

40
src/hooks/useForm.ts Normal file
View File

@ -0,0 +1,40 @@
import {Ref} from "vue";
export interface BasicFormProps{
// 是否显示
visible?: Boolean,
// 表单 ref
dataFormRef?: Ref,
// loading
loading?: Boolean
}
interface Props {
[key: string]: any;
}
export function useTable(dataFormRef: Props | Ref<Props>,
rulesRef?: Props | Ref<Props>) {
const resetFields = () => {
dataFormRef?.value?.resetFields()
}
const validate = () => {
return new Promise((resolve, reject) => {
dataFormRef?.value.validate((prop: any, isValid : boolean, message: string) => {
if(!isValid){
reject(message)
}
resolve(prop)
})
})
}
return {
resetFields,
validate
}
}

View File

@ -97,7 +97,6 @@ export function setFilterRouteEnd() {
*/
export async function setAddRoute() {
await setFilterRouteEnd().forEach((route: RouteRecordRaw) => {
console.log(route, 'route')
router.addRoute(route);
});
}

View File

@ -0,0 +1,139 @@
<template>
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible"
:close-on-click-modal="false" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px">
<el-row :gutter="24">
<el-col :span="24" class="mb20">
<el-form-item :label="t('file.id')" prop="id">
<el-input v-model="form.id" :placeholder="t('file.inputidTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('file.fileName')" prop="fileName">
<el-input v-model="form.fileName" :placeholder="t('file.inputfileNameTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('file.bucketName')" prop="bucketName">
<el-input v-model="form.bucketName" :placeholder="t('file.inputbucketNameTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('file.original')" prop="original">
<el-input v-model="form.original" :placeholder="t('file.inputoriginalTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('file.type')" prop="type">
<el-input v-model="form.type" :placeholder="t('file.inputtypeTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('file.fileSize')" prop="fileSize">
<el-input v-model="form.fileSize" :placeholder="t('file.inputfileSizeTip')"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false" formDialogRef>{{ $t('common.cancelButtonText') }}</el-button>
<el-button type="primary" @click="onSubmit" formDialogRef>{{ $t('common.confirmButtonText') }}</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="SysFileDialog">
// /
import { useDict } from '/@/hooks/dict';
const emit = defineEmits(['refresh']);
import { useMessage } from "/@/hooks/message";
import { getObj, addObj, putObj } from '/@/api/admin/file'
import { useI18n } from "vue-i18n"
const { t } = useI18n();
//
const dataFormRef = ref();
const visible = ref(false)
//
//
const form = reactive({
id: '',
fileName: '',
bucketName: '',
original: '',
type: '',
fileSize: '',
});
//
const dataRules = ref({
})
//
const openDialog = (id: string) => {
visible.value = true
form.id = ''
//
if (dataFormRef.value) {
dataFormRef.value.resetFields()
}
// sysFile
if (id) {
form.id = id
getsysFileData(id)
}
};
//
const onSubmit = () => {
dataFormRef.value.validate((valid: boolean) => {
if (!valid) {
return false
}
//
if (form.id) {
putObj(form).then(() => {
useMessage().success(t('common.editSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
})
} else {
addObj(form).then(() => {
useMessage().success(t('common.addSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
})
}
})
}
//
const getsysFileData = (id: string) => {
//
getObj(id).then((res: any) => {
Object.assign(form, res.data)
})
};
//
defineExpose({
openDialog
});
</script>

View File

@ -0,0 +1,30 @@
export default {
file: {
index: 'index',
importsysFileTip: 'import SysFile',
id: 'id',
fileName: 'fileName',
bucketName: 'bucketName',
original: 'original',
type: 'type',
fileSize: 'fileSize',
createBy: 'createBy',
updateBy: 'updateBy',
createTime: 'createTime',
updateTime: 'updateTime',
delFlag: 'delFlag',
tenantId: 'tenantId',
inputidTip: 'input id',
inputfileNameTip: 'input fileName',
inputbucketNameTip: 'input bucketName',
inputoriginalTip: 'input original',
inputtypeTip: 'input type',
inputfileSizeTip: 'input fileSize',
inputcreateByTip: 'input createBy',
inputupdateByTip: 'input updateBy',
inputcreateTimeTip: 'input createTime',
inputupdateTimeTip: 'input updateTime',
inputdelFlagTip: 'input delFlag',
inputtenantIdTip: 'input tenantId',
}
}

View File

@ -0,0 +1,30 @@
export default {
file: {
index: '序号',
importsysFileTip: '导入文件管理表',
id: '编号',
fileName: '文件名称',
bucketName: '桶名称',
original: '原文件名',
type: '文件类型',
fileSize: '文件大小',
createBy: '创建人',
updateBy: '修改人',
createTime: '上传时间',
updateTime: '更新时间',
delFlag: '${field.fieldComment}',
tenantId: '所属租户',
inputidTip: '请输入编号',
inputfileNameTip: '请输入文件名称',
inputbucketNameTip: '请输入桶名称',
inputoriginalTip: '请输入原文件名',
inputtypeTip: '请输入文件类型',
inputfileSizeTip: '请输入文件大小',
inputcreateByTip: '请输入创建人',
inputupdateByTip: '请输入修改人',
inputcreateTimeTip: '请输入上传时间',
inputupdateTimeTip: '请输入更新时间',
inputdelFlagTip: '请输入${field.fieldComment}',
inputtenantIdTip: '请输入所属租户',
}
}

View File

@ -0,0 +1,107 @@
<template>
<div class="layout-padding">
<el-card class="layout-padding-auto">
<el-row>
<div class="mb8" style="width: 100%">
<el-button formDialogRef icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()">
{{ $t('common.addBtn') }}
</el-button>
<right-toolbar v-model:showSearch="showSearch" class="ml10" style="float: right;margin-right: 20px"
@queryTable="getDataList"></right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" v-loading="state.loading" style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="index" :label="t('file.index')" width="80" />
<el-table-column prop="fileName" :label="t('file.fileName')" show-overflow-tooltip/>
<el-table-column prop="bucketName" :label="t('file.bucketName')" show-overflow-tooltip/>
<el-table-column prop="original" :label="t('file.original')" show-overflow-tooltip/>
<el-table-column prop="type" :label="t('file.type')" show-overflow-tooltip/>
<el-table-column prop="fileSize" :label="t('file.fileSize')" show-overflow-tooltip/>
<el-table-column prop="createTime" :label="t('file.createTime')" show-overflow-tooltip/>
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button size="small" text type="primary" v-auth="'admin_file_edit'"
@click="formDialogRef.openDialog(scope.row.id)">{{ $t('common.editBtn') }}</el-button>
<el-button size="small" text type="primary" v-auth="'sys_file_del'" @click="handleDelete(scope.row)">{{
$t('common.delBtn')
}}</el-button>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</el-card>
<!-- 编辑新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList()" />
</div>
</template>
<script setup lang="ts" name="systemSysFile">
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObj } from "/@/api/admin/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useI18n } from "vue-i18n";
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const { t } = useI18n()
//
//
const formDialogRef = ref()
//
const queryRef = ref()
const showSearch = ref(true)
//
const selectObjs = ref([])
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList
})
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
downBlobFile
} = useTable(state)
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectionChange = (val: any) => {
selectObjs.value = val
multiple.value = !val.length
}
//
const handleDelete = (row: any) => {
if (!row) {
selectObjs.value.forEach((val: any) => {
handleDelete(val)
});
return
}
useMessageBox().confirm(t('common.delConfirmText') + row.id)
.then(() => {
delObj(row.id).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
})
};
</script>

View File

@ -89,7 +89,8 @@ const state: BasicTableProps = reactive<BasicTableProps>({
createTime: ''
},
selectObjs: [],
pageList: pageList // H
pageList: pageList,
ascs: 'time'
});

View File

@ -51,7 +51,7 @@
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="onCancel" size="default">{{ $t('common.cancelButtonText') }}</el-button>
<el-button @click="visible = false" size="default">{{ $t('common.cancelButtonText') }}</el-button>
<el-button type="primary" @click="onSubmit" size="default">{{ $t('common.confirmButtonText') }}</el-button>
</span>
</template>
@ -89,7 +89,7 @@ const state = reactive({
});
//
const getMenuData = async () => {
const getMenuData = () => {
state.parentData = []
pageList().then(res => {
let menu: menuData;
@ -141,27 +141,20 @@ const openDialog = (type: string, row?: any) => {
visible.value = true;
getMenuData();
};
//
const closeDialog = () => {
visible.value = false;
};
//
const onCancel = () => {
closeDialog();
};
//
const onSubmit = () => {
//
if (state.ruleForm.menuId) {
update(state.ruleForm).then(() => {
closeDialog(); //
visible.value = false;
emit('refresh');
}).catch(err => {
useMessage().error(err.msg)
})
} else {
addObj(state.ruleForm).then(() => {
closeDialog(); //
visible.value = false;
emit('refresh');
}).catch(err => {
useMessage().error(err.msg)

View File

@ -0,0 +1,157 @@
<template>
<el-dialog v-model="visible" :close-on-click-modal="false"
:title="form.publicId ? $t('common.editBtn') : $t('common.addBtn')" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px">
<el-row :gutter="24">
<el-col :span="24" class="mb20">
<el-form-item :label="t('param.publicName')" prop="publicName">
<el-input v-model="form.publicName" :placeholder="t('param.inputpublicNameTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('param.publicKey')" prop="publicKey">
<el-input v-model="form.publicKey" :placeholder="t('param.inputpublicKeyTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('param.publicValue')" prop="publicValue">
<el-input v-model="form.publicValue" :placeholder="t('param.inputpublicValueTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('param.status')" prop="status">
<el-select v-model="form.status" :placeholder="t('param.inputstatusTip')">
<el-option v-for="(item, index) in status_type" :key="index" :label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('param.validateCode')" prop="validateCode">
<el-input v-model="form.validateCode" :placeholder="t('param.inputvalidateCodeTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('param.publicType')" prop="publicType">
<el-select v-model="form.publicType" :placeholder="t('param.inputpublicTypeTip')">
<el-option v-for="(item, index) in param_type" :key="index" :label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('param.systemFlag')" prop="systemFlag">
<el-select v-model="form.systemFlag" :placeholder="t('param.inputsystemFlagTip')">
<el-option v-for="(item, index) in dict_type" :key="index" :label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button formDialogRef @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
<el-button formDialogRef type="primary" @click="onSubmit">{{ $t('common.confirmButtonText') }}</el-button>
</span>
</template>
</el-dialog>
</template>
<script lang="ts" name="SysPublicParamDialog" setup>
// /
import {useDict} from '/@/hooks/dict';
import {useMessage} from "/@/hooks/message";
import {addObj, getObj, putObj} from '/@/api/admin/param'
import {useI18n} from "vue-i18n"
const emit = defineEmits(['refresh']);
const {t} = useI18n();
//
const dataFormRef = ref();
const visible = ref(false)
//
const {dict_type, status_type, param_type} = useDict('dict_type', 'status_type', 'param_type')
//
const form = reactive({
publicId: '',
publicName: '',
publicKey: '',
publicValue: '',
status: '',
validateCode: '',
publicType: '',
systemFlag: '',
});
//
const dataRules = ref({})
//
const openDialog = (id: string) => {
visible.value = true
form.publicId = ''
//
if (dataFormRef.value) {
dataFormRef.value.resetFields()
}
// sysPublicParam
if (id) {
form.publicId = id
getsysPublicParamData(id)
}
};
//
const onSubmit = () => {
dataFormRef.value.validate((valid: boolean) => {
if (!valid) {
return false
}
//
if (form.publicId) {
putObj(form).then(() => {
useMessage().success(t('common.editSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
})
} else {
addObj(form).then(() => {
useMessage().success(t('common.addSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
})
}
})
}
//
const getsysPublicParamData = (id: string) => {
//
getObj(id).then((res: any) => {
Object.assign(form, res.data)
})
};
//
defineExpose({
openDialog
});
</script>

View File

@ -0,0 +1,34 @@
export default {
param: {
index: 'index',
importsysPublicParamTip: 'import SysPublicParam',
publicId: 'publicId',
publicName: 'publicName',
publicKey: 'publicKey',
publicValue: 'publicValue',
status: 'status',
validateCode: 'validateCode',
createBy: 'createBy',
updateBy: 'updateBy',
createTime: 'createTime',
updateTime: 'updateTime',
publicType: 'publicType',
systemFlag: 'systemFlag',
delFlag: 'delFlag',
tenantId: 'tenantId',
inputpublicIdTip: 'input publicId',
inputpublicNameTip: 'input publicName',
inputpublicKeyTip: 'input publicKey',
inputpublicValueTip: 'input publicValue',
inputstatusTip: 'input status',
inputvalidateCodeTip: 'input validateCode',
inputcreateByTip: 'input createBy',
inputupdateByTip: 'input updateBy',
inputcreateTimeTip: 'input createTime',
inputupdateTimeTip: 'input updateTime',
inputpublicTypeTip: 'input publicType',
inputsystemFlagTip: 'input systemFlag',
inputdelFlagTip: 'input delFlag',
inputtenantIdTip: 'input tenantId',
}
}

View File

@ -0,0 +1,32 @@
export default {
param: {
index: '序号',
importsysPublicParamTip: '导入公共参数配置表',
publicId: '编号',
publicName: '名称',
publicKey: '键',
publicValue: '值',
status: '状态',
validateCode: '编码',
createBy: '创建人',
updateBy: '修改人',
createTime: '创建时间',
updateTime: '修改时间',
publicType: '类型',
systemFlag: '类型',
tenantId: '租户ID',
inputpublicIdTip: '请输入编号',
inputpublicNameTip: '请输入名称',
inputpublicKeyTip: '请输入键',
inputpublicValueTip: '请输入值',
inputstatusTip: '请输入状态',
inputvalidateCodeTip: '请输入编码',
inputcreateByTip: '请输入创建人',
inputupdateByTip: '请输入修改人',
inputcreateTimeTip: '请输入创建时间',
inputupdateTimeTip: '请输入修改时间',
inputpublicTypeTip: '请输入类型',
inputsystemFlagTip: '请输入类型',
inputtenantIdTip: '请输入租户ID',
}
}

View File

@ -0,0 +1,158 @@
<template>
<div class="layout-padding">
<el-card class="layout-padding-auto">
<el-row v-show="showSearch" class="mb8">
<el-form ref="queryRef" :inline="true" :model="state.queryForm">
<el-form-item :label="t('param.systemFlag')" class="ml2" prop="systemFlag">
<el-select v-model="state.queryForm.systemFlag" :placeholder="t('param.inputsystemFlagTip')">
<el-option v-for="(item, index) in dict_type" :key="index" :label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item class="ml2">
<el-button formDialogRef icon="search" type="primary" @click="getDataList">
{{ $t('common.queryBtn') }}
</el-button>
<el-button formDialogRef icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button class="ml10" formDialogRef icon="folder-add" type="primary"
@click="formDialogRef.openDialog()">
{{ $t('common.addBtn') }}
</el-button>
<el-button class="ml10" formDialogRef icon="Download" type="primary"
@click="exportExcel">
{{ $t('common.exportBtn') }}
</el-button>
<el-button :disabled="multiple" class="ml10" formDialogRef icon="Delete"
type="primary" @click="handleDelete(undefined)">
{{ $t('common.delBtn') }}
</el-button>
<right-toolbar v-model:showSearch="showSearch" class="ml10" style="float: right;margin-right: 20px"
@queryTable="getDataList"></right-toolbar>
</div>
</el-row>
<el-table v-loading="state.loading" :data="state.dataList" style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="50"/>
<el-table-column :label="t('param.index')" type="index" width="80"/>
<el-table-column :label="t('param.publicId')" prop="publicId" show-overflow-tooltip/>
<el-table-column :label="t('param.publicName')" prop="publicName" show-overflow-tooltip/>
<el-table-column :label="t('param.publicKey')" prop="publicKey" show-overflow-tooltip/>
<el-table-column :label="t('param.publicValue')" prop="publicValue" show-overflow-tooltip/>
<el-table-column :label="t('param.status')" prop="status" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="status_type" :value="scope.row.status"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="t('param.validateCode')" prop="validateCode" show-overflow-tooltip/>
<el-table-column :label="t('param.createTime')" prop="createTime" show-overflow-tooltip/>
<el-table-column :label="t('param.publicType')" prop="publicType" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="param_type" :value="scope.row.publicType"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="t('param.systemFlag')" prop="systemFlag" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="dict_type" :value="scope.row.systemFlag"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button size="small" text type="primary"
@click="formDialogRef.openDialog(scope.row.publicId)">{{ $t('common.editBtn') }}
</el-button>
<el-button size="small" text type="primary" @click="handleDelete(scope.row)">{{
$t('common.delBtn')
}}
</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-bind="state.pagination" @size-change="sizeChangeHandle" @current-change="currentChangeHandle"/>
</el-card>
<!-- 编辑新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList()"/>
</div>
</template>
<script lang="ts" name="systemSysPublicParam" setup>
import {BasicTableProps, useTable} from "/@/hooks/table";
import {delObj, fetchList} from "/@/api/admin/param";
import {useMessage, useMessageBox} from "/@/hooks/message";
import {useDict} from '/@/hooks/dict';
import {useI18n} from "vue-i18n";
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const {t} = useI18n()
//
const {dict_type, status_type, param_type} = useDict('dict_type', 'status_type', 'param_type')
//
const formDialogRef = ref()
//
const queryRef = ref()
const showSearch = ref(true)
//
const selectObjs = ref([])
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
systemFlag: ''
},
pageList: fetchList
})
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
downBlobFile
} = useTable(state)
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectionChange = (val: any) => {
selectObjs.value = val
multiple.value = !val.length
}
// excel
const exportExcel = () => {
downBlobFile('/admin/param/export', state.queryForm, 'param.xlsx')
}
//
const handleDelete = (row: any) => {
if (!row) {
selectObjs.value.forEach((val: any) => {
handleDelete(val)
});
return
}
useMessageBox().confirm(t('common.delConfirmText') + row.publicId)
.then(() => {
delObj(row.publicId).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
})
};
</script>

View File

@ -169,7 +169,7 @@ const generatorHandle = () => {
// zip
if (dataForm.generatorType === 0) {
downBlobFile('/gen/generator/download?tableIds=' + [dataForm.id].join(','), {}, 'file.zip')
downBlobFile('/gen/generator/download?tableIds=' + [dataForm.id].join(','), {}, `${dataForm.tableName}.zip`)
visible.value = false
return
}

View File

@ -4,7 +4,7 @@
<el-row v-show="showSearch" class="mb8">
<el-form :model="state.queryForm" ref="queryRef" :inline="true">
<el-form-item label="数据源" prop="name">
<el-select v-model="state.queryForm.name" style="width: 100%" placeholder="请选择数据源" @change="getDataList">
<el-select v-model="state.queryForm.dsName" style="width: 100%" placeholder="请选择数据源" @change="getDataList">
<el-option label="默认数据源" value=""></el-option>
<el-option v-for="ds in datasourceList" :key="ds.id" :label="ds.name" :value="ds.name">
</el-option>
@ -41,15 +41,15 @@
<el-table-column prop="tableName" :label="t('table.tableName')" show-overflow-tooltip />
<el-table-column prop="tableComment" :label="t('table.tableComment')" show-overflow-tooltip />
<el-table-column prop="createTime" :label="t('table.createTime')" show-overflow-tooltip />
<el-table-column :label="$t('common.action')" width="150">
<el-table-column :label="$t('common.action')" width="200">
<template #default="scope">
<el-button size="small" text type="primary"
@click="formDialogRef.openDialog(state.queryForm.name, scope.row.tableName)">{{
@click="formDialogRef.openDialog(state.queryForm.dsName, scope.row.tableName)">{{
$t('common.editBtn')
}}</el-button>
<el-button size="small" text type="primary"
@click="generatorRef.openDialog(state.queryForm.name, scope.row.tableName)">{{
@click="generatorRef.openDialog(state.queryForm.dsName, scope.row.tableName)">{{
$t('gen.genBtn')
}}</el-button>
@ -95,7 +95,9 @@ const multiple = ref(true)
const datasourceList = ref()
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
queryForm: {
dsName: ''
},
pageList: fetchList
})
@ -112,7 +114,7 @@ onMounted(() => {
list().then(res => {
datasourceList.value = res.data
//
state.queryForm.name = datasourceList.value[0].name
state.queryForm.dsName = datasourceList.value[0].name
})
})