add.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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/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="select" :select-open="agencyShow" @click="agencyShow=true" v-model="agencyName" 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" @click="showResidential" v-model="residentialName" placeholder="请选择所属小区" ></u-input>
  15. </u-form-item>
  16. <u-form-item :required="true" :label-width="labelWidth" label="车主姓名" >
  17. <u-input type="text" v-model="model.personName" placeholder="请填写车主姓名"></u-input>
  18. </u-form-item>
  19. <u-form-item :required="true" :label-width="labelWidth" label="手机号" >
  20. <u-input type="number" v-model="model.personPhone" placeholder="请填写手机号" ></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/tag1.png" mode=""></image>
  28. <text class="text-lg text-bold">请选择基本信息</text>
  29. </view>
  30. <view class="card">
  31. <u-form :model="model" ref="uForm" >
  32. <u-form-item :required="true" :label-width="labelWidth" label="车牌号码" >
  33. <u-input type="text" v-model="model.number" disabled @click="openKeyBoard" placeholder="请填写车牌号码" ></u-input>
  34. </u-form-item>
  35. <u-form-item :required="true" :label-width="labelWidth" label="车辆类型" >
  36. <u-input type="select" :select-open="carTypeShow" v-model="carTypeLabel" placeholder="请选择车辆类型" @click="carTypeShow=true"></u-input>
  37. </u-form-item>
  38. <u-form-item :required="true" :label-width="labelWidth" label="车辆性质" >
  39. <u-input type="select" :select-open="carPropertiesShow" v-model="carPropertiesLabel" placeholder="请选择车辆性质" @click="carPropertiesShow=true"></u-input>
  40. </u-form-item>
  41. <u-form-item :required="true" :label-width="labelWidth" label="燃油类别" >
  42. <u-input type="select" :select-open="fuelCategoryShow" v-model="fuelCategoryLabel" placeholder="请选择燃油类别" @click="fuelCategoryShow=true"></u-input>
  43. </u-form-item>
  44. </u-form>
  45. </view>
  46. </view>
  47. <view class="form">
  48. <view class="flex">
  49. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="../../static/tag1.png" mode=""></image>
  50. <text class="text-lg text-bold">请上传车辆照片</text>
  51. </view>
  52. <view class="card">
  53. <view style="padding: 20rpx 0;" @click="chooseImage(1)" class="flex justify-center ">
  54. <view class=" ">
  55. <upload-img
  56. :width="width"
  57. :height="height"
  58. :currentImage="model.carImg"
  59. bgsrc="http://139.9.103.171:1888/miniofile/xlyq/upload.png"
  60. >
  61. </upload-img>
  62. <view class="text-center padding-top-20 base-color" >
  63. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  64. <text v-if="$isEmpty(model.carImg)">点击上传车辆照片</text>
  65. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="form">
  72. <view class="flex">
  73. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="../../static/tag1.png" mode=""></image>
  74. <text class="text-lg text-bold">请上传行驶证正面</text>
  75. </view>
  76. <view class="card">
  77. <view style="padding: 20rpx 0;" @click="chooseImage(2)" class="flex justify-center ">
  78. <view class=" ">
  79. <upload-img
  80. :width="width"
  81. :height="height"
  82. :currentImage="model.vehicleDrivingLicense1"
  83. bgsrc="http://139.9.103.171:1888/miniofile/xlyq/zm.png"
  84. >
  85. </upload-img>
  86. <view class="text-center padding-top-20 base-color" >
  87. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  88. <text v-if="$isEmpty(model.carImg)">点击上传行驶证正面</text>
  89. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="form">
  96. <view class="flex">
  97. <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="../../static/tag1.png" mode=""></image>
  98. <text class="text-lg text-bold">请上传行驶证反面</text>
  99. </view>
  100. <view class="card">
  101. <view style="padding: 20rpx 0;" @click="chooseImage(3)" class="flex justify-center ">
  102. <view class=" ">
  103. <upload-img
  104. :width="width"
  105. :height="height"
  106. :currentImage="model.vehicleDrivingLicense2"
  107. bgsrc="http://139.9.103.171:1888/miniofile/xlyq/fm.png"
  108. >
  109. </upload-img>
  110. <view class="text-center padding-top-20 base-color" >
  111. <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
  112. <text v-if="$isEmpty(model.carImg)">点击上传行驶证反面</text>
  113. <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view >
  120. <view class="bg-white" style="height: 80rpx;"></view>
  121. <view class="" @click="submit" style="width: 90%;margin: 0 auto ;margin-bottom: 10%;">
  122. <view class="cu-btn round" style="padding: 40rpx;width: 100%;background-color: #5064eb;color: #FFFFFF;" >
  123. <text class="cuIcon-add"></text>
  124. <text v-text="model.id?'重新审核':'确认添加'"></text>
  125. </view>
  126. </view>
  127. </view>
  128. <u-popup border-radius="60" height="60%" mode="bottom" v-model="agencyShow">
  129. <view class="fixed cu-bar search bg-white">
  130. <view class="search-form round">
  131. <text class="cuIcon-search"></text>
  132. <u-input style="width: 90%;" v-model="agencyKeyword" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  133. </view>
  134. </view>
  135. <scroll-view v-if="!$isEmpty(agencyList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
  136. <view @click="agencyConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in agencyList" :key="index">
  137. <text>{{item.agencyName}}</text>
  138. </view>
  139. <u-divider v-if="agencyList.length>=10" height="80">只显示十条数据</u-divider>
  140. </scroll-view>
  141. <u-empty v-else name="search"></u-empty>
  142. </u-popup>
  143. <u-popup border-radius="60" height="60%" mode="bottom" v-model="residentialShow">
  144. <view class="fixed cu-bar search bg-white">
  145. <view class="search-form round">
  146. <text class="cuIcon-search"></text>
  147. <u-input style="width: 90%;" v-model="residentialKeyword" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  148. </view>
  149. </view>
  150. <scroll-view v-if="!$isEmpty(residentialList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
  151. <view @click="residentialConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in residentialList" :key="index">
  152. <text>{{item.name}}</text>
  153. </view>
  154. <u-divider v-if="residentialList.length>=10" height="80">只显示十条数据</u-divider>
  155. </scroll-view>
  156. <u-empty v-else name="search"></u-empty>
  157. </u-popup>
  158. <u-select @confirm="carTypeConfirm" v-model="carTypeShow" :list="carTypeList"></u-select>
  159. <u-select @confirm="carPropertiesConfirm" v-model="carPropertiesShow" :list="carPropertiesList"></u-select>
  160. <u-select @confirm="fuelCategoryConfirm" v-model="fuelCategoryShow" :list="fuelCategoryList"></u-select>
  161. <keyboard-package z-index="999" ref="plateNumber" type="plateNumber" @onInput="onInput" @onDelete="onDelete" @onConfirm="onConfirm"/>
  162. </view>
  163. </template>
  164. <script>
  165. import keyboardPackage from "@/components/keyboard-package/keyboard-package.vue"
  166. import uploadImg from '@/components/uploadimg/uploadImg.vue'
  167. var that;
  168. export default {
  169. components:{
  170. uploadImg,keyboardPackage
  171. },
  172. data() {
  173. return {
  174. labelWidth:'200',
  175. width:480,
  176. height:320,
  177. //社区
  178. agencyName:'',
  179. agencyShow:false,
  180. agencyKeyword:'',
  181. agencyList:[],
  182. //小区
  183. residentialShow:false,
  184. residentialName:'',
  185. residentialKeyword:'',
  186. residentialList:[],
  187. //车牌号
  188. carNoInputList:[],
  189. //车辆类型
  190. carTypeList:[],
  191. carTypeShow:false,
  192. carTypeLabel:'',
  193. //车辆性质
  194. carPropertiesList:[],
  195. carPropertiesShow:false,
  196. carPropertiesLabel:'',
  197. //燃油类别
  198. fuelCategoryList:[],
  199. fuelCategoryShow:false,
  200. fuelCategoryLabel:'',
  201. model:{
  202. type:'',//车辆类型的key
  203. number:'',//车牌号
  204. properties:'',//车辆性质的key,
  205. fuelCategory:'',//燃油类别的key
  206. carImg:'',//车辆照片
  207. vehicleDrivingLicense1:'',//行驶证正面
  208. vehicleDrivingLicense2:'',//行驶证反面
  209. //车主信息
  210. agencyId:'',//社区id
  211. residentialId:'',//小区id
  212. personName:'',//车主姓名
  213. personPhone:''//车主手机号
  214. },
  215. }
  216. },
  217. onLoad(options ) {
  218. that=this
  219. //获取字典
  220. this.getDict()
  221. //获取社区列表
  222. this.fetchAgencyList()
  223. },
  224. computed:{
  225. plateNumberStr(){
  226. let str='';
  227. this.carNoInputList.forEach(item=>{
  228. str+=item.toString();
  229. })
  230. this.model.number=str
  231. return str;
  232. }
  233. },
  234. watch:{
  235. agencyKeyword(){
  236. let that=this
  237. //节流函数
  238. if (this.timer){
  239. clearTimeout(this.timer)//阻止setTimeout函数的执行
  240. }
  241. this.timer = setTimeout(() => {
  242. that.agencyList=[]
  243. this.fetchAgencyList()
  244. }, 500)
  245. },
  246. residentialKeyword(){
  247. let that=this
  248. //节流函数
  249. if (this.timer){
  250. clearTimeout(this.timer)//阻止setTimeout函数的执行
  251. }
  252. this.timer = setTimeout(() => {
  253. that.residentialList=[]
  254. this.fetchResidentialList()()
  255. }, 500)
  256. }
  257. },
  258. methods: {
  259. //社区
  260. fetchAgencyList(){
  261. this.$api.agency.page({name:this.agencyKeyword}).then(res=>{
  262. this.agencyList=res.data.records
  263. })
  264. },
  265. agencyConfirm(e){
  266. this.model.agencyId=e.id
  267. this.agencyName=e.agencyName
  268. this.agencyShow=false
  269. this.fetchResidentialList()
  270. },
  271. //小区
  272. showResidential(){
  273. if (this.$isEmpty(this.model.agencyId)) {
  274. this.$u.toast('请选择社区')
  275. return
  276. }
  277. this.residentialShow=true
  278. },
  279. fetchResidentialList(){
  280. let params={
  281. name:this.residentialKeyword,
  282. agencyId:this.model.agencyId
  283. }
  284. this.$api.residential.pageBycondition(params).then(res=>{
  285. this.residentialList=res.data.records
  286. })
  287. },
  288. residentialConfirm(e){
  289. this.residentialName=e.name
  290. this.model.residentialId=e.id
  291. this.residentialShow=false
  292. },
  293. submit(){
  294. if (this.$isEmpty(this.model.agencyId)) {
  295. this.$u.toast('请选择社区')
  296. return
  297. }
  298. if (this.$isEmpty(this.model.residentialId)) {
  299. this.$u.toast('请选择小区')
  300. return
  301. }
  302. if (this.$isEmpty(this.model.number)) {
  303. this.$u.toast('请填写车牌号')
  304. return
  305. }
  306. if (this.$isEmpty(this.model.type)) {
  307. this.$u.toast('请选择车辆类型')
  308. return
  309. }
  310. if (this.$isEmpty(this.model.properties)) {
  311. this.$u.toast('请选择车辆性质')
  312. return
  313. }
  314. if (this.$isEmpty(this.model.fuelCategory)) {
  315. this.$u.toast('请选择燃油类型')
  316. return
  317. }
  318. if (this.$isEmpty(this.model.carImg)) {
  319. this.$u.toast('请上传车辆照片')
  320. return
  321. }
  322. if (this.$isEmpty(this.model.vehicleDrivingLicense1)) {
  323. this.$u.toast('请上传行驶证正面')
  324. return
  325. }
  326. if (this.$isEmpty(this.model.vehicleDrivingLicense2)) {
  327. this.$u.toast('请上传行驶证反面')
  328. return
  329. }
  330. this.$api.car.carAdd(this.model).then(res=>{
  331. if (res.success==true) {
  332. this.$dialog.showModal('操作成功!',false).then(res=>{
  333. this.$util.isReloadAndBack()
  334. })
  335. }else{
  336. this.$dialog.showModal(res.msg,false)
  337. }
  338. })
  339. },
  340. getDict(){
  341. let dict=this.$cache.get('dict')
  342. if (dict) {
  343. //缓存中有字典值
  344. this.carTypeList=dict.carTypeList
  345. this.carPropertiesList=dict.carPropertiesList
  346. this.fuelCategoryList=dict.fuelCategoryList
  347. return
  348. }
  349. //车辆类型
  350. this.$api.dict({code:'car_type'}).then(res=>{
  351. res.data.forEach((item)=>{
  352. let tmp={
  353. value:item.dictKey,
  354. label:item.dictValue
  355. }
  356. this.carTypeList.push(tmp)
  357. })
  358. })
  359. //车辆性质
  360. this.$api.dict({code:'car_properties'}).then(res=>{
  361. res.data.forEach((item)=>{
  362. let tmp={
  363. value:item.dictKey,
  364. label:item.dictValue
  365. }
  366. this.carPropertiesList.push(tmp)
  367. })
  368. })
  369. //燃油类别
  370. this.$api.dict({code:'fuel_category'}).then(res=>{
  371. res.data.forEach((item)=>{
  372. let tmp={
  373. value:item.dictKey,
  374. label:item.dictValue
  375. }
  376. this.fuelCategoryList.push(tmp)
  377. })
  378. })
  379. },
  380. carTypeConfirm(e){
  381. this.model.type=e[0].value
  382. this.carTypeLabel=e[0].label
  383. },
  384. carPropertiesConfirm(e){
  385. this.model.properties=e[0].value
  386. this.carPropertiesLabel=e[0].label
  387. },
  388. fuelCategoryConfirm(e){
  389. this.model.fuelCategory=e[0].value
  390. this.fuelCategoryLabel=e[0].label
  391. },
  392. //上传图片
  393. chooseImage(type) {
  394. this.$mpi.chooseImage().then(res=>{
  395. this.$api.uploadFile.submit(res[0]).then(res=>{
  396. if (type==1) {
  397. //车辆照片
  398. that.model.carImg=res.data
  399. }else if (type==2) {
  400. that.model.vehicleDrivingLicense1=res.data//行驶证正面
  401. }else if (type==3) {
  402. that.model.vehicleDrivingLicense2=res.data//行驶证反面
  403. }
  404. })
  405. })
  406. },
  407. //车牌号键盘
  408. onInput(val){
  409. console.log(val);
  410. this.carNoInputList.push(val)
  411. },
  412. onDelete(){
  413. this.carNoInputList.pop();
  414. },
  415. onConfirm(){
  416. this.model.number=this.plateNumberStr
  417. console.log(this.model.number);
  418. },
  419. openKeyBoard() {
  420. this.$refs.plateNumber.open();
  421. },
  422. }
  423. }
  424. </script>
  425. <style>
  426. page{
  427. background-color: #FFFFFF;
  428. }
  429. </style>
  430. <style lang="scss" scoped>
  431. .form{
  432. padding: 40rpx 30rpx;
  433. .card{
  434. margin-top: 20rpx;
  435. padding: 0 30rpx;
  436. box-sizing: border-box;
  437. border-radius: 12rpx;
  438. 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);
  439. .item{
  440. padding:30rpx 0;
  441. display: flex;
  442. justify-content: space-between;
  443. }
  444. }
  445. }
  446. </style>