Blame view

src/views/fee/ownerApplyInvoiceList.vue 10.9 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
9b01bbd3   wuxw   开发完成发票相关功能
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
    <div class="owner-apply-invoice-container">
      <el-card>
        <div slot="header" class="clearfix flex justify-between">
          <h3>{{ $t('ownerApplyInvoice.title') }}</h3>
          <div class="header-actions">
            <el-button type="primary" size="small" @click="goBack">
              {{ $t('ownerApplyInvoice.back') }}
            </el-button>
          </div>
        </div>
  
        <el-form ref="form" :model="formData" label-width="150px">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item :label="$t('ownerApplyInvoice.invoiceTitle')" required>
                <el-input v-model="formData.invoiceName" :placeholder="$t('ownerApplyInvoice.chooseInvoiceTitle')"
                  disabled />
              </el-form-item>
            </el-col>
            <el-col :span="4" class="text-left">
              <el-button type="primary" size="small" style="margin-left: 150px; margin-bottom: 20px"
                @click="openSelectOwner">
                {{ $t('ownerApplyInvoice.select') }}
              </el-button></el-col>
            <el-col :span="12">
              <el-form-item :label="$t('ownerApplyInvoice.taxpayerId')" required>
                <el-input v-model="formData.invoiceNum" :placeholder="$t('ownerApplyInvoice.chooseTaxId')" disabled />
              </el-form-item>
            </el-col>
          </el-row>
  
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item :label="$t('ownerApplyInvoice.invoiceType')" required>
                <el-select v-model="formData.invoiceType" :placeholder="$t('ownerApplyInvoice.chooseInvoiceType')"
                  style="width:100%">
                  <el-option :label="$t('ownerApplyInvoice.personal')" value="1001" />
                  <el-option :label="$t('ownerApplyInvoice.enterprise')" value="2002" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('ownerApplyInvoice.addressPhone')" required>
                <el-input v-model="formData.invoiceAddress" :placeholder="$t('ownerApplyInvoice.chooseAddressPhone')" />
              </el-form-item>
            </el-col>
          </el-row>
  
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item :label="$t('ownerApplyInvoice.owner')" required>
                <el-input v-model="formData.ownerName" :placeholder="$t('ownerApplyInvoice.chooseContent')" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('ownerApplyInvoice.content')" required>
                <el-select v-model="formData.invoiceFlag" :placeholder="$t('ownerApplyInvoice.chooseContent')"
                  style="width:100%" @change="handleContentChange">
                  <el-option :label="$t('ownerApplyInvoice.paidFees')" value="FEE" />
                  <el-option :label="$t('ownerApplyInvoice.accountDeposit')" value="ACCT" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
  
  
      </el-card>
  
      <!-- 已缴费费用 -->
      <el-card v-if="formData.invoiceFlag === 'FEE'" class="mt-20">
        <div slot="header" class="flex justify-between">
          <h3>{{ $t('ownerApplyInvoice.paidFees') }}</h3>
        </div>
  
        <el-table :data="feeDetails" border style="width: 100%">
b3f585ad   wuxw   v1.9 优化申请开票选择明细 b...
78
79
80
81
82
83
84
85
          <el-table-column width="55" align="center">
            <template slot-scope="scope">
              <el-checkbox 
                :checked="formData.detailIds.includes(scope.row.detailId)"
                @change="handleFeeCheckboxChange(scope.row.detailId, $event)">
              </el-checkbox>
            </template>
          </el-table-column>
