suppAdd.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="app-content">
  3. <form @submit="formSubmit">
  4. <!-- 名称 -->
  5. <div class="module-com input-line-wrap">
  6. <tui-list-cell class="line-cell" :hover="false">
  7. <div class="tui-title required">名称</div>
  8. <input
  9. v-model="form.name"
  10. class="tui-input"
  11. placeholder="请填写名称"
  12. maxlength="50"
  13. type="text"
  14. name="username"
  15. />
  16. </tui-list-cell>
  17. <!-- 手机号 -->
  18. <tui-list-cell class="line-cell" :hover="false">
  19. <div class="tui-title required">手机号</div>
  20. <input
  21. v-model="form.mobile"
  22. class="tui-input"
  23. placeholder="请填写手机号"
  24. maxlength="50"
  25. type="number"
  26. name="phone"
  27. />
  28. </tui-list-cell>
  29. <!-- 确认手机号 -->
  30. <tui-list-cell class="line-cell" :hover="false">
  31. <div class="tui-title required">确认手机号</div>
  32. <input
  33. v-model="form.confirmMobile"
  34. class="tui-input"
  35. placeholder="请确认手机号"
  36. maxlength="50"
  37. type="number"
  38. name="requirePhone"
  39. />
  40. </tui-list-cell>
  41. <!-- 地址 -->
  42. <tui-list-cell class="line-cell" :hover="false">
  43. <div class="tui-title">地址</div>
  44. <input
  45. v-model="form.address"
  46. class="tui-input"
  47. placeholder="选填"
  48. maxlength="50"
  49. type="text"
  50. />
  51. </tui-list-cell>
  52. </div>
  53. <!-- 提交 -->
  54. <div class="confirm-btn">
  55. <button class="admin-button-com big blue" formType="submit">确认</button>
  56. </div>
  57. </form>
  58. </div>
  59. </template>
  60. <script>
  61. import TuiListCell from "@/components/plugin/list-cell";
  62. import { ghsAdd } from "@/api/ghs"
  63. const form = require("@/utils/formValidation.js");
  64. export default {
  65. components: {
  66. TuiListCell,
  67. },
  68. data() {
  69. return {
  70. form: {
  71. mobile: '',
  72. confirmMobile: '',
  73. name: '',
  74. address: ''
  75. }
  76. }
  77. },
  78. methods: {
  79. // 表单验证
  80. formSubmit(e) {
  81. // 表单规则
  82. let rules = [
  83. {
  84. name: "username",
  85. rule: ["required"],
  86. msg: ["请填写名称"]
  87. },
  88. {
  89. name: "phone",
  90. rule: ["required"],
  91. msg: ["请填写手机号"]
  92. },
  93. {
  94. name: "requirePhone",
  95. rule: ["required"],
  96. msg: ["请确认手机号"]
  97. }
  98. ];
  99. // 进行表单检查
  100. let formData = e.detail.value;
  101. let checkRes = form.validation(formData, rules);
  102. // 验证通过!
  103. if (!checkRes) {
  104. this.confirmFn();
  105. } else {
  106. this.$msg(checkRes);
  107. }
  108. },
  109. confirmFn() {
  110. uni.showLoading({
  111. title:"加载中..."
  112. })
  113. ghsAdd(this.form).then(res => {
  114. uni.setStorageSync('newGhs', res.data);
  115. uni.hideLoading()
  116. setTimeout(() => {
  117. this.$util.pageTo(1);
  118. }, 1000);
  119. }).catch(err => {})
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .app-content {
  126. min-height: calc(100vh - 20upx);
  127. padding-top: 20upx;
  128. }
  129. .prompt-text {
  130. color: $fontColor3;
  131. padding-left: 30upx;
  132. margin-bottom: 30upx;
  133. }
  134. .module-com {
  135. margin-bottom: 20upx;
  136. .member-wrap {
  137. .member-det {
  138. font-size: 24upx;
  139. margin-left: 20upx;
  140. }
  141. }
  142. .remark-wrap {
  143. align-items: flex-start;
  144. .remark {
  145. height: 240upx;
  146. }
  147. }
  148. }
  149. // 按钮
  150. .confirm-btn {
  151. width: calc(100% - 60upx);
  152. margin: 60upx 30upx 20upx;
  153. .admin-button-com {
  154. width: 100%;
  155. }
  156. }
  157. </style>