Ben Lin
2025-03-05 abbc201b41a1a25a19ccf7cff8df633dadcf5d88
src/views/tigerprojects/system/lowcode/entityts/BIZ_MES_WO.ts
@@ -4,15 +4,13 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-07-21 18:40:06
 * @LastEditTime: 2024-10-23 20:48:14
 */
import { Ref, h, ref, render, unref } from 'vue';
import { GetEnum, SaveEntity, convertToTree, getEntity } from '/@/api/tigerapi/system';
import { useLocale } from '/@/locales/useLocale';
import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
import { useI18n } from '/@/hooks/web/useI18n';
import { NavItem } from '/@/api/tigerapi/model/basModel';
import { useMessage } from '/@/hooks/web/useMessage';
import { useModal } from '/@/components/Modal';
import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table';
@@ -22,24 +20,16 @@
import { CustModalParams, FunctionType } from '/@/api/tigerapi/model/systemModel';
import { SaveMesBatchWo } from '/@/api/tigerapi/mes/wo';
import { useForm } from '/@/components/Form/index';
import { uploadApi } from '/@/api/sys/upload';
import { initRoute } from '../data';
import { SP_MES_PROD2WO } from '/@/api/tigerapi/mes/router';
import { cloneDeep } from 'lodash-es';
import { useProdRouteStore } from '/@/store/modules/prodRoute';
import { Tag, Tooltip } from 'ant-design-vue';
const { t } = useI18n();
const { createErrorModal } = useMessage();
const { getLocale } = useLocale();
function _default() {
  /* 定义变量 */
  const isNormal = (type: number) => type === 0;
  const isScan = (type: number) => type === 1;
  const isAssy = (type: number) => type === 2;
  const isTest = (type: number) => type === 3;
  const isAudit = (type: number) => type === 4;
  const isPrint = (type: number) => type === 5;
  const isPackage = (type: number) => type === 6;
  const ActionColumn: BasicColumn = {
    width: 220,
    width: 180,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
@@ -54,10 +44,104 @@
     * @description: 获取新增按钮的行为
     * @return {*}
     */
    CreateAction: (fnName: string) => {
      return {
        action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
      };
    CreateAction: (type: string, fnName: string) => {
      let action = {} as any;
      switch (fnName) {
        case 'ImportExcel':
          action = {
            action: 'importModal', //drawer(打开左侧抽屉框) | go(跳转到新的页面) | modal(打开模态窗口) | importModal(打开导入模态窗口) | ToPrint(打印功能)
            params: {
              tmpHeader: ['工单号', '计划日期', '计划数量'] /* 下载模板的标题字段 */,
              filename: '工单计划模板.xlsx' /* 下载模板的文件名 */,
              entityName: 'BIZ_MES_WO_BATCH' /* 导入表的表名 */,
              checkJson: ['ORDER_NO', 'PLAN_DATE', 'PLAN_QTY'] /* 导入表需要检查的字段列表 */,
              where: ['ORDER_NO'] /* 导入表需要查询的字段列表 */,
              typeFullName:
                'Tiger.IBusiness.MES.IImportWoPlan,Tiger.IBusiness.MES' /* 导入的方法全名,通用导入用这个:Tiger.IBusiness.ICommonImportExcel,Tiger.IBusiness */,
              baseColumns: [
                /* 导入时界面显示数据的字段 */
                {
                  title: '工单号',
                  dataIndex: 'ORDER_NO',
                  ifShow: true,
                  width: 180,
                },
                // {
                //   title: '工单批次号',
                //   dataIndex: 'BATCH_NO',
                //   ifShow: true,
                //   width: 180,
                //   // customRender: ({ record }) => {
                //   //   record.BATCH_NO = record.ORDER_NO+'-01'
                //   //   return record.BATCH_NO
                //   // },
                // },
                {
                  title: '计划日期',
                  dataIndex: 'PLAN_DATE',
                  ifShow: true,
                  width: 180,
                },
                {
                  title: '计划数量',
                  dataIndex: 'PLAN_QTY',
                  ifShow: true,
                  width: 100,
                },
                {
                  title: '处理方式',
                  dataIndex: 'VALIDATION_TYPE',
                  ifShow: true,
                  width: 100,
                  customRender: ({ record }) => {
                    const status = record.VALIDATION_TYPE;
                    var text = '';
                    var color = 'green';
                    if (status == '异常') {
                      color = 'red';
                      text = status;
                    } else if (status == '更新') {
                      color = 'orange';
                      text = status;
                    } else {
                      text = status;
                    }
                    return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text));
                  },
                },
                {
                  title: '处理提示',
                  dataIndex: 'VALIDATION_RESULT',
                  ifShow: true,
                  width: 280,
                  customRender: ({ record }) => {
                    const status = record.VALIDATION_TYPE;
                    var text = record.VALIDATION_RESULT;
                    var color = 'green';
                    if (status == '异常') {
                      color = 'red';
                    } else if (status == '更新') {
                      color = 'orange';
                    }
                    return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text));
                  },
                },
              ],
            },
          };
          break;
        case 'ToPrint':
          action = {
            action: 'ToPrint', //drawer(打开左侧抽屉框) | go(跳转到新的页面) | modal(打开模态窗口) | importModal(打开导入模态窗口) | ToPrint(打印功能)
          };
        break;
        default:
          action = {
            action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面) | modal(打开模态窗口) | importModal(打开导入模态窗口) | ToPrint(打印功能)
          };
          break;
      }
      return action;
    },
    /**
     * @description: 操作字段自定义按钮
@@ -76,6 +160,9 @@
        if (x.name == 'handleRelease') {
          x.onClick = handleRelease.bind(null, args, params);
          x.tooltip = '下发';
        }
        if (x.name == 'ToPrint') {
          x.tooltip = '打印流程卡';
        }
      });
      return data;
@@ -99,6 +186,14 @@
          showActionButtonGroup: false,
        }),
        prodinfo: useForm({
          labelWidth: 120,
          schemas: prodCfgformSchema,
          actionColOptions: {
            span: 24,
          },
          showActionButtonGroup: false,
        }),
        tmpinfo: useForm({
          labelWidth: 120,
          schemas: prodCfgformSchema,
          actionColOptions: {
@@ -255,10 +350,21 @@
          });
          break;
        case 'set':
        case 'setRot':
          openRvModal(true, { rotId: selectVals.value['ROUTE_CODE'], slotName: slotName });
          break;
        case 'setRot':
          break;
      }
    },
    /**
     * @description: 获取标题信息
     * @param {string} type
     * @return {*}
     */
    GetTitle: () => {
      return {
        importTitle: '工单计划导入' /* 打开模态窗口显示的标题 */,
      };
    },
  };
