Ben Lin
2024-06-24 c8f8a9c645f7857859a9d56fac96192d994be70b
src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts
@@ -4,10 +4,19 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-23 00:28:56
 * @LastEditTime: 2024-06-23 23:42:04
 */
import { ActionItem, BasicColumn } from "/@/components/Table";
import { Tag, Tooltip } from 'ant-design-vue';
import { ActionItem, BasicColumn } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';
import { h, unref } from 'vue';
import { GetEnum } from '/@/api/tigerapi/system';
import { useLocale } from '/@/locales/useLocale';
const { getLocale } = useLocale();
const { t } = useI18n();
function _default() {
  const ActionColumn: BasicColumn = {
@@ -22,7 +31,7 @@
     * @description: 获取新增按钮的行为,必需要有的方法
     * @return {*}
     */
    CreateAction: () => {
    CreateAction: (fnName: string) => {
      return {
        action: 'drawer', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
      };
@@ -36,7 +45,164 @@
    },
    GetHomeUrl: () => {
      return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`;
    }
    },
    GetBaseColumns: () => {
      return [
        {
          dataIndex: 'LABEL_ID',
          title: '标签模板ID',
          ifShow: false,
          sorter: true,
          resizable: true,
        },
        {
          dataIndex: 'VAR_NAME',
          title: '变量名称',
          ifShow: true,
          sorter: true,
          resizable: true,
          customRender: () => {},
        },
        {
          dataIndex: 'VAR_TYPE',
          title: '变量类型',
          ifShow: true,
          sorter: true,
          resizable: true,
          customRender: ({ record }) => {
            let color = '';
            let text = '';
            switch (record.VAR_TYPE) {
              case 0:
                text = '常量';
                color = 'green';
                break;
              case 1:
                text = '过程变量';
                color = 'orange';
                break;
              case 2:
                text = '日期变量';
                color = '#4f68b0';
                break;
              case 3:
                text = '自定义变量';
                color = '#bfbfbf';
                break;
            }
            return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text));
          },
        },
        {
          dataIndex: 'VAR_VALUE',
          title: '变量值',
          ifShow: true,
          sorter: true,
          resizable: true,
        },
        {
          dataIndex: 'REMARK',
          title: '备注',
          ifShow: true,
          sorter: true,
          resizable: true,
        },
      ];
    },
    GetSearchForm: () => {
      return [
        {
          field: 'VAR_NAME',
          label: t('变量名'),
          colProps: { span: 8 },
          component: 'Input',
        },
      ];
    },
    GetCrudForm: () => {
      let isShow = false;
      return [
        {
          field: 'ID',
          label: '变量ID',
          component: 'Input',
          colProps: {
            span: 20,
          },
          show: false,
        },
        {
          field: 'LABEL_ID',
          label: '标签模板ID',
          component: 'Input',
          colProps: {
            span: 20,
          },
          show: false,
        },
        {
          field: 'VAR_NAME',
          label: '变量名',
          required: true,
          component: 'Input',
          isexist: 'Y',
          colProps: {
            span: 20,
          },
        },
        {
          field: 'VAR_TYPE',
          label: '变量类型',
          component: 'ApiSelect',
          colProps: {
            span: 20,
          },
          componentProps: {
            api: GetEnum,
            params: { name: 'BAS_LABEL_VAR+VAR_TYPEs' },
            resultField: 'Data',
            labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name',
            valueField: 'Value',
            onChange: (e) => {
              if (e == 1) {
                isShow = true;
              } else {
                isShow = false;
              }
            },
          },
        },
        {
          field: 'VAR_VALUE',
          label: '变量值',
          required: true,
          component: 'Input',
          colProps: {
            span: 20,
          },
        },
        {
          field: 'BAS_LABEL_PV1PSelect_0', //按低代码配置的规则,实体名+序号+PSelect_0,序号用来区分多个的时候,PSelect_0这是个固定后缀
          label: '1',
          defaultValue: 'BAS_LABEL_PV',
          component: 'Input',
          colProps: { span: 4 },
          ifShow: ({ values }) => isShow,
          colSlot: 'BAS_LABEL_PV1add', //按低代码配置的规则,实体名+序号+add,序号用来区分多个的时候,add这是个固定后缀
        },
        {
          field: 'REMARK',
          label: '备注',
          component: 'Input',
          colProps: {
            span: 20,
          },
        },
      ];
    },
    OthersValues: (val: string, id: string) => {
      return { LABEL_ID: id };
    },
  };
  return [methods, ActionColumn];