9b01bbd3   wuxw   开发完成发票相关功能
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
          <el-table-column prop="feeName" :label="$t('ownerApplyInvoice.feeName')" align="center" />
          <el-table-column prop="payerObjName" :label="$t('ownerApplyInvoice.payer')" align="center" />
          <el-table-column :label="$t('ownerApplyInvoice.receivablePaid')" align="center">
            <template slot-scope="scope">
              {{ scope.row.receivableAmount }}/{{ scope.row.receivedAmount }}
            </template>
          </el-table-column>
          <el-table-column prop="primeRateName" :label="$t('ownerApplyInvoice.paymentMethod')" align="center" />
          <el-table-column :label="$t('ownerApplyInvoice.paymentPeriod')" align="center">
            <template slot-scope="scope">
              {{ formatDate(scope.row.startTime) }}~<br>
              {{ formatDate(scope.row.endTime) }}
            </template>
          </el-table-column>
          <el-table-column prop="createTime" :label="$t('ownerApplyInvoice.paymentTime')" align="center" />
          <el-table-column prop="cashierName" :label="$t('ownerApplyInvoice.cashier')" align="center">
            <template slot-scope="scope">
              {{ scope.row.cashierName || '-' }}
            </template>
          </el-table-column>
          <el-table-column prop="stateName" :label="$t('ownerApplyInvoice.status')" align="center" />
          <el-table-column prop="remark" :label="$t('ownerApplyInvoice.remark')" align="center" />
        </el-table>
      </el-card>
  
      <!-- 账户预存 -->
      <el-card v-if="formData.invoiceFlag === 'ACCT'" class="mt-20">
        <div slot="" class="flex justify-between">
          <h3>{{ $t('ownerApplyInvoice.accountDeposit') }}</h3>
        </div>
  
        <el-table :data="acctDetails" border style="width: 100%">
b3f585ad   wuxw   v1.9 优化申请开票选择明细 b...
118
119
120
121
122
123
124
125
          <el-table-column width="55" align="center">
            <template slot-scope="scope">
              <el-checkbox 
                :checked="formData.arIds.includes(scope.row.arId)"
                @change="handleAcctCheckboxChange(scope.row.arId, $event)">
              </el-checkbox>
            </template>
          </el-table-column>
