混凝土运输管理微信小程序、替班
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.

352 lines
7.8 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="carInfo.plateNumber"
  10. placeholder="请输入车牌号"
  11. class="input"
  12. maxlength="8"
  13. />
  14. </view>
  15. <!-- 车辆类型 -->
  16. <view class="form-item" @click="selectCarType">
  17. <view class="label">车辆类型</view>
  18. <view class="select-value">
  19. <text v-if="!carInfo.carType" class="placeholder">请选择车辆类型</text>
  20. <text v-else>{{ carInfo.carType }}</text>
  21. <uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
  22. </view>
  23. </view>
  24. <!-- 轴数 -->
  25. <view class="form-item" @click="selectAxleCount">
  26. <view class="label">轴数</view>
  27. <view class="select-value">
  28. <text v-if="!carInfo.axleCount" class="placeholder">请选择轴数</text>
  29. <text v-else>{{ carInfo.axleCount }}</text>
  30. <uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
  31. </view>
  32. </view>
  33. <!-- 载重量 -->
  34. <view class="form-item">
  35. <view class="label">载重量()</view>
  36. <input
  37. v-model="carInfo.loadCapacity"
  38. placeholder="请输入载重量"
  39. class="input"
  40. type="number"
  41. />
  42. </view>
  43. <!-- 车辆照片 -->
  44. <view class="form-item">
  45. <view class="label">车辆照片</view>
  46. <view class="upload-container">
  47. <view v-for="(image, index) in carInfo.images" :key="index" class="image-item">
  48. <image :src="image" mode="aspectFill" class="uploaded-image" @click="previewImage(index)"></image>
  49. <view class="delete-btn" @click="deleteImage(index)">
  50. <uv-icon name="close" size="16" color="#fff"></uv-icon>
  51. </view>
  52. </view>
  53. <view v-if="carInfo.images.length < 3" class="upload-btn" @click="uploadImage">
  54. <uv-icon name="plus" size="32" color="#999"></uv-icon>
  55. <text>上传照片</text>
  56. </view>
  57. </view>
  58. <view class="upload-tip">最多上传3张照片</view>
  59. </view>
  60. <!-- 证件照片 -->
  61. <view class="form-item">
  62. <view class="label">相关证件</view>
  63. <view class="upload-container">
  64. <view v-for="(doc, index) in carInfo.documents" :key="index" class="image-item">
  65. <image :src="doc" mode="aspectFill" class="uploaded-image" @click="previewDocument(index)"></image>
  66. <view class="delete-btn" @click="deleteDocument(index)">
  67. <uv-icon name="close" size="16" color="#fff"></uv-icon>
  68. </view>
  69. </view>
  70. <view v-if="carInfo.documents.length < 5" class="upload-btn" @click="uploadDocument">
  71. <uv-icon name="plus" size="32" color="#999"></uv-icon>
  72. <text>上传证件</text>
  73. </view>
  74. </view>
  75. <view class="upload-tip">请上传行驶证营运证等相关证件最多5张</view>
  76. </view>
  77. </view>
  78. <!-- 底部按钮 -->
  79. <view class="bottom-buttons">
  80. <button class="btn-save" @click="saveCar">{{ isEdit ? '保存' : '添加' }}</button>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import navbar from '@/components/base/navbar.vue'
  86. export default {
  87. name: 'StaffCar',
  88. components: {
  89. navbar
  90. },
  91. data() {
  92. return {
  93. isEdit: false,
  94. carId: '',
  95. carInfo: {
  96. plateNumber: '',
  97. carType: '',
  98. axleCount: '',
  99. loadCapacity: '',
  100. images: [],
  101. documents: []
  102. }
  103. }
  104. },
  105. onLoad(options) {
  106. if (options.mode === 'edit' && options.id) {
  107. this.isEdit = true;
  108. this.carId = options.id;
  109. this.loadCarInfo();
  110. }
  111. uni.setNavigationBarTitle({
  112. title: this.isEdit ? '编辑车辆' : '添加车辆'
  113. });
  114. },
  115. methods: {
  116. loadCarInfo() {
  117. // 模拟加载车辆信息
  118. this.carInfo = {
  119. plateNumber: '湘A12345',
  120. carType: '泵车',
  121. axleCount: '4轴',
  122. loadCapacity: '25',
  123. images: ['/static/re/ide1.png'],
  124. documents: ['/static/re/ide2.png']
  125. };
  126. },
  127. selectCarType() {
  128. uni.showActionSheet({
  129. itemList: ['泵车', '搅拌车', '车载泵'],
  130. success: (res) => {
  131. const types = ['泵车', '搅拌车', '车载泵'];
  132. this.carInfo.carType = types[res.tapIndex];
  133. }
  134. });
  135. },
  136. selectAxleCount() {
  137. uni.showActionSheet({
  138. itemList: ['2轴', '3轴', '4轴', '5轴', '6轴'],
  139. success: (res) => {
  140. const axles = ['2轴', '3轴', '4轴', '5轴', '6轴'];
  141. this.carInfo.axleCount = axles[res.tapIndex];
  142. }
  143. });
  144. },
  145. uploadImage() {
  146. uni.chooseImage({
  147. count: 3 - this.carInfo.images.length,
  148. sizeType: ['compressed'],
  149. sourceType: ['camera', 'album'],
  150. success: (res) => {
  151. this.carInfo.images.push(...res.tempFilePaths);
  152. }
  153. });
  154. },
  155. uploadDocument() {
  156. uni.chooseImage({
  157. count: 5 - this.carInfo.documents.length,
  158. sizeType: ['compressed'],
  159. sourceType: ['camera', 'album'],
  160. success: (res) => {
  161. this.carInfo.documents.push(...res.tempFilePaths);
  162. }
  163. });
  164. },
  165. previewImage(index) {
  166. uni.previewImage({
  167. current: index,
  168. urls: this.carInfo.images
  169. });
  170. },
  171. previewDocument(index) {
  172. uni.previewImage({
  173. current: index,
  174. urls: this.carInfo.documents
  175. });
  176. },
  177. deleteImage(index) {
  178. this.carInfo.images.splice(index, 1);
  179. },
  180. deleteDocument(index) {
  181. this.carInfo.documents.splice(index, 1);
  182. },
  183. saveCar() {
  184. if (!this.carInfo.plateNumber) {
  185. uni.showToast({
  186. title: '请输入车牌号',
  187. icon: 'none'
  188. });
  189. return;
  190. }
  191. if (!this.carInfo.carType) {
  192. uni.showToast({
  193. title: '请选择车辆类型',
  194. icon: 'none'
  195. });
  196. return;
  197. }
  198. if (!this.carInfo.axleCount) {
  199. uni.showToast({
  200. title: '请选择轴数',
  201. icon: 'none'
  202. });
  203. return;
  204. }
  205. uni.showToast({
  206. title: this.isEdit ? '保存成功' : '添加成功',
  207. icon: 'success'
  208. });
  209. setTimeout(() => {
  210. uni.navigateBack();
  211. }, 1500);
  212. }
  213. }
  214. }
  215. </script>
  216. <style scoped lang="scss">
  217. .content {
  218. padding: 20rpx;
  219. min-height: 100vh;
  220. background-color: #f5f5f5;
  221. padding-bottom: 120rpx;
  222. }
  223. .form-container {
  224. background-color: #fff;
  225. border-radius: 10rpx;
  226. padding: 30rpx;
  227. }
  228. .form-item {
  229. margin-bottom: 40rpx;
  230. &:last-child {
  231. margin-bottom: 0;
  232. }
  233. }
  234. .label {
  235. font-size: 28rpx;
  236. color: #333;
  237. margin-bottom: 20rpx;
  238. font-weight: 500;
  239. }
  240. .input {
  241. width: 100%;
  242. height: 80rpx;
  243. padding: 0 20rpx;
  244. border: 1rpx solid #e0e0e0;
  245. border-radius: 8rpx;
  246. font-size: 28rpx;
  247. box-sizing: border-box;
  248. }
  249. .select-value {
  250. display: flex;
  251. justify-content: space-between;
  252. align-items: center;
  253. height: 80rpx;
  254. padding: 0 20rpx;
  255. border: 1rpx solid #e0e0e0;
  256. border-radius: 8rpx;
  257. font-size: 28rpx;
  258. .placeholder {
  259. color: #999;
  260. }
  261. }
  262. .upload-container {
  263. display: flex;
  264. flex-wrap: wrap;
  265. gap: 20rpx;
  266. }
  267. .image-item {
  268. position: relative;
  269. width: 200rpx;
  270. height: 200rpx;
  271. }
  272. .uploaded-image {
  273. width: 100%;
  274. height: 100%;
  275. border-radius: 8rpx;
  276. }
  277. .delete-btn {
  278. position: absolute;
  279. top: -10rpx;
  280. right: -10rpx;
  281. width: 40rpx;
  282. height: 40rpx;
  283. background-color: #ff3b30;
  284. border-radius: 50%;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. }
  289. .upload-btn {
  290. width: 200rpx;
  291. height: 200rpx;
  292. border: 2rpx dashed #ccc;
  293. border-radius: 8rpx;
  294. display: flex;
  295. flex-direction: column;
  296. align-items: center;
  297. justify-content: center;
  298. gap: 10rpx;
  299. color: #999;
  300. font-size: 24rpx;
  301. }
  302. .upload-tip {
  303. font-size: 24rpx;
  304. color: #999;
  305. margin-top: 10rpx;
  306. }
  307. .bottom-buttons {
  308. position: fixed;
  309. bottom: 0;
  310. left: 0;
  311. right: 0;
  312. padding: 20rpx;
  313. background-color: #fff;
  314. border-top: 1rpx solid #f0f0f0;
  315. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  316. }
  317. .btn-save {
  318. width: 100%;
  319. height: 80rpx;
  320. line-height: 80rpx;
  321. background-color: #007AFF;
  322. color: #fff;
  323. border-radius: 40rpx;
  324. font-size: 32rpx;
  325. border: none;
  326. }
  327. </style>