Blame view

pages/addTitle/addTitle.vue 11.5 KB
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
1
  <template>
81028275   刘淇   发票
2
3
4
5
6
7
8
9
10
11
12
13
14
      <view>
          <uni-section title="抬头类型" type="line">
              <view class="uni-list">
                  <radio-group @change="radioChange">
                      <label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value">
                          <view>
                              <radio :value="item.value" :checked="index === current"/>
                          </view>
                          <view style="flex: 1;">{{item.name}}</view>
                      </label>
                  </radio-group>
              </view>
          </uni-section>
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
15
  
81028275   刘淇   发票
16
17
18
19
20
21
22
23
24
25
  
          <!--个人-->
          <uni-section title="个人发票详情" type="line" v-if="current==0">
              <view class="paddinglr30 margin-top-30">
                  <!-- 基础用法,不包含校验规则 -->
                  <uni-forms ref="baseFormPerson" :rules="rulesPerson" :modelValue="baseFormDataPerson">
                      <uni-forms-item label="发票抬头" name="invoicetitle" required>
                          <uni-easyinput v-model="baseFormDataPerson.invoicetitle" placeholder="请输入发票抬头"/>
                      </uni-forms-item>
  
2b0b0d6f   刘淇   个人发票 手机号必填
26
27
28
29
                      <uni-forms-item label="手机号" name="telphone" required>
                          <uni-easyinput v-model="baseFormDataPerson.telphone" placeholder="请输入手机号"/>
                      </uni-forms-item>
  
81028275   刘淇   发票
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
                      <uni-forms-item label="电子邮箱" name="email" required>
                          <uni-easyinput v-model="baseFormDataPerson.email" placeholder="请输入电子邮箱"/>
                      </uni-forms-item>
  
                      <uni-forms-item label="备注信息">
                          <uni-easyinput type="textarea" v-model="baseFormDataPerson.remark" placeholder="备注"/>
                      </uni-forms-item>
                  </uni-forms>
  
              </view>
          </uni-section>
  
          <!--企业-->
          <uni-section title="发票详情" type="line" v-if="current==1">
              <view class="paddinglr30 margin-top-30">
                  <!-- 基础用法,不包含校验规则 -->
                  <uni-forms ref="baseForm" :rules="rules" :modelValue="baseFormData">
                      <uni-forms-item label="发票抬头" name="invoicetitle" required>
                          <uni-easyinput v-model="baseFormData.invoicetitle" placeholder="请输入发票抬头"/>
                      </uni-forms-item>
                      <uni-forms-item label="纳税人识别号" name="userId" required>
                          <uni-easyinput v-model="baseFormData.userId" placeholder="请输入纳税人识别号"/>
                      </uni-forms-item>
                      <uni-forms-item label="注册地址">
                          <uni-easyinput v-model="baseFormData.address" placeholder="请输入注册地址"/>
                      </uni-forms-item>
2b0b0d6f   刘淇   个人发票 手机号必填
56
57
                      <uni-forms-item label="手机号" name="telphone" required>
                          <uni-easyinput v-model="baseFormData.telphone" placeholder="请输入手机号"/>
