Ben Lin
2024-06-15 6abf4c703ebcdd4f856cb9cfe39bd7f0027dd6ac
src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts
@@ -1,7 +1,14 @@
import { ActionItem, BasicColumn } from '/@/components/Table';
import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { FunctionType } from '/@/api/tigerapi/model/systemModel';
import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
import { Tag } from 'ant-design-vue';
import { Ref, h } from 'vue';
import { isNullOrEmpty } from '/@/utils/is';
import { buildUUID } from '/@/utils/uuid';
import { useUserStore } from '/@/store/modules/user';
import { formatToDateTime } from '/@/utils/dateUtil';
const { t } = useI18n();
const { notification } = useMessage();
@@ -14,6 +21,17 @@
    duration: 3,
  });
  reload();
}
/**
 * @description: 自定义编辑方法,跳转到高级页面
 * @param {Fn} args
 * @param {*} params
 * @return {*}
 */
export function rsnGrpEdit(args: Fn[], params: {}) {
  const param = { CODE: params['record']['RSNG_CODE'], ID: params['record']['ID'], Name: 'BAS_REASON', Title: `编辑不良原因组:${params['record']['RSNG_CODE']}`, pCode: 'RSNG_CODE', IsID: false };
  args[5](`/BAS_REASON/High/${encodeURI(JSON.stringify(param))}`);
}
export const rsGrpactionColumn: BasicColumn = {
@@ -31,6 +49,71 @@
    onClick: () => {},
  },
];
/**
 * @description: 自定义删除方法
 * @param {Fn} args
 * @param {*} params
 * @return {*}
 */
export 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]();
      }
    });
  }
}
/**
 * @description: 自定义明细表中编辑返回方法
 * @param {string} type
 * @param {*} d
 * @param {*} u
 * @return {*}
 */
export function rsnEditeOperation( data: Ref<any[]>, d, u) {
  if (u.isUpdate) {
    //更新
    var _data = data.value.map((item) => {
      if (item['ID'] == d.ID)
        return {
          ...item,
          RSN_CODE: d.RSN_CODE,
          RSN_NAME: d.RSN_NAME,
          NEED_REPLACE: d.NEED_REPLACE,
          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;
  }
}
export function rsGrpGetSelectSuccess(d, u) {
  return {
@@ -69,6 +152,7 @@
    ],
    tableName: 'BAS_REASON_GRP',
    rowKey: 'RSNG_CODE',
    searchInfo: {TABLE_NAME: 'BAS_REASON_GRP'}
  });
}
@@ -83,3 +167,194 @@
  },
  XXX: (e) => {},
};
/**
 * @description: 不良原因主基本信息表单字段
 * @return {*}
 */
export const rsnBaseSchema: FormSchema[] = [
  {
    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,
    },
  },
];
/**
 * @description: 不良原因增删改字段
 * @return {*}
 */
export const rsnCrudSchema: FormSchema[] = [
  {
    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,
  },
];
/**
 * @description: 不良原因查询字段
 * @return {*}
 */
export const rsnSearchSchema: FormSchema[] = [
  {
    field: 'RSN_CODE',
    label: '不良原因编码',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
  {
    label: '不良原因名称',
    field: 'RSN_NAME',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
];
/**
 * @description: 不良原因表格列
 * @return {*}
 */
export const rsnBaseColumn: BasicColumn[] = [
  {
    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',
  },
];