vue3-element-plus-app-chu 0.0.35 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-element-plus-app-chu",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -683,9 +683,10 @@ onBeforeUnmount(() => {
683
683
  background: var(--el-bg-color-page, #f7f8fa);
684
684
  }
685
685
  .estimation-header { flex: 0 0 auto; }
686
- .estimation-heading { display: flex; align-items: flex-end; gap: 6px 14px; }
686
+ .estimation-heading { display: flex; align-items: center; gap: 6px 14px; }
687
687
 
688
- .filter-field label { display: block; margin-bottom: 5px; color: var(--el-text-color-secondary); font-size: 11px; }
688
+ .filter-field { display: flex; align-items: center; gap: 8px; }
689
+ .filter-field label { color: var(--el-text-color-secondary); font-size: 11px; white-space: nowrap; }
689
690
  /* 交易日期设定宽度:el-date-editor 默认宽度更高,其根节点不带本页
690
691
  scoped 属性,需要经 :deep 从宿主命中。 */
691
692
  .estimation-heading :deep(.filter-date) { width: 140px; }
@@ -764,7 +764,7 @@ watch([detailDialogVisible, detailDialogPredRefNo], ([visible]) => {
764
764
  <template>
765
765
  <ElConfigProvider :size="listTableSettings.size">
766
766
  <!-- 新增 / 修改页 -->
767
- <main v-if="isEditor" class="dcps-forecast-shell">
767
+ <div v-if="isEditor" class="dcps-forecast-shell dcps-forecast-shell--editor">
768
768
  <el-card class="shell-header" shadow="never" :body-style="{ padding: '10px' }">
769
769
  <div class="shell-heading">
770
770
  <el-button class="shell-back" :disabled="submitting" @click="backToList">
@@ -870,7 +870,7 @@ watch([detailDialogVisible, detailDialogPredRefNo], ([visible]) => {
870
870
  </div>
871
871
  </div>
872
872
  </el-card>
873
- </main>
873
+ </div>
874
874
 
875
875
  <!-- 详情页 -->
876
876
  <main v-else-if="isDetail" class="dcps-forecast-shell">
@@ -1073,6 +1073,12 @@ watch([detailDialogVisible, detailDialogPredRefNo], ([visible]) => {
1073
1073
  .shell-title { margin: 0; color: var(--el-text-color-primary); font-size: 16px; font-weight: 600; line-height: 22px; }
1074
1074
 
1075
1075
  /* ---------- 新增 / 修改页 ---------- */
1076
+ .dcps-forecast-shell--editor > .shell-header,
1077
+ .dcps-forecast-shell--editor > .editor-card {
1078
+ box-sizing: border-box;
1079
+ width: clamp(min(100%, 560px), calc(100% - 32px), 1080px);
1080
+ margin-inline: auto;
1081
+ }
1076
1082
  .dcps-forecast-shell .editor-card { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; }
1077
1083
  /* 显式建立卡片内容区的高度链,不依赖宿主的 Element Plus 卡片布局。 */
1078
1084
  .dcps-forecast-shell .editor-card > :deep(.el-card__body) { box-sizing: border-box; display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
@@ -6,22 +6,7 @@ import type {
6
6
  Tam120502003InBody,
7
7
  } from './typs'
8
8
 
9
- // 同一操作的相同请求失败后复用流水号,避免响应丢失后重试导致重复记账。
10
- // 成功后结束本次操作;请求体变化时自动生成新的流水号。
11
- const pendingOperations = new Map<string, string>()
12
- const submitOperation = async (code: string, body: unknown) => {
13
- const key = `${code}:${JSON.stringify(body)}`
14
- let consumerSeqNo = pendingOperations.get(key)
15
- if (!consumerSeqNo) {
16
- consumerSeqNo = crypto.randomUUID()
17
- pendingOperations.set(key, consumerSeqNo)
18
- }
19
- const response = await baseHttpClient.post<any>(`/TAM/0001/${code}`, {
20
- appHead: {}, head: { consumerSeqNo }, body,
21
- })
22
- if (response.head?.retCode === '00000') pendingOperations.delete(key)
23
- return response
24
- }
9
+ type WriteOffRequest<T> = T & { consumerSeqNo: string }
25
10
 
26
11
  export default {
27
12
  /**
@@ -29,20 +14,20 @@ export default {
29
14
  * @param params 修改参数:predRefNo 为预报流水号,predAmt 为预报金额,
30
15
  * beforeVerifyAmt 为修改前已核销金额,verifyAmt 为修改后的已核销金额。
31
16
  */
32
- editApi: (params: EditVerifyFormValues) => submitOperation('120502001', params),
17
+ editApi: (params: WriteOffRequest<EditVerifyFormValues>) => baseHttpClient.post<any>('/TAM/0001/120502001', params),
33
18
  /**
34
19
  * 提交头寸核销。
35
20
  * @param params 核销参数:predList 为预报核销集合(必填),每项包含 predRefNo、predAmt、
36
21
  * verifyAmt、verifyStatus 均为查询时的原值快照;服务端按剩余金额自动分配,不能传入拟核销额。
37
22
  * tranList 为流水核销集合(可选),每项包含原 refNo、tranAmt、verifyStatus。
38
23
  */
39
- writeOffApi: (params: Tam120502002InBody) => submitOperation('120502002', params),
24
+ writeOffApi: (params: WriteOffRequest<Tam120502002InBody>) => baseHttpClient.post<any>('/TAM/0001/120502002', params),
40
25
  /**
41
26
  * 撤销头寸核销。
42
27
  * @param params 撤销参数:predList 为预报集合,tranList 为流水集合,均可选;
43
28
  * 预报项按行原值提交,流水项需包含 refNo、tranAmt、verifyStatus。
44
29
  */
45
- cancelWriteOffApi: (params: Tam120502003InBody) => submitOperation('120502003', params),
30
+ cancelWriteOffApi: (params: WriteOffRequest<Tam120502003InBody>) => baseHttpClient.post<any>('/TAM/0001/120502003', params),
46
31
  /**
47
32
  * 分页查询核销预报信息。
48
33
  * @param params 查询参数:tranDate 为交易日期(必填,YYYYMMDD);pageIndex、pageSize 为页码和每页条数。
@@ -50,8 +35,7 @@ export default {
50
35
  * clientName 为客户名称,competName 为交易对手名称,payDirec 为收支方向(1 收入、2 支出),
51
36
  * startTransAmt、endTransAmt 为金额范围,verifyStatusList 待核销传 [1,3]、已核销传 [2]。
52
37
  */
53
- queryForecastApi: (params: ForecastQueryParams) =>
54
- baseHttpClient.post<any>('/TAM/0001/140502001', params),
38
+ queryForecastApi: (params: ForecastQueryParams) => baseHttpClient.post<any>('/TAM/0001/140502001', params),
55
39
  /**
56
40
  * 分页查询核销流水信息。
57
41
  * @param params 查询参数:tranDate 为交易日期(必填,YYYYMMDD);pageIndex、pageSize 为页码和每页条数。
@@ -59,5 +43,5 @@ export default {
59
43
  * payerName、payeeName 为付款人和收款人名称,
60
44
  * payDirec 为收支方向(I 收入、O 支出),startTransAmt、endTransAmt 为金额范围,verifyStatus 为核销状态。
61
45
  */
62
- queryFlowApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/140502002", params)
46
+ queryFlowApi: (params: unknown) => baseHttpClient.post<any>('/TAM/0001/140502002', params)
63
47
  }
@@ -1,3 +1,8 @@
1
+ <script lang="ts">
2
+ // 响应丢失后,重新进入页面提交相同操作时仍复用原流水号。
3
+ const pendingConsumerSeqNos = new Map<string, string>()
4
+ </script>
5
+
1
6
  <script setup lang="ts">
2
7
  import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
3
8
  import { ElConfigProvider, ElMessage, ElMessageBox } from 'element-plus'
@@ -179,6 +184,20 @@ const remainingAmountSort = localSort(
179
184
 
180
185
  // ---------- 提交状态 ----------
181
186
 
187
+ const submitMutation = async <T extends object>(
188
+ action: 'edit' | 'writeOff' | 'cancel',
189
+ send: (params: T & { consumerSeqNo: string }) => Promise<unknown>,
190
+ params: T,
191
+ fallback: string,
192
+ ) => {
193
+ const key = `${action}:${JSON.stringify(params)}`
194
+ const consumerSeqNo = pendingConsumerSeqNos.get(key) ?? crypto.randomUUID()
195
+ pendingConsumerSeqNos.set(key, consumerSeqNo)
196
+
197
+ ensureSuccess(await send({ ...params, consumerSeqNo }), fallback)
198
+ pendingConsumerSeqNos.delete(key)
199
+ }
200
+
182
201
  // 两个表格的勾选行;按预报流水号、流水号过滤出可提交的记录。
183
202
  const predSelection = ref<ForecastRow[]>([])
184
203
  const flowSelection = ref<FlowRow[]>([])
@@ -268,7 +287,8 @@ const submitWriteOff = async () => {
268
287
  }))
269
288
  mutation.value = 'writeOff'
270
289
  try {
271
- ensureSuccess(await API.writeOffApi(tranList.length ? { predList, tranList } : { predList }) as any, '核销提交失败')
290
+ const payload = tranList.length ? { predList, tranList } : { predList }
291
+ await submitMutation('writeOff', API.writeOffApi, payload, '核销提交失败')
272
292
  ElMessage.success('操作成功')
273
293
  writeOffVisible.value = false
274
294
  await refreshBoth()
@@ -333,7 +353,7 @@ const cancelWriteOff = async () => {
333
353
  const payload = predList.length && tranList.length
334
354
  ? { predList, tranList }
335
355
  : predList.length ? { predList } : { tranList }
336
- ensureSuccess(await API.cancelWriteOffApi(payload) as any, '撤销核销提交失败')
356
+ await submitMutation('cancel', API.cancelWriteOffApi, payload, '撤销核销提交失败')
337
357
  ElMessage.success('操作成功')
338
358
  await refreshBoth()
339
359
  } catch (error) {
@@ -579,12 +599,12 @@ const submitEdit = async () => {
579
599
  if (compareAmounts(amount, editForm.value.beforeVerifyAmt) === 0) return void ElMessage.warning('请先调整已核销金额')
580
600
  editRequesting.value = true
581
601
  try {
582
- ensureSuccess(await API.editApi({
602
+ await submitMutation('edit', API.editApi, {
583
603
  predRefNo: editForm.value.predRefNo,
584
604
  predAmt: editForm.value.predAmt,
585
605
  beforeVerifyAmt: editForm.value.beforeVerifyAmt,
586
606
  verifyAmt: amount,
587
- }) as any, '修改提交失败')
607
+ }, '修改提交失败')
588
608
  if (disposed) return
589
609
  ElMessage.success('操作成功')
590
610
  editVisible.value = false