Ben Lin
2024-06-24 c8f8a9c645f7857859a9d56fac96192d994be70b
src/views/tigerprojects/system/lowcode/composition/RouteAction.vue
@@ -4,7 +4,7 @@
 * @version: 
 * @Date: 2024-06-20 12:13:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-21 00:11:00
 * @LastEditTime: 2024-06-24 10:56:19
-->
<template>
  <Card title="操作">
@@ -20,11 +20,20 @@
<script lang="ts" setup>
  import { Card, CardGrid } from 'ant-design-vue';
  import Icon from '@/components/Icon/Icon.vue';
  import { RouteToProd } from '/@/api/tigerapi/mes/router';
  import { RouteToCust, RouteToProd } from '/@/api/tigerapi/mes/router';
  import GeneralModal from '/@/views/components/GeneralModal.vue';
  import { useModal } from '/@/components/Modal';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { Ref, inject, ref, watch } from 'vue';
  import { isNullOrEmpty } from '/@/utils/is';
  import { useTabs } from '/@/hooks/web/useTabs';
  import { useMessage } from '/@/hooks/web/useMessage';
  const { refreshPage } = useTabs();
  const { createErrorModal } = useMessage();
  // const props = defineProps({
  //   prodCode: { type: String },
  // });
  const { t } = useI18n();
  const [register, { openModal }] = useModal();
  interface NavItem {
@@ -34,20 +43,32 @@
    url: string;
    action: string;
  }
  const Prod_Code = inject('prodCode') as Ref<string>;
  // watch(
  //   () => Prod_Code,
  //   (v) => {
  //     if (v !== Prod_Code.value) {
  //       Prod_Code.value = isNullOrEmpty(v) ? Prod_Code.value : v;
  //     }
  //   },
  //   { deep: true },
  // );
  // 快捷导航
  const navItems: NavItem[] = [
    {
      title: '添加工艺路线',
      icon: 'ion:home-outline',
      title: '添加产品工艺路线',
      icon: 'add_green|svg',
      color: '#1fdaca',
      url: '/workbench',
      url: '/addRoute',
      action: 'addRoute',
    },
    {
      title: '添加客户',
      icon: 'materialreq|svg',
      title: '添加客户工艺路线',
      icon: 'add_customer|svg',
      color: '#bf0c2c',
      url: '/materialreq',
      url: '/addCustomer',
      action: 'addCustomer',
    },
    // {
@@ -88,41 +109,40 @@
    // },
  ];
  function changeItem(action) {
    if (action == 'addRoute') {
      openModal(true, {
        title: '工艺路线列表',
        schemas: [
          {
            field: 'ROT_CODE',
            component: 'Input',
            label: '工艺路线编码',
            colProps: {
              span: 12,
            },
    openModal(true, {
      title: '工艺路线列表',
      schemas: [
        {
          field: 'ROT_CODE',
          component: 'Input',
          label: '工艺路线编码',
          colProps: {
            span: 12,
          },
        ],
        ItemColumns: [
          {
            title: t('工艺路线编码'),
            dataIndex: 'ROT_CODE',
            resizable: true,
            sorter: true,
            width: 200,
          },
          {
            title: t('工艺路线名称'),
            dataIndex: 'ROT_NAME',
            resizable: true,
            sorter: true,
            width: 180,
          },
        ],
        tableName: 'MES_ROUTE',
        rowKey: 'ROT_CODE',
        returnFieldName: 'ROUTE_CODE', //返回值要赋值的字段名称
        searchInfo: { TABLE_NAME: 'MES_ROUTE' },
      });
    }
        },
      ],
      ItemColumns: [
        {
          title: t('工艺路线编码'),
          dataIndex: 'ROT_CODE',
          resizable: true,
          sorter: true,
          width: 200,
        },
        {
          title: t('工艺路线名称'),
          dataIndex: 'ROT_NAME',
          resizable: true,
          sorter: true,
          width: 180,
        },
      ],
      tableName: 'MES_ROUTE',
      rowKey: 'ROT_CODE',
      returnFieldName: 'ROUTE_CODE', //返回值要赋值的字段名称
      searchInfo: { TABLE_NAME: 'MES_ROUTE' },
      which: action,
    });
  }
  /**
@@ -131,12 +151,24 @@
   * @param {*} u
   * @return {*}
   */
  function handleSuccess(d, u) {
  async function handleSuccess(d, u) {
    if (isNullOrEmpty(Prod_Code.value)) {
      createErrorModal({
        title: t('sys.api.errorTip'),
        content: '产品为空,不能添加工艺路线,请点击左侧选择产品',
      });
      return;
    }
    let codes = d.values.id.split(',');
    let eintity: any[] = [];
    var i;
    for (i = 0; i < codes.length; i++) {
      RouteToProd({ rotId: codes[i], prodCode: 'K5811AA015007' }).then(() => {});
      if (d.which == 'addRoute') {
        await RouteToProd({ rotId: codes[i], prodCode: Prod_Code.value });
      } else {
        await RouteToCust({ rotId: codes[i], prodCode: Prod_Code.value, custCode: '' });
      }
    }
    await refreshPage();
  }
</script>