add.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="" >
  3. <u-toast ref="uToast"/>
  4. <view class="bg-white" style="padding: 10rpx 30rpx;margin: 20rpx;border-radius: 12rpx;">
  5. <u-form :label-style="labelStyle" label-width="150" :model="form" ref="uForm">
  6. <u-form-item label="车主姓名" :required="true"><u-input v-model="form.userName" placeholder="车主姓名"/></u-form-item>
  7. <u-form-item v-if="!$isEmpty(form.id)" label="手机号码" :required="true"><u-input type="number" v-model="form.userMobile" placeholder="请输入手机号码"/></u-form-item>
  8. <u-form-item label="所属小区" :required="true">
  9. <u-input type="select" :select-open="residentialShow" v-model="residentialName" placeholder="请选择小区" @click="residentialShow=true"></u-input>
  10. <!-- <u-input v-else disabled v-model="form.xqName" ></u-input> -->
  11. </u-form-item>
  12. <u-form-item label="车牌号" :required="true">
  13. <u-input v-model="form.loginName" placeholder="请填写车牌号"></u-input>
  14. </u-form-item>
  15. <u-form-item label="车辆型号">
  16. <u-input v-model="form.loginPwd" placeholder="请填写车辆型号"></u-input>
  17. </u-form-item>
  18. <!-- <u-form-item label="燃油类别">
  19. <u-input v-model="form.fuelCategory" placeholder="请填写燃油类别"></u-input>
  20. </u-form-item> -->
  21. <u-form-item label="车身颜色">
  22. <u-input v-model="form.remark" placeholder="请填写车身颜色"></u-input>
  23. </u-form-item>
  24. <!-- <u-form-item label="车辆照片">
  25. <u-input v-model="form.carImg" placeholder="车辆照片"></u-input>
  26. </u-form-item> -->
  27. </u-form>
  28. </view>
  29. <!-- 小区 -->
  30. <u-popup border-radius="60" height="60%" mode="bottom" v-model="residentialShow">
  31. <view class="fixed cu-bar search bg-white">
  32. <view class="search-form round">
  33. <text class="cuIcon-search"></text>
  34. <u-input style="width: 90%;" v-model="residentialKeyword" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  35. </view>
  36. </view>
  37. <scroll-view v-if="!$isEmpty(residentialList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
  38. <view @click="residentialConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in residentialList" :key="index">
  39. <text>{{item.name}}</text>
  40. </view>
  41. <u-divider v-if="residentialList.length>=10" height="80">只显示十条数据</u-divider>
  42. </scroll-view>
  43. <u-empty v-else name="search"></u-empty>
  44. </u-popup>
  45. <view @click="confirm" class="bottom-bar" >
  46. <view class="cu-btn bg-blue radius" style="width: 70%;height: 84rpx;">
  47. 提交
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. name: '',
  55. data() {
  56. return {
  57. labelStyle:{
  58. "fontWeight":"600"
  59. },
  60. form:{
  61. userName:'',
  62. xqName:'',
  63. userMobile:'',
  64. fuelCategory:'',
  65. loginName:'',
  66. loginPwd:'',
  67. xqId:'',
  68. // carImg:'',
  69. remark:''
  70. },
  71. //小区
  72. residentialName:'',
  73. residentialShow:false,
  74. residentialKeyword:'',
  75. residentialList:[],
  76. };
  77. },
  78. onLoad(options) {
  79. //加载小区数据
  80. this.fetchResidentialList()
  81. if (!this.$isEmpty(options.id)) {
  82. this.form.id=options.id
  83. this.fetchDataDetail()
  84. uni.setNavigationBarTitle({
  85. title:"修改车辆信息"
  86. })
  87. }
  88. },
  89. watch:{
  90. //小区
  91. residentialKeyword(){
  92. let that=this
  93. if (this.timer){
  94. clearTimeout(this.timer)
  95. }
  96. this.timer = setTimeout(() => {
  97. that.residentialList=[]
  98. that.getResidentailList()
  99. }, 500)
  100. },
  101. },
  102. methods:{
  103. fetchDataDetail(){
  104. console.log(this.form.id)
  105. this.$api.carManage.page({id:this.form.id}).then(res=>{
  106. console.log(res.data.records[0])
  107. this.form=res.data.records[0]
  108. })
  109. },
  110. /**
  111. * 获取小区数据列表
  112. */
  113. fetchResidentialList(){
  114. let params={
  115. isSelect: true,
  116. name:this.residentialKeyword
  117. }
  118. this.$api.residential.page(params).then(res=>{
  119. this.residentialList = res.list
  120. })
  121. },
  122. //点击选择小区时
  123. residentialConfirm(item){
  124. //赋值给提交的数据
  125. this.form.residentialId=item.id
  126. //赋值给回显的名称
  127. this.residentialName=item.name
  128. this.residentialShow=false
  129. },
  130. confirm(){
  131. if (this.$isEmpty(this.form.userName)) {
  132. this.$u.toast('请输入车主姓名')
  133. return
  134. }
  135. if (this.$isEmpty(this.form.residentialId)) {
  136. this.$u.toast("请选择小区")
  137. return
  138. }
  139. console.log(this.form);
  140. if (this.$isEmpty(this.form.id)) {
  141. return
  142. this.$api.carManage.submit(this.form).then(res=>{
  143. if (res.data) {
  144. this.$dialog.showModal('操作成功',false).then(res=>{
  145. uni.navigateBack()
  146. })
  147. }else{
  148. this.$u.toast('操作失败')
  149. }
  150. })
  151. //新增
  152. }else{
  153. let {oldId,orgPosition,...params}=this.form
  154. //修改
  155. this.$api.carManage.submit(params).then(res=>{
  156. if (res.data==true) {
  157. this.$dialog.showModal('操作成功',false).then(res=>{
  158. uni.navigateBack()
  159. })
  160. }else{
  161. this.$u.toast('操作失败')
  162. }
  163. })
  164. }
  165. }
  166. }
  167. };
  168. </script>
  169. <style lang="scss" scoped>
  170. page{
  171. background-color: #FFFFFF;
  172. }
  173. </style>