| | |
| | | const userId = row.userId || ids.value
|
| | | getUser(userId).then(response => {
|
| | | form.value = response.data
|
| | | form.value.deptId = getMatchedDeptId(
|
| | | response.deptId ?? response.data?.deptId ?? response.data?.dept?.id
|
| | | )
|
| | | postOptions.value = response.posts
|
| | | roleOptions.value = response.roles
|
| | | form.value.postIds = response.postIds
|
| | |
| | | })
|
| | | }
|
| | |
|
| | | function getMatchedDeptId(rawDeptId) {
|
| | | if (rawDeptId === undefined || rawDeptId === null || !Array.isArray(enabledDeptOptions.value)) {
|
| | | return rawDeptId
|
| | | }
|
| | | const target = String(rawDeptId)
|
| | | const stack = [...enabledDeptOptions.value]
|
| | | while (stack.length) {
|
| | | const node = stack.shift()
|
| | | if (!node) {
|
| | | continue
|
| | | }
|
| | | if (String(node.id) === target) {
|
| | | return node.id
|
| | | }
|
| | | if (Array.isArray(node.children) && node.children.length) {
|
| | | stack.push(...node.children)
|
| | | }
|
| | | }
|
| | | return rawDeptId
|
| | | }
|
| | |
|
| | | /** 提交按钮 */
|
| | | function submitForm() {
|
| | | proxy.$refs["userRef"].validate(valid => {
|