add.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. <template>
  2. <view class="page-container">
  3. <view class="page-body">
  4. <u--form label-width="auto" labelAlign="left"
  5. ref="uForm"
  6. :model="model"
  7. :rules="rules"
  8. :labelStyle="{
  9. fontSize: '28rpx',
  10. fontWeight: '500',
  11. }"
  12. >
  13. <u-cell-group :border="false">
  14. <view class="box">
  15. <template v-if="hasPlat(['sanitation'])">
  16. <u-cell :border="true" :isLink="true" :clickable="false" class="hidde-cell-title"
  17. @click="$refs.coverageRef.show()"
  18. >
  19. <view slot="value" class="value">
  20. <u-form-item label="所属行政区" prop="form.areaCode" :required="true">
  21. <u--input
  22. :value="model.form.areaName"
  23. placeholder="请选择"
  24. border="none"
  25. inputAlign="right"
  26. :disabled="true"
  27. disabledColor="none"
  28. :customStyle="{
  29. pointerEvents: 'none',
  30. }"
  31. >
  32. </u--input>
  33. </u-form-item>
  34. </view>
  35. </u-cell>
  36. <tq-area-coverage ref="coverageRef"
  37. @confirm="(data) => {
  38. model.form.areaCode = data.code
  39. model.form.areaName = data.areaName
  40. }"
  41. >
  42. </tq-area-coverage>
  43. </template>
  44. <template>
  45. <u-cell :border="true" :isLink="true" :clickable="false" class="hidde-cell-title"
  46. @click="$refs.deptChooseRef.show()"
  47. >
  48. <view slot="value" class="value">
  49. <u-form-item label="所属单位" prop="form.deptId" :required="true">
  50. <u--input
  51. :value="model.form.deptName"
  52. placeholder="请选择"
  53. border="none"
  54. inputAlign="right"
  55. :disabled="true"
  56. disabledColor="none"
  57. :customStyle="{
  58. pointerEvents: 'none',
  59. }"
  60. >
  61. </u--input>
  62. </u-form-item>
  63. </view>
  64. </u-cell>
  65. <tq-dept ref="deptChooseRef"
  66. @confirm="(data) => {
  67. model.form.deptId = data.deptId
  68. model.form.deptName = data.deptName
  69. }"
  70. >
  71. </tq-dept>
  72. </template>
  73. <template>
  74. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  75. <view slot="value" class="value">
  76. <u-form-item label="车牌号" prop="form.plate" :required="true">
  77. <u--input
  78. v-model="model.form.plate"
  79. placeholder="请输入"
  80. border="none"
  81. type="text"
  82. :clearable="true"
  83. inputAlign="right"
  84. maxlength="10"
  85. >
  86. </u--input>
  87. </u-form-item>
  88. </view>
  89. </u-cell>
  90. </template>
  91. <template>
  92. <u-cell :border="true" :isLink="true" :clickable="false" class="hidde-cell-title"
  93. @click="$refs.workTypeRef.show()"
  94. >
  95. <view slot="value" class="value">
  96. <u-form-item label="作业类型" prop="form.workId" :required="true">
  97. <u--input
  98. :value="model.form.workName"
  99. placeholder="请选择"
  100. border="none"
  101. inputAlign="right"
  102. :disabled="true"
  103. disabledColor="none"
  104. :customStyle="{
  105. pointerEvents: 'none',
  106. }"
  107. >
  108. </u--input>
  109. </u-form-item>
  110. </view>
  111. </u-cell>
  112. <tq-work-type ref="workTypeRef"
  113. @confirm="(data) => {
  114. model.form.workId = data.id
  115. model.form.workName = data.name
  116. }"
  117. >
  118. </tq-work-type>
  119. </template>
  120. <template>
  121. <u-cell :border="true" :isLink="true" :clickable="false" class="hidde-cell-title"
  122. @click="$refs.vehTypeRef.show()"
  123. >
  124. <view slot="value" class="value">
  125. <u-form-item label="车辆类型" prop="form.vehType" :required="true">
  126. <u--input
  127. :value="model.form.vehTypeName"
  128. placeholder="请选择"
  129. border="none"
  130. inputAlign="right"
  131. :disabled="true"
  132. disabledColor="none"
  133. :customStyle="{
  134. pointerEvents: 'none',
  135. }"
  136. >
  137. </u--input>
  138. </u-form-item>
  139. </view>
  140. </u-cell>
  141. <tq-select ref="vehTypeRef"
  142. :workTypeId="model.form.workId"
  143. api="dropDown"
  144. @confirm="(data) => {
  145. model.form.vehType = data.value
  146. model.form.vehTypeName = data.label
  147. }"
  148. >
  149. </tq-select>
  150. </template>
  151. <template>
  152. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  153. <view slot="value" class="value">
  154. <u-form-item label="车辆载重" prop="form.loadWeight" :required="false">
  155. <u--input
  156. v-model="model.form.loadWeight"
  157. placeholder="请输入"
  158. border="none"
  159. type="number"
  160. :clearable="true"
  161. inputAlign="right"
  162. maxlength="10"
  163. >
  164. </u--input>
  165. </u-form-item>
  166. </view>
  167. </u-cell>
  168. </template>
  169. <template>
  170. <u-cell title="绑定驾驶员" :border="true" :isLink="true" :clickable="false"
  171. @click="$refs.userChooseRef.show()"
  172. >
  173. <view slot="value">
  174. <u-form-item label="">
  175. <u--input
  176. :value="model.form.driverName"
  177. placeholder="请选择"
  178. border="none"
  179. inputAlign="right"
  180. :disabled="true"
  181. disabledColor="none"
  182. :customStyle="{
  183. pointerEvents: 'none',
  184. }"
  185. >
  186. </u--input>
  187. </u-form-item>
  188. </view>
  189. </u-cell>
  190. <tq-car-user ref="userChooseRef"
  191. :isGetIcon="false"
  192. :queryType="3"
  193. @confirm="(data) => {
  194. model.form.driverId = data.id
  195. model.form.driverName = data.label
  196. }"
  197. >
  198. </tq-car-user>
  199. </template>
  200. <template>
  201. <u-cell :border="true" :isLink="true" :clickable="true" class="hidde-cell-title"
  202. @click="$refs.selectRef.show()"
  203. >
  204. <view slot="value" class="value">
  205. <u-form-item label="车辆使用状态" prop="form.useStatus" :required="false">
  206. <u--input
  207. :value="model.form.useStatusName"
  208. placeholder="请选择"
  209. border="none"
  210. inputAlign="right"
  211. :disabled="true"
  212. disabledColor="none"
  213. :customStyle="{
  214. pointerEvents: 'none',
  215. }"
  216. >
  217. </u--input>
  218. </u-form-item>
  219. </view>
  220. </u-cell>
  221. <tq-dict-select ref="selectRef"
  222. dictType="vehicle_use_sts"
  223. @confirm="(data) => {
  224. model.form.useStatus = data.dictValue
  225. model.form.useStatusName = data.dictLabel
  226. $refs.uForm.validateField('form.useStatus')
  227. }"
  228. >
  229. </tq-dict-select>
  230. </template>
  231. <template v-if="hasPlat(['enterprises'])">
  232. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  233. <view slot="value" class="value">
  234. <u-form-item label="品牌" prop="form.vehBrand" :required="false">
  235. <u--input
  236. v-model="model.form.vehBrand"
  237. placeholder="请输入"
  238. border="none"
  239. type="text"
  240. :clearable="true"
  241. inputAlign="right"
  242. maxlength="20"
  243. >
  244. </u--input>
  245. </u-form-item>
  246. </view>
  247. </u-cell>
  248. </template>
  249. <template v-if="hasPlat(['enterprises'])">
  250. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  251. <view slot="value" class="value">
  252. <u-form-item label="车辆颜色" prop="form.vehColor" :required="false">
  253. <u--input
  254. v-model="model.form.vehColor"
  255. placeholder="请输入"
  256. border="none"
  257. type="text"
  258. :clearable="true"
  259. inputAlign="right"
  260. maxlength="20"
  261. >
  262. </u--input>
  263. </u-form-item>
  264. </view>
  265. </u-cell>
  266. </template>
  267. <template v-if="hasPlat(['enterprises'])">
  268. <u-cell title="" :border="true" :isLink="true" class="hidde-cell-title"
  269. @click="$refs.buyTimeRef.show()"
  270. >
  271. <view slot="value" class="value">
  272. <u-form-item label="购置时间" prop="form.buyTime" :required="false">
  273. <u--input
  274. :value="model.form.buyTime"
  275. placeholder="请选择"
  276. border="none"
  277. inputAlign="right"
  278. :disabled="true"
  279. disabledColor="none"
  280. :customStyle="{
  281. pointerEvents: 'none',
  282. }"
  283. >
  284. </u--input>
  285. </u-form-item>
  286. </view>
  287. </u-cell>
  288. <tq-date-time ref="buyTimeRef"
  289. mode="date"
  290. format="YYYY-MM-DD"
  291. @confirm="(data) => {
  292. model.form.buyTime = data
  293. }"
  294. >
  295. </tq-date-time>
  296. </template>
  297. <u-cell :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
  298. <view slot="value" class="value">
  299. <u-form-item label="备注" labelPosition="top" prop="form.remark" :required="false">
  300. <u--textarea
  301. v-model="model.form.remark"
  302. placeholder="请输入备注"
  303. border="none"
  304. :count="true"
  305. maxlength="200"
  306. >
  307. </u--textarea>
  308. </u-form-item>
  309. </view>
  310. </u-cell>
  311. <u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
  312. <view slot="value" class="value">
  313. <u-form-item label="上传照片" labelPosition="top" prop="form.imageUrl" :required="true">
  314. <view slot="label" class="item-label">
  315. <view class="item-label-left">
  316. <!-- <text>*</text> -->
  317. 车辆照片
  318. </view>
  319. <view class="item-label-right">{{model.form.imageUrl?model.form.imageUrl.split(',').length:0}}/1</view>
  320. </view>
  321. <view style="margin-top: 30rpx;">
  322. <tq-upload-img
  323. v-model="model.form.imageUrl"
  324. :maxCount="1"
  325. width="80"
  326. height="80"
  327. uploadText=""
  328. >
  329. </tq-upload-img>
  330. </view>
  331. </u-form-item>
  332. </view>
  333. </u-cell>
  334. </view>
  335. <view class="box">
  336. <template>
  337. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  338. <view slot="value" class="value">
  339. <u-form-item label="行驶证号" prop="form.drivingPermitCode" :required="false">
  340. <u--input
  341. v-model="model.form.drivingPermitCode"
  342. placeholder="请输入"
  343. border="none"
  344. type="text"
  345. :clearable="true"
  346. inputAlign="right"
  347. maxlength="20"
  348. >
  349. </u--input>
  350. </u-form-item>
  351. </view>
  352. </u-cell>
  353. </template>
  354. <template>
  355. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  356. <view slot="value" class="value">
  357. <u-form-item label="道路运输证号" prop="form.transportCode" :required="false">
  358. <u--input
  359. v-model="model.form.transportCode"
  360. placeholder="请输入"
  361. border="none"
  362. type="text"
  363. :clearable="true"
  364. inputAlign="right"
  365. maxlength="20"
  366. >
  367. </u--input>
  368. </u-form-item>
  369. </view>
  370. </u-cell>
  371. </template>
  372. <template>
  373. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  374. <view slot="value" class="value">
  375. <u-form-item label="每行走里程保养(km)" prop="form.intervalMile" :required="false">
  376. <u--input
  377. v-model="model.form.intervalMile"
  378. placeholder="请输入"
  379. border="none"
  380. type="number"
  381. :clearable="true"
  382. inputAlign="right"
  383. maxlength="10"
  384. >
  385. </u--input>
  386. </u-form-item>
  387. </view>
  388. </u-cell>
  389. </template>
  390. <template>
  391. <u-cell title="" :border="true" :isLink="false" :clickable="false" class="hidde-cell-title">
  392. <view slot="value" class="value">
  393. <u-form-item label="初始里程(km)" prop="form.startMile" :required="false">
  394. <u--input
  395. v-model="model.form.startMile"
  396. placeholder="请输入"
  397. border="none"
  398. type="number"
  399. :clearable="true"
  400. inputAlign="right"
  401. maxlength="10"
  402. >
  403. </u--input>
  404. </u-form-item>
  405. </view>
  406. </u-cell>
  407. </template>
  408. <template>
  409. <u-cell title="" :border="true" :isLink="true" class="hidde-cell-title"
  410. @click="$refs.maintainRef.show()"
  411. >
  412. <view slot="value" class="value">
  413. <u-form-item label="保养到期" prop="form.maintain" :required="false">
  414. <u--input
  415. :value="model.form.maintain"
  416. placeholder="请选择"
  417. border="none"
  418. inputAlign="right"
  419. :disabled="true"
  420. disabledColor="none"
  421. :customStyle="{
  422. pointerEvents: 'none',
  423. }"
  424. >
  425. </u--input>
  426. </u-form-item>
  427. </view>
  428. </u-cell>
  429. <tq-date-time ref="maintainRef"
  430. mode="date"
  431. format="YYYY-MM-DD"
  432. @confirm="(data) => {
  433. model.form.maintain = data
  434. }"
  435. >
  436. </tq-date-time>
  437. </template>
  438. <template>
  439. <u-cell title="" :border="true" :isLink="true" class="hidde-cell-title"
  440. @click="$refs.bxDateRef.show()"
  441. >
  442. <view slot="value" class="value">
  443. <u-form-item label="保险到期" prop="form.bxDate" :required="false">
  444. <u--input
  445. :value="model.form.maintain"
  446. placeholder="请选择"
  447. border="none"
  448. inputAlign="right"
  449. :disabled="true"
  450. disabledColor="none"
  451. :customStyle="{
  452. pointerEvents: 'none',
  453. }"
  454. >
  455. </u--input>
  456. </u-form-item>
  457. </view>
  458. </u-cell>
  459. <tq-date-time ref="bxDateRef"
  460. mode="date"
  461. format="YYYY-MM-DD"
  462. @confirm="(data) => {
  463. model.form.bxDate = data
  464. }"
  465. >
  466. </tq-date-time>
  467. </template>
  468. <template>
  469. <u-cell title="" :border="true" :isLink="true" class="hidde-cell-title"
  470. @click="$refs.yearCheckRef.show()"
  471. >
  472. <view slot="value" class="value">
  473. <u-form-item label="年检到期" prop="form.bxDate" :required="false">
  474. <u--input
  475. :value="model.form.yearCheck"
  476. placeholder="请选择"
  477. border="none"
  478. inputAlign="right"
  479. :disabled="true"
  480. disabledColor="none"
  481. :customStyle="{
  482. pointerEvents: 'none',
  483. }"
  484. >
  485. </u--input>
  486. </u-form-item>
  487. </view>
  488. </u-cell>
  489. <tq-date-time ref="yearCheckRef"
  490. mode="date"
  491. format="YYYY-MM-DD"
  492. @confirm="(data) => {
  493. model.form.yearCheck = data
  494. }"
  495. >
  496. </tq-date-time>
  497. </template>
  498. <template>
  499. <u-cell title="" :border="true" :isLink="true" class="hidde-cell-title"
  500. @click="$refs.serviceDateRef.show()"
  501. >
  502. <view slot="value" class="value">
  503. <u-form-item label="服务到期" prop="form.bxDate" :required="false">
  504. <u--input
  505. :value="model.form.serviceDate"
  506. placeholder="请选择"
  507. border="none"
  508. inputAlign="right"
  509. :disabled="true"
  510. disabledColor="none"
  511. :customStyle="{
  512. pointerEvents: 'none',
  513. }"
  514. >
  515. </u--input>
  516. </u-form-item>
  517. </view>
  518. </u-cell>
  519. <tq-date-time ref="serviceDateRef"
  520. mode="date"
  521. format="YYYY-MM-DD"
  522. @confirm="(data) => {
  523. model.form.serviceDate = data
  524. }"
  525. >
  526. </tq-date-time>
  527. </template>
  528. <u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
  529. <view slot="value" class="value">
  530. <u-form-item label="" labelPosition="top" prop="form.drivingPermitUrl" :required="true">
  531. <view slot="label" class="item-label">
  532. <view class="item-label-left">
  533. <!-- <text>*</text> -->
  534. 行驶证扫描件
  535. </view>
  536. <view class="item-label-right">{{model.form.drivingPermitUrl?model.form.drivingPermitUrl.split(',').length:0}}/1</view>
  537. </view>
  538. <view style="margin-top: 30rpx;">
  539. <tq-upload-img
  540. v-model="model.form.drivingPermitUrl"
  541. :maxCount="1"
  542. width="80"
  543. height="80"
  544. uploadText=""
  545. >
  546. </tq-upload-img>
  547. </view>
  548. </u-form-item>
  549. </view>
  550. </u-cell>
  551. <u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
  552. <view slot="value" class="value">
  553. <u-form-item label="" labelPosition="top" prop="form.transportFileUrl" :required="true">
  554. <view slot="label" class="item-label">
  555. <view class="item-label-left">
  556. <!-- <text>*</text> -->
  557. 道路运输证扫描件
  558. </view>
  559. <view class="item-label-right">{{model.form.transportFileUrl?model.form.transportFileUrl.split(',').length:0}}/1</view>
  560. </view>
  561. <view style="margin-top: 30rpx;">
  562. <tq-upload-img
  563. v-model="model.form.transportFileUrl"
  564. :maxCount="1"
  565. width="80"
  566. height="80"
  567. uploadText=""
  568. >
  569. </tq-upload-img>
  570. </view>
  571. </u-form-item>
  572. </view>
  573. </u-cell>
  574. </view>
  575. </u-cell-group>
  576. </u--form>
  577. </view>
  578. <view class="page-footer">
  579. <u-row style="margin-top: 40rpx;">
  580. <u-col :span="6">
  581. <u-button type="info" shape="" :hairline="false" :custom-style="{
  582. width: '100%',
  583. borderRadius: '0',
  584. background: '#FFF',
  585. height: '100rpx',
  586. fontSize: '32rpx',
  587. fontWeight: '500',
  588. }" @click="handleClear">返回
  589. </u-button>
  590. </u-col>
  591. <u-col :span="6">
  592. <u-button type="primary" shape="" :hairline="false"
  593. :custom-style="{
  594. width: '100%',
  595. borderRadius: '0',
  596. height: '100rpx',
  597. fontSize: '32rpx',
  598. fontWeight: '500',
  599. background:'linear-gradient(to right, #41B5FF, #4573FC)'
  600. }" @click="handleSubmit">提交
  601. </u-button>
  602. </u-col>
  603. </u-row>
  604. </view>
  605. </view>
  606. </template>
  607. <script>
  608. import {userProfile} from '@/api/common/user.js'
  609. import {add,update,getDetail} from '@/api/system/vehicle.js'
  610. import {clearProps,copyProps} from '@/utils/gdtq.js'
  611. import {isEmpty} from 'lodash'
  612. export default {
  613. components: {
  614. },
  615. data() {
  616. return {
  617. model: {
  618. form: {
  619. vehicleId: "",
  620. areaCode: "",
  621. areaName: "",
  622. deptId: "",
  623. deptName: "",
  624. plate: '',
  625. workId: '',
  626. workName: '',
  627. vehType: '',
  628. vehTypeName: '',
  629. loadWeight: '',
  630. driverId: "",
  631. driverName: "",
  632. useStatus: "",
  633. useStatusName: "",
  634. vehBrand: "",
  635. vehColor: "",
  636. buyTime: "",
  637. remark: "",
  638. imageUrl: "",
  639. drivingPermitCode: "",
  640. transportCode: "",
  641. intervalMile: "",
  642. startMile: "",
  643. maintain: "",
  644. bxDate: "",
  645. yearCheck: "",
  646. serviceDate: "",
  647. serviceDate: "",
  648. drivingPermitUrl: "",
  649. transportFileUrl: "",
  650. }
  651. },
  652. rules: {
  653. 'form.areaCode': [
  654. {
  655. type: 'string',
  656. required: true,
  657. message: '请选择所属行政区',
  658. trigger: ['blur', 'change']
  659. },
  660. ],
  661. 'form.deptId': [
  662. {
  663. type: 'string',
  664. required: true,
  665. message: '请选择所属单位',
  666. trigger: ['blur', 'change']
  667. },
  668. ],
  669. 'form.plate': [
  670. {
  671. type: 'string',
  672. required: true,
  673. message: '请输入车牌号',
  674. trigger: ['blur', 'change']
  675. },
  676. ],
  677. 'form.workId': [
  678. {
  679. type: 'string',
  680. required: true,
  681. message: '请选择作业类型',
  682. trigger: ['blur', 'change']
  683. },
  684. ],
  685. 'form.vehType': [
  686. {
  687. type: 'number',
  688. required: true,
  689. message: '请选择车辆类型',
  690. trigger: ['blur', 'change']
  691. },
  692. ],
  693. 'form.loadWeight': [
  694. {
  695. pattern: /^\d+(\.\d{1,2})?$/,
  696. // 正则检验前先将值转为字符串
  697. transform(value) {
  698. return value?String(value):0;
  699. },
  700. message: '车辆载重需为正数且最多两位小数',
  701. // 触发器可以同时用blur和change
  702. trigger: ['change','blur'],
  703. }
  704. ],
  705. 'form.intervalMile': [
  706. {
  707. pattern: /^\d+(\.\d{1,2})?$/,
  708. // 正则检验前先将值转为字符串
  709. transform(value) {
  710. return value?String(value):0;
  711. },
  712. message: '里程需为正数且最多两位小数',
  713. // 触发器可以同时用blur和change
  714. trigger: ['change','blur'],
  715. }
  716. ],
  717. 'form.startMile': [
  718. {
  719. pattern: /^\d+(\.\d{1,2})?$/,
  720. // 正则检验前先将值转为字符串
  721. transform(value) {
  722. return value?String(value):0;
  723. },
  724. message: '里程需为正数且最多两位小数',
  725. // 触发器可以同时用blur和change
  726. trigger: ['change','blur'],
  727. }
  728. ],
  729. },
  730. userInfo: null,
  731. }
  732. },
  733. onLoad({id}) {
  734. // console.log(id,'id')
  735. if(id) {
  736. this.getInfo(id)
  737. } else {
  738. // this.getUserInfo()
  739. }
  740. },
  741. onShow() {
  742. },
  743. onHide() {
  744. },
  745. onReady() {
  746. this.resetRules()
  747. },
  748. methods: {
  749. resetRules() {
  750. this.$refs.uForm.setRules(this.rules)
  751. },
  752. async getInfo(vehicleId) {
  753. let {code,data} = await getDetail({vehicleId})
  754. if(code == 0) {
  755. for (let key in this.model.form) {
  756. if (key === 'workId') {
  757. let workIdArr = data[key] ? data[key].split(',') : [];
  758. this.model.form[key] = workIdArr[workIdArr.length - 1]
  759. } else {
  760. this.model.form[key] = this.isNull(data[key]) ? undefined : data[key]
  761. }
  762. }
  763. // copyProps(this.model.form,data)
  764. }
  765. },
  766. getUserInfo() {
  767. userProfile().then((res) => {
  768. this.userInfo = res.data
  769. this.model.form.deptId = res.data.deptId
  770. this.model.form.deptName = res.data.deptName
  771. })
  772. },
  773. // 提交
  774. async handleSubmit() {
  775. this.$refs.uForm.validate().then(async res => {
  776. let ajaxData = {
  777. ...this.model.form,
  778. }
  779. let { data, code,msg } =ajaxData.vehicleId? await update(ajaxData) : await add(ajaxData)
  780. if (code == 0) {
  781. uni.showModal({
  782. title: '提示',
  783. content: `提交成功~`,
  784. showCancel:false,
  785. confirmText: '好的',
  786. success: function(res) {
  787. if (res.confirm) {
  788. uni.navigateTo({url: `/pagesBase/vehManage/index`})
  789. }
  790. }
  791. })
  792. }
  793. }).catch(errors => {
  794. console.log('校验失败',errors)
  795. })
  796. },
  797. handleClear() {
  798. uni.navigateBack()
  799. // clearProps(this.model.form,['outflowUserId','outflowUser','deptId','deptName'])
  800. },
  801. }
  802. }
  803. </script>
  804. <style lang="scss" scoped>
  805. .disflex-center {
  806. display: flex;
  807. justify-content: center;
  808. align-items: center;
  809. }
  810. .disflex-right {
  811. display: flex;
  812. justify-content: right;
  813. align-items: center;
  814. }
  815. .page-container {
  816. font-size: 28rpx;
  817. min-height: 100%;
  818. position: relative;
  819. // padding-bottom: 60rpx;
  820. .box {
  821. margin: 20rpx;
  822. border-radius: 10rpx;
  823. background: #fff;
  824. .item-label {
  825. display: flex;
  826. justify-content: space-between;
  827. align-items: center;
  828. &-left {
  829. font-family: PingFangSC, PingFang SC;
  830. font-weight: 400;
  831. font-size: 28rpx;
  832. color: #333333;
  833. position: relative;
  834. text {
  835. color: #f56c6c;
  836. font-size: 40rpx;
  837. position: absolute;
  838. left: -18rpx;
  839. }
  840. }
  841. &-right {
  842. font-family: PingFangSC, PingFang SC;
  843. font-weight: 400;
  844. font-size: 20rpx;
  845. color: #999999;
  846. }
  847. }
  848. }
  849. .page-body {
  850. padding-bottom: 120rpx;
  851. }
  852. .page-footer {
  853. padding: 0rpx 0;
  854. position: fixed;
  855. width: 100%;
  856. left: 0;
  857. bottom: 0;
  858. }
  859. }
  860. ::v-deep {
  861. .u-cell-group {
  862. .u-cell__title-text {
  863. font-family: PingFangSC, PingFang SC;
  864. font-weight: 400;
  865. font-size: 28rpx;
  866. color: #333333;
  867. }
  868. .u-form-item__body__right__content__slot {
  869. font-family: PingFangSC, PingFang SC;
  870. font-weight: 400;
  871. font-size: 28rpx;
  872. color: #333333;
  873. .u-input__content__field-wrapper__field {
  874. font-family: PingFangSC, PingFang SC !important;
  875. font-weight: 400 !important;
  876. font-size: 28rpx !important;
  877. color: #333333 !important;
  878. }
  879. }
  880. }
  881. .u-form-item__body {
  882. padding: 0;
  883. }
  884. .hidde-cell-title {
  885. .u-cell__body__content {
  886. width: auto;
  887. flex: none;
  888. }
  889. .u-cell__body {
  890. .value {
  891. flex: 1;
  892. }
  893. }
  894. }
  895. }
  896. </style>