fix: 自测问题修复。
This commit is contained in:
@@ -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%)'
|
||||
}
|
||||
])
|
||||
|
||||
@@ -21,14 +21,6 @@
|
||||
inputAlign="right" border="none"></u--input>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="状态" prop="statusName" @click="showStatusPicker = true">
|
||||
<u--input v-model="statusName" disabled disabledColor="#ffffff" placeholder="请选择状态"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
<template #right>
|
||||
<u-icon name="arrow-down"></u-icon>
|
||||
</template>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="备注" prop="remark" labelPosition="top">
|
||||
<u--textarea v-model="form.remark" placeholder="请输入备注" border="none" autoHeight inputAlign="right" count
|
||||
maxlength="500" style="padding:18rpx 0;"></u--textarea>
|
||||
@@ -40,8 +32,6 @@
|
||||
</view>
|
||||
</view>
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
<u-picker itemHeight="88" :show="showStatusPicker" :columns="statusList" keyName="dictLabel" @cancel="showStatusPicker = false"
|
||||
@confirm="handleStatusConfirm"></u-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -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 被调用')
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
<text class="item-label">字典类型</text>
|
||||
<text class="item-value">{{ detailInfo.dictType }}</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">状态</text>
|
||||
<text class="item-value" :class="getStatusClass(detailInfo.status)">{{ statusText }}</text>
|
||||
</view>
|
||||
<view class="list-item" v-if="detailInfo.createTime">
|
||||
<text class="item-label">创建时间</text>
|
||||
<text class="item-value">{{ detailInfo.createTime }}</text>
|
||||
|
||||
@@ -51,11 +51,6 @@
|
||||
<text class="card-name">{{ item.dictName }}<text class="card-code" v-if="item.dictType">({{ item.dictType }})</text></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="balance-section">
|
||||
<view class="status-tag" :class="item.status === '0' ? 'status-normal' : 'status-disabled'">
|
||||
{{ dictStr(item.status, statusList) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card-body">
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="显示排序" prop="dictSort" required>
|
||||
<u--input v-model="form.dictSort" type="number" placeholder="请输入显示排序"
|
||||
<u--input v-model.number="form.dictSort" type="digit" placeholder="请输入显示排序"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
</u-form-item>
|
||||
|
||||
@@ -39,14 +39,6 @@
|
||||
</template>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="状态" prop="statusName" @click="showStatusPicker = true">
|
||||
<u--input v-model="statusName" disabled disabledColor="#ffffff" placeholder="请选择状态"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
<template #right>
|
||||
<u-icon name="arrow-down"></u-icon>
|
||||
</template>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="备注" prop="remark" labelPosition="top">
|
||||
<u--textarea v-model="form.remark" placeholder="请输入备注" border="none" autoHeight inputAlign="right" count
|
||||
maxlength="500" style="padding:18rpx 0;"></u--textarea>
|
||||
@@ -58,8 +50,6 @@
|
||||
</view>
|
||||
</view>
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
<u-picker itemHeight="88" :show="showStatusPicker" :columns="statusList" keyName="dictLabel" @cancel="showStatusPicker = false"
|
||||
@confirm="handleStatusConfirm"></u-picker>
|
||||
<u-picker itemHeight="88" :show="showListClassPicker" :columns="listClassList" keyName="label" @cancel="showListClassPicker = false"
|
||||
@confirm="handleListClassConfirm"></u-picker>
|
||||
</view>
|
||||
@@ -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('请填写完整信息')
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -48,10 +48,6 @@
|
||||
<text class="item-label">回显样式</text>
|
||||
<text class="item-value">{{ listClassText }}</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">状态</text>
|
||||
<text class="item-value" :class="getStatusClass(detailInfo.status)">{{ statusText }}</text>
|
||||
</view>
|
||||
<view class="list-item" v-if="detailInfo.createTime">
|
||||
<text class="item-label">创建时间</text>
|
||||
<text class="item-value">{{ detailInfo.createTime }}</text>
|
||||
|
||||
@@ -60,11 +60,6 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="balance-section">
|
||||
<view class="status-tag" :class="item.status === '0' ? 'status-normal' : 'status-disabled'">
|
||||
{{ dictStr(item.status, statusList) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card-body">
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<uni-icons type="person" size="24" color="#ffffff"></uni-icons>
|
||||
</view>
|
||||
<view class="header-info">
|
||||
<text class="card-name">{{ info.nickName }}<text class="card-code" v-if="info.userName">({{ info.userName }})</text></text>
|
||||
<text class="card-name">{{ info.user.nickName }}<text class="card-code" v-if="info.user.userName">({{ info.user.userName }})</text></text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -26,19 +26,19 @@
|
||||
<view class="info-list">
|
||||
<view class="list-item">
|
||||
<text class="item-label">用户昵称</text>
|
||||
<text class="item-value">{{ info.nickName || '-' }}</text>
|
||||
<text class="item-value">{{ info.user.nickName || '-' }}</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">用户名称</text>
|
||||
<text class="item-value">{{ info.userName || '-' }}</text>
|
||||
<text class="item-value">{{ info.user.userName || '-' }}</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">手机号码</text>
|
||||
<text class="item-value">{{ info.phonenumber || '-' }}</text>
|
||||
<text class="item-value">{{ info.user.phonenumber || '-' }}</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">邮箱</text>
|
||||
<text class="item-value">{{ info.email || '-' }}</text>
|
||||
<text class="item-value">{{ info.user.email || '-' }}</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">用户性别</text>
|
||||
@@ -46,26 +46,26 @@
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">部门</text>
|
||||
<text class="item-value">{{ info.dept && info.dept.deptName || '-' }}</text>
|
||||
<text class="item-value">{{ info.user.deptId && info.user.deptName || '-' }}</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="item-label">状态</text>
|
||||
<text class="item-value" :class="getStatusClass(info.status)">{{ statusStr }}</text>
|
||||
<text class="item-value" :class="getStatusClass(info.user.status)">{{ statusStr }}</text>
|
||||
</view>
|
||||
<view class="list-item" v-if="info.createTime">
|
||||
<view class="list-item" v-if="info.user.createTime">
|
||||
<text class="item-label">创建时间</text>
|
||||
<text class="item-value">{{ info.createTime }}</text>
|
||||
<text class="item-value">{{ info.user.createTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="info-section" v-if="info.remark">
|
||||
<view class="info-section" v-if="info.user.remark">
|
||||
<view class="section-title">
|
||||
<view class="title-icon"></view>
|
||||
<text>备注</text>
|
||||
</view>
|
||||
<view class="remark-content">
|
||||
<text>{{ info.remark }}</text>
|
||||
<text>{{ info.user.remark }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -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 : ''
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user