Ben Lin
2024-07-02 04259fe9c84d819791cab926b959cab8dc6584b6
src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
@@ -4,16 +4,17 @@
 * @version:
 * @Date: 2024-06-22 00:58:43
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-26 03:13:26
 * @LastEditTime: 2024-07-01 17:13:16
 */
import { Ref, h } from 'vue';
import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
import { ActionItem, BasicColumn } from '/@/components/Table';
import { ActionItem, BasicColumn, useTable } 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';
import { Tag } from 'ant-design-vue';
import { useDrawer } from '/@/components/Drawer';
function _default() {
  const ActionColumn: BasicColumn = {
@@ -27,7 +28,7 @@
  /**
   * @description: 一些自定义方法
   * @return {*}
   */
   */
  const methods = {
    /**
     * @description: 获取新增按钮的行为
@@ -93,154 +94,14 @@
    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',
        },
      ];
    GetBaseColumns: (type) => {
      return baseColumns[type];
    },
    GetSearchForm: () => {
      return [
        {
          field: 'RSN_CODE',
          label: '不良原因编码',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
        {
          label: '不良原因名称',
          field: 'RSN_NAME',
          component: 'Input',
          colProps: {
            span: 8,
          },
        },
      ];
    GetSearchForm: (type: string) => {
      return searchForms[type];
    },
    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,
        },
      ];
    GetCrudForm: (type: string) => {
      return crudForms[type];
    },
    GetBaseForm: () => {
      return [
@@ -292,6 +153,48 @@
        },
      ];
    },
    /**
     * @description: 获取右侧边框use方法
     * @return {*}
     */
    GetUseDrawers: () => {
      return [
        {
          BAS_REASON: useDrawer(),
        },
      ];
    },
    /**
     * @description: 获取表格use列表
     * @param {string} type
     * @param {array} args
     * @return {*}
     */
    GetUseTables: (data: any[], ...args) => {
      return {
        BAS_REASON: useTable({
          title: '列表信息',
          dataSource: data,
          columns: baseColumns['BAS_REASON'],
          formConfig: {
            labelWidth: 140,
            schemas: searchForms['BAS_REASON'],
          },
          useSearchForm: true,
          showTableSetting: true,
          bordered: true,
          canResize: true,
          showIndexColumn: false,
          actionColumn: {
            width: 130,
            title: '操作',
            dataIndex: 'action',
            slots: { customRender: 'action' },
            fixed: 'right',
          }, //自定义操作列
        }),
      };
    },
    OthersValues: (val: string, id: string) => {
      return { RSNG_CODE: val };
    },
@@ -304,7 +207,9 @@
      return {
        pageTitle: '不良原因组管理',
        pageContent: '这里可以添加和修改不良原因组和不良代码。',
        baseTableTitle: '不良原因管理',
        tableTitle: {
          BAS_REASON: '不良原因管理',
        }
      };
    },
  };
@@ -337,6 +242,158 @@
    }
  }
  const baseColumns = {
    BAS_REASON: [
      {
        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',
      },
    ],
  };
  const searchForms = {
    BAS_REASON: [
      {
        field: 'RSN_CODE',
        label: '不良原因编码',
        component: 'Input',
        colProps: {
          span: 8,
        },
      },
      {
        label: '不良原因名称',
        field: 'RSN_NAME',
        component: 'Input',
        colProps: {
          span: 8,
        },
      },
    ],
  };
  const crudForms = {
    BAS_REASON: [
      {
        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,
      },
    ],
  };
  return [methods, ActionColumn];
}