addinfo.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view>
  3. <ujp-navbar :title="id!=0?'编辑':'新增'">
  4. <view slot="right" @click="infodelete()"
  5. v-if="id!=0"
  6. style="margin-right: 20px;">
  7. <span class="delete" >删除</span>
  8. </view>
  9. </ujp-navbar>
  10. <u-keyboard ref="uKeyboard"
  11. @change="valChange" @backspace="backspace"
  12. mode="car" v-model="show"></u-keyboard>
  13. <view class="ower-infos">
  14. <view class="infos-item border-none">
  15. <view class="title">
  16. 车牌号码<text class="asterisk">*</text>
  17. </view>
  18. <view class="content" @click="show=true">
  19. {{obj.carNum?obj.carNum:'请填写车牌号码'}}
  20. </view>
  21. </view>
  22. <view class="infos-item">
  23. <view class="title">
  24. 车辆品牌
  25. </view>
  26. <view class="content">
  27. <u-input v-model="obj.brand" placeholder="请填写车辆品牌" />
  28. </view>
  29. </view>
  30. <view class="infos-item">
  31. <view class="title">
  32. 限乘人数
  33. </view>
  34. <view class="content">
  35. <u-input type="number" v-model="obj.capacity" placeholder="请填写限乘人数" />
  36. </view>
  37. </view>
  38. </view>
  39. <u-button type="primary" @click="submit()">保存</u-button>
  40. </view>
  41. </template>
  42. <script>
  43. import * as API from '@/apis/accountType8.js'
  44. import {
  45. checkPhone
  46. } from '@/utils'
  47. export default {
  48. data() {
  49. return {
  50. show:false,
  51. value:'',
  52. uuid:'',
  53. id:"",
  54. entAccountId:"",
  55. obj:{
  56. carNum:"",
  57. entAccountId:0,
  58. brand:"",
  59. capacity:"",
  60. carId:"",
  61. }
  62. }
  63. },
  64. onReady() {
  65. if(this.id!=0){
  66. this.getInfo()
  67. }
  68. },
  69. onLoad(op) {
  70. this.entAccountId=op.p
  71. this.id=op.id
  72. this.uuid=op.uuid;
  73. },
  74. methods: {
  75. // 按键被点击(点击退格键不会触发此事件)
  76. valChange(val) {
  77. // 将每次按键的值拼接到value变量中,注意+=写法
  78. this.value += val;
  79. console.log(this.value);
  80. this.obj.carNum=this.value
  81. },
  82. // 退格键被点击
  83. backspace() {
  84. // 删除value的最后一个字符
  85. if(this.value.length) this.value = this.value.substr(0, this.value.length - 1);
  86. console.log(this.value);
  87. this.obj.carNum=this.value
  88. },
  89. infodelete(){
  90. uni.showLoading({
  91. title: "加载中",
  92. mask: true,
  93. })
  94. this.obj.entAccountId=this.entAccountId
  95. API.entCarDelete(this.obj).then((res) => {
  96. uni.hideLoading()
  97. this.carhelp.set("addOwnerInformation",{
  98. uuid:this.uuid,
  99. selectObj:this.obj
  100. })
  101. uni.showModal({
  102. showCancel:false,
  103. title: '提示',
  104. content: '操作成功',
  105. success: function (res) {
  106. uni.navigateBack({
  107. })
  108. }
  109. });
  110. }).catch(error => {
  111. uni.showToast({
  112. title: error
  113. })
  114. })
  115. },
  116. submit(){
  117. if(!this.obj.carNum){
  118. uni.showToast({
  119. title: "请填写车牌号码"
  120. })
  121. return false
  122. }
  123. uni.showLoading({
  124. title: "加载中",
  125. mask: true,
  126. })
  127. this.obj.entAccountId=this.entAccountId
  128. API.entCarSave(this.obj).then((res) => {
  129. uni.hideLoading()
  130. this.carhelp.set("addOwnerInformation",{
  131. uuid:this.uuid,
  132. selectObj:this.obj
  133. })
  134. uni.showModal({
  135. showCancel:false,
  136. title: '提示',
  137. content: '操作成功',
  138. success: function (res) {
  139. uni.navigateBack({
  140. })
  141. }
  142. });
  143. }).catch(error => {
  144. uni.showToast({
  145. title: error
  146. })
  147. })
  148. },
  149. getInfo(){
  150. uni.showLoading({
  151. title: "加载中",
  152. mask: true,
  153. })
  154. API.entCarDetails({
  155. entCarId:this.id,
  156. }).then((res) => {
  157. this.obj=res.data.entRegCar;
  158. this.obj.carId=this.id
  159. uni.hideLoading()
  160. }).catch(error => {
  161. uni.showToast({
  162. title: error
  163. })
  164. })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. page{
  171. background-color: #f3f4f7;
  172. }
  173. .ower-infos{
  174. background-color: #fff;
  175. padding-left: 16px;
  176. .border-none{
  177. border: none !important;
  178. }
  179. .infos-item{
  180. padding: 24rpx 0;
  181. display: flex;
  182. border-bottom: 1px solid #e9e9e9 ;
  183. .title{
  184. width: 30%;
  185. font-size: 32rpx;
  186. line-height: 64rpx;
  187. color: #7d7d7d;
  188. .asterisk{
  189. color: #EE3138;
  190. }
  191. }
  192. .content{
  193. color: rgba(172, 172, 172, 100);
  194. font-size: 32rpx;
  195. line-height: 64rpx;
  196. }
  197. }
  198. }
  199. .u-btn{
  200. background-color: rgba(0, 90, 217, 100);
  201. margin: 16px;
  202. height: 44px;
  203. line-height: 44px;
  204. font-size: 18px
  205. }
  206. .delete{
  207. color: rgba(238, 49, 56, 100);
  208. font-size: 16px;
  209. }
  210. </style>