ApplicantInfoForm.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <u-form :model="policyHolderInfo" :rules="policyRules" ref="policyForm" :errorType="errorType" label-width="200"
  3. style="padding: 0 15px;">
  4. <u-form-item label="姓名:" prop="name">
  5. <u-input placeholder="请输入姓名" v-model="policyHolderInfo.name" type="text"
  6. :custom-style="{textAlign:'right'}"></u-input>
  7. </u-form-item>
  8. <u-form-item label="证件类型:" prop="identifyType" style="padding: 14rpx 0;">
  9. <view class="dis a-c j-end" style="width:100%;height: 100%;">
  10. 身份证
  11. </view>
  12. </u-form-item>
  13. <u-form-item label="证件号:" prop="identifyNumber">
  14. <u-input placeholder="请输入证件号" v-model="policyHolderInfo.identifyNumber" type="text"
  15. :custom-style="{textAlign:'right'}"
  16. @blur="binddata('identifyNumber', $event,'policyHolderInfo')"></u-input>
  17. </u-form-item>
  18. <u-form-item label="年龄:" prop="age">
  19. <u-input placeholder="请输入年龄" v-model="policyHolderInfo.age" disabled type="text"
  20. :custom-style="{textAlign:'right'}"></u-input>
  21. </u-form-item>
  22. <u-form-item label="性别:" prop="gender">
  23. <u-input placeholder="请输入性别" v-model="policyHolderInfo.gender" disabled type="text"
  24. :custom-style="{textAlign:'right'}"></u-input>
  25. </u-form-item>
  26. <u-form-item label="手机号:" prop="mobile">
  27. <u-input placeholder="请输入手机号" v-model="policyHolderInfo.mobile" type="text" maxlength="11"
  28. :custom-style="{textAlign:'right'}"></u-input>
  29. </u-form-item>
  30. <u-form-item label="地址:" prop="addr">
  31. <u-input type="textarea" v-model="policyHolderInfo.addr" :custom-style="{textAlign:'right'}"
  32. placeholder-style="color:#808080" :auto-height="true" placeholder="请输入地址" />
  33. </u-form-item>
  34. <u-form-item label="邮箱:">
  35. <u-input placeholder="请输入邮箱" v-model="policyHolderInfo.email" type="text"
  36. :custom-style="{textAlign:'right'}"></u-input>
  37. </u-form-item>
  38. <u-form-item label="有效期起期:" prop="identifyValidDate">
  39. <u-input type="select" :select-open="applicantDateShow" v-model="policyHolderInfo.identifyValidDate"
  40. placeholder="请选择有效期起期" @click="applicantDateShow = true" :custom-style="{textAlign:'right'}"
  41. placeholder-style="color:#808080"></u-input>
  42. <u-picker v-model="applicantDateShow" mode="time" :params="params"
  43. @confirm="e=> Dateconfirm(e,'policyHolderInfo','identifyValidDate')"></u-picker>
  44. </u-form-item>
  45. <u-form-item label="有效期止期:" prop="identifyValidEndDate">
  46. <u-input placeholder="有效期止期" v-model="policyHolderInfo.identifyValidEndDate" type="text"
  47. :custom-style="{textAlign:'right'}"></u-input>
  48. </u-form-item>
  49. <u-form-item label="止期年限:" style="padding: 10rpx 0;">
  50. <view class="dis a-c j-c">
  51. <view class="status-data" :class="item.value==policyValidEndDateholder? 'active':''"
  52. v-for="(item,index) in endDateList"
  53. @tap="ValidEndDateClick(item.value,'policyValidEndDateholder','policyHolderInfo')" :key="index">
  54. {{item.label}}
  55. </view>
  56. </view>
  57. </u-form-item>
  58. </u-form>
  59. </template>
  60. <script>
  61. export default {
  62. props: {
  63. policyHolderInfo: Object,
  64. Dateconfirm: Function,
  65. binddata: Function,
  66. endDateList: Array,
  67. ValidEndDateClick: Function,
  68. policyValidEndDateholder: {
  69. type: String,
  70. default: null,
  71. },
  72. errorType: {
  73. type: Array,
  74. default: () => ['border-bottom', 'toast'],
  75. },
  76. },
  77. data() {
  78. return {
  79. applicantDateShow: false,
  80. params: {
  81. year: true, //年
  82. month: true, //月
  83. day: true, //日
  84. hour: false, //时
  85. minute: false, //分
  86. second: false, //秒
  87. },
  88. policyRules: {
  89. name: [{
  90. required: true,
  91. message: '请输入投保人姓名',
  92. trigger: ['blur', 'change'],
  93. },
  94. {
  95. minLength: 2,
  96. maxLength: 5,
  97. message: '车主姓名长度在 {minLength} 到 {maxLength} 个字符',
  98. },
  99. {
  100. pattern: /^([\u4e00-\u9fa5]{1,6}|[a-zA-Z\.\s]{1,6})$/,
  101. message: '请输入正确的车主姓名',
  102. }
  103. ],
  104. identifyNumber: [{
  105. required: true,
  106. message: '请输入车主证件号',
  107. trigger: ['blur', 'change'],
  108. },
  109. {
  110. pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
  111. message: '请输入正确的车主证件号',
  112. }
  113. ],
  114. mobile: [{
  115. required: true,
  116. message: '请输入车主手机号',
  117. trigger: ['blur', 'change'],
  118. },
  119. {
  120. pattern: /^1[3-9]\d{9}$/,
  121. message: '请输入正确的手机号',
  122. }
  123. ],
  124. addr: [{
  125. required: true,
  126. message: '请输入车主地址',
  127. trigger: ['blur', 'change'],
  128. },
  129. {
  130. minLength: 8,
  131. maxLength: 40,
  132. message: '车主地址长度在 {minLength} 到 {maxLength} 个字符',
  133. },
  134. ],
  135. identifyValidDate: [{
  136. required: true,
  137. message: '请选择身份证起期',
  138. trigger: ['blur', 'change'],
  139. }, {
  140. pattern: /^\d{4}-\d{2}-\d{2}$/,
  141. message: '身份证起期格式错误',
  142. }],
  143. identifyValidEndDate: [{
  144. required: true,
  145. message: '请选择身份证止期',
  146. trigger: ['blur', 'change'],
  147. }, {
  148. pattern: /^\d{4}-\d{2}-\d{2}$/,
  149. message: '身份证止期格式错误',
  150. }]
  151. },
  152. }
  153. },
  154. methods: {
  155. validate(callback) {
  156. this.$refs.policyForm.setRules(this.policyRules);
  157. this.$refs.policyForm.validate(valid => {
  158. if (callback) {
  159. callback(valid);
  160. }
  161. });
  162. },
  163. setRules(rules) {
  164. // 更新规则逻辑
  165. this.policyRules = rules; // 或者根据需要
  166. },
  167. },
  168. }
  169. </script>
  170. <style scoped lang="scss">
  171. /* 添加样式 */
  172. .status-data {
  173. width: 66px;
  174. height: 30px;
  175. margin: 0 7px;
  176. font-size: 14px;
  177. border: 1px solid #CDCDCD;
  178. cursor: pointer;
  179. text-align: center;
  180. line-height: 30px;
  181. }
  182. .active {
  183. position: relative;
  184. background: rgba(0, 82, 255, 0.1);
  185. color: #0052FF;
  186. border: 1px solid #0052FF;
  187. font-weight: 700;
  188. }
  189. .active::before {
  190. content: "";
  191. position: absolute;
  192. top: 0;
  193. left: 0;
  194. width: 10px;
  195. height: 10px;
  196. background-image: url("/static/image/car-insure/before.png");
  197. background-size: cover;
  198. }
  199. </style>