editVehicle.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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.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) {
  110. _this = this;
  111. console.log(options)
  112. this.dataDetails = options
  113. this.fileList1 = [{
  114. url:options.addressUrl
  115. }]
  116. },
  117. methods: {
  118. focus(e){
  119. console.log('11111')
  120. console.log(e)
  121. },
  122. blur(e){
  123. console.log(e)
  124. },
  125. // 车型切换
  126. changeCarModel(e) {
  127. const {
  128. columnIndex,
  129. index,
  130. // 微信小程序无法将picker实例传出来,只能通过ref操作
  131. picker = this.$refs.carTypePicker
  132. } = e
  133. if (columnIndex === 0) {
  134. // 模拟网络请求
  135. picker.setColumnValues(1, this.carModelColumnData[index])
  136. }
  137. },
  138. // 删除图片
  139. deletePic(event) {
  140. this[`fileList${event.name}`].splice(event.index, 1)
  141. },
  142. // 新增图片
  143. async afterRead(event) {
  144. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  145. let lists = [].concat(event.file)
  146. let fileListLen = this[`fileList${event.name}`].length
  147. lists.map((item) => {
  148. this[`fileList${event.name}`].push({
  149. ...item,
  150. status: 'uploading',
  151. message: '上传中'
  152. })
  153. })
  154. for (let i = 0; i < lists.length; i++) {
  155. const result = await this.uploadFilePromise(lists[i].url)
  156. let item = this[`fileList${event.name}`][fileListLen]
  157. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  158. status: 'success',
  159. message: '',
  160. url: result
  161. }))
  162. fileListLen++
  163. }
  164. },
  165. uploadFilePromise(url) {
  166. uploadImage(url, 'appData/',
  167. result => {
  168. // 上传成功回调函数
  169. console.log('图片地址', result)
  170. this.dataDetails.addressUrl += result
  171. }
  172. )
  173. },
  174. //车牌号弹出键盘
  175. handleShowKeyboard(index) {
  176. if (this.dataDetails.carNumber == '') {
  177. this.carNumber = ''
  178. } else {
  179. this.carNumber = this.dataDetails.carNumber
  180. }
  181. if (this.$refs.keyboard.open) {
  182. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  183. } else {
  184. this.$refs.keyboard[0].open(false)
  185. }
  186. this.index = index
  187. if (this.$refs.keyboard.open) {
  188. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  189. } else {
  190. this.$refs.keyboard[0].open(true)
  191. }
  192. },
  193. //车牌号弹出键盘
  194. handleClick(e) {
  195. this.carNumber = e.value
  196. this.dataDetails.carNumber = e.value //键盘输入值
  197. },
  198. confirmColor(val) {
  199. this.dataDetails.carNumberColour = val.value[0]
  200. this.carColor = false
  201. },
  202. colorClose() {
  203. this.carColor = false
  204. },
  205. selectNoColor() {
  206. this.carColor = true
  207. },
  208. confirmCarModel(val) {
  209. this.dataDetails.carType = val.value[0] + ' ' + val.value[1]
  210. this.carModel = false
  211. },
  212. carModelClose() {
  213. this.carModel = false
  214. },
  215. selectCarModel() {
  216. this.carModel = true
  217. },
  218. selectNoColor() {
  219. this.carColor = true
  220. },
  221. unloadGroupPhoto() {
  222. uni.chooseImage({
  223. count: 1,
  224. success: function(res) {
  225. console.log(JSON.stringify(res.tempFilePaths));
  226. uploadImage(res.tempFilePaths[0], 'appData/',
  227. result => {
  228. // 上传成功
  229. console.log('图片地址', result)
  230. }
  231. )
  232. }
  233. });
  234. },
  235. submit() {
  236. this.$request.baseRequest('post', '/driverCarInfo/api/editInfo', this.dataDetails).then(res => {
  237. if (res.code == '200') {
  238. let params = {
  239. type: 'success',
  240. message: "提交成功",
  241. }
  242. this.$refs.uToast.show({
  243. ...params
  244. })
  245. uni.$u.route('/pages/mine/manageVehicles/index');
  246. }else{
  247. uni.$u.toast(res.message);
  248. }
  249. })
  250. .catch(res => {
  251. uni.$u.toast(res.message);
  252. });
  253. },
  254. },
  255. }
  256. </script>
  257. <style lang="scss" scoped>
  258. .container {
  259. margin: 20rpx;
  260. background: white;
  261. padding: 0 20rpx;
  262. border-radius: 20rpx;
  263. .left-text {
  264. // background: red;
  265. width: 290rpx;
  266. color: #333333;
  267. display: flex;
  268. align-items: center;
  269. }
  270. .row {
  271. border-bottom: 1px solid #EEEEEE;
  272. padding-bottom: 28rpx;
  273. margin-top: 26rpx;
  274. .ch-style {}
  275. }
  276. .row-ch {
  277. padding-right: 250rpx;
  278. box-sizing: border-box;
  279. }
  280. }
  281. .input-ckg {
  282. height: 86rpx;
  283. margin-top: 0 !important;
  284. padding-bottom: 0 !important;
  285. .u-input {
  286. height: 100%;
  287. background: #F7F8FA;
  288. padding-left: 10rpx !important;
  289. padding-right: 85rpx !important;
  290. }
  291. .star {
  292. display: flex;
  293. align-items: center;
  294. margin: 0 10rpx;
  295. }
  296. .input-positon {
  297. position: relative;
  298. }
  299. .position-right {
  300. position: absolute;
  301. right: 20rpx;
  302. top: 0;
  303. width: 60rpx;
  304. height: 50rpx;
  305. bottom: 0;
  306. margin: auto;
  307. }
  308. }
  309. .picture {
  310. margin-top: 20rpx;
  311. background: #F5F6FA;
  312. width: 212rpx;
  313. height: 212rpx;
  314. border-radius: 10rpx;
  315. display: flex;
  316. flex-direction: column;
  317. justify-content: center;
  318. align-items: center;
  319. color: #6A7282;
  320. }
  321. .submit-btn {
  322. position: fixed;
  323. bottom: 40rpx;
  324. width: 90%;
  325. background: #2772FB;
  326. color: white;
  327. text-align: center;
  328. margin-left: 5%;
  329. padding: 30rpx 0;
  330. border-radius: 50rpx;
  331. }
  332. </style>