From 8a12783afd1d6c4881d90e66bb0a52010a1598ae Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 27 二月 2025 00:52:57 +0800
Subject: [PATCH] 一些更改

---
 src/views/tigerprojects/system/lowcode/composition/LeftTable.vue |  510 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 453 insertions(+), 57 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/composition/LeftTable.vue b/src/views/tigerprojects/system/lowcode/composition/LeftTable.vue
index 03f5acd..3804aa2 100644
--- a/src/views/tigerprojects/system/lowcode/composition/LeftTable.vue
+++ b/src/views/tigerprojects/system/lowcode/composition/LeftTable.vue
@@ -7,26 +7,29 @@
  * @LastEditTime: 2024-10-21 23:03:27
 -->
 <template>
-  <div>
-    <Suspense class="w-1/4 xl:w-1/5">
-      <mainTable />
+  <div class="flex">
+    <div v-show="false">
+      <printTemplate1 :table-data="printData" :qrInstoreOrder="qrInstoreOrder"></printTemplate1>
+    </div>
+    <Suspense>
+      <div class="w-1/4 xl:w-4/5 h-full">
+        <mainTable />
+      </div>
     </Suspense>
     <Suspense>
-      <div class="w-3/4 xl:w-4/5 p-5">
-        <CarGridNav v-if="showNav" :configType="configType" :nodes="nodes">
-          <template #[item] v-for="item in otherSlots" :key="item">
-            <!-- 鑷畾涔夊唴瀹� -->
-            <div class="h-full" style="height: 400px">
-              <FlowChartView :data="routeData" @init="init" />
-            </div>
-          </template>
-        </CarGridNav>
-        <Config
-          v-if="showConfig"
-          :configType="configType"
-          :OtherTableName="OtherTableName"
-          @success="configSuccess"
-        />
+      <div class="w-1/4 xl:w-1/5 py-4 pr-4 h-full">
+        <div class="p-5 h-full" style="background-color: white">
+          <span class="mb-5 p-5" style="color: #0780b9; font-size: 16px">璇锋壂鐮佹墦鍗板叆搴撳崟</span>
+          <a-button type="primary" @click="ToPrint"> 鎵撳嵃 </a-button>
+          <QrCode
+            :value="qrCodeUrl"
+            :height="198"
+            :options="{ margin: 5 }"
+            ref="qrDiyRef"
+            :logo="LogoImg"
+          />
+        </div>
+        <span class="mb-5 p-5" style="color: #0780b9">{{ tag }}</span>
       </div>
     </Suspense>
     <Suspense>
@@ -63,24 +66,30 @@
 <script lang="ts" setup>
   import { useModal } from '@/components/Modal';
   import GeneralModal from '/@/views/components/GeneralModal.vue';
-  import CarGridNav from './CarGridNav.vue';
-  import Config from './Config.vue';
   import mainTable from './mainTable.vue';
+  import printTemplate1 from './printTemplate1.vue';
   import CustModal from '/@/views/components/CustModal.vue';
-  import { OpenCustModal, initRoute } from '../data';
-  import { Ref, onMounted, provide, ref } from 'vue';
-  import { FlowChartView } from '/@/components/FlowChart';
-  import { useRoute } from 'vue-router';
+  import { custOnChange, goByParams, OpenCustModal } from '../data';
+  import { Ref, h, onMounted, onUnmounted, provide, ref, unref } from 'vue';
+  import { useRoute, useRouter } from 'vue-router';
   import { BasicForm } from '/@/components/Form/index';
-  import { useTabs } from '/@/hooks/web/useTabs';
-  import { useMessage } from '/@/hooks/web/useMessage';
-  import LogicFlow from '@logicflow/core';
+  import { getEntity, GetEnum } from '/@/api/tigerapi/system';
+  import { isNullOrEmpty } from '/@/utils/is';
+  import { useLocale } from '/@/locales/useLocale';
+  import { Tag, Tooltip } from 'ant-design-vue';
+  import { getRoleButtons } from '/@/api/sys/menu';
+  import { QrCode } from '/@/components/Qrcode/index';
+  import LogoImg from '/@/assets/images/logo.png';
+  import printJS from 'print-js';
+  import { useWebSocketStore } from '/@/store/modules/websocket';
+  import { buildUUID } from '/@/utils/uuid';
 
   defineOptions({ name: '宸ュ崟宸ヨ壓缁戝畾' });
 
-  const { notification } = useMessage();
+  const usewebSocket = useWebSocketStore();
+  const { getLocale } = useLocale();
   const route = useRoute();
-  const { setTitle } = useTabs();
+  const { currentRoute } = useRouter();
   // const objParams = ref(JSON.parse(decodeURI(route.params?.id as string))); //ref(JSON.parse(history.state.obj))
   const routeParams = ref(JSON.parse(decodeURI(route.params?.id as string)));
   // 浠巗essionStorage涓鍙栧弬鏁板苟杞崲鍥炲璞�
