|
|
@@ -0,0 +1,829 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <view class="receipt-form-page">
|
|
|
3
|
+ <u-navbar
|
|
|
4
|
+ placeholder
|
|
|
5
|
+ :autoBack="true"
|
|
|
6
|
+ :title="pageTitle"
|
|
|
7
|
+ @rightClick="submitForm"
|
|
|
8
|
+ >
|
|
|
9
|
+ <view class="u-nav-slot" slot="right"> 保存 </view>
|
|
|
10
|
+ </u-navbar>
|
|
|
11
|
+
|
|
|
12
|
+ <!-- 表单内容 -->
|
|
|
13
|
+ <view class="follow_form_wrap">
|
|
|
14
|
+ <u--form
|
|
|
15
|
+ labelPosition="left"
|
|
|
16
|
+ labelWidth="100"
|
|
|
17
|
+ :model="form"
|
|
|
18
|
+ :rules="rules"
|
|
|
19
|
+ ref="receiptFormRef"
|
|
|
20
|
+ class="form_wrap"
|
|
|
21
|
+ :errorType="'toast'"
|
|
|
22
|
+ >
|
|
|
23
|
+ <u-form-item label="最后修改时间" prop="updateTime" borderBottom>
|
|
|
24
|
+ <u--input
|
|
|
25
|
+ v-model="form.updateTime"
|
|
|
26
|
+ placeholder="最后修改时间"
|
|
|
27
|
+ disabled
|
|
|
28
|
+ ></u--input>
|
|
|
29
|
+ </u-form-item>
|
|
|
30
|
+
|
|
|
31
|
+ <u-form-item label="客服" prop="customerServiceName" borderBottom>
|
|
|
32
|
+ <u--input
|
|
|
33
|
+ v-model="form.customerServiceName"
|
|
|
34
|
+ placeholder="请输入客服姓名"
|
|
|
35
|
+ border="none"
|
|
|
36
|
+ :disabled="!isEdit"
|
|
|
37
|
+ ></u--input>
|
|
|
38
|
+ </u-form-item>
|
|
|
39
|
+
|
|
|
40
|
+ <u-form-item
|
|
|
41
|
+ label="物品名称"
|
|
|
42
|
+ prop="item"
|
|
|
43
|
+ borderBottom
|
|
|
44
|
+ class="form_required"
|
|
|
45
|
+ >
|
|
|
46
|
+ <u--input
|
|
|
47
|
+ v-model="form.item"
|
|
|
48
|
+ placeholder="请输入物品名称"
|
|
|
49
|
+ border="none"
|
|
|
50
|
+ :disabled="!isEdit"
|
|
|
51
|
+ ></u--input>
|
|
|
52
|
+ </u-form-item>
|
|
|
53
|
+
|
|
|
54
|
+ <u-form-item
|
|
|
55
|
+ label="类别"
|
|
|
56
|
+ prop="category"
|
|
|
57
|
+ borderBottom
|
|
|
58
|
+ class="form_required"
|
|
|
59
|
+ >
|
|
|
60
|
+ <ld-select
|
|
|
61
|
+ :list="categoryDict"
|
|
|
62
|
+ label-key="dictLabel"
|
|
|
63
|
+ value-key="dictValue"
|
|
|
64
|
+ placeholder="请选择类别"
|
|
|
65
|
+ v-model="form.category"
|
|
|
66
|
+ :border="false"
|
|
|
67
|
+ ></ld-select>
|
|
|
68
|
+ <u-icon slot="right" name="arrow-right"></u-icon>
|
|
|
69
|
+ </u-form-item>
|
|
|
70
|
+
|
|
|
71
|
+ <u-form-item label="品牌" prop="brand" borderBottom>
|
|
|
72
|
+ <ld-select
|
|
|
73
|
+ :list="brandDict"
|
|
|
74
|
+ label-key="dictLabel"
|
|
|
75
|
+ value-key="dictValue"
|
|
|
76
|
+ placeholder="请选择品牌"
|
|
|
77
|
+ v-model="form.brand"
|
|
|
78
|
+ :border="false"
|
|
|
79
|
+ ></ld-select>
|
|
|
80
|
+ <u-icon slot="right" name="arrow-right"></u-icon>
|
|
|
81
|
+ </u-form-item>
|
|
|
82
|
+
|
|
|
83
|
+ <u-form-item
|
|
|
84
|
+ label="是否需要查码"
|
|
|
85
|
+ prop="needCheckCode"
|
|
|
86
|
+ borderBottom
|
|
|
87
|
+ class="form_required"
|
|
|
88
|
+ >
|
|
|
89
|
+ <u-radio-group
|
|
|
90
|
+ v-model="form.needCheckCode"
|
|
|
91
|
+ :disabled="!isEdit"
|
|
|
92
|
+ @change="(val) => (form.needCheckCode = val)"
|
|
|
93
|
+ >
|
|
|
94
|
+ <u-radio
|
|
|
95
|
+ v-for="item in needCheckCodeOptions"
|
|
|
96
|
+ :key="item.value"
|
|
|
97
|
+ :name="item.value"
|
|
|
98
|
+ :label="item.label"
|
|
|
99
|
+ style="margin-right: 10px"
|
|
|
100
|
+ ></u-radio>
|
|
|
101
|
+ </u-radio-group>
|
|
|
102
|
+ </u-form-item>
|
|
|
103
|
+
|
|
|
104
|
+ <u-form-item label="编码" prop="code" borderBottom>
|
|
|
105
|
+ <u--input
|
|
|
106
|
+ v-model="form.code"
|
|
|
107
|
+ :disabled="form.needCheckCode !== 1 || !isEdit"
|
|
|
108
|
+ placeholder="请输入编码"
|
|
|
109
|
+ ></u--input>
|
|
|
110
|
+ </u-form-item>
|
|
|
111
|
+
|
|
|
112
|
+ <u-form-item label="查码费" prop="checkCodeFee" borderBottom>
|
|
|
113
|
+ <u--input
|
|
|
114
|
+ v-model.number="form.checkCodeFee"
|
|
|
115
|
+ type="number"
|
|
|
116
|
+ placeholder="请输入查码费"
|
|
|
117
|
+ border="none"
|
|
|
118
|
+ :disabled="!isEdit"
|
|
|
119
|
+ ></u--input>
|
|
|
120
|
+ </u-form-item>
|
|
|
121
|
+
|
|
|
122
|
+ <u-form-item label="表款" prop="tableFee" borderBottom>
|
|
|
123
|
+ <u--input
|
|
|
124
|
+ v-model.number="form.tableFee"
|
|
|
125
|
+ type="number"
|
|
|
126
|
+ placeholder="请输入表款"
|
|
|
127
|
+ border="none"
|
|
|
128
|
+ :disabled="!isEdit"
|
|
|
129
|
+ ></u--input>
|
|
|
130
|
+ </u-form-item>
|
|
|
131
|
+
|
|
|
132
|
+ <u-form-item label="好处费" prop="benefitFee" borderBottom>
|
|
|
133
|
+ <u--input
|
|
|
134
|
+ v-model.number="form.benefitFee"
|
|
|
135
|
+ type="number"
|
|
|
136
|
+ placeholder="请输入好处费"
|
|
|
137
|
+ border="none"
|
|
|
138
|
+ :disabled="!isEdit"
|
|
|
139
|
+ ></u--input>
|
|
|
140
|
+ </u-form-item>
|
|
|
141
|
+
|
|
|
142
|
+ <u-form-item label="运费" prop="freight" borderBottom>
|
|
|
143
|
+ <u--input
|
|
|
144
|
+ v-model.number="form.freight"
|
|
|
145
|
+ type="number"
|
|
|
146
|
+ placeholder="请输入运费"
|
|
|
147
|
+ border="none"
|
|
|
148
|
+ :disabled="!isEdit"
|
|
|
149
|
+ ></u--input>
|
|
|
150
|
+ </u-form-item>
|
|
|
151
|
+
|
|
|
152
|
+ <u-form-item label="维修金额" prop="repairAmount" borderBottom>
|
|
|
153
|
+ <u--input
|
|
|
154
|
+ v-model.number="form.repairAmount"
|
|
|
155
|
+ type="number"
|
|
|
156
|
+ placeholder="请输入维修金额"
|
|
|
157
|
+ border="none"
|
|
|
158
|
+ :disabled="!isEdit"
|
|
|
159
|
+ ></u--input>
|
|
|
160
|
+ </u-form-item>
|
|
|
161
|
+
|
|
|
162
|
+ <u-form-item label="成本合计" prop="totalCost" borderBottom>
|
|
|
163
|
+ <u--input
|
|
|
164
|
+ v-model.number="form.totalCost"
|
|
|
165
|
+ type="number"
|
|
|
166
|
+ placeholder="自动计算成本合计"
|
|
|
167
|
+ disabled
|
|
|
168
|
+ ></u--input>
|
|
|
169
|
+ </u-form-item>
|
|
|
170
|
+
|
|
|
171
|
+ <u-form-item label="卖价" prop="sellingPrice" borderBottom>
|
|
|
172
|
+ <u--input
|
|
|
173
|
+ v-model.number="form.sellingPrice"
|
|
|
174
|
+ type="number"
|
|
|
175
|
+ placeholder="请输入卖价"
|
|
|
176
|
+ border="none"
|
|
|
177
|
+ :disabled="!isEdit"
|
|
|
178
|
+ ></u--input>
|
|
|
179
|
+ </u-form-item>
|
|
|
180
|
+
|
|
|
181
|
+ <u-form-item label="业绩" prop="performance" borderBottom>
|
|
|
182
|
+ <u--input
|
|
|
183
|
+ v-model.number="form.performance"
|
|
|
184
|
+ type="number"
|
|
|
185
|
+ placeholder="自动计算业绩"
|
|
|
186
|
+ disabled
|
|
|
187
|
+ ></u--input>
|
|
|
188
|
+ </u-form-item>
|
|
|
189
|
+
|
|
|
190
|
+ <u-form-item label="分单比例" prop="splitRatio" borderBottom>
|
|
|
191
|
+ <u--input
|
|
|
192
|
+ v-model="form.splitRatio"
|
|
|
193
|
+ type="number"
|
|
|
194
|
+ step="0.01"
|
|
|
195
|
+ placeholder="0-100"
|
|
|
196
|
+ :disabled="!isEdit"
|
|
|
197
|
+ @blur="validateSplitRatio"
|
|
|
198
|
+ ></u--input>
|
|
|
199
|
+ </u-form-item>
|
|
|
200
|
+
|
|
|
201
|
+ <u-form-item label="毛业绩" prop="grossPerformance" borderBottom>
|
|
|
202
|
+ <u--input
|
|
|
203
|
+ v-model.number="form.grossPerformance"
|
|
|
204
|
+ type="number"
|
|
|
205
|
+ :placeholder="
|
|
|
206
|
+ canEditGrossPerformance ? '请输入毛业绩' : '自动计算毛业绩'
|
|
|
207
|
+ "
|
|
|
208
|
+ :disabled="!canEditGrossPerformance"
|
|
|
209
|
+ ></u--input>
|
|
|
210
|
+ </u-form-item>
|
|
|
211
|
+
|
|
|
212
|
+ <u-form-item label="开户人姓名" prop="customName" borderBottom>
|
|
|
213
|
+ <u--input
|
|
|
214
|
+ v-model="form.customName"
|
|
|
215
|
+ placeholder="请输入开户人姓名"
|
|
|
216
|
+ border="none"
|
|
|
217
|
+ :disabled="!isEdit"
|
|
|
218
|
+ ></u--input>
|
|
|
219
|
+ </u-form-item>
|
|
|
220
|
+
|
|
|
221
|
+ <u-form-item label="身份证号码" prop="idCard" borderBottom>
|
|
|
222
|
+ <u--input
|
|
|
223
|
+ v-model="form.idCard"
|
|
|
224
|
+ placeholder="请输入客户身份证号码"
|
|
|
225
|
+ border="none"
|
|
|
226
|
+ :disabled="!isEdit"
|
|
|
227
|
+ ></u--input>
|
|
|
228
|
+ </u-form-item>
|
|
|
229
|
+
|
|
|
230
|
+ <u-form-item label="银行卡号" prop="bankCardNumber" borderBottom>
|
|
|
231
|
+ <u--input
|
|
|
232
|
+ v-model="form.bankCardNumber"
|
|
|
233
|
+ placeholder="请输入银行卡号"
|
|
|
234
|
+ border="none"
|
|
|
235
|
+ :disabled="!isEdit"
|
|
|
236
|
+ ></u--input>
|
|
|
237
|
+ </u-form-item>
|
|
|
238
|
+
|
|
|
239
|
+ <u-form-item label="银行名称" prop="bankName" borderBottom>
|
|
|
240
|
+ <u--input
|
|
|
241
|
+ v-model="form.bankName"
|
|
|
242
|
+ placeholder="请输入银行名称"
|
|
|
243
|
+ border="none"
|
|
|
244
|
+ :disabled="!isEdit"
|
|
|
245
|
+ ></u--input>
|
|
|
246
|
+ </u-form-item>
|
|
|
247
|
+
|
|
|
248
|
+ <u-form-item label="快递单号" prop="expressOrderNo" borderBottom>
|
|
|
249
|
+ <u--input
|
|
|
250
|
+ v-model="form.expressOrderNo"
|
|
|
251
|
+ placeholder="请输入快递单号"
|
|
|
252
|
+ border="none"
|
|
|
253
|
+ :disabled="!isEdit"
|
|
|
254
|
+ ></u--input>
|
|
|
255
|
+ </u-form-item>
|
|
|
256
|
+
|
|
|
257
|
+ <u-form-item label="附件" prop="fileIds" borderBottom>
|
|
|
258
|
+ <view class="file-list">
|
|
|
259
|
+ <view
|
|
|
260
|
+ v-for="file in fileOptions"
|
|
|
261
|
+ :key="file.id"
|
|
|
262
|
+ class="file-item"
|
|
|
263
|
+ @click="handleFileSelect(file)"
|
|
|
264
|
+ :class="{
|
|
|
265
|
+ fileSelected: fileIds.includes(file.id.toString()),
|
|
|
266
|
+ fileDisabled:
|
|
|
267
|
+ file.receiptFormId !== null && file.receiptFormId !== form.id,
|
|
|
268
|
+ }"
|
|
|
269
|
+ :disabled="
|
|
|
270
|
+ file.receiptFormId !== null && file.receiptFormId !== form.id
|
|
|
271
|
+ "
|
|
|
272
|
+ >
|
|
|
273
|
+ <view class="file-info">
|
|
|
274
|
+ <text class="file-name">{{ handleShowLabel(file) }}</text>
|
|
|
275
|
+ <text
|
|
|
276
|
+ v-if="
|
|
|
277
|
+ file.receiptFormId !== null &&
|
|
|
278
|
+ file.receiptFormId !== form.id
|
|
|
279
|
+ "
|
|
|
280
|
+ class="file-bound"
|
|
|
281
|
+ >已绑定</text
|
|
|
282
|
+ >
|
|
|
283
|
+ </view>
|
|
|
284
|
+ <u-icon
|
|
|
285
|
+ v-if="fileIds.includes(file.id.toString())"
|
|
|
286
|
+ name="checkmark"
|
|
|
287
|
+ color="#409eff"
|
|
|
288
|
+ size="18"
|
|
|
289
|
+ class="fileSelectedIcon"
|
|
|
290
|
+ ></u-icon>
|
|
|
291
|
+ </view>
|
|
|
292
|
+ </view>
|
|
|
293
|
+ <view v-if="fileOptions.length === 0" class="no-files">
|
|
|
294
|
+ <u-empty mode="data" text="暂无附件"></u-empty>
|
|
|
295
|
+ </view>
|
|
|
296
|
+ </u-form-item>
|
|
|
297
|
+
|
|
|
298
|
+ <u-form-item label="收单备注" prop="receiptRemark" borderBottom>
|
|
|
299
|
+ <u-textarea
|
|
|
300
|
+ confirmType="done"
|
|
|
301
|
+ v-model="form.receiptRemark"
|
|
|
302
|
+ placeholder="请输入收单备注"
|
|
|
303
|
+ :disabled="!isEdit"
|
|
|
304
|
+ auto-height
|
|
|
305
|
+ ></u-textarea>
|
|
|
306
|
+ </u-form-item>
|
|
|
307
|
+ </u--form>
|
|
|
308
|
+ </view>
|
|
|
309
|
+ </view>
|
|
|
310
|
+</template>
|
|
|
311
|
+
|
|
|
312
|
+<script>
|
|
|
313
|
+import { cloneDeep } from "lodash";
|
|
|
314
|
+import ldSelect from "@/components/ld-select/ld-select.vue";
|
|
|
315
|
+
|
|
|
316
|
+export default {
|
|
|
317
|
+ name: "ReceiptForm",
|
|
|
318
|
+ components: {
|
|
|
319
|
+ ldSelect,
|
|
|
320
|
+ },
|
|
|
321
|
+ data() {
|
|
|
322
|
+ return {
|
|
|
323
|
+ loading: false,
|
|
|
324
|
+ form: {
|
|
|
325
|
+ id: undefined,
|
|
|
326
|
+ sendFormId: '',
|
|
|
327
|
+ clueId: '',
|
|
|
328
|
+ item: '',
|
|
|
329
|
+ brand: '',
|
|
|
330
|
+ needCheckCode: 1,
|
|
|
331
|
+ code: '',
|
|
|
332
|
+ tableFee: 0,
|
|
|
333
|
+ benefitFee: 0,
|
|
|
334
|
+ freight: 0,
|
|
|
335
|
+ checkCodeFee: 0,
|
|
|
336
|
+ totalCost: 0,
|
|
|
337
|
+ sellingPrice: 0,
|
|
|
338
|
+ performance: 0,
|
|
|
339
|
+ receiptRemark: '',
|
|
|
340
|
+ repairAmount: 0,
|
|
|
341
|
+ grossPerformance: 0,
|
|
|
342
|
+ expressOrderNo: '',
|
|
|
343
|
+ fileIds: '',
|
|
|
344
|
+ category: '',
|
|
|
345
|
+ customName: '',
|
|
|
346
|
+ idCard: '',
|
|
|
347
|
+ bankCardNumber: '',
|
|
|
348
|
+ bankName: '',
|
|
|
349
|
+ customerServiceName: '',
|
|
|
350
|
+ updateTime: '',
|
|
|
351
|
+ splitRatio: 0
|
|
|
352
|
+ },
|
|
|
353
|
+ fileOptions: [],
|
|
|
354
|
+ orderId: "",
|
|
|
355
|
+ clueId: "",
|
|
|
356
|
+ receiptId: "",
|
|
|
357
|
+ receiptDetail: {},
|
|
|
358
|
+ needCheckCodeOptions: [
|
|
|
359
|
+ { label: "是", value: 1 },
|
|
|
360
|
+ { label: "否", value: 2 },
|
|
|
361
|
+ ],
|
|
|
362
|
+ categoryDict: [],
|
|
|
363
|
+ brandDict: [],
|
|
|
364
|
+ labelStyle: {
|
|
|
365
|
+ fontSize: "28rpx",
|
|
|
366
|
+ color: "#606266",
|
|
|
367
|
+ },
|
|
|
368
|
+ // 表单验证规则
|
|
|
369
|
+ rules: {
|
|
|
370
|
+ item: [{ required: true, message: "请输入物品名称", trigger: "blur" }],
|
|
|
371
|
+ category: [
|
|
|
372
|
+ { required: true, message: "请选择类别", trigger: "change" },
|
|
|
373
|
+ ],
|
|
|
374
|
+ needCheckCode: [
|
|
|
375
|
+ {
|
|
|
376
|
+ validator: (rule, value, callback) => {
|
|
|
377
|
+ if (!value) {
|
|
|
378
|
+ callback(new Error("请选择是否查码"));
|
|
|
379
|
+ } else {
|
|
|
380
|
+ callback();
|
|
|
381
|
+ }
|
|
|
382
|
+ },
|
|
|
383
|
+ trigger: "blur",
|
|
|
384
|
+ },
|
|
|
385
|
+ ],
|
|
|
386
|
+ brand: [
|
|
|
387
|
+ {
|
|
|
388
|
+ required: true,
|
|
|
389
|
+ message: "请选择品牌",
|
|
|
390
|
+ trigger: ["blur", "change"]
|
|
|
391
|
+ }
|
|
|
392
|
+ ],
|
|
|
393
|
+ code: [
|
|
|
394
|
+ {
|
|
|
395
|
+ validator: (rule, value, callback) => {
|
|
|
396
|
+ if (this.form.needCheckCode === 1 && !value) {
|
|
|
397
|
+ callback(new Error("编码不能为空"));
|
|
|
398
|
+ } else {
|
|
|
399
|
+ callback();
|
|
|
400
|
+ }
|
|
|
401
|
+ },
|
|
|
402
|
+ trigger: "blur",
|
|
|
403
|
+ },
|
|
|
404
|
+ ],
|
|
|
405
|
+ },
|
|
|
406
|
+ };
|
|
|
407
|
+ },
|
|
|
408
|
+ computed: {
|
|
|
409
|
+ pageTitle() {
|
|
|
410
|
+ return this.form.id ? "编辑收单" : "新增收单";
|
|
|
411
|
+ },
|
|
|
412
|
+ fileIds: {
|
|
|
413
|
+ get() {
|
|
|
414
|
+ if (this.form.fileIds) {
|
|
|
415
|
+ return this.form.fileIds.split(",").filter((id) => id);
|
|
|
416
|
+ } else {
|
|
|
417
|
+ return [];
|
|
|
418
|
+ }
|
|
|
419
|
+ },
|
|
|
420
|
+ set(value) {
|
|
|
421
|
+ this.form.fileIds = value.join(",");
|
|
|
422
|
+ },
|
|
|
423
|
+ },
|
|
|
424
|
+ isEdit() {
|
|
|
425
|
+ return true;
|
|
|
426
|
+ },
|
|
|
427
|
+ // 判断是否显示保存按钮:status=2时,只有接单人本人可以编辑
|
|
|
428
|
+ canShowSaveButton() {
|
|
|
429
|
+ if (!this.receiptDetail.status) return true;
|
|
|
430
|
+ const { status, identification } = this.receiptDetail;
|
|
|
431
|
+ const currentUserId = this.$store.state.user.userId;
|
|
|
432
|
+
|
|
|
433
|
+ // 如果status不是"2",显示保存按钮
|
|
|
434
|
+ if (status !== "2") {
|
|
|
435
|
+ return true;
|
|
|
436
|
+ }
|
|
|
437
|
+
|
|
|
438
|
+ // 如果status是"2",只有接单人本人可以看到保存按钮
|
|
|
439
|
+ return String(identification) === String(currentUserId);
|
|
|
440
|
+ },
|
|
|
441
|
+ // 自动计算成本合计 = 表款 + 好处费 + 运费 + 查码费 + 维修金额
|
|
|
442
|
+ calculatedTotalCost() {
|
|
|
443
|
+ const { tableFee, benefitFee, freight, checkCodeFee, repairAmount } =
|
|
|
444
|
+ this.form;
|
|
|
445
|
+ return (
|
|
|
446
|
+ (tableFee || 0) +
|
|
|
447
|
+ (benefitFee || 0) +
|
|
|
448
|
+ (freight || 0) +
|
|
|
449
|
+ (checkCodeFee || 0) +
|
|
|
450
|
+ (repairAmount || 0)
|
|
|
451
|
+ );
|
|
|
452
|
+ },
|
|
|
453
|
+ // 自动计算业绩 = 卖价 - 成本合计
|
|
|
454
|
+ // 卖价为空时不计算,避免出现负数业绩
|
|
|
455
|
+ calculatedPerformance() {
|
|
|
456
|
+ const { sellingPrice } = this.form;
|
|
|
457
|
+ // 卖价为空或为0时,不计算业绩
|
|
|
458
|
+ if (!sellingPrice || sellingPrice <= 0) {
|
|
|
459
|
+ return null;
|
|
|
460
|
+ }
|
|
|
461
|
+ return sellingPrice - this.calculatedTotalCost;
|
|
|
462
|
+ },
|
|
|
463
|
+ // 自动计算毛业绩 = 业绩 × 分单比例(仅当两者都不为空时)
|
|
|
464
|
+ // 智能判断:<=1直接乘,>1先除以100再乘
|
|
|
465
|
+ // 四舍五入保留两位小数
|
|
|
466
|
+ calculatedGrossPerformance() {
|
|
|
467
|
+ const { splitRatio } = this.form;
|
|
|
468
|
+ if (
|
|
|
469
|
+ this.calculatedPerformance &&
|
|
|
470
|
+ splitRatio !== null &&
|
|
|
471
|
+ splitRatio !== undefined &&
|
|
|
472
|
+ splitRatio !== ""
|
|
|
473
|
+ ) {
|
|
|
474
|
+ // 智能判断:<=1直接乘,>1先除以100再乘
|
|
|
475
|
+ const ratio = splitRatio <= 1 ? splitRatio : splitRatio / 100;
|
|
|
476
|
+ const result = this.calculatedPerformance * ratio;
|
|
|
477
|
+ // 四舍五入保留两位小数
|
|
|
478
|
+ return Math.round(result * 100) / 100;
|
|
|
479
|
+ }
|
|
|
480
|
+ return null;
|
|
|
481
|
+ },
|
|
|
482
|
+ // 毛业绩是否可编辑:业绩不为空 且 比例为空
|
|
|
483
|
+ canEditGrossPerformance() {
|
|
|
484
|
+ return (
|
|
|
485
|
+ this.calculatedPerformance &&
|
|
|
486
|
+ !this.form.splitRatio &&
|
|
|
487
|
+ this.form.splitRatio !== 0 &&
|
|
|
488
|
+ this.isEdit
|
|
|
489
|
+ );
|
|
|
490
|
+ },
|
|
|
491
|
+ },
|
|
|
492
|
+ watch: {
|
|
|
493
|
+ // 监听成本合计变化,自动更新form
|
|
|
494
|
+ calculatedTotalCost(val) {
|
|
|
495
|
+ this.form.totalCost = val;
|
|
|
496
|
+ },
|
|
|
497
|
+ // 监听业绩业绩变化,自动更新form
|
|
|
498
|
+ calculatedPerformance(val) {
|
|
|
499
|
+ this.form.performance = val;
|
|
|
500
|
+ },
|
|
|
501
|
+ // 监听毛业绩变化,仅当比例不为空时自动更新form
|
|
|
502
|
+ calculatedGrossPerformance(val) {
|
|
|
503
|
+ if (
|
|
|
504
|
+ this.form.splitRatio !== null &&
|
|
|
505
|
+ this.form.splitRatio !== undefined &&
|
|
|
506
|
+ this.form.splitRatio !== "" &&
|
|
|
507
|
+ val !== null
|
|
|
508
|
+ ) {
|
|
|
509
|
+ this.form.grossPerformance = val;
|
|
|
510
|
+ }
|
|
|
511
|
+ },
|
|
|
512
|
+ },
|
|
|
513
|
+ onLoad(options) {
|
|
|
514
|
+ // 从路由参数获取orderId和clueId
|
|
|
515
|
+ this.orderId = options.orderId;
|
|
|
516
|
+ this.clueId = options.clueId;
|
|
|
517
|
+ this.receiptId = options.receiptId;
|
|
|
518
|
+ this.getDicts().then(() => {
|
|
|
519
|
+ this.initForm();
|
|
|
520
|
+ });
|
|
|
521
|
+ },
|
|
|
522
|
+ methods: {
|
|
|
523
|
+ // 获取字典数据
|
|
|
524
|
+ async getDicts() {
|
|
|
525
|
+ try {
|
|
|
526
|
+ const [categoryRes, brandRes] = await Promise.all([
|
|
|
527
|
+ this.$getDicts("crm_form_category"),
|
|
|
528
|
+ this.$getDicts("crm_form_brand")
|
|
|
529
|
+ ]);
|
|
|
530
|
+ this.categoryDict = categoryRes;
|
|
|
531
|
+ this.brandDict = brandRes;
|
|
|
532
|
+ } catch (error) {
|
|
|
533
|
+ console.error("获取字典数据失败:", error);
|
|
|
534
|
+ }
|
|
|
535
|
+ },
|
|
|
536
|
+ handleBack() {
|
|
|
537
|
+ uni.navigateBack();
|
|
|
538
|
+ },
|
|
|
539
|
+ /** 表单重置 */
|
|
|
540
|
+ reset() {
|
|
|
541
|
+ const form = Object.assign({
|
|
|
542
|
+ id: undefined,
|
|
|
543
|
+ sendFormId: this.orderId,
|
|
|
544
|
+ clueId: this.clueId,
|
|
|
545
|
+ item: undefined,
|
|
|
546
|
+ brand: undefined,
|
|
|
547
|
+ needCheckCode: 1,
|
|
|
548
|
+ code: undefined,
|
|
|
549
|
+ tableFee: undefined,
|
|
|
550
|
+ benefitFee: undefined,
|
|
|
551
|
+ freight: undefined,
|
|
|
552
|
+ checkCodeFee: undefined,
|
|
|
553
|
+ totalCost: undefined,
|
|
|
554
|
+ sellingPrice: undefined,
|
|
|
555
|
+ performance: undefined,
|
|
|
556
|
+ receiptRemark: undefined,
|
|
|
557
|
+ repairAmount: undefined,
|
|
|
558
|
+ grossPerformance: undefined,
|
|
|
559
|
+ expressOrderNo: undefined,
|
|
|
560
|
+ fileIds: "",
|
|
|
561
|
+ category: undefined,
|
|
|
562
|
+ customName: undefined,
|
|
|
563
|
+ idCard: undefined,
|
|
|
564
|
+ bankCardNumber: undefined,
|
|
|
565
|
+ bankName: undefined,
|
|
|
566
|
+ customerServiceName: undefined,
|
|
|
567
|
+ updateTime: undefined,
|
|
|
568
|
+ splitRatio: undefined,
|
|
|
569
|
+ });
|
|
|
570
|
+ // 从订单详情预填充字段
|
|
|
571
|
+ if (this.receiptDetail) {
|
|
|
572
|
+ form.status = this.receiptDetail.status;
|
|
|
573
|
+ form.identification = this.receiptDetail.identification;
|
|
|
574
|
+ form.item = this.receiptDetail.item;
|
|
|
575
|
+ form.category = this.receiptDetail.category;
|
|
|
576
|
+ form.brand = this.receiptDetail.brand;
|
|
|
577
|
+ }
|
|
|
578
|
+ this.form = form;
|
|
|
579
|
+ },
|
|
|
580
|
+ handleShowLabel(file) {
|
|
|
581
|
+ // 获取文件在fileIds数组中的索引,如果存在则显示序号
|
|
|
582
|
+ const index = this.fileIds.indexOf(file.id.toString());
|
|
|
583
|
+ let label = "";
|
|
|
584
|
+ if (index !== -1) {
|
|
|
585
|
+ label = `[${index + 1}] `;
|
|
|
586
|
+ }
|
|
|
587
|
+ label += file.fileName;
|
|
|
588
|
+ if (file.remark) {
|
|
|
589
|
+ label += `(${file.remark})`;
|
|
|
590
|
+ }
|
|
|
591
|
+ // 如果文件已绑定到其他收单,显示绑定信息
|
|
|
592
|
+ if (file.receiptFormId !== null && file.receiptFormId !== this.form.id) {
|
|
|
593
|
+ label += ` - 已绑定${file.item || ""}`;
|
|
|
594
|
+ }
|
|
|
595
|
+ return label;
|
|
|
596
|
+ },
|
|
|
597
|
+ initForm() {
|
|
|
598
|
+ // 获取订单详情数据
|
|
|
599
|
+ uni.$u.api
|
|
|
600
|
+ .getClueSendFormVoByOrderId({
|
|
|
601
|
+ id: this.orderId,
|
|
|
602
|
+ })
|
|
|
603
|
+ .then((res) => {
|
|
|
604
|
+ this.receiptDetail = res.data;
|
|
|
605
|
+
|
|
|
606
|
+ // 如果有receiptId,说明是编辑模式,获取收单详情
|
|
|
607
|
+ if (this.receiptId) {
|
|
|
608
|
+ return uni.$u.api
|
|
|
609
|
+ .getReceiptForm(this.receiptId)
|
|
|
610
|
+ .then((receiptRes) => {
|
|
|
611
|
+ this.form = receiptRes.data;
|
|
|
612
|
+ // 在数据初始化完成后获取附件列表
|
|
|
613
|
+ this.fetchFileOptions();
|
|
|
614
|
+ });
|
|
|
615
|
+ } else {
|
|
|
616
|
+ // 新增模式:初始化表单数据(需要receiptDetail数据才能预填充字段)
|
|
|
617
|
+ this.reset();
|
|
|
618
|
+ // 在数据初始化完成后获取附件列表
|
|
|
619
|
+ this.fetchFileOptions();
|
|
|
620
|
+ }
|
|
|
621
|
+ })
|
|
|
622
|
+ .catch((error) => {
|
|
|
623
|
+ console.error("初始化表单失败:", error);
|
|
|
624
|
+ uni.$u.toast("初始化表单失败");
|
|
|
625
|
+ });
|
|
|
626
|
+ },
|
|
|
627
|
+ // 获取附件选项列表
|
|
|
628
|
+ async fetchFileOptions() {
|
|
|
629
|
+ try {
|
|
|
630
|
+ const params = {
|
|
|
631
|
+ clueId: this.receiptDetail.clueId,
|
|
|
632
|
+ sourceId: this.receiptDetail.sendFormId,
|
|
|
633
|
+ notBound: "1",
|
|
|
634
|
+ orderFileType: "3",
|
|
|
635
|
+ type: "2",
|
|
|
636
|
+ };
|
|
|
637
|
+ const { rows } = await uni.$u.api.selectClueFileByDto(params);
|
|
|
638
|
+ this.fileOptions = rows || [];
|
|
|
639
|
+ } catch (error) {
|
|
|
640
|
+ console.error("获取附件列表失败:", error);
|
|
|
641
|
+ uni.$u.toast("获取附件列表失败");
|
|
|
642
|
+ }
|
|
|
643
|
+ },
|
|
|
644
|
+ // 文件选择
|
|
|
645
|
+ handleFileSelect(file) {
|
|
|
646
|
+ if (!this.isEdit) return;
|
|
|
647
|
+
|
|
|
648
|
+ const fileId = file.id.toString();
|
|
|
649
|
+ const index = this.fileIds.indexOf(fileId);
|
|
|
650
|
+ const newFileIds = [...this.fileIds]; // 创建数组副本
|
|
|
651
|
+
|
|
|
652
|
+ if (index > -1) {
|
|
|
653
|
+ // 已选中,取消选择
|
|
|
654
|
+ newFileIds.splice(index, 1);
|
|
|
655
|
+ } else {
|
|
|
656
|
+ // 未选中,添加选择
|
|
|
657
|
+ newFileIds.push(fileId);
|
|
|
658
|
+ }
|
|
|
659
|
+
|
|
|
660
|
+ // 重新赋值,触发set方法
|
|
|
661
|
+ this.fileIds = newFileIds;
|
|
|
662
|
+ },
|
|
|
663
|
+ // 分单比例验证:非空时范围必须在0-100之间
|
|
|
664
|
+ validateSplitRatio() {
|
|
|
665
|
+ const { splitRatio } = this.form;
|
|
|
666
|
+ if (
|
|
|
667
|
+ splitRatio === null ||
|
|
|
668
|
+ splitRatio === undefined ||
|
|
|
669
|
+ splitRatio === ""
|
|
|
670
|
+ ) {
|
|
|
671
|
+ return; // 允许为空
|
|
|
672
|
+ }
|
|
|
673
|
+ const ratio = Number(splitRatio);
|
|
|
674
|
+ // 范围验证:0-100
|
|
|
675
|
+ if (ratio < 0) {
|
|
|
676
|
+ uni.$u.toast("分单比例不能小于0");
|
|
|
677
|
+ this.form.splitRatio = 0;
|
|
|
678
|
+ } else if (ratio > 100) {
|
|
|
679
|
+ uni.$u.toast("分单比例不能大于100");
|
|
|
680
|
+ this.form.splitRatio = 100;
|
|
|
681
|
+ }
|
|
|
682
|
+ },
|
|
|
683
|
+ // 提交表单
|
|
|
684
|
+ submitForm() {
|
|
|
685
|
+ this.$refs.receiptFormRef.validate().then(async (valid) => {
|
|
|
686
|
+ console.log(valid);
|
|
|
687
|
+ if (valid) {
|
|
|
688
|
+ await this.handleUpdate();
|
|
|
689
|
+ } else {
|
|
|
690
|
+ uni.$u.toast("请检查表单填写是否正确");
|
|
|
691
|
+ }
|
|
|
692
|
+ });
|
|
|
693
|
+ },
|
|
|
694
|
+ // 更新表单
|
|
|
695
|
+ async handleUpdate() {
|
|
|
696
|
+ try {
|
|
|
697
|
+ this.loading = true;
|
|
|
698
|
+
|
|
|
699
|
+ // 准备提交数据
|
|
|
700
|
+ const submitData = {
|
|
|
701
|
+ ...this.form,
|
|
|
702
|
+ sendFormId: this.orderId,
|
|
|
703
|
+ clueId: this.clueId,
|
|
|
704
|
+ };
|
|
|
705
|
+
|
|
|
706
|
+ // 根据是否有id判断是新增还是修改
|
|
|
707
|
+ if (this.form.id) {
|
|
|
708
|
+ // 修改
|
|
|
709
|
+ await uni.$u.api.updateReceiptForm(submitData);
|
|
|
710
|
+ uni.$u.toast("修改成功");
|
|
|
711
|
+ } else {
|
|
|
712
|
+ // 新增
|
|
|
713
|
+ await uni.$u.api.addReceiptForm(submitData);
|
|
|
714
|
+ uni.$u.toast("新增成功");
|
|
|
715
|
+ }
|
|
|
716
|
+
|
|
|
717
|
+ // 延迟返回上一页
|
|
|
718
|
+ setTimeout(() => {
|
|
|
719
|
+ uni.navigateBack();
|
|
|
720
|
+ }, 1500);
|
|
|
721
|
+ } catch (error) {
|
|
|
722
|
+ console.error("保存失败:", error);
|
|
|
723
|
+ uni.$u.toast("保存失败,请重试");
|
|
|
724
|
+ } finally {
|
|
|
725
|
+ this.loading = false;
|
|
|
726
|
+ }
|
|
|
727
|
+ },
|
|
|
728
|
+ },
|
|
|
729
|
+};
|
|
|
730
|
+</script>
|
|
|
731
|
+
|
|
|
732
|
+<style lang="scss">
|
|
|
733
|
+.receipt-form-page {
|
|
|
734
|
+ background-color: #fff;
|
|
|
735
|
+}
|
|
|
736
|
+@import "@/static/follow/index.scss";
|
|
|
737
|
+
|
|
|
738
|
+// 附件列表样式优化
|
|
|
739
|
+.file-list {
|
|
|
740
|
+ display: flex;
|
|
|
741
|
+ flex-direction: column;
|
|
|
742
|
+ gap: 16rpx;
|
|
|
743
|
+ padding: 10rpx 0;
|
|
|
744
|
+}
|
|
|
745
|
+
|
|
|
746
|
+.file-item {
|
|
|
747
|
+ display: flex;
|
|
|
748
|
+ align-items: center;
|
|
|
749
|
+ justify-content: space-between;
|
|
|
750
|
+ padding: 24rpx 30rpx;
|
|
|
751
|
+ background-color: #f8f9fa;
|
|
|
752
|
+ border-radius: 12rpx;
|
|
|
753
|
+ border: 2rpx solid transparent;
|
|
|
754
|
+ transition: all 0.3s ease;
|
|
|
755
|
+ position: relative;
|
|
|
756
|
+ cursor: pointer;
|
|
|
757
|
+
|
|
|
758
|
+ &:active {
|
|
|
759
|
+ background-color: #e9ecef;
|
|
|
760
|
+ transform: scale(0.98);
|
|
|
761
|
+ }
|
|
|
762
|
+
|
|
|
763
|
+ // 选中状态样式
|
|
|
764
|
+ &.fileSelected {
|
|
|
765
|
+ background-color: #e6f4ff;
|
|
|
766
|
+ border-color: #409eff;
|
|
|
767
|
+ box-shadow: 0 4rpx 12rpx rgba(64, 158, 255, 0.2);
|
|
|
768
|
+ }
|
|
|
769
|
+
|
|
|
770
|
+ // 禁用状态样式
|
|
|
771
|
+ &.fileDisabled {
|
|
|
772
|
+ background-color: #f5f5f5;
|
|
|
773
|
+ opacity: 0.6;
|
|
|
774
|
+ cursor: not-allowed;
|
|
|
775
|
+
|
|
|
776
|
+ &:active {
|
|
|
777
|
+ transform: none;
|
|
|
778
|
+ background-color: #f5f5f5;
|
|
|
779
|
+ }
|
|
|
780
|
+ }
|
|
|
781
|
+
|
|
|
782
|
+ .file-info {
|
|
|
783
|
+ flex: 1;
|
|
|
784
|
+ display: flex;
|
|
|
785
|
+ align-items: center;
|
|
|
786
|
+ gap: 16rpx;
|
|
|
787
|
+
|
|
|
788
|
+ .file-name {
|
|
|
789
|
+ font-size: 28rpx;
|
|
|
790
|
+ color: #303133;
|
|
|
791
|
+ line-height: 40rpx;
|
|
|
792
|
+ word-break: break-all;
|
|
|
793
|
+ }
|
|
|
794
|
+
|
|
|
795
|
+ .file-bound {
|
|
|
796
|
+ font-size: 24rpx;
|
|
|
797
|
+ color: #909399;
|
|
|
798
|
+ background-color: #f5f7fa;
|
|
|
799
|
+ padding: 2rpx 16rpx;
|
|
|
800
|
+ border-radius: 16rpx;
|
|
|
801
|
+ }
|
|
|
802
|
+ }
|
|
|
803
|
+
|
|
|
804
|
+ .u-icon {
|
|
|
805
|
+ // 为选中图标添加动画效果
|
|
|
806
|
+ &.fileSelectedIcon {
|
|
|
807
|
+ animation: fadeInScale 0.3s ease;
|
|
|
808
|
+ }
|
|
|
809
|
+ }
|
|
|
810
|
+}
|
|
|
811
|
+
|
|
|
812
|
+// 动画效果
|
|
|
813
|
+@keyframes fadeInScale {
|
|
|
814
|
+ 0% {
|
|
|
815
|
+ opacity: 0;
|
|
|
816
|
+ transform: scale(0.5);
|
|
|
817
|
+ }
|
|
|
818
|
+ 100% {
|
|
|
819
|
+ opacity: 1;
|
|
|
820
|
+ transform: scale(1);
|
|
|
821
|
+ }
|
|
|
822
|
+}
|
|
|
823
|
+
|
|
|
824
|
+// 无附件时的样式
|
|
|
825
|
+.no-files {
|
|
|
826
|
+ padding: 60rpx 0;
|
|
|
827
|
+ text-align: center;
|
|
|
828
|
+}
|
|
|
829
|
+</style>
|