creatUser.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="mainBox">
  3. <div class="layerBox">
  4. <tableTitle :name="tableDivTitle"/>
  5. <div>
  6. <el-radio-group v-model="userType">
  7. <el-radio v-for="option in radioOptions"
  8. :key="option.label"
  9. :label="option.value"
  10. :disabled="isDisabled(option.value)">
  11. {{ option.label }}
  12. </el-radio>
  13. </el-radio-group>
  14. </div>
  15. </div>
  16. <!-- 根据 userType 的值动态显示组件 -->
  17. <user-admin v-if="userType === '10000'" />
  18. <user-investigate v-if="userType === '4'" />
  19. <user-default v-if="userType === '1'" />
  20. <user-enterprise v-if="userType === '3'" />
  21. <user-politician v-if="userType === '2'" />
  22. </div>
  23. </template>
  24. <script>
  25. // 引入组件
  26. import tableTitle from './components/tableTitle';
  27. import userAdmin from './components/userAdmin'; // 引入管理员组件
  28. import userInvestigate from './components/userInvestigate'; // 引入调研员组件
  29. import userDefault from './components/userDefault'; // 引入个人会员组件
  30. import userEnterprise from './components/userEnterprise'; // 引入企业会员组件
  31. import userPolitician from './components/userPolitician'; // 引入政务会员组件
  32. // 引入公用样式
  33. import '@/styles/global.less';
  34. export default {
  35. components: {
  36. tableTitle,
  37. userAdmin, // 注册管理员组件
  38. userInvestigate, // 注册调研员组件
  39. userDefault, // 注册个人会员组件
  40. userEnterprise, // 注册企业会员组件
  41. userPolitician // 注册政务会员组件
  42. },
  43. data() {
  44. return {
  45. tableDivTitle: "选择用户类型",
  46. userType: "10000", // 用户类型
  47. radioOptions: [
  48. // { label: '管理员', value: '10000' },
  49. { label: '调研员', value: '4' },
  50. { label: '个人会员', value: '1' },
  51. { label: '企业会员', value: '3' },
  52. { label: '政务会员', value: '2' }
  53. ]
  54. };
  55. },
  56. methods: {
  57. isDisabled(value) {
  58. // 如果 type_id 存在,则禁用与 userType 不对应的选项
  59. if (this.$route.query.type_id) {
  60. return value !== this.userType;
  61. }
  62. // 如果 type_id 不存在,则允许所有选项
  63. return false;
  64. }
  65. },
  66. mounted() {
  67. // 其他逻辑
  68. if (this.$route.query.type_id != undefined) {
  69. this.userType = String(this.$route.query.type_id);
  70. console.log("编辑用户!");
  71. } else {
  72. console.log("添加用户!");
  73. }
  74. },
  75. };
  76. </script>
  77. <style scoped lang="less">
  78. </style>