addUserDl.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <uni-popup ref="commonPopup" :animation="false" :is-mask-click="false" mask-background-color="rgba(0, 0, 0, 0.4)">
  3. <view class="phone-common-dialog">
  4. <view class="common-body-box">
  5. <view class="common-title">{{title}}</view>
  6. <view class="common-input-box">
  7. <view class="common-input-row">
  8. <view class="common-input-label"><text class="common-label-require">*</text>姓名:</view>
  9. <input class="common-input" v-model="realName" placeholder="请输入姓名" />
  10. </view>
  11. <view class="common-input-row">
  12. <view class="common-input-label"><text class="common-label-require">*</text>密码:</view>
  13. <input class="common-input" v-model="password" placeholder="请输入密码" />
  14. </view>
  15. <view class="common-input-row">
  16. <view class="common-input-label"><text class="common-label-require">*</text>手机号:</view>
  17. <input class="common-input" v-model="userName" placeholder="请输入手机号" />
  18. </view>
  19. </view>
  20. <view class="common-btn-box">
  21. <view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
  22. <view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </uni-popup>
  27. </template>
  28. <script setup>
  29. import {
  30. ref
  31. } from 'vue';
  32. import {
  33. getUserGuanliAdd
  34. } from "@/api/zizhanghao.js"
  35. const props = defineProps({
  36. title: {
  37. type: String,
  38. default: ''
  39. },
  40. dialogContentClass: {
  41. type: String,
  42. require: true,
  43. default: 'content-center-class'
  44. },
  45. notBtn: {
  46. type: String,
  47. require: true,
  48. default: '取消'
  49. },
  50. okBtn: {
  51. type: String,
  52. require: true,
  53. default: '确认'
  54. },
  55. });
  56. const realName = ref('');
  57. const userName = ref('');
  58. const password = ref('');
  59. const userId = ref(null)
  60. const commonPopup = ref(null); // 索引
  61. const $emit = defineEmits(['confirm-btn'])
  62. // 打开弹窗
  63. function handleShow() {
  64. commonPopup.value.open();
  65. }
  66. // 取消
  67. function handleClose() {
  68. commonPopup.value.close();
  69. realName.value = '';
  70. userName.value = '';
  71. userId.value = null;
  72. }
  73. // 确认
  74. function confirmBtn() {
  75. if (!realName.value) {
  76. uni.showToast({
  77. icon: 'none',
  78. title: '请输入用户名'
  79. })
  80. return;
  81. }
  82. if (!userName.value) {
  83. uni.showToast({
  84. icon: 'none',
  85. title: '请输入手机号'
  86. })
  87. return;
  88. }
  89. if (!password.value) {
  90. uni.showToast({
  91. icon: 'none',
  92. title: '请输入密码'
  93. })
  94. return;
  95. }
  96. getUserGuanliAdd({
  97. userName: userName.value,
  98. realName: realName.value,
  99. password: password.value
  100. }).then(res => {
  101. if (res.data) {
  102. uni.showToast({
  103. icon: 'none',
  104. title: '新增成功'
  105. })
  106. $emit('confirm-btn');
  107. commonPopup.value.close();
  108. realName.value = '';
  109. userName.value = '';
  110. userId.value = null;
  111. }
  112. })
  113. }
  114. defineExpose({
  115. handleShow,
  116. handleClose
  117. })
  118. </script>
  119. <style>
  120. </style>