index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <view class="container">
  3. <uni-navbar :title="form.id?'修改车辆':'新增车辆'"></uni-navbar>
  4. <view class="box">
  5. <view class="reject-box commonRedBj commonMt" v-if="form.auditType===-1">
  6. <view class="reject-box-top">
  7. <image src="../../static/images/car/yunshu.png" mode="widthFix"></image>
  8. <text class="listTitle">审批状态</text>
  9. </view>
  10. <view class="reject-box-bottom">
  11. <view class="state-icon">
  12. <view class="flexAlignCenter">
  13. <view class="redCircle mCircle">
  14. </view>
  15. <text class="itemText">审批状态:</text>
  16. </view>
  17. <view class="flexAlignCenter">
  18. <u-icon color="#FB5637" name="close-circle-fill" style="margin-right: 12rpx;"></u-icon>
  19. <text class="redText">驳回</text>
  20. </view>
  21. </view>
  22. <view class="state-icon">
  23. <view class="flexAlignCenter">
  24. <view class="redCircle mCircle">
  25. </view>
  26. <text class="itemText">驳回原因:</text>
  27. </view>
  28. <view class="flexAlignCenter">
  29. <text class="redText">{{form.auditContent}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="registerBox commonBj" :class="form.auditType === -1?'':'commonMt'">
  35. <view class="reject-box-top" v-if="form.id">
  36. <view class="top-left">
  37. <image src="../../static/images/car/yunshu.png" mode="widthFix"></image>
  38. <text class="listTitle">车辆信息</text>
  39. </view>
  40. </view>
  41. <u--form :model="form" ref="uForm" :rules="rules" labelWidth="0" class='formStyle addHeight'>
  42. <u-form-item prop="companyName">
  43. <view class="redCircle"></view>
  44. <text class="itemText">企业名称</text>
  45. <u-input disabled disabledColor="rgba(73,91,147,0.2)" class="inputStyle"
  46. suffixIconStyle="color: #495B93" v-model="form.companyName" placeholder="" />
  47. </u-form-item>
  48. <u-form-item prop="carNumber">
  49. <view class="redCircle"></view>
  50. <text class="itemText">车牌号码</text>
  51. <u-input class="inputStyle" maxlength="10" v-model="form.carNumber" placeholder="请输入车牌号码" />
  52. </u-form-item>
  53. <u-form-item prop="carType">
  54. <view class="redCircle"></view>
  55. <text class="itemText">车&emsp;&emsp;型</text>
  56. <u-input class="inputStyle" maxlength="20" v-model="form.carType" placeholder="请输入品牌" />
  57. </u-form-item>
  58. <u-form-item prop="carSeries">
  59. <view class="redCircle"></view>
  60. <text class="itemText">车&emsp;&emsp;系</text>
  61. <u-input class="inputStyle" maxlength="20" v-model="form.carSeries" placeholder="请输入具体型号" />
  62. </u-form-item>
  63. <u-form-item prop="carCarry">
  64. <view class="redCircle"></view>
  65. <text class="itemText">载重标准</text>
  66. <u-input class="inputStyle" maxlength="10" v-model="form.carCarry" placeholder="请输入载重量" />
  67. </u-form-item>
  68. <u-form-item prop="drivingLicense">
  69. <view class="uploadBox">
  70. <view class="textBox ">
  71. <view class="redCircle"></view>
  72. <text class="itemText">车辆行驶证件</text>
  73. </view>
  74. <xfx-image-upload uploadTitle="车辆行驶证" uploadType="0" :max="1" :chooseNum="1"
  75. v-model="drivingLicense" @uploadSuccess="UploadSuccessTruckCertificate"
  76. @uploadFail="errorUploadruckCertificate" @imgDelete="delTruckCertificate"
  77. mediaType="image" :action="urlConfig">
  78. </xfx-image-upload>
  79. </view>
  80. </u-form-item>
  81. <u-form-item class="block-box1" prop="truckState">
  82. <view class="textBox">
  83. <view class="redCircle"></view>
  84. <text class="itemText">车辆状态(<text class="redText">拍摄车辆外观图片+视频</text>)</text>
  85. </view>
  86. <view class="textBox mt29 flex-start">
  87. <xfx-image-upload uploadType="1" :max="2" :chooseNum="2" v-model="imgList"
  88. @uploadSuccess="UploadSuccessStateImg" @uploadFail="errorTruckImg"
  89. @imgDelete="delTruckImg" mediaType="image" :action="urlConfig">
  90. </xfx-image-upload>
  91. <xfx-image-upload class="ml29" uploadType="2" :max="1" :chooseNum="1" v-model="carVideo"
  92. @uploadSuccess="UploadSuccessVideo" @uploadFail="errorTruckVideo" @imgDelete="delVideo"
  93. mediaType="video" :action="urlConfig">
  94. </xfx-image-upload>
  95. </view>
  96. </u-form-item>
  97. </u--form>
  98. </view>
  99. <u-button @click="submit" class="custom-style mt27 commonMb" shape="circle"
  100. color="linear-gradient(to top, #F59A02, #FFD334)">{{form.id?'确认修改车辆信息':'确认新增'}}</u-button>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import {
  106. addCar,
  107. carDetail,
  108. editCar
  109. } from "@/api/company/car.js"
  110. import {
  111. getInfo
  112. } from '../../api/login.js'
  113. import config from '@/config.js'
  114. import {
  115. uploadAvatar
  116. } from '../../api/company/user.js'
  117. export default {
  118. data() {
  119. return {
  120. drivingLicense: [],
  121. carVideo: [],
  122. imgList: [],
  123. // 图片上传地址
  124. urlConfig: '',
  125. // 行驶证数据
  126. form: {
  127. companyName: null,
  128. id: null,
  129. carNumber: null,
  130. carType: null,
  131. carSeries: null,
  132. carCarry: null,
  133. drivingLicense: [],
  134. truckState: {
  135. imgList: [],
  136. carVideo: [],
  137. },
  138. imgList: [],
  139. carVideo: [],
  140. companyId: null,
  141. },
  142. rules: {
  143. companyName: [{
  144. required: true,
  145. whitespace:true,
  146. message: '请输入企业名称',
  147. trigger: ['blur', 'change']
  148. }, ],
  149. carNumber: [{
  150. required: true,
  151. whitespace:true,
  152. message: '请输入车牌号码',
  153. trigger: ['blur', 'change']
  154. }, ],
  155. carType: [{
  156. required: true,
  157. whitespace:true,
  158. message: '请输入车型',
  159. trigger: ['blur', 'change']
  160. }, ],
  161. carSeries: [{
  162. required: true,
  163. whitespace:true,
  164. message: '请输入车系',
  165. trigger: ['blur', 'change']
  166. }, ],
  167. carCarry: [{
  168. required: true,
  169. whitespace:true,
  170. message: '请输入载重标准',
  171. trigger: ['blur', 'change']
  172. }, ],
  173. drivingLicense: [{
  174. required: true,
  175. message: '请上传车辆行驶证',
  176. // trigger: ['blur', 'change'],
  177. },
  178. {
  179. validator: (rule, value, callback) => {
  180. return value !== []
  181. },
  182. message: '请上传车辆行驶证'
  183. },
  184. ],
  185. truckState: [{
  186. required: true,
  187. // trigger: ['blur', 'change']
  188. },
  189. {
  190. validator: (rule, value, callback) => {
  191. return value.carVideo.length !== 0 && value.imgList.length === 2
  192. },
  193. message: '请上传两张车辆状态照片与一段视频'
  194. },
  195. ],
  196. },
  197. // 点击修改传回来的id
  198. id: '',
  199. srcVideo: '',
  200. }
  201. },
  202. methods: {
  203. select() {
  204. uni.requireNativePlugin('TX-VideoTool').getVideoThumbnailImage({
  205. "videoPath": this.srcVideo,
  206. "saveImagePath": plus.io.convertLocalFileSystemURL(
  207. "_doc/TXVideoTool/"),
  208. "saveImageName": "testLocal" + new Date().getTime() + ".png",
  209. "second": 0
  210. }, result => {
  211. console.log(result, '<---------------我是返回的数据')
  212. this.carVideo = [{
  213. cover: result.imagePath,
  214. url: this.srcVideo
  215. }]
  216. });
  217. },
  218. // 清空表单方法
  219. reset() {
  220. this.form = {
  221. id: null,
  222. carNumber: null,
  223. carType: null,
  224. carSeries: null,
  225. carCarry: null,
  226. drivingLicense: [],
  227. imgList: [],
  228. carVideo: [],
  229. truckState: {
  230. imgList: [],
  231. carVideo: [],
  232. }
  233. }
  234. this.drivingLicense = []
  235. this.imgList = []
  236. this.carVideo = []
  237. },
  238. //行驶证上传成功
  239. UploadSuccessTruckCertificate(res) {
  240. /****************
  241. 因为上传接口返回的结构不一致,所以以下代码需要根据实际的接口返回结构开发,在此只是展示如果给数组里添加的过程,仅供参考
  242. ***************/
  243. var _res = JSON.parse(res.data);
  244. console.log(_res);
  245. if (_res.code == 200) {
  246. this.form.drivingLicense.push(_res.data);
  247. this.drivingLicense.push(_res.data.url)
  248. }
  249. },
  250. // 行驶证删除图片行驶证
  251. delTruckCertificate(del, tempFilePaths) {
  252. console.log('111',
  253. del.tempFilePaths);
  254. this.drivingLicense = []
  255. this.form.drivingLicense = []
  256. },
  257. // 上传失败
  258. errorUploadruckCertificate(res) {},
  259. // 车辆状态图片上传成功
  260. UploadSuccessStateImg(res) {
  261. var _res = JSON.parse(res.data);
  262. console.log(_res.data, '_res.data');
  263. if (_res.code == 200) {
  264. // let obj = {}
  265. // obj.name = this.imgListName
  266. // obj.url = _res.data.url
  267. this.form.truckState.imgList.push(_res.data);
  268. this.form.imgList.push(_res.data);
  269. this.imgList.push(_res.data.url)
  270. }
  271. },
  272. // 车辆状态图片删除
  273. delTruckImg(del, tempFilePaths) {
  274. console.log('del', del);
  275. console.log('tempFilePaths', tempFilePaths);
  276. let obj = {}
  277. if (del.tempFilePaths.length !== 0) {
  278. obj.name = del.tempFilePaths[0].slice(50)
  279. obj.url = del.tempFilePaths[0]
  280. }
  281. this.imgList = del.tempFilePaths;
  282. this.form.imgList = this.form.imgList.filter(item => {
  283. return item.url === obj.url
  284. })
  285. this.form.truckState.imgList = this.form.truckState.imgList.filter(item => {
  286. return item.url === obj.url
  287. })
  288. },
  289. // 车辆图片上传失败的回调
  290. errorTruckImg(res) {},
  291. // 车辆视频上传成功Vedio
  292. UploadSuccessVideo(res, cover) {
  293. console.log(res);
  294. var _res = JSON.parse(res.data);
  295. console.log(_res, '_res');
  296. if (_res.code == 200) {
  297. this.form.truckState.carVideo.push(_res.data);
  298. this.form.carVideo.push(_res.data);
  299. this.srcVideo = _res.data.url;
  300. this.carVideo = [{
  301. url: this.srcVideo,
  302. cover: cover
  303. }]
  304. }
  305. },
  306. // 车辆视频删除回调
  307. delVideo(del, tempFilePaths) {
  308. this.carVideo = []
  309. this.form.carVideo = []
  310. this.form.truckState.carVideo = []
  311. },
  312. // 视频上传失败的回调
  313. errorTruckVideo(res) {},
  314. // 提交
  315. submit() {
  316. this.$refs.uForm.validate().then(async res => {
  317. this.form.auditType = 0
  318. if (this.form.id) {
  319. const res = await editCar(this.form)
  320. console.log(res);
  321. this.$tab.navigateBack()
  322. } else {
  323. let result = await addCar(this.form)
  324. this.$tab.navigateBack()
  325. }
  326. })
  327. },
  328. // 获取详情信息
  329. async getDetail(id) {
  330. const res = await carDetail(id)
  331. this.form = res.data
  332. this.drivingLicense.push(res.data.drivingLicense[0].url)
  333. this.form.truckState = {}
  334. this.form.truckState.imgList = []
  335. this.form.truckState.carVideo = []
  336. console.log(this.form, '<---------------我是获取到的数据');
  337. res.data.imgList.forEach(item => {
  338. this.imgList.push(item.url)
  339. this.form.truckState.imgList.push(item)
  340. })
  341. res.data.carVideo.forEach(item => {
  342. this.form.truckState.carVideo.push(item)
  343. })
  344. this.srcVideo = res.data.carVideo[0].url
  345. this.carVideo = [{
  346. url: this.srcVideo
  347. }]
  348. this.select()
  349. }
  350. },
  351. onLoad: function(option) {
  352. this.form.companyName = this.$store.state.user.companyName
  353. this.form.companyId = this.$store.state.user.companyId;
  354. if (option.id) {
  355. this.getDetail(option.id)
  356. }
  357. this.urlConfig = config.baseUrl + '/file/upload'
  358. }
  359. }
  360. </script>
  361. <style lang="scss" scoped>
  362. .uploadBox {
  363. /deep/.xfx-image-upload-list {
  364. height: 300rpx !important;
  365. .xfx-image-upload-Item-add {
  366. padding-top: 100rpx !important;
  367. }
  368. }
  369. }
  370. // 车辆状态上传图片
  371. .flex-start {
  372. justify-content: start;
  373. /deep/.xfx-image-upload-list {
  374. // border: 2rpx solid #495B93;
  375. // border-radius: 15rpx;
  376. // // width: 160rpx;
  377. // height: 160rpx;
  378. .xfx-image-upload-Item {
  379. width: 180rpx;
  380. height: 180rpx;
  381. margin-right: 0;
  382. margin-bottom: 0;
  383. border: 2rpx solid #495B93;
  384. border-radius: 15rpx;
  385. // background-color: rgba(255, 255, 255, 0.1);
  386. &:not(:first-child) {
  387. margin-left: 20rpx;
  388. }
  389. &:nth-child(1) {
  390. background-color: rgba(255, 255, 255, 0.1);
  391. }
  392. }
  393. .xfx-image-upload-Item-add {
  394. padding-top: 36rpx;
  395. .text-upload {
  396. margin-top: 0;
  397. }
  398. }
  399. }
  400. }
  401. // 上传组件样式
  402. .uploadBox {
  403. width: 100%;
  404. .u-upload__wrap__preview__image {
  405. width: 598rpx !important;
  406. height: 250rpx !important;
  407. border-radius: 13rpx;
  408. }
  409. /deep/.xfx-image-upload-list {
  410. display: block;
  411. margin-top: 30rpx;
  412. border: 2rpx solid #495B93;
  413. border-radius: 15rpx;
  414. height: 250rpx;
  415. .xfx-image-upload-Item {
  416. width: 100%;
  417. height: 100%;
  418. margin-right: 0;
  419. margin-bottom: 0;
  420. background-color: rgba(255, 255, 255, 0.1);
  421. }
  422. .xfx-image-upload-Item-add {
  423. padding-top: 84rpx;
  424. }
  425. }
  426. }
  427. .formStyle {
  428. padding: 41rpx 39rpx;
  429. }
  430. .registerBox {
  431. .reject-box-top {
  432. width: 100%;
  433. height: 69rpx;
  434. background: #7FB5FF;
  435. border-radius: 26rpx 26rpx 0px 0px;
  436. display: flex;
  437. justify-content: space-between;
  438. uni-image {
  439. width: 50rpx;
  440. margin-left: 32rpx;
  441. vertical-align: middle;
  442. }
  443. // .state-text {
  444. // font-size: 28rpx;
  445. // font-weight: bold;
  446. // color: #FFFFFF;
  447. // margin-left: 23rpx;
  448. // line-height: 69rpx;
  449. // }
  450. }
  451. }
  452. /deep/ .block-box1 .u-form-item__body__right__content__slot {
  453. display: block;
  454. }
  455. /deep/ .block-box1 .u-form-item__body {
  456. display: block;
  457. .u-form-item__body__right {
  458. // margin-top: 29rpx;
  459. .u-form-item__body__right__content__slot {
  460. align-items: start;
  461. .u-upload {
  462. display: block;
  463. flex: 0;
  464. // margin-right: 8rpx;
  465. .u-upload__wrap {
  466. flex-direction: row;
  467. flex-wrap: nowrap;
  468. justify-content: space-between;
  469. // width: 400rpx;
  470. .u-upload__wrap__preview {
  471. border-radius: 15rpx;
  472. overflow: visible;
  473. margin: 0 52rpx 0 0;
  474. &:nth-child(2) {
  475. margin-right: 26rpx !important;
  476. }
  477. .u-upload__wrap__preview__image {
  478. // border-radius: 15rpx !important;
  479. width: 167rpx !important;
  480. height: 167rpx !important;
  481. // border: 2rpx solid #495B93;
  482. }
  483. }
  484. .u-upload__button {
  485. background: rgba(255, 255, 255, 0.1);
  486. border: 1px solid #495B93;
  487. border-radius: 15px;
  488. }
  489. }
  490. }
  491. }
  492. }
  493. }
  494. .mt27 {
  495. margin-top: 27rpx;
  496. }
  497. .ml29 {
  498. margin-left: 20rpx;
  499. }
  500. .reject-box {
  501. // width: 88%;
  502. // height: 290rpx;
  503. margin-left: auto;
  504. margin-right: auto;
  505. margin-bottom: 28rpx;
  506. }
  507. .reject-box-top {
  508. width: 100%;
  509. height: 69rpx;
  510. background: #FB5637;
  511. border-radius: 26rpx 26rpx 0px 0px;
  512. uni-image {
  513. width: 50rpx;
  514. margin-left: 32rpx;
  515. vertical-align: middle;
  516. }
  517. // .state-text {
  518. // font-size: 28rpx;
  519. // font-weight: bold;
  520. // color: #FFFFFF;
  521. // margin-left: 23rpx;
  522. // line-height: 69rpx;
  523. // }
  524. }
  525. .reject-box-bottom {
  526. .state-icon {
  527. display: flex;
  528. margin: 40rpx;
  529. &:nth-child(2) {
  530. margin-bottom: 40rpx !important;
  531. }
  532. .state-icon-left {
  533. display: flex;
  534. // align-items: center;
  535. }
  536. .state-icon-right {
  537. display: flex;
  538. // align-items: center;
  539. }
  540. }
  541. }
  542. .textBox {
  543. display: flex;
  544. align-items: center;
  545. }
  546. .mt29 {
  547. margin-top: 29rpx;
  548. }
  549. .mt {
  550. margin-top: 31rpx;
  551. font-size: 28rpx;
  552. font-weight: 400;
  553. color: #495B93;
  554. }
  555. </style>