add.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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/icon/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/icon/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/xlyq/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/icon/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/xlyq/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/icon/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/xlyq/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 "@/components/keyboard-package/keyboard-package.vue"
  114. import uploadImg from '@/components/uploadimg/uploadImg.vue'
  115. var that;
  116. export default {
  117. components:{
  118. uploadImg,keyboardPackage
  119. },
  120. data() {
  121. return {
  122. labelWidth:'200',
  123. width:480,
  124. height:320,
  125. //员工id
  126. userId:'',
  127. //园区id
  128. agencyId:'',
  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. },
  152. }
  153. },
  154. onLoad(options) {
  155. that=this
  156. let loginType=this.$cache.get('loginType')
  157. this.userId=this.$cache.get('userId')
  158. this.agencyId=this.$cache.get('agencyId')
  159. if (loginType!=this.$loginType.STAFF||
  160. this.$isEmpty(this.userId)||
  161. this.$isEmpty(this.agencyId)) {
  162. this.$dialog.showModal('系统异常',false).then(res=>{
  163. this.$navigateBack()
  164. })
  165. }
  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. this.carTypeList=this.vuex_carTypeList
  181. this.carPropertiesList=this.vuex_carPropertiesList
  182. this.fuelCategoryList=this.vuex_fuelCategoryList
  183. if (this.$isEmpty(options)) {
  184. return
  185. }
  186. if (!this.$isEmpty(options.id)) {
  187. uni.setNavigationBarTitle({
  188. title:"编辑车辆"
  189. })
  190. }
  191. this.model=options
  192. this.carNoInputList=options.number.split('')
  193. this.carTypeList.forEach(item=>{
  194. if (item.value==options.type) {
  195. this.carTypeLabel=item.label
  196. }
  197. })
  198. this.carPropertiesList.forEach(item=>{
  199. if (item.value==options.properties) {
  200. this.carPropertiesLabel=item.label
  201. }
  202. })
  203. this.fuelCategoryList.forEach(item=>{
  204. if (item.value==options.fuelCategory) {
  205. this.fuelCategoryLabel=item.label
  206. }
  207. })
  208. },
  209. submit(){
  210. if (this.$isEmpty(this.model.number)) {
  211. this.$u.toast('请填写车牌号')
  212. return
  213. }
  214. if (this.$isEmpty(this.model.type)) {
  215. this.$u.toast('请选择车辆类型')
  216. return
  217. }
  218. if (this.$isEmpty(this.model.properties)) {
  219. this.$u.toast('请选择车辆性质')
  220. return
  221. }
  222. if (this.$isEmpty(this.model.fuelCategory)) {
  223. this.$u.toast('请选择燃油类型')
  224. return
  225. }
  226. if (this.$isEmpty(this.model.carImg)) {
  227. this.$u.toast('请上传车辆照片')
  228. return
  229. }
  230. if (this.$isEmpty(this.model.vehicleDrivingLicense1)) {
  231. this.$u.toast('请上传行驶证正面')
  232. return
  233. }
  234. if (this.$isEmpty(this.model.vehicleDrivingLicense2)) {
  235. this.$u.toast('请上传行驶证反面')
  236. return
  237. }
  238. this.model.personId=this.userId
  239. this.model.agencyId=this.agencyId
  240. this.$api.car.carAdd(this.model).then(res=>{
  241. if (res.success==true) {
  242. this.$dialog.showModal('操作成功!',false).then(res=>{
  243. this.$util.isReloadAndBack()
  244. })
  245. }else{
  246. this.$dialog.showModal(res.msg,false)
  247. }
  248. })
  249. },
  250. carTypeConfirm(e){
  251. this.model.type=e[0].value
  252. this.carTypeLabel=e[0].label
  253. },
  254. carPropertiesConfirm(e){
  255. this.model.properties=e[0].value
  256. this.carPropertiesLabel=e[0].label
  257. },
  258. fuelCategoryConfirm(e){
  259. this.model.fuelCategory=e[0].value
  260. this.fuelCategoryLabel=e[0].label
  261. },
  262. //上传图片
  263. chooseImage(type) {
  264. this.$mpi.chooseImage().then(res=>{
  265. this.$api.uploadFile.submit(res[0]).then(res=>{
  266. if (type==1) {
  267. //车辆照片
  268. that.model.carImg=res.data.link
  269. }else if (type==2) {
  270. that.model.vehicleDrivingLicense1=res.data.link//行驶证正面
  271. }else if (type==3) {
  272. that.model.vehicleDrivingLicense2=res.data.link//行驶证反面
  273. }
  274. })
  275. })
  276. },
  277. //车牌号键盘
  278. onInput(val){
  279. console.log(val);
  280. this.carNoInputList.push(val)
  281. },
  282. onDelete(){
  283. this.carNoInputList.pop();
  284. },
  285. onConfirm(){
  286. this.model.number=this.plateNumberStr
  287. console.log(this.model.number);
  288. },
  289. openKeyBoard() {
  290. this.$refs.plateNumber.open();
  291. },
  292. }
  293. }
  294. </script>
  295. <style>
  296. page{
  297. background-color: #FFFFFF;
  298. }
  299. </style>
  300. <style lang="scss" scoped>
  301. .form{
  302. padding: 40rpx 30rpx;
  303. .card{
  304. margin-top: 20rpx;
  305. padding: 0 30rpx;
  306. box-sizing: border-box;
  307. border-radius: 12rpx;
  308. 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);
  309. .item{
  310. padding:30rpx 0;
  311. display: flex;
  312. justify-content: space-between;
  313. }
  314. }
  315. }
  316. </style>