f067518c0e
- 批量同步后解析返回结果,按"同步失败"标识区分成功与失败条目 - 部分失败时以 warning 提示成功/失败条数及具体失败原因(停留8秒),全部成功仍提示已同步条数
522 lines
17 KiB
Vue
522 lines
17 KiB
Vue
<template>
|
||
<basic-container class="payment-page">
|
||
<section class="payment-page__search">
|
||
<el-form :model="query" label-position="right" label-width="88px">
|
||
<div class="payment-page__search-grid">
|
||
<el-form-item label="单据号"
|
||
><el-input v-model="query.paymentNo" clearable
|
||
/></el-form-item>
|
||
<el-form-item label="日期"
|
||
><el-date-picker
|
||
v-model="query.applyDateRange"
|
||
type="daterange"
|
||
value-format="YYYY-MM-DD"
|
||
range-separator="~"
|
||
start-placeholder="年/月/日"
|
||
end-placeholder="年/月/日"
|
||
/></el-form-item>
|
||
<el-form-item label="客户名称"
|
||
><el-input v-model="query.payeeName" clearable
|
||
/></el-form-item>
|
||
<el-form-item label="项目名称"
|
||
><el-input v-model="query.projectName" clearable
|
||
/></el-form-item>
|
||
<template v-if="searchExpanded">
|
||
<el-form-item label="所属组织"
|
||
><el-cascader
|
||
v-model="query.deptPath"
|
||
:options="organizationTreeOptions"
|
||
:props="organizationCascaderProps"
|
||
filterable
|
||
clearable
|
||
style="width: 100%"
|
||
placeholder="请选择 所属组织"
|
||
@change="val => { query.deptName = findOrgById(val)?.rawLabel || '' }"
|
||
/></el-form-item>
|
||
<el-form-item label="关联结算单"
|
||
><el-input v-model="query.settlementNo" clearable
|
||
/></el-form-item>
|
||
<el-form-item label="付款类型"
|
||
><el-select v-model="query.paymentType" clearable
|
||
><el-option
|
||
v-for="item in paymentTypeOptions"
|
||
:key="item.value"
|
||
v-bind="item" /></el-select
|
||
></el-form-item>
|
||
<el-form-item label="审核状态"
|
||
><el-select v-model="query.approvalStatus" clearable
|
||
><el-option
|
||
v-for="item in approvalStatusOptions"
|
||
:key="item.value"
|
||
v-bind="item" /></el-select
|
||
></el-form-item>
|
||
<el-form-item label="金蝶单据状态"
|
||
><el-select v-model="query.kingdeeStatus" clearable
|
||
><el-option
|
||
v-for="item in kingdeeStatusOptions"
|
||
:key="item.value"
|
||
v-bind="item" /></el-select
|
||
></el-form-item>
|
||
</template>
|
||
</div>
|
||
<div class="payment-page__search-actions">
|
||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||
<el-button @click="resetSearch">重置</el-button>
|
||
<el-button text @click="searchExpanded = !searchExpanded"
|
||
><el-icon><component :is="searchExpanded ? ArrowUp : ArrowDown" /></el-icon
|
||
></el-button>
|
||
</div>
|
||
</el-form>
|
||
</section>
|
||
<section class="payment-page__table-panel">
|
||
<div class="payment-page__toolbar">
|
||
<div class="payment-page__toolbar-left">
|
||
<el-button
|
||
v-if="hasPermission('payment_application_add')"
|
||
type="primary"
|
||
@click="openCreate"
|
||
>新增付款申请</el-button
|
||
>
|
||
<el-button
|
||
v-if="hasPermission('payment_application_sync')"
|
||
type="primary"
|
||
plain
|
||
@click="handleSync"
|
||
>批量同步</el-button
|
||
>
|
||
<el-button
|
||
v-if="hasPermission('payment_application_sync')"
|
||
type="primary"
|
||
plain
|
||
@click="handleSyncResult"
|
||
>同步付款结果</el-button
|
||
>
|
||
<el-button
|
||
v-if="hasPermission('payment_application_add')"
|
||
type="primary"
|
||
plain
|
||
@click="openSettlementPayment"
|
||
>申请付尾款</el-button
|
||
>
|
||
<el-button
|
||
v-if="hasPermission('payment_application_add')"
|
||
type="primary"
|
||
plain
|
||
@click="openProjectAdvance"
|
||
>预付申请</el-button
|
||
>
|
||
<el-button
|
||
v-if="hasPermission('payment_application_export')"
|
||
type="primary"
|
||
plain
|
||
@click="handleExport"
|
||
>导出</el-button
|
||
>
|
||
</div>
|
||
<el-button text :icon="Refresh" @click="loadTable" />
|
||
</div>
|
||
<el-table v-loading="loading" :data="rows" border @selection-change="selection = $event">
|
||
<el-table-column type="selection" width="52" fixed="left" align="center" />
|
||
<el-table-column type="index" label="序号" width="64" fixed="left" align="center" />
|
||
<el-table-column
|
||
v-for="column in columns"
|
||
:key="column.prop"
|
||
v-bind="column"
|
||
align="center"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<el-link v-if="column.link" type="primary" @click="openView(row)">{{
|
||
row[column.prop]
|
||
}}</el-link>
|
||
<el-tag
|
||
v-else-if="column.status"
|
||
:type="statusType(row.approvalStatus)"
|
||
class="status-text"
|
||
>{{ row[column.prop] || '-' }}</el-tag
|
||
>
|
||
<span v-else-if="column.money">{{ formatMoney(row[column.prop]) }}</span>
|
||
<span v-else>{{ displayValue(row[column.prop]) }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="320" fixed="right" align="center">
|
||
<template #default="{ row }"
|
||
><div class="payment-page__links">
|
||
<el-link
|
||
v-if="hasPermission('payment_application_view')"
|
||
type="primary"
|
||
@click="openView(row)"
|
||
>查看</el-link
|
||
>
|
||
<el-link
|
||
v-if="
|
||
hasPermission('payment_application_edit') &&
|
||
['draft', 'returned'].includes(row.approvalStatus)
|
||
"
|
||
type="primary"
|
||
@click="openEdit(row)"
|
||
>编辑</el-link
|
||
>
|
||
<el-link
|
||
v-if="hasPermission('payment_application_submit') && row.approvalStatus === 'draft'"
|
||
type="primary"
|
||
@click="handleSubmit(row)"
|
||
>提交</el-link
|
||
>
|
||
<el-link
|
||
v-if="
|
||
hasPermission('payment_application_approve') && row.approvalStatus === 'reviewing'
|
||
"
|
||
type="primary"
|
||
@click="handleApprove(row)"
|
||
>通过</el-link
|
||
>
|
||
<el-link
|
||
v-if="
|
||
hasPermission('payment_application_approve') && row.approvalStatus === 'reviewing'
|
||
"
|
||
type="danger"
|
||
@click="handleReturn(row)"
|
||
>驳回</el-link
|
||
>
|
||
<el-link
|
||
v-if="hasPermission('payment_application_view') && row.approvalStatus !== 'draft'"
|
||
type="primary"
|
||
@click="openFlow(row)"
|
||
>流程</el-link
|
||
>
|
||
<el-link
|
||
v-if="
|
||
hasPermission('payment_application_void') && row.approvalStatus === 'approved'
|
||
"
|
||
type="danger"
|
||
@click="handleVoid(row)"
|
||
>作废</el-link
|
||
>
|
||
<el-link
|
||
v-if="hasPermission('payment_application_delete') && row.approvalStatus === 'draft'"
|
||
type="danger"
|
||
@click="handleDelete(row)"
|
||
>删除</el-link
|
||
>
|
||
</div></template
|
||
>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div class="payment-page__pagination">
|
||
<el-pagination
|
||
v-model:current-page="page.current"
|
||
v-model:page-size="page.size"
|
||
:total="page.total"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
@current-change="loadTable"
|
||
@size-change="handleSizeChange"
|
||
/>
|
||
</div>
|
||
</section>
|
||
<el-dialog v-model="flowDialog.visible" title="审批流程" width="620px" append-to-body>
|
||
<el-descriptions :column="1" border>
|
||
<el-descriptions-item label="付款申请单号">
|
||
{{ flowDialog.row.paymentNo || '-' }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="审核状态">
|
||
{{ flowDialog.row.approvalStatusName || '-' }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="当前节点">
|
||
{{ flowDialog.row.currentNode || '-' }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="当前处理人">
|
||
{{ flowDialog.row.currentProcessor || '-' }}
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
</el-dialog>
|
||
</basic-container>
|
||
</template>
|
||
|
||
<script>
|
||
import { ArrowDown, ArrowUp, Refresh } from '@element-plus/icons-vue';
|
||
import { mapGetters } from 'vuex';
|
||
import * as api from '@/api/payment/paymentApplication';
|
||
import { paymentApplicationTableColumns } from '@/option/payment/paymentApplication';
|
||
import organizationSearch from '@/mixins/organization-search';
|
||
|
||
const emptyQuery = () => ({
|
||
paymentNo: '',
|
||
applyDateRange: [],
|
||
payeeName: '',
|
||
projectName: '',
|
||
deptName: '',
|
||
deptPath: [],
|
||
settlementNo: '',
|
||
paymentType: '',
|
||
approvalStatus: '',
|
||
kingdeeStatus: '',
|
||
});
|
||
export default {
|
||
name: 'PaymentApplication',
|
||
mixins: [organizationSearch],
|
||
data() {
|
||
return {
|
||
ArrowDown,
|
||
ArrowUp,
|
||
Refresh,
|
||
query: emptyQuery(),
|
||
searchExpanded: false,
|
||
paymentTypeOptions: api.paymentTypeOptions,
|
||
approvalStatusOptions: api.approvalStatusOptions,
|
||
kingdeeStatusOptions: api.kingdeeStatusOptions,
|
||
columns: paymentApplicationTableColumns,
|
||
rows: [],
|
||
selection: [],
|
||
loading: false,
|
||
page: { current: 1, size: 10, total: 0 },
|
||
flowDialog: { visible: false, row: {} },
|
||
};
|
||
},
|
||
computed: {
|
||
...mapGetters(['permission']),
|
||
visibleSearchFields() {
|
||
return this.searchExpanded ? this.columns : this.columns.slice(0, 4);
|
||
},
|
||
},
|
||
mounted() {
|
||
this.loadOrganizationOptions();
|
||
this.loadTable();
|
||
},
|
||
methods: {
|
||
hasPermission(code) {
|
||
return this.permission?.[code] !== false;
|
||
},
|
||
unwrapData(response) {
|
||
const body = response?.data || response || {};
|
||
return body?.data || body;
|
||
},
|
||
buildParams() {
|
||
const params = { ...this.query };
|
||
const range = params.applyDateRange || [];
|
||
delete params.applyDateRange;
|
||
if (range.length === 2) {
|
||
params.applyStartDate = range[0];
|
||
params.applyEndDate = range[1];
|
||
}
|
||
return params;
|
||
},
|
||
async loadTable() {
|
||
this.loading = true;
|
||
try {
|
||
const data = this.unwrapData(
|
||
await api.getList(this.page.current, this.page.size, this.buildParams())
|
||
);
|
||
this.rows = data.records || [];
|
||
this.page.total = data.total || 0;
|
||
} finally {
|
||
this.loading = false;
|
||
}
|
||
},
|
||
handleSearch() {
|
||
this.page.current = 1;
|
||
this.loadTable();
|
||
},
|
||
resetSearch() {
|
||
this.query = emptyQuery();
|
||
this.handleSearch();
|
||
},
|
||
handleSizeChange() {
|
||
this.page.current = 1;
|
||
this.loadTable();
|
||
},
|
||
openCreate() {
|
||
this.$router.push({ path: '/payment/payment-application/form', query: { mode: 'add' } });
|
||
},
|
||
openProjectAdvance() {
|
||
this.$router.push({
|
||
path: '/payment/payment-application/form',
|
||
query: { mode: 'add', paymentType: 'project_advance' },
|
||
});
|
||
},
|
||
openEdit(row) {
|
||
this.$router.push({
|
||
path: '/payment/payment-application/form',
|
||
query: { mode: 'edit', id: row.id },
|
||
});
|
||
},
|
||
openView(row) {
|
||
this.$router.push({
|
||
path: '/payment/payment-application/form',
|
||
query: { mode: 'view', id: row.id },
|
||
});
|
||
},
|
||
openSettlementPayment() {
|
||
this.$router.push({
|
||
path: '/payment/payment-application/form',
|
||
query: { mode: 'add', paymentType: 'settlement_payment' },
|
||
});
|
||
},
|
||
selectedOne(action) {
|
||
if (this.selection.length !== 1) {
|
||
this.$message.warning(`${action}需选择一条付款申请`);
|
||
return null;
|
||
}
|
||
return this.selection[0];
|
||
},
|
||
async handleDelete(row) {
|
||
await this.$confirm('确认删除该付款申请?', '提示', { type: 'warning' });
|
||
await api.remove(row.id);
|
||
this.$message.success('删除成功');
|
||
this.loadTable();
|
||
},
|
||
async handleSubmit(row) {
|
||
await api.submit({ id: row.id });
|
||
this.$message.success('提交成功');
|
||
this.loadTable();
|
||
},
|
||
async handleApprove(row) {
|
||
await api.approve({ id: row.id });
|
||
this.$message.success('审批通过');
|
||
this.loadTable();
|
||
},
|
||
async handleReturn(row) {
|
||
const { value } = await this.$prompt('请输入驳回原因', '审批驳回');
|
||
await api.returnBill({ id: row.id, reason: value });
|
||
this.$message.success('已驳回');
|
||
this.loadTable();
|
||
},
|
||
openFlow(row) {
|
||
this.flowDialog.row = row;
|
||
this.flowDialog.visible = true;
|
||
},
|
||
async handleVoid(row) {
|
||
const { value } = await this.$prompt('请输入作废原因', '作废付款申请');
|
||
await api.voidBill({ id: row.id, reason: value });
|
||
this.$message.success('作废成功');
|
||
this.loadTable();
|
||
},
|
||
async handleSyncRow(row) {
|
||
const data = this.unwrapData(await api.syncKingdee(row.id));
|
||
this.$message.success(`已生成金蝶付款单:${data}`);
|
||
this.loadTable();
|
||
},
|
||
async handleSync() {
|
||
const rows = this.selection.filter(row => row.approvalStatus === 'approved');
|
||
if (!rows.length) {
|
||
this.$message.warning('请选择至少一条审批通过的付款申请');
|
||
return;
|
||
}
|
||
const data = this.unwrapData(await api.syncKingdeeBatch(rows.map(row => row.id))) || [];
|
||
const failedList = data.filter(item => String(item).includes('同步失败'));
|
||
if (failedList.length) {
|
||
this.$message({
|
||
type: 'warning',
|
||
message: `同步完成:成功${data.length - failedList.length}条,失败${failedList.length}条。${failedList.join(';')}`,
|
||
duration: 8000,
|
||
});
|
||
} else {
|
||
this.$message.success(`已同步${data.length}条付款申请`);
|
||
}
|
||
this.loadTable();
|
||
},
|
||
async handleSyncResult() {
|
||
const data = this.unwrapData(await api.syncKingdeeResult());
|
||
this.$message.success(data || '金蝶付款结果回写完成');
|
||
this.loadTable();
|
||
},
|
||
handleExport() {
|
||
const headers = this.columns.map(item => item.label);
|
||
const rows = this.rows.map(row => this.columns.map(item => row[item.prop] || ''));
|
||
const csv = [headers, ...rows]
|
||
.map(item => item.map(value => `"${String(value).replaceAll('"', '""')}"`).join(','))
|
||
.join('\n');
|
||
const blob = new Blob([`\ufeff${csv}`], { type: 'text/csv;charset=utf-8;' });
|
||
const link = document.createElement('a');
|
||
link.href = URL.createObjectURL(blob);
|
||
link.download = `付款申请${this.$dayjs().format('YYYY-MM-DD HH-mm-ss')}.csv`;
|
||
link.click();
|
||
URL.revokeObjectURL(link.href);
|
||
},
|
||
statusType(status) {
|
||
return (
|
||
{ approved: 'success', reviewing: 'warning', returned: 'danger', voided: 'info' }[status] ||
|
||
''
|
||
);
|
||
},
|
||
displayValue(value) {
|
||
return value === null || value === undefined || value === '' ? '-' : value;
|
||
},
|
||
formatMoney(value) {
|
||
return Number(value || 0).toFixed(2);
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.payment-page__search {
|
||
padding: 12px 12px 4px;
|
||
background: #fff;
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||
}
|
||
.payment-page__search-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||
gap: 8px 24px;
|
||
}
|
||
.payment-page__search :deep(.el-form-item) {
|
||
margin-bottom: 8px;
|
||
}
|
||
.payment-page__search :deep(.el-input),
|
||
.payment-page__search :deep(.el-select),
|
||
.payment-page__search :deep(.el-date-editor) {
|
||
width: 100%;
|
||
}
|
||
.payment-page__search-actions {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
gap: 8px;
|
||
margin-bottom: 8px;
|
||
}
|
||
.payment-page__table-panel {
|
||
margin-top: 8px;
|
||
}
|
||
.payment-page__toolbar {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
padding: 12px 0;
|
||
}
|
||
.payment-page__toolbar-left {
|
||
display: flex;
|
||
gap: 8px;
|
||
}
|
||
.payment-page__links {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: center;
|
||
gap: 8px;
|
||
}
|
||
.payment-page__pagination {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
margin-top: 12px;
|
||
}
|
||
.payment-page :deep(.el-table) {
|
||
--el-table-border-color: #eff1f7;
|
||
}
|
||
.payment-page :deep(.el-table__body tr:nth-child(even) > td.el-table__cell) {
|
||
background: #fafafa;
|
||
}
|
||
:deep(.payment-page.basic-container .basic-container__card > .el-card__body) {
|
||
padding: 0;
|
||
}
|
||
@media (max-width: 1200px) {
|
||
.payment-page__search-grid {
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
}
|
||
}
|
||
@media (max-width: 760px) {
|
||
.payment-page__search-grid {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
}
|
||
</style>
|