From e2f24f54294071b232a9b5616bee4d6dc46c7ae5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com>
Date: Sat, 15 Jan 2022 23:55:14 +0800
Subject: [PATCH] =?UTF-8?q?refactor(user/index.vue):=20=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +-
src/api/system/dept.ts | 2 +-
src/api/system/dict.ts | 2 +-
src/api/system/role.ts | 2 +-
src/api/system/user.ts | 52 +-
src/components/TreeSelect/index.vue | 36 +-
src/main.ts | 4 +-
src/views/dashboard/index.vue | 102 ++--
src/views/sms/advert/index.vue | 13 +-
src/views/system/client/index.vue | 2 +-
src/views/system/dept/index.vue | 15 +-
src/views/system/menu/components/Perm.vue | 4 +-
src/views/system/user/index.vue | 615 +++++++++-------------
13 files changed, 362 insertions(+), 491 deletions(-)
diff --git a/README.md b/README.md
index 0eba5f2a..fcc12b02 100644
--- a/README.md
+++ b/README.md
@@ -101,7 +101,7 @@ import '@/permission'
import Pagination from '@/components/Pagination/index.vue'
-import {getDictItemsByCode} from '@/api/system/dict'
+import {listDictsByCode} from '@/api/system/dict'
const app = createApp(App)
@@ -113,7 +113,7 @@ for (let iconName in ElIconModules) {
}
// 全局方法
-app.config.globalProperties.$getDictItemsByCode = getDictItemsByCode
+app.config.globalProperties.$listDictsByCode = listDictsByCode
app.component('Pagination', Pagination) // 全局组件
.use(store)
.use(router)
diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts
index 9dc3bb45..43123e06 100644
--- a/src/api/system/dept.ts
+++ b/src/api/system/dept.ts
@@ -41,7 +41,7 @@ export const updateDept = (id:number,data: any) => {
}
-export const getDeptSelectList = ()=> {
+export const listDeptsForSelect = ()=> {
return request({
url: '/youlai-admin/api/v1/depts/select',
method: 'get'
diff --git a/src/api/system/dict.ts b/src/api/system/dict.ts
index a3b08056..5b203566 100644
--- a/src/api/system/dict.ts
+++ b/src/api/system/dict.ts
@@ -83,7 +83,7 @@ export function listDictItemsWithPage(queryParams: object) {
*
* @param dictCode
*/
-export function getDictItemsByCode(dictCode: string) {
+export function listDictsByCode(dictCode: string) {
return request({
url: '/youlai-admin/api/v2/dict/items',
method: 'get',
diff --git a/src/api/system/role.ts b/src/api/system/role.ts
index 6962fed8..5dc499ca 100644
--- a/src/api/system/role.ts
+++ b/src/api/system/role.ts
@@ -18,7 +18,7 @@ export function listRolesWithPage(queryParams: object) {
*
* @param queryParams
*/
-export function listRoles(queryParams: object) {
+export function listRoles(queryParams?: object) {
return request({
url: '/youlai-admin/api/v1/roles',
method: 'get',
diff --git a/src/api/system/user.ts b/src/api/system/user.ts
index d7a6bb15..327ac301 100644
--- a/src/api/system/user.ts
+++ b/src/api/system/user.ts
@@ -1,21 +1,36 @@
-
import request from "@/utils/request";
-export const listUser = (queryParams:any)=> {
+
+/**
+ * 获取用户分页列表
+ *
+ * @param queryParams
+ */
+export function listUsersWithPage(queryParams: any) {
return request({
- url: '/youlai-admin/api/v2/users',
+ url: '/youlai-admin/api/v1/users/page',
method: 'get',
params: queryParams
})
}
-export const getUser = (id ?:any) =>{
+/**
+ * 获取用户表单详情
+ *
+ * @param userId
+ */
+export function getUserFormDetail(userId: any) {
return request({
- url: '/youlai-admin/api/v1/users/' + id,
+ url: '/youlai-admin/api/v1/users/' + userId + '/form',
method: 'get'
})
}
-export const addUser = (data:any) => {
+/**
+ * 添加用户
+ *
+ * @param data
+ */
+export function addUser(data: any) {
return request({
url: '/youlai-admin/api/v1/users',
method: 'post',
@@ -23,7 +38,13 @@ export const addUser = (data:any) => {
})
}
-export const updateUser = (id:number, data:any)=> {
+/**
+ * 修改用户
+ *
+ * @param id
+ * @param data
+ */
+export function updateUser(id: number, data: any) {
return request({
url: '/youlai-admin/api/v1/users/' + id,
method: 'put',
@@ -31,7 +52,13 @@ export const updateUser = (id:number, data:any)=> {
})
}
-export const patch = (id:number, data:any) => {
+/**
+ * 选择性修改用户
+ *
+ * @param id
+ * @param data
+ */
+export function updateUserPart(id: number, data: any) {
return request({
url: '/youlai-admin/api/v1/users/' + id,
method: 'patch',
@@ -39,9 +66,14 @@ export const patch = (id:number, data:any) => {
})
}
-export const delUser =(ids:number) =>{
+
+/**
+ * 删除用户
+ * @param ids
+ */
+export function deleteUsers(ids: number) {
return request({
- url: '/youlai-admin/api/v1/users/'+ids,
+ url: '/youlai-admin/api/v1/users/' + ids,
method: 'delete',
})
}
diff --git a/src/components/TreeSelect/index.vue b/src/components/TreeSelect/index.vue
index 11f95a0d..c9090939 100644
--- a/src/components/TreeSelect/index.vue
+++ b/src/components/TreeSelect/index.vue
@@ -2,7 +2,7 @@
-
+
{
@@ -44,24 +44,24 @@ const state = defineProps({
}
}
},
- /* 自动收起 */
+ // 自动收起
accordion: {
type: Boolean,
default: () => {
return false
}
},
- /**当前双向数据绑定的值 */
+ // v-model 绑定的值
modelValue: {
- type: [String, Number],
+ type: Object,
default: ''
},
- /**当前的数据 */
+ // 数据源
options: {
type: Array,
- default: () => []
+ default:[]
},
- /**输入框内部的文字 */
+ // 提示文字
placeholder: {
type: String,
default: ''
@@ -70,8 +70,9 @@ const state = defineProps({
const emit = defineEmits(['update:modelValue']);
-const valueId = computed({
+const modelValue = computed({
get: () => {
+ console.log('heihei',state.modelValue)
return state.modelValue
},
set: (val) => {
@@ -83,7 +84,9 @@ const defaultExpandedKey = ref([]);
function initHandle() {
nextTick(() => {
- const selectedValue = valueId.value;
+ console.log("selectedValue1",modelValue)
+ const selectedValue = modelValue.value;
+ console.log("selectedValue",modelValue.value)
if(selectedValue !== null && typeof (selectedValue) !== "undefined"){
const node = proxy.$refs.selectTree.getNode(selectedValue)
if (node) {
@@ -98,34 +101,39 @@ function initHandle() {
}
function handleNodeClick(node) {
valueTitle.value = node[state.props.label]
- valueId.value = node[state.props.value];
+ modelValue.value = node[state.props.value];
defaultExpandedKey.value = [];
proxy.$refs.treeSelect.blur()
selectFilterData('')
}
+
function selectFilterData(val) {
proxy.$refs.selectTree.filter(val)
}
+
function filterNode(value, data) {
if (!value) return true
return data[state.props['label']].indexOf(value) !== -1
}
+
function clearHandle() {
valueTitle.value = ''
- valueId.value = ''
+ modelValue.value = ''
defaultExpandedKey.value = [];
clearSelected()
}
+
function clearSelected() {
const allNode = document.querySelectorAll('#tree-option .el-tree-node')
allNode.forEach((element) => element.classList.remove('is-current'))
}
onMounted(() => {
+ console.log('hah',modelValue)
initHandle()
})
-watch(valueId, () => {
+watch(modelValue, () => {
initHandle();
})
diff --git a/src/main.ts b/src/main.ts
index 20e31e5d..fef06866 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -15,7 +15,7 @@ import '@/permission'
import Pagination from '@/components/Pagination/index.vue'
-import {getDictItemsByCode} from '@/api/system/dict'
+import {listDictsByCode} from '@/api/system/dict'
const app = createApp(App)
@@ -27,7 +27,7 @@ for (let iconName in ElIconModules) {
}
// 全局方法
-app.config.globalProperties.$getDictItemsByCode = getDictItemsByCode
+app.config.globalProperties.$listDictsByCode = listDictsByCode
app.component('Pagination', Pagination) // 全局组件
.use(store)
.use(router)
diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue
index ea09b9fa..964d5093 100644
--- a/src/views/dashboard/index.vue
+++ b/src/views/dashboard/index.vue
@@ -156,82 +156,46 @@
+
+
+
+
+
+
Mr.
+
+ 后端
+ 前端
+ 运维
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
猴子也能上天
-
- 后端
- 前端
- 运维
-
-
-
-
-
-
-
-
-
-
DaniR
-
- 后端
- 前端
- 运维
-
-
-
-
-
-
-
-
-
-
-
-
Mr.
-
- 后端
- 前端
- 运维
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/views/sms/advert/index.vue b/src/views/sms/advert/index.vue
index 37698bbd..28abd087 100644
--- a/src/views/sms/advert/index.vue
+++ b/src/views/sms/advert/index.vue
@@ -96,7 +96,7 @@
width="700px"
>
{
+ const dataForm = unref(dataFormRef)
+ dataForm.validate((valid: any) => {
if (valid) {
- if (state.formData.id) {
- updateAdvert(state.formData.id as any, state.formData).then(response => {
+ const avertId = state.formData.id
+ if (avertId) {
+ updateAdvert(avertId, state.formData).then(response => {
ElMessage.success('修改成功')
state.dialog.visible = false
handleQuery()
diff --git a/src/views/system/client/index.vue b/src/views/system/client/index.vue
index 57e7c1b1..b187f0ea 100644
--- a/src/views/system/client/index.vue
+++ b/src/views/system/client/index.vue
@@ -263,7 +263,7 @@ onMounted(() => {
handleQuery()
// 全局字典调用
const {proxy}: any = getCurrentInstance();
- proxy.$getDictItemsByCode('gender').then((response: any) => {
+ proxy.$listDictsByCode('gender').then((response: any) => {
console.log('性别字典数据', response.data)
})
})
diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue
index 73359477..81f8e696 100644
--- a/src/views/system/dept/index.vue
+++ b/src/views/system/dept/index.vue
@@ -14,9 +14,7 @@
-
+
-
+
+
import {onMounted, reactive, unref, ref, toRefs} from 'vue'
import {Search, Plus, Edit, Refresh, Delete} from '@element-plus/icons'
-import {listDept, getDept, delDept, updateDept, addDept, getDeptSelectList} from '@/api/system/dept'
+import {listDept, getDept, delDept, updateDept, addDept, listDeptsForSelect} from '@/api/system/dept'
import TreeSelect from '@/components/TreeSelect/Index.vue'
import {ElForm, ElMessage, ElMessageBox} from 'element-plus'
@@ -250,7 +247,6 @@ const queryForm = ref(ElForm)
const formDialog = ref(ElForm)
-
/**
* 删除按钮
* */
@@ -295,7 +291,7 @@ function resetQuery() {
/** 查询部门下拉树结构 */
function getTreeselect() {
- getDeptSelectList().then(response => {
+ listDeptsForSelect().then(response => {
dataMap.deptOptions = response.data
})
}
@@ -369,6 +365,7 @@ async function handleDelete(row: any) {
function dialogshow() {
getTreeselect()
}
+
const {
ids, single,
multiple,
diff --git a/src/views/system/menu/components/Perm.vue b/src/views/system/menu/components/Perm.vue
index 0d8293cd..04636e02 100644
--- a/src/views/system/menu/components/Perm.vue
+++ b/src/views/system/menu/components/Perm.vue
@@ -244,11 +244,11 @@ function handleSelectionChange(selection: any) {
* 字典数据准备
*/
function loadDictData() {
- proxy.$getDictItemsByCode('micro_service').then((response: any) => {
+ proxy.$listDictsByCode('micro_service').then((response: any) => {
state.microServiceOptions = response.data
})
- proxy.$getDictItemsByCode('request_method').then((response: any) => {
+ proxy.$listDictsByCode('request_method').then((response: any) => {
state.requestMethodOptions = response.data
})
}
diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 84506ca0..c370898d 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -1,49 +1,44 @@
-
+
-
-
-
-
-
-
+
+
+
-
+
+
-
+
-
-
-
-
+
+
-
+
+
+
+
@@ -252,23 +219,22 @@
:total="total"
v-model:page="queryParams.page"
v-model:limit="queryParams.limit"
- @pagination="getList"
+ @pagination="handleQuery"
/>
@@ -279,7 +245,7 @@
prop="nickname"
>
@@ -290,9 +256,10 @@
prop="deptId"
>
@@ -304,7 +271,7 @@
prop="mobile"
>
@@ -316,7 +283,7 @@
prop="email"
>
@@ -326,26 +293,21 @@
-
-
- {{ dict.dictLabel }}
-
+
+ 正常
+ 禁用
@@ -355,22 +317,19 @@
-
+
+
+
@@ -379,23 +338,20 @@
:key="item.id"
:label="item.name"
:value="item.id"
- :disabled="item.status === 0"
/>
-
-
@@ -425,29 +381,24 @@