add.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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 ;position: absolute;bottom: 50rpx;left: 0;right: 0;">
  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. let id= e[0].value
  297. let flag= this.parkingSpaceList.some(item=>item.id==id && item.isUsed==1)
  298. if (flag) {
  299. this.$dialog.showModal('该车位已被占用,请联系社区负责人',false)
  300. return
  301. }
  302. this.parkingSpaceLabel = e[0].label
  303. this.parkingSpaceValue = id
  304. },
  305. //车位 end
  306. parseParams(options) {
  307. if (this.$isEmpty(options)) {
  308. return
  309. }
  310. this.isAdd = false
  311. //获取车位
  312. this.fetchParkingSpace(options.id)
  313. this.model = options
  314. this.carTypeList.forEach(item => {
  315. if (item.value == options.type) {
  316. this.carTypeLabel = item.label
  317. }
  318. })
  319. this.carPropertiesList.forEach(item => {
  320. if (item.value == options.properties) {
  321. this.carPropertiesLabel = item.label
  322. }
  323. })
  324. this.fuelCategoryList.forEach(item => {
  325. if (item.value == options.fuelCategory) {
  326. this.fuelCategoryLabel = item.label
  327. }
  328. })
  329. },
  330. fetchParkingSpace(carId) {
  331. let params = {
  332. carId
  333. }
  334. this.$http.parking.parkingSpaceList(params).then(res => {
  335. let records = res.data.data
  336. let data = records[0]
  337. if (this.$isNotEmpty(data)) {
  338. this.parkingLotLabel = data.parkingLotName
  339. this.parkingLotValue = data.parkingLotId
  340. this.parkingAreaLabel = data.parkingAreaName
  341. this.parkingAreaValue = data.parkingAreaId
  342. this.parkingSpaceLabel = data.number
  343. this.parkingSpaceValue = data.id
  344. data.isUsed = 0
  345. this.parkingSpaceList = records
  346. }
  347. })
  348. },
  349. submit() {
  350. if (this.$isEmpty(this.model.carImg)) {
  351. this.$u.toast('请上传车辆照片')
  352. return
  353. }
  354. let that = this;
  355. this.model.parkingLotId=this.parkingLotValue
  356. this.model.residentialId = uni.getStorageSync('residentialId')
  357. this.model.personId = this.vuex_member.id
  358. this.model.personName = this.vuex_member.name
  359. this.model.personPhone = this.vuex_member.phone
  360. this.model.userIdCard = this.vuex_member.idcard
  361. that.$http.saveOrUpdateCar(this.model).then(res => {
  362. if (res.data.result) {
  363. that.$util.showModal('操作成功!', false).then(res => {
  364. that.$util.isReloadAndBack()
  365. })
  366. } else {
  367. that.$util.showModal("提交失败", false);
  368. }
  369. })
  370. },
  371. getDict() {
  372. let carType = uni.getStorageSync("carType");
  373. let carProperty = uni.getStorageSync("carProperty");
  374. let fuelCategory = uni.getStorageSync("fuelCategory");
  375. if (!this.$isEmpty(carType) || !this.$isEmpty(carProperty) || !this.$isEmpty(fuelCategory)) {
  376. this.carTypeList = carType;
  377. this.carPropertiesList = carProperty;
  378. this.fuelCategoryList = fuelCategory;
  379. return;
  380. }
  381. // let operation = 'permissions/dict/getByCode?code=car_type';
  382. let that = this;
  383. let params = {};
  384. //车辆类型
  385. that.$http.getDictByCode("car_type").then(res => {
  386. if (res.data.code != 200) {
  387. app.globalData.oneFailHint(res.data.msg, function() {
  388. uni.switchTab({
  389. url: "../index/index"
  390. })
  391. });
  392. }
  393. res.data.data.forEach((item) => {
  394. let tmp = {
  395. value: item.dictKey,
  396. label: item.dictValue
  397. }
  398. that.carTypeList.push(tmp)
  399. })
  400. });
  401. //车辆性质
  402. // operation = "permissions/dict/getByCode?code=car_properties"
  403. that.$http.getDictByCode("car_properties").then(res => {
  404. if (res.data.code != 200) {
  405. app.globalData.oneFailHint(res.data.msg, function() {
  406. uni.switchTab({
  407. url: "../index/index"
  408. })
  409. });
  410. }
  411. res.data.data.forEach((item) => {
  412. let tmp = {
  413. value: item.dictKey,
  414. label: item.dictValue
  415. }
  416. that.carPropertiesList.push(tmp)
  417. })
  418. });
  419. //燃油类别
  420. // operation = "permissions/dict/getByCode?code=fuel_category"
  421. that.$http.getDictByCode("fuel_category").then(res => {
  422. if (res.data.code != 200) {
  423. app.globalData.oneFailHint(res.data.msg, function() {
  424. uni.switchTab({
  425. url: "../index/index"
  426. })
  427. });
  428. }
  429. res.data.data.forEach((item) => {
  430. let tmp = {
  431. value: item.dictKey,
  432. label: item.dictValue
  433. }
  434. that.fuelCategoryList.push(tmp);
  435. })
  436. });
  437. },
  438. carTypeConfirm(e) {
  439. this.model.type = e[0].value
  440. this.carTypeLabel = e[0].label
  441. },
  442. carPropertiesConfirm(e) {
  443. this.model.properties = e[0].value
  444. this.carPropertiesLabel = e[0].label
  445. },
  446. fuelCategoryConfirm(e) {
  447. this.model.fuelCategory = e[0].value
  448. this.fuelCategoryLabel = e[0].label
  449. },
  450. //上传图片
  451. chooseImage(type) {
  452. uni.chooseImage({
  453. count: 1,
  454. //最多可以选择的图片张数,默认9
  455. sourceType: ['album'],
  456. sizeType: ['compressed'],
  457. //可选择原图或压缩后的图片
  458. success: res => {
  459. this.uploadImage(res.tempFilePaths[0], type);
  460. }
  461. });
  462. },
  463. /**上传图片
  464. * @param {Object} imgUrl 图片url
  465. */
  466. uploadImage(imgUrl, type) {
  467. var that = this;
  468. //是否需要md5加密上传人脸照
  469. let is_need_md5 = false;
  470. this.$http.uploadFile(imgUrl).then(res => {
  471. if (type == 1) {
  472. that.model.carImg = res.data.data.link;
  473. } else if (type == 2) {
  474. that.model.vehicleDrivingLicense1 = res.data.data.link;
  475. } else if (type == 3) {
  476. that.model.vehicleDrivingLicense2 = res.data.data.link;
  477. }
  478. })
  479. },
  480. }
  481. }
  482. </script>
  483. <style>
  484. page {
  485. background-color: #FFFFFF;
  486. }
  487. </style>
  488. <style lang="scss" scoped>
  489. .form {
  490. padding: 40rpx 30rpx;
  491. .card {
  492. margin-top: 20rpx;
  493. padding: 0 30rpx;
  494. box-sizing: border-box;
  495. border-radius: 12rpx;
  496. 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);
  497. .item {
  498. padding: 30rpx 0;
  499. display: flex;
  500. justify-content: space-between;
  501. }
  502. }
  503. }
  504. </style>