Ben Lin
2025-01-09 7bcfc0507043dc878c801a259aa7d058f4982551
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
<template>
  <div>
    <Loading
      :loading="compState.loading"
      :absolute="compState.absolute"
      :theme="compState.theme"
      :background="compState.background"
      :tip="compState.tip"
    />
    <div v-show="false">
      <printTemplate />
    </div>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <!-- 根据菜单设置的按钮,自动生成 -->
        <a-button
          type="primary"
          v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)"
          @click="handleCreate(item['DO_METHOD'])"
          :preIcon="item['ICON_URL']"
          :key="item"
        >
          {{ item['FUNC_NAME'] }}
        </a-button>
      </template>
      <template #action="{ record }">
        <TableAction :actions="createActions(record)" />
      </template>
      <template #[item]="{ field }" v-for="item in colSlots" :key="item">
        <!-- <template #form-BAS_REASON3aadd="{ field }"> -->
        <a-button
          v-if="field"
          class="mt-1 ml-1"
          size="small"
          @click="handleSelectItem(item)"
          preIcon="search|svg"
        />
        <GeneralModal
          @register="useModalInTableForm[item]"
          @success="(d, u) => handleItemSuccess(d, u, item)"
        />
      </template>
    </BasicTable>
    <Suspense>
      <CustModal
        @register="registerCust"
        @success="custSuccess"
        @cancel="custCancel"
        :type="cType"
        :entityName="entityName"
        @modal-inner="getdtlSlots"
      >
        <!-- 用插槽自定义多表单 -->
        <template #[item.name] v-for="item in dtlSlots" :key="item.name">
          <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]">
            <!-- 用插槽自定义弹出选择框 -->
            <template #[name]="{ field }" v-for="name in item.slots" :key="name">
              <a-button
                class="mt-1 ml-1"
                size="small"
                @click="handleCustClick(field)"
                :preIcon="item.preIcons[name]"
              />
              <GeneralModal
                @register="useModalData[name][0]"
                @success="(d, u) => handleEntSuccess(d, u, item.name)"
              />
            </template>
          </BasicForm>
          <!-- 自定义内容 -->
          <div class="h-full" style="height: 380px" v-if="isCustEl[item.name]">
            <FlowChartView :data="routeData" @init="init" />
            <RouteViewModal @register="registerRv" @success="RvItemSuccess" />
          </div>
        </template>
      </CustModal>
    </Suspense>
    <normalDrawer @register="registerDrawer" @success="handleSuccess" />
    <ImportExcelModal @register="registerImport" :title="ImportTitle" />
  </div>
