Commit f841ca11a5d047f43a9b031fe003756f72a6bca9

Authored by xingyu4j
1 parent 1bdde35d

fix: form solts

yudao-ui-admin-vue3/src/views/Profile/components/BasicInfo.vue
1 1 <template>
2 2 <Form ref="formRef" :rules="rules" :schema="schema" :labelWidth="80">
3   - <template #sex>
4   - <el-radio-group v-model="sexVlue">
  3 + <template #sex="form">
  4 + <el-radio-group v-model="form['sex']">
5 5 <el-radio :label="1">{{ t('profile.user.man') }}</el-radio>
6 6 <el-radio :label="2">{{ t('profile.user.woman') }}</el-radio>
7 7 </el-radio-group>
... ... @@ -67,7 +67,6 @@ const schema = reactive&lt;FormSchema[]&gt;([
67 67 value: 0
68 68 }
69 69 ])
70   -const sexVlue = ref<number>()
71 70 const formRef = ref<FormExpose>() // 表单 Ref
72 71 const submit = () => {
73 72 const elForm = unref(formRef)?.getElFormRef()
... ... @@ -75,7 +74,6 @@ const submit = () =&gt; {
75 74 elForm.validate(async (valid) => {
76 75 if (valid) {
77 76 const data = unref(formRef)?.formModel as UserProfileUpdateReqVO
78   - data.sex = sexVlue.value as unknown as number
79 77 await updateUserProfileApi(data)
80 78 ElMessage.success(t('common.updateSuccess'))
81 79 await init()
... ... @@ -84,7 +82,6 @@ const submit = () =&gt; {
84 82 }
85 83 const init = async () => {
86 84 const res = await getUserProfileApi()
87   - sexVlue.value = res.sex
88 85 unref(formRef)?.setValues(res)
89 86 }
90 87 onMounted(async () => {
... ...
yudao-ui-admin-vue3/src/views/bpm/group/index.vue
... ... @@ -29,7 +29,6 @@ const dialogTitle = ref(&#39;edit&#39;) // 弹出层标题
29 29 const formRef = ref<FormExpose>() // 表单 Ref
30 30  
31 31 // ========== 用户选择 ==========
32   -const userIds = ref<number[]>([])
33 32 const userOptions = ref<UserVO[]>([])
34 33 const getUserOptions = async () => {
35 34 const res = await getListSimpleUsersApi()
... ... @@ -46,7 +45,6 @@ const setDialogTile = (type: string) =&gt; {
46 45 // 新增操作
47 46 const handleCreate = () => {
48 47 setDialogTile('create')
49   - userIds.value = []
50 48 }
51 49  
52 50 // 修改操作
... ... @@ -54,7 +52,6 @@ const handleUpdate = async (row: UserGroupVO) =&gt; {
54 52 setDialogTile('update')
55 53 // 设置数据
56 54 const res = await UserGroupApi.getUserGroupApi(row.id)
57   - userIds.value = res.memberUserIds
58 55 unref(formRef)?.setValues(res)
59 56 }
60 57  
... ... @@ -68,7 +65,6 @@ const submitForm = async () =&gt; {
68 65 // 提交请求
69 66 try {
70 67 const data = unref(formRef)?.formModel as UserGroupVO
71   - data.memberUserIds = userIds.value
72 68 if (actionType.value === 'create') {
73 69 await UserGroupApi.createUserGroupApi(data)
74 70 ElMessage.success(t('common.createSuccess'))
... ... @@ -183,8 +179,8 @@ onMounted(async () =&gt; {
183 179 :rules="rules"
184 180 ref="formRef"
185 181 >
186   - <template #memberUserIds>
187   - <el-select v-model="userIds" multiple>
  182 + <template #memberUserIds="form">
  183 + <el-select v-model="form['memberUserIds']" multiple>
188 184 <el-option
189 185 v-for="item in userOptions"
190 186 :key="item.id"
... ...
yudao-ui-admin-vue3/src/views/infra/job/index.vue
... ... @@ -93,8 +93,8 @@
93 93 :rules="rules"
94 94 ref="formRef"
95 95 >
96   - <template #cronExpression>
97   - <Crontab v-model="cronExpression" :shortcuts="shortcuts" />
  96 + <template #cronExpression="form">
  97 + <Crontab v-model="form['cronExpression']" :shortcuts="shortcuts" />
98 98 </template>
99 99 </Form>
100 100 <!-- 对话框(详情) -->
... ... @@ -162,7 +162,6 @@ const dialogVisible = ref(false) // 是否显示弹出层
162 162 const dialogTitle = ref('edit') // 弹出层标题
163 163 const formRef = ref<FormExpose>() // 表单 Ref
164 164 const detailRef = ref() // 详情 Ref
165   -const cronExpression = ref('')
166 165 const nextTimes = ref([])
167 166 const shortcuts = ref([
168 167 {
... ... @@ -179,7 +178,6 @@ const setDialogTile = (type: string) =&gt; {
179 178  
180 179 // 新增操作
181 180 const handleCreate = () => {
182   - cronExpression.value = ''
183 181 setDialogTile('create')
184 182 }
185 183  
... ... @@ -193,7 +191,6 @@ const handleUpdate = async (rowId: number) =&gt; {
193 191 setDialogTile('update')
194 192 // 设置数据
195 193 const res = await JobApi.getJobApi(rowId)
196   - cronExpression.value = res.cronExpression
197 194 unref(formRef)?.setValues(res)
198 195 }
199 196  
... ... @@ -305,7 +302,6 @@ const submitForm = async () =&gt; {
305 302 // 提交请求
306 303 try {
307 304 const data = unref(formRef)?.formModel as JobApi.JobVO
308   - data.cronExpression = cronExpression.value
309 305 if (actionType.value === 'create') {
310 306 await JobApi.createJobApi(data)
311 307 message.success(t('common.createSuccess'))
... ...
yudao-ui-admin-vue3/src/views/system/dept/index.vue
... ... @@ -38,20 +38,19 @@
38 38 <!-- 添加或修改菜单对话框 -->
39 39 <XModal id="deptModel" v-model="dialogVisible" :title="dialogTitle">
40 40 <!-- 对话框(添加 / 修改) -->
41   - <!-- 操作工具栏 -->
42 41 <Form ref="formRef" :schema="allSchemas.formSchema" :rules="rules">
43   - <template #parentId>
  42 + <template #parentId="form">
44 43 <el-tree-select
45 44 node-key="id"
46   - v-model="deptParentId"
  45 + v-model="form['parentId']"
47 46 :props="defaultProps"
48 47 :data="deptOptions"
49 48 :default-expanded-keys="[100]"
50 49 check-strictly
51 50 />
52 51 </template>
53   - <template #leaderUserId>
54   - <el-select v-model="leaderUserId">
  52 + <template #leaderUserId="form">
  53 + <el-select v-model="form['leaderUserId']">
55 54 <el-option
56 55 v-for="item in userOption"
57 56 :key="item.id"
... ... @@ -105,8 +104,6 @@ const dialogVisible = ref(false) // 是否显示弹出层
105 104 const dialogTitle = ref('edit') // 弹出层标题
106 105 const actionType = ref('') // 操作按钮的类型
107 106 const actionLoading = ref(false) // 遮罩层
108   -const deptParentId = ref(0) // 上级ID
109   -const leaderUserId = ref()
110 107 const formRef = ref<FormExpose>() // 表单 Ref
111 108 const deptOptions = ref() // 树形结构
112 109 const userOption = ref<UserVO[]>([])
... ... @@ -154,8 +151,6 @@ const setDialogTile = (type: string) =&gt; {
154 151  
155 152 // 新增操作
156 153 const handleCreate = async () => {
157   - deptParentId.value = 0
158   - leaderUserId.value = null
159 154 setDialogTile('create')
160 155 }
161 156  
... ... @@ -164,8 +159,6 @@ const handleUpdate = async (rowId: number) =&gt; {
164 159 setDialogTile('update')
165 160 // 设置数据
166 161 const res = await DeptApi.getDeptApi(rowId)
167   - deptParentId.value = res.parentId
168   - leaderUserId.value = res.leaderUserId
169 162 await nextTick()
170 163 unref(formRef)?.setValues(res)
171 164 }
... ... @@ -180,8 +173,6 @@ const submitForm = async () =&gt; {
180 173 // 提交请求
181 174 try {
182 175 const data = unref(formRef)?.formModel as DeptApi.DeptVO
183   - data.parentId = deptParentId.value
184   - data.leaderUserId = leaderUserId.value
185 176 if (actionType.value === 'create') {
186 177 await DeptApi.createDeptApi(data)
187 178 message.success(t('common.createSuccess'))
... ...
yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue
... ... @@ -62,8 +62,8 @@
62 62 :schema="allSchemas.formSchema"
63 63 :rules="rules"
64 64 >
65   - <template #logo>
66   - <UploadImg :imgs="uploadLogo" :limit="1" />
  65 + <template #logo="form">
  66 + <UploadImg :imgs="form['logo']" :limit="1" />
67 67 </template>
68 68 </Form>
69 69 <!-- 表单:详情 -->
... ... @@ -164,7 +164,6 @@ const actionType = ref(&#39;&#39;) // 操作按钮的类型
164 164 const actionLoading = ref(false) // 按钮 Loading
165 165 const formRef = ref<FormExpose>() // 表单 Ref
166 166 const detailRef = ref() // 详情 Ref
167   -const uploadLogo = ref('')
168 167 // 设置标题
169 168 const setDialogTile = (type: string) => {
170 169 dialogTitle.value = t('action.' + type)
... ... @@ -174,7 +173,6 @@ const setDialogTile = (type: string) =&gt; {
174 173  
175 174 // 新增操作
176 175 const handleCreate = () => {
177   - uploadLogo.value = ''
178 176 setDialogTile('create')
179 177 }
180 178  
... ... @@ -183,7 +181,6 @@ const handleUpdate = async (rowId: number) =&gt; {
183 181 setDialogTile('update')
184 182 // 设置数据
185 183 const res = await ClientApi.getOAuth2ClientApi(rowId)
186   - uploadLogo.value = res.logo
187 184 unref(formRef)?.setValues(res)
188 185 }
189 186  
... ... @@ -209,7 +206,6 @@ const submitForm = async () =&gt; {
209 206 // 提交请求
210 207 try {
211 208 const data = unref(formRef)?.formModel as ClientApi.OAuth2ClientVO
212   - data.logo = uploadLogo.value
213 209 if (actionType.value === 'create') {
214 210 await ClientApi.createOAuth2ClientApi(data)
215 211 message.success(t('common.createSuccess'))
... ...
yudao-ui-admin-vue3/src/views/system/sensitiveWord/index.vue
... ... @@ -64,8 +64,8 @@
64 64 :rules="rules"
65 65 ref="formRef"
66 66 >
67   - <template #tags>
68   - <el-select v-model="tags" multiple placeholder="请选择">
  67 + <template #tags="form">
  68 + <el-select v-model="form['tags']" multiple placeholder="请选择">
69 69 <el-option v-for="item in tagsOptions" :key="item" :label="item" :value="item" />
70 70 </el-select>
71 71 </template>
... ... @@ -130,7 +130,6 @@ const dialogVisible = ref(false) // 是否显示弹出层
130 130 const dialogTitle = ref('edit') // 弹出层标题
131 131 const formRef = ref<FormExpose>() // 表单 Ref
132 132 const detailData = ref() // 详情 Ref
133   -const tags = ref()
134 133  
135 134 // 获取标签
136 135 const tagsOptions = ref()
... ... @@ -148,7 +147,6 @@ const setDialogTile = (type: string) =&gt; {
148 147  
149 148 // 新增操作
150 149 const handleCreate = () => {
151   - tags.value = null
152 150 setDialogTile('create')
153 151 }
154 152  
... ... @@ -162,7 +160,6 @@ const handleUpdate = async (rowId: number) =&gt; {
162 160 setDialogTile('update')
163 161 // 设置数据
164 162 const res = await SensitiveWordApi.getSensitiveWordApi(rowId)
165   - tags.value = res.tags
166 163 unref(formRef)?.setValues(res)
167 164 }
168 165  
... ... @@ -188,7 +185,6 @@ const submitForm = async () =&gt; {
188 185 // 提交请求
189 186 try {
190 187 const data = unref(formRef)?.formModel as SensitiveWordApi.SensitiveWordVO
191   - data.tags = tags.value
192 188 if (actionType.value === 'create') {
193 189 await SensitiveWordApi.createSensitiveWordApi(data)
194 190 message.success(t('common.createSuccess'))
... ...
yudao-ui-admin-vue3/src/views/system/tenantPackage/index.vue
... ... @@ -155,7 +155,7 @@ const submitForm = async () =&gt; {
155 155 // 提交请求
156 156 try {
157 157 const data = unref(formRef)?.formModel as TenantPackageApi.TenantPackageVO
158   - data.menuIds = treeRef.value!.getCheckedKeys(false) as string[]
  158 + data.menuIds = treeRef.value!.getCheckedKeys(false) as number[]
159 159 if (actionType.value === 'create') {
160 160 await TenantPackageApi.createTenantPackageTypeApi(data)
161 161 message.success(t('common.createSuccess'))
... ...
yudao-ui-admin-vue3/src/views/system/user/index.vue
... ... @@ -130,17 +130,17 @@
130 130 :schema="allSchemas.formSchema"
131 131 ref="formRef"
132 132 >
133   - <template #deptId>
  133 + <template #deptId="form">
134 134 <el-tree-select
135 135 node-key="id"
136   - v-model="deptId"
  136 + v-model="form['deptId']"
137 137 :props="defaultProps"
138 138 :data="deptOptions"
139 139 check-strictly
140 140 />
141 141 </template>
142   - <template #postIds>
143   - <el-select v-model="postIds" multiple :placeholder="t('common.selectText')">
  142 + <template #postIds="form">
  143 + <el-select v-model="form['postIds']" multiple :placeholder="t('common.selectText')">
144 144 <el-option
145 145 v-for="item in postOptions"
146 146 :key="item.id"
... ... @@ -354,8 +354,6 @@ const actionType = ref(&#39;&#39;) // 操作按钮的类型
354 354 const dialogVisible = ref(false) // 是否显示弹出层
355 355 const dialogTitle = ref('edit') // 弹出层标题
356 356 const formRef = ref<FormExpose>() // 表单 Ref
357   -const deptId = ref() // 部门ID
358   -const postIds = ref<string[]>([]) // 岗位ID
359 357 const postOptions = ref<PostVO[]>([]) //岗位列表
360 358  
361 359 // 获取岗位列表
... ... @@ -374,8 +372,6 @@ const setDialogTile = async (type: string) =&gt; {
374 372 const handleCreate = async () => {
375 373 setDialogTile('create')
376 374 // 重置表单
377   - deptId.value = null
378   - postIds.value = []
379 375 await nextTick()
380 376 if (allSchemas.formSchema[0].field !== 'username') {
381 377 unref(formRef)?.addSchema(
... ... @@ -405,8 +401,6 @@ const handleUpdate = async (rowId: number) =&gt; {
405 401 unref(formRef)?.delSchema('password')
406 402 // 设置数据
407 403 const res = await UserApi.getUserApi(rowId)
408   - deptId.value = res.deptId
409   - postIds.value = res.postIds
410 404 unref(formRef)?.setValues(res)
411 405 }
412 406 const detailData = ref()
... ... @@ -428,8 +422,6 @@ const submitForm = async () =&gt; {
428 422 // 提交请求
429 423 try {
430 424 const data = unref(formRef)?.formModel as UserApi.UserVO
431   - data.deptId = deptId.value
432   - data.postIds = postIds.value
433 425 if (actionType.value === 'create') {
434 426 await UserApi.createUserApi(data)
435 427 message.success(t('common.createSuccess'))
... ...
yudao-ui-admin-vue3/src/views/system/user/user.data.ts
... ... @@ -10,6 +10,7 @@ export const rules = reactive({
10 10 username: [required],
11 11 nickname: [required],
12 12 email: [required],
  13 + postIds: [required],
13 14 status: [required],
14 15 mobile: [
15 16 {
... ...