yyg1378265336
2025-02-26 61900b1f71f4c9048cbc48ed6f4b41ccfa1a6ce4
工具属性、工具信息页面初次编写
已添加2个文件
497 ■■■■■ 文件已修改
src/views/tigerprojects/system/lowcode/entityts/MES_TOOL.ts 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/system/lowcode/entityts/MES_TOOL_PROP.ts 352 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/system/lowcode/entityts/MES_TOOL.ts
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,145 @@
/*
 * @Description: ä¸è‰¯ä»£ç ç»„相关
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-08-04 14:20:02
 */
import { ActionItem, BasicColumn } from '/@/components/Table';
import { buildUUID } from '/@/utils/uuid';
import { useI18n } from '/@/hooks/web/useI18n';
import { isNullOrUnDef } from '/@/utils/is';
const { t } = useI18n();
function _default() {
  const ActionColumn: BasicColumn = {
    width: 100,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: 'right',
  };
  /**
   * @description: ä¸€äº›è‡ªå®šä¹‰æ–¹æ³•
   * @return {*}
   */
  const methods = {
    /**
     * @description: èŽ·å–æ–°å¢žæŒ‰é’®çš„è¡Œä¸º
     * @return {*}
     */
    CreateAction: (type: string) => {
      return {
        action: 'go', //drawer(打开左侧抽屉框) | go(跳转到新的页面) | edit(如果是表格可编辑页面就是自定义方法)
        url: 'MES_TOOL_PROP/High',
        params: {
          CODE: '0',
          ID: buildUUID(),
          Name: 'MES_TOOL_PROP',
          Title: '新增生产工具信息',
          // pCode: 'DFTG_CODE',
          IsID: false,
          ifSave: false,
          drawers: [{ name: 'MES_TOOL_PROP', code: 'TOOL_CODE', type: 'one', keyName: 'MES_TOOL_PROP' }], //drawers是右边弹出增改侧框的名字列表
        },
      };
    },
    /**
     * @description: æ“ä½œå­—段自定义按钮
     * @return {*}
     */
    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
      if (!isNullOrUnDef(data[0])) {
        data[0].onClick =Redact.bind(null, args, params);
      }
      return data;
    },
    /**
     * @description: å¼¹å‡ºé€‰æ‹©æ¡†æˆåŠŸè¿”å›žæ–¹æ³•
     * @param {*} d
     * @param {*} u
     * @return {*}
     */
    GetSelectSuccess: (d, u) => {
      return {
        ITEM_CODE: d.values['val'],
      };
    },
    /**
     * @description: å¼¹å‡ºé€‰æ‹©æ¡†æ‰“开方法
     * @param {Fn} openItemModal
     * @return {*}
     */
    OpenSelectItem: (openItemModal: Fn, ...args) => {
      openItemModal(true, {
        title: '物料列表',
        schemas: [
          {
            field: 'ITEM_CODE',
            component: 'Input',
            label: '物料编码',
            colProps: {
              span: 12,
            },
          },
        ],
        ItemColumns: [
          {
            title: t('物料编码'),
            dataIndex: 'ITEM_CODE',
            resizable: true,
            sorter: true,
            width: 200,
          },
          {
            title: t('物料名称'),
            dataIndex: 'ITEM_NAME',
            resizable: true,
            sorter: true,
            width: 180,
          },
        ],
        tableName: 'BAS_ITEM',
        rowKey: 'ITEM_CODE',
        searchInfo: { TABLE_NAME: 'BAS_ITEM' },
      });
    },
    GetUseForm: () => {
      return {};
    },
  };
  /* ä»¥ä¸‹æ˜¯å†…部方法,不export,供上面的方法调用 */
  /**
   * @description: è‡ªå®šä¹‰ç¼–辑方法
   * @param {Fn} args
   * @param {*} params
   * @return {*}
   */
  function Redact(args: Fn[], params: {}) {
    const param = {
      CODE: params['record']['TOOL_CODE'],
      ID: params['record']['ID'],
      Name: 'MES_TOOL_PROP',
      SessionName: 'MES_TOOL_PROP_update',
      Title: `编辑生产工具信息:${params['record']['TOOL_CODE']}`,
      pCode: 'TOOL_CODE',
      IsID: false,
      ifSave: false,
      drawers: [{ name: 'MES_TOOL_PROP', code: 'TOOL_CODE', type: 'one', keyName: 'MES_TOOL_PROP' }], //drawers是右边弹出增改侧框的名字列表
    };
    // å°†å¯¹è±¡è½¬æ¢ä¸ºJSON字符串并保存到sessionStorage
    sessionStorage.removeItem(`${param.SessionName}_params`);
    sessionStorage.setItem(`${param.SessionName}_params`, encodeURI(JSON.stringify(param)));
    args[5](
      `/MES_TOOL_PROP/High/${encodeURI(JSON.stringify({ sName: param.SessionName, Name: param.Name }))}`,
    );
  }
  return [methods, ActionColumn];
}
export default _default;
src/views/tigerprojects/system/lowcode/entityts/MES_TOOL_PROP.ts
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,352 @@
/*
 * @Description: ç”Ÿäº§å·¥å…·ä¿¡æ¯
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-07-04 11:21:28
 */
