add.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <view>
  3. <view v-if="step==2" class="" @click="step--"
  4. style="position: absolute;right: 20rpx;top: 10rpx;font-size: 28rpx;color: #5064eb;">
  5. <text>上一步</text>
  6. </view>
  7. <view v-show="step==1" style="margin-top: 20rpx;">
  8. <view class="form">
  9. <view class="flex">
  10. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;"
  11. src="/static/myCar/tag1.png" mode=""></image>
  12. <text class="text-lg text-bold">请选择基本信息</text>
  13. </view>
  14. <view class="card">
  15. <u-form :model="model" ref="uForm">
  16. <u-form-item :required="true" :label-width="labelWidth" label="车牌号码">
  17. <u-input type="text" v-model="model.number" placeholder="请填写车牌号码"></u-input>
  18. </u-form-item>
  19. <u-form-item :label-width="labelWidth" label="车辆类型">
  20. <u-input type="select" :select-open="carTypeShow" v-model="carTypeLabel"
  21. placeholder="请选择车辆类型" @click="carTypeShow=true"></u-input>
  22. </u-form-item>
  23. <u-form-item :label-width="labelWidth" label="车辆性质">
  24. <u-input type="select" :select-open="carPropertiesShow" v-model="carPropertiesLabel"
  25. placeholder="请选择车辆性质" @click="carPropertiesShow=true"></u-input>
  26. </u-form-item>
  27. <u-form-item :label-width="labelWidth" label="燃油类别">
  28. <u-input type="select" :select-open="fuelCategoryShow" v-model="fuelCategoryLabel"
  29. placeholder="请选择燃油类别" @click="fuelCategoryShow=true"></u-input>
  30. </u-form-item>
  31. </u-form>
  32. </view>
  33. </view>
  34. <view class="form">
  35. <view class="flex">
  36. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;"
  37. src="/static/myCar/tag1.png" mode=""></image>
  38. <text class="text-lg text-bold">请选择车位信息</text>
  39. </view>
  40. <view class="card">
  41. <u-form :model="model" ref="uForm">
  42. <u-form-item :required="true" :label-width="labelWidth" label="所属车场">
  43. <u-input type="select" :select-open="parkingLotShow" v-model="parkingLotLabel"
  44. placeholder="请选择车场区域" @click="parkingLotShow=true"></u-input>
  45. </u-form-item>
  46. <u-form-item :required="true" :label-width="labelWidth" label="车场区域">
  47. <u-input type="select" :select-open="parkingAreaShow" v-model="parkingAreaLabel"
  48. placeholder="请选择车场区域" @click="parkingAreaShow=true"></u-input>
  49. </u-form-item>
  50. <u-form-item :required="true" :label-width="labelWidth" label="所属车位">
  51. <u-input type="select" :select-open="parkingSpaceShow" v-model="parkingSpaceLabel"
  52. placeholder="请选择所属车位" @click="parkingSpaceShow=true"></u-input>
  53. </u-form-item>
  54. </u-form>
  55. </view>
  56. </view>
  57. </view>
  58. <view v-show="step==2" style="margin-top: 20rpx;">
  59. <view class="form">
  60. <view class="flex">
  61. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;"
  62. src="/static/myCar/tag1.png" mode=""></image>
  63. <text class="text-lg text-bold">请上传车辆照片</text>
  64. <text class="text-sm text-gray margin-top-10">(必填)</text>
  65. </view>
  66. <view class="card">
  67. <view style="padding: 20rpx 0;" @click="chooseImage(1)" class="flex justify-center ">
  68. <view class=" ">
  69. <upload-img :width="width" :height="height" :currentImage="model.carImg"
  70. bgsrc="https://szsq.nxzhsq.cn/community/miniofile/app/upload.png">
  71. </upload-img>
  72. <view class="text-center padding-top-20 base-color">
  73. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  74. <text v-if="$isEmpty(model.carImg)">点击上传车辆照片</text>
  75. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="form">
  82. <view class="flex">
  83. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;"
  84. src="/static/myCar/tag1.png" mode=""></image>
  85. <text class="text-lg text-bold">请上传行驶证正面</text>
  86. <text class="text-sm text-gray margin-top-10">(选填)</text>
  87. </view>
  88. <view class="card">
  89. <view style="padding: 20rpx 0;" @click="chooseImage(2)" class="flex justify-center ">
  90. <view class=" ">
  91. <upload-img :width="width" :height="height" :currentImage="model.vehicleDrivingLicense1"
  92. bgsrc="https://szsq.nxzhsq.cn/community/miniofile/app/zm.png">
  93. </upload-img>
  94. <view class="text-center padding-top-20 base-color">
  95. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  96. <text v-if="$isEmpty(model.carImg)">点击上传行驶证正面</text>
  97. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="form">
  104. <view class="flex">
  105. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;"
  106. src="/static/myCar/tag1.png" mode=""></image>
  107. <text class="text-lg text-bold">请上传行驶证反面</text>
  108. <text class="text-sm text-gray margin-top-10">(选填)</text>
  109. </view>
  110. <view class="card">
  111. <view style="padding: 20rpx 0;" @click="chooseImage(3)" class="flex justify-center ">
  112. <view class=" ">
  113. <upload-img :width="width" :height="height" :currentImage="model.vehicleDrivingLicense2"
  114. bgsrc="https://szsq.nxzhsq.cn/community/miniofile/app/fm.png">
  115. </upload-img>
  116. <view class="text-center padding-top-20 base-color">
  117. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  118. <text v-if="$isEmpty(model.carImg)">点击上传行驶证反面</text>
  119. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. <view>
  127. <view class="bg-white" style="height: 80rpx;"></view>
  128. <view v-if="step==1" class="" @click="next" style="width: 90%;margin: 0 auto ;margin-bottom: 10%;">
  129. <view class="cu-btn round base-bg-color" style="padding: 40rpx;width: 100%;">
  130. <text>下一步</text>
  131. </view>
  132. </view>
  133. <view v-if="step==2" class="" @click="submit" style="width: 90%;margin: 0 auto ;margin-bottom: 10%;">
  134. <view class="cu-btn round base-bg-color" style="padding: 40rpx;width: 100%;">
  135. <text :class="isAdd?'cuIcon-add':'cuIcon-edit'" class="margin-right-10"></text>
  136. <text v-text="isAdd?'确认添加':'确定修改'"></text>
  137. </view>
  138. </view>
  139. </view>
  140. <u-select @confirm="carTypeConfirm" v-model="carTypeShow" :list="carTypeList"></u-select>
  141. <u-select @confirm="carPropertiesConfirm" v-model="carPropertiesShow" :list="carPropertiesList"></u-select>
  142. <u-select @confirm="fuelCategoryConfirm" v-model="fuelCategoryShow" :list="fuelCategoryList"></u-select>
  143. <u-select @confirm="parkingLotConfirm" v-model="parkingLotShow" :list="parkingLotList" label-name="parkName"
  144. value-name="id"></u-select>
  145. <u-select @confirm="parkingAreaConfirm" v-model="parkingAreaShow" :list="parkingAreaList" label-name="name"
  146. value-name="id"></u-select>
  147. <u-select @confirm="parkingSpaceConfirm" v-model="parkingSpaceShow" :list="parkingSpaceList" label-name="number"
  148. value-name="id"></u-select>
  149. </view>
  150. </template>
  151. <script>
  152. import uploadImg from '@/comps/uploadimg/uploadImg.vue'
  153. var that;
  154. var app = getApp();
  155. export default {
  156. components: {
  157. uploadImg
  158. },
  159. data() {
  160. return {
  161. isAdd: true,
  162. step: 1,
  163. labelWidth: '200',
  164. width: 480,
  165. height: 320,
  166. //车场
  167. parkingLotLabel: '',
  168. parkingLotValue: "",
  169. parkingLotList: [],
  170. parkingLotShow: false,
  171. //车场区域
  172. parkingAreaLabel: '',
  173. parkingAreaValue: "",
  174. parkingAreaList: [],
  175. parkingAreaShow: false,
  176. //车位
  177. parkingSpaceLabel: '',
  178. parkingSpaceValue: "",
  179. parkingSpaceList: [],
  180. parkingSpaceShow: false,
  181. //车牌号
  182. carNoInputList: [],
  183. //车辆类型
  184. carTypeList: [],
  185. carTypeShow: false,
  186. carTypeLabel: '',
  187. //车辆性质
  188. carPropertiesList: [],
  189. carPropertiesShow: false,
  190. carPropertiesLabel: '',
  191. //燃油类别
  192. fuelCategoryList: [],
  193. fuelCategoryShow: false,
  194. fuelCategoryLabel: '',
  195. model: {
  196. type: '', //车辆类型的key
  197. number: '', //车牌号
  198. properties: '', //车辆性质的key,
  199. fuelCategory: '', //燃油类别的key
  200. carImg: '', //车辆照片
  201. vehicleDrivingLicense1: '', //行驶证正面
  202. vehicleDrivingLicense2: '', //行驶证反面
  203. personId: '',
  204. residentialId: '',
  205. tenantType: 0
  206. },
  207. }
  208. },
  209. onLoad(options) {
  210. that = this;
  211. this.model.residentialId = uni.getStorageSync('residentialId')
  212. this.model.personPhone = this.vuex_member.tel;
  213. this.model.memberId = this.vuex_member.id;
  214. this.model.idCard = this.vuex_member.idcard;
  215. this.model.personName = this.vuex_member.name;
  216. //获取车位数量
  217. this.getParkingSpaceCount()
  218. //获取字典
  219. this.getDict()
  220. //获取车场
  221. this.initParkingLot()
  222. this.parseParams(options)
  223. },
  224. methods: {
  225. next() {
  226. if (this.$isEmpty(this.model.number)) {
  227. this.$u.toast('请填写车牌号')
  228. return
  229. }
  230. if (this.$isEmpty(this.parkingLotValue)) {
  231. this.$u.toast('请选择车场')
  232. return
  233. }
  234. if (this.$isEmpty(this.parkingAreaValue)) {
  235. this.$u.toast('请选择车场区域')
  236. return
  237. }
  238. if (this.$isEmpty(this.parkingSpaceValue)) {
  239. this.$u.toast('请选择车场')
  240. return
  241. }
  242. let data = this.parkingSpaceList.find(item => item.id == this.parkingSpaceValue)
  243. if (data.isUsed) {
  244. this.$dialog.showModal('该车位已被占用,请联系物业负责人', false)
  245. return
  246. }
  247. this.model.parkingSpaceId = this.parkingSpaceValue
  248. this.step++
  249. },
  250. //车位 begin
  251. initParkingLot() {
  252. let params = {
  253. residentialId: this.model.residentialId
  254. }
  255. this.$http.parking.parkingLotList(params).then(res => {
  256. this.parkingLotList = res.data.data
  257. })
  258. },
  259. initParkingArea() {
  260. let params = {
  261. parkingLotId: this.parkingLotValue
  262. }
  263. this.$http.parking.parkingAreaList(params).then(res => {
  264. this.parkingAreaList = res.data.data
  265. })
  266. },
  267. initParkingSpace() {
  268. let params = {
  269. parkingAreaId: this.parkingAreaValue
  270. }
  271. this.$http.parking.parkingSpaceList(params).then(res => {
  272. this.parkingSpaceList = res.data.data
  273. })
  274. },
  275. getParkingSpaceCount() {
  276. let params = {
  277. residentialId: this.model.residentialId
  278. }
  279. this.$http.parking.parkingSpaceCount(params).then(res => {
  280. if (this.$isEmpty(res.data.data)) {
  281. this.$dialog.showModalAndBack('该小区暂未创建车位,请联系小区负责人创建!', false)
  282. }
  283. })
  284. },
  285. parkingLotConfirm(e) {
  286. this.parkingLotLabel = e[0].label
  287. this.parkingLotValue = e[0].value
  288. this.initParkingArea()
  289. },
  290. parkingAreaConfirm(e) {
  291. this.parkingAreaLabel = e[0].label
  292. this.parkingAreaValue = e[0].value
  293. this.initParkingSpace()
  294. },
  295. parkingSpaceConfirm(e) {
  296. this.parkingSpaceLabel = e[0].label
  297. this.parkingSpaceValue = e[0].value
  298. },
  299. //车位 end
  300. parseParams(options) {
  301. console.log(options);
  302. if (this.$isEmpty(options)) {
  303. return
  304. }
  305. this.isAdd = false
  306. //获取车位
  307. this.fetchParkingSpace(options.id)
  308. this.model = options
  309. this.carTypeList.forEach(item => {
  310. if (item.value == options.type) {
  311. this.carTypeLabel = item.label
  312. }
  313. })
  314. this.carPropertiesList.forEach(item => {
  315. if (item.value == options.properties) {
  316. this.carPropertiesLabel = item.label
  317. }
  318. })
  319. this.fuelCategoryList.forEach(item => {
  320. if (item.value == options.fuelCategory) {
  321. this.fuelCategoryLabel = item.label
  322. }
  323. })
  324. },
  325. fetchParkingSpace(carId) {
  326. let params = {
  327. carId
  328. }
  329. this.$http.parking.parkingSpaceList(params).then(res => {
  330. let records = res.data.data
  331. let data = records[0]
  332. if (this.$isNotEmpty(data)) {
  333. this.parkingLotLabel = data.parkingLotName
  334. this.parkingLotValue = data.parkingLotId
  335. this.parkingAreaLabel = data.parkingAreaName
  336. this.parkingAreaValue = data.parkingAreaId
  337. this.parkingSpaceLabel = data.number
  338. this.parkingSpaceValue = data.id
  339. data.isUsed = 0
  340. this.parkingSpaceList = records
  341. }
  342. })
  343. },
  344. submit() {
  345. if (this.$isEmpty(this.model.carImg)) {
  346. this.$u.toast('请上传车辆照片')
  347. return
  348. }
  349. let that = this;
  350. this.model.residentialId = uni.getStorageSync('residentialId')
  351. this.model.personId = this.vuex_member.id
  352. this.model.personName = this.vuex_member.name
  353. this.model.personPhone = this.vuex_member.phone
  354. this.model.userIdCard = this.vuex_member.idcard
  355. that.$http.saveOrUpdateCar(this.model).then(res => {
  356. if (res.data.result) {
  357. that.$util.showModal('操作成功!', false).then(res => {
  358. that.$util.isReloadAndBack()
  359. })
  360. } else {
  361. that.$util.showModal("提交失败", false);
  362. }
  363. })
  364. },
  365. getDict() {
  366. let carType = uni.getStorageSync("carType");
  367. let carProperty = uni.getStorageSync("carProperty");
  368. let fuelCategory = uni.getStorageSync("fuelCategory");
  369. if (!this.$isEmpty(carType) || !this.$isEmpty(carProperty) || !this.$isEmpty(fuelCategory)) {
  370. this.carTypeList = carType;
  371. this.carPropertiesList = carProperty;
  372. this.fuelCategoryList = fuelCategory;
  373. return;
  374. }
  375. // let operation = 'permissions/dict/getByCode?code=car_type';
  376. let that = this;
  377. let params = {};
  378. //车辆类型
  379. that.$http.getDictByCode("car_type").then(res => {
  380. if (res.data.code != 200) {
  381. app.globalData.oneFailHint(res.data.msg, function() {
  382. uni.switchTab({
  383. url: "../index/index"
  384. })
  385. });
  386. }
  387. res.data.data.forEach((item) => {
  388. let tmp = {
  389. value: item.dictKey,
  390. label: item.dictValue
  391. }
  392. that.carTypeList.push(tmp)
  393. })
  394. });
  395. //车辆性质
  396. // operation = "permissions/dict/getByCode?code=car_properties"
  397. that.$http.getDictByCode("car_properties").then(res => {
  398. if (res.data.code != 200) {
  399. app.globalData.oneFailHint(res.data.msg, function() {
  400. uni.switchTab({
  401. url: "../index/index"
  402. })
  403. });
  404. }
  405. res.data.data.forEach((item) => {
  406. let tmp = {
  407. value: item.dictKey,
  408. label: item.dictValue
  409. }
  410. that.carPropertiesList.push(tmp)
  411. })
  412. });
  413. //燃油类别
  414. // operation = "permissions/dict/getByCode?code=fuel_category"
  415. that.$http.getDictByCode("fuel_category").then(res => {
  416. if (res.data.code != 200) {
  417. app.globalData.oneFailHint(res.data.msg, function() {
  418. uni.switchTab({
  419. url: "../index/index"
  420. })
  421. });
  422. }
  423. res.data.data.forEach((item) => {
  424. let tmp = {
  425. value: item.dictKey,
  426. label: item.dictValue
  427. }
  428. that.fuelCategoryList.push(tmp);
  429. })
  430. });
  431. },
  432. carTypeConfirm(e) {
  433. this.model.type = e[0].value
  434. this.carTypeLabel = e[0].label
  435. },
  436. carPropertiesConfirm(e) {
  437. this.model.properties = e[0].value
  438. this.carPropertiesLabel = e[0].label
  439. },
  440. fuelCategoryConfirm(e) {
  441. this.model.fuelCategory = e[0].value
  442. this.fuelCategoryLabel = e[0].label
  443. },
  444. //上传图片
  445. chooseImage(type) {
  446. uni.chooseImage({
  447. count: 1,
  448. //最多可以选择的图片张数,默认9
  449. sourceType: ['album'],
  450. sizeType: ['compressed'],
  451. //可选择原图或压缩后的图片
  452. success: res => {
  453. this.uploadImage(res.tempFilePaths[0], type);
  454. }
  455. });
  456. },
  457. /**上传图片
  458. * @param {Object} imgUrl 图片url
  459. */
  460. uploadImage(imgUrl, type) {
  461. var that = this;
  462. //是否需要md5加密上传人脸照
  463. let is_need_md5 = false;
  464. this.$http.uploadFile(imgUrl).then(res => {
  465. if (type == 1) {
  466. that.model.carImg = res.data.data.link;
  467. } else if (type == 2) {
  468. that.model.vehicleDrivingLicense1 = res.data.data.link;
  469. } else if (type == 3) {
  470. that.model.vehicleDrivingLicense2 = res.data.data.link;
  471. }
  472. })
  473. },
  474. }
  475. }
  476. </script>
  477. <style>
  478. page {
  479. background-color: #FFFFFF;
  480. }
  481. </style>
  482. <style lang="scss" scoped>
  483. .form {
  484. padding: 40rpx 30rpx;
  485. .card {
  486. margin-top: 20rpx;
  487. padding: 0 30rpx;
  488. box-sizing: border-box;
  489. border-radius: 12rpx;
  490. box-shadow: 0 -10rpx rgba(248, 248, 248, .9), 0 10rpx rgba(248, 248, 248, .9), -10rpx 0rpx rgba(248, 248, 248, .9), 10rpx 0rpx rgba(248, 248, 248, .9);
  491. .item {
  492. padding: 30rpx 0;
  493. display: flex;
  494. justify-content: space-between;
  495. }
  496. }
  497. }
  498. </style>