zhangwei
2025-08-22 85c54d88f139096614aea4b06f2166cae27729d7
src/views/login/index.vue
@@ -24,7 +24,8 @@
  ElRadioGroup,
  ElRadio,
  ElRow,
  ElTag
  ElTag,
  ElCol
} from "element-plus";
import { useLayout } from "@/layout/hooks/useLayout";
import { useUserStoreHook } from "@/store/modules/user";
@@ -156,78 +157,82 @@
          rules: loginRules,
          size: "large"
        },
        [
          h(Motion, { delay: 150 }, [
            h(
              ElFormItem,
              {
                prop: "exRoleCode",
                label: ""
              },
              [
                // 单选框组 - 纵向排列
                h(
                  ElRadioGroup,
                  {
                    modelValue: secondId.value,
                    "onUpdate:modelValue": val => {
                      secondId.value = val;
                    }
                  },
                  [
                    // 循环渲染单选框 - 根据每项的isManager显示标签
                    state.myEnterpriseList.map(item =>
        {
          default: () => {
            return [
              h(
                ElFormItem,
                { prop: "exRoleCode", label: "" },
                {
                  default: () => {
                    return [
                      h(
                        "el-row",
                        ElRadioGroup,
                        {
                          style: {
                            width: "100%"
                          }
                          modelValue: secondId.value,
                          "onUpdate:modelValue": val => (secondId.value = val)
                        },
                        [
                          h(
                            "el-col",
                            {
                              span: 24
                            },
                            [
                              h(
                                ElRadio,
                                {
                                  key: item.customerUserID,
                                  value: item.customerUserID
                                },
                                [
                                  // 单选框文本
                                  item.enterpriseName,
                                  // 根据当前项的isManager显示标签(放在文本后面)
                                  item.isManger
                                    ? h(
                                        ElTag,
                                        {
                                          type: "primary",
                                          size: "small",
                                          style: {
                                            marginLeft: "8px",
                                            alignSelf: "center"
                                          }
                                        },
                                        "管理员"
                                      )
                                    : null
                                ]
                              )
                            ]
                        // ElRadioGroup 的内容是循环生成的,用函数包裹
                        () =>
                          state.myEnterpriseList.map(item =>
                            h(
                              ElRow,
                              { style: { width: "100%" } },
                              {
                                default: () => {
                                  return [
                                    h(
                                      ElCol,
                                      { span: 24 },
                                      {
                                        default: () => {
                                          return [
                                            h(
                                              ElRadio,
                                              {
                                                key: item.customerUserID,
                                                value: item.customerUserID
                                              },
                                              // ElRadio 的内容是动态的,用函数包裹
                                              () => [
                                                // 文本直接返回(不要嵌套函数)
                                                item.enterpriseName,
                                                item.isManger
                                                  ? h(
                                                      ElTag,
                                                      {
                                                        type: "primary",
                                                        size: "small",
                                                        style: {
                                                          marginLeft: "8px",
                                                          alignSelf: "center"
                                                        }
                                                      },
                                                      // ElTag 的内容是静态文本,直接返回
                                                      {
                                                        default: () => "管理员"
                                                      }
                                                    )
                                                  : null
                                              ]
                                            )
                                          ];
                                        }
                                      }
                                    )
                                  ];
                                }
                              }
                            )
                          )
                        ]
                      )
                    )
                  ]
                )
              ]
            )
          ])
        ]
                    ];
                  }
                }
              )
            ];
          }
        }
      ),
    // jsx 语法 (注意在.vue文件启用jsx语法,需要在script开启lang="tsx")
    closeCallBack: ({ options, args }) => {