9b01bbd3   wuxw   开发完成发票相关功能
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
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
243
244
245
246
247
          <el-table-column prop="acctName" :label="$t('ownerApplyInvoice.accountName')" align="center" />
          <el-table-column prop="acctTypeName" :label="$t('ownerApplyInvoice.accountType')" align="center" />
          <el-table-column prop="ownerName" :label="$t('ownerApplyInvoice.owner')" align="center" />
          <el-table-column prop="receivedAmount" :label="$t('ownerApplyInvoice.depositAmount')" align="center" />
          <el-table-column prop="primeRateName" :label="$t('ownerApplyInvoice.depositMethod')" align="center" />
          <el-table-column prop="amount" :label="$t('ownerApplyInvoice.totalAmount')" align="center" />
          <el-table-column prop="createTime" :label="$t('ownerApplyInvoice.depositTime')" align="center" />
        </el-table>
      </el-card>
  
      <div class="mt-20 text-right">
        <el-button type="primary" @click="handleSubmit">
          {{ $t('ownerApplyInvoice.submit') }}
        </el-button>
      </div>
  
      <search-owner-invoice ref="searchOwnerInvoice" :visible.sync="showSearchDialog" @select="handleOwnerSelect" />
    </div>
  </template>
  
  <script>
  import { queryFeeDetail, listAccountReceipt, saveInvoiceApply } from '@/api/fee/ownerApplyInvoiceApi'
  import SearchOwnerInvoice from '@/components/fee/searchOwnerInvoice'
  import { formatDate } from '@/utils/dateUtil'
  
  export default {
    name: 'OwnerApplyInvoiceList',
    components: {
      SearchOwnerInvoice
    },
    data() {
      return {
        showSearchDialog: false,
        formData: {
          oiId: '',
          ownerId: '',
          ownerName: '',
          invoiceType: '',
          invoiceName: '',
          invoiceAddress: '',
          invoiceNum: '',
          detailIds: [],
          feeDetails: [],
          invoiceFlag: 'FEE',
          arIds: [],
          acctDetails: []
        },
        feeDetails: [],
        acctDetails: []
      }
    },
    methods: {
      formatDate,
      goBack() {
        this.$router.go(-1)
      },
      openSelectOwner() {
        this.showSearchDialog = true
        this.$nextTick(() => {
          this.$refs.searchOwnerInvoice.open()
        })
      },
      handleOwnerSelect(owner) {
        Object.assign(this.formData, owner)
        this.formData.detailIds = []
        this.formData.arIds = []
  
        if (this.formData.invoiceFlag === 'FEE') {
          this.loadFeeDetails()
        } else {
          this.loadAcctDetails()
        }
      },
      async loadFeeDetails() {
        try {
          const params = {
            page: 1,
            row: 50,
            ownerId: this.formData.ownerId,
            openInvoice: 'N'
          }
  
          const res = await queryFeeDetail(params)
          this.feeDetails = res.feeDetails || []
  
          // 默认全选
          this.formData.detailIds = this.feeDetails.map(item => item.detailId)
        } catch (error) {
          console.error('Failed to load fee details:', error)
          this.$message.error(this.$t('common.loadFailed'))
        }
      },
      async loadAcctDetails() {
        try {
          const params = {
            page: 1,
            row: 50,
            ownerId: this.formData.ownerId
          }
  
          const res = await listAccountReceipt(params)
          this.acctDetails = res.data || []
  
          // 默认全选
          this.formData.arIds = this.acctDetails.map(item => item.arId)
        } catch (error) {
          console.error('Failed to load account details:', error)
          this.$message.error(this.$t('common.loadFailed'))
        }
      },
      handleContentChange() {
        if (!this.formData.ownerId) return
  
        this.formData.detailIds = []
        this.formData.arIds = []
  
        if (this.formData.invoiceFlag === 'FEE') {
          this.loadFeeDetails()
        } else {
          this.loadAcctDetails()
        }
      },
b3f585ad   wuxw   v1.9 优化申请开票选择明细 b...
248
249
250
251
252
253
      handleFeeCheckboxChange(detailId, checked) {
        if (checked) {
          this.formData.detailIds.push(detailId)
        } else {
          this.formData.detailIds = this.formData.detailIds.filter(id => id !== detailId)
        }
9b01bbd3   wuxw   开发完成发票相关功能
254
      },
b3f585ad   wuxw   v1.9 优化申请开票选择明细 b...
255
256
257
258
259
260
      handleAcctCheckboxChange(arId, checked) {
        if (checked) {
          this.formData.arIds.push(arId)
        } else {
          this.formData.arIds = this.formData.arIds.filter(id => id !== arId)
        }
9b01bbd3   wuxw   开发完成发票相关功能
261
262
263
264
265
      },
      async handleSubmit() {
        try {
          // 验证表单
          if (!this.formData.ownerId) {
b3f585ad   wuxw   v1.9 优化申请开票选择明细 b...
266
            this.$message.warning(this.$t('ownerApplyInvoice.chooseOwner'))
9b01bbd3   wuxw   开发完成发票相关功能
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
            return
          }
  
          if (this.formData.invoiceFlag === 'FEE' && !this.formData.detailIds.length) {
            this.$message.warning(this.$t('ownerApplyInvoice.noFeeSelected'))
            return
          }
  
          if (this.formData.invoiceFlag === 'ACCT' && !this.formData.arIds.length) {
            this.$message.warning(this.$t('ownerApplyInvoice.noDepositSelected'))
            return
          }
  
          // 准备提交数据
          const submitData = {
            ...this.formData,
            detailIds: this.formData.invoiceFlag === 'FEE' ? this.formData.detailIds : [],
            arIds: this.formData.invoiceFlag === 'ACCT' ? this.formData.arIds : []
          }
  
          // 调用API
          await saveInvoiceApply(submitData)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
289
          this.$message.success(this.$t('common.operationSuccess'))
9b01bbd3   wuxw   开发完成发票相关功能
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
          this.goBack()
        } catch (error) {
          console.error('Failed to submit invoice application:', error)
          this.$message.error(error.message || this.$t('common.submitFailed'))
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .owner-apply-invoice-container {
    padding: 20px;
  }
  
  .mt-20 {
    margin-top: 20px;
  }
  
  .text-right {
    text-align: right;
  }
  
  .header-actions {}
  </style>