addKh.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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="goUpPage" 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 formData = reactive({
  43. realName: '',
  44. userName: '',
  45. idcard: '',
  46. idtype: '1',
  47. })
  48. function goback2() {
  49. popupRef.value.close();
  50. }
  51. const popupRef = ref(null)
  52. const data = reactive({
  53. })
  54. function handleShow() {
  55. popupRef.value.open();
  56. }
  57. // 保存
  58. function saveBtn(){
  59. htAdd();
  60. }
  61. // 新增
  62. function htAdd(){
  63. let arr = [];
  64. if (!formData.realName) {
  65. arr.push('姓名');
  66. }
  67. if (!formData.userName) {
  68. arr.push('电话');
  69. }
  70. if (!formData.realName || !formData.userName) {
  71. uni.showToast({
  72. icon: 'none',
  73. title: `请完善${arr.join('、')}信息!`
  74. })
  75. return;
  76. }
  77. const opt = {
  78. realName: formData.realName,
  79. userName: formData.userName,
  80. idtype: formData.idtype,
  81. idcard: formData.idcard,
  82. }
  83. khApi.getKehuAdd(opt).then(res => {
  84. if (res.data) {
  85. uni.showToast({
  86. title: '新增成功'
  87. })
  88. goUpPage();
  89. }
  90. })
  91. }
  92. defineExpose({
  93. handleShow
  94. })
  95. </script>
  96. <style>
  97. </style>