Ben Lin
2024-06-23 200eb764e83c7a77defeaf98130801d300dbee5d
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-23 00:16:36
 * @LastEditTime: 2024-06-23 18:41:06
 */
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 { 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,
@@ -76,7 +79,250 @@
    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 {*}
    */
   EditeOperation:(data: Ref<any[]>, d, u) => {
     if (u.isUpdate) {
       //更新
       var _data = data.value.map((item) => {
         if (item['ID'] == d.ID)
           return {
             ...item,
             DFT_CODE: d.DFT_CODE,
             DFT_NAME: d.DFT_NAME,
             DFT_LEVEL: d.DFT_LEVEL,
             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;
     }
   }
  };
  /**