Merge remote-tracking branch 'origin/hui_dev' into leng_dev

# Conflicts:
#	src/components/Upload/index.vue
#	src/views/admin/user/index.vue
This commit is contained in:
lbw 2023-03-07 22:47:31 +08:00
commit af6504007a
8 changed files with 540 additions and 452 deletions

View File

@ -45,3 +45,10 @@ export function info() {
method: 'get',
});
}
export function refreshCache() {
return request({
url: '/admin/i18n/sync',
method: 'put',
})
}

View File

@ -16,29 +16,29 @@
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
{{ $t('excel.operationNotice') }}
<em>{{ $t('excel.clickUpload') }}</em>
</div>
<template #tip>
<div class="el-upload__tip text-center">
<span>仅允许导入xlsxlsx格式文件</span>
<span>{{ $t('excel.fileFormat') }}</span>
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="downExcelTemp" v-if="tempUrl"
>下载模板
>{{ $t('excel.downloadTemplate') }}
</el-link>
</div>
</template>
</el-upload>
<template #footer>
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="state.upload.open = false"> </el-button>
<el-button type="primary" @click="submitFileForm">{{ $t('common.confirmButtonText') }}</el-button>
<el-button @click="state.upload.open = false">{{ $t('common.cancelButtonText') }}</el-button>
</template>
</el-dialog>
<!--校验失败错误数据-->
<el-dialog title="校验失败数据" v-model="state.errorVisible">
<el-dialog :title="$t('common.validationFailureData')" v-model="state.errorVisible">
<el-table :data="state.errorData">
<el-table-column property="lineNum" label="行号" width="100"></el-table-column>
<el-table-column property="errors" label="错误描述" show-overflow-tooltip>
<el-table-column property="lineNum" :label="$t('common.lineNumbers')" width="100"></el-table-column>
<el-table-column property="errors" :label="$t('common.misDescription')" show-overflow-tooltip>
<template v-slot="scope">
<el-tag type="danger" v-for="error in scope.row.errors" :key="error">{{ error }} </el-tag>
</template>
@ -51,6 +51,9 @@
import { useMessage } from '/@/hooks/message';
import other from '/@/utils/other';
import { Session } from '/@/utils/storage';
import {useI18n} from 'vue-i18n';
const {t} = useI18n()
const emit = defineEmits(['sizeChange', 'refreshDataList']);
const prop = defineProps({

View File

@ -0,0 +1,15 @@
export default {
excel: {
downloadTemplate :"downloading the template",
fileFormat:"only xls, xlsx format files are allowed",
operationNotice:"Drag the file here and",
clickUpload:"click upload",
lineNumbers:"line numbers",
misDescription:"misDescription",
validationFailureData:"validation failure data",
pleaseUpload:"please upload",
size:"size not exceeding",
format:"format",
file:"file"
},
};

View File

@ -0,0 +1,15 @@
export default {
excel: {
downloadTemplate :"下载模板",
fileFormat:"仅允许导入xls、xlsx格式文件。",
operationNotice:"将文件拖到此处,或",
clickUpload:"点击上传",
lineNumbers:"行号",
misDescription:"错误描述",
validationFailureData:"校验失败数据",
pleaseUpload:"请上传",
size:"大小不超过",
format:"格式为",
file:"的文件",
},
};

View File

@ -20,19 +20,19 @@
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
{{ $t('excel.operationNotice') }}
<em>{{ $t('excel.clickUpload') }}</em>
</div>
<template #tip>
<div class="el-upload__tip" v-if="props.isShowTip">
请上传
{{ $t('excel.pleaseUpload') }}
<template v-if="props.fileSize">
大小不超过 <b style="color: #f56c6c">{{ props.fileSize }}MB</b></template
{{ $t('excel.size') }} <b style="color: #f56c6c">{{ props.fileSize }}MB</b></template
>
<template v-if="props.fileType">
格式为 <b style="color: #f56c6c">{{ props.fileType.join('/') }}</b>
{{ $t('excel.format') }} <b style="color: #f56c6c">{{ props.fileType.join('/') }}</b>
</template>
的文件
{{ $t('excel.file') }}
</div>
</template>
</el-upload>
@ -52,15 +52,18 @@
class="upload-file-uploader"
multiple
>
<el-button type="primary" link>点击上传</el-button>
<el-button type="primary" link>{{ $t('excel.clickUpload') }}</el-button>
</el-upload>
</div>
</template>
<script setup lang="ts" name="upload-file">
import { useMessage } from '/@/hooks/message';
import { Session } from '/@/utils/storage';
import { Local, Session } from '/@/utils/storage';
import {useI18n} from 'vue-i18n';
const {t} = useI18n()
const props = defineProps({
modelValue: [String, Array],
//
@ -110,9 +113,9 @@ const uploadList = ref([]) as any;
const fileUpload = ref();
const headers = computed(() => {
const tenantId = Session.getTenant();
const tenantId = Local.get('tenantId') ? Local.get('tenantId') : 1;
return {
Authorization: 'Bearer ' + Session.getToken(),
Authorization: 'Bearer ' + Session.get('token'),
'TENANT-ID': tenantId,
};
});

View File

@ -1,156 +1,174 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-row class="mb8" v-show="showSearch">
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('i18n.name')" prop="name">
<el-input :placeholder="t('i18n.inputKeyTip')" style="max-width: 180px" v-model="state.queryForm.name" />
</el-form-item>
<el-form-item :label="$t('i18n.zhCn')" prop="zh-cn">
<el-input :placeholder="t('i18n.inputZhCnTip')" style="max-width: 180px" v-model="state.queryForm.zhCn" />
</el-form-item>
<el-form-item :label="$t('i18n.en')" prop="en">
<el-input :placeholder="t('i18n.inputEnTip')" style="max-width: 180px" v-model="state.queryForm.en" />
</el-form-item>
<el-form-item class="ml2">
<el-button @click="getDataList" formDialogRef icon="search" type="primary">
{{ $t('common.queryBtn') }}
</el-button>
<el-button @click="resetQuery" formDialogRef icon="Refresh">{{ $t('common.resetBtn') }} </el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button @click="formDialogRef.openDialog()" class="ml10" formDialogRef icon="folder-add" type="primary" v-auth="'admin_i18n_add'">
{{ $t('common.addBtn') }}
</el-button>
<el-button @click="exportExcel" class="ml10" formDialogRef icon="Download" type="primary" v-auth="'admin_i18n_export'">
{{ $t('common.exportBtn') }}
</el-button>
<el-button
:disabled="multiple"
@click="handleDelete(selectObjs)"
class="ml10"
formDialogRef
icon="Delete"
type="primary"
v-auth="'admin_i18n_del'"
>
{{ $t('common.delBtn') }}
</el-button>
<right-toolbar
@queryTable="getDataList"
class="ml10"
style="float: right; margin-right: 20px"
v-model:showSearch="showSearch"
></right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
@selection-change="handleSelectionChange"
@sort-change="sortChangeHandle"
style="width: 100%"
v-loading="state.loading"
>
<el-table-column align="center" type="selection" width="60" />
<el-table-column type="index" :label="t('file.index')" width="80" />
<el-table-column :label="t('i18n.name')" prop="name" show-overflow-tooltip />
<el-table-column :label="t('i18n.zhCn')" prop="zhCn" show-overflow-tooltip />
<el-table-column :label="t('i18n.en')" prop="en" show-overflow-tooltip />
<el-table-column :label="t('i18n.createBy')" prop="createBy" show-overflow-tooltip />
<el-table-column :label="t('i18n.createTime')" prop="createTime" show-overflow-tooltip />
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button @click="formDialogRef.openDialog(scope.row.id)" text type="primary" v-auth="'admin_i18n_edit'"
>{{ $t('common.editBtn') }}
</el-button>
<el-button @click="handleDelete([scope.row.id])" text type="primary" v-auth="'admin_i18n_del'">
{{ $t('common.delBtn') }}
</el-button>
</template>
</el-table-column>
</el-table>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination" />
</div>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-row class="mb8" v-show="showSearch">
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('i18n.name')" prop="name">
<el-input :placeholder="t('i18n.inputKeyTip')" style="max-width: 180px"
v-model="state.queryForm.name"/>
</el-form-item>
<el-form-item :label="$t('i18n.zhCn')" prop="zh-cn">
<el-input :placeholder="t('i18n.inputZhCnTip')" style="max-width: 180px"
v-model="state.queryForm.zhCn"/>
</el-form-item>
<el-form-item :label="$t('i18n.en')" prop="en">
<el-input :placeholder="t('i18n.inputEnTip')" style="max-width: 180px"
v-model="state.queryForm.en"/>
</el-form-item>
<el-form-item class="ml2">
<el-button @click="getDataList" formDialogRef icon="search" type="primary">
{{ $t('common.queryBtn') }}
</el-button>
<el-button @click="resetQuery" formDialogRef icon="Refresh">{{ $t('common.resetBtn') }}
</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button @click="formDialogRef.openDialog()" class="ml10" formDialogRef icon="folder-add"
type="primary" v-auth="'admin_i18n_add'">
{{ $t('common.addBtn') }}
</el-button>
<el-button @click="exportExcel" class="ml10" formDialogRef icon="Download" type="primary"
v-auth="'admin_i18n_export'">
{{ $t('common.exportBtn') }}
</el-button>
<el-button
:disabled="multiple"
@click="handleDelete(selectObjs)"
class="ml10"
formDialogRef
icon="Delete"
type="primary"
v-auth="'admin_i18n_del'"
>
{{ $t('common.delBtn') }}
</el-button>
<el-button @click="handleRefreshCache()" class="ml10" icon="refresh-left" type="primary">
{{ $t('common.refreshCacheBtn') }}
</el-button>
<right-toolbar
@queryTable="getDataList"
class="ml10"
style="float: right; margin-right: 20px"
v-model:showSearch="showSearch"
></right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
@selection-change="handleSelectionChange"
@sort-change="sortChangeHandle"
border
style="width: 100%"
v-loading="state.loading"
>
<el-table-column align="center" type="selection" width="60"/>
<el-table-column :label="t('file.index')" type="index" width="80"/>
<el-table-column :label="t('i18n.name')" prop="name" show-overflow-tooltip/>
<el-table-column :label="t('i18n.zhCn')" prop="zhCn" show-overflow-tooltip/>
<el-table-column :label="t('i18n.en')" prop="en" show-overflow-tooltip/>
<el-table-column :label="t('i18n.createBy')" prop="createBy" show-overflow-tooltip/>
<el-table-column :label="t('i18n.createTime')" prop="createTime" show-overflow-tooltip/>
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button @click="formDialogRef.openDialog(scope.row.id)" text type="primary"
v-auth="'admin_i18n_edit'"
>{{ $t('common.editBtn') }}
</el-button>
<el-button @click="handleDelete([scope.row.id])" text type="primary" v-auth="'admin_i18n_del'">
{{ $t('common.delBtn') }}
</el-button>
</template>
</el-table-column>
</el-table>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle"
v-bind="state.pagination"/>
</div>
<!-- 编辑新增 -->
<form-dialog @refresh="getDataList()" ref="formDialogRef" />
</div>
<!-- 编辑新增 -->
<form-dialog @refresh="getDataList()" ref="formDialogRef"/>
</div>
</template>
<script lang="ts" name="systemSysI18n" setup>
import { BasicTableProps, useTable } from '/@/hooks/table';
import { delObj, fetchList } from '/@/api/admin/i18n';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useI18n } from 'vue-i18n';
import {BasicTableProps, useTable} from '/@/hooks/table';
import {delObj, fetchList,refreshCache} from '/@/api/admin/i18n';
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([]) as any;
const multiple = ref(true);
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const {t} = useI18n();
//
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
name: '',
zhCn: '',
en: '',
},
pageList: fetchList,
descs: ['create_time'],
});
//
const formDialogRef = ref();
//
const queryRef = ref();
const showSearch = ref(true);
//
const selectObjs = ref([]) as any;
const multiple = ref(true);
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile } = useTable(state);
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
name: '',
zhCn: '',
en: '',
},
pageList: fetchList,
descs: ['create_time'],
});
//
const resetQuery = () => {
//
queryRef.value.resetFields();
//
state.queryForm!.descs = [];
state.queryForm!.ascs = [];
//
selectObjs.value = [];
getDataList();
};
// table hook
const {getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile} = useTable(state);
// excel
const exportExcel = () => {
downBlobFile('/admin/i18n/export', state.queryForm, 'i18n.xlsx');
};
//
const resetQuery = () => {
//
queryRef.value.resetFields();
//
state.queryForm!.descs = [];
state.queryForm!.ascs = [];
//
selectObjs.value = [];
getDataList();
};
const handleRefreshCache = () => {
refreshCache().then(() => {
useMessage().success('同步成功');
});
};
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.id);
});
multiple.value = !objs.length;
};
// excel
const exportExcel = () => {
downBlobFile('/admin/i18n/export', state.queryForm, 'i18n.xlsx');
};
//
const handleDelete = (ids: string[]) => {
useMessageBox()
.confirm(t('common.delConfirmText'))
.then(() => {
delObj(ids)
.then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
})
.catch((err: any) => {
useMessage().error(err.msg);
});
});
};
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.id);
});
multiple.value = !objs.length;
};
//
const handleDelete = (ids: string[]) => {
useMessageBox()
.confirm(t('common.delConfirmText'))
.then(() => {
delObj(ids)
.then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
})
.catch((err: any) => {
useMessage().error(err.msg);
});
});
};
</script>

