mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-23 05:40:20 +08:00
♻️ Refactoring code. 增加参数管理和文件管理
This commit is contained in:
parent
d594dda9a2
commit
5721bde085
39
src/api/admin/file.ts
Normal file
39
src/api/admin/file.ts
Normal 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
39
src/api/admin/param.ts
Normal 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
|
||||
})
|
||||
}
|
@ -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
40
src/hooks/useForm.ts
Normal 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
|
||||
}
|
||||
|
||||
}
|
@ -97,7 +97,6 @@ export function setFilterRouteEnd() {
|
||||
*/
|
||||
export async function setAddRoute() {
|
||||
await setFilterRouteEnd().forEach((route: RouteRecordRaw) => {
|
||||
console.log(route, 'route')
|
||||
router.addRoute(route);
|
||||
});
|
||||
}
|
||||
|
139
src/views/admin/file/form.vue
Normal file
139
src/views/admin/file/form.vue
Normal 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>
|
30
src/views/admin/file/i18n/en.ts
Normal file
30
src/views/admin/file/i18n/en.ts
Normal 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',
|
||||
}
|
||||
}
|
30
src/views/admin/file/i18n/zh-cn.ts
Normal file
30
src/views/admin/file/i18n/zh-cn.ts
Normal 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: '请输入所属租户',
|
||||
}
|
||||
}
|
107
src/views/admin/file/index.vue
Normal file
107
src/views/admin/file/index.vue
Normal 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>
|
@ -89,7 +89,8 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
createTime: ''
|
||||
},
|
||||
selectObjs: [],
|
||||
pageList: pageList // H
|
||||
pageList: pageList,
|
||||
ascs: 'time'
|
||||
});
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
157
src/views/admin/param/form.vue
Normal file
157
src/views/admin/param/form.vue
Normal 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>
|
34
src/views/admin/param/i18n/en.ts
Normal file
34
src/views/admin/param/i18n/en.ts
Normal 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',
|
||||
}
|
||||
}
|
32
src/views/admin/param/i18n/zh-cn.ts
Normal file
32
src/views/admin/param/i18n/zh-cn.ts
Normal 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',
|
||||
}
|
||||
}
|
158
src/views/admin/param/index.vue
Normal file
158
src/views/admin/param/index.vue
Normal 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>
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user