81028275   刘淇   发票
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
                      </uni-forms-item>
                      <uni-forms-item label="开户行">
                          <uni-easyinput v-model="baseFormData.bank" placeholder="请输入开户行"/>
                      </uni-forms-item>
                      <uni-forms-item label="开户账号">
                          <uni-easyinput v-model="baseFormData.bankAccount" placeholder="请输入开户账号"/>
                      </uni-forms-item>
                      <uni-forms-item label="电子邮箱" name="email" required>
                          <uni-easyinput v-model="baseFormData.email" placeholder="请输入电子邮箱"/>
                      </uni-forms-item>
                      <uni-forms-item label="备注">
                          <uni-easyinput type="textarea" v-model="baseFormData.remark" placeholder="备注"/>
                      </uni-forms-item>
                      <!--<uni-section title="纸质票邮寄方式" type="line">-->
                          <!--<uni-forms-item label="邮寄地址" name="emsAdress" required="">-->
                              <!--<uni-easyinput v-model="baseFormData.emsAdress" placeholder="请输入邮寄地址"/>-->
                          <!--</uni-forms-item>-->
                          <!--<uni-forms-item label="联系人">-->
                              <!--<uni-easyinput v-model="baseFormData.emsUsername" placeholder="请输入联系人"/>-->
                          <!--</uni-forms-item>-->
                          <!--<uni-forms-item label="联系方式">-->
                              <!--<uni-easyinput v-model="baseFormData.emsTel" placeholder="请输入联系方式"/>-->
                          <!--</uni-forms-item>-->
                      <!--</uni-section>-->
                  </uni-forms>
  
              </view>
          </uni-section>
          <view class="paddinglr30 margin-top-30 uni-common-mb">
              <button type="primary" @click="submit()">确认</button>
          </view>
      </view>
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
90
91
92
  </template>
  
  <script>
