混凝土运输管理微信小程序、替班
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

401 lines
9.7 KiB

2 weeks ago
  1. <template>
  2. <view class="content">
  3. <navbar title="司机信息" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="form-container">
  5. <!-- 司机姓名 -->
  6. <view class="form-item">
  7. <view class="label">司机姓名</view>
  8. <input
  9. v-model="driverInfo.name"
  10. placeholder="请输入司机姓名"
  11. class="input"
  12. />
  13. </view>
  14. <!-- 联系电话 -->
  15. <view class="form-item">
  16. <view class="label">联系电话</view>
  17. <input
  18. v-model="driverInfo.phone"
  19. placeholder="请输入司机联系电话"
  20. class="input"
  21. type="number"
  22. maxlength="11"
  23. />
  24. </view>
  25. <!-- 驾驶车型 -->
  26. <view class="form-item">
  27. <view class="label">驾驶车型</view>
  28. <view class="select-value" @click="selectCarType">
  29. <text v-if="!driverInfo.carType" class="placeholder">请选择驾驶车型</text>
  30. <text v-else>{{ driverInfo.carType }}</text>
  31. <uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
  32. </view>
  33. </view>
  34. <!-- 工作经验 -->
  35. <view class="form-item">
  36. <view class="label">工作经验</view>
  37. <view class="select-value" @click="selectExperience">
  38. <text v-if="!driverInfo.experience" class="placeholder">请选择工作经验</text>
  39. <text v-else>{{ driverInfo.experience }}</text>
  40. <uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
  41. </view>
  42. </view>
  43. <!-- 所在地区 -->
  44. <view class="form-item">
  45. <view class="label">所在地区</view>
  46. <view class="address-input" @click="selectLocation">
  47. <text v-if="!driverInfo.location" class="placeholder">请选择所在地区</text>
  48. <text v-else>{{ driverInfo.location }}</text>
  49. <uv-icon name="map-pin" size="20" color="#007AFF"></uv-icon>
  50. </view>
  51. </view>
  52. <!-- 身份证号 -->
  53. <view class="form-item">
  54. <view class="label">身份证号</view>
  55. <input
  56. v-model="driverInfo.idCard"
  57. placeholder="请输入身份证号"
  58. class="input"
  59. maxlength="18"
  60. />
  61. </view>
  62. <!-- 驾驶证照片 -->
  63. <view class="form-item">
  64. <view class="label">驾驶证照片</view>
  65. <view class="upload-container">
  66. <view v-for="(image, index) in driverInfo.licenseImages" :key="index" class="image-item">
  67. <image :src="image" mode="aspectFill" class="uploaded-image" @click="previewImage(index, 'license')"></image>
  68. <view class="delete-btn" @click="deleteLicenseImage(index)">
  69. <uv-icon name="close" size="16" color="#fff"></uv-icon>
  70. </view>
  71. </view>
  72. <view v-if="driverInfo.licenseImages.length < 2" class="upload-btn" @click="uploadLicenseImage">
  73. <uv-icon name="plus" size="32" color="#999"></uv-icon>
  74. <text>上传驾驶证</text>
  75. </view>
  76. </view>
  77. <view class="upload-tip">请上传驾驶证正反面最多2张</view>
  78. </view>
  79. <!-- 身份证照片 -->
  80. <view class="form-item">
  81. <view class="label">身份证照片</view>
  82. <view class="upload-container">
  83. <view v-for="(image, index) in driverInfo.idCardImages" :key="index" class="image-item">
  84. <image :src="image" mode="aspectFill" class="uploaded-image" @click="previewImage(index, 'idCard')"></image>
  85. <view class="delete-btn" @click="deleteIdCardImage(index)">
  86. <uv-icon name="close" size="16" color="#fff"></uv-icon>
  87. </view>
  88. </view>
  89. <view v-if="driverInfo.idCardImages.length < 2" class="upload-btn" @click="uploadIdCardImage">
  90. <uv-icon name="plus" size="32" color="#999"></uv-icon>
  91. <text>上传身份证</text>
  92. </view>
  93. </view>
  94. <view class="upload-tip">请上传身份证正反面最多2张</view>
  95. </view>
  96. <!-- 推荐理由 -->
  97. <view class="form-item">
  98. <view class="label">推荐理由</view>
  99. <textarea
  100. v-model="driverInfo.reason"
  101. placeholder="请简述推荐理由,如:技术熟练、工作认真等"
  102. class="textarea"
  103. maxlength="200"
  104. ></textarea>
  105. </view>
  106. </view>
  107. <!-- 底部按钮 -->
  108. <view class="bottom-buttons">
  109. <button class="btn-save" @click="submitRecommendation">提交推荐</button>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. import navbar from '@/components/base/navbar.vue'
  115. export default {
  116. name: 'StaffDriver',
  117. components: {
  118. navbar
  119. },
  120. data() {
  121. return {
  122. driverInfo: {
  123. name: '',
  124. phone: '',
  125. carType: '',
  126. experience: '',
  127. location: '',
  128. idCard: '',
  129. licenseImages: [],
  130. idCardImages: [],
  131. reason: ''
  132. }
  133. }
  134. },
  135. onLoad() {
  136. uni.setNavigationBarTitle({
  137. title: '推荐司机'
  138. });
  139. },
  140. methods: {
  141. selectCarType() {
  142. uni.showActionSheet({
  143. itemList: ['泵车', '搅拌车', '车载泵', '其他'],
  144. success: (res) => {
  145. const types = ['泵车', '搅拌车', '车载泵', '其他'];
  146. this.driverInfo.carType = types[res.tapIndex];
  147. }
  148. });
  149. },
  150. selectExperience() {
  151. uni.showActionSheet({
  152. itemList: ['1年以下', '1-3年', '3-5年', '5-10年', '10年以上'],
  153. success: (res) => {
  154. const experiences = ['1年以下', '1-3年', '3-5年', '5-10年', '10年以上'];
  155. this.driverInfo.experience = experiences[res.tapIndex];
  156. }
  157. });
  158. },
  159. selectLocation() {
  160. uni.chooseLocation({
  161. success: (res) => {
  162. this.driverInfo.location = res.address;
  163. }
  164. });
  165. },
  166. uploadLicenseImage() {
  167. uni.chooseImage({
  168. count: 2 - this.driverInfo.licenseImages.length,
  169. sizeType: ['compressed'],
  170. sourceType: ['camera', 'album'],
  171. success: (res) => {
  172. this.driverInfo.licenseImages.push(...res.tempFilePaths);
  173. }
  174. });
  175. },
  176. uploadIdCardImage() {
  177. uni.chooseImage({
  178. count: 2 - this.driverInfo.idCardImages.length,
  179. sizeType: ['compressed'],
  180. sourceType: ['camera', 'album'],
  181. success: (res) => {
  182. this.driverInfo.idCardImages.push(...res.tempFilePaths);
  183. }
  184. });
  185. },
  186. previewImage(index, type) {
  187. const images = type === 'license' ? this.driverInfo.licenseImages : this.driverInfo.idCardImages;
  188. uni.previewImage({
  189. current: index,
  190. urls: images
  191. });
  192. },
  193. deleteLicenseImage(index) {
  194. this.driverInfo.licenseImages.splice(index, 1);
  195. },
  196. deleteIdCardImage(index) {
  197. this.driverInfo.idCardImages.splice(index, 1);
  198. },
  199. submitRecommendation() {
  200. // 表单验证
  201. if (!this.driverInfo.name) {
  202. uni.showToast({ title: '请输入司机姓名', icon: 'none' });
  203. return;
  204. }
  205. if (!this.driverInfo.phone) {
  206. uni.showToast({ title: '请输入联系电话', icon: 'none' });
  207. return;
  208. }
  209. if (!/^1[3-9]\d{9}$/.test(this.driverInfo.phone)) {
  210. uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
  211. return;
  212. }
  213. if (!this.driverInfo.carType) {
  214. uni.showToast({ title: '请选择驾驶车型', icon: 'none' });
  215. return;
  216. }
  217. if (!this.driverInfo.experience) {
  218. uni.showToast({ title: '请选择工作经验', icon: 'none' });
  219. return;
  220. }
  221. if (!this.driverInfo.idCard) {
  222. uni.showToast({ title: '请输入身份证号', icon: 'none' });
  223. return;
  224. }
  225. if (!/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(this.driverInfo.idCard)) {
  226. uni.showToast({ title: '请输入正确的身份证号', icon: 'none' });
  227. return;
  228. }
  229. uni.showToast({
  230. title: '推荐成功',
  231. icon: 'success'
  232. });
  233. setTimeout(() => {
  234. uni.navigateBack();
  235. }, 1500);
  236. }
  237. }
  238. }
  239. </script>
  240. <style scoped lang="scss">
  241. .content {
  242. padding: 20rpx;
  243. min-height: 100vh;
  244. background-color: #f5f5f5;
  245. padding-bottom: 120rpx;
  246. }
  247. .form-container {
  248. background-color: #fff;
  249. border-radius: 10rpx;
  250. padding: 30rpx;
  251. }
  252. .form-item {
  253. margin-bottom: 40rpx;
  254. &:last-child {
  255. margin-bottom: 0;
  256. }
  257. }
  258. .label {
  259. font-size: 28rpx;
  260. color: #333;
  261. margin-bottom: 20rpx;
  262. font-weight: 500;
  263. }
  264. .input {
  265. width: 100%;
  266. height: 80rpx;
  267. padding: 0 20rpx;
  268. border: 1rpx solid #e0e0e0;
  269. border-radius: 8rpx;
  270. font-size: 28rpx;
  271. box-sizing: border-box;
  272. }
  273. .textarea {
  274. width: 100%;
  275. height: 120rpx;
  276. padding: 20rpx;
  277. border: 1rpx solid #e0e0e0;
  278. border-radius: 8rpx;
  279. font-size: 28rpx;
  280. box-sizing: border-box;
  281. resize: none;
  282. }
  283. .select-value {
  284. display: flex;
  285. justify-content: space-between;
  286. align-items: center;
  287. height: 80rpx;
  288. padding: 0 20rpx;
  289. border: 1rpx solid #e0e0e0;
  290. border-radius: 8rpx;
  291. font-size: 28rpx;
  292. }
  293. .address-input {
  294. display: flex;
  295. justify-content: space-between;
  296. align-items: center;
  297. height: 80rpx;
  298. padding: 0 20rpx;
  299. border: 1rpx solid #e0e0e0;
  300. border-radius: 8rpx;
  301. font-size: 28rpx;
  302. }
  303. .placeholder {
  304. color: #999;
  305. }
  306. .upload-container {
  307. display: flex;
  308. flex-wrap: wrap;
  309. gap: 20rpx;
  310. }
  311. .image-item {
  312. position: relative;
  313. width: 200rpx;
  314. height: 200rpx;
  315. }
  316. .uploaded-image {
  317. width: 100%;
  318. height: 100%;
  319. border-radius: 8rpx;
  320. }
  321. .delete-btn {
  322. position: absolute;
  323. top: -10rpx;
  324. right: -10rpx;
  325. width: 40rpx;
  326. height: 40rpx;
  327. background-color: #ff3b30;
  328. border-radius: 50%;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. }
  333. .upload-btn {
  334. width: 200rpx;
  335. height: 200rpx;
  336. border: 2rpx dashed #ccc;
  337. border-radius: 8rpx;
  338. display: flex;
  339. flex-direction: column;
  340. align-items: center;
  341. justify-content: center;
  342. gap: 10rpx;
  343. color: #999;
  344. font-size: 24rpx;
  345. }
  346. .upload-tip {
  347. font-size: 24rpx;
  348. color: #999;
  349. margin-top: 10rpx;
  350. }
  351. .bottom-buttons {
  352. position: fixed;
  353. bottom: 0;
  354. left: 0;
  355. right: 0;
  356. padding: 20rpx;
  357. background-color: #fff;
  358. border-top: 1rpx solid #f0f0f0;
  359. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  360. }
  361. .btn-save {
  362. width: 100%;
  363. height: 80rpx;
  364. line-height: 80rpx;
  365. background-color: #007AFF;
  366. color: #fff;
  367. border-radius: 40rpx;
  368. font-size: 32rpx;
  369. border: none;
  370. }
  371. </style>