@@ -94,29 +103,236 @@
   const otherSlots = ref<any[]>([]);
   const selectVals = ref({});
   const isMounted = ref(false);
-  const showNav = ref(false);
-  const showConfig = ref(false);
-  const configType = ref('');
-  const OtherTableName = ref('');
-  const nodes = ref([]);
-  const routeData = ref({
-    nodes: [],
-    edges: [],
+  const qrCodeUrl = ref(`PrintJS_${buildUUID()}`);
+  const tag = ref('');
+  const _columns = ref<any[]>([]);
+  const _searchFormSchema = ref<any[]>([]);
+  const _crudFormSchema = ref<any[]>([]);
+  const buttons = ref([]);
+  const printData = ref<any[]>([]);
+  const qrInstoreOrder = ref('YDRKD20241118001');
+  const AuthOption = ref({
+    BY_ORG: '',
+    BY_PROD: '',
+    BY_WH: '',
   });
   const keyFieldValues = ref<any>(null);
   const custImport = ref<any>(null);
   const [registerCust] = useModal();
   provide<Ref<any>>('objParams', objParams);
-  provide<Ref<any>>('selectedNodes', nodes);
-  setTitle(objParams.value.Title); //璁剧疆鏍囩椤垫爣棰�
-
-
-  // function handleAdd(){
-  //   console.log('handleAdd');
-  // }
+  provide<Ref<any>>('keyFieldValues', keyFieldValues);
+  provide<Ref<{}>>('AuthOption', AuthOption);
+  provide<Ref<any[]>>('_columns', _columns);
+  provide<Ref<any[]>>('_searchFormSchema', _searchFormSchema);
+  provide<Ref<any[]>>('_crudFormSchema', _crudFormSchema);
 
   onMounted(async () => {
     isMounted.value = false;
+
+    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'
+          },
+        ],
+      },
+      // {
+      //   id: '112',
+      //   Items: [
+      //     {
+      //       ID: 311,
+      //       ORDER_NO: 'YDSO241101002',
+      //       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: 312,
+      //       ORDER_NO: 'YDSO241101002',
+      //       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: 313,
+      //       ORDER_NO: 'YDSO241101002',
+      //       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',
+      //   Items: [
+      //     {
+      //       ID: 211,
+      //       ORDER_NO: 'YDSO241101002',
+      //       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: 212,
+      //       ORDER_NO: 'YDSO241101002',
+      //       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: 213,
+      //       ORDER_NO: 'YDSO241101002',
+      //       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'
+      //     },
+      //   ],
+      // },
+    ];
+
     /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
     try {
       custImport.value = await import(`../entityts/${entityName.value}.ts`);
@@ -124,29 +340,209 @@
         otherSlots.value = custImport.value['default']()[0]['GetSlots']();
       }
       isMounted.value = true;
+
+      const data = await getEntity({
+        sqlcmd: `CODE_NAME ='${objParams.value.Name}'`,
+        entityName: 'SYS_LOW_CODE',
+        order: '',
+      });
+      AuthOption.value.BY_ORG = data.Data.Items[0].BY_ORG;
+      AuthOption.value.BY_PROD = data.Data.Items[0].BY_PROD;
+      AuthOption.value.BY_WH = data.Data.Items[0].BY_WH;
+      var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON);
+      for (const i in searchForms) {
+        if (
+          !isNullOrEmpty(searchForms[i].componentProps) &&
+          !isNullOrEmpty(searchForms[i].componentProps.api) &&
+          searchForms[i].componentProps.api == 'GetEnum'
+        ) {
+          searchForms[i].componentProps.api = GetEnum;
+          searchForms[i].componentProps.params.name =
+            `${objParams.value.ID}+${searchForms[i].field}s`;
+          searchForms[i].componentProps.labelField = unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name';
+        }
+        if (
+          !isNullOrEmpty(searchForms[i].componentProps) &&
+          !isNullOrEmpty(searchForms[i].componentProps.api) &&
+          searchForms[i].componentProps.api == 'getEntity'
+        ) {
+          searchForms[i].componentProps.api = getEntity;
+          searchForms[i].componentProps.resultField = 'Data.Items';
+        }
+        if (searchForms[i].component == 'RangePicker') {
+        }
+        onChangeConfig(searchForms[i]);
+      }
+      _searchFormSchema.value = searchForms;
+
+      var objs = JSON.parse(data.Data.Items[0].BASE_FORM_JSON);
+      for (const i in objs) {
+        if (!isNullOrEmpty(objs[i].customRender)) {
+          const func = new Function(objs[i].customRender)();
+          objs[i].customRender = ({ record }) => {
+            let texts = func(record);
+            /* 濡傛灉鏄摼鎺ュ氨璺宠浆骞朵紶鍏ラ厤缃殑鍙傛暟 */
+            if (texts.isLink == 'Y') {
+              return h('a', [
+                h(
+                  'span',
+                  {
+                    onClick: () => {
+                      goByParams(texts.path, texts.params, go);
+                    },
+                  },
+                  texts.text,
+                ),
+              ]);
+            } else {
+              return h(Tooltip, { title: texts.text }, () =>
+                h(Tag, { color: texts.color }, () => texts.text),
+              );
+            }
+          };
+        }
+      }
+      _columns.value = objs;
+      buttons.value = await getRoleButtons(currentRoute.value.meta.menuCode as string);
     } catch (e) {
       console.log(e);
     }
   });
 
