add.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. >
  38. </upload-img>
  39. <view class="text-center padding-top-20 base-color" >
  40. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  41. <text v-if="$isEmpty(model.carImg)">点击上传车辆照片</text>
  42. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="form">
  49. <view class="flex">
  50. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="../../../../static/icon/tag1.png" mode=""></image>
  51. <text class="text-lg text-bold">请上传行驶证正面</text>
  52. </view>
  53. <view class="card">
  54. <view style="padding: 20rpx 0;" @click="chooseImage(2)" class="flex justify-center ">
  55. <view class=" ">
  56. <upload-img
  57. :width="width"
  58. :height="height"
  59. :currentImage="model.vehicleDrivingLicense1"
  60. :bgsrc="setting.vehicleLicenseFront"
  61. >
  62. </upload-img>
  63. <view class="text-center padding-top-20 base-color" >
  64. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  65. <text v-if="$isEmpty(model.carImg)">点击上传行驶证正面</text>
  66. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="form">
  73. <view class="flex">
  74. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="../../../../static/icon/tag1.png" mode=""></image>
  75. <text class="text-lg text-bold">请上传行驶证反面</text>
  76. </view>
  77. <view class="card">
  78. <view style="padding: 20rpx 0;" @click="chooseImage(3)" class="flex justify-center ">
  79. <view class=" ">
  80. <upload-img
  81. :width="width"
  82. :height="height"
  83. :currentImage="model.vehicleDrivingLicense2"
  84. :bgsrc="setting.vehicleLicenseContrary"
  85. >
  86. </upload-img>
  87. <view class="text-center padding-top-20 base-color" >
  88. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  89. <text v-if="$isEmpty(model.carImg)">点击上传行驶证反面</text>
  90. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <view >
  97. <view class="bg-white" style="height: 80rpx;"></view>
  98. <view class="" @click="submit" style="width: 90%;margin: 0 auto ;margin-bottom: 10%;">
  99. <view class="cu-btn round base-bg-color" style="padding: 40rpx;width: 100%;" >
  100. <text class="cuIcon-add"></text>
  101. <text v-text="model.id?'重新审核':'确认添加'"></text>
  102. </view>
  103. </view>
  104. </view>
  105. <u-select @confirm="carTypeConfirm" v-model="carTypeShow" :list="carTypeList"></u-select>
  106. <u-select @confirm="carPropertiesConfirm" v-model="carPropertiesShow" :list="carPropertiesList"></u-select>
  107. <u-select @confirm="fuelCategoryConfirm" v-model="fuelCategoryShow" :list="fuelCategoryList"></u-select>
  108. <keyboard-package z-index="999" ref="plateNumber" type="plateNumber" @onInput="onInput" @onDelete="onDelete" @onConfirm="onConfirm"/>
  109. </view>
  110. </template>
  111. <script>
  112. import keyboardPackage from "@/components/keyboard-package/keyboard-package.vue"
  113. import uploadImg from '@/components/uploadimg/uploadImg.vue'
  114. import setting from "@/assets/http/setting.js"
  115. var that;
  116. export default {
  117. components:{
  118. uploadImg,keyboardPackage
  119. },
  120. data() {
  121. return {
  122. setting:setting,
  123. labelWidth:'200',
  124. width:480,
  125. height:320,
  126. //员工id
  127. userId:'',
  128. //园区id
  129. agencyId:'',
  130. //车牌号
  131. carNoInputList:[],
  132. //车辆类型
  133. carTypeList:[],
  134. carTypeShow:false,
  135. carTypeLabel:'',
  136. //车辆性质
  137. carPropertiesList:[],
  138. carPropertiesShow:false,
  139. carPropertiesLabel:'',
  140. //燃油类别
  141. fuelCategoryList:[],
  142. fuelCategoryShow:false,
  143. fuelCategoryLabel:'',
  144. model:{
  145. type:'',//车辆类型的key
  146. number:'',//车牌号
  147. properties:'',//车辆性质的key,
  148. fuelCategory:'',//燃油类别的key
  149. carImg:'',//车辆照片
  150. vehicleDrivingLicense1:'',//行驶证正面
  151. vehicleDrivingLicense2:'',//行驶证反面
  152. },
  153. }
  154. },
  155. onLoad(options) {
  156. that=this
  157. let loginType=this.$cache.get('loginType')
  158. this.userId=this.$cache.get('userId')
  159. this.agencyId=this.$cache.get('agencyId')
  160. if (loginType!=this.$loginType.STAFF||
  161. this.$isEmpty(this.userId)||
  162. this.$isEmpty(this.agencyId)) {
  163. this.$dialog.showModal('系统异常',false).then(res=>{
  164. this.$navigateBack()
  165. })
  166. }
  167. this.parseParams(options)
  168. },
  169. computed:{
  170. plateNumberStr(){
  171. let str='';
  172. this.carNoInputList.forEach(item=>{
  173. str+=item.toString();
  174. })
  175. this.model.number=str
  176. return str;
  177. }
  178. },
  179. methods: {
  180. parseParams(options){
  181. this.carTypeList=this.vuex_carTypeList
  182. this.carPropertiesList=this.vuex_carPropertiesList
  183. this.fuelCategoryList=this.vuex_fuelCategoryList
  184. if (this.$isEmpty(options)) {
  185. return
  186. }
  187. if (!this.$isEmpty(options.id)) {
  188. uni.setNavigationBarTitle({
  189. title:"编辑车辆"
  190. })
  191. }
  192. this.model=options
  193. this.carNoInputList=options.number.split('')
  194. this.carTypeList.forEach(item=>{
  195. if (item.value==options.type) {
  196. this.carTypeLabel=item.label
  197. }
  198. })
  199. this.carPropertiesList.forEach(item=>{
  200. if (item.value==options.properties) {
  201. this.carPropertiesLabel=item.label
  202. }
  203. })
  204. this.fuelCategoryList.forEach(item=>{
  205. if (item.value==options.fuelCategory) {
  206. this.fuelCategoryLabel=item.label
  207. }
  208. })
  209. },
  210. submit(){
  211. if (this.$isEmpty(this.model.number)) {
  212. this.$u.toast('请填写车牌号')
  213. return
  214. }
  215. if (this.$isEmpty(this.model.type)) {
  216. this.$u.toast('请选择车辆类型')
  217. return
  218. }
  219. if (this.$isEmpty(this.model.properties)) {
  220. this.$u.toast('请选择车辆性质')
  221. return
  222. }
  223. if (this.$isEmpty(this.model.fuelCategory)) {
  224. this.$u.toast('请选择燃油类型')
  225. return
  226. }
  227. if (this.$isEmpty(this.model.carImg)) {
  228. this.$u.toast('请上传车辆照片')
  229. return
  230. }
  231. if (this.$isEmpty(this.model.vehicleDrivingLicense1)) {
  232. this.$u.toast('请上传行驶证正面')
  233. return
  234. }
  235. if (this.$isEmpty(this.model.vehicleDrivingLicense2)) {
  236. this.$u.toast('请上传行驶证反面')
  237. return
  238. }
  239. this.model.personId=this.userId
  240. this.model.agencyId=this.agencyId
  241. this.$api.car.carAdd(this.model).then(res=>{
  242. if (res.success==true) {
  243. this.$dialog.showModal('操作成功!',false).then(res=>{
  244. this.$util.isReloadAndBack()
  245. })
  246. }else{
  247. this.$dialog.showModal(res.msg,false)
  248. }
  249. })
  250. },
  251. carTypeConfirm(e){
  252. this.model.type=e[0].value
  253. this.carTypeLabel=e[0].label
  254. },
  255. carPropertiesConfirm(e){
  256. this.model.properties=e[0].value
  257. this.carPropertiesLabel=e[0].label
  258. },
  259. fuelCategoryConfirm(e){
  260. this.model.fuelCategory=e[0].value
  261. this.fuelCategoryLabel=e[0].label
  262. },
  263. //上传图片
  264. chooseImage(type) {
  265. this.$mpi.chooseImage().then(res=>{
  266. this.$api.uploadFile.submit(res[0]).then(res=>{
  267. if (type==1) {
  268. //车辆照片
  269. that.model.carImg=res.data.link
  270. }else if (type==2) {
  271. that.model.vehicleDrivingLicense1=res.data.link//行驶证正面
  272. }else if (type==3) {
  273. that.model.vehicleDrivingLicense2=res.data.link//行驶证反面
  274. }
  275. })
  276. })
  277. },
  278. //车牌号键盘
  279. onInput(val){
  280. console.log(val);
  281. this.carNoInputList.push(val)
  282. },
  283. onDelete(){
  284. this.carNoInputList.pop();
  285. },
  286. onConfirm(){
  287. this.model.number=this.plateNumberStr
  288. console.log(this.model.number);
  289. },
  290. openKeyBoard() {
  291. this.$refs.plateNumber.open();
  292. },
  293. }
  294. }
  295. </script>
  296. <style>
  297. page{
  298. background-color: #FFFFFF;
  299. }
  300. </style>
  301. <style lang="scss" scoped>
  302. .form{
  303. padding: 40rpx 30rpx;
  304. .card{
  305. margin-top: 20rpx;
  306. padding: 0 30rpx;
  307. box-sizing: border-box;
  308. border-radius: 12rpx;
  309. 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);
  310. .item{
  311. padding:30rpx 0;
  312. display: flex;
  313. justify-content: space-between;
  314. }
  315. }
  316. }
  317. </style>