add.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <view>
  3. <view class="form">
  4. <view class="flex">
  5. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
  6. <text class="text-lg text-bold">请选择基本信息</text>
  7. </view>
  8. <view class="card">
  9. <u-form :model="model" ref="uForm" >
  10. <u-form-item :required="true" :label-width="labelWidth" label="车牌号码" >
  11. <u-input type="text" v-model="model.number" disabled @click="openKeyBoard" placeholder="请填写车牌号码" ></u-input>
  12. </u-form-item>
  13. <u-form-item :label-width="labelWidth" label="车辆类型" >
  14. <u-input type="select" :select-open="carTypeShow" v-model="carTypeLabel" placeholder="请选择车辆类型" @click="carTypeShow=true"></u-input>
  15. </u-form-item>
  16. <u-form-item :label-width="labelWidth" label="车辆性质" >
  17. <u-input type="select" :select-open="carPropertiesShow" v-model="carPropertiesLabel" placeholder="请选择车辆性质" @click="carPropertiesShow=true"></u-input>
  18. </u-form-item>
  19. <u-form-item :label-width="labelWidth" label="燃油类别" >
  20. <u-input type="select" :select-open="fuelCategoryShow" v-model="fuelCategoryLabel" placeholder="请选择燃油类别" @click="fuelCategoryShow=true"></u-input>
  21. </u-form-item>
  22. </u-form>
  23. </view>
  24. </view>
  25. <view class="form">
  26. <view class="flex">
  27. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
  28. <text class="text-lg text-bold">请上传车辆照片</text>
  29. <text class="text-sm text-gray margin-top-10">(必填)</text>
  30. </view>
  31. <view class="card">
  32. <view style="padding: 20rpx 0;" @click="chooseImage(1)" class="flex justify-center ">
  33. <view class=" ">
  34. <upload-img
  35. :width="width"
  36. :height="height"
  37. :currentImage="model.carImg"
  38. bgsrc="https://szsq.nxzhsq.cn/community/miniofile/app/upload.png"
  39. >
  40. </upload-img>
  41. <view class="text-center padding-top-20 base-color" >
  42. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  43. <text v-if="$isEmpty(model.carImg)">点击上传车辆照片</text>
  44. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="form">
  51. <view class="flex">
  52. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
  53. <text class="text-lg text-bold">请上传行驶证正面</text>
  54. <text class="text-sm text-gray margin-top-10">(选填)</text>
  55. </view>
  56. <view class="card">
  57. <view style="padding: 20rpx 0;" @click="chooseImage(2)" class="flex justify-center ">
  58. <view class=" ">
  59. <upload-img
  60. :width="width"
  61. :height="height"
  62. :currentImage="model.vehicleDrivingLicense1"
  63. bgsrc="https://szsq.nxzhsq.cn/community/miniofile/app/zm.png"
  64. >
  65. </upload-img>
  66. <view class="text-center padding-top-20 base-color" >
  67. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  68. <text v-if="$isEmpty(model.carImg)">点击上传行驶证正面</text>
  69. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="form">
  76. <view class="flex">
  77. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
  78. <text class="text-lg text-bold">请上传行驶证反面</text>
  79. <text class="text-sm text-gray margin-top-10">(选填)</text>
  80. </view>
  81. <view class="card">
  82. <view style="padding: 20rpx 0;" @click="chooseImage(3)" class="flex justify-center ">
  83. <view class=" ">
  84. <upload-img
  85. :width="width"
  86. :height="height"
  87. :currentImage="model.vehicleDrivingLicense2"
  88. bgsrc="https://szsq.nxzhsq.cn/community/miniofile/app/fm.png"
  89. >
  90. </upload-img>
  91. <view class="text-center padding-top-20 base-color" >
  92. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  93. <text v-if="$isEmpty(model.carImg)">点击上传行驶证反面</text>
  94. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view >
  101. <view class="bg-white" style="height: 80rpx;"></view>
  102. <view class="" @click="submit" style="width: 90%;margin: 0 auto ;margin-bottom: 10%;">
  103. <view class="cu-btn round base-bg-color" style="padding: 40rpx;width: 100%;" >
  104. <text class="cuIcon-add"></text>
  105. <text >确认添加</text>
  106. </view>
  107. </view>
  108. </view>
  109. <u-select @confirm="carTypeConfirm" v-model="carTypeShow" :list="carTypeList"></u-select>
  110. <u-select @confirm="carPropertiesConfirm" v-model="carPropertiesShow" :list="carPropertiesList"></u-select>
  111. <u-select @confirm="fuelCategoryConfirm" v-model="fuelCategoryShow" :list="fuelCategoryList"></u-select>
  112. <keyboard-package z-index="999" ref="plateNumber" type="plateNumber" @onInput="onInput" @onDelete="onDelete" @onConfirm="onConfirm"/>
  113. </view>
  114. </template>
  115. <script>
  116. import keyboardPackage from "@/comps/keyboard-package/keyboard-package.vue"
  117. import uploadImg from '@/comps/uploadimg/uploadImg.vue'
  118. var that;
  119. var app = getApp();
  120. export default {
  121. components: {
  122. uploadImg, keyboardPackage
  123. },
  124. data() {
  125. return {
  126. labelWidth:'200',
  127. width:480,
  128. height:320,
  129. //车牌号
  130. carNoInputList:[],
  131. //车辆类型
  132. carTypeList:[],
  133. carTypeShow:false,
  134. carTypeLabel:'',
  135. //车辆性质
  136. carPropertiesList:[],
  137. carPropertiesShow:false,
  138. carPropertiesLabel:'',
  139. //燃油类别
  140. fuelCategoryList:[],
  141. fuelCategoryShow:false,
  142. fuelCategoryLabel:'',
  143. model:{
  144. type:'',//车辆类型的key
  145. number:'',//车牌号
  146. properties:'',//车辆性质的key,
  147. fuelCategory:'',//燃油类别的key
  148. carImg:'',//车辆照片
  149. vehicleDrivingLicense1:'',//行驶证正面
  150. vehicleDrivingLicense2:'',//行驶证反面
  151. personId:'',
  152. residentialId:'',
  153. tenantType:0
  154. },
  155. }
  156. },
  157. onLoad(options) {
  158. that = this;
  159. this.model.residentialId = uni.getStorageSync('residentialId')
  160. this.model.personPhone = this.vuex_member.tel;
  161. this.model.memberId = this.vuex_member.id;
  162. this.model.idCard = this.vuex_member.idcard;
  163. this.model.personName = this.vuex_member.name;
  164. //获取字典
  165. this.getDict()
  166. this.parseParams(options)
  167. },
  168. computed: {
  169. plateNumberStr() {
  170. let str = '';
  171. this.carNoInputList.forEach(item=>{
  172. str += item.toString();
  173. })
  174. this.model.number=str
  175. return str;
  176. }
  177. },
  178. methods: {
  179. parseParams(options){
  180. if (this.$isEmpty(options)) {
  181. return
  182. }
  183. this.model=options
  184. this.carNoInputList=options.number.split('')
  185. this.carTypeList.forEach(item=>{
  186. if (item.value==options.type) {
  187. this.carTypeLabel=item.label
  188. }
  189. })
  190. this.carPropertiesList.forEach(item=>{
  191. if (item.value==options.properties) {
  192. this.carPropertiesLabel=item.label
  193. }
  194. })
  195. this.fuelCategoryList.forEach(item=>{
  196. if (item.value==options.fuelCategory) {
  197. this.fuelCategoryLabel=item.label
  198. }
  199. })
  200. },
  201. submit(){
  202. if (this.$isEmpty(this.model.number)) {
  203. this.$u.toast('请填写车牌号')
  204. return
  205. }
  206. if (this.$isEmpty(this.model.carImg)) {
  207. this.$u.toast('请上传车辆照片')
  208. return
  209. }
  210. let that = this;
  211. this.model.residentialId = uni.getStorageSync('residentialId')
  212. this.model.personId=this.vuex_member.id
  213. this.model.personName=this.vuex_member.name
  214. this.model.personPhone=this.vuex_member.phone
  215. that.$http.saveOrUpdateCar(this.model).then (res=>{
  216. if (res.data.result) {
  217. that.$util.showModal('操作成功!',false).then(res=>{
  218. that.$util.isReloadAndBack()
  219. })
  220. } else {
  221. that.$util.showModal("提交失败",false);
  222. }
  223. })
  224. },
  225. getDict() {
  226. let carType = uni.getStorageSync("carType");
  227. let carProperty = uni.getStorageSync("carProperty");
  228. let fuelCategory = uni.getStorageSync("fuelCategory");
  229. if (!this.$isEmpty(carType) || !this.$isEmpty(carProperty) || !this.$isEmpty(fuelCategory)) {
  230. this.carTypeList = carType;
  231. this.carPropertiesList = carProperty;
  232. this.fuelCategoryList = fuelCategory;
  233. return;
  234. }
  235. // let operation = 'permissions/dict/getByCode?code=car_type';
  236. let that = this;
  237. let params = {};
  238. //车辆类型
  239. that.$http.getDictByCode("car_type").then (res=>{
  240. if (res.data.code != 200) {
  241. app.globalData.oneFailHint(res.data.msg, function () {
  242. uni.switchTab({
  243. url:"../index/index"
  244. })
  245. });
  246. }
  247. res.data.data.forEach((item) => {
  248. let tmp = {
  249. value: item.dictKey,
  250. label: item.dictValue
  251. }
  252. that.carTypeList.push(tmp)
  253. })
  254. });
  255. //车辆性质
  256. // operation = "permissions/dict/getByCode?code=car_properties"
  257. that.$http.getDictByCode("car_properties").then (res=>{
  258. if (res.data.code != 200) {
  259. app.globalData.oneFailHint(res.data.msg, function () {
  260. uni.switchTab({
  261. url:"../index/index"
  262. })
  263. });
  264. }
  265. res.data.data.forEach((item) => {
  266. let tmp = {
  267. value:item.dictKey,
  268. label:item.dictValue
  269. }
  270. that.carPropertiesList.push(tmp)
  271. })
  272. });
  273. //燃油类别
  274. // operation = "permissions/dict/getByCode?code=fuel_category"
  275. that.$http.getDictByCode("fuel_category").then (res=>{
  276. if (res.data.code != 200) {
  277. app.globalData.oneFailHint(res.data.msg, function () {
  278. uni.switchTab({
  279. url:"../index/index"
  280. })
  281. });
  282. }
  283. res.data.data.forEach((item)=>{
  284. let tmp = {
  285. value:item.dictKey,
  286. label:item.dictValue
  287. }
  288. that.fuelCategoryList.push(tmp);
  289. })
  290. });
  291. },
  292. carTypeConfirm(e){
  293. this.model.type=e[0].value
  294. this.carTypeLabel=e[0].label
  295. },
  296. carPropertiesConfirm(e){
  297. this.model.properties=e[0].value
  298. this.carPropertiesLabel=e[0].label
  299. },
  300. fuelCategoryConfirm(e){
  301. this.model.fuelCategory=e[0].value
  302. this.fuelCategoryLabel=e[0].label
  303. },
  304. //上传图片
  305. chooseImage(type) {
  306. uni.chooseImage({
  307. count: 1,
  308. //最多可以选择的图片张数,默认9
  309. sourceType: ['album'],
  310. sizeType: ['compressed'],
  311. //可选择原图或压缩后的图片
  312. success: res => {
  313. this.uploadImage(res.tempFilePaths[0], type);
  314. }
  315. });
  316. },
  317. /**上传图片
  318. * @param {Object} imgUrl 图片url
  319. */
  320. uploadImage(imgUrl, type) {
  321. var that = this;
  322. //是否需要md5加密上传人脸照
  323. let is_need_md5 = false;
  324. this.$http.uploadFile(imgUrl).then(res =>{
  325. if (type == 1) {
  326. that.model.carImg = res.data.data.link;
  327. } else if (type == 2) {
  328. that.model.vehicleDrivingLicense1 = res.data.data.link;
  329. } else if (type == 3) {
  330. that.model.vehicleDrivingLicense2 = res.data.data.link;
  331. }
  332. })
  333. },
  334. //车牌号键盘
  335. onInput(val){
  336. this.carNoInputList.push(val)
  337. },
  338. onDelete(){
  339. this.carNoInputList.pop();
  340. },
  341. onConfirm(){
  342. this.model.number=this.plateNumberStr
  343. },
  344. openKeyBoard() {
  345. this.$refs.plateNumber.open();
  346. },
  347. }
  348. }
  349. </script>
  350. <style>
  351. page{
  352. background-color: #FFFFFF;
  353. }
  354. </style>
  355. <style lang="scss" scoped>
  356. .form {
  357. padding: 40rpx 30rpx;
  358. .card {
  359. margin-top: 20rpx;
  360. padding: 0 30rpx;
  361. box-sizing: border-box;
  362. border-radius: 12rpx;
  363. 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);
  364. .item {
  365. padding:30rpx 0;
  366. display: flex;
  367. justify-content: space-between;
  368. }
  369. }
  370. }
  371. </style>