Ben Lin
2024-06-30 943954bdcb3b672b89cfa097e53d2ac17a36a101
src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
@@ -2,46 +2,20 @@
 * @Description: 不良原因相关
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @Date: 2024-06-22 00:58:43
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-22 22:28:08
 * @LastEditTime: 2024-06-26 03:13:26
 */
import { Ref } from 'vue';
import { DeleteEntity } from '/@/api/tigerapi/system';
import { Ref, h } from 'vue';
import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
import { ActionItem, BasicColumn } from '/@/components/Table';
import { isNullOrEmpty } from '/@/utils/is';
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';
function _default() {
  /**
   * @description: 自定义删除方法
   * @param {Fn} args
   * @param {*} params
   * @return {*}
   */
  function rsnGrpDel(args: Fn[], params: {}) {
    if (!isNullOrEmpty(params['data'])) {
      var _data = params['data'].value.filter((item) => item['ID'] != params['record']['ID']);
      params['data'].value = _data;
      args[6]({
        dataSource: [],
      });
      args[6]({
        dataSource: params['data'],
      });
      args[1]();
    } else {
      DeleteEntity(params['record'], params['entityName']).then((action) => {
        if (action.IsSuccessed) {
          args[1]();
        }
      });
    }
  }
  const ActionColumn: BasicColumn = {
    width: 80,
    title: '操作',
@@ -50,22 +24,28 @@
    fixed: undefined,
  };
  /**
   * @description: 一些自定义方法
   * @return {*}
   */
  const methods = {
    /**
     * @description: 获取新增按钮的行为
     * @return {*}
     */
    CreateAction: () => {
    CreateAction: (fnName: string) => {
      return {
        action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
      };
    },
    /**
     * @description: 产品绑定工艺路线操作字段自定义按钮
     * @description: 操作字段自定义按钮
     * @return {*}
     */
    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
      data[1].popConfirm.confirm = rsnGrpDel.bind(null, args, params);
      if (!isNullOrUnDef(data[1])) {
        data[1].popConfirm.confirm = rsnGrpDel.bind(null, args, params);
      }
      return data;
    },
    /**
@@ -75,7 +55,7 @@
     * @param {*} u
     * @return {*}
     */
    EditeOperation:( data: Ref<any[]>, d, u) => {
    EditOperation: (data: Ref<any[]>, d, u) => {
      if (u.isUpdate) {
        //更新
        var _data = data.value.map((item) => {
@@ -105,9 +85,258 @@
        _data2.push(d);
        data.value = _data2;
      }
    }
    },
    /**
     * @description: 高级表单和详情页面返回主页面的url
     * @return {*}
     */
    GetHomeUrl: () => {
      return `/BAS_REASON_GRP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_REASON_GRP', colSlots: [], crudColSlots: [] }))}`;
    },
    GetBaseColumns: () => {
      return [
        {
          title: '不良原因编码',
          dataIndex: 'RSN_CODE',
          // ifShow: false,
          width: 180,
        },
        {
          title: '不良原因名称',
          dataIndex: 'RSN_NAME',
        },
        {
          title: '是否必须更换零件',
          dataIndex: 'NEED_REPLACE',
          customRender: ({ record }) => {
            const type = record.NEED_REPLACE;
            var text = '';
            var color = 'green';
            switch (type) {
              case 'Y':
                text = '更换';
                break;
              case 'N':
                color = 'blue';
                text = '不更换';
                break;
            }
            return h(Tag, { color: color }, () => text);
          },
        },
        {
          title: '不良原因组编码',
          dataIndex: 'RSNG_CODE',
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
        },
        {
          title: '更新时间',
          dataIndex: 'UPDATE_TIME',
        },
        {
          title: '更新人',
          dataIndex: 'UPDATE_USER',
        },
      ];
    },
    GetSearchForm: () => {
      return [
        {
          field: 'RSN_CODE',
          label: '不良原因编码',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '不良原因名称',
          field: 'RSN_NAME',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
      ];
    },
    GetCrudForm: () => {
      return [
        {
          field: 'RSN_CODE',
          label: '不良原因编码',
          component: 'Input',
          required: true,
          colProps: {
            span: 24,
          },
        },
        {
          label: '不良原因名称',
          field: 'RSN_NAME',
          component: 'Input',
          required: true,
          colProps: {
            span: 24,
          },
        },
        {
          label: '不良原因组编码',
          field: 'RSNG_CODE',
          component: 'ApiSelect',
          colProps: {
            span: 24,
          },
          componentProps: {
            api: getEntity,
            params: { entityName: 'BAS_REASON_GRP', sqlcmd: ' 1=1 ' },
            resultField: 'Data.Items',
            labelField: 'RSNG_NAME',
            valueField: 'RSNG_CODE',
          },
          dynamicDisabled: ({ values }) => {
            return true;
          },
        },
        {
          label: '是否必须更换零件',
          field: 'NEED_REPLACE',
          component: 'Select',
          required: true,
          colProps: {
            span: 24,
          },
          componentProps: {
            options: [
              {
                label: '更换',
                value: 'Y',
                key: 'Y',
              },
              {
                label: '不更换',
                value: 'N',
                key: 'N',
              },
            ],
          },
        },
        {
          label: '备注',
          field: 'REMARK',
          component: 'Input',
          colProps: {
            span: 24,
          },
        },
        {
          label: 'ID',
          field: 'ID',
          component: 'Input',
          colProps: {
            span: 24,
          },
          show: false,
        },
      ];
    },
    GetBaseForm: () => {
      return [
        {
          field: 'RSNG_CODE',
          label: '不良原因组编码',
          component: 'Input',
          required: true,
          colProps: {
            span: 8,
          },
        },
        {
          label: '不良原因组名称',
          field: 'RSNG_NAME',
          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,
        },
      ];
    },
    GetBaseCards: () => {
      return [
        {
          name: 'BaseForm',
          slots: [],
          preIcons: {},
          title: '不良原因组信息',
          entityName: 'BAS_REASON_GRP',
        },
      ];
    },
    OthersValues: (val: string, id: string) => {
      return { RSNG_CODE: val };
    },
    /**
     * @description: 获取标题信息
     * @param {string} type
     * @return {*}
     */
    GetTitle: () => {
      return {
        pageTitle: '不良原因组管理',
        pageContent: '这里可以添加和修改不良原因组和不良代码。',
        baseTableTitle: '不良原因管理',
      };
    },
  };
  /* 以下是内部方法,不export,供上面的方法调用 */
  /**
   * @description: 自定义删除方法
   * @param {Fn} args
   * @param {*} params
   * @return {*}
   */
  function rsnGrpDel(args: Fn[], params: {}) {
    if (!isNullOrEmpty(params['data'])) {
      var _data = params['data'].value.filter((item) => item['ID'] != params['record']['ID']);
      params['data'].value = _data;
      args[6]({
        dataSource: [],
      });
      args[6]({
        dataSource: params['data'],
      });
      args[1]();
    } else {
      DeleteEntity(params['record'], params['entityName']).then((action) => {
        if (action.IsSuccessed) {
          args[1]();
        }
      });
    }
  }
  return [methods, ActionColumn];
}