editVehicle.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <!-- 管理车辆 -->
  2. <template>
  3. <view class="content">
  4. <view class="flex s-row container">
  5. <view class="flex row">
  6. <view class="left left-text">车牌号</view>
  7. <view class="right flex">
  8. <input class="car-uumber" v-model='dataDetails.carNumber' @click.stop="handleShowKeyboard(index)"
  9. :disabled="true" placeholder="输入车牌号" name="input"></input>
  10. </view>
  11. </view>
  12. <view class="flex row">
  13. <view class="left-text">车牌颜色</view>
  14. <view class="color" @click="selectNoColor">{{dataDetails.carNumberColour}}</view>
  15. <view>></view>
  16. <u-picker :show="carColor" :columns="colorColumns" :closeOnClickOverlay='true' @close='colorClose'
  17. @cancel='colorClose' @confirm='confirmColor'></u-picker>
  18. </view>
  19. <view class="flex row">
  20. <view class="left-text">车型</view>
  21. <view class="color" @click="selectCarModel">{{dataDetails.carType}}</view>
  22. <view>></view>
  23. <u-picker :show="carModel" :columns="carModelColumns" :closeOnClickOverlay='true' @close='carModelClose'
  24. @cancel='carModelClose' @change="changeCarModel" @confirm='confirmCarModel($event)'></u-picker>
  25. </view>
  26. <view class="flex row">
  27. <view class="left-text">总质量(千克)</view>
  28. <u--input placeholder="输入总质量" inputAlign='left' border="none" v-model="dataDetails.carTotalWeight">
  29. </u--input>
  30. </view>
  31. <view class="flex row">
  32. <view class="left-text">核定载质量(千克)</view>
  33. <u--input placeholder="输入核定载质量" inputAlign='left' border="none" v-model="dataDetails.carApprovedWeight">
  34. </u--input>
  35. </view>
  36. <view class="flex row noborder">
  37. <view class="left-text">外廓尺寸</view>
  38. </view>
  39. <view class="flex row noborder input-ckg">
  40. <view class="input-positon">
  41. <u--input class="input" placeholder="长" inputAlign='left' border="none"
  42. v-model="dataDetails.carLong">
  43. </u--input>
  44. <view class="position-right">
  45. mm
  46. </view>
  47. </view>
  48. <view class="star">*</view>
  49. <view class="input-positon">
  50. <u--input placeholder="宽" inputAlign='left' border="none" v-model="dataDetails.carWidth">
  51. </u--input>
  52. <view class="position-right">
  53. mm
  54. </view>
  55. </view>
  56. <view class="star">*</view>
  57. <view class="input-positon">
  58. <u--input placeholder="高" inputAlign='left' border="none" v-model="dataDetails.carHeight">
  59. </u--input>
  60. <view class="position-right">
  61. mm
  62. </view>
  63. </view>
  64. </view>
  65. <view class="flex row noborder s-row">
  66. <view class="left-text" style="width: 100%;">人车合影(车头车牌号可见)</view>
  67. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)"
  68. @delete="deletePic" name="1" multiple :maxCount="1"></u-upload>
  69. <!-- <image class="preview" :src="item.addressUrl" mode="aspectFit"
  70. style="width:710rpx:height:710rpx;margin: 20rpx;"> -->
  71. <!-- <upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="1"
  72. :size-type="['compressed']" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
  73. @on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload> -->
  74. </view>
  75. </view>
  76. <view class="submit-btn" @click="submit">提交</view>
  77. <master-keyboard ref="keyboard" keyboardtype="car" :show="keyShow" :randomNumber="true" :newCar="false"
  78. :defaultValue="carNumber" @keyboardClick="handleClick"></master-keyboard>
  79. <u-toast ref="uToast"></u-toast>
  80. </view>
  81. </template>
  82. <script>
  83. import uploadImage from '@/components/ossutil/uploadFile.js';
  84. import keyboard from "@/components/master-keyboard/master-keyboard.vue";
  85. var _this;
  86. export default {
  87. data() {
  88. return {
  89. index:'',
  90. keyShow: false,
  91. carNumber: '',
  92. dataDetails: {},
  93. carModelColumns: [
  94. ['挂车', '非挂车'],
  95. ['高栏', '集装箱', '自卸车']
  96. ],
  97. carModelColumnData: [
  98. ['高栏', '集装箱', '自卸车'],
  99. ['重型仓栏']
  100. ],
  101. colorColumns: [
  102. ['黄色', '蓝色']
  103. ],
  104. carColor: false,
  105. carModel: false,
  106. fileList1:[]
  107. };
  108. },
  109. onLoad(options) {debugger
  110. _this = this;
  111. console.log(options)
  112. this.dataDetails = options
  113. this.fileList1 = [{
  114. url:options.addressUrl
  115. }]
  116. },
  117. methods: {
  118. // 车型切换
  119. changeCarModel(e) {
  120. const {
  121. columnIndex,
  122. index,
  123. // 微信小程序无法将picker实例传出来,只能通过ref操作
  124. picker = this.$refs.carTypePicker
  125. } = e
  126. if (columnIndex === 0) {
  127. // 模拟网络请求
  128. picker.setColumnValues(1, this.carModelColumnData[index])
  129. }
  130. },
  131. // 删除图片
  132. deletePic(event) {
  133. this[`fileList${event.name}`].splice(event.index, 1)
  134. },
  135. // 新增图片
  136. async afterRead(event) {
  137. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  138. let lists = [].concat(event.file)
  139. let fileListLen = this[`fileList${event.name}`].length
  140. lists.map((item) => {
  141. this[`fileList${event.name}`].push({
  142. ...item,
  143. status: 'uploading',
  144. message: '上传中'
  145. })
  146. })
  147. for (let i = 0; i < lists.length; i++) {
  148. const result = await this.uploadFilePromise(lists[i].url)
  149. let item = this[`fileList${event.name}`][fileListLen]
  150. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  151. status: 'success',
  152. message: '',
  153. url: result
  154. }))
  155. fileListLen++
  156. }
  157. },
  158. uploadFilePromise(url) {
  159. uploadImage(url, 'appData/',
  160. result => {
  161. // 上传成功回调函数
  162. console.log('图片地址', result)
  163. this.dataDetails.addressUrl += result
  164. }
  165. )
  166. },
  167. //车牌号弹出键盘
  168. handleShowKeyboard(index) {
  169. if (this.dataDetails.carNumber == '') {
  170. this.carNumber = ''
  171. } else {
  172. this.carNumber = this.dataDetails.carNumber
  173. }
  174. if (this.$refs.keyboard.open) {
  175. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  176. } else {
  177. this.$refs.keyboard[0].open(false)
  178. }
  179. this.index = index
  180. if (this.$refs.keyboard.open) {
  181. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  182. } else {
  183. this.$refs.keyboard[0].open(true)
  184. }
  185. },
  186. //车牌号弹出键盘
  187. handleClick(e) {
  188. this.carNumber = e.value
  189. this.dataDetails.carNumber = e.value //键盘输入值
  190. },
  191. confirmColor(val) {
  192. this.dataDetails.carNumberColour = val.value[0]
  193. this.carColor = false
  194. },
  195. colorClose() {
  196. this.carColor = false
  197. },
  198. selectNoColor() {
  199. this.carColor = true
  200. },
  201. confirmCarModel(val) {
  202. this.dataDetails.carType = val.value[0] + ' ' + val.value[1]
  203. this.carModel = false
  204. },
  205. carModelClose() {
  206. this.carModel = false
  207. },
  208. selectCarModel() {
  209. this.carModel = true
  210. },
  211. selectNoColor() {
  212. this.carColor = true
  213. },
  214. unloadGroupPhoto() {
  215. uni.chooseImage({
  216. count: 1,
  217. success: function(res) {
  218. console.log(JSON.stringify(res.tempFilePaths));
  219. uploadImage(res.tempFilePaths[0], 'appData/',
  220. result => {
  221. // 上传成功
  222. console.log('图片地址', result)
  223. }
  224. )
  225. }
  226. });
  227. },
  228. submit() {
  229. this.$request.baseRequest('post', '/driverCarInfo/api/editInfo', this.dataDetails).then(res => {
  230. if (res.code == '200') {
  231. let params = {
  232. type: 'success',
  233. message: "提交成功",
  234. }
  235. this.$refs.uToast.show({
  236. ...params
  237. })
  238. uni.$u.route('/pages/mine/manageVehicles/index');
  239. }else{
  240. uni.$u.toast(res.message);
  241. }
  242. })
  243. .catch(res => {
  244. uni.$u.toast(res.message);
  245. });
  246. },
  247. },
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .container {
  252. margin: 20rpx;
  253. background: white;
  254. padding: 0 20rpx;
  255. border-radius: 20rpx;
  256. .left-text {
  257. // background: red;
  258. width: 290rpx;
  259. color: #333333;
  260. display: flex;
  261. align-items: center;
  262. }
  263. .row {
  264. border-bottom: 1px solid #EEEEEE;
  265. padding-bottom: 28rpx;
  266. margin-top: 26rpx;
  267. .ch-style {}
  268. }
  269. .row-ch {
  270. padding-right: 250rpx;
  271. box-sizing: border-box;
  272. }
  273. }
  274. .input-ckg {
  275. height: 86rpx;
  276. margin-top: 0 !important;
  277. padding-bottom: 0 !important;
  278. .u-input {
  279. height: 100%;
  280. background: #F7F8FA;
  281. padding-left: 10rpx !important;
  282. padding-right: 85rpx !important;
  283. }
  284. .star {
  285. display: flex;
  286. align-items: center;
  287. margin: 0 10rpx;
  288. }
  289. .input-positon {
  290. position: relative;
  291. }
  292. .position-right {
  293. position: absolute;
  294. right: 20rpx;
  295. top: 0;
  296. width: 60rpx;
  297. height: 50rpx;
  298. bottom: 0;
  299. margin: auto;
  300. }
  301. }
  302. .picture {
  303. margin-top: 20rpx;
  304. background: #F5F6FA;
  305. width: 212rpx;
  306. height: 212rpx;
  307. border-radius: 10rpx;
  308. display: flex;
  309. flex-direction: column;
  310. justify-content: center;
  311. align-items: center;
  312. color: #6A7282;
  313. }
  314. .submit-btn {
  315. position: fixed;
  316. bottom: 40rpx;
  317. width: 90%;
  318. background: #2772FB;
  319. color: white;
  320. text-align: center;
  321. margin-left: 5%;
  322. padding: 30rpx 0;
  323. border-radius: 50rpx;
  324. }
  325. </style>