Blame view

src/views/project/order/index.vue 43 KB
sanmu authored
1
<template>
sanmu authored
2
  <div class="order-page">
sanmu authored
3
4
5
6
7
    <BasicTable @register="registerTable" bordered>
      <template #headerCell="{ column }">
        <!-- <template v-if="column.key === 'address1'">
          <span class="flex items-center justify-center"> 自定义字段列11 </span>
        </template> -->
8
        <template v-if="SELECT_FIELD_COLUMNS.includes(column.key) && role === ROLE.ADMIN">
sanmu authored
9
10
11
12
13
14
15
16
17
18
19
20
21
22
          <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>
23
24
25
              <a-button
                :style="{ borderRadius: '5px 5px 5px 5px' }"
                type="link"
26
                @click="handleClearChoose"
27
28
29
                size="small"
                >清空</a-button
              >
sanmu authored
30
31
32
33
34
35
36
37
38
39
            </template>
            <template v-else>
              <span>未选中任何订单</span>
            </template>
          </template>
        </a-alert>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'action'">
          <TableAction
40
            :actions="
41
              role !== ROLE.PRODUCE && role !== ROLE.FINANCE
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
                ? [
                    {
                      // 数据分析没有编辑权限
                      ...(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),
                    //   }),
                    // },
                  ]
                : []
            "
sanmu authored
68
            :dropDownActions="
69
              role !== ROLE.DATA_REPORT_USER && role !== ROLE.PRODUCE
sanmu authored
70
71
72
73
74
                ? [
                    {
                      label: '历史记录',
                      onClick: handleHistory.bind(null, record),
                    },
75
                    {
76
                      label: '跟单结果记录',
77
                      onClick: handleTrackHistory.bind(null, record),
78
79
                    },
                    {
sanmu authored
80
                      // 数据分析没有编辑权限
81
82
83
                      ...((role === ROLE.ADMIN ||
                        role === ROLE.TRACKER ||
                        role === ROLE.FINANCE) && {
sanmu authored
84
85
86
87
88
89
                        label: '复制',
                        // icon: 'ic:outline-delete-outline',
                        onClick: handleCopy.bind(null, record),
                      }),
                    },
                    {
90
91
92
93
94
95
96
97
98
                      ...(role === ROLE.ADMIN && {
                        label: '删除',
                        popConfirm: {
                          title: '是否确认删除',
                          placement: 'left',
                          confirm: handleDelete.bind(null, record?.id),
                        },
                      }),
                    },
sanmu authored
99
100
101
                  ]
                : []
            "
sanmu authored
102
103
104
105
106
107
          />
        </template>
        <template v-if="column.key === 'picUrl'">
          <img
            :width="100"
            :height="100"
sanmu authored
108
109
            :src="record.smallPicUrl"
            :key="record.smallPicUrl"
sanmu authored
110
111
112
113
114
115
            @click="handlePreview(record.picUrl)"
          />
        </template>
      </template>

      <template #toolbar>
116
117
118
119
120
121
122
123
124
125
        <div style="position: relative">
          <div style="padding-left: 50px; right: 123px">
            <!-- <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
126
              >
127
128
129
130
131
132
133
              <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
134
              >
135
136
137
138
139
140
141
              <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"
142
              >
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
                <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"
柏杨 authored
158
                v-if="role === ROLE.ADMIN || role === ROLE.FINANCE"
159
160
161
162
163
164
                >内部生产净利润分析</a-button
              >
              <a-button
                :style="{ borderRadius: '5px 5px 5px 5px' }"
                type="primary"
                @click="handleServiceProfitModal"
柏杨 authored
165
                v-if="role === ROLE.ADMIN || role === ROLE.FINANCE"
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
                >业务/研发净利润分析</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 ||
柏杨 authored
190
191
                  role === ROLE.FINANCE ||
                  role === ROLE.INSPECT
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
                "
                >导出</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
209
            >
210
211
          </div></div
        >
sanmu authored
212
213
214
215
216
217
218
      </template>
    </BasicTable>
    <FormDetail
      @register="formDetailRegister"
      :onGoCheckDetail="handleGoCheckDetail"
      @success="handleFormSuccess"
    />
219
220
221
222
223
    <ProductText
      @register="productModalRegister"
      :role="role"
      :customerCodes="selectedCustomCodes"
    />
224
    <InvoiceCreate @register="invoiceCreateModalRegister" />
225
226
    <ServiceProfit @register="serviceProfitModalRegister" />
    <ProductProfit @register="productProfitModalRegister" />
227
    <ProductInvoice @register="productInvoiceModalRegister" />
sanmu authored
228
    <ProfitAnalysis @register="profitModalRegister" />
sanmu authored
229
    <RateModal @register="rateModalRegister" />
230
    <ExportModal @register="exportModalRegister" :role="role" :ids="checkedKeys" />
sanmu authored
231
232
    <CheckDetail @register="checkModalRegister" :onGoFormDetail="handleGoFormDetail" />
    <HistoryDetail @register="historyDetailRegister" />
233
    <TrackHistory @register="trackHistoryRegister" />
sanmu authored
234
    <FieldDetail @register="fieldDetailRegister" />
235
    <PassCalculate @register="passModalRegister" />
sanmu authored
236
237
238
  </div>
</template>
<script lang="ts">
sanmu authored
239
  import { defineComponent, onMounted, ref, toRaw, computed } from 'vue';
sanmu authored
240
241
242
243
244
245
246
  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';
247
  import ProductText from './ProductText.vue';
sanmu authored
248
249
  import RateModal from './RateModal.vue';
  import ExportModal from './ExportModal.vue';
250
  import PassCalculate from './PassCalculate.vue';
251
  import InvoiceCreate from './InvoiceCreate.vue';
252
253
  import ServiceProfit from './ServiceProfit.vue';
  import ProductProfit from './ProductProfit.vue';
254
  import ProductInvoice from './ProductInvoice.vue';
sanmu authored
255
256
  import { useModal } from '/@/components/Modal';
sanmu authored
257
258
  import { getFormConfig, getOrderColumns, SELECT_FIELD_COLUMNS } from './tableData';
  import FormDetail from './FormDetail/index.vue';
sanmu authored
259
260
  import CheckDetail from './CheckDetail.vue';
  import HistoryDetail from './HistoryDetail.vue';
261
  import TrackHistory from './TrackHistory.vue';
sanmu authored
262
263
  import FieldDetail from './FieldDetail.vue';
  import { createImgPreview } from '/@/components/Preview/index';
264
  import { getOrderList, orderDelete } from '/@/api/project/order';
sanmu authored
265
  import { useOrderStoreWithOut } from '/@/store/modules/order';
sanmu authored
266
  import { useUserStoreWithOut } from '/@/store/modules/user';
sanmu authored
267
  import { ROLE } from './type.d';
sanmu authored
268
  import { getUserList } from '/@/api/project/account';
269
270
  import { useMessage } from '/@/hooks/web/useMessage';
  import { getBaseInvoice } from '/@/api/project/invoice';
sanmu authored
271
272

  const orderStore = useOrderStoreWithOut();
sanmu authored
273
  const userStore = useUserStoreWithOut();
sanmu authored
274
275
276
277
278
279
280
281
282

  export default defineComponent({
    components: {
      HeaderCell,
      BasicTable,
      AAlert: Alert,
      TableAction,
      FormDetail,
      ProfitAnalysis,
283
      ProductText,
284
      PassCalculate,
sanmu authored
285
286
287
      FormOutlined,
      CheckDetail,
      HistoryDetail,
288
      TrackHistory,
sanmu authored
289
      FieldDetail,
sanmu authored
290
      RateModal,
291
      InvoiceCreate,
292
      ServiceProfit,
293
      ProductInvoice,
294
      ProductProfit,
sanmu authored
295
      ExportModal,
sanmu authored
296
297
298
    },
    setup() {
      const checkedKeys = ref<Array<string | number>>([]);
299
      // const selectedCustomCodes = ref<Array<string>>([]);
sanmu authored
300
      const [profitModalRegister, { openModal: openProfitModal }] = useModal();
301
      const [invoiceCreateModalRegister, { openModal: openInvoiceCreateModal }] = useModal();
302
303
      const [serviceProfitModalRegister, { openModal: openServiceProfitModal }] = useModal();
      const [productProfitModalRegister, { openModal: openProductProfitModal }] = useModal();
304
      const [productInvoiceModalRegister, { openModal: openProductInvoiceModal }] = useModal();
sanmu authored
305
306
      const [rateModalRegister, { openModal: openRateModal }] = useModal();
      const [exportModalRegister, { openModal: openExportModal }] = useModal();
307
      const [productModalRegister, { openModal: openProductModal }] = useModal();
308
      const [passModalRegister, { openModal: openPassModal }] = useModal();
sanmu authored
309
sanmu authored
310
311
312
      const tooltipVisible = ref(false);
      const [formDetailRegister, { openDrawer: openFormDetailDrawer }] = useDrawer();
      const [historyDetailRegister, { openDrawer: openHistoryDetailDrawer }] = useDrawer();
313
      const [trackHistoryRegister, { openDrawer: openTrackHistoryDrawer }] = useDrawer();
sanmu authored
314
315
      const [fieldDetailRegister, { openDrawer: openFieldDetailDrawer }] = useDrawer();
sanmu authored
316
      const user = userStore.getUserInfo;
sanmu authored
317
318
319
      const role = computed(() => {
        return user?.roleSmallVO?.code;
      });
sanmu authored
320
321
322
      // 业务员列表
      const businessUsers = ref([]);
sanmu authored
323
324
325
326
327
      const [checkModalRegister, { openDrawer: openCheckDetailDrawer }] = useDrawer();
      onMounted(async () => {
        await orderStore.getDict();
      });
sanmu authored
328
329
330
331
332
333
334
335
336
337
338
339
      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);
      });
sanmu authored
340
      const [registerTable, { getForm, reload, getColumns }] = useTable({
sanmu authored
341
342
343
344
345
        api: getOrderList,
        title: '订单列表',
        pagination: {
          total: 60,
        },
346
        clickToRowSelect: false,
sanmu authored
347
        columns: getOrderColumns(user?.roleSmallVO?.code),
sanmu authored
348
        useSearchForm: true,
sanmu authored
349
        formConfig: formConfig,
sanmu authored
350
351
352
353
354
355
356
        showTableSetting: true,
        // tableSetting: { fullScreen: true },
        showIndexColumn: false,
        rowKey: 'id',
        rowSelection: {
          type: 'checkbox',
          selectedRowKeys: checkedKeys,
sanmu authored
357
358
          onSelect,
          onSelectAll,
sanmu authored
359
        },
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
        // 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,
sanmu authored
375
376
377
378
      });
      function getFormValues() {
        console.log(getForm().getFieldsValue());
      }
379
柏杨 authored
380
381
      // type CustomerCodeEntry = [string, number]; // 定义二维数组类型 [customerCode, count]
      // type ProductionDepartmentEntry = [string, number]; // 定义二维数组类型 [productionDepartment, count]
382
      // type ProjectNoEntry = [string, number]; // 定义二维数组类型 [innerNo, count]
柏杨 authored
383
384
385

      // const selectedCustomCodes = ref<CustomerCodeEntry[]>([]); // 创建一个二维数组的 ref
      // const selectedProductionDepartment = ref<ProductionDepartmentEntry[]>([]); // 创建一个二维数组的 ref
386
      // const selectedProjectNos = ref<ProjectNoEntry[]>([]); // 创建一个二维数组的 ref
柏杨 authored
387
388
389

      // // 单选处理函数
      // function onSelect(
390
391
392
393
394
395
      //   record: {
      //     customerCode: string;
      //     productionDepartment: string;
      //     projectNo: string;
      //     id: string;
      //   },
柏杨 authored
396
397
398
399
400
401
402
403
404
405
406
407
      //   selected: boolean,
      // ) {
      //   // 查找 customerCode 在 selectedCustomCodes 中的位置
      //   const customerCodeIndex = selectedCustomCodes.value.findIndex(
      //     ([customerCode]) => customerCode === record.customerCode,
      //   );

      //   // 查找 productionDepartment 在 selectedProductionDepartment 中的位置
      //   const productionDepartmentIndex = selectedProductionDepartment.value.findIndex(
      //     ([department]) => department === record.productionDepartment,
      //   );
408
409
410
411
412
      //   // 查找 projectNo 在 selectedProjectNos 中的位置
      //   const projectNoIndex = selectedProjectNos.value.findIndex(
      //     ([projectNo]) => projectNo === record.projectNo,
      //   );
柏杨 authored
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
      //   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]);
      //     }
434
435
436
437
438
439
440
441
442

      //     // 更新 selectedProjectNos
      //     if (projectNoIndex !== -1) {
      //       // 如果已存在,增加计数
      //       selectedProjectNos.value[projectNoIndex][1] += 1;
      //     } else {
      //       // 如果不存在,添加新项 [projectNo, 1]
      //       selectedProjectNos.value.push([record.projectNo, 1]);
      //     }
柏杨 authored
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
      //   } 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);
      //       }
      //     }
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

      //     // 更新 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);
      //   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
      //     changeProjectNos.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);
      //         }
      //       }
      //     });
柏杨 authored
568
569
570
571
572
      //   }

      //   console.log('5656Checked Keys:', checkedKeys.value);
      //   console.log('5656Selected Customer Codes:', selectedCustomCodes.value);
      //   console.log('5656Selected Production Departments:', selectedProductionDepartment.value);
573
      //   console.log('5656Selected projectNos:', selectedProjectNos.value);
柏杨 authored
574
      // }
575
576
577
      type CustomerCodeEntry = [string, number]; // 定义二维数组类型 [customerCode, count]
      type ProductionDepartmentEntry = [string, number]; // 定义二维数组类型 [productionDepartment, count]
柏杨 authored
578
      type ProjectNoEntry = [string, number]; // 定义二维数组类型 [innerNo, count]
579
      type BusinessPersonEntry = [string, number]; // 定义二维数组类型 [businessPerson, count]
580
581
582

      const selectedCustomCodes = ref<CustomerCodeEntry[]>([]); // 创建一个二维数组的 ref
      const selectedProductionDepartment = ref<ProductionDepartmentEntry[]>([]); // 创建一个二维数组的 ref
柏杨 authored
583
      const selectedProjectNos = ref<ProjectNoEntry[]>([]); // 创建一个二维数组的 ref
584
      const selectedBusinessPersons = ref<BusinessPersonEntry[]>([]); // 创建一个二维数组的 ref
585
586
587

      // 单选处理函数
      function onSelect(
柏杨 authored
588
589
590
591
        record: {
          customerCode: string;
          productionDepartment: string;
          projectNo: string;
592
          businessPerson: string; // 添加 businessPerson 属性
柏杨 authored
593
594
          id: string;
        },
595
596
597
598
599
600
601
602
603
604
        selected: boolean,
      ) {
        const customerCodeIndex = selectedCustomCodes.value.findIndex(
          ([customerCode]) => customerCode === record.customerCode,
        );

        const productionDepartmentIndex = selectedProductionDepartment.value.findIndex(
          ([department]) => department === record.productionDepartment,
        );
柏杨 authored
605
606
607
608
        const projectNoIndex = selectedProjectNos.value.findIndex(
          ([projectNo]) => projectNo === record.projectNo,
        );
609
610
611
612
        const businessPersonIndex = selectedBusinessPersons.value.findIndex(
          ([businessPerson]) => businessPerson === record.businessPerson,
        );
sanmu authored
613
614
        if (selected) {
          checkedKeys.value = [...checkedKeys.value, record.id];
615
616
617
618
619
620
621
622
623
624
625
626
627
628

          // 更新 selectedCustomCodes
          if (customerCodeIndex !== -1) {
            selectedCustomCodes.value[customerCodeIndex][1] += 1;
          } else {
            selectedCustomCodes.value.push([record.customerCode, 1]);
          }

          // 更新 selectedProductionDepartment
          if (productionDepartmentIndex !== -1) {
            selectedProductionDepartment.value[productionDepartmentIndex][1] += 1;
          } else {
            selectedProductionDepartment.value.push([record.productionDepartment, 1]);
          }
柏杨 authored
629
630
631
632
633
634
635

          // 更新 selectedProjectNos
          if (projectNoIndex !== -1) {
            selectedProjectNos.value[projectNoIndex][1] += 1;
          } else {
            selectedProjectNos.value.push([record.projectNo, 1]);
          }
636
637
638
639
640
641
642

          // 更新 selectedBusinessPersons
          if (businessPersonIndex !== -1) {
            selectedBusinessPersons.value[businessPersonIndex][1] += 1;
          } else {
            selectedBusinessPersons.value.push([record.businessPerson, 1]);
          }
sanmu authored
643
644
        } else {
          checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662

          // 更新 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);
            }
          }
柏杨 authored
663
664
665
666
667
668
669
670
671

          // 更新 selectedProjectNos
          if (projectNoIndex !== -1) {
            if (selectedProjectNos.value[projectNoIndex][1] > 1) {
              selectedProjectNos.value[projectNoIndex][1] -= 1;
            } else {
              selectedProjectNos.value.splice(projectNoIndex, 1);
            }
          }
672
673
674
675
676
677
678
679
680

          // 更新 selectedBusinessPersons
          if (businessPersonIndex !== -1) {
            if (selectedBusinessPersons.value[businessPersonIndex][1] > 1) {
              selectedBusinessPersons.value[businessPersonIndex][1] -= 1;
            } else {
              selectedBusinessPersons.value.splice(businessPersonIndex, 1);
            }
          }
sanmu authored
681
        }
