fix: remove manual expense detail add action
This commit is contained in:
@@ -130,16 +130,6 @@
|
||||
<i class="mdi mdi-robot-outline"></i>
|
||||
<span>{{ uploadingExpenseId ? '识别中' : '智能录入' }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="isEditableRequest"
|
||||
class="smart-entry-btn secondary"
|
||||
type="button"
|
||||
:disabled="actionBusy"
|
||||
@click="handleAddExpenseItem"
|
||||
>
|
||||
<i class="mdi mdi-plus-circle-outline"></i>
|
||||
<span>{{ creatingExpense ? '新增中' : '增加明细' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isApplicationDocument" class="application-detail-facts">
|
||||
@@ -439,7 +429,7 @@
|
||||
</template>
|
||||
<tr v-if="!expenseItems.length" class="empty-row">
|
||||
<td :colspan="expenseTableColumnCount" class="empty-row-cell">
|
||||
当前还没有费用明细,点击右上角“增加明细”继续补充。
|
||||
当前还没有费用明细,请通过智能录入上传票据后由系统自动归集。
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -590,7 +590,6 @@ export default {
|
||||
const { currentUser } = useSystemState()
|
||||
const editingExpenseId = ref('')
|
||||
const savingExpenseId = ref('')
|
||||
const creatingExpense = ref(false)
|
||||
const uploadingExpenseId = ref('')
|
||||
const deletingAttachmentId = ref('')
|
||||
const deletingExpenseId = ref('')
|
||||
@@ -898,7 +897,6 @@ export default {
|
||||
|| returnBusy.value
|
||||
|| approveBusy.value
|
||||
|| payBusy.value
|
||||
|| creatingExpense.value
|
||||
|| smartEntryRecognitionBusy.value
|
||||
|| Boolean(uploadingExpenseId.value)
|
||||
|| Boolean(deletingAttachmentId.value)
|
||||
@@ -1086,7 +1084,7 @@ export default {
|
||||
return `已选择 ${names.length} 张附件`
|
||||
})
|
||||
const smartEntryUploadBusy = computed(() =>
|
||||
smartEntryUploadDialogOpen.value && (creatingExpense.value || Boolean(uploadingExpenseId.value))
|
||||
smartEntryUploadDialogOpen.value && Boolean(uploadingExpenseId.value)
|
||||
)
|
||||
const attachmentPreviewEntries = computed(() =>
|
||||
expenseItems.value
|
||||
@@ -1839,48 +1837,6 @@ export default {
|
||||
return ''
|
||||
}
|
||||
|
||||
async function createDraftExpenseItem({ openEditor = true } = {}) {
|
||||
if (!request.value.claimId) {
|
||||
toast('当前草稿缺少 claimId,暂时无法新增费用明细。')
|
||||
return null
|
||||
}
|
||||
|
||||
creatingExpense.value = true
|
||||
try {
|
||||
const existingIds = new Set(expenseItems.value.map((item) => item.id))
|
||||
const claim = await createExpenseClaimItem(request.value.claimId, {})
|
||||
const createdItem = Array.isArray(claim?.items)
|
||||
? claim.items.find((entry) => !existingIds.has(String(entry?.id || '')))
|
||||
: null
|
||||
|
||||
if (!createdItem) {
|
||||
throw new Error('新增费用明细失败,请稍后重试。')
|
||||
}
|
||||
|
||||
const nextItem = buildExpenseItemViewModel(createdItem, expenseItems.value.length, request.value)
|
||||
expenseItems.value = rebuildExpenseItems([...expenseItems.value, nextItem], request.value)
|
||||
creatingExpense.value = false
|
||||
if (openEditor) {
|
||||
startExpenseEdit(nextItem)
|
||||
toast('已新增一条费用明细,请继续填写。')
|
||||
}
|
||||
return nextItem
|
||||
} catch (error) {
|
||||
toast(error?.message || '新增费用明细失败,请稍后重试。')
|
||||
return null
|
||||
} finally {
|
||||
creatingExpense.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAddExpenseItem() {
|
||||
if (!isEditableRequest.value || actionBusy.value) {
|
||||
return
|
||||
}
|
||||
|
||||
await createDraftExpenseItem({ openEditor: true })
|
||||
}
|
||||
|
||||
function triggerSmartEntryUpload() {
|
||||
if (!isEditableRequest.value || actionBusy.value) {
|
||||
return
|
||||
@@ -2590,12 +2546,12 @@ export default {
|
||||
currentSubmitRiskWarning,
|
||||
canEditDetailNote, deleteActionLabel, deleteBusy, deleteDialogDescription, deleteDialogOpen,
|
||||
deleteDialogTitle, deletingAttachmentId, deletingExpenseId, detailNote, detailNoteDirty,
|
||||
detailNoteEditor, detailNoteEditorView, detailNoteTags, draftBlockingIssues, editingExpenseId, creatingExpense, expenseEditor,
|
||||
detailNoteEditor, detailNoteEditorView, detailNoteTags, draftBlockingIssues, editingExpenseId, expenseEditor,
|
||||
expenseItems, expenseTableColumnCount, expenseTotal, expenseUploadInput,
|
||||
expenseTypeOptions: EXPENSE_TYPE_OPTIONS,
|
||||
goToNextSubmitRisk, goToPreviousSubmitRisk,
|
||||
focusExpenseRisk,
|
||||
handleAddExpenseItem, handleApproveRequest, handleDeleteRequest, handleExpenseFileChange, handleSmartEntryFileChange,
|
||||
handleApproveRequest, handleDeleteRequest, handleExpenseFileChange, handleSmartEntryFileChange,
|
||||
handleModifyApplication,
|
||||
handlePayRequest,
|
||||
handleReturnRequest, handleSubmit, heroFactItems, isApplicationDocument, isDraftRequest, isEditableRequest, isTravelRequest,
|
||||
|
||||
@@ -605,6 +605,10 @@ test('expense attachment actions keep preview as the only recognition entry poin
|
||||
test('expense detail table shows the amount total below detail rows', () => {
|
||||
assert.match(detailViewTemplate, /<div[^>]*class="detail-expense-table"/)
|
||||
assert.match(detailViewTemplate, /当前还没有费用明细/)
|
||||
assert.match(detailViewTemplate, /通过智能录入上传票据后由系统自动归集/)
|
||||
assert.doesNotMatch(detailViewTemplate, /增加明细/)
|
||||
assert.doesNotMatch(detailViewTemplate, /handleAddExpenseItem/)
|
||||
assert.doesNotMatch(detailViewScript, /handleAddExpenseItem/)
|
||||
assert.doesNotMatch(detailViewTemplate, /class="total-row"/)
|
||||
assert.match(detailViewTemplate, /class="expense-total-under-table"[\s\S]*金额合计[\s\S]*\{\{ expenseTotal \}\}/)
|
||||
assert.doesNotMatch(detailViewTemplate, /\{\{ uploadedExpenseCount \}\} 项已关联票据/)
|
||||
|
||||
Reference in New Issue
Block a user