index.vue
38.2 KB
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
<template>
<div class="order-page">
<BasicTable @register="registerTable" bordered>
<template #headerCell="{ column }">
<!-- <template v-if="column.key === 'address1'">
<span class="flex items-center justify-center"> 自定义字段列11 </span>
</template> -->
<template v-if="SELECT_FIELD_COLUMNS.includes(column.key) && role === ROLE.ADMIN">
<span class="flex items-center justify-center">
{{ column.customTitle }}
<FormOutlined class="ml-2 cursor-pointer" @click="handleFieldVisible(column)" />
</span>
</template>
<template v-else>
<HeaderCell :column="column" />
</template>
</template>
<template #headerTop>
<a-alert type="info" show-icon>
<template #message>
<template v-if="checkedKeys.length > 0">
<span>已选中{{ checkedKeys.length }}条记录(可跨页)</span>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="link"
@click="checkedKeys = []"
size="small"
>清空</a-button
>
</template>
<template v-else>
<span>未选中任何订单</span>
</template>
</template>
</a-alert>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="
role !== ROLE.PRODUCE
? [
{
// 数据分析没有编辑权限
...(role !== ROLE.DATA_REPORT_USER && {
label: '编辑',
// icon: 'ic:outline-delete-outline',
onClick: handleEdit.bind(null, record),
}),
},
{
...(role !== ROLE.DATA_REPORT_USER && {
label: '申请权限',
// icon: 'ic:outline-delete-outline',
onClick: handleCheck.bind(null, record),
}),
},
// {
// ...(role !== ROLE.DATA_REPORT_USER && {
// label: '申请',
// // icon: 'ic:outline-delete-outline',
// onClick: handleCheck.bind(null, record),
// }),
// },
]
: []
"
:dropDownActions="
role !== ROLE.DATA_REPORT_USER && role !== ROLE.PRODUCE
? [
{
label: '历史记录',
onClick: handleHistory.bind(null, record),
},
{
label: '跟单结果记录',
onClick: handleTrackHistory.bind(null, record),
},
{
// 数据分析没有编辑权限
...((role === ROLE.ADMIN || role === ROLE.TRACKER) && {
label: '复制',
// icon: 'ic:outline-delete-outline',
onClick: handleCopy.bind(null, record),
}),
},
{
...(role === ROLE.ADMIN && {
label: '删除',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record?.id),
},
}),
},
]
: []
"
/>
</template>
<template v-if="column.key === 'picUrl'">
<img
:width="100"
:height="100"
:src="record.smallPicUrl"
:key="record.smallPicUrl"
@click="handlePreview(record.picUrl)"
/>
</template>
</template>
<template #toolbar>
<div style="width: 1050px; padding-left: 50px">
<!-- <a-space wrap :size="[8, 16]" :style="{ marginBottom: '2px', marginLeft: '10px' }"> -->
<a-space wrap :style="{ marginBottom: '2px', marginTop: '2px' }">
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleProductInvoiceModal"
v-if="role === ROLE.ADMIN || role === ROLE.BUSINESS || role === ROLE.TRACKER"
>生产对账单创建</a-button
>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
shape="default"
type="primary"
@click="handleInvoiceCreateModal"
v-if="role === ROLE.ADMIN || role === ROLE.BUSINESS || role === ROLE.TRACKER"
>Invoice创建</a-button
>
<a-select
ref="select"
v-model:value="value1"
@change="handleChange"
class="passCalculate"
dropdown-class-name="dropdown-class"
v-if="role === ROLE.ADMIN || role === ROLE.TRACKER || role === ROLE.BUSINESS"
>
<a-select-option value1="一次通过率">一次通过率</a-select-option>
<a-select-option value="确认样品" @click="handlePassModal('确认意见')"
>确认样品</a-select-option
>
<a-select-option value="生产样品" @click="handlePassModal('生产样品')"
>生产样品</a-select-option
>
<a-select-option value="测试样品" @click="handlePassModal('测试样品')"
>测试样品</a-select-option
>
</a-select>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleProductProfitModal"
>内部生产净利润分析</a-button
>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleServiceProfitModal"
>业务/研发净利润分析</a-button
>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleProductModal"
v-if="role === ROLE.ADMIN || role === ROLE.TRACKER"
>生产指标书</a-button
>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleRateModal"
v-if="role === ROLE.ADMIN"
>比重计算</a-button
>
<!-- 质检角色不能导出任何信息 -->
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleExportModal"
v-if="role === ROLE.ADMIN || role === ROLE.TRACKER || role === ROLE.BUSINESS"
>导出</a-button
>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleProfitModal"
v-if="role === ROLE.ADMIN || role === ROLE.BUSINESS"
>分析利润</a-button
>
<a-button
:style="{ borderRadius: '5px 5px 5px 5px' }"
type="primary"
@click="handleAdd"
v-if="role === ROLE.ADMIN || role === ROLE.TRACKER"
>创建订单</a-button
></a-space
>
</div>
</template>
</BasicTable>
<FormDetail
@register="formDetailRegister"
:onGoCheckDetail="handleGoCheckDetail"
@success="handleFormSuccess"
/>
<ProductText
@register="productModalRegister"
:role="role"
:customerCodes="selectedCustomCodes"
/>
<InvoiceCreate @register="invoiceCreateModalRegister" />
<ServiceProfit @register="serviceProfitModalRegister" />
<ProductProfit @register="productProfitModalRegister" />
<ProductInvoice @register="productInvoiceModalRegister" />
<ProfitAnalysis @register="profitModalRegister" />
<RateModal @register="rateModalRegister" />
<ExportModal @register="exportModalRegister" :role="role" :ids="checkedKeys" />
<CheckDetail @register="checkModalRegister" :onGoFormDetail="handleGoFormDetail" />
<HistoryDetail @register="historyDetailRegister" />
<TrackHistory @register="trackHistoryRegister" />
<FieldDetail @register="fieldDetailRegister" />
<PassCalculate @register="passModalRegister" />
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref, toRaw, computed } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { FormOutlined } from '@ant-design/icons-vue';
import HeaderCell from '/@/components/Table/src/components/HeaderCell.vue';
import { Alert } from 'ant-design-vue';
import { useDrawer } from '/@/components/Drawer';
import ProfitAnalysis from './ProfitAnalysis.vue';
import ProductText from './ProductText.vue';
import RateModal from './RateModal.vue';
import ExportModal from './ExportModal.vue';
import PassCalculate from './PassCalculate.vue';
import InvoiceCreate from './InvoiceCreate.vue';
import ServiceProfit from './ServiceProfit.vue';
import ProductProfit from './ProductProfit.vue';
import ProductInvoice from './ProductInvoice.vue';
import { useModal } from '/@/components/Modal';
import { getFormConfig, getOrderColumns, SELECT_FIELD_COLUMNS } from './tableData';
import FormDetail from './FormDetail/index.vue';
import CheckDetail from './CheckDetail.vue';
import HistoryDetail from './HistoryDetail.vue';
import TrackHistory from './TrackHistory.vue';
import FieldDetail from './FieldDetail.vue';
import { createImgPreview } from '/@/components/Preview/index';
import { getOrderList, orderDelete } from '/@/api/project/order';
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { useUserStoreWithOut } from '/@/store/modules/user';
import { ROLE } from './type.d';
import { getUserList } from '/@/api/project/account';
import { useMessage } from '/@/hooks/web/useMessage';
import { getBaseInvoice } from '/@/api/project/invoice';
const orderStore = useOrderStoreWithOut();
const userStore = useUserStoreWithOut();
export default defineComponent({
components: {
HeaderCell,
BasicTable,
AAlert: Alert,
TableAction,
FormDetail,
ProfitAnalysis,
ProductText,
PassCalculate,
FormOutlined,
CheckDetail,
HistoryDetail,
TrackHistory,
FieldDetail,
RateModal,
InvoiceCreate,
ServiceProfit,
ProductInvoice,
ProductProfit,
ExportModal,
},
setup() {
const checkedKeys = ref<Array<string | number>>([]);
// const selectedCustomCodes = ref<Array<string>>([]);
const [profitModalRegister, { openModal: openProfitModal }] = useModal();
const [invoiceCreateModalRegister, { openModal: openInvoiceCreateModal }] = useModal();
const [serviceProfitModalRegister, { openModal: openServiceProfitModal }] = useModal();
const [productProfitModalRegister, { openModal: openProductProfitModal }] = useModal();
const [productInvoiceModalRegister, { openModal: openProductInvoiceModal }] = useModal();
const [rateModalRegister, { openModal: openRateModal }] = useModal();
const [exportModalRegister, { openModal: openExportModal }] = useModal();
const [productModalRegister, { openModal: openProductModal }] = useModal();
const [passModalRegister, { openModal: openPassModal }] = useModal();
const tooltipVisible = ref(false);
const [formDetailRegister, { openDrawer: openFormDetailDrawer }] = useDrawer();
const [historyDetailRegister, { openDrawer: openHistoryDetailDrawer }] = useDrawer();
const [trackHistoryRegister, { openDrawer: openTrackHistoryDrawer }] = useDrawer();
const [fieldDetailRegister, { openDrawer: openFieldDetailDrawer }] = useDrawer();
const user = userStore.getUserInfo;
const role = computed(() => {
return user?.roleSmallVO?.code;
});
// 业务员列表
const businessUsers = ref([]);
const [checkModalRegister, { openDrawer: openCheckDetailDrawer }] = useDrawer();
onMounted(async () => {
await orderStore.getDict();
});
onMounted(async () => {
// 获取业务员
const res = await getUserList({ page: 1, pageSize: 1000 });
businessUsers.value = res.items
.filter((item) => item.roleCode === ROLE.BUSINESS)
.map((item) => ({ value: item.userName, label: item.userName }));
});
const formConfig = computed(() => {
return getFormConfig(businessUsers.value);
});
const [registerTable, { getForm, reload, getColumns }] = useTable({
api: getOrderList,
title: '订单列表',
pagination: {
total: 60,
},
clickToRowSelect: false,
columns: getOrderColumns(user?.roleSmallVO?.code),
useSearchForm: true,
formConfig: formConfig,
showTableSetting: true,
// tableSetting: { fullScreen: true },
showIndexColumn: false,
rowKey: 'id',
rowSelection: {
type: 'checkbox',
selectedRowKeys: checkedKeys,
onSelect,
onSelectAll,
},
// actionColumn: {
// width: 160,
// title: 'Action',
// dataIndex: 'action',
// // slots: { customRender: 'action' },
// },
actionColumn:
role.value !== ROLE.PRODUCE
? {
width: 160,
title: 'Action',
dataIndex: 'action',
// slots: { customRender: 'action' },
}
: undefined,
});
function getFormValues() {
console.log(getForm().getFieldsValue());
}
// type CustomerCodeEntry = [string, number]; // 定义二维数组类型 [customerCode, count]
// type ProductionDepartmentEntry = [string, number]; // 定义二维数组类型 [productionDepartment, count]
// const selectedCustomCodes = ref<CustomerCodeEntry[]>([]); // 创建一个二维数组的 ref
// const selectedProductionDepartment = ref<ProductionDepartmentEntry[]>([]); // 创建一个二维数组的 ref
// // 单选处理函数
// function onSelect(
// record: { customerCode: string; productionDepartment: string; id: string },
// selected: boolean,
// ) {
// // 查找 customerCode 在 selectedCustomCodes 中的位置
// const customerCodeIndex = selectedCustomCodes.value.findIndex(
// ([customerCode]) => customerCode === record.customerCode,
// );
// // 查找 productionDepartment 在 selectedProductionDepartment 中的位置
// const productionDepartmentIndex = selectedProductionDepartment.value.findIndex(
// ([department]) => department === record.productionDepartment,
// );
// if (selected) {
// // 添加到 checkedKeys
// checkedKeys.value = [...checkedKeys.value, record.id];
// // 更新 selectedCustomCodes
// if (customerCodeIndex !== -1) {
// // 如果已存在,增加计数
// selectedCustomCodes.value[customerCodeIndex][1] += 1;
// } else {
// // 如果不存在,添加新项 [customerCode, 1]
// selectedCustomCodes.value.push([record.customerCode, 1]);
// }
// // 更新 selectedProductionDepartment
// if (productionDepartmentIndex !== -1) {
// // 如果已存在,增加计数
// selectedProductionDepartment.value[productionDepartmentIndex][1] += 1;
// } else {
// // 如果不存在,添加新项 [productionDepartment, 1]
// selectedProductionDepartment.value.push([record.productionDepartment, 1]);
// }
// } else {
// // 从 checkedKeys 中移除
// checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
// // 更新 selectedCustomCodes
// if (customerCodeIndex !== -1) {
// if (selectedCustomCodes.value[customerCodeIndex][1] > 1) {
// selectedCustomCodes.value[customerCodeIndex][1] -= 1;
// } else {
// selectedCustomCodes.value.splice(customerCodeIndex, 1);
// }
// }
// // 更新 selectedProductionDepartment
// if (productionDepartmentIndex !== -1) {
// if (selectedProductionDepartment.value[productionDepartmentIndex][1] > 1) {
// selectedProductionDepartment.value[productionDepartmentIndex][1] -= 1;
// } else {
// selectedProductionDepartment.value.splice(productionDepartmentIndex, 1);
// }
// }
// }
// console.log('5656Checked Keys:', checkedKeys.value);
// console.log('5656Selected Customer Codes:', selectedCustomCodes.value);
// console.log('5656Selected Production Departments:', selectedProductionDepartment.value);
// }
type CustomerCodeEntry = [string, number]; // 定义二维数组类型 [customerCode, count]
type ProductionDepartmentEntry = [string, number]; // 定义二维数组类型 [productionDepartment, count]
type ProjectNoEntry = [string, number]; // 定义二维数组类型 [innerNo, count]
const selectedCustomCodes = ref<CustomerCodeEntry[]>([]); // 创建一个二维数组的 ref
const selectedProductionDepartment = ref<ProductionDepartmentEntry[]>([]); // 创建一个二维数组的 ref
const selectedProjectNos = ref<ProjectNoEntry[]>([]); // 创建一个二维数组的 ref
// 单选处理函数
function onSelect(
record: {
customerCode: string;
productionDepartment: string;
projectNo: string;
id: string;
},
selected: boolean,
) {
// 查找 customerCode 在 selectedCustomCodes 中的位置
const customerCodeIndex = selectedCustomCodes.value.findIndex(
([customerCode]) => customerCode === record.customerCode,
);
// 查找 productionDepartment 在 selectedProductionDepartment 中的位置
const productionDepartmentIndex = selectedProductionDepartment.value.findIndex(
([department]) => department === record.productionDepartment,
);
// 查找 projectNo 在 selectedProjectNos 中的位置
const projectNoIndex = selectedProjectNos.value.findIndex(
([projectNo]) => projectNo === record.projectNo,
);
if (selected) {
// 添加到 checkedKeys
checkedKeys.value = [...checkedKeys.value, record.id];
// 更新 selectedCustomCodes
if (customerCodeIndex !== -1) {
// 如果已存在,增加计数
selectedCustomCodes.value[customerCodeIndex][1] += 1;
} else {
// 如果不存在,添加新项 [customerCode, 1]
selectedCustomCodes.value.push([record.customerCode, 1]);
}
// 更新 selectedProductionDepartment
if (productionDepartmentIndex !== -1) {
// 如果已存在,增加计数
selectedProductionDepartment.value[productionDepartmentIndex][1] += 1;
} else {
// 如果不存在,添加新项 [productionDepartment, 1]
selectedProductionDepartment.value.push([record.productionDepartment, 1]);
}
// 更新 selectedProjectNos
if (projectNoIndex !== -1) {
// 如果已存在,增加计数
selectedProjectNos.value[projectNoIndex][1] += 1;
} else {
// 如果不存在,添加新项 [projectNo, 1]
selectedProjectNos.value.push([record.projectNo, 1]);
}
} else {
// 从 checkedKeys 中移除
checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
// 更新 selectedCustomCodes
if (customerCodeIndex !== -1) {
if (selectedCustomCodes.value[customerCodeIndex][1] > 1) {
selectedCustomCodes.value[customerCodeIndex][1] -= 1;
} else {
selectedCustomCodes.value.splice(customerCodeIndex, 1);
}
}
// 更新 selectedProductionDepartment
if (productionDepartmentIndex !== -1) {
if (selectedProductionDepartment.value[productionDepartmentIndex][1] > 1) {
selectedProductionDepartment.value[productionDepartmentIndex][1] -= 1;
} else {
selectedProductionDepartment.value.splice(productionDepartmentIndex, 1);
}
}
// 更新 selectedProjectNos
if (projectNoIndex !== -1) {
if (selectedProjectNos.value[projectNoIndex][1] > 1) {
selectedProjectNos.value[projectNoIndex][1] -= 1;
} else {
selectedProjectNos.value.splice(projectNoIndex, 1);
}
}
}
console.log('5656Checked Keys:', checkedKeys.value);
console.log('5656Selected Customer Codes:', selectedCustomCodes.value);
console.log('56565Selected Production Departments:', selectedProductionDepartment.value);
console.log('5656Selected projectNo:', selectedProjectNos.value);
}
// // 全选处理函数
// function onSelectAll(selected: boolean, selectedRows: any[], changeRows: any[]) {
// const changeIds = changeRows.map((item) => item.id);
// const changeCustomerCodes = changeRows.map((item) => item.customerCode);
// const changeProductionDepartments = changeRows.map((item) => item.productionDepartment);
// if (selected) {
// // 添加到 checkedKeys
// checkedKeys.value = [...checkedKeys.value, ...changeIds];
// // 更新 selectedCustomCodes
// changeCustomerCodes.forEach((code) => {
// const index = selectedCustomCodes.value.findIndex(
// ([customerCode]) => customerCode === code,
// );
// if (index !== -1) {
// selectedCustomCodes.value[index][1] += 1;
// } else {
// selectedCustomCodes.value.push([code, 1]);
// }
// });
// // 更新 selectedProductionDepartment
// changeProductionDepartments.forEach((department) => {
// const index = selectedProductionDepartment.value.findIndex(
// ([prodDepartment]) => prodDepartment === department,
// );
// if (index !== -1) {
// selectedProductionDepartment.value[index][1] += 1;
// } else {
// selectedProductionDepartment.value.push([department, 1]);
// }
// });
// } else {
// // 从 checkedKeys 中移除
// checkedKeys.value = checkedKeys.value.filter((id) => !changeIds.includes(id));
// // 更新 selectedCustomCodes
// changeCustomerCodes.forEach((code) => {
// const index = selectedCustomCodes.value.findIndex(
// ([customerCode]) => customerCode === code,
// );
// if (index !== -1) {
// if (selectedCustomCodes.value[index][1] > 1) {
// selectedCustomCodes.value[index][1] -= 1;
// } else {
// selectedCustomCodes.value.splice(index, 1);
// }
// }
// });
// // 更新 selectedProductionDepartment
// changeProductionDepartments.forEach((department) => {
// const index = selectedProductionDepartment.value.findIndex(
// ([prodDepartment]) => prodDepartment === department,
// );
// if (index !== -1) {
// if (selectedProductionDepartment.value[index][1] > 1) {
// selectedProductionDepartment.value[index][1] -= 1;
// } else {
// selectedProductionDepartment.value.splice(index, 1);
// }
// }
// });
// }
// console.log('5656Checked Keys:', checkedKeys.value);
// console.log('5656Selected Customer Codes:', selectedCustomCodes.value);
// console.log('5656Selected Production Departments:', selectedProductionDepartment.value);
// }
// 全选处理函数
function onSelectAll(selected: boolean, selectedRows: any[], changeRows: any[]) {
const changeIds = changeRows.map((item) => item.id);
const changeCustomerCodes = changeRows.map((item) => item.customerCode);
const changeProductionDepartments = changeRows.map((item) => item.productionDepartment);
const changeProjectNos = changeRows.map((item) => item.projectNo);
if (selected) {
// 添加到 checkedKeys
checkedKeys.value = [...checkedKeys.value, ...changeIds];
// 更新 selectedCustomCodes
changeCustomerCodes.forEach((code) => {
const index = selectedCustomCodes.value.findIndex(
([customerCode]) => customerCode === code,
);
if (index !== -1) {
selectedCustomCodes.value[index][1] += 1;
} else {
selectedCustomCodes.value.push([code, 1]);
}
});
// 更新 selectedProductionDepartment
changeProductionDepartments.forEach((department) => {
const index = selectedProductionDepartment.value.findIndex(
([prodDepartment]) => prodDepartment === department,
);
if (index !== -1) {
selectedProductionDepartment.value[index][1] += 1;
} else {
selectedProductionDepartment.value.push([department, 1]);
}
});
// 更新 selectedProjectNos
changeProjectNos.forEach((projectNo) => {
const index = selectedProjectNos.value.findIndex(([no]) => no === projectNo);
if (index !== -1) {
selectedProjectNos.value[index][1] += 1;
} else {
selectedProjectNos.value.push([projectNo, 1]);
}
});
} else {
// 从 checkedKeys 中移除
checkedKeys.value = checkedKeys.value.filter((id) => !changeIds.includes(id));
// 更新 selectedCustomCodes
changeCustomerCodes.forEach((code) => {
const index = selectedCustomCodes.value.findIndex(
([customerCode]) => customerCode === code,
);
if (index !== -1) {
if (selectedCustomCodes.value[index][1] > 1) {
selectedCustomCodes.value[index][1] -= 1;
} else {
selectedCustomCodes.value.splice(index, 1);
}
}
});
// 更新 selectedProductionDepartment
changeProductionDepartments.forEach((department) => {
const index = selectedProductionDepartment.value.findIndex(
([prodDepartment]) => prodDepartment === department,
);
if (index !== -1) {
if (selectedProductionDepartment.value[index][1] > 1) {
selectedProductionDepartment.value[index][1] -= 1;
} else {
selectedProductionDepartment.value.splice(index, 1);
}
}
});
// 更新 selectedProjectNos
changeInnerNos.forEach((projectNo) => {
const index = selectedProjectNos.value.findIndex(([no]) => no === projectNo);
if (index !== -1) {
if (selectedProjectNos.value[index][1] > 1) {
selectedProjectNos.value[index][1] -= 1;
} else {
selectedProjectNos.value.splice(index, 1);
}
}
});
}
console.log('5656Checked Keys:', checkedKeys.value);
console.log('5656Selected Customer Codes:', selectedCustomCodes.value);
console.log('5656Selected Production Departments:', selectedProductionDepartment.value);
console.log('5656Selected projectNos:', selectedProjectNos.value);
}
function handleEdit(record, e) {
openFormDetailDrawer(true, { ...toRaw(record) });
e?.stopPropagation();
return false;
}
function handleCopy(record, e) {
openFormDetailDrawer(true, { ...toRaw(record), id: undefined, isCopy: true });
e?.stopPropagation();
return false;
}
function handleAdd() {
openFormDetailDrawer(true, {});
}
function handleCheck(record, e) {
openCheckDetailDrawer(true, record);
e?.stopPropagation();
return false;
}
function handleHistory(record, e) {
openHistoryDetailDrawer(true, record);
e?.stopPropagation();
return false;
}
function handleTrackHistory(record, e) {
openTrackHistoryDrawer(true, record);
return false;
}
function handleProfitModal() {
const form = getForm();
const values = form.getFieldsValue();
openProfitModal(true, {
data: checkedKeys.value,
searchData: values,
});
}
function handleInvoiceCreateModal(record) {
const form = getForm();
const values = form.getFieldsValue();
if (checkedKeys.value.length == 0) {
error('请选择订单');
return;
}
if (selectedCustomCodes.value.length > 1) {
error('勾选订单的客户编码需一致');
return;
}
openInvoiceCreateModal(true, {
record: record,
customersCodes: selectedCustomCodes.value,
data: checkedKeys.value,
searchData: values,
});
}
function handleProductInvoiceModal() {
const form = getForm();
const values = form.getFieldsValue();
if (checkedKeys.value.length == 0) {
error('请选择订单');
return;
}
if (selectedProductionDepartment.value.length > 1) {
error('勾选订单的生产科需一致');
return;
}
openProductInvoiceModal(true, {
data: checkedKeys.value,
searchData: values,
});
}
//一次通过率
const value1 = ref('一次通过率');
function handleChange() {}
function handlePassModal(title) {
const form = getForm();
const values = form.getFieldsValue();
openPassModal(true, {
check: checkedKeys.value,
title: title,
searchData: values,
});
}
// const form = getForm();
// const values = form.getFieldsValue();
// if (title == '确认样品') {
// openPassModal(true, {
// check: checkedKeys.value,
// title: title,
// });
// return false;
// } else if (title == '生产样品') {
// openPassModal(true, {
// check: checkedKeys.value,
// title: title,
// });
// return false;
// } else if (title == '测试样品') {
// openPassModal(true, {
// check: checkedKeys.value,
// title: title,
// });
// return false;
// }
// }
const { createMessage } = useMessage();
const { error } = createMessage;
function handleProductModal(record) {
const form = getForm();
const values = form.getFieldsValue();
console.log(selectedCustomCodes.value, 5656);
if (selectedCustomCodes.value.length == 0) {
error('请选择订单');
return;
}
openProductModal(true, {
checkedKeys: checkedKeys.value,
customers: selectedCustomCodes.value,
data: values,
});
}
function handleRateModal() {
const form = getForm();
const values = form.getFieldsValue();
openRateModal(true, {
data: values,
});
}
function handleFieldVisible(record) {
openFieldDetailDrawer(true, record);
}
function handleGoCheckDetail() {
openCheckDetailDrawer(true);
openFormDetailDrawer(false);
}
function handleGoFormDetail() {
openCheckDetailDrawer(false);
openFormDetailDrawer(true);
}
function handlePreview(url) {
createImgPreview({ imageList: [url], defaultWidth: 500 });
// e?.stopPropagation();
// e?.preventDefault();
return false;
}
async function handleExportModal() {
const form = getForm();
const values = form.getFieldsValue();
openExportModal(true, {
data: values,
});
}
async function handleServiceProfitModal() {
if (selectedCustomCodes.value.length > 1) {
error('勾选订单的客户编码需一致');
return;
}
if (selectedProjectNos.value.length > 1) {
error('勾选订单的项目号需一致');
return;
}
const form = getForm();
const values = form.getFieldsValue();
const resAll = await getOrderList({});
console.log(resAll, '5656resall');
const filteredItems = resAll.items.filter((item: { id: string }) =>
checkedKeys.value.includes(item.id),
);
console.log(filteredItems, '5656filteredItems');
openServiceProfitModal(true, {
res: filteredItems,
data: checkedKeys.value,
orderList: resAll,
customerCode: selectedCustomCodes.value,
projectNo: selectedProjectNos.value,
searchData: values,
});
}
async function handleProductProfitModal() {
if (selectedCustomCodes.value.length > 1) {
error('勾选订单的客户编码需一致');
return;
}
const form = getForm();
const values = form.getFieldsValue();
const resAll = await getOrderList({});
const filteredItems = resAll.items.filter((item: { id: string }) =>
checkedKeys.value.includes(item.id),
);
openProductProfitModal(true, {
filteredItems: filteredItems,
data: checkedKeys.value,
searchData: values,
customerCode: selectedCustomCodes.value,
projectNo: selectedProjectNos.value,
});
}
const handleFormSuccess = () => {
reload();
};
async function handleDelete(id: string) {
try {
await orderDelete({ ids: [id] });
reload();
} catch (error) {
console.log(error);
}
}
return {
user,
SELECT_FIELD_COLUMNS,
fieldDetailRegister,
profitModalRegister,
invoiceCreateModalRegister,
productInvoiceModalRegister,
serviceProfitModalRegister,
productProfitModalRegister,
handleChange,
rateModalRegister,
exportModalRegister,
productModalRegister,
passModalRegister,
historyDetailRegister,
trackHistoryRegister,
formDetailRegister,
handleProfitModal,
handleInvoiceCreateModal,
handleProductInvoiceModal,
registerTable,
getFormValues,
checkedKeys,
onSelect,
handleEdit,
handleCopy,
handleCheck,
onSelectAll,
tooltipVisible,
handleFieldVisible,
checkModalRegister,
handleGoCheckDetail,
handleGoFormDetail,
handleHistory,
focus,
value1,
handlePassModal,
handleTrackHistory,
handleAdd,
createImgPreview,
handleExportModal,
handlePreview,
handleFormSuccess,
handleProductModal,
handleRateModal,
openExportModal,
openProductModal,
openPassModal,
handleDelete,
handleServiceProfitModal,
handleProductProfitModal,
selectedCustomCodes,
role,
ROLE,
};
},
});
</script>
<style lang="less">
.ant-table-thead th,
.ant-table-tbody td {
padding: 0;
white-space: pre-wrap;
}
.ant-table-cell img {
width: 40px;
height: 40px;
}
.order-page .vben-basic-table .ant-form-item .ant-picker {
width: 100%;
}
.order-page .ant-table.ant-table-middle .ant-table-tbody > tr > td {
padding-top: 0;
padding-bottom: 0;
}
.passCalculate .ant-select-selector {
background-color: #1890ff !important;
color: white !important;
border-radius: 5px 5px 5px 5px !important;
}
.passCalculate .ant-select-selection-item {
color: white !important;
}
.dropdown-class {
background-color: #1890ff; /* 选择框背景颜色 */
color: white;
border: none; /* 去除选择框边框 */
}
.dropdown-class .ant-select-selector {
background-color: #1890ff; /* 选择框背景颜色 */
color: white;
border: none !important; /* 去除选择框边框 */
box-shadow: none !important; /* 去除选择框阴影 */
}
.dropdown-class .ant-select-dropdown {
background-color: #1890ff; /* 下拉框背景颜色 */
border: none !important; /* 去除下拉框边框 */
box-shadow: none !important; /* 去除下拉框阴影 */
}
.dropdown-class .ant-select-item {
background-color: #1890ff; /* 下拉选项背景颜色 */
color: white !important; /* 下拉选项字体颜色 */
border: none !important; /* 去除下拉选项边框 */
}
.dropdown-class .ant-select-item:hover,
.dropdown-class .ant-select-item-option-active,
.dropdown-class .ant-select-item-option-selected {
background-color: #1967d3 !important; /* 选中和悬停状态下拉选项背景颜色 */
color: white !important; /* 选中和悬停状态下拉选项字体颜色 */
border: none !important; /* 去除选中和悬停状态下拉选项边框 */
}
.dropdown-class .ant-select-item-option {
background-color: #1890ff; /* 下拉选项背景颜色 */
color: white !important; /* 下拉选项字体颜色 */
border: none !important; /* 去除下拉选项边框 */
}
</style>
./constant