Ben Lin
2024-06-30 943954bdcb3b672b89cfa097e53d2ac17a36a101
src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts
@@ -4,23 +4,321 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-22 00:34:46
 * @LastEditTime: 2024-06-26 03:14:01
 */
import { DeleteEntity } from '/@/api/tigerapi/system';
import { ActionItem } from '/@/components/Table';
import { isNullOrEmpty } from '/@/utils/is';
import { Ref } from 'vue';
import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
import { ActionItem, BasicColumn } 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';
function _default() {
function _default(): any[] {
  const ActionColumn: BasicColumn = {
    width: 80,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: undefined,
  };
  /**
   * @description: 产品绑定工艺路线操作字段自定义按钮
   * @description: 一些自定义方法
   * @return {*}
   */
  function ActionItem(params: Recordable<any>, data, ...args): ActionItem[] {
    data[1].popConfirm.confirm = custDel.bind(null, args[1], params);
    return data;
  }
   */
  const methods = {
    /**
     * @description: 获取新增按钮的行为
     * @return {*}
     */
    CreateAction: (fnName: 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: 自定义明细表中编辑返回方法
     * @param {string} type
     * @param {*} d
     * @param {*} u
     * @return {*}
     */
    EditOperation: (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;
      }
    },
    /**
     * @description: 高级表单和详情页面返回主页面的url
     * @return {*}
     */
    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,
        },
      ];
    },
    /**
     * @description: 高级表单主信息卡片生成,可以多个
     * @return {*}
     */
    GetBaseCards: () => {
      return [
        {
          name: 'BaseForm',
          slots: [], //定义插槽
          preIcons: {}, //定义插槽中按钮图标
          title: '包装信息',
          entityName: 'BAS_PKG_RULE', //实体名称
        },
      ];
    },
    /**
     * @description: 获取标题信息
     * @param {string} type
     * @return {*}
     */
    GetTitle: () => {
      return {
        pageTitle: '包装规则管理',
        pageContent: '这里可以添加和修改包装规则和包装信息。',
        baseTableTitle: '包装信息管理',
      };
    },
  };
  /* 以下是内部方法,不export,供上面的方法调用 */
  /**
   * @description: 自定义删除方法
   * @param {Fn} args
@@ -46,17 +344,9 @@
      });
    }
  }
  /**
   * @description: 公用编辑方法
   * @param {Fn} fn
   * @param {*} params
   * @return {*}
   */
  function editRecord(fn: Fn, params: {}) {
    fn(true, params);
  }
  return [ActionItem];
  return [methods, ActionColumn];
}
export default _default;