Blame view

src/components/widgets/form/ShipmentForm.vue 3.49 KB
ade01719f   Jatinder Singh   change
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  <template>
    <v-form v-model="valid">
        <v-subheader class="pa-0 mt-3">CONTACT DETAIL</v-subheader>
        <v-text-field
          label="Full Name"
          name="fullname"
          placeholder="Michael Wang"
          v-model="formModel.name"
          v-validate="'required'"
          data-vv-name="fullname"     
          :error-messages="errors.collect('fullname')"  
          required
        ></v-text-field>    
        <v-text-field
          label="Email"
          placeholder="wangqiangshen@gmail.com"
          name="email"
          v-validate="'required|email'"
          data-vv-name="email"     
          :error-messages="errors.collect('email')"        
          v-model="formModel.email"
          required
        ></v-text-field>    
        <v-text-field
          label="Phone"
          placeholder="(###) ### - ####"
          v-validate="'required'"
          data-vv-name="phone"     
          :error-messages="errors.collect('phone')"                
          v-model="formModel.phone"
          mask="phone"
          required
        ></v-text-field>    
        <v-subheader class="pa-0 mt-3">SHIP ADDRESS</v-subheader>
        <v-select
          :items="countries"
          v-validate="'required'"
          data-vv-name="country"     
          :error-messages="errors.collect('country')"           
          v-model="formModel.country"
          label="Country"
          auto
          required
          item-text="country"
          item-value="abbr"
        ></v-select>
        <v-select
          :items="states"
          v-validate="'required'"
          data-vv-name="state"     
          :error-messages="errors.collect('state')"           
          v-model="formModel.state"
          label="State"
          auto
          required
          item-text="name"
          item-value="id"
        ></v-select>
        <v-select
          :items="cities"
          v-validate="'required'"
          data-vv-name="city"     
          :error-messages="errors.collect('city')"           
          v-model="formModel.city"
          label="City"
          required
          auto
          item-text="name"
          item-value="id"
        ></v-select>
      <v-text-field
        label="Zip Code"
        v-model="formModel.zipcode"
        required
      ></v-text-field>
      <v-text-field
        label="Address"
          v-validate="'required'"
          data-vv-name="address"     
          :error-messages="errors.collect('address')"         
        v-model="formModel.address"
        required
      ></v-text-field>
      <div class="form-btn">
        <v-btn outline @click="submit" color="primary">Submit</v-btn>
        <v-btn outline @click="clear">Clear</v-btn>
      </div>
  
    </v-form>
  </template>
  
  <script>
  import Countries from '@/api/country';
  export default {
    $_veeValidate: {
      validator: 'new'
    },    
    data: () => ({
      formModel: {
        country: null,
      },
      countries: Countries,
      states: [
        { name: 'Florida', abbr: 'FL', id: 1, country_id: 1 },
        { name: 'Georgia', abbr: 'GA', id: 2, country_id: 1 },
        { name: 'Nebraska', abbr: 'NE', id: 3, country_id: 1 },
        { name: 'California', abbr: 'CA', id: 4, country_id: 1 },
      ],    
      cities: [
        { name: 'New York', abbr: 'NY', id: 1, country_id: 1 },
        { name: 'Tample', abbr: 'TA', id: 2, country_id: 1 },
        { name: 'San Francisco', abbr: 'SF', id: 3, country_id: 1 },
      ],    
      valid: true,
  
    }),
    mounted () {
      this.$validator.localize('en', this.dictionary);
    },  
    methods: {
      submit () {
        this.$validator.validateAll();
      },
      clear () {
        this.formModel = {};
        this.$validator.reset();
      }    
    }
  };
  </script>