OwnerInfoForm.vue 6.0 KB

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