InsuredInfoForm.vue 7.4 KB

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