Ben Lin
2024-06-27 226ad601bb8326814c3e94efd6f476014f6a9e66
src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts
@@ -4,17 +4,20 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-22 20:31:44
 * @LastEditTime: 2024-06-26 03:13:41
 */
import { Ref } from 'vue';
import { DeleteEntity } from '/@/api/tigerapi/system';
import { Ref, h, unref } from 'vue';
import { DeleteEntity, GetEnum, 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';
import { useLocale } from '/@/locales/useLocale';
const { getLocale } = useLocale();
function _default() {
  const ActionColumn: BasicColumn = {
    width: 80,
@@ -25,7 +28,246 @@
  };
  const methods = {
    EditOperation: (type: string, data: Ref<any[]>, d, u) => {
    /**
     * @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 = DftGrpDel.bind(null, args, params);
      }
      return data;
    },
    /**
     * @description: 高级表单和详情页面返回主页面的url
     * @return {*}
     */
    GetHomeUrl: () => {
      const param = { ID: 'BAS_DEFECT_GRP', colSlots: [], crudColSlots: [] };
      return `/BAS_DEFECT_GRP/LC/${encodeURI(JSON.stringify(param))}`;
    },
    GetBaseColumns: () => {
      return [
        {
          title: '不良代码编码',
          dataIndex: 'DFT_CODE',
          // ifShow: false,
          width: 180,
        },
        {
          title: '不良代码名称',
          dataIndex: 'DFT_NAME',
        },
        {
          title: '缺陷等级',
          dataIndex: 'DFT_LEVEL',
          customRender: ({ record }) => {
            const type = record.DFT_LEVEL;
            var text = '';
            var color = 'green';
            switch (type) {
              case 0:
                text = '轻微缺陷';
                break;
              case 1:
                color = 'blue';
                text = '严重缺陷';
                break;
              case 2:
                color = 'red';
                text = '致命缺陷';
                break;
            }
            return h(Tag, { color: color }, () => text);
          },
        },
        {
          title: '不良代码组编码',
          dataIndex: 'DFTG_CODE',
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
        },
        {
          title: '更新时间',
          dataIndex: 'UPDATE_TIME',
        },
        {
          title: '更新人',
          dataIndex: 'UPDATE_USER',
        },
      ];
    },
    GetSearchForm: () => {
      return [
        {
          field: 'DFT_CODE',
          label: '不良代码编码',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '不良代码名称',
          field: 'DFT_NAME',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
      ];
    },
    GetCrudForm: () => {
      return [
        {
          field: 'DFT_CODE',
          label: '不良代码编码',
          component: 'Input',
          required: true,
          colProps: {
            span: 24,
          },
        },
        {
          label: '不良代码名称',
          field: 'DFT_NAME',
          component: 'Input',
          required: true,
          colProps: {
            span: 24,
          },
        },
        {
          label: '不良代码组编码',
          field: 'DFTG_CODE',
          component: 'ApiSelect',
          colProps: {
            span: 24,
          },
          componentProps: {
            api: getEntity,
            params: { entityName: 'BAS_DEFECT_GRP', sqlcmd: ' 1=1 ' },
            resultField: 'Data.Items',
            labelField: 'DFTG_NAME',
            valueField: 'DFTG_CODE',
          },
          dynamicDisabled: ({ values }) => {
            return true;
          },
        },
        {
          label: '缺陷等级',
          field: 'DFT_LEVEL',
          component: 'ApiSelect',
          required: true,
          colProps: {
            span: 24,
          },
          componentProps: {
            api: GetEnum,
            params: { name: 'BAS_DEFECT+DFT_LEVELs' },
            resultField: 'Data',
            labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name',
            valueField: 'Value',
          },
        },
        {
          label: '备注',
          field: 'REMARK',
          component: 'Input',
          colProps: {
            span: 24,
          },
        },
        {
          label: 'ID',
          field: 'ID',
          component: 'Input',
          colProps: {
            span: 24,
          },
          show: false,
        },
      ];
    },
    GetBaseForm: () => {
      return [
        {
          field: 'DFTG_CODE',
          label: '不良代码组编码',
          component: 'Input',
          required: true,
          colProps: {
            span: 8,
          },
        },
        {
          label: '不良代码组名称',
          field: 'DFTG_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_DEFECT_GRP',
        },
        // {
        //   name: 'prodinfo',
        //   slots: ['addRot', 'setRot'],
        //   preIcons: { addRot: 'search|svg', setRot: 'config|svg' },
        //   title: '产品信息',
        // },
        // { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '工艺信息' },
      ];
    },
    OthersValues: (val: string, id: string) => {
      return { DFTG_CODE: val };
    } /**
     * @description: 自定义明细表中编辑返回方法
     * @param {string} type
     * @param {*} d
     * @param {*} u
     * @return {*}
     */,
    EditOperation: (data: Ref<any[]>, d, u) => {
      if (u.isUpdate) {
        //更新
        var _data = data.value.map((item) => {
@@ -57,21 +299,16 @@
      }
    },
    /**
     * @description: 获取新增按钮的行为
     * @description: 获取标题信息
     * @param {string} type
     * @return {*}
     */
    CreateAction: () => {
    GetTitle: () => {
      return {
        action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
        pageTitle: '不良代码组管理',
        pageContent: '这里可以添加和修改不良代码组和不良代码。',
        baseTableTitle: '不良代码管理',
      };
    },
    /**
     * @description: 产品绑定工艺路线操作字段自定义按钮
     * @return {*}
     */
    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
      data[1].popConfirm.confirm = DftGrpDel.bind(null, args, params);
      return data;
    },
  };