gaoluyang
2026-09-20 e449a5408265e4bd1f6c66f5be28a42efac444ee
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
<template>
  <view class="account-view">
    <!-- 使用通用页面头部组件 -->
    <PageHeader title="台账详情"
                @back="goBack" />
    <!-- 基本信息展示 -->
    <view class="info-section">
      <view class="section-title">基本信息</view>
      <view class="info-grid">
        <view class="info-item">
          <text class="info-label">销售合同号</text>
          <text class="info-value">{{ form.salesContractNo }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">客户名称</text>
          <text class="info-value">{{ form.customerName }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">业务员</text>
          <text class="info-value">{{ form.salesman }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">项目名称</text>
          <text class="info-value">{{ form.projectName }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">签订日期</text>
          <text class="info-value">{{ form.executionDate }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">年份</text>
          <text class="info-value">{{ form.year || "-" }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">付款方式</text>
          <text class="info-value">{{ dictLabel(form.paymentMethod) }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">交货日期</text>
          <text class="info-value">{{ form.deliveryDate || "-" }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">签单单位</text>
          <text class="info-value">{{ deptName(form.signingUnitId) }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">办事处</text>
          <text class="info-value">{{ deptName(form.officeId) }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">组负责人</text>
          <text class="info-value">{{ userName(form.groupLeaderId) }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">是否开发票</text>
          <text class="info-value">{{ form.isInvoice === 1 ? "是" : "否" }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">是否中标</text>
          <text class="info-value">{{ form.isBid === 1 ? "是" : "否" }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">{{ form.isBid === 1 ? "中标价" : "未中标原因" }}</text>
          <text class="info-value">
            {{ form.isBid === 1 ? form.bidPrice ?? "-" : form.unbidReason || "-" }}
          </text>
        </view>
        <view class="info-item">
          <text class="info-label">合同原件约定回传日期</text>
          <text class="info-value">{{ form.contractOriginalReturnDate || "-" }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">录入人</text>
          <text class="info-value">{{ form.entryPersonName }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">录入日期</text>
          <text class="info-value">{{ form.entryDate }}</text>
        </view>
        <view v-if="form.remarks"
              class="info-item remarks-item">
          <text class="info-label">备注</text>
          <text class="info-value">{{ form.remarks }}</text>
        </view>
      </view>
    </view>
    <!-- 产品信息展示 -->
    <view class="product-section"
          v-if="productData && productData.length > 0">
      <view class="section-title">产品信息</view>
      <view class="product-card"
            v-for="(product, idx) in productData"
            :key="idx">
        <view class="product-header">
          <view class="product-title">
            <!-- 替换 van-icon 为 u-icon -->
            <u-icon name="file-text"
                    color="#2979ff"
                    size="15" />
            <text class="product-productCategory">产品 {{ idx + 1 }}</text>
          </view>
        </view>
        <view class="product-info">
          <view class="info-grid">
            <view class="info-item">
              <text class="info-label">产品大类</text>
              <text class="info-value">{{ product.productCategory }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">规格型号</text>
              <text class="info-value">{{ product.specificationModel }}</text>
            </view>
            <!-- <view class="info-item">
              <text class="info-label">绑定机器</text>
              <text class="info-value">{{ product.speculativeTradingName }}</text>
            </view> -->
            <view class="info-item">
              <text class="info-label">单位</text>
              <text class="info-value">{{ product.unit }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">税率(%)</text>
              <text class="info-value">{{ product.taxRate }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">含税单价(元)</text>
              <text class="info-value highlight">{{ product.taxInclusiveUnitPrice }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">数量</text>
              <text class="info-value highlight">{{ product.quantity }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">含税总价(元)</text>
              <text class="info-value highlight">{{ product.taxInclusiveTotalPrice }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">不含税总价(元)</text>
              <text class="info-value highlight">{{ product.taxExclusiveTotalPrice }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">发票类型</text>
              <text class="info-value">{{ product.invoiceType }}</text>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view v-else
          class="no-product">
      <text>暂无产品信息</text>
    </view>
    <!-- 需求五.4:签约金额 = 含税单价 × 数量,按产品行汇总(对齐管理端 summarizeMainTable) -->
    <view v-if="productData.length > 0"
          class="product-summary">
      <view class="summary-row">
        <text class="summary-label">签约金额合计(元)</text>
        <text class="summary-value highlight">{{ productTotals.taxInclusive }}</text>
      </view>
      <view class="summary-row">
        <text class="summary-label">不含税总价合计(元)</text>
        <text class="summary-value">{{ productTotals.taxExclusive }}</text>
      </view>
    </view>
  </view>
</template>
 
<script setup>
  import { computed, onMounted, ref } from "vue";
  import { getSalesLedgerWithProducts } from "@/api/salesManagement/salesLedger";
  import { getDept } from "@/api/collaborativeApproval/approvalProcess";
  import { userListNoPageByTenantId } from "@/api/system/user";
  import { useDict } from "@/utils/dict";
  import PageHeader from "@/components/PageHeader.vue";
 
  const { checkout_payment } = useDict("checkout_payment");
 
  // 获取页面参数
  const editData = ref(null);
 
  const form = ref({
    id: "",
    salesContractNo: "",
    customerId: "",
    customerName: "",
    projectName: "",
    executionDate: "",
    paymentMethod: "",
    entryPerson: "",
    entryPersonName: "",
    entryDate: "",
    salesman: "",
  });
 
  // 产品数据
  const productData = ref([]);
  const deptOptions = ref([]);
  const userOptions = ref([]);
 
  const dictLabel = value => {
    if (value === undefined || value === null || value === "") return "-";
    const matched = (checkout_payment.value || []).find(
      item => String(item.value) === String(value)
    );
    return matched ? matched.label : String(value);
  };
 
  // 后端只存 id,只读页需要自己反查部门 / 员工名称
  const deptName = id =>
    deptOptions.value.find(item => String(item.value) === String(id))?.name ||
    "-";
  const userName = id =>
    userOptions.value.find(item => String(item.value) === String(id))?.name ||
    "-";
 
  const productTotals = computed(() => {
    const sumBy = key =>
      (productData.value || [])
        .reduce((sum, row) => sum + (Number(row?.[key]) || 0), 0)
        .toFixed(2);
    return {
      taxInclusive: sumBy("taxInclusiveTotalPrice"),
      taxExclusive: sumBy("taxExclusiveTotalPrice"),
    };
  });
 
  // 返回上一页
  const goBack = () => {
    // 清理本地存储的数据
    uni.removeStorageSync("editData");
    uni.navigateBack();
  };
 
  // 填充表单数据
  const fillFormData = () => {
    if (!editData.value) return;
 
    // 获取完整的产品信息
    getSalesLedgerWithProducts({ id: editData.value.id, type: 1 }).then(res => {
      productData.value = res.productData || [];
      form.value = { ...res };
    });
  };
 
  const loadOrgOptions = async () => {
    const [depts, users] = await Promise.all([
      getDept().catch(() => ({})),
      userListNoPageByTenantId().catch(() => ({})),
    ]);
    deptOptions.value = (depts?.data || []).map(item => ({
      name: item.deptName,
      value: item.deptId,
    }));
    const rows = users?.data || [];
    userOptions.value = (Array.isArray(rows) ? rows : []).map(item => ({
      name: item.nickName || item.userName || `用户${item.userId}`,
      value: item.userId,
    }));
  };
 
  onMounted(() => {
    loadOrgOptions();
    // 获取编辑数据并填充表单
    const editDataStr = uni.getStorageSync("editData");
    if (editDataStr) {
      try {
        editData.value = JSON.parse(editDataStr);
        // 使用 nextTick 确保数据加载完成后再填充
        setTimeout(() => {
          fillFormData();
        }, 100);
      } catch (error) {
        console.error("解析编辑数据失败:", error);
      }
    }
  });
</script>
 
<style scoped lang="scss">
  .account-view {
    min-height: 100vh;
    background: #f8f9fa;
    padding-bottom: 2rem;
  }
 
  .header {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 1rem 1.25rem;
    border-bottom: 0.0625rem solid #f0f0f0;
    position: sticky;
    top: 0;
    z-index: 100;
  }
 
  .title {
    flex: 1;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: #333;
  }
 
  .info-section {
    background: #fff;
    margin: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.04);
  }
 
  .product-section {
    background: #fff;
    margin: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.04);
  }
 
  .section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 0.0625rem solid #e8e8e8;
  }
 
  .info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
 
  .info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
 
  .info-label {
    font-size: 0.75rem;
    color: #666;
    font-weight: 400;
  }
 
  .info-value {
    font-size: 0.875rem;
    color: #333;
    font-weight: 500;
  }
 
  .info-value.highlight {
    color: #2979ff;
    font-weight: 600;
  }
 
  .product-card {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 0.0625rem solid #e8e8e8;
  }
 
  .product-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 0.0625rem solid #e8e8e8;
  }
 
  .product-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
 
  .product-productCategory {
    font-size: 0.875rem;
    font-weight: 500;
    color: #333;
  }
 
  .product-info .info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
 
  .no-product {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-size: 0.875rem;
  }
 
  .remarks-item {
    grid-column: 1 / -1;
  }
 
  .product-summary {
    background: #fff;
    margin: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
 
  .summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
 
  .summary-label {
    font-size: 0.8125rem;
    color: #666;
  }
 
  .summary-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #333;
  }
 
  .summary-value.highlight {
    color: #2979ff;
  }
</style>