Ben Lin
2024-10-24 5a813f3b28f3cbf1db3a3657ccf83267c6e0d315
src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts
@@ -4,14 +4,14 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-10-22 09:56:57
 * @LastEditTime: 2024-10-23 23:55:56
 */
import { Ref, h, ref, render, unref } from 'vue';
import { Ref, unref } from 'vue';
import {
  DeleteWoRoute,
  GetWoPTree,
  SP_MES_PROD2WO,
  ProdRouteToWo,
  SP_MES_WO2CUST,
} from '/@/api/tigerapi/mes/router';
import { GetEnum, SaveEntity, convertToTree, getEntity } from '/@/api/tigerapi/system';
@@ -32,11 +32,14 @@
import { buildUUID } from '/@/utils/uuid';
import { mesApi } from '/@/api/tigerapi/mes/mesApi';
import { useProdRouteStore } from '/@/store/modules/prodRoute';
import { useWebSocketStore } from '/@/store/modules/websocket';
import { useGlobSetting } from '/@/hooks/setting';
const { t } = useI18n();
const { createErrorModal } = useMessage();
const useProdRoute = useProdRouteStore();
const { getLocale } = useLocale();
const globSetting = useGlobSetting();
function _default() {
  /* 定义变量 */
  const isNormal = (type: number) => type === 0;
@@ -328,10 +331,9 @@
                ? ents.Data.Items
                : JSON.parse(res.Data.Items[0].OPTION_1);
              /* 如果OPTION_1字段为空就把包装信息转JSON存到OPTION_1字段 */
              res.Data.Items[0].OPTION_1 = isNullOrEmpty(res.Data.Items[0].OPTION_1)
                ? JSON.stringify(ents.Data.Items)
                : res.Data.Items[0].OPTION_1;
            } /* 如果是组装上料 */
              res.Data.Items[0].OPTION_1 = JSON.stringify(result['BAS_PKG_DTL']);
            }
            /* 如果是组装上料 */
            if (res.Data.Items[0].ACT_TYPE == 2) {
              result['name'] = 'ItemCode';
              result['ItemCode'] = JSON.parse(res.Data.Items[0].OPTION_1);
@@ -548,33 +550,18 @@
            return;
          }
          /* 更新工单状态并生成工单的工艺路线 */
          UpdateWoStatus({
            UserId: useUserStore().getUserInfo.userId as string,
            WorkOrder: args[1]['CODE'],
            Status: -1,
            RouteStatus: 1,
            WoBatch: '',
            ActLine: '',
          ProdRouteToWo({
            rotId: d.values.id, wo: args[1]['CODE'],
            rotCode: '',
            options: {
              //根据据点查询,必需带这个参数
              UserId: useUserStore().getUserInfo.userId,
              ByOrg: true,
              CurOrg: useUserStore().getUserInfo.orgCode,
            }
          }).then((action) => {
            if (action.IsSuccessed) {
              SP_MES_PROD2WO({ rotId: d.values.id, wo: args[1]['CODE'] }).then((action) => {
                if (action.IsSuccessed) {
                  args[2]();
                } else {
                  UpdateWoStatus({
                    UserId: useUserStore().getUserInfo.userId as string,
                    WorkOrder: args[1]['CODE'],
                    Status: -1,
                    RouteStatus: 0,
                    WoBatch: '',
                    ActLine: '',
                  });
                  createErrorModal({
                    title: t('sys.api.errorTip'),
                    content: t(action.LocaleMsg),
                  });
                }
              });
              args[2]();
            } else {
              createErrorModal({
                title: t('sys.api.errorTip'),
@@ -874,7 +861,25 @@
              param.values['WORK_ORDER'] = param.others['WORK_ORDER'];
              param.values['ID'] = buildUUID();
              await AddOrEditLabelVarByWorkOrder(param.values as unknown as BAS_LABEL_VAR_WO);
              const apiaction = await AddOrEditLabelVarByWorkOrder(
                param.values as unknown as BAS_LABEL_VAR_WO,
              );
              if (apiaction.IsSuccessed) {
                const webSocketStore = useWebSocketStore();
                if (webSocketStore.GetSocketState == 1) {
                  webSocketStore.sendMessage(
                    `wsGetNew ${param.values['LABEL_ID']}_#_${param.values['WORK_ORDER']}`,
                  );
                }
              }
            case 'delete':
              const webSocketStore = useWebSocketStore();
              if (webSocketStore.GetSocketState == 1) {
                webSocketStore.sendMessage(
                  `wsGetNew ${param.values['LABEL_ID']}_#_${param.values['WORK_ORDER']}`,
                );
              }
              break;
          }
          resolve('OK');
        } catch (e) {