gaoluyang
2026-09-20 b58f53769f004fb0ba6b5aedf55ef602850c7c97
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<template>
  <view class="sales-account">
    <PageHeader title="客户往来"
                @back="goBack" />
 
    <!-- 统计条(需求七:应收摘要) -->
    <view class="summary-strip">
      <view class="summary-cell">
        <text class="summary-num">{{ summary.totalProjects || 0 }}</text>
        <text class="summary-cap">项目</text>
      </view>
      <view class="summary-cell">
        <text class="summary-num">{{ summary.totalCustomers || 0 }}</text>
        <text class="summary-cap">客户</text>
      </view>
      <view class="summary-cell">
        <text class="summary-num">{{ summary.totalContracts || 0 }}</text>
        <text class="summary-cap">合同</text>
      </view>
      <view class="summary-cell">
        <text class="summary-num">{{ fmtMoney(summary.totalAmount) }}</text>
        <text class="summary-cap">签约总额</text>
      </view>
      <view class="summary-cell overdue">
        <text class="summary-num">{{ summary.totalOverdueCount || 0 }}</text>
        <text class="summary-cap">超30天未回款</text>
      </view>
    </view>
 
    <!-- 搜索区域 -->
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input v-model="query.projectName"
                    class="search-text"
                    placeholder="请输入项目名称搜索"
                    clearable
                    @change="getList" />
        </view>
        <view class="filter-button"
              @click="showFilter = true">
          <up-icon name="list"
                   size="24"
                   color="#999" />
        </view>
      </view>
    </view>
 
    <!-- 项目列表 -->
    <view v-if="projectList.length > 0"
          class="ledger-list">
      <view v-for="item in projectList"
            :key="item.projectId"
            class="ledger-item"
            @click="goDetail(item)">
        <view class="item-header">
          <view class="item-left">
            <view class="document-icon">
              <up-icon name="file-text"
                       size="16"
                       color="#ffffff" />
            </view>
            <text class="item-id">{{ item.projectName || "-" }}</text>
          </view>
          <up-tag :text="overdueText(item.overdueCount)"
                  :type="item.overdueCount > 0 ? 'error' : 'success'"
                  size="mini"
                  shape="circle" />
        </view>
        <up-divider></up-divider>
        <view class="item-details">
          <view class="detail-row">
            <text class="detail-label">项目编号</text>
            <text class="detail-value">{{ item.projectCode || "-" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">签约总额</text>
            <text class="detail-value highlight">{{ fmtMoney(item.contractAmounts) }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">开票金额</text>
            <text class="detail-value">{{ fmtMoney(item.invoiceAmount) }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">回款金额</text>
            <text class="detail-value highlight">{{ fmtMoney(item.receiptPaymentAmount) }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">应收金额</text>
            <text class="detail-value danger">{{ fmtMoney(item.receiptableAmount) }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">退货金额</text>
            <text class="detail-value">{{ fmtMoney(item.returnAmount) }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">回款进度</text>
            <text class="detail-value"
                  :class="{ danger: item.overdueCount > 0 }">
              {{ calcRate(item.receiptPaymentAmount, item.contractAmounts) }}%
            </text>
          </view>
          <view class="detail-row">
            <text class="detail-label">客户 / 合同</text>
            <text class="detail-value">{{ item.customerCount || 0 }} 家 / {{ item.contractCount || 0 }} 份</text>
          </view>
        </view>
        <view class="action-buttons">
          <up-button class="action-btn"
                     size="small"
                     type="primary"
                     @click.stop="goDetail(item)">查看客户往来</up-button>
        </view>
      </view>
    </view>
    <view v-else
          class="no-data">
      <text>暂无项目往来数据</text>
    </view>
 
    <FilterPanel v-model:show="showFilter"
                 :model-value="query"
                 title="客户往来筛选"
                 :fields="filterFields"
                 @search="onFilterSearch"
                 @reset="onFilterSearch" />
  </view>
</template>
 
<script setup>
  import { reactive, ref, onMounted } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import FilterPanel from "@/components/FilterPanel.vue";
  import {
    projectTransactions,
    transactionsSummary,
  } from "@/api/salesManagement/indicatorStats";
  import { unwrapList } from "@/utils/list";
 
  const projectList = ref([]);
  const summary = ref({});
  const showFilter = ref(false);
 
  const query = reactive({
    projectName: "",
    customerName: "",
    contractName: "",
  });
 
  const filterFields = [
    { prop: "customerName", label: "客户名称", type: "input", placeholder: "请输入客户名称" },
    { prop: "contractName", label: "合同名称", type: "input", placeholder: "请输入合同名称" },
  ];
 
  const goBack = () => {
    uni.navigateBack();
  };
 
  const getList = () => {
    uni.showLoading({ title: "加载中...", mask: true });
    const params = { ...query, current: -1, size: -1 };
    projectTransactions(params)
      .then(res => {
        projectList.value = unwrapList(res);
        uni.hideLoading();
      })
      .catch(() => {
        uni.hideLoading();
        uni.showToast({ title: "查询失败", icon: "none" });
      });
  };
 
  const getSummary = () => {
    transactionsSummary()
      .then(res => {
        summary.value = res.data || {};
      })
      .catch(() => {});
  };
 
  const onFilterSearch = values => {
    Object.assign(query, values || {});
    getList();
  };
 
  const goDetail = item => {
    if (!item?.projectId) return;
    uni.navigateTo({
      url: `/pages/sales/receiptPaymentLedger/detail?projectId=${item.projectId}`
        + `&projectName=${encodeURIComponent(item.projectName || "")}`,
    });
  };
 
  const overdueText = count => (count > 0 ? `${count} 份超期` : "正常履约");
 
  const fmtMoney = value => {
    const num = Number(value);
    if (!Number.isFinite(num)) return "¥ 0.00";
    return "¥ " + num.toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
  };
 
  const calcRate = (paid, amount) => {
    const total = Number(amount);
    if (!Number.isFinite(total) || total === 0) return "0.0";
    return (((Number(paid) || 0) / total) * 100).toFixed(1);
  };
 
  onShow(() => {
    getList();
    getSummary();
  });
 
  onMounted(() => {
    getList();
    getSummary();
  });
</script>
 
<style scoped lang="scss">
  @import "@/styles/sales-common.scss";
 
  .summary-strip {
    display: flex;
    flex-wrap: wrap;
    background: #ffffff;
    margin: 12px 12px 0;
    border-radius: 12px;
    padding: 12px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
 
  .summary-cell {
    flex: 1 0 33%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0;
  }
 
  .summary-num {
    font-size: 16px;
    font-weight: 600;
    color: #333333;
  }
 
  .summary-cap {
    font-size: 11px;
    color: #909399;
    margin-top: 2px;
  }
 
  .summary-cell.overdue .summary-num {
    color: #ff4757;
  }
 
  .detail-value.danger {
    color: #ff4757;
    font-weight: 500;
  }
</style>