ZN
7 天以前 dd630fede0cc46500fe898c75464e3e04ce82b0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
  <view class="sales-account">
    <PageHeader title="收入管理" @back="goBack" />
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <uni-datetime-picker type="daterange" v-model="filters.entryDate" @change="onDateChange" />
        </view>
        <view class="search-input">
          <up-input readonly placeholder="收款方式" v-model="incomeMethodLabel" @click="methodPickerShow = true" />
        </view>
        <view class="filter-button" @click="getList">
          <up-icon name="search" size="24" color="#999" />
        </view>
      </view>
    <view class="actions">
        <u-button type="primary" size="small" @click="goAdd">新增</u-button>
    </view>
    </view>
    <view class="ledger-list" v-if="list.length>0">
      <view class="ledger-item" v-for="item in list" :key="item.id">
        <view class="item-header">
          <view class="item-left">
            <view class="document-icon"><up-icon name="file-text" color="#fff" size="16" /></view>
            <text class="item-id">{{ item.customerName || '--' }}</text>
          </view>
          <view class="item-tag">
            <u-tag>{{ methodText(item.incomeMethod) }}</u-tag>
          </view>
        </view>
        <up-divider></up-divider>
        <view class="item-details">
          <view class="detail-row"><text class="detail-label">收入日期</text><text class="detail-value">{{ item.incomeDate || '--' }}</text></view>
          <view class="detail-row"><text class="detail-label">收入类型</text><text class="detail-value">{{ incomeTypeText(item.incomeType) || '--' }}</text></view>
          <view class="detail-row"><text class="detail-label">收入金额(元)</text><text class="detail-value highlight">{{ fmtAmount(item.incomeMoney) }}</text></view>
          <view class="detail-row"><text class="detail-label">发票号码</text><text class="detail-value">{{ item.invoiceNumber || '--' }}</text></view>
          <view class="detail-row"><text class="detail-label">备注</text><text class="detail-value">{{ item.note || '--' }}</text></view>
        </view>
        <view class="card-actions">
          <u-button size="small" @click="goEdit(item)" :disabled="!!item.businessId">编辑</u-button>
          <u-button size="small" type="error" @click="confirmDelete(item)" :disabled="!!item.businessId">删除</u-button>
        </view>
      </view>
    </view>
    <view class="no-data" v-else><text>暂无数据</text></view>
 
    <up-action-sheet :show="methodPickerShow" :actions="paymentMethods" title="收款方式" @select="onSelectMethod" @close="methodPickerShow=false" />
  </view>
</template>
 
<script setup>
import { ref, reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { listPage, delAccountIncome } from "@/api/financialManagement/revenueManagement";
import { useDict } from "@/utils/dict";
 
const list = ref([]);
const filters = reactive({ entryDate: null, incomeMethod: undefined, entryDateStart: undefined, entryDateEnd: undefined });
const { payment_methods, income_types } = useDict("payment_methods", "income_types");
const paymentMethods = ref([]);
const incomeTypes = ref([]);
const methodPickerShow = ref(false);
const incomeMethodLabel = ref("");
 
const syncDict = () => {
  paymentMethods.value = (payment_methods?.value || []).map(i => ({ label: i.label, value: i.value }));
  incomeTypes.value = (income_types?.value || []).filter(i=>i.value!=3).map(i => ({ label: i.label, value: i.value }));
};
 
const getList = () => {
  listPage({ incomeMethod: filters.incomeMethod, entryDateStart: filters.entryDateStart, entryDateEnd: filters.entryDateEnd, current: 1, size: 100 })
    .then(res => {
      const records = res?.data?.records ?? res?.records ?? [];
      list.value = records;
    });
};
 
const onDateChange = (val) => {
  if (val && val.length === 2) {
    filters.entryDateStart = val[0];
    filters.entryDateEnd = val[1];
  } else {
    filters.entryDateStart = undefined;
    filters.entryDateEnd = undefined;
  }
};
 
const onSelectMethod = (e) => {
  filters.incomeMethod = e.value;
  incomeMethodLabel.value = e.label;
  methodPickerShow.value = false;
};
 
const methodText = (v) => {
  const m = paymentMethods.value.find(i=>String(i.value)===String(v));
  return m?.label || "--";
};
const incomeTypeText = (v) => {
  const m = incomeTypes.value.find(i=>String(i.value)===String(v));
  return m?.label || null;
};
const fmtAmount = (v) => {
  const n = parseFloat(v || 0);
  return n.toFixed(2);
};
 
const goAdd = () => {
  uni.navigateTo({ url: "/pages/financialManagement/revenueManagement/edit?type=add" });
};
const goEdit = (row) => {
  uni.navigateTo({ url: `/pages/financialManagement/revenueManagement/edit?type=edit&id=${row.id}` });
};
const confirmDelete = (row) => {
  uni.showModal({
    title: "提示",
    content: "确认删除该记录?",
    success: async (r) => {
      if (r.confirm) {
        const ids = Array.isArray(row) ? row.map(i=>i.id) : [row.id];
        const res = await delAccountIncome(ids);
        if (res?.code === 200) getList();
      }
    },
  });
};
 
const onIncomeTypeConfirm = (e) => {
  const item = incomeTypes.value[e.value[0]];
  if (item) form.incomeType = item.value;
};
const onMethodConfirm = (e) => {
  const item = paymentMethods.value[e.value[0]];
  if (item) form.incomeMethod = item.value;
};
 
const goBack = () => {
  uni.navigateBack();
};
 
syncDict();
onShow(() => {
  getList();
});
</script>
 
<style scoped lang="scss">
@import "@/styles/sales-common.scss";
.actions { margin-top: 8px; }
</style>