|
@@ -37,8 +37,8 @@
|
|
|
<AccountModal @register="registerModal" @success="handleSuccess" />
|
|
|
</PageWrapper>
|
|
|
</template>
|
|
|
-<script lang="ts">
|
|
|
- import { defineComponent, ref, reactive, h } from 'vue';
|
|
|
+<script lang="ts" setup>
|
|
|
+ import { ref, reactive, h } from 'vue';
|
|
|
import { BasicTable, useTable, TableAction, FormSchema, BasicColumn } from '/@/components/Table';
|
|
|
import { getUserPageList, deleteUser, resetUserPassword } from '/@/api/system/user';
|
|
|
import { PageWrapper } from '/@/components/Page';
|
|
@@ -52,7 +52,7 @@
|
|
|
import { postUserChangeStatus } from '/@/services/apis/UserController';
|
|
|
const { t } = useI18n();
|
|
|
const searchInfo = reactive<Recordable>({});
|
|
|
- export const searchFormSchema: FormSchema[] = [
|
|
|
+ const searchFormSchema: FormSchema[] = [
|
|
|
{
|
|
|
field: 'userName',
|
|
|
label: t('用户名'),
|
|
@@ -79,7 +79,7 @@
|
|
|
},
|
|
|
];
|
|
|
|
|
|
- export const columns: BasicColumn[] = [
|
|
|
+ const columns: BasicColumn[] = [
|
|
|
{
|
|
|
title: t('用户名'),
|
|
|
dataIndex: 'userName',
|
|
@@ -164,141 +164,119 @@
|
|
|
},
|
|
|
];
|
|
|
|
|
|
- export default defineComponent({
|
|
|
- name: 'UserManagement',
|
|
|
- components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction },
|
|
|
- setup() {
|
|
|
- const { notification } = useMessage();
|
|
|
+ const { notification } = useMessage();
|
|
|
|
|
|
- const isVisible = ref<boolean>(false);
|
|
|
- const deleteIndex = ref();
|
|
|
- const [registerModal, { openModal }] = useModal();
|
|
|
- const [registerTable, { reload, getSelectRows }] = useTable({
|
|
|
- title: t('用户列表'),
|
|
|
- api: getUserPageList,
|
|
|
- rowKey: 'id',
|
|
|
- columns,
|
|
|
- formConfig: {
|
|
|
- rowProps: {
|
|
|
- gutter: 16,
|
|
|
- },
|
|
|
- schemas: searchFormSchema,
|
|
|
- },
|
|
|
- rowSelection: {
|
|
|
- type: 'radio',
|
|
|
- },
|
|
|
- useSearchForm: true,
|
|
|
- showTableSetting: true,
|
|
|
- striped: false,
|
|
|
- immediate: false,
|
|
|
- actionColumn: {
|
|
|
- width: 80,
|
|
|
- title: t('操作'),
|
|
|
- dataIndex: 'action',
|
|
|
- slots: { customRender: 'action' },
|
|
|
- },
|
|
|
- });
|
|
|
+ const isVisible = ref<boolean>(false);
|
|
|
+ const deleteIndex = ref();
|
|
|
+ const [registerModal, { openModal }] = useModal();
|
|
|
+ const [registerTable, { reload, getSelectRows }] = useTable({
|
|
|
+ title: t('用户列表'),
|
|
|
+ api: getUserPageList,
|
|
|
+ rowKey: 'id',
|
|
|
+ columns,
|
|
|
+ formConfig: {
|
|
|
+ rowProps: {
|
|
|
+ gutter: 16,
|
|
|
+ },
|
|
|
+ schemas: searchFormSchema,
|
|
|
+ },
|
|
|
+ rowSelection: {
|
|
|
+ type: 'radio',
|
|
|
+ },
|
|
|
+ useSearchForm: true,
|
|
|
+ showTableSetting: true,
|
|
|
+ striped: false,
|
|
|
+ immediate: false,
|
|
|
+ actionColumn: {
|
|
|
+ width: 80,
|
|
|
+ title: t('操作'),
|
|
|
+ dataIndex: 'action',
|
|
|
+ slots: { customRender: 'action' },
|
|
|
+ },
|
|
|
+ });
|
|
|
|
|
|
- function popVisible(index) {
|
|
|
- return isVisible.value && index === deleteIndex.value;
|
|
|
- }
|
|
|
+ function popVisible(index) {
|
|
|
+ return isVisible.value && index === deleteIndex.value;
|
|
|
+ }
|
|
|
|
|
|
- function handleCreate() {
|
|
|
- openModal(true, {
|
|
|
- isUpdate: false,
|
|
|
- });
|
|
|
- }
|
|
|
+ function handleCreate() {
|
|
|
+ openModal(true, {
|
|
|
+ isUpdate: false,
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- function handleEdit(record: Recordable) {
|
|
|
- openModal(true, {
|
|
|
- id: record.id,
|
|
|
- isUpdate: true,
|
|
|
- });
|
|
|
- }
|
|
|
+ function handleEdit(record: Recordable) {
|
|
|
+ openModal(true, {
|
|
|
+ id: record.id,
|
|
|
+ isUpdate: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- function handleVisibleChange(index, bool) {
|
|
|
- if (!bool) {
|
|
|
- isVisible.value = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- // if (process.env.NODE_ENV === 'production') {
|
|
|
- // notification.warning({
|
|
|
- // message: '在线环境暂不允许该操作,请联系管理员。',
|
|
|
- // });
|
|
|
- // return;
|
|
|
- // }
|
|
|
- isVisible.value = true;
|
|
|
- deleteIndex.value = index;
|
|
|
- }
|
|
|
+ function handleVisibleChange(index, bool) {
|
|
|
+ if (!bool) {
|
|
|
+ isVisible.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // if (process.env.NODE_ENV === 'production') {
|
|
|
+ // notification.warning({
|
|
|
+ // message: '在线环境暂不允许该操作,请联系管理员。',
|
|
|
+ // });
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ isVisible.value = true;
|
|
|
+ deleteIndex.value = index;
|
|
|
+ }
|
|
|
|
|
|
- function handleDelete(record: Recordable) {
|
|
|
- isVisible.value = false;
|
|
|
- deleteUser([record.id]).then((_) => {
|
|
|
- reload();
|
|
|
- notification.success({
|
|
|
- message: t('删除'),
|
|
|
- description: t('成功'),
|
|
|
- }); //提示消息
|
|
|
- });
|
|
|
- }
|
|
|
- function handleCancel() {
|
|
|
- isVisible.value = false;
|
|
|
- }
|
|
|
- function handleReset() {
|
|
|
- // if (process.env.NODE_ENV === 'production') {
|
|
|
- // notification.warning({
|
|
|
- // message: '在线环境暂不允许该操作,请联系管理员。',
|
|
|
- // });
|
|
|
- // return;
|
|
|
- // }
|
|
|
- let rows = warning();
|
|
|
- if (!rows) {
|
|
|
- return;
|
|
|
- }
|
|
|
- resetUserPassword(rows.id).then(() => {
|
|
|
- notification.success({
|
|
|
- message: t('重置密码成功'),
|
|
|
- description: t('成功'),
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- function warning() {
|
|
|
- const selectRows = getSelectRows();
|
|
|
- if (selectRows.length === 0) {
|
|
|
- notification.warning({
|
|
|
- message: t('警告'),
|
|
|
- description: t('必须选中一行!'),
|
|
|
- }); //提示消息
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return selectRows[0];
|
|
|
- }
|
|
|
- }
|
|
|
- function handleSuccess() {
|
|
|
- reload();
|
|
|
- }
|
|
|
-
|
|
|
- function handleSelect(item) {
|
|
|
- searchInfo.treeId = item.id;
|
|
|
- searchInfo.treeType = item.type;
|
|
|
- reload();
|
|
|
- }
|
|
|
+ function handleDelete(record: Recordable) {
|
|
|
+ isVisible.value = false;
|
|
|
+ deleteUser([record.id]).then((_) => {
|
|
|
+ reload();
|
|
|
+ notification.success({
|
|
|
+ message: t('删除'),
|
|
|
+ description: t('成功'),
|
|
|
+ }); //提示消息
|
|
|
+ });
|
|
|
+ }
|
|
|
+ function handleCancel() {
|
|
|
+ isVisible.value = false;
|
|
|
+ }
|
|
|
+ function handleReset() {
|
|
|
+ // if (process.env.NODE_ENV === 'production') {
|
|
|
+ // notification.warning({
|
|
|
+ // message: '在线环境暂不允许该操作,请联系管理员。',
|
|
|
+ // });
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ let rows = warning();
|
|
|
+ if (!rows) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ resetUserPassword(rows.id).then(() => {
|
|
|
+ notification.success({
|
|
|
+ message: t('重置密码成功'),
|
|
|
+ description: t('成功'),
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ function warning() {
|
|
|
+ const selectRows = getSelectRows();
|
|
|
+ if (selectRows.length === 0) {
|
|
|
+ notification.warning({
|
|
|
+ message: t('警告'),
|
|
|
+ description: t('必须选中一行!'),
|
|
|
+ }); //提示消息
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return selectRows[0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function handleSuccess() {
|
|
|
+ reload();
|
|
|
+ }
|
|
|
|
|
|
- return {
|
|
|
- registerTable,
|
|
|
- registerModal,
|
|
|
- popVisible,
|
|
|
- handleVisibleChange,
|
|
|
- handleCreate,
|
|
|
- handleEdit,
|
|
|
- handleDelete,
|
|
|
- handleSuccess,
|
|
|
- handleSelect,
|
|
|
- handleReset,
|
|
|
- handleCancel,
|
|
|
- t,
|
|
|
- searchInfo,
|
|
|
- };
|
|
|
- },
|
|
|
- });
|
|
|
+ function handleSelect(item) {
|
|
|
+ searchInfo.treeId = item.id;
|
|
|
+ searchInfo.treeType = item.type;
|
|
|
+ reload();
|
|
|
+ }
|
|
|
</script>
|