details.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view class="">
  3. <uni-nav-bar title="轮胎保注册信息" backgroundColor='#03803B' color="#fff" left-icon="left" fixed statusBar
  4. @clickLeft='goBack()' @clickRight="inItemDetail">
  5. <block slot="right" v-if='form.status>1'>
  6. <view>
  7. <uni-icons type="list" size="24" color='#fff'></uni-icons>
  8. </view>
  9. </block>
  10. </uni-nav-bar>
  11. <uni-section title="基本信息" style="padding: 0 62rpx;" titleColor="5F5F5F" titleFontSize="28rpx">
  12. <template v-slot:right>
  13. <text style="color: #5F5F5F;">
  14. {{form.insuranceNo}}
  15. </text>
  16. </template>
  17. <uni-forms ref="form1" :modelValue="form" :border="true">
  18. <uni-forms-item name="consumerName" label="联系人">
  19. <uni-easyinput v-model="form.consumerName" class="right-align" placeholder-class="placeholder-right"
  20. placeholder="请输入内容" :inputBorder="false" :disabled="form.status>1"></uni-easyinput>
  21. </uni-forms-item>
  22. <uni-forms-item name="consumerPhone" label="电话">
  23. <uni-easyinput v-model="form.consumerPhone" class="right-align"
  24. placeholder-class="placeholder-right" placeholder="请输入内容" :inputBorder="false"
  25. :disabled="form.status>1"></uni-easyinput>
  26. </uni-forms-item>
  27. <uni-forms-item name="vehicleNumber" label="车牌号">
  28. <uni-easyinput v-model="form.vehicleNumber" class="right-align"
  29. placeholder-class="placeholder-right" placeholder="请输入内容" :inputBorder="false"
  30. :disabled="form.status>1"></uni-easyinput>
  31. </uni-forms-item>
  32. <uni-forms-item name="tyreSpecs" label="规格型号">
  33. <uni-easyinput v-model="form.tyreSpecs" class="right-align" placeholder-class="placeholder-right"
  34. placeholder="请输入内容" :inputBorder="false" :disabled="form.status>1"></uni-easyinput>
  35. </uni-forms-item>
  36. <uni-forms-item name="tireQuantity" label="轮胎数量">
  37. <uni-easyinput v-model="form.tireQuantity" class="right-align" placeholder-class="placeholder-right"
  38. placeholder="请输入数量" :inputBorder="false" :disabled="form.status>1" type="number"
  39. @input="handleInput"></uni-easyinput>
  40. </uni-forms-item>
  41. <uni-forms-item name="insuranceTime" label="有效截至日期" label-width='80'>
  42. <view style="display: flex;justify-content: flex-end;align-items: center;height: 36px;">
  43. <text style="color: #B5B4B4;">
  44. {{form.insuranceTime}}
  45. </text>
  46. </view>
  47. </uni-forms-item>
  48. </uni-forms>
  49. </uni-section>
  50. <uni-section title="轮胎证据" style="padding: 0 62rpx 60rpx 62rpx;margin-top: 30rpx;" titleColor="5F5F5F"
  51. titleFontSize="28rpx">
  52. <view class="photo-upload">
  53. <view>
  54. <view class="photo-upload-text">示例照片</view>
  55. <view>
  56. <image class="photo-upload-img" src="@/static/images/home/insurance/em1.png" />
  57. </view>
  58. </view>
  59. <view>
  60. <view class="photo-upload-text" style="color: #B5B4B4;">上传车辆整体照片</view>
  61. <view class="photo-upload-upload">
  62. <uni-file-picker v-model="form.overallVehicle" return-type="object" limit="1" disable-preview
  63. :imageStyles="imageStyles" file-mediatype="image" @select="fileSelect1" @delete="fileDelete"
  64. @success='fileSuccess' @fail='fileFail' :readonly="form.status>1">
  65. <image class="photo-upload-img2" src="@/static/images/home/insurance/upload.png" />
  66. </uni-file-picker>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="photo-upload">
  71. <view>
  72. <view class="photo-upload-text">示例照片</view>
  73. <view>
  74. <image class="photo-upload-img" src="@/static/images/home/insurance/em2.png" />
  75. </view>
  76. </view>
  77. <view>
  78. <view class="photo-upload-text" style="color: #B5B4B4;">轮胎DOT</view>
  79. <view class="photo-upload-upload">
  80. <uni-file-picker v-model="form.tireDot" return-type="object" limit="1" disable-preview
  81. :imageStyles="imageStyles" file-mediatype="image" @select="fileSelect2" @delete="fileDelete"
  82. @success='fileSuccess' @fail='fileFail' :readonly="form.status>1">
  83. <image class="photo-upload-img2" src="@/static/images/home/insurance/upload.png" />
  84. </uni-file-picker>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="photo-upload">
  89. <view>
  90. <view class="photo-upload-text">示例照片</view>
  91. <view>
  92. <image class="photo-upload-img" src="@/static/images/home/insurance/em3.png" />
  93. </view>
  94. </view>
  95. <view>
  96. <view class="photo-upload-text" style="color: #B5B4B4;">花纹深度</view>
  97. <view class="photo-upload-upload">
  98. <uni-file-picker v-model="form.tirePattern" return-type="object" limit="1" disable-preview
  99. :imageStyles="imageStyles" file-mediatype="image" @select="fileSelect3" @delete="fileDelete"
  100. @success='fileSuccess' @fail='fileFail' :readonly="form.status>1">
  101. <image class="photo-upload-img2" src="@/static/images/home/insurance/upload.png" />
  102. </uni-file-picker>
  103. </view>
  104. </view>
  105. </view>
  106. </uni-section>
  107. <!-- <view style="height: 200rpx;display: flex;align-items: center;justify-content: center;">
  108. <button style="color:#ffffff;backgroundColor:#03803B;width: 400rpx;" @click="submit">提交材料</button>
  109. </view> -->
  110. <view style="height: 200rpx;display: flex;align-items: center;justify-content: center;">
  111. <button v-if="!form.id" style="color:#ffffff;backgroundColor:#03803B;width: 400rpx;"
  112. @click="submit">保存</button>
  113. <view v-if="form.status==1" style="display: flex;">
  114. <button
  115. style="color:#ffffff;backgroundColor:#03803B;width: 200rpx;border-top-right-radius:0rpx;border-bottom-right-radius:0rpx"
  116. @click="submit">保存</button>
  117. <button type="warn" v-if="form.status==1"
  118. style="color:#ffffff;width: 200rpx;border-top-left-radius:0rpx;border-bottom-left-radius:0rpx"
  119. @click="approval">提交</button>
  120. </view>
  121. <view v-if="form.status==2" style="display: flex;">
  122. <button type="warn" v-if="form.status==2" style="color:#ffffff;width: 400rpx;"
  123. @click="revoke">撤销</button>
  124. </view>
  125. </view>
  126. </view>
  127. </template>
  128. <script>
  129. import http from '@/http/api.js'
  130. import {
  131. clientId,
  132. clientSecret
  133. } from '@/common/setting'
  134. import {
  135. submit,
  136. getDetail,
  137. fileRemove,
  138. submitApproval,
  139. revokeApproval
  140. } from '@/api/home/insurance.js'
  141. export default {
  142. data() {
  143. return {
  144. form: {
  145. file1: {},
  146. file2: {},
  147. file3: {},
  148. file4: {},
  149. tireQuantity:0,
  150. claimAttachmentList: [],
  151. },
  152. imageStyles: {
  153. width: 145,
  154. height: 145,
  155. border: false,
  156. },
  157. mapObject: {
  158. text: 'name',
  159. value: 'code',
  160. children: 'children'
  161. },
  162. addressData: [],
  163. labelList: [],
  164. corpsTypeList: [],
  165. storeAttributesList: [],
  166. chainAttributeList: [],
  167. signingLevelList: []
  168. }
  169. },
  170. onLoad(option) {
  171. this.addressData = JSON.parse(uni.getStorageSync("addressData"))
  172. if (option && option.id) {
  173. this.getDetail(option.id)
  174. }
  175. },
  176. methods: {
  177. inItemDetail(){
  178. if(this.form.status>1){
  179. uni.navigateTo({
  180. url: '/pages/home/insurance/itemDetails?id=' + this.form.id,
  181. });
  182. }
  183. },
  184. handleInput(value) {
  185. const decimalRegex = /^-?\d+\.\d+$/ // 小数正则
  186. if (decimalRegex.test(value)) {
  187. uni.showToast({
  188. title: '请输入整数',
  189. icon: 'none'
  190. });
  191. }
  192. },
  193. removeByIdFilter(arr, id) {
  194. return arr.filter(item => item.id !== id);
  195. },
  196. fileDelete(row) {
  197. if (row.tempFile.id) {
  198. uni.showLoading({
  199. title: '加载中',
  200. mask: true
  201. });
  202. fileRemove(row.tempFile.id).then(res => {
  203. uni.showToast({
  204. title: '删除成功',
  205. icon: 'none'
  206. });
  207. this.form.claimAttachmentList = this.removeByIdFilter(this.form.claimAttachmentList, row
  208. .tempFile.id);
  209. }).finally(() => {
  210. uni.hideLoading()
  211. });
  212. }
  213. },
  214. getFileExtension(filename) {
  215. return filename.slice(((filename.lastIndexOf(".") - 1) >>> 0) + 2);
  216. },
  217. fileSelect1(files) {
  218. files.tempFiles.forEach(file => {
  219. uni.showLoading({
  220. title: '加载中',
  221. mask: true
  222. });
  223. uni.uploadFile({
  224. url: http.config.baseURL +
  225. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  226. filePath: file.path,
  227. header: {
  228. // 客户端认证参数
  229. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' + clientSecret),
  230. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  231. },
  232. name: 'file',
  233. success: (res) => {
  234. const data = JSON.parse(res.data).data
  235. this.form.overallVehicle = {
  236. url: data.link,
  237. name: data.originalName,
  238. extname: this.getFileExtension(data.originalName)
  239. }
  240. this.form.overallVehicleUrl = data.link
  241. uni.showToast({
  242. title: '上传成功',
  243. icon: 'none'
  244. });
  245. },
  246. fail: (err) => {
  247. uni.showToast({
  248. title: '上传失败',
  249. icon: 'none'
  250. });
  251. },
  252. complete: () => {
  253. uni.hideLoading()
  254. }
  255. })
  256. })
  257. },
  258. fileSelect2(files) {
  259. files.tempFiles.forEach(file => {
  260. uni.showLoading({
  261. title: '加载中',
  262. mask: true
  263. });
  264. uni.uploadFile({
  265. url: http.config.baseURL +
  266. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  267. filePath: file.path,
  268. header: {
  269. // 客户端认证参数
  270. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' + clientSecret),
  271. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  272. },
  273. name: 'file',
  274. success: (res) => {
  275. const data = JSON.parse(res.data).data
  276. this.form.tireDot = {
  277. url: data.link,
  278. name: data.originalName,
  279. extname: this.getFileExtension(data.originalName)
  280. }
  281. this.form.tireDotUrl = data.link
  282. uni.showToast({
  283. title: '上传成功',
  284. icon: 'none'
  285. });
  286. },
  287. fail: (err) => {
  288. uni.showToast({
  289. title: '上传失败',
  290. icon: 'none'
  291. });
  292. },
  293. complete: () => {
  294. uni.hideLoading()
  295. }
  296. })
  297. })
  298. },
  299. fileSelect3(files) {
  300. files.tempFiles.forEach(file => {
  301. uni.showLoading({
  302. title: '加载中',
  303. mask: true
  304. });
  305. uni.uploadFile({
  306. url: http.config.baseURL +
  307. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  308. filePath: file.path,
  309. header: {
  310. // 客户端认证参数
  311. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' + clientSecret),
  312. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  313. },
  314. name: 'file',
  315. success: (res) => {
  316. const data = JSON.parse(res.data).data
  317. this.form.tirePattern = {
  318. url: data.link,
  319. name: data.originalName,
  320. extname: this.getFileExtension(data.originalName)
  321. }
  322. this.form.tirePatternUrl = data.link
  323. uni.showToast({
  324. title: '上传成功',
  325. icon: 'none'
  326. });
  327. },
  328. fail: (err) => {
  329. uni.showToast({
  330. title: '上传失败',
  331. icon: 'none'
  332. });
  333. },
  334. complete: () => {
  335. uni.hideLoading()
  336. }
  337. })
  338. })
  339. },
  340. async submit() {
  341. if (!this.form.consumerName) {
  342. uni.showToast({
  343. title: '请输入联系人',
  344. icon: 'none'
  345. });
  346. return
  347. }
  348. if (!this.form.consumerPhone) {
  349. uni.showToast({
  350. title: '请输入电话',
  351. icon: 'none'
  352. });
  353. return
  354. }
  355. if (!this.form.vehicleNumber) {
  356. uni.showToast({
  357. title: '请输入车牌号',
  358. icon: 'none'
  359. });
  360. return
  361. }
  362. if (!this.form.tyreSpecs) {
  363. uni.showToast({
  364. title: '请输入规格型号',
  365. icon: 'none'
  366. });
  367. return
  368. }
  369. const decimalRegex = /^-?\d+\.\d+$/ // 小数正则
  370. if (!Number(this.form.tireQuantity)||decimalRegex.test(Number(this.form.tireQuantity))) {
  371. uni.showToast({
  372. title: '请正确输入轮胎数量',
  373. icon: 'none'
  374. });
  375. return
  376. }
  377. if (!this.form.overallVehicle) {
  378. uni.showToast({
  379. title: '请上传车辆整体照片',
  380. icon: 'none'
  381. });
  382. return
  383. }
  384. if (!this.form.tireDot) {
  385. uni.showToast({
  386. title: '请上传轮胎DOT',
  387. icon: 'none'
  388. });
  389. return
  390. }
  391. if (!this.form.tirePattern) {
  392. uni.showToast({
  393. title: '请上传花纹深度',
  394. icon: 'none'
  395. });
  396. return
  397. }
  398. let obj = await this.convertData(this.$deepClone(this.form))
  399. uni.showLoading({
  400. title: '加载中',
  401. mask: true
  402. });
  403. submit(obj).then(res => {
  404. setTimeout(() => {
  405. uni.showToast({
  406. title: '保存成功',
  407. icon: 'none',
  408. });
  409. }, 10);
  410. this.getDetail(res.data.id)
  411. })
  412. .finally(() => {
  413. uni.hideLoading()
  414. });
  415. },
  416. async approval() {
  417. let obj = await this.convertData(this.$deepClone(this.form))
  418. let _this = this
  419. uni.showModal({
  420. title: '提示',
  421. content: '是否提交?',
  422. success: function(res) {
  423. if (res.confirm) {
  424. uni.showLoading({
  425. title: '加载中',
  426. mask: true
  427. });
  428. submitApproval(obj).then(res => {
  429. setTimeout(() => {
  430. uni.showToast({
  431. title: '操作成功',
  432. icon: 'none',
  433. duration: 2000
  434. });
  435. }, 10);
  436. _this.getDetail(res.data.id)
  437. })
  438. .finally(() => {
  439. uni.hideLoading()
  440. });
  441. }
  442. }
  443. });
  444. },
  445. revoke() {
  446. let obj = {
  447. id: this.form.id
  448. }
  449. let _this = this
  450. uni.showModal({
  451. title: '提示',
  452. content: '是否撤销?',
  453. success: function(res) {
  454. if (res.confirm) {
  455. uni.showLoading({
  456. title: '加载中',
  457. mask: true
  458. });
  459. revokeApproval(obj).then(res => {
  460. setTimeout(() => {
  461. uni.showToast({
  462. title: '操作成功',
  463. icon: 'none',
  464. duration: 2000
  465. });
  466. }, 10);
  467. _this.getDetail(res.data.id)
  468. })
  469. .finally(() => {
  470. uni.hideLoading()
  471. });
  472. }
  473. }
  474. });
  475. },
  476. getDetail(id) {
  477. let obj = {
  478. id: id
  479. }
  480. uni.showLoading({
  481. title: '加载中',
  482. mask: true
  483. });
  484. getDetail(obj).then(res => {
  485. if (res.data.overallVehicle) {
  486. res.data.overallVehicle = JSON.parse(res.data.overallVehicle)
  487. }
  488. if (res.data.tireDot) {
  489. res.data.tireDot = JSON.parse(res.data.tireDot)
  490. }
  491. if (res.data.tirePattern) {
  492. res.data.tirePattern = JSON.parse(res.data.tirePattern)
  493. }
  494. this.form = res.data
  495. })
  496. .finally(() => {
  497. uni.hideLoading()
  498. });
  499. },
  500. async convertData(obj) {
  501. if (obj.overallVehicle) {
  502. obj.overallVehicle = JSON.stringify(obj.overallVehicle)
  503. }
  504. if (obj.tireDot) {
  505. obj.tireDot = JSON.stringify(obj.tireDot)
  506. }
  507. if (obj.tirePattern) {
  508. obj.tirePattern = JSON.stringify(obj.tirePattern)
  509. }
  510. return obj
  511. },
  512. goBack() {
  513. uni.navigateBack({
  514. delta: 1,
  515. });
  516. }
  517. }
  518. }
  519. </script>
  520. <style lang="scss" scoped>
  521. .right-align {
  522. text-align: right;
  523. }
  524. .photo {
  525. margin-left: 20rpx;
  526. width: 38rpx;
  527. height: 32rpx;
  528. }
  529. .photo-upload {
  530. display: flex;
  531. justify-content: space-around;
  532. margin-top: 45rpx;
  533. .photo-upload-text {
  534. font-weight: 400;
  535. font-size: 28rpx;
  536. color: #5F5F5F;
  537. line-height: 32rpx;
  538. text-align: center;
  539. margin-bottom: 15rpx;
  540. }
  541. .photo-upload-img {
  542. width: 280rpx;
  543. height: 280rpx;
  544. background: #D13B34;
  545. border-radius: 7rpx;
  546. }
  547. .photo-upload-upload {
  548. width: 280rpx;
  549. height: 280rpx;
  550. background: #F6F6F6;
  551. border-radius: 7rpx;
  552. display: flex;
  553. justify-content: center;
  554. align-items: center;
  555. .photo-upload-img2 {
  556. width: 219rpx;
  557. height: 219rpx;
  558. }
  559. }
  560. }
  561. ::v-deep .uni-file-picker__container {
  562. margin: 0 !important;
  563. }
  564. ::v-deep .file-picker__box-content {
  565. margin: 0 !important;
  566. }
  567. ::v-deep .file-picker__progress {
  568. display: none;
  569. }
  570. ::v-deep .uni-section .uni-section-header {
  571. font-weight: bold !important;
  572. padding: 12px 0px !important;
  573. border-bottom: 2px solid #F6F6F6;
  574. }
  575. .slot-content-item {
  576. border-radius: 13rpx;
  577. border: 2rpx solid #03803B;
  578. padding: 1rpx 5rpx;
  579. color: #03803B;
  580. }
  581. .slot-content-item-placeholder {
  582. font-weight: 400 !important;
  583. font-size: 28rpx !important;
  584. height: 38rpx !important;
  585. color: #B5B4B4 !important;
  586. }
  587. .slot-box {
  588. gap: 5px;
  589. display: flex;
  590. flex-wrap: wrap;
  591. justify-content: flex-end;
  592. }
  593. </style>