View File

@ -1,116 +1,129 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<div class="mb15">
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
<el-form-item :label="$t('sysmenu.name')" prop="menuName">
<el-input :placeholder="$t('sysmenu.inputNameTip')" style="max-width: 180px" clearable v-model="state.queryForm.menuName" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" class="ml10" @click="getDataList">
{{ $t('common.queryBtn') }}
</el-button>
<el-button icon="folder-add" type="primary" class="ml10" @click="onOpenAddMenu" v-auth="'sys_menu_add'">
{{ $t('common.addBtn') }}
</el-button>
</el-form-item>
</el-form>
</div>
<el-table
:data="state.dataList"
v-loading="state.loading"
style="width: 100%"
row-key="path"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<el-table-column prop="name" :label="$t('sysmenu.name')" show-overflow-tooltip></el-table-column>
<el-table-column prop="sortOrder" :label="$t('sysmenu.sortOrder')" show-overflow-tooltip></el-table-column>
<el-table-column prop="icon" :label="$t('sysmenu.icon')" show-overflow-tooltip>
<template #default="scope">
<SvgIcon :name="scope.row.icon" />
</template>
</el-table-column>
<el-table-column prop="path" :label="$t('sysmenu.path')" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysmenu.menuType')" show-overflow-tooltip>
<template #default="scope">
<el-tag v-if="scope.row.menuType === '0'" type="success">左菜单</el-tag>
<el-tag v-if="scope.row.menuType === '2'" type="success">顶菜单</el-tag>
<el-tag v-if="scope.row.menuType === '1'" type="info">按钮</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysmenu.keepAlive')" show-overflow-tooltip>
<template #default="scope">
<el-tag v-if="scope.row.keepAlive === '0'" type="info">关闭</el-tag>
<el-tag v-if="scope.row.keepAlive === '1'" type="success">开启</el-tag>
</template>
</el-table-column>
<el-table-column prop="permission" :label="$t('sysmenu.permission')" :show-overflow-tooltip="true"></el-table-column>
<el-table-column :label="$t('common.action')" show-overflow-tooltip width="200">
<template #default="scope">
<el-button text type="primary" @click="onOpenAddMenu('add', scope.row)" v-auth="'sys_menu_add'"> {{ $t('common.addBtn') }}</el-button>
<el-button text type="primary" @click="onOpenEditMenu('edit', scope.row)" v-auth="'sys_menu_edit'">{{ $t('common.editBtn') }}</el-button>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<div class="mb15">
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('sysmenu.name')" prop="menuName">
<el-input :placeholder="$t('sysmenu.inputNameTip')" clearable style="max-width: 180px"
v-model="state.queryForm.menuName"/>
</el-form-item>
<el-form-item>
<el-button @click="getDataList" class="ml10" icon="search" type="primary">
{{ $t('common.queryBtn') }}
</el-button>
<el-button @click="onOpenAddMenu" class="ml10" icon="folder-add" type="primary"
v-auth="'sys_menu_add'">
{{ $t('common.addBtn') }}
</el-button>
</el-form-item>
</el-form>
</div>
<el-table
:data="state.dataList"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
border
max-height="450"
row-key="path"
style="width: 100%"
v-loading="state.loading"
>
<el-table-column :label="$t('sysmenu.name')" fixed prop="name" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysmenu.sortOrder')" prop="sortOrder"
show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysmenu.icon')" prop="icon" show-overflow-tooltip>
<template #default="scope">
<SvgIcon :name="scope.row.icon"/>
</template>
</el-table-column>
<el-table-column :label="$t('sysmenu.path')" prop="path" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysmenu.menuType')" show-overflow-tooltip>
<template #default="scope">
<el-tag type="success" v-if="scope.row.menuType === '0'">左菜单</el-tag>
<el-tag type="success" v-if="scope.row.menuType === '2'">顶菜单</el-tag>
<el-tag type="info" v-if="scope.row.menuType === '1'">按钮</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysmenu.keepAlive')" show-overflow-tooltip>
<template #default="scope">
<el-tag type="info" v-if="scope.row.keepAlive === '0'">关闭</el-tag>
<el-tag type="success" v-if="scope.row.keepAlive === '1'">开启</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysmenu.permission')" :show-overflow-tooltip="true"
prop="permission"></el-table-column>
<el-table-column :label="$t('common.action')" show-overflow-tooltip width="200">
<template #default="scope">
<el-button @click="onOpenAddMenu('add', scope.row)" text type="primary" v-auth="'sys_menu_add'">
{{ $t('common.addBtn') }}
</el-button>
<el-button @click="onOpenEditMenu('edit', scope.row)" text type="primary"
v-auth="'sys_menu_edit'">{{ $t('common.editBtn') }}
</el-button>
<el-tooltip :content="$t('sysmenu.deleteDisabledTip')" :disabled="!deleteMenuDisabled(scope.row)" placement="top">
<el-tooltip :content="$t('sysmenu.deleteDisabledTip')"
:disabled="!deleteMenuDisabled(scope.row)" placement="top">
<span style="margin-left: 12px">
<el-button text type="primary" :disabled="deleteMenuDisabled(scope.row)" @click="onTabelRowDel(scope.row)" v-auth="'sys_menu_del'">
<el-button :disabled="deleteMenuDisabled(scope.row)" @click="onTabelRowDel(scope.row)"
text
type="primary" v-auth="'sys_menu_del'">
{{ $t('common.delBtn') }}
</el-button>
</span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div>
<MenuDialog ref="menuDialogRef" @refresh="getDataList()" />
</div>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div>
<MenuDialog @refresh="getDataList()" ref="menuDialogRef"/>
</div>
</template>
<script setup lang="ts" name="systemMenu">
import { pageList, delObj } from '/@/api/admin/menu';
import { useTable, BasicTableProps } from '/@/hooks/table';
import { useMessage, useMessageBox } from '/@/hooks/message';
//
const MenuDialog = defineAsyncComponent(() => import('./form.vue'));
<script lang="ts" name="systemMenu" setup>
import {delObj, pageList} from '/@/api/admin/menu';
import {BasicTableProps, useTable} from '/@/hooks/table';
import {useMessage, useMessageBox} from '/@/hooks/message';
//
const MenuDialog = defineAsyncComponent(() => import('./form.vue'));
//
const menuDialogRef = ref();
const state: BasicTableProps = reactive<BasicTableProps>({
pageList: pageList, // H
queryForm: {
menuName: '',
},
isPage: false,
});
//
const menuDialogRef = ref();
const state: BasicTableProps = reactive<BasicTableProps>({
pageList: pageList, // H
queryForm: {
menuName: '',
},
isPage: false,
});
const { getDataList } = useTable(state);
const {getDataList} = useTable(state);
//
const onOpenAddMenu = (type: string, row?: any) => {
menuDialogRef.value.openDialog(type, row);
};
//
const onOpenEditMenu = (type: string, row: any) => {
menuDialogRef.value.openDialog(type, row);
};
//
const onOpenAddMenu = (type: string, row?: any) => {
menuDialogRef.value.openDialog(type, row);
};
//
const onOpenEditMenu = (type: string, row: any) => {
menuDialogRef.value.openDialog(type, row);
};
//
const deleteMenuDisabled = (row: any) => {
return (row.children || []).length > 0;
};
//
const deleteMenuDisabled = (row: any) => {
return (row.children || []).length > 0;
};
//
const onTabelRowDel = (row: any) => {
useMessageBox()
.confirm(`此操作将永久删除:${row.name}`)
.then(() => {
delObj(row.id)
.then(() => {
useMessage().success('删除成功');
getDataList();
})
.catch((err: any) => {
useMessage().error(err.msg);
});
});
};
//
const onTabelRowDel = (row: any) => {
useMessageBox()
.confirm(`此操作将永久删除:${row.name}`)
.then(() => {
delObj(row.id)
.then(() => {
useMessage().success('删除成功');
getDataList();
})
.catch((err: any) => {
useMessage().error(err.msg);
});
});
};
</script>

