Ben Lin
2024-06-09 38b2a8369513ebcc34c6dd01a176593b825fe71e
src/views/components/bizMesWo.ts
@@ -1,46 +1,202 @@
/* 工单相关自定义方法 */
import { FunctionType } from '/@/api/tigerapi/model/systemModel';
import { SaveEntity, getEntity } from '/@/api/tigerapi/system';
import { GetEnum, SaveEntity, getEntity } from '/@/api/tigerapi/system';
import { FormSchema } from '/@/components/Table';
import { useUserStore } from '/@/store/modules/user';
import { useI18n } from '/@/hooks/web/useI18n';
import { uploadApi } from '/@/api/sys/upload';
import { notification } from 'ant-design-vue';
import { useLocale } from '/@/locales/useLocale';
import { unref } from 'vue';
const { t } = useI18n();
export const getFns: Record<string, FunctionType> = {
const { getLocale } = useLocale();
/* 自定义方法 */
export const getWoFns: Record<string, FunctionType> = {
  handleSubmit: async (e, ...args) => {
    try {
      const values = await args[0][0].validate();
      args[0][1]({ confirmLoading: true });
      values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
      //   const apiAction = SaveEntity(values, e, 'MES_LINE');
      //   apiAction.then((action) => {
      //     if (action.IsSuccessed) {
      //       args[0][2]();
      //       args[0][3]('success');
      //     }
      //   });
      args[0][2]();
      args[0][3]('success');
    } finally {
      args[0][1]({ confirmLoading: false });
    }
    const values = await args[0][0].validate();
    return new Promise((resolve, reject) => {
      try {
        args[0][1]({ confirmLoading: true });
        values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
        //   const apiAction = SaveEntity(values, e, 'MES_LINE');
        //   apiAction.then((action) => {
        //     if (action.IsSuccessed) {
        //       args[0][2]();
        //       args[0][3]('success');
        //     }
        //   });
        args[0][2]();
        args[0][3]('success');
        resolve(true);
      } catch {
        reject(false);
      } finally {
        args[0][1]({ confirmLoading: false });
      }
    });
  },
  rvSubmit: (e, ...args) => {
    try {
      args[0][0]({ confirmLoading: true });
      args[0][1]();
      args[0][2]('success');
    } finally {
      args[0][0]({ confirmLoading: false });
    }
    return new Promise((resolve, reject) => {
      try {
        args[0][0]({ confirmLoading: true });
        args[0][1]();
        args[0][2]('success');
        resolve(true);
      } catch {
        reject(false);
      } finally {
        args[0][0]({ confirmLoading: false });
      }
    });
  },
  //工单配置保存方法
  SaveCofig: (e, ...args) => {
    return new Promise((resolve, reject) => {
      try {
        const xx = e['prodinfo'];
        resolve(true);
      } catch {
        reject(false);
      } finally {
        args[0][0]({ confirmLoading: false });
      }
    });
  },
  //工单下发保存方法
  SaveWoBatch: (e, ...args) => {
    return new Promise((resolve, reject) => {
      try {
        const xx = e['forminfo'];
        resolve(true);
      } catch {
        reject(false);
      } finally {
        args[0][0]({ confirmLoading: false });
      }
    });
  },
};
export const woCfgformSchema: FormSchema[] = [
  {
    field: 'field1',
    field: 'ORDER_NO',
    component: 'Input',
    label: '工单号',
    colProps: {
      span: 8,
    },
    componentProps: {
      placeholder: '请输入工单号',
      onChange: (e: any) => {
        console.log(e);
      },
    },
    dynamicDisabled: true,
  },
  {
    field: 'ORDER_TYPE',
    component: 'Select',
    label: '工单类型',
    colProps: {
      span: 8,
    },
    defaultValue: 'Normal',
    componentProps: {
      options: [
        {
          label: '正常',
          value: 'Normal',
        },
        {
          label: '返工',
          value: 'Rework',
        },
      ],
    },
    dynamicDisabled: true,
  },
  {
    field: 'PLAN_QTY',
    component: 'Input',
    label: '计划数量',
    colProps: {
      span: 8,
    },
    dynamicDisabled: true,
  },
];
export const prodCfgformSchema: FormSchema[] = [
  {
    field: 'ITEM_CODE',
    component: 'Input',
    label: '物料编码',
    required: true,
    colProps: {
      span: 12,
    },
    componentProps: {
      placeholder: '请输入物料编码',
      onChange: (e: any) => {
        console.log(e);
      },
    },
    dynamicDisabled: true,
  },
  {
    field: 'ITEM_TYPE',
    component: 'Input',
    label: '物料类型',
    colProps: {
      span: 12,
    },
  },
  {
    label: '工艺路线',
    field: 'ROUTE_CODE',
    component: 'Input',
    required: true,
    colProps: {
      span: 12,
    },
  },
  {
    field: 'addRot',
    component: 'Input',
    label: '1',
    colSlot: 'addRot',
    defaultValue: 'MES_ROUTE',
    colProps: {
      span: 1,
    },
  },
  {
    field: 'setRot',
    component: 'Input',
    label: '1',
    colSlot: 'setRot',
    defaultValue: 'MES_ROUTE',
    colProps: {
      span: 1,
    },
  },
  {
    field: 'fieldsc',
    component: 'Upload',
    label: '打印模板',
    colProps: {
      span: 10,
    },
    rules: [{ required: true, message: '请选择上传文件' }],
    componentProps: {
      api: uploadApi,
    },
  },
];
export const xxCfgformSchema: FormSchema[] = [
  {
    field: 'field10',
    component: 'Input',
    label: '字段1',
    colProps: {
@@ -54,7 +210,7 @@
    },
  },
  {
    field: 'field2',
    field: 'ROUTE_CODE',
    component: 'Input',
    label: '字段2',
    colProps: {
@@ -62,7 +218,17 @@
    },
  },
  {
    field: 'field3',
    field: 'add',
    component: 'Input',
    label: '1',
    colSlot: 'add',
    defaultValue: 'MES_ROUTE',
    colProps: {
      span: 1,
    },
  },
  {
    field: 'field12',
    component: 'DatePicker',
    label: '字段3',
    colProps: {
@@ -129,7 +295,7 @@
  {
    field: 'fieldsc',
    component: 'Upload',
    label: '上传打印模板',
    label: '打印模板',
    colProps: {
      span: 10,
    },
@@ -148,10 +314,12 @@
  };
}
export function woCustFn(openItemModal: Fn, slotName: string, others: Fn[], ...args) {
/* 自定义模态框打开方法 */
export function woCustFn(openModal: Fn, slotName: string, others: Fn[], ...args) {
  switch (slotName) {
    case 'add':
      openItemModal(true, {
    case 'addRot':
      openModal(true, {
        title: '工艺路线列表',
        schemas: [
          {
@@ -185,12 +353,13 @@
      });
      break;
    case 'set':
    case 'setRot':
      //   notification.success({
      //     message: '点击了设置按钮',
      //     description: `OK`,
      //     duration: 3,
      //   });
      others[0](true, { rotId: args[0][0], slotName: 'set' });
      others[0](true, { rotId: args[0][0], slotName: slotName });
      break;
    default:
      () => {};