Blame view

src/views/mycar/index.vue 7.41 KB
613d2a9c   Andy   add icon
1
  <template>
ec35bad6   Andy   add 账户设置 前端页面
2
    <div>
613d2a9c   Andy   add icon
3
  
ec35bad6   Andy   add 账户设置 前端页面
4
5
6
      <div class="search-wrap">
        <el-row :gutter="20">
          <el-form ref="form" :model="form" label-width="60px" label-position="left">
50ae39a5   Andy   add bug修复
7
            <el-col :xs="8" :sm="6" :md="7" :lg="7" :xl="7">
ea291b39   王富生   提交登陆
8
9
10
11
              <el-form-item label="账户ID">
                <el-input v-model="form.custId" maxlength="20" :disabled="true"/>
              </el-form-item>
            </el-col>
50ae39a5   Andy   add bug修复
12
            <el-col :xs="8" :sm="6" :md="7" :lg="7" :xl="7">
ea291b39   王富生   提交登陆
13
14
              <el-form-item label="手机号">
                <el-input v-model="form.phone" maxlength="20" :disabled="true"/>
ec35bad6   Andy   add 账户设置 前端页面
15
16
17
18
19
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
ea291b39   王富生   提交登陆
20
21
22
23
24
25
26
27
28
29
30
31
32
33
      <el-row :gutter="20" style="margin-top: 8px">
        <el-col :span="12">
          <el-card class="box-card" style="height: 300px">
            <div slot="header" class="clearfix">
              <span>车牌绑定</span>
            </div>
            <el-form ref="bondform" :model="bondform" label-width="60px" label-position="left" :rules="rules">
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item label="车牌号" prop="carNum">
                    <el-input type="text" v-model="bondform.carNum"/>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
edc38b57   王富生   提交bug
34
                  <el-button type="primary" :loading="bondformBtnVisible" @click="checkCarNum('bondform')">绑定车牌</el-button>
ea291b39   王富生   提交登陆
35
36
37
38
39
40
41
42
                </el-col>
              </el-row>
  
            </el-form>
  
          </el-card>
        </el-col>
        <el-col :span="12">
edc38b57   王富生   提交bug
43
          <el-card class="box-card" style="min-height: 300px">
ea291b39   王富生   提交登陆
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
            <div slot="header" class="clearfix">
              <span>解绑车牌</span>
            </div>
            <el-form ref="form" :model="form" label-width="60px" label-position="left">
              <el-row :gutter="20" v-for="item in alredyBoundCar" style="margin-top: 4px">
                <el-col :span="12">
                  <el-form-item label="已绑车牌">
                    <el-input  :value="item.carNumber"/>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-button type="primary" @click="alredyBoundCarBtn(item.carNumber)">解绑车牌</el-button>
                </el-col>
              </el-row>
  
            </el-form>
  
          </el-card>
        </el-col>
      </el-row>
  
613d2a9c   Andy   add icon
65
  
613d2a9c   Andy   add icon
66
67
68
69
    </div>
  </template>
  
  <script>
373bae16   王富生   登陆验证码提交
70
    import {checkCarNumIsbind,getPersonCarNumPC,boundCarNum,unboundCarNum} from '@/api/mycar.js';
