Ben Lin
2024-06-11 5d3661fd40aa5fe0f669edb18b1c2aed458fb4e8
src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
@@ -1,3 +1,11 @@
<!--
 * @Description: 工单管理页面
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-05-25 00:27:00
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-10 23:54:01
-->
<template>
  <div>
    <BasicTable @register="registerTable">
@@ -110,7 +118,7 @@
  import { useMessage } from '/@/hooks/web/useMessage';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useModal } from '/@/components/Modal';
  import { getListByPage } from '/@/api/tigerapi/system';
  import { SaveEntity, getListByPage } from '/@/api/tigerapi/system';
  import { GetSelectSuccess, OpenSelectItem, getFormSchema } from '/@/views/components/data';
  import LogicFlow from '@logicflow/core';
  import { getRouteData } from '/@/api/tigerapi/mes/router';
@@ -121,7 +129,7 @@
  import PackingNode from '/@/components/FlowChart/src/PackingNode';
  import RepairNode from '/@/components/FlowChart/src/RepairNode';
  import customEdge from '/@/components/FlowChart/src/customEdge';
  import { Snapshot, BpmnElement, Menu, DndPanel, SelectionSelect } from '@logicflow/extension';
  import { BpmnElement } from '@logicflow/extension';
  const { t } = useI18n();
  const ASteps = Steps;