81028275   刘淇   发票
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  export default {
    data() {
      return {
        items: [{
          value: '1',
          name: '个人'
        },
          {
            value: '2',
            name: '企业'
          },
          // {
          //   value: '3',
          //   name: '非企业性单位'
          // },
        ],
        current: 0,
        baseFormDataPerson: {
          invoicetitle: '',
2b0b0d6f   刘淇   个人发票 手机号必填
112
          telphone: '',
81028275   刘淇   发票
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
          email: '',
          remark: '',
        },
        baseFormData: {
          invoicetitle: '',
          userId: '',
          address: '',
          telphone: '',
          bank: '',
          bankAccount: '',
          email: '',
          remark: '',
          // emsAdress: '',
          // emsUsername: '',
          // emsTel: '',
        },
        // 校验规则
        rulesPerson: {
          invoicetitle: {
            rules: [{
              required: true,
              errorMessage: '发票抬头不能为空'
            }]
          },
  
2b0b0d6f   刘淇   个人发票 手机号必填
138
139
140
141
142
143
          telphone: {
            rules: [{
              required: true,
              errorMessage: '手机号不能为空'
            },]
          },
81028275   刘淇   发票
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
          email: {
            rules: [{
              required: true,
              errorMessage: '电子邮箱不能为空'
            },]
          },
  
        },
        // 校验规则
        rules: {
          invoicetitle: {
            rules: [{
              required: true,
              errorMessage: '发票抬头不能为空'
            }]
          },
2b0b0d6f   刘淇   个人发票 手机号必填
160
161
162
163
164
165
          telphone: {
            rules: [{
              required: true,
              errorMessage: '手机号不能为空'
            },]
          },
81028275   刘淇   发票
166
167
168
169
          userId: {
            rules: [{
              required: true,
              errorMessage: '纳税人识别号不能为空'
81028275   刘淇   发票
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
            }]
          },
          email: {
            rules: [{
              required: true,
              errorMessage: '电子邮箱不能为空'
            },]
          },
          emsAdress: {
            rules: [{
              required: true,
              errorMessage: '邮寄地址不能为空'
            },]
          },
        },
      };
    },
    onLoad() {
    },
    onReady() {
      // 设置自定义表单校验规则,必须在节点渲染完毕后执行
      // this.$refs.baseForm.setRules(this.rules)
      // this.$refs.baseFormPerson.setRules(this.rulesPerson)
    },
    methods: {
      radioChange: function (evt) {
        for (let i = 0; i < this.items.length; i++) {
          if (this.items[i].value === evt.detail.value) {
            this.current = i;
            break;
          }
        }
        console.log(this.current)
      },
      submit() {
        console.log()
        if(this.current==0){
2b0b0d6f   刘淇   个人发票 手机号必填
207
208
209
210
211
212
213
214
215
216
217
218
  
          if (this.baseFormDataPerson.phone) {
            const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
            if (!reg.test(this.baseFormDataPerson.phone)) {
              uni.showToast({
                icon: 'none',
                title: `手机号输入不正确`
              })
              return
            }
          }
  
81028275   刘淇   发票
219
220
          this.$refs['baseFormPerson'].validate().then(res => {
            console.log('success', res);
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
221
  
81028275   刘淇   发票
222
223
224
225
226
227
228
            let insertCustInvoiceInfo = this.$common.insertCustInvoiceInfo;
            let jsondata = {
              name: this.baseFormDataPerson.invoicetitle,
              email: this.baseFormDataPerson.email,
              remark: this.baseFormDataPerson.remark,
              isDefault: '1',// 是否默认客户抬头信息,1表示是默认抬头信息,0不是默认抬头信息(默认0)
              invoiceType: '0', // 发票类型(个人、公司),0 表示个人,1表示公司
01be6617   刘淇   测试库
229
              phone: this.baseFormDataPerson.telphone,
81028275   刘淇   发票
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
            };
            uni.request({
              url: insertCustInvoiceInfo,
              data: JSON.stringify(this.$common.requestSign(jsondata)),
              dataType: "json",
              method: "POST",
              success: (res) => {
                console.log(res)
                if (res.data.code == 0) {
                  uni.showToast({
                    icon:'none',
                    title: `新增个人发票抬头成功`
                  })
                  uni.navigateBack({
                    delta:1,//返回层数,2则上上页
                  })
                }else{
                  uni.showToast({
                    icon:'none',
                    title: res.data.message
                  })
                }
                if(res.code=='1001'){
                  uni.showToast({
                    icon:'none',
                    title: res.message
                  })
                }
              }
            })
          }).catch(err => {
            console.log('err', err);
          })
        }
        if(this.current==1){
2b0b0d6f   刘淇   个人发票 手机号必填
265
266
267
268
269
270
271
272
273
274
275
276
  
          if (this.baseFormData.telphone) {
            const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
            if (!reg.test(this.baseFormData.telphone)) {
              uni.showToast({
                icon: 'none',
                title: `手机号输入不正确`
              })
              return
            }
          }
  
81028275   刘淇   发票
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
          this.$refs['baseForm'].validate().then(res => {
            console.log('success', res);
            let insertCustInvoiceInfo = this.$common.insertCustInvoiceInfo;
            let jsondata = {
              name: this.baseFormData.invoicetitle,
              email: this.baseFormData.email,
              remark: this.baseFormData.remark,
              isDefault: '1',// 是否默认客户抬头信息,1表示是默认抬头信息,0不是默认抬头信息(默认0)
              invoiceType: '1', // 发票类型(个人、公司),0 表示个人,1表示公司
              bankName: this.baseFormData.bank,
              taxid: this.baseFormData.userId,
              cardNo: this.baseFormData.bankAccount,
              address: this.baseFormData.address,
              phone: this.baseFormData.telphone,
            };
            uni.request({
              url: insertCustInvoiceInfo,
              data: JSON.stringify(this.$common.requestSign(jsondata)),
              dataType: "json",
              method: "POST",
              success: (res) => {
                console.log(res)
                if (res.data.code == 0) {
                  uni.showToast({
                    icon:'none',
                    title: `新增企业发票抬头成功`
                  })
                  uni.navigateBack({
                    delta:1,//返回层数,2则上上页
                  })
                }else{
                  uni.showToast({
                    icon:'none',
                    title: res.data.message
                  })
                }
                if(res.code=='1001'){
                  uni.showToast({
                    icon:'none',
                    title: res.message
                  })
                }
              }
            })
          }).catch(err => {
            console.log('err', err);
          })
        }
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
325
  
81028275   刘淇   发票
326
327
328
      }
    },
  }
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
329
330
331
332
333
  </script>
  
  <style lang="scss">
  
  </style>