682
683
684
685
686
687
        console.log('Checked Keys:', checkedKeys.value);
        console.log('Selected Customer Codes:', selectedCustomCodes.value);
        console.log('Selected Production Departments:', selectedProductionDepartment.value);
        console.log('Selected Project Nos:', selectedProjectNos.value);
        console.log('Selected Business Persons:', selectedBusinessPersons.value);
sanmu authored
688
      }
689
690
691

      // 全选处理函数
      function onSelectAll(selected: boolean, selectedRows: any[], changeRows: any[]) {
sanmu authored
692
        const changeIds = changeRows.map((item) => item.id);
693
        const changeCustomerCodes = changeRows.map((item) => item.customerCode);
694
        const changeProductionDepartments = changeRows.map((item) => item.productionDepartment);
柏杨 authored
695
        const changeProjectNos = changeRows.map((item) => item.projectNo);
696
        const changeBusinessPersons = changeRows.map((item) => item.businessPerson); // 新增处理 businessPerson
697
sanmu authored
698
699
        if (selected) {
          checkedKeys.value = [...checkedKeys.value, ...changeIds];
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723

          // 更新 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]);
            }
          });
柏杨 authored
724
725
726
727
728
729
730
731
732
733

          // 更新 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]);
            }
          });
734
735
736
737
738
739
740
741
742
743

          // 更新 selectedBusinessPersons
          changeBusinessPersons.forEach((businessPerson) => {
            const index = selectedBusinessPersons.value.findIndex(([bp]) => bp === businessPerson);
            if (index !== -1) {
              selectedBusinessPersons.value[index][1] += 1;
            } else {
              selectedBusinessPersons.value.push([businessPerson, 1]);
            }
          });
