addUserDl.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. password.value = '';
  73. }
  74. // 确认
  75. function confirmBtn() {
  76. if (!realName.value) {
  77. uni.showToast({
  78. icon: 'none',
  79. title: '请输入用户名'
  80. })
  81. return;
  82. }
  83. if (!userName.value) {
  84. uni.showToast({
  85. icon: 'none',
  86. title: '请输入手机号'
  87. })
  88. return;
  89. }
  90. if (!password.value) {
  91. uni.showToast({
  92. icon: 'none',
  93. title: '请输入密码'
  94. })
  95. return;
  96. }
  97. getUserGuanliAdd({
  98. userName: userName.value,
  99. realName: realName.value,
  100. password: password.value
  101. }).then(res => {
  102. if (res.data) {
  103. uni.showToast({
  104. icon: 'none',
  105. title: '新增成功'
  106. })
  107. $emit('confirm-btn');
  108. commonPopup.value.close();
  109. realName.value = '';
  110. userName.value = '';
  111. userId.value = null;
  112. password.value = '';
  113. }
  114. })
  115. }
  116. defineExpose({
  117. handleShow,
  118. handleClose
  119. })
  120. </script>
  121. <style>
  122. </style>