add.vue 12 KB

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