All checks were successful
Build and Deploy Front / deploy (push) Successful in 6m37s
将站点/API 默认值收敛到配置,避免再次全局改域名;同步 H5/PC 支付充值与助手浮层交互调整。 Co-authored-by: Cursor <cursoragent@cursor.com>
893 lines
29 KiB
Vue
893 lines
29 KiB
Vue
<template>
|
|
<div class="finance-contract-container">
|
|
<div class="finance-contract-page-card">
|
|
<div class="status-tabs">
|
|
<SlidingTabs
|
|
v-model="tabFilter"
|
|
:items="tabItems"
|
|
@change="handleTabChange"
|
|
/>
|
|
<a-space wrap :size="8" class="status-tabs-filter">
|
|
<a-input
|
|
v-model="keyword"
|
|
allow-clear
|
|
:placeholder="t('finance.contract.search.keyword')"
|
|
class="filter-keyword"
|
|
@press-enter="handleSearch"
|
|
/>
|
|
<a-button class="app-btn-search" @click="handleSearch">
|
|
{{ t('finance.contract.search.actions.search') }}
|
|
</a-button>
|
|
<a-button @click="handleReset">
|
|
{{ t('finance.contract.search.actions.reset') }}
|
|
</a-button>
|
|
</a-space>
|
|
</div>
|
|
|
|
<div class="table-toolbar">
|
|
<div class="toolbar-left">
|
|
<a-space :size="8">
|
|
<a-button
|
|
v-if="hasPermission('Finance.Contract.Create')"
|
|
class="app-btn-primary-soft"
|
|
@click="openCreate"
|
|
>
|
|
{{ t('finance.contract.search.actions.create') }}
|
|
</a-button>
|
|
<a-button
|
|
v-if="hasPermission('Finance.Contract.SupplierManage')"
|
|
@click="supplierVisible = true"
|
|
>
|
|
{{ t('finance.contract.search.actions.supplier') }}
|
|
</a-button>
|
|
</a-space>
|
|
</div>
|
|
<div class="toolbar-right">
|
|
<PaginationPro
|
|
:total-count="totalCount"
|
|
v-model:current-page="currentPage"
|
|
v-model:page-size="pageSize"
|
|
@page-change="loadList"
|
|
@page-size-change="loadList"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<a-spin class="list-spin" :loading="listLoading">
|
|
<div ref="tableContainerRef" class="list-wrap">
|
|
<HandsontablePro
|
|
:columns="hotColumns"
|
|
:data="tableRows"
|
|
:total="totalCount"
|
|
:current-page="currentPage"
|
|
:page-size="pageSize"
|
|
:show-action-column="true"
|
|
:action-renderer="actionRenderer"
|
|
:custom-cell-renderer="customCellRenderer"
|
|
:stretch-columns="true"
|
|
:height="handsontableHeight"
|
|
@action-click="handleActionClick"
|
|
/>
|
|
</div>
|
|
</a-spin>
|
|
</div>
|
|
|
|
<a-drawer
|
|
:visible="drawerVisible"
|
|
:title="drawerTitle"
|
|
:width="640"
|
|
unmount-on-close
|
|
@cancel="drawerVisible = false"
|
|
>
|
|
<a-form :model="form" layout="vertical" :disabled="drawerReadonly">
|
|
<a-row :gutter="16">
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.contractName')" required>
|
|
<a-input v-model="form.contractName" allow-clear />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.partyType')" required>
|
|
<a-select
|
|
v-model="form.partyType"
|
|
:disabled="drawerReadonly || !!form.id"
|
|
@change="handlePartyTypeChange"
|
|
>
|
|
<a-option :value="CONTRACT_PARTY_TYPE.Customer">
|
|
{{ t('finance.contract.party.customer') }}
|
|
</a-option>
|
|
<a-option :value="CONTRACT_PARTY_TYPE.Supplier">
|
|
{{ t('finance.contract.party.supplier') }}
|
|
</a-option>
|
|
<a-option :value="CONTRACT_PARTY_TYPE.Agent">
|
|
{{ t('finance.contract.party.agent') }}
|
|
</a-option>
|
|
</a-select>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.party')" required>
|
|
<a-select
|
|
v-model="form.partyId"
|
|
allow-search
|
|
:options="partyOptions"
|
|
:loading="partyLoading"
|
|
:disabled="drawerReadonly || !!form.id"
|
|
:placeholder="t('finance.contract.form.party')"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.ourEntityName')">
|
|
<a-input v-model="form.ourEntityName" allow-clear />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.signDate')">
|
|
<a-date-picker v-model="form.signDate" style="width: 100%" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.effectiveDate')" required>
|
|
<a-date-picker v-model="form.effectiveDate" style="width: 100%" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.expireDate')">
|
|
<a-date-picker v-model="form.expireDate" style="width: 100%" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.autoRenew')">
|
|
<a-switch v-model="form.autoRenew" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.settlementMethod')" required>
|
|
<a-select v-model="form.settlementMethod">
|
|
<a-option :value="SETTLEMENT_METHOD.Prepaid">
|
|
{{ t('finance.contract.settlement.prepaid') }}
|
|
</a-option>
|
|
<a-option :value="SETTLEMENT_METHOD.Ticket">
|
|
{{ t('finance.contract.settlement.ticket') }}
|
|
</a-option>
|
|
<a-option :value="SETTLEMENT_METHOD.Monthly">
|
|
{{ t('finance.contract.settlement.monthly') }}
|
|
</a-option>
|
|
<a-option :value="SETTLEMENT_METHOD.Biweekly">
|
|
{{ t('finance.contract.settlement.biweekly') }}
|
|
</a-option>
|
|
</a-select>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.paymentTermDays')">
|
|
<a-input-number v-model="form.paymentTermDays" :min="0" style="width: 100%" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.billingDay')">
|
|
<a-input-number v-model="form.billingDay" :min="1" :max="28" style="width: 100%" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.paymentDay')">
|
|
<a-input-number v-model="form.paymentDay" :min="1" :max="28" style="width: 100%" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.currency')">
|
|
<a-input v-model="form.currency" allow-clear />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col v-if="form.partyType === CONTRACT_PARTY_TYPE.Customer" :span="12">
|
|
<a-form-item :label="t('finance.contract.form.creditLimit')">
|
|
<a-input-number v-model="form.creditLimit" :min="0" :precision="2" style="width: 100%" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col v-if="form.partyType === CONTRACT_PARTY_TYPE.Agent" :span="12">
|
|
<a-form-item :label="t('finance.contract.form.commissionBaseType')">
|
|
<a-select v-model="form.commissionBaseType" allow-clear>
|
|
<a-option value="freight">freight</a-option>
|
|
<a-option value="receivable">receivable</a-option>
|
|
</a-select>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col v-if="form.partyType === CONTRACT_PARTY_TYPE.Agent" :span="12">
|
|
<a-form-item :label="t('finance.contract.form.commissionRate')">
|
|
<a-input-number
|
|
v-model="form.commissionRate"
|
|
:min="0"
|
|
:max="1"
|
|
:step="0.01"
|
|
:precision="4"
|
|
style="width: 100%"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col v-if="form.partyType === CONTRACT_PARTY_TYPE.Supplier" :span="12">
|
|
<a-form-item :label="t('finance.contract.form.requireVendorInvoice')">
|
|
<a-switch v-model="form.requireVendorInvoice" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('finance.contract.form.ownerName')">
|
|
<a-input v-model="form.ownerName" allow-clear />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-item :label="t('finance.contract.form.attachmentUrls')">
|
|
<a-textarea v-model="form.attachmentUrls" :auto-size="{ minRows: 2, maxRows: 4 }" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-item :label="t('finance.contract.form.remark')">
|
|
<a-textarea v-model="form.remark" :auto-size="{ minRows: 2, maxRows: 4 }" />
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
</a-form>
|
|
<template v-if="!drawerReadonly" #footer>
|
|
<a-space>
|
|
<a-button @click="drawerVisible = false">{{ t('common.cancel') }}</a-button>
|
|
<a-button :loading="saving" @click="handleSave(false)">
|
|
{{ t('finance.contract.form.save') }}
|
|
</a-button>
|
|
<a-button
|
|
v-if="hasPermission('Finance.Contract.Activate')"
|
|
class="app-btn-primary-soft"
|
|
:loading="saving"
|
|
@click="handleSave(true)"
|
|
>
|
|
{{ t('finance.contract.form.activateNow') }}
|
|
</a-button>
|
|
</a-space>
|
|
</template>
|
|
</a-drawer>
|
|
|
|
<a-modal
|
|
v-model:visible="terminateVisible"
|
|
:title="t('finance.contract.terminate.title')"
|
|
:ok-loading="terminating"
|
|
unmount-on-close
|
|
@ok="handleTerminateOk"
|
|
>
|
|
<a-textarea
|
|
v-model="terminateReason"
|
|
:placeholder="t('finance.contract.terminate.reason')"
|
|
:auto-size="{ minRows: 3, maxRows: 5 }"
|
|
/>
|
|
</a-modal>
|
|
|
|
<a-drawer
|
|
:visible="supplierVisible"
|
|
:title="t('finance.contract.supplier.title')"
|
|
:width="720"
|
|
:footer="false"
|
|
unmount-on-close
|
|
@cancel="supplierVisible = false"
|
|
>
|
|
<div class="supplier-toolbar">
|
|
<a-button class="app-btn-primary-soft" @click="openSupplierForm()">
|
|
{{ t('finance.contract.supplier.add') }}
|
|
</a-button>
|
|
</div>
|
|
<a-table
|
|
:data="supplierRows"
|
|
:columns="supplierColumns"
|
|
:loading="supplierLoading"
|
|
:pagination="false"
|
|
row-key="id"
|
|
size="small"
|
|
>
|
|
<template #bank="{ record }">
|
|
{{ [record.bankAccountName, record.bankName, record.bankAccountNo].filter(Boolean).join(' / ') }}
|
|
</template>
|
|
<template #action="{ record }">
|
|
<a-link @click="openSupplierForm(record)">编辑</a-link>
|
|
</template>
|
|
</a-table>
|
|
<a-modal
|
|
v-model:visible="supplierFormVisible"
|
|
:title="t('finance.contract.supplier.add')"
|
|
:ok-loading="supplierSaving"
|
|
unmount-on-close
|
|
@before-ok="handleSupplierSave"
|
|
>
|
|
<a-form :model="supplierForm" layout="vertical">
|
|
<a-form-item :label="t('finance.contract.supplier.code')" required>
|
|
<a-input v-model="supplierForm.supplierCode" :disabled="!!supplierForm.id" />
|
|
</a-form-item>
|
|
<a-form-item :label="t('finance.contract.supplier.name')" required>
|
|
<a-input v-model="supplierForm.supplierName" />
|
|
</a-form-item>
|
|
<a-form-item label="户名">
|
|
<a-input v-model="supplierForm.bankAccountName" />
|
|
</a-form-item>
|
|
<a-form-item label="开户行">
|
|
<a-input v-model="supplierForm.bankName" />
|
|
</a-form-item>
|
|
<a-form-item label="账号">
|
|
<a-input v-model="supplierForm.bankAccountNo" />
|
|
</a-form-item>
|
|
<a-form-item label="币种">
|
|
<a-input v-model="supplierForm.currency" />
|
|
</a-form-item>
|
|
</a-form>
|
|
</a-modal>
|
|
</a-drawer>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { Message, Modal } from '@arco-design/web-vue'
|
|
import dayjs from 'dayjs'
|
|
import HandsontablePro from '@/components/HandsontablePro/index.vue'
|
|
import PaginationPro from '@/components/PaginationPro/index.vue'
|
|
import SlidingTabs from '@/components/SlidingTabs/index.vue'
|
|
import { useTableContainerHeight } from '@/composables/useTableContainerHeight'
|
|
import { useWarehouseAdminCustomer } from '@/composables/useWarehouseAdminCustomer'
|
|
import { hasPermission } from '@/utils/rbac-permission'
|
|
import { renderWarehouseActionBtn, wrapWarehouseActions } from '@/utils/warehouseActionRenderer'
|
|
import { buildStatusTagHtml } from '@/utils/statusTag'
|
|
import { extractOmsRequestError } from '@/api/oms/common'
|
|
import { AgentAdminApi } from '@/api/agent'
|
|
import {
|
|
CONTRACT_PARTY_TYPE,
|
|
CONTRACT_STATUS,
|
|
SETTLEMENT_METHOD,
|
|
activateFinanceContract,
|
|
getFinanceContractList,
|
|
renewFinanceContract,
|
|
saveFinanceContract,
|
|
terminateFinanceContract,
|
|
type FinanceContract,
|
|
} from '@/api/finance/contract'
|
|
import {
|
|
getFinanceSupplierList,
|
|
getFinanceSupplierOptions,
|
|
saveFinanceSupplier,
|
|
type FinanceSupplier,
|
|
} from '@/api/finance/master'
|
|
|
|
defineOptions({ name: 'FinanceContract' })
|
|
|
|
const { t } = useI18n()
|
|
const { tableContainerRef, tableHeight } = useTableContainerHeight()
|
|
const handsontableHeight = computed(() => Math.max(tableHeight.value || 0, 400))
|
|
const { customerOptions } = useWarehouseAdminCustomer()
|
|
|
|
const tabFilter = ref('all')
|
|
const keyword = ref('')
|
|
const currentPage = ref(1)
|
|
const pageSize = ref(50)
|
|
const totalCount = ref(0)
|
|
const listLoading = ref(false)
|
|
const tableRows = ref<FinanceContract[]>([])
|
|
const saving = ref(false)
|
|
const drawerVisible = ref(false)
|
|
const drawerReadonly = ref(false)
|
|
const terminateVisible = ref(false)
|
|
const terminateReason = ref('')
|
|
const terminating = ref(false)
|
|
const terminateId = ref(0)
|
|
|
|
const supplierVisible = ref(false)
|
|
const supplierLoading = ref(false)
|
|
const supplierRows = ref<FinanceSupplier[]>([])
|
|
const supplierFormVisible = ref(false)
|
|
const supplierSaving = ref(false)
|
|
const supplierForm = reactive({
|
|
id: undefined as number | undefined,
|
|
supplierCode: '',
|
|
supplierName: '',
|
|
bankAccountName: '',
|
|
bankName: '',
|
|
bankAccountNo: '',
|
|
currency: 'CNY',
|
|
})
|
|
const supplierColumns = computed(() => [
|
|
{
|
|
title: t('finance.contract.supplier.code'),
|
|
dataIndex: 'supplierCode',
|
|
},
|
|
{
|
|
title: t('finance.contract.supplier.name'),
|
|
dataIndex: 'supplierName',
|
|
},
|
|
{
|
|
title: t('finance.contract.supplier.bank'),
|
|
slotName: 'bank',
|
|
},
|
|
{
|
|
title: '操作',
|
|
slotName: 'action',
|
|
width: 80,
|
|
},
|
|
])
|
|
|
|
const partyLoading = ref(false)
|
|
const partyOptions = ref<Array<{ label: string; value: number }>>([])
|
|
const supplierOptions = ref<Array<{ label: string; value: number }>>([])
|
|
const agentOptions = ref<Array<{ label: string; value: number }>>([])
|
|
|
|
const form = reactive({
|
|
id: undefined as number | undefined,
|
|
contractName: '',
|
|
partyType: CONTRACT_PARTY_TYPE.Customer as string,
|
|
partyId: undefined as number | undefined,
|
|
ourEntityName: '',
|
|
signDate: undefined as any,
|
|
effectiveDate: dayjs().format('YYYY-MM-DD') as any,
|
|
expireDate: undefined as any,
|
|
autoRenew: false,
|
|
settlementMethod: SETTLEMENT_METHOD.Monthly as string,
|
|
paymentTermDays: 30,
|
|
billingDay: undefined as number | undefined,
|
|
paymentDay: undefined as number | undefined,
|
|
currency: 'CNY',
|
|
creditLimit: undefined as number | undefined,
|
|
commissionBaseType: undefined as string | undefined,
|
|
commissionRate: undefined as number | undefined,
|
|
requireVendorInvoice: false,
|
|
ownerName: '',
|
|
attachmentUrls: '',
|
|
remark: '',
|
|
})
|
|
|
|
const tabItems = computed(() => [
|
|
{ key: 'all', label: t('finance.contract.tab.all') },
|
|
{ key: 'customer', label: t('finance.contract.tab.customer') },
|
|
{ key: 'supplier', label: t('finance.contract.tab.supplier') },
|
|
{ key: 'agent', label: t('finance.contract.tab.agent') },
|
|
{ key: 'expiringSoon', label: t('finance.contract.tab.expiringSoon') },
|
|
{ key: 'ended', label: t('finance.contract.tab.ended') },
|
|
])
|
|
|
|
const drawerTitle = computed(() => {
|
|
if (drawerReadonly.value) return t('finance.contract.drawer.view')
|
|
return form.id ? t('finance.contract.drawer.edit') : t('finance.contract.drawer.create')
|
|
})
|
|
|
|
const hotColumns = computed(() => [
|
|
{ key: 'contractNo', label: t('finance.contract.table.contractNo'), width: 140 },
|
|
{ key: 'contractName', label: t('finance.contract.table.contractName'), width: 160 },
|
|
{ key: 'partyTypeName', label: t('finance.contract.table.partyType'), width: 90 },
|
|
{ key: 'partyDisplay', label: t('finance.contract.table.party'), width: 160 },
|
|
{ key: 'settlementMethodName', label: t('finance.contract.table.settlementMethod'), width: 90 },
|
|
{ key: 'paymentTermDays', label: t('finance.contract.table.paymentTermDays'), width: 90 },
|
|
{ key: 'currency', label: t('finance.contract.table.currency'), width: 70 },
|
|
{ key: 'effectiveRange', label: t('finance.contract.table.effectiveRange'), width: 200 },
|
|
{ key: 'statusName', label: t('finance.contract.table.status'), width: 90 },
|
|
{ key: 'attachmentCount', label: t('finance.contract.table.attachmentCount'), width: 70 },
|
|
{ key: 'ownerName', label: t('finance.contract.table.ownerName'), width: 100 },
|
|
])
|
|
|
|
function formatDate(value?: string) {
|
|
if (!value) return ''
|
|
return dayjs(value).format('YYYY-MM-DD')
|
|
}
|
|
|
|
function mapRow(row: FinanceContract) {
|
|
return {
|
|
...row,
|
|
partyDisplay: [row.partyName, row.partyCode].filter(Boolean).join(' / '),
|
|
effectiveRange: `${formatDate(row.effectiveDate)} ~ ${formatDate(row.expireDate) || '-'}`,
|
|
}
|
|
}
|
|
|
|
async function loadList() {
|
|
listLoading.value = true
|
|
try {
|
|
const params: Record<string, any> = {
|
|
page: currentPage.value,
|
|
pageSize: pageSize.value,
|
|
keyword: keyword.value || undefined,
|
|
}
|
|
if (tabFilter.value === 'expiringSoon' || tabFilter.value === 'ended') {
|
|
params.status = tabFilter.value
|
|
} else if (tabFilter.value !== 'all') {
|
|
params.partyType = tabFilter.value
|
|
}
|
|
const { items, total } = await getFinanceContractList(params)
|
|
tableRows.value = items.map(mapRow)
|
|
totalCount.value = total
|
|
} catch (e) {
|
|
Message.error(extractOmsRequestError(e) || t('finance.contract.message.loadFailed'))
|
|
} finally {
|
|
listLoading.value = false
|
|
}
|
|
}
|
|
|
|
function handleTabChange() {
|
|
currentPage.value = 1
|
|
loadList()
|
|
}
|
|
|
|
function handleSearch() {
|
|
currentPage.value = 1
|
|
loadList()
|
|
}
|
|
|
|
function handleReset() {
|
|
keyword.value = ''
|
|
tabFilter.value = 'all'
|
|
currentPage.value = 1
|
|
loadList()
|
|
}
|
|
|
|
function resetForm() {
|
|
form.id = undefined
|
|
form.contractName = ''
|
|
form.partyType = CONTRACT_PARTY_TYPE.Customer
|
|
form.partyId = undefined
|
|
form.ourEntityName = ''
|
|
form.signDate = undefined
|
|
form.effectiveDate = dayjs().format('YYYY-MM-DD')
|
|
form.expireDate = undefined
|
|
form.autoRenew = false
|
|
form.settlementMethod = SETTLEMENT_METHOD.Monthly
|
|
form.paymentTermDays = 30
|
|
form.billingDay = undefined
|
|
form.paymentDay = undefined
|
|
form.currency = 'CNY'
|
|
form.creditLimit = undefined
|
|
form.commissionBaseType = undefined
|
|
form.commissionRate = undefined
|
|
form.requireVendorInvoice = false
|
|
form.ownerName = ''
|
|
form.attachmentUrls = ''
|
|
form.remark = ''
|
|
}
|
|
|
|
async function loadPartyOptions() {
|
|
partyLoading.value = true
|
|
try {
|
|
if (form.partyType === CONTRACT_PARTY_TYPE.Customer) {
|
|
partyOptions.value = customerOptions.value
|
|
} else if (form.partyType === CONTRACT_PARTY_TYPE.Supplier) {
|
|
if (!supplierOptions.value.length) {
|
|
const list = await getFinanceSupplierOptions()
|
|
supplierOptions.value = list.map((x) => ({
|
|
label: `${x.supplierName} (${x.supplierCode})`,
|
|
value: x.id,
|
|
}))
|
|
}
|
|
partyOptions.value = supplierOptions.value
|
|
} else {
|
|
if (!agentOptions.value.length) {
|
|
const { items } = await AgentAdminApi.list({ page: 1, pageSize: 500 })
|
|
agentOptions.value = (items || []).map((row: any) => {
|
|
const id = Number(row.id ?? row.Id ?? 0)
|
|
const name = String(row.agentName ?? row.AgentName ?? `#${id}`)
|
|
const code = String(row.agentCode ?? row.AgentCode ?? '')
|
|
return { label: code ? `${name} (${code})` : name, value: id }
|
|
})
|
|
}
|
|
partyOptions.value = agentOptions.value
|
|
}
|
|
} finally {
|
|
partyLoading.value = false
|
|
}
|
|
}
|
|
|
|
function handlePartyTypeChange() {
|
|
form.partyId = undefined
|
|
loadPartyOptions()
|
|
}
|
|
|
|
async function openCreate() {
|
|
resetForm()
|
|
drawerReadonly.value = false
|
|
drawerVisible.value = true
|
|
await loadPartyOptions()
|
|
}
|
|
|
|
async function openEdit(row: FinanceContract, readonly = false) {
|
|
form.id = row.id
|
|
form.contractName = row.contractName
|
|
form.partyType = row.partyType
|
|
form.partyId = row.partyId
|
|
form.ourEntityName = row.ourEntityName || ''
|
|
form.signDate = row.signDate ? dayjs(row.signDate).format('YYYY-MM-DD') : undefined
|
|
form.effectiveDate = row.effectiveDate ? dayjs(row.effectiveDate).format('YYYY-MM-DD') : undefined
|
|
form.expireDate = row.expireDate ? dayjs(row.expireDate).format('YYYY-MM-DD') : undefined
|
|
form.autoRenew = row.autoRenew
|
|
form.settlementMethod = row.settlementMethod
|
|
form.paymentTermDays = row.paymentTermDays
|
|
form.billingDay = row.billingDay ?? undefined
|
|
form.paymentDay = row.paymentDay ?? undefined
|
|
form.currency = row.currency || 'CNY'
|
|
form.creditLimit = row.creditLimit ?? undefined
|
|
form.commissionBaseType = row.commissionBaseType
|
|
form.commissionRate = row.commissionRate ?? undefined
|
|
form.requireVendorInvoice = row.requireVendorInvoice
|
|
form.ownerName = row.ownerName || ''
|
|
form.attachmentUrls = row.attachmentUrls || ''
|
|
form.remark = row.remark || ''
|
|
drawerReadonly.value = readonly
|
|
drawerVisible.value = true
|
|
await loadPartyOptions()
|
|
}
|
|
|
|
function toDateString(value: any) {
|
|
if (!value) return undefined
|
|
return dayjs(value).format('YYYY-MM-DD')
|
|
}
|
|
|
|
async function handleSave(activate: boolean) {
|
|
if (!form.contractName?.trim() || !form.partyId || !form.effectiveDate) {
|
|
Message.warning('请填写必填项')
|
|
return
|
|
}
|
|
saving.value = true
|
|
try {
|
|
await saveFinanceContract({
|
|
id: form.id,
|
|
contractName: form.contractName.trim(),
|
|
partyType: form.partyType,
|
|
partyId: form.partyId,
|
|
ourEntityName: form.ourEntityName || undefined,
|
|
signDate: toDateString(form.signDate),
|
|
effectiveDate: toDateString(form.effectiveDate)!,
|
|
expireDate: toDateString(form.expireDate),
|
|
autoRenew: form.autoRenew,
|
|
settlementMethod: form.settlementMethod,
|
|
paymentTermDays: form.paymentTermDays,
|
|
billingDay: form.billingDay,
|
|
paymentDay: form.paymentDay,
|
|
currency: form.currency,
|
|
creditLimit: form.creditLimit,
|
|
commissionBaseType: form.commissionBaseType,
|
|
commissionRate: form.commissionRate,
|
|
requireVendorInvoice: form.requireVendorInvoice,
|
|
ownerName: form.ownerName || undefined,
|
|
attachmentUrls: form.attachmentUrls || undefined,
|
|
remark: form.remark || undefined,
|
|
activate,
|
|
})
|
|
Message.success(
|
|
activate
|
|
? t('finance.contract.message.activateSuccess')
|
|
: t('finance.contract.message.saveSuccess'),
|
|
)
|
|
drawerVisible.value = false
|
|
await loadList()
|
|
} catch (e) {
|
|
Message.error(extractOmsRequestError(e))
|
|
} finally {
|
|
saving.value = false
|
|
}
|
|
}
|
|
|
|
function actionRenderer(row: FinanceContract) {
|
|
const buttons: string[] = [
|
|
renderWarehouseActionBtn('view', t('finance.contract.action.view'), 'view'),
|
|
]
|
|
if (
|
|
(row.status === CONTRACT_STATUS.Draft || row.status === CONTRACT_STATUS.Active)
|
|
&& hasPermission('Finance.Contract.Update')
|
|
) {
|
|
buttons.push(renderWarehouseActionBtn('edit', t('finance.contract.action.edit'), 'edit'))
|
|
}
|
|
if (row.status === CONTRACT_STATUS.Draft && hasPermission('Finance.Contract.Activate')) {
|
|
buttons.push(renderWarehouseActionBtn('receive', t('finance.contract.action.activate'), 'activate'))
|
|
}
|
|
if (row.status !== CONTRACT_STATUS.Terminated && hasPermission('Finance.Contract.Renew')) {
|
|
buttons.push(renderWarehouseActionBtn('history', t('finance.contract.action.renew'), 'renew'))
|
|
}
|
|
if (
|
|
(row.status === CONTRACT_STATUS.Draft || row.status === CONTRACT_STATUS.Active)
|
|
&& hasPermission('Finance.Contract.Terminate')
|
|
) {
|
|
buttons.push(renderWarehouseActionBtn('delete', t('finance.contract.action.terminate'), 'terminate'))
|
|
}
|
|
return wrapWarehouseActions(buttons)
|
|
}
|
|
|
|
function customCellRenderer(instance: any, td: HTMLTableCellElement, row: number, col: number, prop: string | number, value: any) {
|
|
if (prop === 'statusName') {
|
|
const rowData = tableRows.value[row]
|
|
const color =
|
|
rowData?.status === CONTRACT_STATUS.Active
|
|
? 'green'
|
|
: rowData?.status === CONTRACT_STATUS.Draft
|
|
? 'blue'
|
|
: rowData?.expiringSoon
|
|
? 'orangered'
|
|
: 'gray'
|
|
td.innerHTML = buildStatusTagHtml(String(value || ''), color)
|
|
return td
|
|
}
|
|
td.textContent = value == null ? '' : String(value)
|
|
return td
|
|
}
|
|
|
|
async function handleActionClick(payload: { action: string; row: number }) {
|
|
const row = tableRows.value[payload.row]
|
|
if (!row) return
|
|
if (payload.action === 'view') {
|
|
await openEdit(row, true)
|
|
return
|
|
}
|
|
if (payload.action === 'edit') {
|
|
await openEdit(row, false)
|
|
return
|
|
}
|
|
if (payload.action === 'activate') {
|
|
Modal.confirm({
|
|
title: t('finance.contract.action.activate'),
|
|
content: t('finance.contract.message.activateConfirm'),
|
|
onOk: async () => {
|
|
await activateFinanceContract(row.id)
|
|
Message.success(t('finance.contract.message.activateSuccess'))
|
|
await loadList()
|
|
},
|
|
})
|
|
return
|
|
}
|
|
if (payload.action === 'renew') {
|
|
Modal.confirm({
|
|
title: t('finance.contract.action.renew'),
|
|
content: t('finance.contract.message.renewConfirm'),
|
|
onOk: async () => {
|
|
await renewFinanceContract(row.id)
|
|
Message.success(t('finance.contract.message.renewSuccess'))
|
|
await loadList()
|
|
},
|
|
})
|
|
return
|
|
}
|
|
if (payload.action === 'terminate') {
|
|
terminateId.value = row.id
|
|
terminateReason.value = ''
|
|
terminateVisible.value = true
|
|
}
|
|
}
|
|
|
|
async function handleTerminateOk() {
|
|
terminating.value = true
|
|
try {
|
|
await terminateFinanceContract(terminateId.value, terminateReason.value || undefined)
|
|
Message.success(t('finance.contract.message.terminateSuccess'))
|
|
terminateVisible.value = false
|
|
await loadList()
|
|
} catch (e) {
|
|
Message.error(extractOmsRequestError(e))
|
|
return false
|
|
} finally {
|
|
terminating.value = false
|
|
}
|
|
}
|
|
|
|
async function loadSuppliers() {
|
|
supplierLoading.value = true
|
|
try {
|
|
const { items } = await getFinanceSupplierList({ page: 1, pageSize: 200 })
|
|
supplierRows.value = items
|
|
} finally {
|
|
supplierLoading.value = false
|
|
}
|
|
}
|
|
|
|
function openSupplierForm(row?: FinanceSupplier) {
|
|
supplierForm.id = row?.id
|
|
supplierForm.supplierCode = row?.supplierCode || ''
|
|
supplierForm.supplierName = row?.supplierName || ''
|
|
supplierForm.bankAccountName = row?.bankAccountName || ''
|
|
supplierForm.bankName = row?.bankName || ''
|
|
supplierForm.bankAccountNo = row?.bankAccountNo || ''
|
|
supplierForm.currency = row?.currency || 'CNY'
|
|
supplierFormVisible.value = true
|
|
}
|
|
|
|
async function handleSupplierSave() {
|
|
if (!supplierForm.supplierCode.trim() || !supplierForm.supplierName.trim()) {
|
|
Message.warning('请填写编码和名称')
|
|
return false
|
|
}
|
|
supplierSaving.value = true
|
|
try {
|
|
await saveFinanceSupplier({ ...supplierForm })
|
|
Message.success(t('finance.contract.message.saveSuccess'))
|
|
supplierFormVisible.value = false
|
|
supplierOptions.value = []
|
|
await loadSuppliers()
|
|
return true
|
|
} catch (e) {
|
|
Message.error(extractOmsRequestError(e))
|
|
return false
|
|
} finally {
|
|
supplierSaving.value = false
|
|
}
|
|
}
|
|
|
|
watch(supplierVisible, (v) => {
|
|
if (v) loadSuppliers()
|
|
})
|
|
|
|
onMounted(() => {
|
|
loadList()
|
|
})
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.finance-contract-container {
|
|
height: 100%;
|
|
padding: 16px;
|
|
box-sizing: border-box;
|
|
background: #f0f3f4;
|
|
}
|
|
|
|
.finance-contract-page-card {
|
|
height: 100%;
|
|
background: #fff;
|
|
border-radius: 4px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-height: 0;
|
|
padding: 0 16px 16px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.status-tabs {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
padding-top: 8px;
|
|
flex-wrap: wrap;
|
|
|
|
:deep(.t-tabs) {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
}
|
|
|
|
.status-tabs-filter {
|
|
flex-shrink: 0;
|
|
margin-left: auto;
|
|
}
|
|
|
|
.filter-keyword {
|
|
width: 240px;
|
|
}
|
|
|
|
.table-toolbar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
padding: 8px 0 0;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.list-spin {
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.list-spin :deep(.arco-spin-container) {
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.list-wrap {
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.supplier-toolbar {
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|