From 68b837c7f2f903bc93622f6f9f3ce7ce6c8e3cb2 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期三, 07 八月 2024 10:14:33 +0800
Subject: [PATCH] fix: 知识库上传文件按钮取消
---
src/views/authority/users/index.vue | 983 ++++++++++++++++++++++++++++++---------------------------
1 files changed, 523 insertions(+), 460 deletions(-)
diff --git a/src/views/authority/users/index.vue b/src/views/authority/users/index.vue
index 80bb673..d20bb62 100644
--- a/src/views/authority/users/index.vue
+++ b/src/views/authority/users/index.vue
@@ -1,29 +1,32 @@
<template>
<div class="container">
<authheader :items="menuTips"></authheader>
- <a-card ref="account" class="general-card" :title="$t('menu.user.title')">
+ <a-card ref="account" class="general-card">
<a-row>
<a-col :flex="2"></a-col>
<a-col :flex="1">
- <a-form :model="formModel">
+ <a-form :model="formModel" style="margin-top: 30px">
<a-form-item field="name">
- <a-input v-model="formModel.name" :style="{width:'320px'}" :placeholder="$t('璇疯緭鍏�')" />
+ <a-input
+ v-model="formModel.name"
+ :style="{ width: '320px' }"
+ :placeholder="$t('璇疯緭鍏�')"
+ />
</a-form-item>
</a-form>
</a-col>
- <a-divider style="height: 40px" direction="vertical" />
- <a-col :flex="'200px'" style="text-align: right">
+ <a-col :flex="'200px'" style="text-align: right;margin-top: 30px">
<a-button @click="reset" style="margin-right: 20px">
<template #icon>
<icon-refresh />
</template>
- {{ $t("searchTable.form.reset") }}
+ {{ $t('searchTable.form.reset') }}
</a-button>
<a-button type="primary" @click="search">
<template #icon>
<icon-search />
</template>
- {{ $t("searchTable.form.search") }}
+ {{ $t('searchTable.form.search') }}
</a-button>
</a-col>
</a-row>
@@ -31,7 +34,9 @@
<a-row style="margin-bottom: 16px">
<a-col :span="12">
<a-space>
- <a-button type="primary" :align="'right'" @click="operation(0)">+ 鏂板缓璐︽埛</a-button>
+ <a-button type="primary" :align="'right'" @click="operation(0)"
+ >+ 鏂板缓璐︽埛</a-button
+ >
</a-space>
</a-col>
<a-col
@@ -39,10 +44,8 @@
style="display: flex; align-items: center; justify-content: end"
>
<a-tooltip :content="$t('searchTable.actions.refresh')">
- <div class="action-icon" @click="search"
- >
- <icon-refresh size="18"
- />
+ <div class="action-icon" @click="search">
+ <icon-refresh size="18" />
</div>
</a-tooltip>
<a-dropdown @select="handleSelectDensity">
@@ -77,23 +80,44 @@
<template #index="{ rowIndex }">
{{ rowIndex + 1 + (pagination.current - 1) * pagination.pageSize }}
</template>
- <template #dept="{ record }">{{ record.dept ? record.dept.deptName : "" }}</template>
- <template #status="{record}">
- <a-switch checked-value="1" unchecked-value="0" @change="statusChange(record.status,record)"
- v-model="record.status" />
+ <template #dept="{ record }">{{
+ record.dept ? record.dept.deptName : ''
+ }}</template>
+ <template #status="{ record }">
+ <a-switch
+ checked-value="1"
+ unchecked-value="0"
+ @change="statusChange(record.status, record)"
+ v-model="record.status"
+ />
</template>
<template #operations="{ record }">
- <a-button type="outline" @click="operation(1,record)">閲嶇疆瀵嗙爜</a-button>
- <a-button type="outline" @click="operation(2,record)">缂栬緫</a-button>
- <a-popconfirm content="Are you sure you want to delete?" type="success" @ok="operation(3,record)">
+ <a-button type="outline" @click="operation(1, record)"
+ >閲嶇疆瀵嗙爜</a-button
+ >
+ <a-button type="outline" @click="operation(2, record)">缂栬緫</a-button>
+ <a-popconfirm
+ content="Are you sure you want to delete?"
+ type="success"
+ @ok="operation(3, record)"
+ >
<a-button type="outline">鍒犻櫎</a-button>
</a-popconfirm>
- <a-button type="outline" @click="operation(4,record)">鏉冮檺閰嶇疆</a-button>
- <a-button type="outline" @click="operation(5,record)">閮ㄩ棬閰嶇疆</a-button>
+ <a-button type="outline" @click="operation(4, record)"
+ >鏉冮檺閰嶇疆</a-button
+ >
+ <a-button type="outline" @click="operation(5, record)"
+ >閮ㄩ棬閰嶇疆</a-button
+ >
</template>
</a-table>
</a-card>
- <a-modal v-model:visible="visible" :title="save" @cancel="handleCancel(1)" @ok="editHandleOk">
+ <a-modal
+ v-model:visible="visible"
+ :title="save"
+ @cancel="handleCancel(1)"
+ @ok="editHandleOk"
+ >
<a-form :model="editform">
<a-form-item field="name" label="鏄电О">
<a-input v-model="editform.nickName" />
@@ -109,10 +133,19 @@
</a-form-item>
</a-form>
</a-modal>
- <a-modal width="50%" v-model:visible="deptvisible" title="閮ㄩ棬閰嶇疆" @cancel="handleCancel(2)"
- @ok="editDeptHandleOk">
+ <a-modal
+ width="50%"
+ v-model:visible="deptvisible"
+ title="閮ㄩ棬閰嶇疆"
+ @cancel="handleCancel(2)"
+ @ok="editDeptHandleOk"
+ >
<div :style="{ display: 'flex' }">
- <a-card :style="{ width: '460px',height: '500px', 'overflow-y': 'auto' }" title="鏈烘瀯" hoverable>
+ <a-card
+ :style="{ 'width': '460px', 'height': '500px', 'overflow-y': 'auto' }"
+ title="鏈烘瀯"
+ hoverable
+ >
<a-tree
class="tree-demo"
v-model:checked-keys="checkedKeys"
@@ -122,19 +155,15 @@
:show-line="showLine"
@check="onCheck"
:fieldNames="{
- key:'deptId',
- title:'deptName',
- children:'children',
+ key: 'deptId',
+ title: 'deptName',
+ children: 'children',
}"
:check-strictly="checkStrictly"
>
</a-tree>
</a-card>
- <a-card
- class="card-demo"
- title="鐢ㄦ埛鎵�灞炴満鏋�"
- hoverable
- >
+ <a-card class="card-demo" title="鐢ㄦ埛鎵�灞炴満鏋�" hoverable>
<a-space wrap>
<a-tag
v-for="(tag, index) of checkStrictly"
@@ -146,12 +175,18 @@
</a-space>
</a-card>
</div>
-
</a-modal>
- <a-modal width="30%" v-model:visible="resourcevisible" title="鏉冮檺閰嶇疆" @cancel="handleCancel(3)"
- @ok="editResourceHandleOk">
- <div :style="{ display:'flex', 'flex-direction':'column' }">
- <a-tabs :style="{ width: '100%',height: '500px', 'overflow-y': 'auto' }">
+ <a-modal
+ width="30%"
+ v-model:visible="resourcevisible"
+ title="鏉冮檺閰嶇疆"
+ @cancel="handleCancel(3)"
+ @ok="editResourceHandleOk"
+ >
+ <div :style="{ 'display': 'flex', 'flex-direction': 'column' }">
+ <a-tabs
+ :style="{ 'width': '100%', 'height': '500px', 'overflow-y': 'auto' }"
+ >
<a-tab-pane key="1">
<template #title>
<icon-calendar />
@@ -166,10 +201,10 @@
:show-line="showLineMenu"
@check="onCheckMenu"
:fieldNames="{
- key:'menuId',
- title:'menuName',
- children:'children',
- }"
+ key: 'menuId',
+ title: 'menuName',
+ children: 'children',
+ }"
:check-strictly="checkStrictlyMenu"
>
</a-tree>
@@ -180,7 +215,11 @@
鐭ヨ瘑搴�
</template>
<a-space direction="vertical" size="large">
- <a-checkbox-group v-model="checkedKeysKnowledge" direction="vertical" @change="onCheckKnowledge">
+ <a-checkbox-group
+ v-model="checkedKeysKnowledge"
+ direction="vertical"
+ @change="onCheckKnowledge"
+ >
<a-checkbox
v-for="(knowledg, index) of knowledgeList"
:value="knowledg.id"
@@ -197,7 +236,11 @@
<icon-user />
鏅鸿兘浣�
</template>
- <a-checkbox-group v-model="checkedKeysDialog" direction="vertical" @change="onCheckDialog">
+ <a-checkbox-group
+ v-model="checkedKeysDialog"
+ direction="vertical"
+ @change="onCheckDialog"
+ >
<a-checkbox
v-for="(dialog, index) of DialogsList"
:value="dialog.id"
@@ -209,10 +252,16 @@
</a-checkbox-group>
</a-tab-pane>
</a-tabs>
- <a-card :style="{ width: '100%',height: '200px', 'overflow-y': 'auto', margin:'1px'}"
- class="card-demo"
- title="鐢ㄦ埛鎵�鏈夋潈闄�"
- hoverable
+ <a-card
+ :style="{
+ 'width': '100%',
+ 'height': '200px',
+ 'overflow-y': 'auto',
+ 'margin': '1px',
+ }"
+ class="card-demo"
+ title="鐢ㄦ埛鎵�鏈夋潈闄�"
+ hoverable
>
<a-space wrap>
鑿滃崟鍔熻兘锛�
@@ -248,444 +297,458 @@
</a-space>
</a-card>
</div>
-
</a-modal>
</div>
</template>
<script lang="ts" setup>
-import { computed, reactive, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import useLoading from "@/hooks/loading";
-import { Pagination } from "@/types/global";
-import type { TableColumnData } from "@arco-design/web-vue/es/table/interface";
-import {
- DialogList,
- KnowledgeList,
- OrganizationList,
- ResourceList,
- User,
- UserAdd,
- UserChangePwd,
- UserDelete,
- UserEdit,
- UserList,
- Userstatus
-} from "@/api/authority";
-import { Modal } from "@arco-design/web-vue";
-import Authheader from "@/views/authority/components/authheader.vue";
+ import { computed, reactive, ref } from 'vue';
+ import { useI18n } from 'vue-i18n';
+ import useLoading from '@/hooks/loading';
+ import { Pagination } from '@/types/global';
+ import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
+ import {
+ DialogList,
+ KnowledgeList,
+ OrganizationList,
+ ResourceList,
+ User,
+ UserAdd,
+ UserChangePwd,
+ UserDelete,
+ UserEdit,
+ UserList,
+ Userstatus,
+ } from '@/api/authority';
+ import { Modal } from '@arco-design/web-vue';
+ import Authheader from '@/views/authority/components/authheader.vue';
-let treeData = ref([]);
-let checkedKeys = ref([]);
-let expandKdys = ref([]);
-let checkStrictly = ref([]);
+ let treeData = ref([]);
+ let checkedKeys = ref([]);
+ let expandKdys = ref([]);
+ let checkStrictly = ref([]);
+ let treeDataMenu = ref([]);
+ let checkedKeysMenu = ref([]);
+ let expandKdysMenu = ref([]);
+ let checkStrictlyMenu = ref([]);
-let treeDataMenu = ref([]);
-let checkedKeysMenu = ref([]);
-let expandKdysMenu = ref([]);
-let checkStrictlyMenu = ref([]);
+ let checkedKeysKnowledge = ref([]);
+ let checkStrictlyKnowledge = ref([]);
-let checkedKeysKnowledge= ref([]);
-let checkStrictlyKnowledge= ref([]);
+ let checkedKeysDialog = ref([]);
+ let checkStrictlyDialog = ref([]);
-let checkedKeysDialog= ref([]);
-let checkStrictlyDialog= ref([]);
+ let knowledgeList = ref([]);
+ let DialogsList = ref([]);
-let knowledgeList = ref([]);
-let DialogsList = ref([]);
-
-
-let menuTips = ref(["鏉冮檺绠$悊", "璐﹀彿"]);
-type SizeProps = "mini" | "small" | "medium" | "large";
-const account = ref(null);
-const generateFormModel = () => {
- return {
- name: ""
+ let menuTips = ref(['鏉冮檺绠$悊', '璐﹀彿']);
+ type SizeProps = 'mini' | 'small' | 'medium' | 'large';
+ const account = ref(null);
+ const generateFormModel = () => {
+ return {
+ name: '',
+ };
};
-};
-let showLine = ref(true);
-const { loading, setLoading } = useLoading(true);
-const { t } = useI18n();
-let save = ref("鏂板");
-let renderData = ref<User[]>([]);
-let formModel = ref(generateFormModel());
-let editform = ref<User>({
- createTime: "",
- dept: undefined,
- email: "",
- nickName: "",
- phoneNumber: "",
- status: "",
- userId: "",
- userName: ""
-});
-
-let size = ref<SizeProps>("medium");
-let visible = ref(false);
-let deptvisible = ref(false);
-let resourcevisible = ref(false);
-let selectUser = ref({});
-
-const onCheck = (newCheckedKeys, event) => {
- let o = { "deptId": event.node.deptId, "deptName": event.node.deptName };
- if (event.checked) {
- checkStrictly.value.push(o);
- } else {
- checkStrictly.value.forEach((val, idx, array) => {
- // val: 褰撳墠鍊�
- if (val.deptId == event.node.deptId) {
- checkStrictly.value.splice(idx, 1);
- return true;
- }
- });
-
- }
-};
-const onCheckMenu = (newCheckedKeys, event) => {
- let o = { "menuId": event.node.menuId, "menuName": event.node.menuName };
- if (event.checked) {
- checkStrictlyMenu.value.push(o);
- } else {
- checkStrictlyMenu.value.forEach((val, idx, array) => {
- // val: 褰撳墠鍊�
- if (val.menuId == event.node.menuId) {
- checkStrictlyMenu.value.splice(idx, 1);
- return true;
- }
- });
- }
-};
-const onCheckKnowledge = (newCheckedKeys, event) => {
- let o = { "knowledgeId": event.target.value, "knowledgeName": event.target.labels[0].innerText };
- if (event.target.checked) {
- checkStrictlyKnowledge.value.push(o);
- } else {
- checkStrictlyKnowledge.value.forEach((val, idx, array) => {
- // val: 褰撳墠鍊�
- if (val.knowledgeId == event.target.value) {
- checkStrictlyKnowledge.value.splice(idx, 1);
- return true;
- }
- });
- }
-};
-
-
-const onCheckDialog = (newCheckedKeys, event) => {
- let o = { "dialogId": event.target.value, "dialogName": event.target.labels[0].innerText };
- if (event.target.checked) {
- checkStrictlyDialog.value.push(o);
- } else {
- checkStrictlyDialog.value.forEach((val, idx, array) => {
- // val: 褰撳墠鍊�
- if (val.dialogId == event.target.value) {
- checkStrictlyDialog.value.splice(idx, 1);
- return true;
- }
- });
- }
-};
-
-const handleRemove = (key) => {
- checkStrictly.value = checkStrictly.value.filter((tag) => tag !== key);
-};
-const handleMenuRemove = (key) => {
- checkStrictlyMenu.value = checkStrictlyMenu.value.filter((tag) => tag !== key);
-};
-const handleKnowledgeRemove = (key) => {
- checkStrictlyKnowledge.value = checkStrictlyKnowledge.value.filter((tag) => tag !== key);
-};
-const handleDialogRemove = (key) => {
- checkStrictlyDialog.value = checkStrictlyDialog.value.filter((tag) => tag !== key);
-};
-
-
-const basePagination: Pagination = {
- current: 1,
- pageSize: 20
-};
-const pagination = reactive({
- ...basePagination
-});
-
-const densityList = computed(() => [
- {
- name: t("searchTable.size.mini"),
- value: "mini"
- },
- {
- name: t("searchTable.size.small"),
- value: "small"
- },
- {
- name: t("searchTable.size.medium"),
- value: "medium"
- },
- {
- name: t("searchTable.size.large"),
- value: "large"
- }
-]);
-const columns = computed<TableColumnData[]>(() => [
- {
- title: t("搴忓彿"),
- dataIndex: "index",
- slotName: "index"
- },
- {
- title: t("鐢ㄦ埛鍚�"),
- dataIndex: "userName"
- },
- {
- title: t("鍒涘缓鏃堕棿"),
- dataIndex: "createTime"
- },
- {
- title: t("鎵�灞為儴闂�"),
- dataIndex: "dept",
- slotName: "dept"
- },
- {
- title: t("鐘舵��"),
- dataIndex: "status",
- slotName: "status"
- },
- {
- title: t("searchTable.columns.operations"),
- dataIndex: "operations",
- slotName: "operations"
- }
-]);
-
-const statusChange = async (value, record) => {
- await Userstatus(record.userId, value).then((res) => {
-
+ let showLine = ref(true);
+ const { loading, setLoading } = useLoading(true);
+ const { t } = useI18n();
+ let save = ref('鏂板');
+ let renderData = ref<User[]>([]);
+ let formModel = ref(generateFormModel());
+ let editform = ref<User>({
+ createTime: '',
+ dept: undefined,
+ email: '',
+ nickName: '',
+ phoneNumber: '',
+ status: '',
+ userId: '',
+ userName: '',
});
-};
-const handleCancel = (type) => {
- if (type == 1) {
- visible.value = false;
- }
- if (type == 2) {
- deptvisible.value = false;
- }
- if (type == 2) {
- resourcevisible.value = false;
- }
+ let size = ref<SizeProps>('medium');
+ let visible = ref(false);
+ let deptvisible = ref(false);
+ let resourcevisible = ref(false);
+ let selectUser = ref({});
-};
+ const onCheck = (newCheckedKeys, event) => {
+ let o = { deptId: event.node.deptId, deptName: event.node.deptName };
+ if (event.checked) {
+ checkStrictly.value.push(o);
+ } else {
+ checkStrictly.value.forEach((val, idx, array) => {
+ // val: 褰撳墠鍊�
+ if (val.deptId == event.node.deptId) {
+ checkStrictly.value.splice(idx, 1);
+ return true;
+ }
+ });
+ }
+ };
+ const onCheckMenu = (newCheckedKeys, event) => {
+ let o = { menuId: event.node.menuId, menuName: event.node.menuName };
+ if (event.checked) {
+ checkStrictlyMenu.value.push(o);
+ } else {
+ checkStrictlyMenu.value.forEach((val, idx, array) => {
+ // val: 褰撳墠鍊�
+ if (val.menuId == event.node.menuId) {
+ checkStrictlyMenu.value.splice(idx, 1);
+ return true;
+ }
+ });
+ }
+ };
+ const onCheckKnowledge = (newCheckedKeys, event) => {
+ let o = {
+ knowledgeId: event.target.value,
+ knowledgeName: event.target.labels[0].innerText,
+ };
+ if (event.target.checked) {
+ checkStrictlyKnowledge.value.push(o);
+ } else {
+ checkStrictlyKnowledge.value.forEach((val, idx, array) => {
+ // val: 褰撳墠鍊�
+ if (val.knowledgeId == event.target.value) {
+ checkStrictlyKnowledge.value.splice(idx, 1);
+ return true;
+ }
+ });
+ }
+ };
-const editDeptHandleOk = async () => {
- let depts: Array = [], user: User = { "userId": selectUser.value.userId };
- checkStrictly.value.forEach((val) => {
- depts.push(val.deptId);
- });
- user.dept = depts;
- await UserEdit(user).then((res) => {
- fetchData();
- });
-};
+ const onCheckDialog = (newCheckedKeys, event) => {
+ let o = {
+ dialogId: event.target.value,
+ dialogName: event.target.labels[0].innerText,
+ };
+ if (event.target.checked) {
+ checkStrictlyDialog.value.push(o);
+ } else {
+ checkStrictlyDialog.value.forEach((val, idx, array) => {
+ // val: 褰撳墠鍊�
+ if (val.dialogId == event.target.value) {
+ checkStrictlyDialog.value.splice(idx, 1);
+ return true;
+ }
+ });
+ }
+ };
-const editResourceHandleOk = async () => {
- let resources: Array = [],dialogs: Array = [],Knowledges: Array = [], user: User = { "userId": selectUser.value.userId };
- checkStrictlyMenu.value.forEach((val) => {
- resources.push(val.menuId);
- });
- user.resources = resources;
+ const handleRemove = (key) => {
+ checkStrictly.value = checkStrictly.value.filter((tag) => tag !== key);
+ };
+ const handleMenuRemove = (key) => {
+ checkStrictlyMenu.value = checkStrictlyMenu.value.filter(
+ (tag) => tag !== key
+ );
+ };
+ const handleKnowledgeRemove = (key) => {
+ checkStrictlyKnowledge.value = checkStrictlyKnowledge.value.filter(
+ (tag) => tag !== key
+ );
+ };
+ const handleDialogRemove = (key) => {
+ checkStrictlyDialog.value = checkStrictlyDialog.value.filter(
+ (tag) => tag !== key
+ );
+ };
- checkStrictlyKnowledge.value.forEach((val) => {
- Knowledges.push(val.knowledgeId);
- });
- user.knowledges = Knowledges;
-
- checkStrictlyDialog.value.forEach((val) => {
- dialogs.push(val.dialogId);
- });
- user.dialogs = dialogs;
-
- await UserEdit(user).then((res) => {
- fetchData();
- });
-};
-
-const editHandleOk = async () => {
- if (editform.value.userId.length > 0) {
- await UserEdit({
- ...editform.value
- } as unknown as User).then((res) => {
- fetchData();
- });
- } else {
- await UserAdd({
- ...editform.value
- } as unknown as User).then((res) => {
- fetchData();
- });
- }
-};
-const operation = async (t, record) => {
- if (t == 0) {
- save.value = "鏂板";
- visible.value = true;
- editform.value.userId = "";
- editform.value.userName = "";
- editform.value.nickName = "";
- editform.value.email = "";
- editform.value.phoneNumber = "";
- }
-//閲嶇疆瀵嗙爜
- if (t == 1) {
- await UserChangePwd(record.userId).then((res) => {
- if (res.code == 20000) {
- Modal.success({
- title: "閲嶇疆瀵嗙爜",
- content: "璇ョ敤鎴峰瘑鐮侀噸缃负000000"
- });
- } else {
- Modal.error({
- title: "閲嶇疆瀵嗙爜",
- content: "璇ョ敤鎴峰瘑鐮侀噸缃け璐�"
- });
- }
- });
- }
- //缂栬緫
- if (t == 2) {
- visible.value = true;
- save.value = "缂栬緫";
- editform.value.userId = record.userId;
- editform.value.userName = record.userName;
- editform.value.nickName = record.nickName;
- editform.value.email = record.email;
- editform.value.phoneNumber = record.phoneNumber;
- }
- //鍒犻櫎
- if (t == 3) {
- await UserDelete(record.userId).then((res) => {
- if (res.code == 20000) {
- fetchData();
- }
- });
- }
- //鏉冮檺
- if (t == 4) {
- resourcevisible.value = true;
- checkedKeysMenu.value = [];
- expandKdysMenu.value = [];
- checkStrictlyMenu.value = [];
- checkStrictlyKnowledge.value=[];
- checkedKeysKnowledge.value=[];
- checkStrictlyDialog.value=[];
- checkedKeysDialog.value=[];
- selectUser.value = record;
- record.resources.forEach((val) => {
- checkStrictlyMenu.value.push({ "menuId": val.menuId, "menuName": val.menuName });
- checkedKeysMenu.value.push(val.menuId);
- expandKdysMenu.value.push(val.menuId);
- });
- record.knowledges.forEach((val) => {
- checkStrictlyKnowledge.value.push({ "knowledgeId": val.id, "knowledgeName": val.name });
- checkedKeysKnowledge.value.push(val.id);
- });
- record.dialogs.forEach((val) => {
- checkStrictlyDialog.value.push({ "dialogId": val.id, "dialogName": val.name });
- checkedKeysDialog.value.push(val.id);
- });
-
- }
- //鏈烘瀯
- if (t == 5) {
- deptvisible.value = true;
- checkedKeys.value = [];
- expandKdys.value = [];
- checkStrictly.value = [];
- selectUser.value = record;
- expandKdys.value.push("0");
- record.dept.forEach((val) => {
- checkStrictly.value.push({ "deptId": val.deptId, "deptName": val.deptName });
- checkedKeys.value.push(val.deptId);
- expandKdys.value.push(val.deptId);
- });
-
- }
-};
-
-const fetchData = async (
- params: Pagination = { current: 1, pageSize: 20 }
-) => {
- setLoading(true);
- try {
- await UserList(params).then((res) => {
- renderData.value = res.rows;
- console.log(renderData);
- pagination.current = params.current;
- pagination.total = res.total;
- });
- } catch (err) {
- // you can report use errorHandler or other
- } finally {
- setLoading(false);
- }
-};
-
-const search = () => {
- fetchData({
+ const basePagination: Pagination = {
+ current: 1,
+ pageSize: 20,
+ };
+ const pagination = reactive({
...basePagination,
- ...formModel.value
- } as unknown as Pagination);
-};
-
-const onPageChange = (current: number) => {
- fetchData({ ...basePagination, current });
-};
-
-const OrganizationData = async (key) => {
- await OrganizationList(key).then((res) => {
- treeData.value = [...res.rows];
});
-};
-const MenuData = async (key) => {
- await ResourceList(key).then((res) => {
- treeDataMenu.value = [...res.rows];
+
+ const densityList = computed(() => [
+ {
+ name: t('searchTable.size.mini'),
+ value: 'mini',
+ },
+ {
+ name: t('searchTable.size.small'),
+ value: 'small',
+ },
+ {
+ name: t('searchTable.size.medium'),
+ value: 'medium',
+ },
+ {
+ name: t('searchTable.size.large'),
+ value: 'large',
+ },
+ ]);
+ const columns = computed<TableColumnData[]>(() => [
+ {
+ title: t('搴忓彿'),
+ dataIndex: 'index',
+ slotName: 'index',
+ },
+ {
+ title: t('鐢ㄦ埛鍚�'),
+ dataIndex: 'userName',
+ },
+ {
+ title: t('鍒涘缓鏃堕棿'),
+ dataIndex: 'createTime',
+ },
+ {
+ title: t('鎵�灞為儴闂�'),
+ dataIndex: 'dept',
+ slotName: 'dept',
+ },
+ {
+ title: t('鐘舵��'),
+ dataIndex: 'status',
+ slotName: 'status',
+ },
+ {
+ title: t('searchTable.columns.operations'),
+ dataIndex: 'operations',
+ slotName: 'operations',
+ },
+ ]);
+
+ const statusChange = async (value, record) => {
+ await Userstatus(record.userId, value).then((res) => {});
+ };
+
+ const handleCancel = (type) => {
+ if (type == 1) {
+ visible.value = false;
+ }
+ if (type == 2) {
+ deptvisible.value = false;
+ }
+ if (type == 2) {
+ resourcevisible.value = false;
+ }
+ };
+
+ const editDeptHandleOk = async () => {
+ let depts: Array = [],
+ user: User = { userId: selectUser.value.userId };
+ checkStrictly.value.forEach((val) => {
+ depts.push(val.deptId);
+ });
+ user.dept = depts;
+ await UserEdit(user).then((res) => {
+ fetchData();
+ });
+ };
+
+ const editResourceHandleOk = async () => {
+ let resources: Array = [],
+ dialogs: Array = [],
+ Knowledges: Array = [],
+ user: User = { userId: selectUser.value.userId };
+ checkStrictlyMenu.value.forEach((val) => {
+ resources.push(val.menuId);
+ });
+ user.resources = resources;
+
+ checkStrictlyKnowledge.value.forEach((val) => {
+ Knowledges.push(val.knowledgeId);
+ });
+ user.knowledges = Knowledges;
+
+ checkStrictlyDialog.value.forEach((val) => {
+ dialogs.push(val.dialogId);
+ });
+ user.dialogs = dialogs;
+
+ await UserEdit(user).then((res) => {
+ fetchData();
+ });
+ };
+
+ const editHandleOk = async () => {
+ if (editform.value.userId.length > 0) {
+ await UserEdit({
+ ...editform.value,
+ } as unknown as User).then((res) => {
+ fetchData();
+ });
+ } else {
+ await UserAdd({
+ ...editform.value,
+ } as unknown as User).then((res) => {
+ fetchData();
+ });
+ }
+ };
+ const operation = async (t, record) => {
+ if (t == 0) {
+ save.value = '鏂板';
+ visible.value = true;
+ editform.value.userId = '';
+ editform.value.userName = '';
+ editform.value.nickName = '';
+ editform.value.email = '';
+ editform.value.phoneNumber = '';
+ }
+ //閲嶇疆瀵嗙爜
+ if (t == 1) {
+ await UserChangePwd(record.userId).then((res) => {
+ if (res.code == 20000) {
+ Modal.success({
+ title: '閲嶇疆瀵嗙爜',
+ content: '璇ョ敤鎴峰瘑鐮侀噸缃负000000',
+ });
+ } else {
+ Modal.error({
+ title: '閲嶇疆瀵嗙爜',
+ content: '璇ョ敤鎴峰瘑鐮侀噸缃け璐�',
+ });
+ }
+ });
+ }
+ //缂栬緫
+ if (t == 2) {
+ visible.value = true;
+ save.value = '缂栬緫';
+ editform.value.userId = record.userId;
+ editform.value.userName = record.userName;
+ editform.value.nickName = record.nickName;
+ editform.value.email = record.email;
+ editform.value.phoneNumber = record.phoneNumber;
+ }
+ //鍒犻櫎
+ if (t == 3) {
+ await UserDelete(record.userId).then((res) => {
+ if (res.code == 20000) {
+ fetchData();
+ }
+ });
+ }
+ //鏉冮檺
+ if (t == 4) {
+ resourcevisible.value = true;
+ checkedKeysMenu.value = [];
+ expandKdysMenu.value = [];
+ checkStrictlyMenu.value = [];
+ checkStrictlyKnowledge.value = [];
+ checkedKeysKnowledge.value = [];
+ checkStrictlyDialog.value = [];
+ checkedKeysDialog.value = [];
+ selectUser.value = record;
+ record.resources.forEach((val) => {
+ checkStrictlyMenu.value.push({
+ menuId: val.menuId,
+ menuName: val.menuName,
+ });
+ checkedKeysMenu.value.push(val.menuId);
+ expandKdysMenu.value.push(val.menuId);
+ });
+ record.knowledges.forEach((val) => {
+ checkStrictlyKnowledge.value.push({
+ knowledgeId: val.id,
+ knowledgeName: val.name,
+ });
+ checkedKeysKnowledge.value.push(val.id);
+ });
+ record.dialogs.forEach((val) => {
+ checkStrictlyDialog.value.push({
+ dialogId: val.id,
+ dialogName: val.name,
+ });
+ checkedKeysDialog.value.push(val.id);
+ });
+ }
+ //鏈烘瀯
+ if (t == 5) {
+ deptvisible.value = true;
+ checkedKeys.value = [];
+ expandKdys.value = [];
+ checkStrictly.value = [];
+ selectUser.value = record;
+ expandKdys.value.push('0');
+ record.dept.forEach((val) => {
+ checkStrictly.value.push({
+ deptId: val.deptId,
+ deptName: val.deptName,
+ });
+ checkedKeys.value.push(val.deptId);
+ expandKdys.value.push(val.deptId);
+ });
+ }
+ };
+
+ const fetchData = async (
+ params: Pagination = { current: 1, pageSize: 20 }
+ ) => {
+ setLoading(true);
+ try {
+ await UserList(params).then((res) => {
+ renderData.value = res.rows;
+ console.log(renderData);
+ pagination.current = params.current;
+ pagination.total = res.total;
+ });
+ } catch (err) {
+ // you can report use errorHandler or other
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const search = () => {
+ fetchData({
+ ...basePagination,
+ ...formModel.value,
+ } as unknown as Pagination);
+ };
+
+ const onPageChange = (current: number) => {
+ fetchData({ ...basePagination, current });
+ };
+
+ const OrganizationData = async (key) => {
+ await OrganizationList(key).then((res) => {
+ treeData.value = [...res.rows];
+ });
+ };
+ const MenuData = async (key) => {
+ await ResourceList(key).then((res) => {
+ treeDataMenu.value = [...res.rows];
+ });
+ };
+
+ KnowledgeList().then((res) => {
+ knowledgeList.value = res.rows;
});
-};
-KnowledgeList().then((res) => {
- knowledgeList.value = res.rows;
-});
+ DialogList().then((res) => {
+ DialogsList.value = res.rows;
+ });
+ fetchData();
+ OrganizationData('');
+ MenuData();
-DialogList().then((res) => {
- DialogsList.value = res.rows;
-});
-fetchData();
-OrganizationData("");
-MenuData();
+ const reset = () => {
+ formModel.value = generateFormModel();
+ };
-const reset = () => {
- formModel.value = generateFormModel();
-};
-
-const handleSelectDensity = (
- val: string | number | Record<string, any> | undefined,
- e: Event
-) => {
- size.value = val as SizeProps;
-};
-
+ const handleSelectDensity = (
+ val: string | number | Record<string, any> | undefined,
+ e: Event
+ ) => {
+ size.value = val as SizeProps;
+ };
</script>
-
<style scoped>
-.card-demo {
- width: 460px;
- margin-left: 24px;
- transition-property: all;
-}
+ .card-demo {
+ width: 460px;
+ margin-left: 24px;
+ transition-property: all;
+ }
-.card-demo:hover {
- transform: translateY(-4px);
-}
+ .card-demo:hover {
+ transform: translateY(-4px);
+ }
</style>
-
--
Gitblit v1.8.0