import { Ref, h, unref } from 'vue';
import { DeleteEntity, GetEnum, getEntity } from '/@/api/tigerapi/system';
import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table';
import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
import { buildUUID } from '/@/utils/uuid';
import { useUserStore } from '/@/store/modules/user';
import { formatToDateTime } from '/@/utils/dateUtil';
import { Tag } from 'ant-design-vue';
import { useLocale } from '/@/locales/useLocale';
import { useDrawer } from '/@/components/Drawer';
import { EditOperation, Search, custDel } from '../data';
const { getLocale } = useLocale();
function _default() {
  const ActionColumn: BasicColumn = {
    width: 80,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: undefined,
  };
  /**
   * @description: äº›è‡ªå®šä¹‰æ–¹æ³•
   * @return {*}
   */
  const methods = {
    /**
     * @description: èŽ·å–æ–°å¢žæŒ‰é’®çš„è¡Œä¸º
     * @return {*}
     */
    CreateAction: (type: string) => {
      return {
        action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
      };
    },
    /**
     * @description: æ“ä½œå­—段自定义按钮
     * @return {*}
     */
    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
      if (!isNullOrUnDef(data[1])) {
        data[1].popConfirm.confirm = custDel.bind(null, args, params);
      }
      return data;
    },
    /**
     * @description: é«˜çº§è¡¨å•和详情页面返回主页面的url
     * @return {*}
     */
    GetHomeUrl: () => {
      const param = { ID: 'MES_TOOL_PROP', colSlots: [], crudColSlots: [] };
      return `/MES_TOOL_PROP/LC/${encodeURI(JSON.stringify(param))}`;
    },
    GetBaseColumns: (type: string) => {
      return baseColumns[type];
    },
    GetSearchForm: (type: string) => {
      return searchForms[type];
    },
    GetCrudForm: (type: string) => {
      return crudForms[type];
    },
    //主表 ç”Ÿäº§å·¥å…·ä¿¡æ¯
    GetBaseForm: () => {
      return [
        {
          field: 'TOOL_CODE',
          label: '工具编码',
          component: 'Input',
          required: true,
          colProps: {
            span: 8,
          },
        },
        {
          label: '工具型号',
          field: 'TOOL_MODEL',
          required: true,
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '工具规格',
          field: 'TOOL_SPEC',
          required: true,
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '工具类型',
          field: 'TOOL_TYPE',
          required: true,
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '车间编码',
          field: 'WS_CODE',
          required: true,
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '备注',
          field: 'REMARK',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: 'ID',
          field: 'ID',
          component: 'Input',
          colProps: {
            span: 8,
          },
          show: false,
        },
      ];
    },
    /**
     * @description: èŽ·å–å¡ç‰‡å†…é…ç½®åˆ—è¡¨ï¼Œä»¥å¾ªçŽ¯æ˜¾ç¤ºå¤šä¸ªå¡ç‰‡å¹¶é…ç½®å¤šä¸ªæ’æ§½
     * @return {*}
     */
    GetBaseCards: (type: string) => {
      return [
        {
          name: 'BaseForm',
          slots: [],
          preIcons: {},
          title: '生产工具信息',
          entityName: 'MES_TOOL_PROP',
        },
        // {
        //   name: 'prodinfo',
        //   slots: ['addRot', 'setRot'],
        //   preIcons: { addRot: 'search|svg', setRot: 'config|svg' },
        //   title: '产品信息',
        // },
        // { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '工艺信息' },
      ];
    },
    /**
     * @description: èŽ·å–å³ä¾§è¾¹æ¡†use方法
     * @return {*}
     */
    GetUseDrawers: () => {
      return [{
        'MES_TOOL_PROP': useDrawer(),
      }];
    },
    /**
     * @description: èŽ·å–è¡¨æ ¼use列表
     * @param {string} type
     * @param {array} args
     * @return {*}
     */
    GetUseTables: (data: Ref<{}>, ...args) => {
      return {
        MES_TOOL_PROP: useTable({
          title: '列表信息',
          dataSource: data.value['MES_TOOL_PROP'],
          columns: baseColumns['MES_TOOL_PROP'],
          formConfig: {
            labelWidth: 140,
            schemas: searchForms['MES_TOOL_PROP'],
            submitFunc: () => Search('MES_TOOL_PROP', data, args[0]), //自定义查询提交按钮的方法,触发查询提交事件
          },
          useSearchForm: true,
          showTableSetting: false,
          bordered: true,
          canResize: true,
          showIndexColumn: false,
          actionColumn: {
            width: 130,
            title: '操作',
            dataIndex: 'action',
            slots: { customRender: 'action' },
            fixed: 'right',
          }, //自定义操作列
        })
      };
    },
    /**
     * @description: è¡¨æ ¼æŸ¥è¯¢å›žè°ƒï¼Œçˆ¶ç»„件中通过子组件触发的事件获取传入的值,做具体的查询逻辑实现
     * @param {*} d
     * @return {*}
     */
    FormSearch: (d) => {
      let data = {} as any;
      switch (d.type) {
        case 'MES_TOOL_PROP':
          data = d.data.value[d.type].filter(
            (item) =>
              item.DFT_CODE.includes(d.values.DFT_CODE) || item.DFT_NAME == d.values.DFT_NAME,
          );
          if (isNullOrEmpty(d.values.DFT_CODE) && isNullOrEmpty(d.values.DFT_NAME)) {
            data = d.data.value[d.type];
          }
          break;
      }
      return data;
    },
    KeyFieldValues: (val: string, id: string) => {
      return { DFTG_CODE: val };
    } /**
     * @description: è‡ªå®šä¹‰æ˜Žç»†è¡¨ä¸­ç¼–辑返回方法
     * @param {string} type
     * @param {*} d
     * @param {*} u
     * @return {*}
     */,
    EditOperation: (data: Ref<any[]>, d, u, item) => {
      //更新
      var _data = data.value[item].map((item) => {
        if (item['ID'] == d.ID)
          return {
            ...item,
            DFT_CODE: d.DFT_CODE,
            DFT_NAME: d.DFT_NAME,
            DFT_LEVEL: d.DFT_LEVEL,
            REMARK: d.REMARK,
          };
        return item;
      });
      EditOperation(data,d, u, item, _data);
    },
    /**
     * @description: èŽ·å–æ ‡é¢˜ä¿¡æ¯
     * @param {string} type
     * @return {*}
     */
    GetTitle: () => {
      return {
        pageTitle: '生产工具管理',
        pageContent: '这里可以添加和修改生产工具管理和生产工具属性管理。',
        tableTitle: {
          MES_TOOL_PROP: '生产工具管理',
        }
      };
    },
    GetUseForm: () => {
      return {};
    },
  };
  /* ä»¥ä¸‹æ˜¯å†…部方法,不export,供上面的方法调用 */
  // åˆ—表
  const baseColumns = {
    MES_TOOL_PROP: [
      {
        title: '工具编码',
        dataIndex: 'TOOL_CODE',
      },
      {
        title: '点检项目名称',
        dataIndex: 'PROP_NAME',
      },
      {
        title: '备注',
        dataIndex: 'REMARK',
      },
      {
        title: '更新时间',
        dataIndex: 'UPDATE_TIME',
      },
      {
        title: '更新人',
        dataIndex: 'UPDATE_USER',
      },
    ]
  }
  const searchForms = {
    MES_TOOL_PROP: [
      {
        label: '点检项目名称',
        field: 'PROP_NAME',
        component: 'Input',
        colProps: {
          span: 8,
        },
      },
    ] as FormSchema[],
  }
  //列表信息 --新增
  const crudForms = {
    MES_TOOL_PROP: [
      {
        field: 'TOOL_CODE',
        label: '工具编码',
        component: 'Input',
        required: true,
        colProps: {
          span: 24,
        },
        dynamicDisabled: ({ values }) => {
          return true;
        },
      },
      {
        label: '点检项目名称',
        field: 'PROP_NAME',
        component: 'Input',
        required: true,
        colProps: {
          span: 24,
        },
      },
      {
        label: '备注',
        field: 'REMARK',
        component: 'Input',
        colProps: {
          span: 24,
        },
      },
      {
        label: 'ID',
        field: 'ID',
        component: 'Input',
        colProps: {
          span: 24,
        },
        show: false,
      },
    ] as FormSchema[],
  }
  return [methods, ActionColumn];
}
export default _default;