sanmu authored
744
        } else {
745
746
747
748
749
750
751
752
753
754
755
756
757
758
          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);
              }
            }
sanmu authored
759
          });
760
761
762
763
764
765
766
767
768
769
770
771
772

          // 更新 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);
              }
            }
773
          });
柏杨 authored
774
775

          // 更新 selectedProjectNos
776
          changeProjectNos.forEach((projectNo) => {
柏杨 authored
777
778
779
780
781
782
783
784
785
            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);
              }
            }
          });
786
787
788
789
790
791
792
793
794
795
796
797

          // 更新 selectedBusinessPersons
          changeBusinessPersons.forEach((businessPerson) => {
            const index = selectedBusinessPersons.value.findIndex(([bp]) => bp === businessPerson);
            if (index !== -1) {
              if (selectedBusinessPersons.value[index][1] > 1) {
                selectedBusinessPersons.value[index][1] -= 1;
              } else {
                selectedBusinessPersons.value.splice(index, 1);
              }
            }
          });
sanmu authored
798
        }
799
800
801
802
803
804
805
806
807
808
809
810
811
812
        console.log('Checked Keys:', checkedKeys.value);
        console.log('Selected Customer Codes:', selectedCustomCodes.value);
        console.log('Selected Production Departments:', selectedProductionDepartment.value);
        console.log('Selected Project Nos:', selectedProjectNos.value);
        console.log('Selected Business Persons:', selectedBusinessPersons.value);
      }

      function handleClearChoose() {
        checkedKeys.value = [];
        selectedCustomCodes.value = [];
        selectedProductionDepartment.value = [];
        selectedProjectNos.value = [];
        selectedBusinessPersons.value = [];
sanmu authored
813
814
815
816
817
818
819
820
      }

      function handleEdit(record, e) {
        openFormDetailDrawer(true, { ...toRaw(record) });
        e?.stopPropagation();
        return false;
      }