View File

@ -1,211 +1,225 @@
<template>
<div class="layout-padding">
<el-row :gutter="10">
<el-col :span="4" :xs="24">
<el-card class="layout-padding-auto" shadow="hover">
<query-tree :placeholder="$t('common.queryDeptTip')" :query="deptData.queryList" @node-click="handleNodeClick">
<template #default="{ node, data }">
<el-tooltip v-if="data.isLock" class="item" effect="dark" content="无数据权限" placement="right-start">
<span>{{ node.label }} <SvgIcon name="ele-Lock"></SvgIcon></span>
</el-tooltip>
<span v-if="!data.isLock">{{ node.label }}</span>
</template>
</query-tree>
</el-card>
</el-col>
<el-col :span="20" :xs="24">
<div class="layout-padding-auto layout-padding-view">
<el-row class="mb8" v-show="showSearch">
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('sysuser.username')" prop="username">
<el-input :placeholder="$t('sysuser.inputUsernameTip')" clearable style="width: 240px" v-model="state.queryForm.username" />
</el-form-item>
<el-form-item :label="$t('sysuser.phone')" prop="phone">
<el-input :placeholder="$t('sysuser.inputPhoneTip')" clearable style="width: 240px" v-model="state.queryForm.phone" />
</el-form-item>
<el-form-item>
<el-button @click="getDataList" icon="Search" type="primary">{{ $t('common.queryBtn') }} </el-button>
<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button @click="userDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary" v-auth="'sys_user_add'">
{{ $t('common.addBtn') }}
</el-button>
<el-button @click="excelUploadRef.show()" class="ml10" icon="upload-filled" type="primary" v-auth="'sys_user_add'">
{{ $t('common.importBtn') }}
</el-button>
<el-button @click="exportExcel" class="ml10" icon="Download" type="primary" v-auth="'sys_user_export'">
{{ $t('common.exportBtn') }}
</el-button>
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete" type="primary" v-auth="'sys_user_del'">
{{ $t('common.delBtn') }}
</el-button>
<right-toolbar
@queryTable="getDataList"
class="ml10"
style="float: right; margin-right: 20px"
v-model:showSearch="showSearch"
></right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" @selection-change="handleSelectionChange" style="width: 100%" v-loading="state.loading">
<el-table-column :selectable="handleSelectable" align="center" type="selection" width="50" />
<el-table-column :label="$t('sysuser.index')" type="index" width="80" />
<el-table-column :label="$t('sysuser.username')" prop="username" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysuser.name')" prop="name" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysuser.phone')" prop="phone" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysuser.post')" show-overflow-tooltip>
<template #default="scope">
<el-tag :key="index" type="success" v-for="(item, index) in scope.row.postList">{{ item.postName }} </el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.role')" show-overflow-tooltip>
<template #default="scope">
<el-tag :key="index" type="success" v-for="(item, index) in scope.row.roleList">{{ item.roleName }} </el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.lockFlag')" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="lock_flag" :value="scope.row.lockFlag"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.createTime')" prop="createTime" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button @click="userDialogRef.openDialog(scope.row.userId)" text type="primary" v-auth="'sys_user_edit'">
{{ $t('common.editBtn') }}
</el-button>
<el-tooltip :content="$t('sysuser.deleteDisabledTip')" :disabled="scope.row.userId !== '1'" placement="top">
<span style="margin-left: 12px">
<el-button
:disabled="scope.row.userId === '1'"
@click="handleDelete([scope.row.userId])"
text
type="primary"
v-auth="'sys_user_del'"
>{{ $t('common.delBtn') }}
</el-button>
</span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<div class="layout-padding">
<el-row :gutter="20">
<el-col :span="4" :xs="24">
<el-card class="layout-padding-auto" shadow="hover">
<query-tree :placeholder="$t('common.queryDeptTip')" :query="deptData.queryList"
@node-click="handleNodeClick"/>
</el-card>
</el-col>
<el-col :span="20" :xs="24">
<div class="layout-padding-auto layout-padding-view">
<el-row class="mb8" v-show="showSearch">
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('sysuser.username')" prop="username">
<el-input :placeholder="$t('sysuser.inputUsernameTip')"
clearable style="width: 240px"
v-model="state.queryForm.username"/>
</el-form-item>
<el-form-item :label="$t('sysuser.phone')" prop="phone">
<el-input :placeholder="$t('sysuser.inputPhoneTip')" clearable
style="width: 240px"
v-model="state.queryForm.phone"/>
</el-form-item>
<el-form-item>
<el-button @click="getDataList" icon="Search" type="primary">{{ $t('common.queryBtn')
}}
</el-button>
<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button @click="userDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary"
v-auth="'sys_user_add'">
{{ $t('common.addBtn') }}
</el-button>
<el-button @click="excelUploadRef.show()" class="ml10" icon="upload-filled" type="primary"
v-auth="'sys_user_add'">
{{ $t('common.importBtn') }}
</el-button>
<el-button @click="exportExcel" class="ml10" icon="Download" type="primary"
v-auth="'sys_user_export'">
{{ $t('common.exportBtn') }}
</el-button>
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete"
type="primary"
v-auth="'sys_user_del'">
{{ $t('common.delBtn') }}
</el-button>
<right-toolbar @queryTable="getDataList" class="ml10"
style="float: right;margin-right: 20px"
v-model:showSearch="showSearch"></right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" @selection-change="handleSelectionChange" border
max-height="450" style="width: 100%" v-loading="state.loading">
<el-table-column :selectable='handleSelectable' align="center" type="selection" width="50"/>
<el-table-column :label="$t('sysuser.index')" type="index" width="60"/>
<el-table-column :label="$t('sysuser.username')" prop="username"
show-overflow-tooltip width="120"></el-table-column>
<el-table-column :label="$t('sysuser.name')" fixed
prop="name" show-overflow-tooltip width="100"></el-table-column>
<el-table-column :label="$t('sysuser.phone')" prop="phone"
show-overflow-tooltip width="120"></el-table-column>
<el-table-column :label="$t('sysuser.post')" show-overflow-tooltip width="120">
<template #default="scope">
<el-tag :key="index" type="success" v-for="(item, index) in scope.row.postList">{{
item.postName }}
</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.role')" show-overflow-tooltip width="100">
<template #default="scope">
<el-tag :key="index" type="success" v-for="(item, index) in scope.row.roleList">{{
item.roleName }}
</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.lockFlag')" show-overflow-tooltip width="100">
<template #default="scope">
<dict-tag :options="lock_flag" :value="scope.row.lockFlag"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.createTime')" prop="createTime"
show-overflow-tooltip width="180"></el-table-column>
<el-table-column :label="$t('common.action')" fixed="right" width="160">
<template #default="scope">
<el-button @click="userDialogRef.openDialog(scope.row.userId)" text type="primary"
v-auth="'sys_user_edit'"> {{
$t('common.editBtn')
}}
</el-button>
<el-tooltip :content="$t('sysuser.deleteDisabledTip')"
:disabled="scope.row.userId !== '1'"
placement="top">
<span style="margin-left: 12px">
<el-button :disabled="scope.row.userId === '1'" @click="handleDelete([scope.row.userId])" text
type="primary"
v-auth="'sys_user_del'">{{
$t('common.delBtn')
}}
</el-button>
</span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination"> </pagination>
</div>
</el-col>
</el-row>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle"
v-bind="state.pagination">
</pagination>
</div>
</el-col>
</el-row>
<user-form @refresh="getDataList(false)" ref="userDialogRef" />
<user-form @refresh="getDataList(false)" ref="userDialogRef"/>
<upload-excel
:title="$t('sysuser.importUserTip')"
@refreshDataList="getDataList"
ref="excelUploadRef"
temp-url="/admin/sys-file/local/file/user.xlsx"
url="/admin/user/import"
/>
</div>
<upload-excel :title="$t('sysuser.importUserTip')" @refreshDataList="getDataList" ref="excelUploadRef"
temp-url="/admin/sys-file/local/file/user.xlsx" url="/admin/user/import"/>
</div>
</template>
<script lang="ts" name="systemUser" setup>
import { delObj, pageList } from '/@/api/admin/user';
import { depttree } from '/@/api/admin/dept';
import { BasicTableProps, useTable } from '/@/hooks/table';
import { useDict } from '/@/hooks/dict';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useI18n } from 'vue-i18n';
import {delObj, pageList} from '/@/api/admin/user'
import {depttree} from '/@/api/admin/dept'
import {BasicTableProps, useTable} from '/@/hooks/table'
import {useDict} from '/@/hooks/dict'
import {useMessage, useMessageBox} from '/@/hooks/message'
import {useI18n} from 'vue-i18n'
//
const UserForm = defineAsyncComponent(() => import('./form.vue'));
const QueryTree = defineAsyncComponent(() => import('/@/components/QueryTree/index.vue'));
//
const UserForm = defineAsyncComponent(() => import('./form.vue'));
const QueryTree = defineAsyncComponent(() => import('/@/components/QueryTree/index.vue'))
const { lock_flag } = useDict('lock_flag');
const { t } = useI18n();
const {lock_flag} = useDict('lock_flag')
const {t} = useI18n()
//
const userDialogRef = ref();
const excelUploadRef = ref();
const queryRef = ref();
const showSearch = ref(true);
//
const userDialogRef = ref();
const excelUploadRef = ref();
const queryRef = ref();
const showSearch = ref(true)
// rows
const selectObjs = ref([]) as any;
//
const multiple = ref(true);
// API
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
deptId: '',
username: '',
phone: '',
},
pageList: pageList,
});
// rows
const selectObjs = ref([]) as any
//
const multiple = ref(true)
// 使
const deptData = reactive({
queryList: (name: String) => {
return depttree({
deptName: name,
});
},
});
// API
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
deptId: '',
username: '',
phone: ''
},
pageList: pageList
});
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile } = useTable(state);
// 使
const deptData = reactive({
queryList: (name: String) => {
return depttree({
deptName: name
})
}
})
//
const resetQuery = () => {
queryRef.value.resetFields();
getDataList();
};
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
downBlobFile
} = useTable(state)
//
const handleNodeClick = (e: any) => {
state.queryForm.deptId = e.id;
getDataList();
};
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
// excel
const exportExcel = () => {
downBlobFile('/admin/user/export', state.queryForm, 'users.xlsx');
};
//
const handleNodeClick = (e: any) => {
state.queryForm.deptId = e.id
getDataList()
}
//
const handleSelectable = (row: any) => {
return row.userId !== '1';
};
// excel
const exportExcel = () => {
downBlobFile('/admin/user/export', state.queryForm, 'users.xlsx')
}
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.userId);
});
multiple.value = !objs.length;
};
//
const handleSelectable = (row: any) => {
return row.userId !== '1'
}
//
const handleDelete = (ids: string[]) => {
useMessageBox()
.confirm(t('common.delConfirmText'))
.then(() => {
delObj(ids)
.then(() => {
getDataList(false);
useMessage().success(t('common.delSuccessText'));
})
.catch((err: any) => {
useMessage().error(err.msg);
});
});
};
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.userId)
});
multiple.value = !objs.length
}
onMounted(() => {
state.dataList;
});
//
const handleDelete = (ids: string[]) => {
useMessageBox().confirm(t('common.delConfirmText'))
.then(() => {
delObj(ids).then(() => {
getDataList(false);
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
})
};
onMounted(() => {
state.dataList
})
</script>