OwnerInfoForm.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="">
  3. <u--form labelPosition="left" :model="ownerInfo" :rules="ownerRules" ref="ownerForm" labelWidth="80"
  4. errorType="message">
  5. <u-form-item label="姓名" prop="name" borderBottom>
  6. <u-input v-model="ownerInfo.name" border="none" clearable placeholder="请输入姓名"
  7. placeholderStyle="text-align:right;"></u-input>
  8. </u-form-item>
  9. <u-form-item label="证件类型" borderBottom @click="identifyTypeShow=true">
  10. <u-input v-model="ownerInfos.identifyType" border="none" clearable placeholder=""
  11. placeholderStyle="text-align:right;" suffixIcon='arrow-down'
  12. suffixIconStyle="color:#333;font-size:30rpx" style="pointer-events: none"></u-input>
  13. </u-form-item>
  14. <u-form-item label="证件号" prop="identifyNumber" borderBottom>
  15. <u-input v-model="ownerInfo.identifyNumber" border="none" clearable placeholder="请输入证件号"
  16. placeholderStyle="text-align:right;"></u-input>
  17. </u-form-item>
  18. <u-form-item label="手机号" prop="mobile" borderBottom>
  19. <u-input v-model="ownerInfo.mobile" border="none" clearable placeholder="请输入手机号" maxlength="11"
  20. placeholderStyle="text-align:right;"></u-input>
  21. </u-form-item>
  22. <u-form-item label="地址" prop="addr" borderBottom>
  23. <u--textarea v-model="ownerInfo.addr" border="none" placeholder="请输入地址" autoHeight></u--textarea>
  24. </u-form-item>
  25. <u-form-item label="证件起期" prop="identifyValidDate" borderBottom @click="identifyValidDateShow = true; ">
  26. <u--input v-model="ownerInfo.identifyValidDate" disabled disabledColor="#ffffff" clearable
  27. suffixIcon='calendar' suffixIconStyle="color:#333;font-size:40rpx" placeholder="请选择证件起期 "
  28. placeholderStyle="text-align:right;" border="none" style="pointer-events: none"></u--input>
  29. </u-form-item>
  30. <u-form-item label="证件止期" prop="identifyValidEndDate" @click="identifyValidEndDateShow = true; ">
  31. <u--input v-model="ownerInfo.identifyValidEndDate" disabled disabledColor="#ffffff" clearable
  32. suffixIcon='calendar' suffixIconStyle="color:#333;font-size:40rpx;margin-right:20px"
  33. placeholder="请选择证件止期 " placeholderStyle="text-align:right;" border="none"
  34. style="pointer-events: none">
  35. </u--input>
  36. <u-checkbox-group v-model="ownerlongTerm" iconPlacement="right" @change="ownerlongTermChange">
  37. <u-checkbox activeColor="#FDE935" iconColor="#333" labelSize="15px" shape="circle" label="长期有效"
  38. name="长期有效"></u-checkbox>
  39. </u-checkbox-group>
  40. </u-form-item>
  41. </u--form>
  42. <u-picker :show="identifyTypeShow" :columns="identifyTypelist" keyName="label" @cancel="identifyTypeShow=false"
  43. @confirm="identifyTypeConfirm($event,'identifyType','identifyTypeShow')" @close="identifyTypeShow=false"
  44. :closeOnClickOverlay="true"></u-picker>
  45. <u-datetime-picker :show="identifyValidDateShow" v-model="identifyValidDatevalue" mode="date"
  46. :formatter="formatter" @cancel="identifyValidDateShow=false" @close="identifyValidDateShow=false"
  47. :closeOnClickOverlay="true" @confirm="identifyValidDateconfirm" confirmText="确定"></u-datetime-picker>
  48. <u-datetime-picker :show="identifyValidEndDateShow" mode="date" v-model="identifyValidEndDatevalue"
  49. :formatter="formatter" @cancel="identifyValidEndDateShow=false" @confirm="identifyValidEndDateconfirm"
  50. :closeOnClickOverlay="true" @close="identifyValidEndDateShow=false" confirmText="确定"></u-datetime-picker>
  51. </view>
  52. </template>
  53. <script>
  54. var dateTime = new Date();
  55. let Year = dateTime.getFullYear();
  56. let Month = Number(dateTime.getMonth() + 1);
  57. export default {
  58. props: {
  59. ownerInfo: Object,
  60. ownerInfos: Object,
  61. },
  62. data() {
  63. return {
  64. identifyValidDatevalue: Number(new Date()), //证件起期
  65. identifyValidEndDatevalue: Number(new Date()), //证件止期
  66. identifyTypeShow: false, //证件类型
  67. identifyValidDateShow: false, //证件起期
  68. identifyValidEndDateShow: false, //证件止期
  69. ownerlongTerm: [], //车主长期
  70. identifyTypelist: [
  71. [{
  72. label: "身份证",
  73. value: "01",
  74. },
  75. {
  76. label: "统一社会信用代码",
  77. value: "10",
  78. }
  79. ]
  80. ],
  81. ownerRules: {
  82. name: [{
  83. required: true,
  84. message: '请输入车主姓名',
  85. trigger: ['blur', 'change'],
  86. },
  87. {
  88. minLength: 2,
  89. maxLength: 5,
  90. message: '车主姓名长度在 {minLength} 到 {maxLength} 个字符',
  91. },
  92. {
  93. pattern: /^([\u4e00-\u9fa5]{1,6}|[a-zA-Z\.\s]{1,6})$/,
  94. message: '请输入正确的车主姓名',
  95. }
  96. ],
  97. identifyNumber: [{
  98. required: true,
  99. message: '请输入车主证件号',
  100. trigger: ['blur', 'change'],
  101. },
  102. {
  103. 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]$/,
  104. message: '请输入正确的车主证件号',
  105. }
  106. ],
  107. mobile: [{
  108. required: true,
  109. message: '请输入车主手机号',
  110. trigger: ['blur', 'change'],
  111. },
  112. {
  113. pattern: /^1[3-9]\d{9}$/,
  114. message: '请输入正确的手机号',
  115. }
  116. ],
  117. addr: [{
  118. required: true,
  119. message: '请输入车主地址',
  120. trigger: ['blur', 'change'],
  121. },
  122. {
  123. minLength: 8,
  124. maxLength: 40,
  125. message: '车主地址长度在 {minLength} 到 {maxLength} 个字符',
  126. },
  127. ],
  128. identifyValidDate: [{
  129. required: true,
  130. message: '请选择身份证起期',
  131. trigger: ['blur', 'change'],
  132. }, {
  133. pattern: /^\d{4}-\d{2}-\d{2}$/,
  134. message: '身份证起期格式错误',
  135. }],
  136. identifyValidEndDate: [{
  137. required: true,
  138. message: '请选择身份证止期',
  139. trigger: ['blur', 'change'],
  140. }, {
  141. pattern: /^\d{4}-\d{2}-\d{2}$/,
  142. message: '身份证止期格式错误',
  143. }]
  144. },
  145. }
  146. },
  147. methods: {
  148. identifyTypeConfirm(value, name, showName) {
  149. this.ownerInfo[name] = value.value[0].value;
  150. this.ownerInfos[name] = value.value[0].label;
  151. this[showName] = false;
  152. },
  153. ownerlongTermChange(e) {
  154. if (e.length) {
  155. this.ownerInfo.identifyValidEndDate = '9999-12-31';
  156. } else {
  157. this.ownerInfo.identifyValidEndDate = '';
  158. }
  159. },
  160. identifyValidDateconfirm(e) {
  161. this.ownerInfo.identifyValidDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  162. this.identifyValidDateShow = false;
  163. },
  164. identifyValidEndDateconfirm(e) {
  165. this.ownerInfo.identifyValidEndDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  166. this.identifyValidEndDateShow = false;
  167. },
  168. formatter(type, value) {
  169. if (type === 'year') {
  170. return `${value}年`
  171. }
  172. if (type === 'month') {
  173. return `${value}月`
  174. }
  175. if (type === 'day') {
  176. return `${value}日`
  177. }
  178. return value
  179. },
  180. validate(callback) {
  181. this.$refs.ownerForm.setRules(this.ownerRules)
  182. this.$refs.ownerForm.validate().then(res => {
  183. callback(res)
  184. }).catch(errors => {
  185. callback(errors)
  186. })
  187. }
  188. },
  189. }
  190. </script>
  191. <style scoped lang="scss">
  192. ::v-deep {
  193. .u-textarea {
  194. text-align: right;
  195. padding: 0;
  196. color: #303133;
  197. }
  198. .uni-textarea-placeholder {
  199. color: grey !important;
  200. text-align: right;
  201. }
  202. }
  203. /* 添加样式 */
  204. .search {
  205. width: 112rpx;
  206. height: 60rpx;
  207. background: #FDE935;
  208. border-radius: 100rpx 100rpx 100rpx 100rpx;
  209. }
  210. </style>