sanmu authored
821
822
823
824
825
826
      function handleCopy(record, e) {
        openFormDetailDrawer(true, { ...toRaw(record), id: undefined, isCopy: true });
        e?.stopPropagation();
        return false;
      }
sanmu authored
827
      function handleAdd() {
sanmu authored
828
        openFormDetailDrawer(true, {});
sanmu authored
829
830
831
832
833
834
835
836
837
838
839
840
841
842
      }

      function handleCheck(record, e) {
        openCheckDetailDrawer(true, record);
        e?.stopPropagation();
        return false;
      }

      function handleHistory(record, e) {
        openHistoryDetailDrawer(true, record);
        e?.stopPropagation();
        return false;
      }
843
844
845
      function handleTrackHistory(record, e) {
        openTrackHistoryDrawer(true, record);
        return false;
846
847
      }
sanmu authored
848
      function handleProfitModal() {
849
850
        const form = getForm();
        const values = form.getFieldsValue();
sanmu authored
851
852
        openProfitModal(true, {
          data: checkedKeys.value,
853
          searchData: values,
sanmu authored
854
855
856
        });
      }
857
      function handleInvoiceCreateModal(record) {
858
859
        const form = getForm();
        const values = form.getFieldsValue();
860
861
862
863
864
865
866
867
        if (checkedKeys.value.length == 0) {
          error('请选择订单');
          return;
        }
        if (selectedCustomCodes.value.length > 1) {
          error('勾选订单的客户编码需一致');
          return;
        }
868
        openInvoiceCreateModal(true, {
869
870
          record: record,
          customersCodes: selectedCustomCodes.value,
871
872
873
874
875
876
877
878
          data: checkedKeys.value,
          searchData: values,
        });
      }

      function handleProductInvoiceModal() {
        const form = getForm();
        const values = form.getFieldsValue();
879
880
881
882
883
884
885
886
        if (checkedKeys.value.length == 0) {
          error('请选择订单');
          return;
        }
        if (selectedProductionDepartment.value.length > 1) {
          error('勾选订单的生产科需一致');
          return;
        }
887
888
889
890
891
892
        openProductInvoiceModal(true, {
          data: checkedKeys.value,
          searchData: values,
        });
      }
