diff --git a/src/pages_mine/pages/info/index.vue b/src/pages_mine/pages/info/index.vue index 1437159..36309ab 100644 --- a/src/pages_mine/pages/info/index.vue +++ b/src/pages_mine/pages/info/index.vue @@ -44,8 +44,8 @@ const infoList = computed(() => [ }, { icon: 'calendar', - label: '创建日期', - value: user.value.createTime || '-', + label: '最近登录时间', + value: user.value.loginDate || '-', gradient: 'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)' } ]) diff --git a/src/pages_mine/pages/system/dict/addEdit.vue b/src/pages_mine/pages/system/dict/addEdit.vue index 26d2760..5b9f531 100644 --- a/src/pages_mine/pages/system/dict/addEdit.vue +++ b/src/pages_mine/pages/system/dict/addEdit.vue @@ -21,14 +21,6 @@ inputAlign="right" border="none"> - - - - - @@ -40,8 +32,6 @@ - @@ -52,16 +42,12 @@ import { getDicts } from "@/api/system/dict/data" import { onLoad } from "@dcloudio/uni-app" const { proxy } = getCurrentInstance() -const statusList = ref([]) const title = ref('添加字典类型') -const showStatusPicker = ref(false) -const statusName = ref('') const form = reactive({ dictId: undefined, dictName: undefined, dictType: undefined, - status: '0', remark: undefined }) @@ -75,18 +61,9 @@ const rules = { } onLoad((option) => { - getDicts('sys_normal_disable').then(res => { - statusList.value = [res.data] - }) - if (option.id) { title.value = '修改字典类型' getDetail(option.id) - } else { - // 新增时默认显示状态 - setTimeout(() => { - updateStatusName() - }, 100) } }) @@ -94,25 +71,9 @@ onLoad((option) => { function getDetail(id) { getType(id).then(res => { Object.assign(form, res.data) - updateStatusName() }) } -// 更新状态名称显示 -function updateStatusName() { - if (statusList.value.length > 0 && statusList.value[0].length > 0) { - const item = statusList.value[0].find(v => v.dictValue === form.status) - statusName.value = item ? item.dictLabel : '' - } -} - -// 状态选择确认 -function handleStatusConfirm(e) { - form.status = e.value[0].dictValue - statusName.value = e.value[0].dictLabel - showStatusPicker.value = false -} - // 提交 function submit() { console.log('submit 被调用') diff --git a/src/pages_mine/pages/system/dict/details.vue b/src/pages_mine/pages/system/dict/details.vue index c15b873..64ec3c9 100644 --- a/src/pages_mine/pages/system/dict/details.vue +++ b/src/pages_mine/pages/system/dict/details.vue @@ -36,10 +36,6 @@ 字典类型 {{ detailInfo.dictType }} - - 状态 - {{ statusText }} - 创建时间 {{ detailInfo.createTime }} diff --git a/src/pages_mine/pages/system/dict/list.vue b/src/pages_mine/pages/system/dict/list.vue index ca41cdf..93c255e 100644 --- a/src/pages_mine/pages/system/dict/list.vue +++ b/src/pages_mine/pages/system/dict/list.vue @@ -51,11 +51,6 @@ {{ item.dictName }}({{ item.dictType }}) - - - {{ dictStr(item.status, statusList) }} - - diff --git a/src/pages_mine/pages/system/dictData/addEdit.vue b/src/pages_mine/pages/system/dictData/addEdit.vue index b9a5593..b30e730 100644 --- a/src/pages_mine/pages/system/dictData/addEdit.vue +++ b/src/pages_mine/pages/system/dictData/addEdit.vue @@ -27,7 +27,7 @@ - @@ -39,14 +39,6 @@ - - - - - @@ -58,8 +50,6 @@ - @@ -72,7 +62,6 @@ import { getDicts } from "@/api/system/dict/data" import { onLoad } from "@dcloudio/uni-app" const { proxy } = getCurrentInstance() -const statusList = ref([]) const listClassList = ref([[ { value: 'default', label: '默认' }, { value: 'primary', label: '主要' }, @@ -82,9 +71,7 @@ const listClassList = ref([[ { value: 'danger', label: '危险' } ]]) const title = ref('添加字典数据') -const showStatusPicker = ref(false) const showListClassPicker = ref(false) -const statusName = ref('') const listClassName = ref('') const form = reactive({ @@ -92,9 +79,8 @@ const form = reactive({ dictType: undefined, dictLabel: undefined, dictValue: undefined, - dictSort: '0', + dictSort: 0, listClass: 'default', - status: '0', remark: undefined }) @@ -106,23 +92,28 @@ const rules = { { required: true, message: '数据键值不能为空', trigger: ['blur', 'change'] } ], dictSort: [ - { required: true, message: '显示排序不能为空', trigger: ['blur', 'change'] } + { + required: true, + validator: (rule, value, callback) => { + if (value === undefined || value === null || value === '') { + callback(new Error('显示排序不能为空')) + } else { + callback() + } + }, + trigger: ['blur', 'change'] + } ] } onLoad((option) => { - getDicts('sys_normal_disable').then(res => { - statusList.value = [res.data] - }) - if (option.dictCode) { title.value = '修改字典数据' getDetail(option.dictCode) } else if (option.dictType) { form.dictType = option.dictType - // 新增时默认显示状态和回显样式 + // 新增时默认显示回显样式 setTimeout(() => { - updateStatusName() updateListClassName() }, 100) } @@ -132,19 +123,10 @@ onLoad((option) => { function getDetail(dictCode) { getData(dictCode).then(res => { Object.assign(form, res.data) - updateStatusName() updateListClassName() }) } -// 更新状态名称显示 -function updateStatusName() { - if (statusList.value.length > 0 && statusList.value[0].length > 0) { - const item = statusList.value[0].find(v => v.dictValue === form.status) - statusName.value = item ? item.dictLabel : '' - } -} - // 更新回显样式名称显示 function updateListClassName() { if (listClassList.value.length > 0 && listClassList.value[0].length > 0) { @@ -153,13 +135,6 @@ function updateListClassName() { } } -// 状态选择确认 -function handleStatusConfirm(e) { - form.status = e.value[0].dictValue - statusName.value = e.value[0].dictLabel - showStatusPicker.value = false -} - // 回显样式选择确认 function handleListClassConfirm(e) { form.listClass = e.value[0].value @@ -172,26 +147,21 @@ function submit() { proxy.$refs['uForm'].validate().then(() => { if (form.dictCode) { updateData(form).then(() => { - proxy.$refs['uToast'].show({ - message: '修改成功', complete() { - uni.navigateTo({ url: `/pages_mine/pages/system/dictData/list?dictType=${form.dictType}` }) - } - }) + proxy.$modal.msgSuccess('修改成功') + setTimeout(() => { + uni.navigateBack() + }, 1500) }) } else { addData(form).then(() => { - proxy.$refs['uToast'].show({ - message: '新增成功', complete() { - uni.navigateTo({ url: `/pages_mine/pages/system/dictData/list?dictType=${form.dictType}` }) - } - }) + proxy.$modal.msgSuccess('新增成功') + setTimeout(() => { + uni.navigateBack() + }, 1500) }) } }).catch(() => { - proxy.$refs['uToast'].show({ - type: 'error', - message: '请填写完整信息' - }) + proxy.$modal.msgError('请填写完整信息') }) } diff --git a/src/pages_mine/pages/system/dictData/details.vue b/src/pages_mine/pages/system/dictData/details.vue index 6ecacea..f59e1bb 100644 --- a/src/pages_mine/pages/system/dictData/details.vue +++ b/src/pages_mine/pages/system/dictData/details.vue @@ -48,10 +48,6 @@ 回显样式 {{ listClassText }} - - 状态 - {{ statusText }} - 创建时间 {{ detailInfo.createTime }} diff --git a/src/pages_mine/pages/system/dictData/list.vue b/src/pages_mine/pages/system/dictData/list.vue index 814338a..1ed0d9d 100644 --- a/src/pages_mine/pages/system/dictData/list.vue +++ b/src/pages_mine/pages/system/dictData/list.vue @@ -60,11 +60,6 @@ - - - {{ dictStr(item.status, statusList) }} - - diff --git a/src/pages_mine/pages/system/user/addEdit.vue b/src/pages_mine/pages/system/user/addEdit.vue index 43f836f..d142520 100644 --- a/src/pages_mine/pages/system/user/addEdit.vue +++ b/src/pages_mine/pages/system/user/addEdit.vue @@ -163,6 +163,8 @@ import { ref, reactive, getCurrentInstance, computed } from 'vue' import { getUser, addUser, updateUser } from '@/api/system/user' import { listDept } from '@/api/system/dept' +import { listPost } from '@/api/system/post' +import { listRole } from '@/api/system/role' import { getDicts } from "@/api/system/dict/data" import { onLoad } from "@dcloudio/uni-app" @@ -244,11 +246,10 @@ onLoad((option) => { title.value = '修改用户' getDetail(option.id) } else { - // 新增时获取岗位和角色选项 - getUser().then(res => { - postList.value = [res.posts || []] - roleList.value = [res.roles || []] - }) + title.value = '添加用户' + // 新增时直接获取完整的岗位和角色列表 + loadPostList() + loadRoleList() setTimeout(() => { updateStatusName() updateSexName() @@ -264,21 +265,64 @@ function loadDeptList() { }) } +// 加载岗位列表 +function loadPostList() { + listPost().then(res => { + console.log('单独获取岗位列表:', res) + const listData = res.rows || [] + postList.value = [listData] + }).catch(err => { + console.error('获取岗位列表失败:', err) + }) +} + +// 加载角色列表 +function loadRoleList() { + listRole().then(res => { + console.log('单独获取角色列表:', res) + const listData = res.rows || [] + roleList.value = [listData] + }).catch(err => { + console.error('获取角色列表失败:', err) + }) +} + // 获取详情 function getDetail(id) { getUser(id).then(res => { - Object.assign(form, res.data) - // 获取岗位和角色选项 - postList.value = [res.posts || []] - roleList.value = [res.roles || []] - // 设置已选岗位和角色 - form.postIds = res.postIds || [] - form.roleIds = res.roleIds || [] + console.log('编辑用户-获取详情数据:', res) + const data = res.data || {} + console.log('用户信息:', data.user) + console.log('已选岗位IDs:', data.postIds) + console.log('已选角色IDs:', data.roleIds) + + // 用户数据在 data.user 中 + if (data.user) { + Object.assign(form, data.user) + } + + // 单独获取完整的岗位和角色列表 + loadPostList() + loadRoleList() + + // 设置已选岗位和角色(从 data 根级别获取) + form.postIds = data.postIds || [] + form.roleIds = data.roleIds || [] + + console.log('form.postIds:', form.postIds) + console.log('form.roleIds:', form.roleIds) + updateStatusName() updateSexName() updateDeptName() - updatePostNames() - updateRoleNames() + + // 延迟更新岗位和角色名称,等待列表加载完成 + setTimeout(() => { + updatePostNames() + updateRoleNames() + }, 300) + }).catch(err => { + console.error('获取用户详情失败:', err) }) } diff --git a/src/pages_mine/pages/system/user/details.vue b/src/pages_mine/pages/system/user/details.vue index f35988c..4313d06 100644 --- a/src/pages_mine/pages/system/user/details.vue +++ b/src/pages_mine/pages/system/user/details.vue @@ -13,7 +13,7 @@ - {{ info.nickName }}({{ info.userName }}) + {{ info.user.nickName }}({{ info.user.userName }}) @@ -26,19 +26,19 @@ 用户昵称 - {{ info.nickName || '-' }} + {{ info.user.nickName || '-' }} 用户名称 - {{ info.userName || '-' }} + {{ info.user.userName || '-' }} 手机号码 - {{ info.phonenumber || '-' }} + {{ info.user.phonenumber || '-' }} 邮箱 - {{ info.email || '-' }} + {{ info.user.email || '-' }} 用户性别 @@ -46,26 +46,26 @@ 部门 - {{ info.dept && info.dept.deptName || '-' }} + {{ info.user.deptId && info.user.deptName || '-' }} 状态 - {{ statusStr }} + {{ statusStr }} - + 创建时间 - {{ info.createTime }} + {{ info.user.createTime }} - + 备注 - {{ info.remark }} + {{ info.user.remark }} @@ -84,12 +84,12 @@ const statusList = ref([]) const sexList = ref([]) const statusStr = computed(() => { - const item = statusList.value.find(v => v.dictValue === info.value.status) + const item = statusList.value.find(v => v.dictValue === info.value.user.status) return item ? item.dictLabel : '' }) const sexStr = computed(() => { - const item = sexList.value.find(v => v.dictValue === info.value.sex) + const item = sexList.value.find(v => v.dictValue === info.value.user.sex) return item ? item.dictLabel : '' })