mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
fix: form solts
This commit is contained in:
parent
1bdde35dc9
commit
f841ca11a5
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<Form ref="formRef" :rules="rules" :schema="schema" :labelWidth="80">
|
<Form ref="formRef" :rules="rules" :schema="schema" :labelWidth="80">
|
||||||
<template #sex>
|
<template #sex="form">
|
||||||
<el-radio-group v-model="sexVlue">
|
<el-radio-group v-model="form['sex']">
|
||||||
<el-radio :label="1">{{ t('profile.user.man') }}</el-radio>
|
<el-radio :label="1">{{ t('profile.user.man') }}</el-radio>
|
||||||
<el-radio :label="2">{{ t('profile.user.woman') }}</el-radio>
|
<el-radio :label="2">{{ t('profile.user.woman') }}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
@ -67,7 +67,6 @@ const schema = reactive<FormSchema[]>([
|
|||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
const sexVlue = ref<number>()
|
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
const elForm = unref(formRef)?.getElFormRef()
|
const elForm = unref(formRef)?.getElFormRef()
|
||||||
@ -75,7 +74,6 @@ const submit = () => {
|
|||||||
elForm.validate(async (valid) => {
|
elForm.validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
const data = unref(formRef)?.formModel as UserProfileUpdateReqVO
|
const data = unref(formRef)?.formModel as UserProfileUpdateReqVO
|
||||||
data.sex = sexVlue.value as unknown as number
|
|
||||||
await updateUserProfileApi(data)
|
await updateUserProfileApi(data)
|
||||||
ElMessage.success(t('common.updateSuccess'))
|
ElMessage.success(t('common.updateSuccess'))
|
||||||
await init()
|
await init()
|
||||||
@ -84,7 +82,6 @@ const submit = () => {
|
|||||||
}
|
}
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
const res = await getUserProfileApi()
|
const res = await getUserProfileApi()
|
||||||
sexVlue.value = res.sex
|
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -29,7 +29,6 @@ const dialogTitle = ref('edit') // 弹出层标题
|
|||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
|
|
||||||
// ========== 用户选择 ==========
|
// ========== 用户选择 ==========
|
||||||
const userIds = ref<number[]>([])
|
|
||||||
const userOptions = ref<UserVO[]>([])
|
const userOptions = ref<UserVO[]>([])
|
||||||
const getUserOptions = async () => {
|
const getUserOptions = async () => {
|
||||||
const res = await getListSimpleUsersApi()
|
const res = await getListSimpleUsersApi()
|
||||||
@ -46,7 +45,6 @@ const setDialogTile = (type: string) => {
|
|||||||
// 新增操作
|
// 新增操作
|
||||||
const handleCreate = () => {
|
const handleCreate = () => {
|
||||||
setDialogTile('create')
|
setDialogTile('create')
|
||||||
userIds.value = []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改操作
|
// 修改操作
|
||||||
@ -54,7 +52,6 @@ const handleUpdate = async (row: UserGroupVO) => {
|
|||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await UserGroupApi.getUserGroupApi(row.id)
|
const res = await UserGroupApi.getUserGroupApi(row.id)
|
||||||
userIds.value = res.memberUserIds
|
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +65,6 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as UserGroupVO
|
const data = unref(formRef)?.formModel as UserGroupVO
|
||||||
data.memberUserIds = userIds.value
|
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await UserGroupApi.createUserGroupApi(data)
|
await UserGroupApi.createUserGroupApi(data)
|
||||||
ElMessage.success(t('common.createSuccess'))
|
ElMessage.success(t('common.createSuccess'))
|
||||||
@ -183,8 +179,8 @@ onMounted(async () => {
|
|||||||
:rules="rules"
|
:rules="rules"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
>
|
>
|
||||||
<template #memberUserIds>
|
<template #memberUserIds="form">
|
||||||
<el-select v-model="userIds" multiple>
|
<el-select v-model="form['memberUserIds']" multiple>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in userOptions"
|
v-for="item in userOptions"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
|
@ -93,8 +93,8 @@
|
|||||||
:rules="rules"
|
:rules="rules"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
>
|
>
|
||||||
<template #cronExpression>
|
<template #cronExpression="form">
|
||||||
<Crontab v-model="cronExpression" :shortcuts="shortcuts" />
|
<Crontab v-model="form['cronExpression']" :shortcuts="shortcuts" />
|
||||||
</template>
|
</template>
|
||||||
</Form>
|
</Form>
|
||||||
<!-- 对话框(详情) -->
|
<!-- 对话框(详情) -->
|
||||||
@ -162,7 +162,6 @@ const dialogVisible = ref(false) // 是否显示弹出层
|
|||||||
const dialogTitle = ref('edit') // 弹出层标题
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
const detailRef = ref() // 详情 Ref
|
const detailRef = ref() // 详情 Ref
|
||||||
const cronExpression = ref('')
|
|
||||||
const nextTimes = ref([])
|
const nextTimes = ref([])
|
||||||
const shortcuts = ref([
|
const shortcuts = ref([
|
||||||
{
|
{
|
||||||
@ -179,7 +178,6 @@ const setDialogTile = (type: string) => {
|
|||||||
|
|
||||||
// 新增操作
|
// 新增操作
|
||||||
const handleCreate = () => {
|
const handleCreate = () => {
|
||||||
cronExpression.value = ''
|
|
||||||
setDialogTile('create')
|
setDialogTile('create')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +191,6 @@ const handleUpdate = async (rowId: number) => {
|
|||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await JobApi.getJobApi(rowId)
|
const res = await JobApi.getJobApi(rowId)
|
||||||
cronExpression.value = res.cronExpression
|
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +302,6 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as JobApi.JobVO
|
const data = unref(formRef)?.formModel as JobApi.JobVO
|
||||||
data.cronExpression = cronExpression.value
|
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await JobApi.createJobApi(data)
|
await JobApi.createJobApi(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
@ -38,20 +38,19 @@
|
|||||||
<!-- 添加或修改菜单对话框 -->
|
<!-- 添加或修改菜单对话框 -->
|
||||||
<XModal id="deptModel" v-model="dialogVisible" :title="dialogTitle">
|
<XModal id="deptModel" v-model="dialogVisible" :title="dialogTitle">
|
||||||
<!-- 对话框(添加 / 修改) -->
|
<!-- 对话框(添加 / 修改) -->
|
||||||
<!-- 操作工具栏 -->
|
|
||||||
<Form ref="formRef" :schema="allSchemas.formSchema" :rules="rules">
|
<Form ref="formRef" :schema="allSchemas.formSchema" :rules="rules">
|
||||||
<template #parentId>
|
<template #parentId="form">
|
||||||
<el-tree-select
|
<el-tree-select
|
||||||
node-key="id"
|
node-key="id"
|
||||||
v-model="deptParentId"
|
v-model="form['parentId']"
|
||||||
:props="defaultProps"
|
:props="defaultProps"
|
||||||
:data="deptOptions"
|
:data="deptOptions"
|
||||||
:default-expanded-keys="[100]"
|
:default-expanded-keys="[100]"
|
||||||
check-strictly
|
check-strictly
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #leaderUserId>
|
<template #leaderUserId="form">
|
||||||
<el-select v-model="leaderUserId">
|
<el-select v-model="form['leaderUserId']">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in userOption"
|
v-for="item in userOption"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@ -105,8 +104,6 @@ const dialogVisible = ref(false) // 是否显示弹出层
|
|||||||
const dialogTitle = ref('edit') // 弹出层标题
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
const actionType = ref('') // 操作按钮的类型
|
const actionType = ref('') // 操作按钮的类型
|
||||||
const actionLoading = ref(false) // 遮罩层
|
const actionLoading = ref(false) // 遮罩层
|
||||||
const deptParentId = ref(0) // 上级ID
|
|
||||||
const leaderUserId = ref()
|
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
const deptOptions = ref() // 树形结构
|
const deptOptions = ref() // 树形结构
|
||||||
const userOption = ref<UserVO[]>([])
|
const userOption = ref<UserVO[]>([])
|
||||||
@ -154,8 +151,6 @@ const setDialogTile = (type: string) => {
|
|||||||
|
|
||||||
// 新增操作
|
// 新增操作
|
||||||
const handleCreate = async () => {
|
const handleCreate = async () => {
|
||||||
deptParentId.value = 0
|
|
||||||
leaderUserId.value = null
|
|
||||||
setDialogTile('create')
|
setDialogTile('create')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,8 +159,6 @@ const handleUpdate = async (rowId: number) => {
|
|||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await DeptApi.getDeptApi(rowId)
|
const res = await DeptApi.getDeptApi(rowId)
|
||||||
deptParentId.value = res.parentId
|
|
||||||
leaderUserId.value = res.leaderUserId
|
|
||||||
await nextTick()
|
await nextTick()
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
@ -180,8 +173,6 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as DeptApi.DeptVO
|
const data = unref(formRef)?.formModel as DeptApi.DeptVO
|
||||||
data.parentId = deptParentId.value
|
|
||||||
data.leaderUserId = leaderUserId.value
|
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await DeptApi.createDeptApi(data)
|
await DeptApi.createDeptApi(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
@ -62,8 +62,8 @@
|
|||||||
:schema="allSchemas.formSchema"
|
:schema="allSchemas.formSchema"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
>
|
>
|
||||||
<template #logo>
|
<template #logo="form">
|
||||||
<UploadImg :imgs="uploadLogo" :limit="1" />
|
<UploadImg :imgs="form['logo']" :limit="1" />
|
||||||
</template>
|
</template>
|
||||||
</Form>
|
</Form>
|
||||||
<!-- 表单:详情 -->
|
<!-- 表单:详情 -->
|
||||||
@ -164,7 +164,6 @@ const actionType = ref('') // 操作按钮的类型
|
|||||||
const actionLoading = ref(false) // 按钮 Loading
|
const actionLoading = ref(false) // 按钮 Loading
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
const detailRef = ref() // 详情 Ref
|
const detailRef = ref() // 详情 Ref
|
||||||
const uploadLogo = ref('')
|
|
||||||
// 设置标题
|
// 设置标题
|
||||||
const setDialogTile = (type: string) => {
|
const setDialogTile = (type: string) => {
|
||||||
dialogTitle.value = t('action.' + type)
|
dialogTitle.value = t('action.' + type)
|
||||||
@ -174,7 +173,6 @@ const setDialogTile = (type: string) => {
|
|||||||
|
|
||||||
// 新增操作
|
// 新增操作
|
||||||
const handleCreate = () => {
|
const handleCreate = () => {
|
||||||
uploadLogo.value = ''
|
|
||||||
setDialogTile('create')
|
setDialogTile('create')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +181,6 @@ const handleUpdate = async (rowId: number) => {
|
|||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await ClientApi.getOAuth2ClientApi(rowId)
|
const res = await ClientApi.getOAuth2ClientApi(rowId)
|
||||||
uploadLogo.value = res.logo
|
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +206,6 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as ClientApi.OAuth2ClientVO
|
const data = unref(formRef)?.formModel as ClientApi.OAuth2ClientVO
|
||||||
data.logo = uploadLogo.value
|
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await ClientApi.createOAuth2ClientApi(data)
|
await ClientApi.createOAuth2ClientApi(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
@ -64,8 +64,8 @@
|
|||||||
:rules="rules"
|
:rules="rules"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
>
|
>
|
||||||
<template #tags>
|
<template #tags="form">
|
||||||
<el-select v-model="tags" multiple placeholder="请选择">
|
<el-select v-model="form['tags']" multiple placeholder="请选择">
|
||||||
<el-option v-for="item in tagsOptions" :key="item" :label="item" :value="item" />
|
<el-option v-for="item in tagsOptions" :key="item" :label="item" :value="item" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@ -130,7 +130,6 @@ const dialogVisible = ref(false) // 是否显示弹出层
|
|||||||
const dialogTitle = ref('edit') // 弹出层标题
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
const detailData = ref() // 详情 Ref
|
const detailData = ref() // 详情 Ref
|
||||||
const tags = ref()
|
|
||||||
|
|
||||||
// 获取标签
|
// 获取标签
|
||||||
const tagsOptions = ref()
|
const tagsOptions = ref()
|
||||||
@ -148,7 +147,6 @@ const setDialogTile = (type: string) => {
|
|||||||
|
|
||||||
// 新增操作
|
// 新增操作
|
||||||
const handleCreate = () => {
|
const handleCreate = () => {
|
||||||
tags.value = null
|
|
||||||
setDialogTile('create')
|
setDialogTile('create')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +160,6 @@ const handleUpdate = async (rowId: number) => {
|
|||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await SensitiveWordApi.getSensitiveWordApi(rowId)
|
const res = await SensitiveWordApi.getSensitiveWordApi(rowId)
|
||||||
tags.value = res.tags
|
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +185,6 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as SensitiveWordApi.SensitiveWordVO
|
const data = unref(formRef)?.formModel as SensitiveWordApi.SensitiveWordVO
|
||||||
data.tags = tags.value
|
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await SensitiveWordApi.createSensitiveWordApi(data)
|
await SensitiveWordApi.createSensitiveWordApi(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
@ -155,7 +155,7 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as TenantPackageApi.TenantPackageVO
|
const data = unref(formRef)?.formModel as TenantPackageApi.TenantPackageVO
|
||||||
data.menuIds = treeRef.value!.getCheckedKeys(false) as string[]
|
data.menuIds = treeRef.value!.getCheckedKeys(false) as number[]
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await TenantPackageApi.createTenantPackageTypeApi(data)
|
await TenantPackageApi.createTenantPackageTypeApi(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
@ -130,17 +130,17 @@
|
|||||||
:schema="allSchemas.formSchema"
|
:schema="allSchemas.formSchema"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
>
|
>
|
||||||
<template #deptId>
|
<template #deptId="form">
|
||||||
<el-tree-select
|
<el-tree-select
|
||||||
node-key="id"
|
node-key="id"
|
||||||
v-model="deptId"
|
v-model="form['deptId']"
|
||||||
:props="defaultProps"
|
:props="defaultProps"
|
||||||
:data="deptOptions"
|
:data="deptOptions"
|
||||||
check-strictly
|
check-strictly
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #postIds>
|
<template #postIds="form">
|
||||||
<el-select v-model="postIds" multiple :placeholder="t('common.selectText')">
|
<el-select v-model="form['postIds']" multiple :placeholder="t('common.selectText')">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in postOptions"
|
v-for="item in postOptions"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@ -354,8 +354,6 @@ const actionType = ref('') // 操作按钮的类型
|
|||||||
const dialogVisible = ref(false) // 是否显示弹出层
|
const dialogVisible = ref(false) // 是否显示弹出层
|
||||||
const dialogTitle = ref('edit') // 弹出层标题
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
const deptId = ref() // 部门ID
|
|
||||||
const postIds = ref<string[]>([]) // 岗位ID
|
|
||||||
const postOptions = ref<PostVO[]>([]) //岗位列表
|
const postOptions = ref<PostVO[]>([]) //岗位列表
|
||||||
|
|
||||||
// 获取岗位列表
|
// 获取岗位列表
|
||||||
@ -374,8 +372,6 @@ const setDialogTile = async (type: string) => {
|
|||||||
const handleCreate = async () => {
|
const handleCreate = async () => {
|
||||||
setDialogTile('create')
|
setDialogTile('create')
|
||||||
// 重置表单
|
// 重置表单
|
||||||
deptId.value = null
|
|
||||||
postIds.value = []
|
|
||||||
await nextTick()
|
await nextTick()
|
||||||
if (allSchemas.formSchema[0].field !== 'username') {
|
if (allSchemas.formSchema[0].field !== 'username') {
|
||||||
unref(formRef)?.addSchema(
|
unref(formRef)?.addSchema(
|
||||||
@ -405,8 +401,6 @@ const handleUpdate = async (rowId: number) => {
|
|||||||
unref(formRef)?.delSchema('password')
|
unref(formRef)?.delSchema('password')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await UserApi.getUserApi(rowId)
|
const res = await UserApi.getUserApi(rowId)
|
||||||
deptId.value = res.deptId
|
|
||||||
postIds.value = res.postIds
|
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
const detailData = ref()
|
const detailData = ref()
|
||||||
@ -428,8 +422,6 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as UserApi.UserVO
|
const data = unref(formRef)?.formModel as UserApi.UserVO
|
||||||
data.deptId = deptId.value
|
|
||||||
data.postIds = postIds.value
|
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await UserApi.createUserApi(data)
|
await UserApi.createUserApi(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
@ -10,6 +10,7 @@ export const rules = reactive({
|
|||||||
username: [required],
|
username: [required],
|
||||||
nickname: [required],
|
nickname: [required],
|
||||||
email: [required],
|
email: [required],
|
||||||
|
postIds: [required],
|
||||||
status: [required],
|
status: [required],
|
||||||
mobile: [
|
mobile: [
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user