893
894
895
896
897
898
      //一次通过率
      const value1 = ref('一次通过率');
      function handleChange() {}
      function handlePassModal(title) {
        const form = getForm();
        const values = form.getFieldsValue();
899
900
901
902
903
        openPassModal(true, {
          check: checkedKeys.value,
          title: title,
          searchData: values,
        });
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
      // 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;
柏杨 authored
929
      function handleProductModal(record) {
930
931
        const form = getForm();
        const values = form.getFieldsValue();
932
        console.log(selectedCustomCodes.value, 5656);
933
        if (checkedKeys.value.length == 0) {
934
935
936
          error('请选择订单');
          return;
        }
937
938
939
940
941
942
943
944
        if (selectedCustomCodes.value.length > 1) {
          error('客户编码需一致');
          return;
        }
        if (selectedBusinessPersons.value.length > 1) {
          error('业务员需一致');
          return;
        }
945
        openProductModal(true, {
柏杨 authored
946
          checkedKeys: checkedKeys.value,
947
          customers: selectedCustomCodes.value,
948
949
950
951
          data: values,
        });
      }
sanmu authored
952
953
954
955
956
957
958
959
960
      function handleRateModal() {
        const form = getForm();
        const values = form.getFieldsValue();

        openRateModal(true, {
          data: values,
        });
      }
sanmu authored
961
962
963
964
965
966
967
968
969
970
971
972
973
974
      function handleFieldVisible(record) {
        openFieldDetailDrawer(true, record);
      }

      function handleGoCheckDetail() {
        openCheckDetailDrawer(true);
        openFormDetailDrawer(false);
      }

      function handleGoFormDetail() {
        openCheckDetailDrawer(false);
        openFormDetailDrawer(true);
      }
sanmu authored
975
      function handlePreview(url) {
sanmu authored
976
977
978
979
980
981
        createImgPreview({ imageList: [url], defaultWidth: 500 });
        // e?.stopPropagation();
        // e?.preventDefault();
        return false;
      }
sanmu authored
982
      async function handleExportModal() {
sanmu authored
983
984
985
986
987
        const form = getForm();
        const values = form.getFieldsValue();
        openExportModal(true, {
          data: values,
        });
sanmu authored
988
989
      }
柏杨 authored
990
991
992
993
994
      async function handleServiceProfitModal() {
        if (selectedCustomCodes.value.length > 1) {
          error('勾选订单的客户编码需一致');
          return;
        }
柏杨 authored
995
996
997
998
        // if (selectedProjectNos.value.length > 1) {
        //   error('勾选订单的项目号需一致');
        //   return;
        // }
999
1000
        const form = getForm();
        const values = form.getFieldsValue();
柏杨 authored
1001
1002
1003
1004
1005
1006
        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');
1007
        openServiceProfitModal(true, {
柏杨 authored
1008
          res: filteredItems,
1009
          data: checkedKeys.value,
柏杨 authored
1010
1011
1012
          orderList: resAll,
          customerCode: selectedCustomCodes.value,
          projectNo: selectedProjectNos.value,
1013
1014
1015
1016
          searchData: values,
        });
      }
柏杨 authored
1017
1018
1019
1020
1021
      async function handleProductProfitModal() {
        if (selectedCustomCodes.value.length > 1) {
          error('勾选订单的客户编码需一致');
          return;
        }
1022
1023
        const form = getForm();
        const values = form.getFieldsValue();
柏杨 authored
1024
1025
1026
1027
        const resAll = await getOrderList({});
        const filteredItems = resAll.items.filter((item: { id: string }) =>
          checkedKeys.value.includes(item.id),
        );
1028
        openProductProfitModal(true, {
柏杨 authored
1029
          filteredItems: filteredItems,
1030
1031
          data: checkedKeys.value,
          searchData: values,
柏杨 authored
1032
1033
          customerCode: selectedCustomCodes.value,
          projectNo: selectedProjectNos.value,
1034
1035
1036
        });
      }
sanmu authored
1037
1038
1039
1040
      const handleFormSuccess = () => {
        reload();
      };
1041
1042
1043
1044
1045
1046
1047
1048
      async function handleDelete(id: string) {
        try {
          await orderDelete({ ids: [id] });
          reload();
        } catch (error) {
          console.log(error);
        }
      }
1049
sanmu authored
1050
      return {
sanmu authored
1051
        user,
sanmu authored
1052
        SELECT_FIELD_COLUMNS,
sanmu authored
1053
1054
        fieldDetailRegister,
        profitModalRegister,
1055
1056
        invoiceCreateModalRegister,
        productInvoiceModalRegister,
1057
1058
        serviceProfitModalRegister,
        productProfitModalRegister,
1059
        handleChange,
sanmu authored
1060
1061
        rateModalRegister,
        exportModalRegister,
1062
        productModalRegister,
1063
        passModalRegister,
sanmu authored
1064
        historyDetailRegister,
1065
        trackHistoryRegister,
sanmu authored
1066
1067
        formDetailRegister,
        handleProfitModal,
1068
1069
        handleInvoiceCreateModal,
        handleProductInvoiceModal,
sanmu authored
1070
1071
1072
1073
1074
        registerTable,
        getFormValues,
        checkedKeys,
        onSelect,
        handleEdit,
sanmu authored
1075
        handleCopy,
sanmu authored
1076
1077
1078
1079
1080
1081
1082
1083
        handleCheck,
        onSelectAll,
        tooltipVisible,
        handleFieldVisible,
        checkModalRegister,
        handleGoCheckDetail,
        handleGoFormDetail,
        handleHistory,
1084
1085
1086
1087
        focus,
        value1,
        handlePassModal,
        handleTrackHistory,
sanmu authored
1088
1089
        handleAdd,
        createImgPreview,
sanmu authored
1090
        handleExportModal,
sanmu authored
1091
1092
        handlePreview,
        handleFormSuccess,
1093
        handleProductModal,
sanmu authored
1094
1095
        handleRateModal,
        openExportModal,
1096
        openProductModal,
1097
        openPassModal,
1098
        handleDelete,
1099
1100
        handleServiceProfitModal,
        handleProductProfitModal,
1101
        handleClearChoose,
1102
        selectedCustomCodes,
sanmu authored
1103
1104
        role,
        ROLE,
sanmu authored
1105
1106
1107
1108
1109
      };
    },
  });
</script>
1110
<style lang="less">
sanmu authored
1111
1112
1113
1114
1115
1116
1117
  .ant-table-thead th,
  .ant-table-tbody td {
    padding: 0;
    white-space: pre-wrap;
  }

  .ant-table-cell img {
sanmu authored
1118
1119
    width: 40px;
    height: 40px;
sanmu authored
1120
  }
sanmu authored
1121
1122
1123
1124

  .order-page .vben-basic-table .ant-form-item .ant-picker {
    width: 100%;
  }
sanmu authored
1125
1126
1127
1128
1129

  .order-page .ant-table.ant-table-middle .ant-table-tbody > tr > td {
    padding-top: 0;
    padding-bottom: 0;
  }
1130
1131
1132
1133

  .passCalculate .ant-select-selector {
    background-color: #1890ff !important;
    color: white !important;
1134
    border-radius: 5px 5px 5px 5px !important;
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
  }

  .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; /* 去除下拉选项边框 */
  }
sanmu authored
1179
</style>
sanmu authored
1180
./constant