editVehicle.vue 9.2 KB

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