<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>
|