Ben Lin
2024-06-23 200eb764e83c7a77defeaf98130801d300dbee5d
src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts
@@ -4,23 +4,18 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-22 00:34:46
 * @LastEditTime: 2024-06-23 18:28:00
 */
import { DeleteEntity } from '/@/api/tigerapi/system';
import { ActionItem } from '/@/components/Table';
import { Ref } from 'vue';
import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
import { ActionItem, BasicColumn } from '/@/components/Table';
import { isNullOrEmpty } from '/@/utils/is';
import { buildUUID } from '/@/utils/uuid';
import { useUserStore } from '/@/store/modules/user';
import { formatToDateTime } from '/@/utils/dateUtil';
function _default() {
  /**
   * @description: 产品绑定工艺路线操作字段自定义按钮
   * @return {*}
   */
  function ActionItem(params: Recordable<any>, data, ...args): ActionItem[] {
    data[1].popConfirm.confirm = custDel.bind(null, args[1], params);
    return data;
  }
function _default(): any[] {
  /**
   * @description: 自定义删除方法
   * @param {Fn} args
@@ -46,17 +41,282 @@
      });
    }
  }
  /**
   * @description: 公用编辑方法
   * @param {Fn} fn
   * @param {*} params
   * @return {*}
   */
  function editRecord(fn: Fn, params: {}) {
    fn(true, params);
  }
  return [ActionItem];
  const ActionColumn: BasicColumn = {
    width: 80,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: undefined,
  };
  const methods = {
    /**
     * @description: 获取新增按钮的行为
     * @return {*}
     */
    CreateAction: () => {
      return {
        action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
      };
    },
    /**
     * @description: 产品绑定工艺路线操作字段自定义按钮
     * @return {*}
     */
    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
      data[1].popConfirm.confirm = custDel.bind(null, args, params);
      return data;
    },
    /**
     * @description: 自定义明细表中编辑返回方法
     * @param {string} type
     * @param {*} d
     * @param {*} u
     * @return {*}
     */
    EditeOperation: (data: Ref<any[]>, d, u) => {
      if (u.isUpdate) {
        //更新
        var _data = data.value.map((item) => {
          if (item['ID'] == d.ID)
            return {
              ...item,
              PKG_CODE: d.PKG_CODE,
              PKG_LEVEL: d.PKG_LEVEL,
              PKG_QTY: d.PKG_QTY,
              LABEL_CODE: d.LABEL_CODE,
              REMARK: d.REMARK,
            };
          return item;
        });
        data.value = _data;
      } else {
        //新增
        d.ID = buildUUID();
        d.CREATE_USER = useUserStore().getUserInfo.userId as string;
        d.UPDATE_TIME = formatToDateTime(new Date());
        d.UPDATE_USER = useUserStore().getUserInfo.userId as string;
        var _data2: any[] = [];
        if (!isNullOrEmpty(data.value)) {
          _data2 = data.value.map((item) => {
            return item;
          });
        }
        _data2.push(d);
        data.value = _data2;
      }
    },
    GetHomeUrl: () => {
      return `/BAS_PKG_RULE/LC/${encodeURI(JSON.stringify({ ID: 'BAS_PKG_RULE', colSlots: [], crudColSlots: [] }))}`;
    },
    /**
     * @description: 高级表单明细表格字段
     * @return {*}
     */
    GetBaseColumns: () => {
      return [
        {
          title: '包装/载具编码',
          dataIndex: 'PKG_CODE',
          // ifShow: false,
          width: 180,
        },
        {
          title: '包装层级',
          dataIndex: 'PKG_LEVEL',
        },
        {
          title: '包装数量',
          dataIndex: 'PKG_QTY',
        },
        {
          title: '包装规则ID',
          dataIndex: 'PKG_RULE_ID',
          ifShow: false,
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
        },
        {
          title: '更新时间',
          dataIndex: 'UPDATE_TIME',
        },
        {
          title: '更新人',
          dataIndex: 'UPDATE_USER',
        },
      ];
    },
    /**
     * @description: 高级表单查询条件字段
     * @return {*}
     */
    GetSearchForm: () => {
      return [
        {
          field: 'PKG_CODE',
          label: '包装规则编码',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
      ];
    },
    /**
     * @description: 高级表单增删改表单字段
     * @return {*}
     */
    GetCrudForm: () => {
      return [
        {
          field: 'PKG_CODE',
          label: '包装/载具编码',
          component: 'ApiSelect',
          required: true,
          colProps: {
            span: 24,
          },
          componentProps: {
            api: getEntity,
            params: { entityName: 'BAS_PKG_TYPE', sqlcmd: ' 1=1 ' },
            resultField: 'Data.Items',
            labelField: 'PKG_NAME',
            valueField: 'PKG_CODE',
          },
        },
        {
          label: '包装层级',
          field: 'PKG_LEVEL',
          component: 'Input',
          required: true,
          colProps: {
            span: 24,
          },
        },
        {
          label: '包装规则ID',
          field: 'PKG_RULE_ID',
          component: 'Input',
          colProps: {
            span: 24,
          },
          dynamicDisabled: ({ values }) => {
            return true;
          },
        },
        {
          label: '包装数量',
          field: 'PKG_QTY',
          component: 'Input',
          colProps: {
            span: 24,
          },
        },
        {
          label: '备注',
          field: 'REMARK',
          component: 'Input',
          colProps: {
            span: 24,
          },
        },
        {
          label: 'ID',
          field: 'ID',
          component: 'Input',
          colProps: {
            span: 24,
          },
          show: false,
        },
      ];
    },
    OthersValues: (val: string, id: string) => {
      return { PKG_RULE_ID: id };
    },
    /**
     * @description: 高级表单主基本信息字段
     * @return {*}
     */
    GetBaseForm: () => {
      return [
        {
          field: 'RULE_CODE',
          label: '包装规则编码',
          component: 'Input',
          required: true,
          colProps: {
            span: 8,
          },
        },
        {
          label: '包装规则名称',
          field: 'RULE_NAME',
          required: true,
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '是否启用',
          field: 'IS_ACTIVE',
          required: true,
          component: 'Select',
          colProps: {
            span: 8,
          },
          componentProps: {
            options: [
              {
                label: '启用',
                value: 'Y',
                key: 'Y',
              },
              {
                label: '禁用',
                value: 'N',
                key: 'N',
              },
            ],
          },
        },
        {
          label: '备注',
          field: 'REMARK',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: 'ID',
          field: 'ID',
          component: 'Input',
          colProps: {
            span: 8,
          },
          show: false,
        },
      ];
    },
    GetBaseCards: () => {
      return [
        {
          name: 'BaseForm',
          slots: [],
          preIcons: {},
          title: '包装信息',
          entityName: 'BAS_PKG_RULE',
        },
      ];
    },
  };
  return [methods, ActionColumn];
}
export default _default;