| | |
| | | <el-table-column prop="date" label="日期" width="120" /> |
| | | <el-table-column prop="voucherNo" label="凭证字号" width="120" /> |
| | | <el-table-column prop="summary" label="摘要" min-width="200" show-overflow-tooltip /> |
| | | <el-table-column label="借方" width="150"> |
| | | <el-table-column prop="debit" label="借方" width="150"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.debit > 0" class="text-danger">¥{{ formatMoney(row.debit) }}</span> |
| | | <span v-else>-</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="贷方" width="150"> |
| | | <el-table-column prop="credit" label="贷方" width="150"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.credit > 0" class="text-success">¥{{ formatMoney(row.credit) }}</span> |
| | | <span v-else>-</span> |
| | |
| | | <script setup> |
| | | import { ref, reactive, onMounted, computed, watch } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { listAccountSubject } from "@/api/financialManagement/accountSubject"; |
| | | import { getDetailLedger } from "@/api/financialManagement/ledger"; |
| | | |
| | | defineOptions({ |
| | | name: "科目明细账", |
| | |
| | | }); |
| | | |
| | | const dataList = ref([]); |
| | | const subjectOptions = ref([]); |
| | | |
| | | const subjectOptions = [ |
| | | { |
| | | code: "1122", |
| | | name: "应收账款", |
| | | children: [ |
| | | { code: "112201", name: "北京科技有限公司" }, |
| | | { code: "112202", name: "上海贸易公司" }, |
| | | { code: "112203", name: "广州实业有限公司" }, |
| | | ], |
| | | }, |
| | | { |
| | | code: "2202", |
| | | name: "应付账款", |
| | | children: [ |
| | | { code: "220201", name: "北京原材料供应商" }, |
| | | { code: "220202", name: "上海电子元器件公司" }, |
| | | { code: "220203", name: "广州包装材料厂" }, |
| | | ], |
| | | }, |
| | | { |
| | | code: "6602", |
| | | name: "管理费用", |
| | | children: [ |
| | | { code: "660201", name: "办公费" }, |
| | | { code: "660202", name: "差旅费" }, |
| | | { code: "660203", name: "业务招待费" }, |
| | | ], |
| | | }, |
| | | const fallbackSubjects = [ |
| | | { code: "1122", name: "应收账款" }, |
| | | { code: "2202", name: "应付账款" }, |
| | | { code: "6602", name: "管理费用" }, |
| | | ]; |
| | | |
| | | const loadSubjectOptions = async () => { |
| | | try { |
| | | const { data } = await listAccountSubject({ |
| | | current: 1, |
| | | size: 1000, |
| | | }); |
| | | const records = data?.records || []; |
| | | if (records.length > 0) { |
| | | subjectOptions.value = records |
| | | .filter(item => item.subjectCode && item.subjectName) |
| | | .map(item => ({ |
| | | code: item.subjectCode, |
| | | name: item.subjectName, |
| | | children: [], |
| | | })); |
| | | return; |
| | | } |
| | | } catch (error) { |
| | | // 全局拦截器已提示,下面走兜底科目 |
| | | } |
| | | subjectOptions.value = fallbackSubjects.map(item => ({ ...item, children: [] })); |
| | | }; |
| | | |
| | | const auxiliaryItems = computed(() => { |
| | | const map = { |
| | |
| | | const currentSubject = computed(() => { |
| | | if (!filters.subject || filters.subject.length === 0) return null; |
| | | const code = filters.subject[filters.subject.length - 1]; |
| | | return findSubject(subjectOptions, code); |
| | | return findSubject(subjectOptions.value, code); |
| | | }); |
| | | |
| | | const findSubject = (options, code) => { |
| | |
| | | return Number(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| | | }; |
| | | |
| | | const mockData = [ |
| | | { date: "2024-01-01", voucherNo: "-", summary: "期初余额", debit: 0, credit: 0, direction: "借", balance: 10000 }, |
| | | { date: "2024-01-05", voucherNo: "记-0001", summary: "销售出库", debit: 5000, credit: 0, direction: "借", balance: 15000 }, |
| | | { date: "2024-01-10", voucherNo: "记-0002", summary: "收到货款", debit: 0, credit: 3000, direction: "借", balance: 12000 }, |
| | | { date: "2024-01-15", voucherNo: "记-0003", summary: "销售出库", debit: 8000, credit: 0, direction: "借", balance: 20000 }, |
| | | { date: "2024-01-20", voucherNo: "记-0004", summary: "销售退货", debit: 0, credit: 2000, direction: "借", balance: 18000 }, |
| | | { date: "2024-01-25", voucherNo: "记-0005", summary: "收到货款", debit: 0, credit: 5000, direction: "借", balance: 13000 }, |
| | | { date: "2024-01-31", voucherNo: "-", summary: "本月合计", debit: 13000, credit: 10000, direction: "借", balance: 13000 }, |
| | | { date: "2024-02-01", voucherNo: "-", summary: "期初余额", debit: 0, credit: 0, direction: "借", balance: 13000 }, |
| | | { date: "2024-02-10", voucherNo: "记-0006", summary: "销售出库", debit: 6000, credit: 0, direction: "借", balance: 19000 }, |
| | | { date: "2024-02-15", voucherNo: "记-0007", summary: "收到货款", debit: 0, credit: 4000, direction: "借", balance: 15000 }, |
| | | { date: "2024-02-28", voucherNo: "-", summary: "本月合计", debit: 6000, credit: 4000, direction: "借", balance: 15000 }, |
| | | { date: "2024-03-01", voucherNo: "-", summary: "期初余额", debit: 0, credit: 0, direction: "借", balance: 15000 }, |
| | | { date: "2024-03-05", voucherNo: "记-0008", summary: "销售出库", debit: 7000, credit: 0, direction: "借", balance: 22000 }, |
| | | { date: "2024-03-10", voucherNo: "记-0009", summary: "收到货款", debit: 0, credit: 6000, direction: "借", balance: 16000 }, |
| | | { date: "2024-03-31", voucherNo: "-", summary: "本月合计", debit: 7000, credit: 6000, direction: "借", balance: 16000 }, |
| | | { date: "2024-03-31", voucherNo: "-", summary: "本年累计", debit: 26000, credit: 20000, direction: "借", balance: 16000 }, |
| | | ]; |
| | | |
| | | const getTableData = () => { |
| | | // 联调约定:明细账接口可按辅助核算过滤(auxiliaryType/auxiliaryId) |
| | | const getTableData = async () => { |
| | | if (!currentSubject.value) { |
| | | dataList.value = []; |
| | | return; |
| | | } |
| | | dataList.value = [...mockData]; |
| | | try { |
| | | const { data } = await getDetailLedger({ |
| | | subjectCode: currentSubject.value.code, |
| | | auxiliaryType: filters.auxiliary, |
| | | auxiliaryId: filters.auxiliaryItem, |
| | | startMonth: filters.startMonth, |
| | | endMonth: filters.endMonth, |
| | | }); |
| | | dataList.value = Array.isArray(data) ? data : data?.records || []; |
| | | } catch (error) { |
| | | // 提示由全局请求拦截器处理,这里仅防止未捕获异常 |
| | | } |
| | | }; |
| | | |
| | | const resetFilters = () => { |
| | |
| | | ElMessage.success("导出成功"); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | // 默认不加载数据,需要选择科目 |
| | | onMounted(async () => { |
| | | await loadSubjectOptions(); |
| | | }); |
| | | </script> |
| | | |