613d2a9c   Andy   add icon
71
    export default {
613d2a9c   Andy   add icon
72
      data() {
ea291b39   王富生   提交登陆
73
74
75
76
77
        var carNumValidator = (rule, value, callback) => {
          if (value === '') {
            callback(new Error('请输入车牌号'));
          }
  
249594b5   王富生   提交登陆
78
          if (!/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/.test(this.bondform.carNum)||this.bondform.carNum.length<7) {
ea291b39   王富生   提交登陆
79
80
81
82
83
            callback(new Error('请输入正确的车牌号'));
          }
          callback();
  
        };
613d2a9c   Andy   add icon
84
        return {
ec35bad6   Andy   add 账户设置 前端页面
85
          form: {
ea291b39   王富生   提交登陆
86
            custId: '',
249594b5   王富生   提交登陆
87
            phone: '',
ec35bad6   Andy   add 账户设置 前端页面
88
          },
ea291b39   王富生   提交登陆
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
          /**绑定车牌.*/
          bondform: {
            carNum: ''
          },
  
          /**已绑定车牌.*/
          alredyBoundCar:[],
          bondformBtnVisible: false,
          dialogFormVisible: false,
          problemform: {
            carnum: '',
          },
          rules:{
            carNum:[{ validator: carNumValidator, trigger: 'blur' }]
            }
613d2a9c   Andy   add icon
104
        }
ea291b39   王富生   提交登陆
105
106
  
  
613d2a9c   Andy   add icon
107
      },
613d2a9c   Andy   add icon
108
      methods: {
edc38b57   王富生   提交bug
109
110
        /**校验是否已经绑定*/
        checkCarNum(formName){
dfc9b132   Andy   首页add 地图缩放
111
          // debugger
edc38b57   王富生   提交bug
112
          //checkBoundCarNum
249594b5   王富生   提交登陆
113
114
115
          let that = this;
          let custId = this.form.custId;
          let carNum = this.bondform.carNum;
edc38b57   王富生   提交bug
116
          let existFlg = false;
ea291b39   王富生   提交登陆
117
          this.$refs[formName].validate((valid) => {
373bae16   王富生   登陆验证码提交
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
            if (!valid)  return false;
            debugger
  
            if(null != that.alredyBoundCar && that.alredyBoundCar.length >0){
              if(that.alredyBoundCar.length >5){
                this.$message({
                  type: 'error',
                  message: '最多只能绑定5个车牌!'
                });
                return false
              }else{
                let flg =false;
                that.alredyBoundCar.forEach((item,index)=>{
                  if(item.carNumber == carNum){
                    flg = true
                  }
                });
                if(flg){
                  this.$message({
                    type: 'error',
                    message: '请勿做重复绑定!'
edc38b57   王富生   提交bug
139
                  });
373bae16   王富生   登陆验证码提交
140
141
142
143
                  return false
                }else {
                  let checkReq ={
                    carNumber:carNum
edc38b57   王富生   提交bug
144
                  }
373bae16   王富生   登陆验证码提交
145
146
147
148
149
150
151
152
153
154
155
156
157
                  checkCarNumIsbind(checkReq).then(response =>{
                    if(response.code =='8888'){
                      if(null != response.data && null != response.data.id){
                        this.$message({
                          type: 'error',
                          message: '改车牌已被其他车主绑定!'
                        });
                        return false
                      }else{
                        that.bondCarNum(custId,carNum)
                      }
                    }
                  });
edc38b57   王富生   提交bug
158
                }
373bae16   王富生   登陆验证码提交
159
160
              }
  
edc38b57   王富生   提交bug
161
            }
373bae16   王富生   登陆验证码提交
162
  
edc38b57   王富生   提交bug
163
164
165
166
167
          });
        },
        /**绑定车牌*/
        bondCarNum:function(custId,carNum){
             let  that =this;
249594b5   王富生   提交登陆
168
169
170
171
172
173
174
175
176
177
178
179
180
              let req ={
                custId:custId,
                carNumber:carNum,
                sysCode:'1001',
                carBindingStatus:1, //绑定
              };
              boundCarNum(req).then(response =>{
                 if(response.code='8888'){
                   that.bondform.carNum='';
                   this.$message({
                     type: 'success',
                     message: '车牌绑定成功!'
                   });
edc38b57   王富生   提交bug
181
                   that.getPersonCarNumPC();
249594b5   王富生   提交登陆
182
183
184
  
                 }
              });
edc38b57   王富生   提交bug
185
186
  
  
ec35bad6   Andy   add 账户设置 前端页面
187
        },
ea291b39   王富生   提交登陆
188
189
190
191
192
193
194
195
196
        /**获取车牌.*/
        getPersonCarNumPC:function () {
          let that =this;
          getPersonCarNumPC().then(response =>{
  
            if(response.code ='8888'){
              that.alredyBoundCar=response.data;
            }
          });
ec35bad6   Andy   add 账户设置 前端页面
197
        },
ea291b39   王富生   提交登陆
198
199
        /**解绑车牌.*/
        alredyBoundCarBtn:function (carNum) {
249594b5   王富生   提交登陆
200
201
202
203
204
205
206
207
208
209
210
211
212
213
          if("" == carNum || null ==carNum || undefined == carNum){
            this.$message({
              type: 'error',
              message: '解绑的车牌不能为空'
            });
          }
          let that =this;
          let custId = this.form.custId;
          let req ={
            custId:custId,
            carNumber:carNum,
            sysCode:'1001',
            carBindingStatus:2, //解绑
          };
dfc9b132   Andy   首页add 地图缩放
214
          // debugger
249594b5   王富生   提交登陆
215
216
217
218
219
220
221
222
223
224
225
226
227
228
          unboundCarNum(req).then(response =>{
            if(response.code ='8888'){
              this.$message({
                type: 'success',
                message: '车牌解绑成功!'
              });
              this.getPersonCarNumPC();
            }else{
              this.$message({
                type: 'error',
                message: '车牌解绑失败!'
              });
            }
          });
ea291b39   王富生   提交登陆
229
230
231
232
233
234
235
236
237
        }
      },
      mounted:function(){
        let userInfo = this.$store.state.user.userInfo;
        this.form={
          custId: userInfo.custId,
            phone: userInfo.userPhone
        };
        this.getPersonCarNumPC();
613d2a9c   Andy   add icon
238
239
240
241
      }
    }
  </script>
  
ec35bad6   Andy   add 账户设置 前端页面
242
  <style lang="scss">
ea291b39   王富生   提交登陆
243
    .search-wrap {
ec35bad6   Andy   add 账户设置 前端页面
244
245
246
      background-color: #FFF;
      padding: 15px;
    }
ea291b39   王富生   提交登陆
247
248
  
    .card-second-top {
ec35bad6   Andy   add 账户设置 前端页面
249
250
      margin-top: 15px;
    }
ea291b39   王富生   提交登陆
251
252
  
    .el-card__header {
ec35bad6   Andy   add 账户设置 前端页面
253
254
      padding: 10px 20px;
    }
ea291b39   王富生   提交登陆
255
256
  
    .el-radio {
ec35bad6   Andy   add 账户设置 前端页面
257
258
      margin-right: 80px;
    }
ea291b39   王富生   提交登陆
259
260
  
    .el-radio.is-bordered + .el-radio.is-bordered {
ec35bad6   Andy   add 账户设置 前端页面
261
262
263
264
      margin-left: 0px;
      margin-top: 15px;
    }
  </style>