</template>
<script lang="ts" setup>
  import { Ref, inject, nextTick, onMounted, reactive, ref, unref, watch } from 'vue';
  import {
    BasicTable,
    useTable,
    TableAction,
    BasicColumn,
    FormSchema,
    ActionItem,
  } from '/@/components/Table';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { useDrawer } from '/@/components/Drawer';
  import GeneralModal from '/@/views/components/GeneralModal.vue';
  import normalDrawer from '../normalDrawer.vue';
  import CustModal from '/@/views/components/CustModal.vue';
  import RouteViewModal from '/@/views/components/RouteViewModal.vue';
  import ImportExcelModal from '/@/views/components/ImportExcelModal.vue';
  import { FlowChartView } from '/@/components/FlowChart';
  import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
  import { useModal } from '/@/components/Modal';
  import { useGo } from '/@/hooks/web/usePage';
  import { getListByPage } from '/@/api/tigerapi/system';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel';
  import { getRoleButtons } from '/@/api/sys/menu';
  import { useUserStore } from '/@/store/modules/user';
  import { useRouter } from 'vue-router';
  import { afterFetchFn, GenerateActionButton, initRoute, SearchInfoFn } from '../data';
  import LogicFlow from '@logicflow/core';
  import { isFunction } from 'xe-utils';
  import { CustModalParams } from '/@/api/tigerapi/model/systemModel';
  import { useQueryStore } from '/@/store/modules/queryInpage';
  import printJS, { Configuration } from 'print-js';
  import printTemplate from '/@/views/components/printTemplate.vue';
  import { Loading, useLoading } from '@/components/Loading';
  import { useWoFlowcardStore } from '/@/store/modules/woflowcardprint';
  import { storeToRefs } from 'pinia';
 
  const { t } = useI18n();
  const { currentRoute } = useRouter();
  const route = unref(currentRoute);
  const useQuery = useQueryStore();
  const props = defineProps({
    useTableData: { type: Object as PropType<{}>, default: { table: [] } },
    crudColSlots: { type: Object as PropType<any> },
  });
  const objParams = inject('objParams') as Ref<any>;
  const savedParams = inject('savedParams') as Ref<any>;
  const colSlots = ref(objParams.value['colSlots']);
  const _columns = inject('_columns') as Ref<any[]>;
  const _searchFormSchema = inject('_searchFormSchema') as Ref<any[]>;
  const _crudFormSchema = inject('_crudFormSchema') as Ref<any[]>;
  const buttons = ref<[]>(await getRoleButtons(currentRoute.value.meta.menuCode as string));
  const isExistSql = inject('isExistSql') as Ref<string>;
  const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>;
  const AuthOption = inject('AuthOption') as Ref<{}>;
  const entityName = ref(objParams.value['ID']);
  const go = useGo();
  const [registerDrawer, { openDrawer }] = useDrawer();
  const [registerRv, { openModal: openRvModal, closeModal: RvcloseModal }] = useModal();
  const [registerCust, { openModal: openCustModal }] = useModal();
  const [registerCrud, { openModal: openCrudModal }] = useModal();
  const [registerImport, { openModal: openImportModal }] = useModal();
  const useWoFlowCard = useWoFlowcardStore();
  const { curPrintInfo } = storeToRefs(useWoFlowCard);
  const cType = ref('');
  const formSchemas = ref({}); //弹出框多表单结构
  const routeData = ref({
    nodes: [],
    edges: [],
  });
  const selectVals = ref({});
  const printData = ref<any[]>([]);
  const wokerorder = ref('');
  const compState = reactive<{
    absolute?: boolean;
    loading?: boolean;
    theme?: 'dark' | 'light';
    background?: string;
    tip?: string;
  }>({
    absolute: false,
    loading: false,
    theme: 'dark',
    background: 'rgba(111,111,111,.7)',
    tip: '加载中...',
  });
  const [openFullLoading, closeFullLoading] = useLoading({
    tip: '正在加载打印数据...',
  });
 
  printData.value = [
    {
      id: '111',
      Items: [
        {
          ID: 111,
          SALES_ORDER: 'YDSO240400482',
          ORDER_NO: 'YDRKD241000012',
          WORK_ORDER: 'YDMOB241104737',
          ITEM_CODE: '20100705.0102.00',
          ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
          PLAN_QTY: 100,
          SCAN_QTY: 50,
          STATUS: 'Y',
        },
        {
          ID: 112,
          SALES_ORDER: 'YDSO240400483',
          ORDER_NO: 'YDRKD241000013',
          WORK_ORDER: 'YDMOB241104737',
          ITEM_CODE: '20100705.0102.00',
          ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
          PLAN_QTY: 100,
          SCAN_QTY: 50,
          STATUS: 'Y',
        },
        {
          ID: 113,
          SALES_ORDER: 'YDSO240400484',
          ORDER_NO: 'YDRKD241000014',
          WORK_ORDER: 'YDMOB241104737',
          ITEM_CODE: '20100705.0102.00',
          ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
          PLAN_QTY: 100,
          SCAN_QTY: 50,
          STATUS: 'Y',
        },
        {
          ID: 114,
          ORDER_NO: 'YDRKD241000015',
          SALES_ORDER: 'YDSO240400485',
          WORK_ORDER: 'YDMOB241104737',
          ITEM_CODE: '20100705.0102.00',
          ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
          PLAN_QTY: 100,
          SCAN_QTY: 50,
          STATUS: 'Y',
        },
        {
          ID: 115,
          ORDER_NO: 'YDRKD241000016',
          SALES_ORDER: 'YDSO240400486',
          WORK_ORDER: 'YDMOB241104737',
          ITEM_CODE: '20100705.0102.00',
          ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
          PLAN_QTY: 100,
          SCAN_QTY: 50,
          STATUS: 'Y',
        },
        {
          ID: 116,
          ORDER_NO: 'YDRKD241000017',
          SALES_ORDER: 'YDSO240400487',
          WORK_ORDER: 'YDMOB241104737',
          ITEM_CODE: '20100705.0102.00',
          ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
          PLAN_QTY: 100,
          SCAN_QTY: 50,
          STATUS: 'Y',
        },
        // {
        //   ID: 116,
        //   ORDER_NO: 'YDRKD241000018',
        //   SALES_ORDER: 'YDSO240400488',
        //   WORK_ORDER: 'YDMOB241104737',
        //   ITEM_CODE: '20100705.0102.00',
        //   ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
        //   PLAN_QTY: 100,
        //   SCAN_QTY: 50,
        //   STATUS: 'Y',
        // },
        // {
        //   ID: 116,
        //   ORDER_NO: 'YDRKD241000019',
        //   SALES_ORDER: 'YDSO240400489',
        //   WORK_ORDER: 'YDMOB241104737',
        //   ITEM_CODE: '20100705.0102.00',
        //   ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
        //   PLAN_QTY: 100,
        //   SCAN_QTY: 50,
        //   STATUS: 'Y',
        // },
        // {
        //   ID: 116,
        //   ORDER_NO: 'YDRKD241000020',
        //   SALES_ORDER: 'YDSO240400490',
        //   WORK_ORDER: 'YDMOB241104737',
        //   ITEM_CODE: '20100705.0102.00',
        //   ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
        //   PLAN_QTY: 100,
        //   SCAN_QTY: 50,
        //   STATUS: 'Y',
        // },
        // {
        //   ID: 116,
        //   ORDER_NO: 'YDRKD241000021',
        //   SALES_ORDER: 'YDSO240400491',
        //   WORK_ORDER: 'YDMOB241104737',
        //   ITEM_CODE: '20100705.0102.00',
        //   ITEM_NAME: 'YM-DEMS-BD11Q48 AC0-300V AC20mA 电能1级 ',
        //   PLAN_QTY: 100,
        //   SCAN_QTY: 50,
        //   STATUS: 'Y',
        // },
      ],
    },
  ];
  const custImport = ref<any[]>([]);
  const EntityCustFunction = ref([
    {
      ActionItem(params, data, ...args) {},
      KeyFieldValues(val, id) {},
      OpenSelectItem(openItemModal: Fn, ...args) {},
      GetSelectSuccess(d, u, ...args) {},
      GetUseForm(...args) {},
      CustFunc(param: CustModalParams) {},
    } as EntityCustFunctionType,
  ]);
  /* 动态import实体名.ts的自定义方法 */
  try {
    custImport.value = await import(`../entityts/${objParams.value['ID']}.ts`);
  } catch (e) {
    console.log(e);
  }
  const [
    {
      ActionItem: nActionItem,
      KeyFieldValues,
      GetUseForm,
      GetUseModals,
      GetCustData,
      OpenSelectItem: OpenSelectCust,
      GetSelectSuccess,
      CustFunc,
      GetTitle,
    },
    ActionColumn,
  ] = isNullOrUnDef(custImport.value['default'])
    ? EntityCustFunction.value
    : custImport.value['default']();
 
  keyFieldValues.value = isNullOrUnDef(KeyFieldValues)
    ? {}
    : KeyFieldValues(objParams.value['CODE'], objParams.value['ID']);
  const dtlSlots = ref<any[]>([]);
  const ImportTitle = GetTitle && isFunction(GetTitle) ? ref(GetTitle().importTitle) : ref('');
  const useformdata = GetUseForm && isFunction(GetUseForm) ? GetUseForm() : {};
  const useFormData = ref<any>(useformdata);
  /* 自定义模态窗口中表单中插槽渲染按钮打开模态框useModal方法 */
  const modals = GetUseModals && isFunction(GetUseModals) ? GetUseModals() : { useModalData: {} };
  const useModalData = ref(modals['useModalData']);
  /* 表格内的插槽渲染的弹出选择框列表 */
  const useModalInTableForm = ref<any>({});
  colSlots.value.map((x) => {
    useModalInTableForm.value[x] = useModal();
  });
  /* 获取自定义数据 */
  const custData = GetCustData && isFunction(GetCustData) ? GetCustData() : { isCustEl: {} };
  const isCustEl = ref(custData['isCustEl']);
  const [registerTable, { getForm, reload, setProps }] = useTable({
    title: '列表信息',
    api: getListByPage,
    searchInfo: {
      TABLE_NAME: objParams.value['ID'],
      option:
        AuthOption.value['BY_ORG'] == 'Y'
          ? {
              //根据据点查询,必需带这个参数
              UserId: useUserStore().getUserInfo.userId,
              ByOrg: true,
              CurOrg: useUserStore().getUserInfo.orgCode,
            }
          : '',
      NeedInclude: true,
    },
    beforeFetch: (t) => SearchInfoFn(t, route.name, AuthOption.value['BY_ORG'] == 'Y'),
    afterFetch: afterFetch,
    columns: _columns as unknown as BasicColumn[],
    formConfig: {
      labelWidth: 140,
      schemas: _searchFormSchema as unknown as FormSchema[],
      submitFunc: () => Search(), //自定义查询提交按钮的方法,触发查询提交事件
      resetFunc: () => useQuery.resetFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y'),
    },
    useSearchForm: true,
    showTableSetting: true,
    bordered: true,
    canResize: true,
    showIndexColumn: false,
    actionColumn: ActionColumn
      ? ActionColumn
      : {
          width: 120,
          title: '操作',
          dataIndex: 'action',
          slots: { customRender: 'action' },
          fixed: 'right',
        }, //自定义操作列
  });
 
  watch(
    () => AuthOption.value,
    (newVal, oldVal) => {
      nextTick(() => {
        if (!isNullOrEmpty(newVal.BY_ORG) && !isNullOrUnDef(savedParams.value['params'])) {
          getForm().setFieldsValue(savedParams.value['params']);
          setProps({
            searchInfo: {
              TABLE_NAME: objParams.value['ID'],
              option:
                AuthOption.value['BY_ORG'] == 'Y'
                  ? {
                      //根据据点查询,必需带这个参数
                      UserId: useUserStore().getUserInfo.userId,
                      ByOrg: true,
                      CurOrg: useUserStore().getUserInfo.orgCode,
                    }
                  : '',
            },
          });
          reload();
        }
      });
    },
    { deep: true, immediate: true },
  );
 
  onMounted(async () => {
    if (!isNullOrUnDef(savedParams) && !isNullOrUnDef(savedParams.value['params'])) {
      getForm().setFieldsValue(savedParams.value['params']);
      reload();
    }
    // if (
    //   !isNullOrUnDef(useQuery.getCurSearchInfo['searchInfo']) &&
    //   useQuery.getCurSearchInfo['name'] == route.name
    // ) {
    //   getForm().resetFields();
    //   const searchInfo = useQuery.getCurSearchInfo['searchInfo'];
    //   await getForm().setFieldsValue(searchInfo);
    // }
  });
 
  /**
   * @description: 查询提交
   * @return {*}
   */
  async function Search() {
    useQuery.submitFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y').then(() => {
      reload();
    });
  }
 
  /**
   * @description: 请求之后对返回值进行处理
   * @param {*} t
   * @return {*}
   */
  function afterFetch(t) {
    afterFetchFn(t, route.name, getForm());
  }
 
  const currlf = ref(null) as Ref<LogicFlow | null>;
  /**
   * @description: 工艺路线初始化
   * @param {*} lf
   * @return {*}
   */
  async function init(lf, rotId) {
    initRoute(lf, rotId, routeData, currlf, null);
  }
 
  /**
   * @description: 生成列表中操作项的按钮
   * @param {*} record
   * @return {*}
   */
  function createActions(record) {
    const params = {
      record,
      isUpdate: true,
      entityName: objParams.value['ID'],
      formJson: _crudFormSchema.value,
      cType,
      dtlSlots,
      formSchemas,
      useModalData,
      useFormData,
      crudColSlots: objParams.value['crudColSlots'],
      routeData,
      currlf,
      selectVals,
      colSlots,
      ifSave: true,
      sName: objParams.value['sName'],
    };
 
    /* 根据菜单设置的按钮自动生成操作列中的按钮 */
    const _actionItem: ActionItem[] = [];
    const actionItem = GenerateActionButton(params, buttons, openDrawer, reload, _actionItem);
    let _btn = buttons.value.filter((q) => q['BUTTON_TYPE'] == 1 && q['DO_METHOD'] == 'ToPrint');
    if (_btn.length > 0) {
      _actionItem.push({
        icon: isNullOrEmpty(_btn[0]['ICON_URL']) ? '' : _btn[0]['ICON_URL'],
        tooltip: '打印',
        onClick: ToPrint.bind(null, params),
        name: _btn[0]['DO_METHOD'],
      });
    }
    if (isNullOrUnDef(custImport.value['default'])) {
      return actionItem;
    }
    /* 根据动态加载的实体类名.ts中的ActionItem方法,渲染操作列中的按钮方法 */
    return nActionItem(
      params,
      actionItem,
      openDrawer,
      reload,
      null,
      useForm,
      useModal,
      go,
      setProps,
      openCustModal,
      openCrudModal,
    );
  }
 
  /**
   * @description: 获取多表单插槽列表
   * @param {*} d
   * @return {*}
   */
  function getdtlSlots(d, callback) {
    dtlSlots.value = d;
    callback();
    // setTimeout(() => {
    //   callback();
    // }, 100);
  }
 
  /**
   * @description: 获取工具栏中按钮的行为
   * @return {*}
   */
  function handleCreate(fnName: string) {
    if (isNullOrUnDef(custImport.value['default'])) {
      /* 如果动态加载的实体类.ts不存在,则直接打开侧边框 */
      openDrawer(true, {
        isUpdate: false, //是新增还是编辑,false-新增|true-编辑
        entityName: entityName.value, //实体类名
        formJson: _crudFormSchema.value, //新增编辑的表单结构
        crudColSlots: objParams.value['crudColSlots'], //新增编辑的表单中的插槽列表
        isExistSql: isExistSql.value, //是否存在检查sql,比如: XXX_CODE = '12345'
        ifSave: true, //是否提交表单时保存到数据库,否-暂存|是-保存
      });
    } else {
      /* 如果动态加载的实体类.ts存在,根据.ts文件中的方法来执行操作 */
      const [{ CreateAction }] = custImport.value['default']();
      const result = CreateAction(entityName.value, fnName);
      switch (result.action) {
        case 'go' /* 跳转页面 */:
          // 将对象转换为JSON字符串并保存到sessionStorage
          sessionStorage.setItem(
            `${result.params.Name}_params`,
            encodeURI(JSON.stringify(result.params)),
          );
          go(
            `/${result.url}/${encodeURI(JSON.stringify({ sName: result.params.Name, Name: result.params.Name }))}`,
          );
          break;
        case 'drawer' /* 打开侧边框 */:
          openDrawer(true, {
            isUpdate: false, //是新增还是编辑,false-新增|true-编辑
            entityName: entityName.value, //实体类名
            formJson: _crudFormSchema.value, //新增编辑的表单结构
            crudColSlots: objParams.value['crudColSlots'], //新增编辑的表单中的插槽列表
            isExistSql: isExistSql.value, //是否存在检查sql,比如: XXX_CODE = '12345'
            ifSave: true, //是否提交表单时保存到数据库,否-暂存|是-保存
          });
          break;
        case 'importModal' /* 打开导入Excel模态窗口 */:
          openImportModal(true, result.params);
          break;
        case 'ToPrint':
          ToPrint({});
          break;
      }
    }
  }
 
  /**
   * @description: 新增编辑返回成功方法
   * @param {*} d
   * @param {*} u
   * @return {*}
   */
  function handleSuccess(d, u) {
    if (CustFunc && isFunction(CustFunc)) {
      CustFunc({
        values: d,
      });
    }
    reload();
  }
 
  /**
   * @description: 弹出选择框选择成功后事件
   * @param {*} d
   * @param {*} u
   * @param {*} item
   * @return {*}
   */
  function handleItemSuccess(d, u, item) {
    /* 动态import实体名.ts的自定义方法 */
    try {
      import(
        `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}.ts`
      )
        .then((m) => {
          const [{ GetSelectSuccess: GetSelectSuccess2 }] = m.default();
          getForm().setFieldsValue(GetSelectSuccess2(d, u, objParams.value['ID']));
        })
        .catch(() => {
          getForm().setFieldsValue({
            ITEM_CODE: d.values['val'],
          });
        });
    } catch (e) {}
  }
 
  /**
   * @description: 弹出选择框
   * @param {*} item
   * @return {*}
   */
  function handleSelectItem(item) {
    /* 动态import实体名.ts的自定义方法 */
    try {
      import(
        `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}.ts`
      )
        .then((m) => {
          const [{ OpenSelectItem }] = m.default();
          OpenSelectItem(useModalInTableForm.value[item][1].openModal);
        })
        .catch(() => {
          useModalInTableForm.value[item][1].openModal(true, {
            title: '物料列表',
            schemas: [
              {
                field: 'ITEM_CODE',
                component: 'Input',
                label: '物料编码',
                colProps: {
                  span: 12,
                },
              },
            ],
            ItemColumns: [
              {
                title: t('物料编码'),
                dataIndex: 'ITEM_CODE',
                resizable: true,
                sorter: true,
                width: 200,
              },
              {
                title: t('物料名称'),
                dataIndex: 'ITEM_NAME',
                resizable: true,
                sorter: true,
                width: 180,
              },
            ],
            tableName: 'BAS_ITEM',
            rowKey: 'ITEM_CODE',
            searchInfo: { TABLE_NAME: 'BAS_ITEM' },
          });
        });
    } catch (e) {}
  }
 
  /**
   * @description: 弹出框确定返回
   * @param {*} d
   * @return {*}
   */
  function custSuccess(d) {
    reload();
  }
 
  /**
   * @description: 弹出框取消返回
   * @param {*} reload
   * @return {*}
   */
  function custCancel() {
    reload();
  }
 
  /**
   * @description: 各表单内弹出选择框选择成功后方法
   * @param {*} d
   * @param {*} u
   * @param {*} item
   * @return {*}
   */
  function handleEntSuccess(d, u, item) {
    /* 动态import实体名.ts的自定义方法 */
    try {
      var values = GetSelectSuccess(d, u);
      selectVals.value = values; //保存弹出框选择的结果
      let _val = {};
      d.returnFieldName.map((x) => {
        _val[x] = values[x];
      });
      useFormData.value[item][1].setFieldsValue(_val);
      /* 针对工单的方法 */
      if (d.returnFieldName.filter((x) => x == 'ROUTE_CODE') && item == 'prodinfo') {
        routeData.value = {
          nodes: [],
          edges: [],
        };
 
        init(currlf, selectVals.value['ROUTE_CODE']);
        const { transformModel, width, height } = unref(currlf).graphModel;
        transformModel.focusOn(565, 200, width, height);
      }
    } catch (e) {}
  }
 
  /**
   * @description: 打开表单中的模态框
   * @param {*} item
   * @return {*}
   */
  function handleCustClick(item) {
    OpenSelectCust(
      useModalData.value[item][1].openModal, //带入openModal方法
      item,
      openRvModal,
      selectVals,
    );
  }
 
  function RvItemSuccess(d, u) {
    RvcloseModal();
  }
 
  function ToPrint(params: {}) {
    openFullLoading();
    useWoFlowCard.getWoPickList(params['record']['ORDER_NO']).then((res) => {
      const _style = `
      #print-area {
        position: absolute;
        inset: 0;
        background-color: #fff;
 
        .item {
          display: flex;
          flex-direction: column;
          height: 100%;
          margin-right: 10px;
          margin-left: 10px;
          font-family: SimSun, "宋体", serif;
          page-break-after: always;
 
          .head {
          z-index: 1;
          width: 100%;
          background-color: azure;
          font-size: 20px;
          font-weight: bold;
          line-height: 100px;
          text-align: center;
        }
 
          .main {
            display: flex;
            flex: 1;
            justify-content: center;
            margin-top: 10px;
            padding: 15px;
            
            table {
              border-collapse: collapse;
              width: 100%;
            }
 
            table,
            th,
            td {
              border: solid 1px black;
            }
 
            tr > th {
              height: 60px;
            }
            .instore_td {
              border: 1px solid #000;
              font-size: 12px;
              line-height: 16px;
              text-align: center;
              word-break: break-all;
            }
            
            .instore_td2 {
              height: 60px;
              border: 1px solid #000;
              font-family: SimSun, "宋体", serif;
              font-size: 12px; /* 修改为你想要的字体大小 */
              line-height: 20px;
              text-align: center;
              word-break: break-all;
            }
 
            .material_table_td {
              border: 1px solid #000;
              font-size: 12px; 
              height: 25px;
              line-height: 18px;
              text-align: center;
              word-break: break-all;
            }
          }
 
          .footer {
            display: flex;
            margin-bottom: 15px;
            background-color: #eee;
            font-size: 12px;
            line-height: 21px;
            text-align: center;
          }
        }
        .line {
          width: 100px; /* 线条的长度 */
          height: 0;
          margin: 10px; /* 线条与其他元素的距离 */
          border-top: 1px solid black; /* 线条的颜色和宽度 */
        }
      }`;
 
      printJS({
        // 需要打印区域设置的Id
        printable: 'print-area',
        // 打印类型
        type: 'html',
        // 默认值为800,我们把把设置为100%
        maxWidth: '100%',
        // *代表应用所有样式,默认值为null,如果不设置,打印窗口则会忽略所有样式
        targetStyles: ['*'],
        // font_size: '9pt',
        scanStyles: false,
        style: `@page {size: auto; margin: 0mm;} html, ${_style}`,
      } as unknown as Configuration);
      closeFullLoading();
    });
  }
</script>