wlzboy
3 天以前 40a8157440e3b906da8f52e07d939d78c3f4c313
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
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="服务单号" prop="serviceCode">
        <el-input
          v-model="queryParams.serviceCode"
          placeholder="请输入服务单号(如GZ202602)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分公司" prop="serviceOrdClass">
        <el-select v-model="queryParams.serviceOrdClass" placeholder="请选择分公司" clearable>
          <el-option
            v-for="dept in branchOptions"
            :key="dept.serviceOrderClass"
            :label="dept.deptName"
            :value="dept.serviceOrderClass"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="开票抬头" prop="invoiceName">
        <el-input
          v-model="queryParams.invoiceName"
          placeholder="请输入发票抬头"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
          <el-option label="待审核" :value="0" />
          <el-option label="已通过" :value="1" />
          <el-option label="已驳回" :value="2" />
        </el-select>
      </el-form-item>
      <el-form-item label="申请时间">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
 
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:invoice:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-refresh"
          size="mini"
          @click="handleSync"
          v-hasRole="['admin']"
        >同步旧系统状态</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
 
    <el-table v-loading="loading" :data="invoiceList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="invoiceId" width="80" />
      <el-table-column label="服务单号" align="center" prop="serviceCode" width="150" />
      <el-table-column label="开票抬头" align="center" prop="invoiceName" width="150" />
      <el-table-column label="金额" align="center" prop="invoiceMoney" width="100" />
      <el-table-column label="类型" align="center" prop="invoiceType">
        <template slot-scope="scope">
          <el-tag :type="scope.row.invoiceType === 2 ? 'success' : 'info'">
            {{ scope.row.invoiceType === 2 ? '企业' : '个人' }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status === 1 ? 'success' : (scope.row.status === 2 ? 'danger' : 'warning')">
            {{ statusFormat(scope.row.status) }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="发票编号" align="center" prop="invoiceNo" />
      <el-table-column label="申请时间" align="center" prop="applyTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:invoice:edit']"
            v-if="scope.row.status === 0"
          >审核</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            v-if="scope.row.invoiceUrl"
            @click="handleDownload(scope.row)"
          >下载发票</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
 
<script>
import { listInvoice, syncInvoiceStatus } from "@/api/system/invoice";
import { listBranchByOaOrderClass } from "@/api/system/dept";
 
export default {
  name: "Invoice",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 发票申请表格数据
      invoiceList: [],
      // 分公司选项
      branchOptions: [],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        serviceCode: null,
        invoiceName: null,
        status: null,
        serviceOrdClass: null
      }
    };
  },
  created() {
    this.getList();
    this.getBranchList();
  },
  methods: {
    /** 查询分公司列表 */
    getBranchList() {
      listBranchByOaOrderClass().then(response => {
        this.branchOptions = response.data;
      });
    },
    /** 查询发票申请列表 */
    getList() {
      this.loading = true;
      const params = this.addDateRange(this.queryParams, this.dateRange);
      // 将 serviceOrdClass 放入 params 字段中,对应后台 XML 中的 params.serviceOrdClass
      if (this.queryParams.serviceOrdClass) {
        params['params[serviceOrdClass]'] = this.queryParams.serviceOrdClass;
      }
      // serviceCode 查询
      if (this.queryParams.serviceCode) {
        params['params[serviceCode]'] = this.queryParams.serviceCode;
      }
      listInvoice(params).then(response => {
        this.invoiceList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.invoiceId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    // 状态字典转义
    statusFormat(status) {
      const map = { 0: "待审核", 1: "已通过", 2: "已驳回" };
      return map[status] || "未知";
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 详情按钮操作 */
    handleView(row) {
      this.$router.push({
        path: '/system/invoice/detail',
        query: { invoiceId: row.invoiceId }
      });
    },
    /** 审核按钮操作 */
    handleUpdate(row) {
      this.$router.push({
        path: '/system/invoice/audit',
        query: { invoiceId: row.invoiceId }
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/invoice/export', {
        ...this.queryParams
      }, `invoice_${new Date().getTime()}.xlsx`)
    },
    /** 同步按钮操作 */
    handleSync() {
      this.loading = true;
      syncInvoiceStatus().then(() => {
        this.$modal.msgSuccess("同步成功");
        this.getList();
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 下载发票操作 */
    handleDownload(row) {
      window.open(row.invoiceUrl);
    }
  }
};
</script>