@@ -280,12 +386,17 @@
        try {
          const form = param.values['prodinfo'];
          const wo = param.values['mValues'];
          wo.ROUTE_STATUS = 1;
          wo.ROUTE_CODE = form.ROUTE_CODE;
          SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => {
          const _wo = cloneDeep(wo);
          _wo.ROUTE_STATUS = 1;
          _wo.ROUTE_CODE = form.ROUTE_CODE;
          SaveEntity(_wo, true, 'BIZ_MES_WO').then((action) => {
            if (action.IsSuccessed) {
              SP_MES_PROD2WO({ rotId: form.ROT_ID, wo: wo.ORDER_NO });
              resolve(action);
              SP_MES_PROD2WO({ rotId: form.ROT_ID, wo: wo.ORDER_NO }).then((res) => {
                if (!res.IsSuccessed) {
                  SaveEntity(wo, true, 'BIZ_MES_WO');
                }
                resolve(res);
              });
            } else {
              reject(action);
            }
@@ -305,8 +416,7 @@
        try {
          const form = param.values['forminfo'];
          const wo = param.values['mValues'];
          wo.ROUTE_CODE = form.ROUTE_CODE;
          wo.STATUS = 2;
          wo.STATUS = wo.STATUS == 3 ? wo.STATUS : 2;
          let input: SaveWoBatchInput = {
            Wo: wo,
            WoBatch: {
@@ -325,7 +435,7 @@
              CUST_CODE: wo.CUST_CODE,
              FACTORY: wo.FACTORY,
              WS_CODE: wo.WS_CODE,
              ACT_LINE: form.PLAN_LINE,
              ACT_LINE: form.ACT_LINE,
              STD_WORKER_QTY: wo.STD_WORKER_QTY,
              ACT_WORKER_QTY: wo.ACT_WORKER_QTY,
              RELEASE_TIME: new Date(),
@@ -342,6 +452,7 @@
              ACT_END_TIME: wo.ACT_END_TIME,
              BATCH_NO: '',
            },
            IfToCust: form.IfToCust,
          };
          SaveMesBatchWo(input).then((action) => {
            resolve(action);
@@ -374,6 +485,7 @@
      keyFieldValues: { ORDER_NO: params['record']['ORDER_NO'] },
      colSlots: params['colSlots'].value,
      SessionName: 'BIZ_MES_WO_BATCH_update',
      ifSave: false,
    };
    // 将对象转换为JSON字符串并保存到sessionStorage
    sessionStorage.removeItem(`${id.SessionName}_params`);
@@ -388,26 +500,37 @@
   * @return {*}
   */
  function handleConfig(args, params: Recordable) {
    const openCustModal = args[7];
    // rotSchema.value = getFormSchema('rotinfo');
    params['routeData'].value = {
      nodes: [],
      edges: [],
    const go = args[5];
    const id = {
      ID: params['record'].ID,
      Name: 'WoRouteBinding',
      CODE: params['record'].ORDER_NO,
      Title: `工单[${params['record'].ORDER_NO}]工艺绑定`,
      colSlots:
        params['colSlots'].value /* 表格内的查询表单字段的插槽列表,一般用于弹出选择框按钮 */,
      crudColSlots: {
        BAS_PKG_DTL: ['BAS_LABEL_TEMP1add'],
        ItemCode: ['BAS_CODE_RULE1add'],
      } /* 增删改表单字段的插槽列表,一般用于弹出选择框按钮 */,
      OtherTableName: [
        'BAS_PKG_DTL',
        'ItemCode',
      ] /* 自定义显示列表的表名,跟上面增删改的表名一致,有多个就放列表中 */,
      record: params['record'],
      dense: true,
      pageTitle: `工单工艺绑定`,
      pageContent: `这里是管理工单的工艺绑定,一个工单可以绑定一个工艺路线,并可以保存为客户专用的工艺路线`,
      SessionName: 'WoRouteBinding_update',
      ifSave: false,
      rotType: 'Wo',
    };
    initRoute(params['currlf'], params['record'].ROUTE_CODE, params['routeData'], params['currlf']);
    params['selectVals'].value['ROUTE_CODE'] = params['record'].ROUTE_CODE;
    openCustModal(true, {
      isUpdate: true,
      ctype: 'BIZ_MES_WO_Config',
      title: '工艺配置',
      width: '1200px',
      formEl: params['useFormData'].value, //如果是多个表单,增加多个插槽
      formElName: ['woinfo', 'prodinfo', 'rotinfo'], //表单插槽名称,支持多个表单
      RowKey: '',
      fnName: 'SaveCofig', //保存方法名
      others: params['routeData'].value,
      values: params['record'], //表单记录
    });
    // 将对象转换为JSON字符串并保存到sessionStorage
    sessionStorage.removeItem(`${id.SessionName}_params`);
    sessionStorage.setItem(`${id.SessionName}_params`, encodeURI(JSON.stringify(id)));
    /* 设置标志,以根据缓存数据取数据 */
    const useProdRoute = useProdRouteStore();
    useProdRoute.setChangeToCPPage(true);
    go(`/WoRouteBinding/CP/${encodeURI(JSON.stringify({ sName: id.SessionName, Name: id.Name }))}`);
  }
  /**
@@ -454,8 +577,8 @@
      },
    },
    {
      label: '计划产线',
      field: 'PLAN_LINE',
      label: '实际产线',
      field: 'ACT_LINE',
      component: 'ApiSelect',
      required: true,
      colProps: {
@@ -470,34 +593,44 @@
      },
    },
    {
      label: '工艺路线',
      field: 'ROUTE_CODE',
      component: 'Input',
      required: true,
      field: 'IfToCust',
      component: 'Switch',
      label: '是否保存工艺路线到客户',
      defaultValue: true,
      colProps: {
        span: 22,
        span: 8,
      },
      labelWidth: 200,
    },
    {
      field: 'add',
      component: 'Input',
      label: '1',
      colSlot: 'add',
      defaultValue: 'MES_ROUTE',
      colProps: {
        span: 1,
      },
    },
    {
      field: 'set',
      component: 'Input',
      label: '1',
      colSlot: 'set',
      defaultValue: 'MES_ROUTE',
      colProps: {
        span: 1,
      },
    },
    // {
    //   label: '工艺路线',
    //   field: 'ROUTE_CODE',
    //   component: 'Input',
    //   required: true,
    //   colProps: {
    //     span: 22,
    //   },
    // },
    // {
    //   field: 'add',
    //   component: 'Input',
    //   label: '1',
    //   colSlot: 'add',
    //   defaultValue: 'MES_ROUTE',
    //   colProps: {
    //     span: 1,
    //   },
    // },
    // {
    //   field: 'set',
    //   component: 'Input',
    //   label: '1',
    //   colSlot: 'set',
    //   defaultValue: 'MES_ROUTE',
    //   colProps: {
    //     span: 1,
    //   },
    // },
  ];
  const woCfgformSchema: FormSchema[] = [