addUserDl.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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-content" :class="dialogContentClass">
  7. <view class="form-label-input">
  8. <view class="phone-form-label"><text class="form-label-require"></text>姓名</view>
  9. <input v-model="realName" placeholder="请输入姓名" />
  10. </view>
  11. <view class="form-label-input">
  12. <view class="phone-form-label"><text class="form-label-require"></text>手机号</view>
  13. <input v-model="userName" placeholder="请输入手机号" />
  14. </view>
  15. <view class="form-label-input">
  16. <view class="phone-form-label"><text class="form-label-require"></text>密码</view>
  17. <input v-model="password" 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. }
  70. // 确认
  71. function confirmBtn() {
  72. if (!realName.value) {
  73. uni.showToast({
  74. icon: 'none',
  75. title: '请输入用户名'
  76. })
  77. return;
  78. }
  79. if (!userName.value) {
  80. uni.showToast({
  81. icon: 'none',
  82. title: '请输入手机号'
  83. })
  84. return;
  85. }
  86. if (!password.value) {
  87. uni.showToast({
  88. icon: 'none',
  89. title: '请输入密码'
  90. })
  91. return;
  92. }
  93. getUserGuanliAdd({
  94. userName: userName.value,
  95. realName: realName.value,
  96. password: password.value
  97. }).then(res => {
  98. if (res.data) {
  99. uni.showToast({
  100. icon: 'none',
  101. title: '新增成功'
  102. })
  103. $emit('confirm-btn');
  104. commonPopup.value.close();
  105. }
  106. })
  107. }
  108. defineExpose({
  109. handleShow,
  110. handleClose
  111. })
  112. </script>
  113. <style>
  114. </style>