-  const currlf = ref(null) as Ref<LogicFlow | null>;
   /**
-   * @description: 宸ヨ壓璺嚎鍒濆鍖栵紝鐗规畩椤甸潰鑷畾涔夊唴瀹�
-   * @param {*} lf
+   * @description: Select 鑷畾涔塷nChange鏂规硶
+   * @param {*} obj
    * @return {*}
    */
-  async function init(lf, rotId) {
-    initRoute(lf, rotId, routeData, currlf, objParams.value.rotType);
+  function onChangeConfig(obj: any) {
+    if (obj.component == 'Select') {
+      var options = obj.componentProps.options;
+      var onChange = obj.componentProps.onChange;
+      obj.componentProps = ({ schema, tableAction, formActionType, formModel }) => {
+        return {
+          options: options,
+          onChange: (e) => custOnChange(e, onChange, objParams.value.ID),
+        };
+      };
+    }
   }
 
-
-
   /**
-   * @description: 淇濆瓨閰嶇疆鎴愬姛杩斿洖鏂规硶
-   * @return {*}
+   * @desc 鐢熸垚QR瀹屾垚
    */
-  function configSuccess() {
-    notification.success({ message: '鎴愬姛淇濆瓨琛屼负閰嶇疆鏁版嵁' });
+  function onQrcodeDone({ ctx }: any) {
+    if (ctx instanceof CanvasRenderingContext2D) {
+      // 棰濆缁樺埗
+      ctx.fillStyle = 'black';
+      ctx.font = '16px "寰蒋闆呴粦"';
+      ctx.textBaseline = 'bottom';
+      ctx.textAlign = 'center';
+      ctx.fillText('浣犲竻浣犲厛鎵�', 200, 380, 600);
+    }
+  }
+
+  const unsubscribe = usewebSocket.$subscribe((mutation, state) => {
+    tag.value = `鏀跺埌鎵撳嵃璇锋眰锛�${state.printTag}`;
+    if (state.printTag == qrCodeUrl.value) {
+      // printJS(state.printJson);
+      printData.value = state.printJson as unknown as any[];
+      usewebSocket.SetPrintTag('');
+      setTimeout(() => {
+        ToPrint();
+      }, 100);
+    }
+  });
+
+  // 褰撶粍浠跺嵏杞芥椂鍙栨秷璁㈤槄
+  onUnmounted(() => {
+    unsubscribe();
+  });
+
+  function ToPrint() {
+    const _style = `
+      #print-area {
+        position: absolute;
+        inset: 0;
+        background-color: #fff;
+
+        .item {
+          display: flex;
+          flex-direction: column;
+          page-break-after: always;
+          height: 100%;
+
+
+          .head {
+          z-index: 1;
+          width: 100%;
+          background-color: azure;
+          font-size: 22px;
+          font-weight: bold;
+          line-height: 100px;
+          text-align: center;
+        }
+
+          .main {
+            display: flex;
+            flex: 1;
+            justify-content: center;
+            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: 20px;
+              text-align: center;
+              word-break: break-all;
+            }
+
+            .material_table_td {
+              border: 1px solid #000;
+              font-size: 14px; 
+              line-height: 20px;
+              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;
+          }
+        }
+      }`;
+
+    printJS({
+      // 闇�瑕佹墦鍗板尯鍩熻缃殑Id
+      printable: 'print-area',
+      // 鎵撳嵃绫诲瀷
+      type: 'html',
+      // 榛樿鍊间负800锛屾垜浠妸鎶婅缃负100%
+      maxWidth: '100%',
+      // *浠h〃搴旂敤鎵�鏈夋牱寮忥紝榛樿鍊间负null锛屽鏋滀笉璁剧疆锛屾墦鍗扮獥鍙e垯浼氬拷鐣ユ墍鏈夋牱寮�
+      targetStyles: ['*'],
+      // font_size: '9pt',
+      scanStyles: false,
+      style: `@page {size: auto; margin: 0mm;} html, ${_style}`,
+    });
   }
 
   /**
@@ -197,7 +593,7 @@
   }
 </script>
 <style lang="less">
-.vben-page-wrapper .vben-page-wrapper-content {
+  .vben-page-wrapper .vben-page-wrapper-content {
     margin: 1px;
-}
+  }
 </style>

--
Gitblit v1.9.3