addKh.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
  3. <view class="admin-kehu-info">
  4. <view class="icon-title-navBar-box">
  5. <view @click="goback2" class="nav-bar-icon"></view>
  6. <text class="nav-bar-title">新增家政客户</text>
  7. </view>
  8. <view>
  9. <view class="form-label-input">
  10. <view class="phone-form-label"><text class="form-label-require">*</text>姓名</view>
  11. <uni-easyinput v-model="formData.realName"
  12. placeholder="请输入姓名" />
  13. </view>
  14. <view class="form-label-input">
  15. <view class="phone-form-label"><text class="form-label-require">*</text>手机号</view>
  16. <uni-easyinput type="number" v-model="formData.userName"
  17. placeholder="请输入手机号" maxlength="11" />
  18. </view>
  19. <view class="form-label-input">
  20. <view class="phone-form-label">
  21. <text class="form-label-require"></text>
  22. <text v-if="formData.idtype ==1">身份证号</text>
  23. <text v-if="formData.idtype ==2">护照号</text>
  24. <icon @click="idCardChange" class="change-icon">切换</icon>
  25. </view>
  26. <uni-easyinput :disabled="!statusFlag && status=='edit'" @blur="idCardBlur" v-model="formData.idcard"
  27. placeholder="请输入身份证号或护照号" maxlength="18" />
  28. </view>
  29. <view class="form-label-input flex-start-row">
  30. <view class="phone-form-label"><text class="form-label-require"></text>具体地址</view>
  31. <textarea v-model="jingli" maxlength="-1" placeholder="请填写具体地址" class="form-textarea-box" />
  32. </view>
  33. </view>
  34. <button type="default" class="phone-green-btn info-btn" @click="saveBtn">保存</button>
  35. </view>
  36. </uni-popup>
  37. </template>
  38. <script setup>
  39. import {ref,reactive,nextTick} from "vue";
  40. import {onLoad} from "@dcloudio/uni-app";
  41. import * as khApi from "@/api/kehu.js"
  42. const emits = defineEmits('success')
  43. const formData = reactive({
  44. realName: '',
  45. userName: '',
  46. idcard: '',
  47. idtype: '1',
  48. })
  49. function goback2() {
  50. popupRef.value.close();
  51. }
  52. const popupRef = ref(null)
  53. const data = reactive({
  54. })
  55. function handleShow() {
  56. popupRef.value.open();
  57. }
  58. function idCardChange(data) {
  59. formData.idtype = formData.idtype == 1 ? 2 : 1;
  60. }
  61. // 保存
  62. function saveBtn(){
  63. htAdd();
  64. }
  65. // 新增
  66. function htAdd(){
  67. let arr = [];
  68. if (!formData.realName) {
  69. arr.push('姓名');
  70. }
  71. if (!formData.userName) {
  72. arr.push('电话');
  73. }
  74. if (!formData.realName || !formData.userName) {
  75. uni.showToast({
  76. icon: 'none',
  77. title: `请完善${arr.join('、')}信息!`
  78. })
  79. return;
  80. }
  81. const opt = {
  82. realName: formData.realName,
  83. userName: formData.userName,
  84. idtype: formData.idtype,
  85. idcard: formData.idcard,
  86. }
  87. khApi.getKehuAdd(opt).then(res => {
  88. if (res.data) {
  89. uni.showToast({
  90. title: '新增成功'
  91. })
  92. goback2();
  93. emits('success')
  94. }
  95. })
  96. }
  97. defineExpose({
  98. handleShow
  99. })
  100. </script>
  101. <style>
  102. </style>