Blame view

pages/editTitle/editTitle.vue 10.8 KB
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
1
  <template>
81028275   刘淇   发票
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
      <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>
  
          <!--个人-->
          <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   刘淇   个人发票 手机号必填
25
26
27
28
                      <uni-forms-item label="手机号" name="phone" required>
                          <uni-easyinput v-model="baseFormDataPerson.phone" placeholder="请输入手机号"/>
                      </uni-forms-item>
  
81028275   刘淇   发票
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
                      <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   刘淇   个人发票 手机号必填
55
                      <uni-forms-item label="注册电话" name="phone" required>
81028275   刘淇   发票
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
                          <uni-easyinput v-model="baseFormData.phone" placeholder="请输入注册电话"/>
                      </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
112
113
114
  export default {
    data() {
      return {
        titleIfo:'',
        items: [{
          value: '1',
          name: '个人'
        },
          {
            value: '2',
            name: '企业'
          },
          // {
          //   value: '3',
          //   name: '非企业性单位'
          // },
        ],
        current: 0,
        baseFormDataPerson: {
          invoicetitle: '',
          email: '',
          remark: '',
2b0b0d6f   刘淇   个人发票 手机号必填
115
          phone:''
81028275   刘淇   发票
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
        },
        baseFormData: {
          invoicetitle: '',
          userId: '',
          address: '',
          phone: '',
          bank: '',
          bankAccount: '',
          email: '',
          remark: '',
          // emsAdress: '',
          // emsUsername: '',
          // emsTel: '',
        },
        // 校验规则
        rulesPerson: {
          invoicetitle: {
            rules: [{
              required: true,
              errorMessage: '发票抬头不能为空'
            }]
          },
  
          email: {
            rules: [{
              required: true,
              errorMessage: '电子邮箱不能为空'
            },]
          },
  
2b0b0d6f   刘淇   个人发票 手机号必填
146
147
148
149
150
151
152
153
154
          phone: {
            rules: [{
              required: true,
              errorMessage: '手机号不能为空'
            },]
          },
  
  
  
81028275   刘淇   发票
155
156
157
158
159
160
161
162
163
164
165
166
167
        },
        // 校验规则
        rules: {
          invoicetitle: {
            rules: [{
              required: true,
              errorMessage: '发票抬头不能为空'
            }]
          },
          userId: {
            rules: [{
              required: true,
              errorMessage: '纳税人识别号不能为空'
81028275   刘淇   发票
168
169
170
171
172
173
174
175
176
177
178
179
180
181
            }]
          },
          email: {
            rules: [{
              required: true,
              errorMessage: '电子邮箱不能为空'
            },]
          },
          emsAdress: {
            rules: [{
              required: true,
              errorMessage: '邮寄地址不能为空'
            },]
          },
2b0b0d6f   刘淇   个人发票 手机号必填
182
183
184
185
186
187
          phone: {
            rules: [{
              required: true,
              errorMessage: '手机号不能为空'
            },]
          },
81028275   刘淇   发票
188
189
190
191
192
193
194
195
196
197
198
199
        },
      };
    },
    onLoad() {
      this.titleIfo = JSON.parse(uni.getStorageSync('titleIfo'))
      console.log(this.titleIfo)
      if(this.titleIfo.invoiceType == '0'){
        this.current = 0
  
        this.baseFormDataPerson.invoicetitle = this.titleIfo.name
        this.baseFormDataPerson.email = this.titleIfo.email
        this.baseFormDataPerson.remark = this.titleIfo.remark
2b0b0d6f   刘淇   个人发票 手机号必填
200
        this.baseFormDataPerson.phone = this.titleIfo.phone
81028275   刘淇   发票
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
  
      }else{
        this.current = 1
  
        this.baseFormData.invoicetitle = this.titleIfo.name
        this.baseFormData.email = this.titleIfo.email
        this.baseFormData.remark = this.titleIfo.remark
        this.baseFormData.bank = this.titleIfo.bankName
        this.baseFormData.bankAccount = this.titleIfo.cardNo
        this.baseFormData.address = this.titleIfo.address
        this.baseFormData.userId  = this.titleIfo.taxid
        this.baseFormData.phone  = this.titleIfo.phone
  
      }
    },
    onReady() {
      // 设置自定义表单校验规则,必须在节点渲染完毕后执行
      // this.$refs.baseForm.setRules(this.rules)
    },
    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;
          }
        }
      },
      submit(ref) {
        console.log()
        if(this.current==0){
          this.$refs['baseFormPerson'].validate().then(res => {
            console.log('success', res);
  
  
            let updateCustInvoiceInfo = this.$common.updateCustInvoiceInfo;
            let jsondata = {
              id: this.titleIfo.id,
              name: this.baseFormDataPerson.invoicetitle,
              email: this.baseFormDataPerson.email,
              remark: this.baseFormDataPerson.remark,
              invoiceType:'0',
2b0b0d6f   刘淇   个人发票 手机号必填
243
244
              isDefault:this.titleIfo.isDefault,
              phone:this.baseFormDataPerson.phone
81028275   刘淇   发票
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
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
            };
            uni.request({
              url: updateCustInvoiceInfo,
              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
                  })
                }else{
                  uni.showToast({
                    icon:'none',
                    title: res.data.message
                  })
  
                }
              }
            })
  
          }).catch(err => {
            console.log('err', err);
          })
        }
        if(this.current==1){
          this.$refs['baseForm'].validate().then(res => {
  
            let updateCustInvoiceInfo = this.$common.updateCustInvoiceInfo;
            let jsondata = {
  
              id: this.titleIfo.id,
              name: this.baseFormData.invoicetitle,
              email: this.baseFormData.email,
              remark: this.baseFormData.remark,
              invoiceType:'1',
              isDefault:this.titleIfo.isDefault,
              taxid:this.baseFormData.userId,
              bankName:this.baseFormData.bank,
              cardNo:this.baseFormData.bankAccount,
              address:this.baseFormData.address,
              phone:this.baseFormData.phone,
            };
            uni.request({
              url: updateCustInvoiceInfo,
              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
                  })
                }else{
                  uni.showToast({
                    icon:'none',
                    title: res.data.message
                  })
  
                }
              }
            })
  
          }).catch(err => {
            console.log('err', err);
          })
        }
      }
    },
  }
7f3bad7f   chenbiao   add 发票抬头:查看 编辑 新增...
325
326
327
328
329
  </script>
  
  <style lang="scss">
  
  </style>