@@ -131,7 +139,7 @@
  const mtitle = ref('工单列表');
  const dtlSlots = ref([] as any[]);
  const selectVals = ref({});
  const { createMessage } = useMessage();
  const { createMessage, createErrorModal } = useMessage();
  const [registerDrawer, { openDrawer }] = useDrawer();
  const compState = reactive({
    absolute: false,
@@ -171,7 +179,6 @@
  const formSchema = ref([] as FormSchema[]);
  const woSchema = ref([] as FormSchema[]);
  const prodSchema = ref([] as FormSchema[]);
  const rotSchema = ref([] as FormSchema[]);
  const isCustEl = ref({
    forminfo: false,
    woinfo: false,
@@ -262,6 +269,7 @@
    woSchema.value = getFormSchema('woinfo');
    prodSchema.value = getFormSchema('prodinfo');
    // rotSchema.value = getFormSchema('rotinfo');
    //工艺路线渲染图初始化
    if (lfInstance.value != null) {
      routeData.value = {
        nodes: [],
@@ -270,6 +278,7 @@
      const lf = unref(lfInstance)!;
      lf.render({});
    }
    selectVals.value['ROUTE_CODE'] = record.ROUTE_CODE;
    openCustModal(true, {
      isUpdate: true,
      ctype: cType,
@@ -279,13 +288,27 @@
      formElName: ['woinfo', 'prodinfo', 'rotinfo'], //表单插槽名称,支持多个表单
      RowKey: '',
      fnName: { BIZ_MES_WO_Config: 'SaveCofig' }, //保存方法名
      initFnName: {}, //初始化方法名
      initFnName: { BIZ_MES_WO_Config: 'initRoute' }, //初始化方法名
      isCustEl: isCustEl.value,
      ...record,
      others: routeData.value,
      values: record, //表单记录
    });
  }
  //下发
  /**
   * @description: 下发
   * @param {*} record
   * @return {*}
   */
  function handleRelease(record: Recordable) {
    if (record.STATUS == 2) {
      createErrorModal({
        title: t('警告'),
        content: t('工单已经下发,不能再下发!'),
        getContainer: () => document.body,
      });
      return;
    }
    cType.value = 'BIZ_MES_WO';
    dtlSlots.value = [
      {
@@ -307,20 +330,70 @@
      fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //保存方法名
      initFnName: {}, //初始化方法名
      isCustEl: isCustEl.value,
      ...record,
      values: record, //表单记录
    });
  }
  function custSuccess(d) {
    reload();
  /**
   * @description: 取消下发
   * @param {*} record
   * @return {*}
   */
  function handleUnRelease(record: Recordable) {
    if (record.STATUS == 0) {
      createErrorModal({
        title: t('警告'),
        content: t('工单是初始化状态,不能取消下发!'),
        getContainer: () => document.body,
      });
      return;
  }
  //取消下发
  function handleUnRelease(record: Recordable) {}
    record.STATUS = 0;
    SaveEntity(record, true, 'BIZ_MES_WO').then((action) => {
      if (action.IsSuccessed) {
        createMessage.success(t('已取消下发'));
        reload();
      } else {
        createMessage.success(t('取消下发操作失败'));
      }
    });
  }
  //暂停
  function handlePause(record: Recordable) {}
  //删除
  function handlePause(record: Recordable) {
    if (record.STATUS == 0) {
      createErrorModal({
        title: t('警告'),
        content: t('工单是初始化状态,不能暂停!'),
        getContainer: () => document.body,
      });
      return;
    }
    if (record.STATUS == 5) {
      createErrorModal({
        title: t('警告'),
        content: t('工单是完成状态,不能暂停!'),
        getContainer: () => document.body,
      });
      return;
    }
    record.STATUS = 4;
    SaveEntity(record, true, 'BIZ_MES_WO').then((action) => {
      if (action.IsSuccessed) {
        createMessage.success(t('已暂停'));
        reload();
      } else {
        createMessage.success(t('暂停操作失败'));
      }
    });
  }
  /**
   * @description: 删除
   * @param {*} record
   * @return {*}
   */
  function handleDelete(record: Recordable) {
    const apiAction = DeleteMesWo(record.ID);
    apiAction.then((action) => {
    DeleteMesWo(record.ID).then((action) => {
      if (action.IsSuccessed) {
        createMessage.success(t('已删除'));
        reload();
@@ -329,7 +402,20 @@
      }
    });
  }
  //点击打开物料列表框
  /**
   * @description: 弹出框确定返回
   * @param {*} d
   * @return {*}
   */
  function custSuccess(d) {
    reload();
  }
  /**
   * @description: 点击打开物料列表框
   * @return {*}
   */
  function handleSelectItem() {
    openItemModal(true, {
      title: '物料列表',
@@ -364,28 +450,45 @@
    });
  }
  /**
   * @description: 弹出选择物料框返回成功方法
   * @param {*} d
   * @param {*} u
   * @return {*}
   */
  function handleItemSuccess(d, u) {
    getForm().setFieldsValue({
      ITEM_CODE: d.values['val'],
    });
  }
  /* 各表单内弹出选择框选择成功后事件 */
  /**
   * @description: 各表单内弹出选择框选择成功后方法
   * @param {*} d
   * @param {*} u
   * @param {*} item
   * @return {*}
   */
  function handleEntSuccess(d, u, item) {
    var values = GetSelectSuccess(d, u, cType.value);
    selectVals.value = values; //保存弹出框选择的结果
    let _val = {};
    _val[d.returnFieldName] = values[d.returnFieldName];
    useFormData.value[item][1].setFieldsValue(_val);
    if (d.returnFieldName == 'ROUTE_CODE') {
    if (d.returnFieldName == 'ROUTE_CODE' && cType.value == 'BIZ_MES_WO_Config') {
      routeData.value = {
        nodes: [],
        edges: [],
      };
      init(selectVals.value['ID']);
      init(selectVals.value['ROUTE_CODE']);
    }
  }
  /* 弹出选择框 */
  /**
   * @description: 弹出选择框
   * @param {*} item
   * @return {*}
   */
  function handleCustClick(item) {
    //打开自定义模态框
    OpenSelectItem(
@@ -393,7 +496,7 @@
      cType.value,
      item,
      [openRvModal],
      selectVals.value['ID'],
      selectVals.value['ROUTE_CODE'],
    ); //[openRvModal], selectVals.value['ID']这是自定义参数,按实际需求
  }
  function RvItemSuccess(d, u) {}