king
2023-10-19 96989af7e330a08d376002b0759705a477039f61
src/templates/zshare/formconfig.jsx
@@ -1,3 +1,4 @@
import React from 'react'
import { formRule, btnClasses } from '@/utils/option.js'
/**
@@ -448,7 +449,7 @@
      type: 'text',
      key: 'initval',
      label: '初始值',
      tooltip: '类型为下拉菜单时,初始值应为数据的Value值(使用数据源时,应为《值·字段》的值);类型为数值(区间)时,初始值使用逗号拼接,例如 3,10',
      tooltip: '类型为下拉菜单时,初始值应为数据的Value值(使用数据源时,应为《值·字段》的值);类型为数值(区间)时,初始值使用逗号拼接,例如 3,10;文本与下拉菜单中可使用@username@、@fullName@',
      initVal: card.initval,
      required: false
    },
@@ -549,18 +550,80 @@
      }]
    },
    {
      type: 'fields',
      key: 'fields',
      label: '字段集',
      initVal: card.fields || [],
      required: true
    },
    {
      type: 'codemirror',
      key: 'dataSource',
      label: '数据源',
      initVal: card.dataSource || '',
      tooltip: '数据权限替换符 $@ -> /* 或 \'\'、 @$ -> */ 或 \'\'',
      required: true
    },
    {
      type: 'fields',
      key: 'fields',
      label: '字段集',
      initVal: card.fields || [],
      required: true,
      columns: [
        {
          title: '字段名',
          dataIndex: 'field',
          inputType: 'input',
          editable: true,
          unique: true,
          strict: true,
          forbids: ['value', 'parentid', 'pid'],
          initval: 'field',
          rules: [{
            pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig,
            message: '请使用数字、字母、汉字以及_-'
          }],
          width: '20%'
        },
        {
          title: '字体颜色',
          dataIndex: 'color',
          inputType: 'color',
          editable: true,
          initval: 'rgba(0, 0, 0, 0.85)',
          width: '20%',
          render: (text, record) => {
            return <span style={{color: text}}>示例</span>
          }
        },
        {
          title: '字体大小',
          dataIndex: 'fontSize',
          inputType: 'number',
          min: 12,
          max: 50,
          editable: true,
          initval: 14,
          width: '20%',
        },
        {
          title: '对齐方式',
          dataIndex: 'align',
          inputType: 'select',
          editable: true,
          width: '20%',
          initval: 'left',
          options: [
            {value: 'left', text: '居左'},
            {value: 'center', text: '居中'},
            {value: 'right', text: '居右'},
            // {value: 'justify', text: 'justify'}
          ],
          render: (text, record) => {
            if (text === 'center') {
              return '居中'
            } else if (text === 'right') {
              return '居右'
            } else {
              return '居左'
            }
          }
        }
      ]
    },
    {
      type: 'options',
@@ -644,7 +707,7 @@
      required: false
    },
    {
      type: 'select',
      type: 'radio',
      key: 'orderType',
      label: '排序方式',
      initVal: card.orderType || 'asc',
@@ -1417,7 +1480,7 @@
      type: refresh.length === 0 ? 'radio' : 'select',
      key: 'popClose',
      label: '关闭后',
      initVal: card.popClose || 'never',
      initVal: card.popClose || 'grid',
      required: true,
      options: [{
        value: 'never',
@@ -2567,6 +2630,9 @@
    value: 'link',
    text: '联动菜单'
  }, {
    value: 'popSelect',
    text: '选择器'
  }, {
    value: 'switch',
    text: '开关'
  }, {
@@ -2904,12 +2970,218 @@
    //   }]
    // },
    {
      type: 'codemirror',
      key: 'dataSource',
      label: '数据源',
      initVal: card.dataSource || '',
      tooltip: '数据权限替换符 $@ -> /* 或 \'\'、 @$ -> */ 或 \'\'',
      placeholder: '系统变量:mk_departmentcode、mk_organization、mk_user_type。公共值:@ID@、@BID@。',
      required: true,
      readonly: false
    },
    {
      type: 'fields',
      key: 'fields',
      label: '字段集',
      initVal: card.fields || [],
      required: true,
      readonly: false
      readonly: false,
      columns: [
        {
          title: '字段名',
          dataIndex: 'field',
          inputType: 'input',
          editable: true,
          unique: true,
          strict: true,
          forbids: ['value', 'parentid', 'pid'],
          initval: 'field',
          rules: [{
            pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig,
            message: '请使用数字、字母、汉字以及_-'
          }],
          width: '20%'
        },
        {
          title: '字体颜色',
          dataIndex: 'color',
          inputType: 'color',
          editable: true,
          initval: 'rgba(0, 0, 0, 0.85)',
          width: '20%',
          render: (text, record) => {
            return <span style={{color: text}}>示例</span>
          }
        },
        {
          title: '字体大小',
          dataIndex: 'fontSize',
          inputType: 'number',
          min: 12,
          max: 50,
          editable: true,
          initval: 14,
          width: '20%',
        },
        {
          title: '对齐方式',
          dataIndex: 'align',
          inputType: 'select',
          editable: true,
          width: '20%',
          initval: 'left',
          options: [
            {value: 'left', text: '居左'},
            {value: 'center', text: '居中'},
            {value: 'right', text: '居右'},
            // {value: 'justify', text: 'justify'}
          ],
          render: (text, record) => {
            if (text === 'center') {
              return '居中'
            } else if (text === 'right') {
              return '居右'
            } else {
              return '居左'
            }
          }
        }
      ]
    },
    {
      type: 'fields',
      key: 'columns',
      label: '字段集',
      initVal: card.columns || [],
      required: true,
      readonly: false,
      columns: [
        {
          title: '名称',
          dataIndex: 'label',
          inputType: 'input',
          editable: true,
          initval: 'label',
          width: '20%'
        },
        {
          title: '字段',
          dataIndex: 'field',
          inputType: 'input',
          editable: true,
          unique: true,
          strict: true,
          copy: true,
          initval: 'field',
          rules: [{
            pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig,
            message: '请使用数字、字母、汉字以及_-'
          }],
          width: '20%'
        },
        {
          title: '隐藏',
          dataIndex: 'Hide',
          inputType: 'radio',
          editable: true,
          width: '20%',
          initval: 'false',
          options: [
            {value: 'true', text: '是'},
            {value: 'false', text: '否'},
          ],
          render: (text, record) => {
            if (text === 'true') {
              return '是'
            } else {
              return '否'
            }
          }
        },
        {
          title: '排序',
          dataIndex: 'IsSort',
          inputType: 'radio',
          editable: true,
          width: '20%',
          initval: 'false',
          options: [
            {value: 'true', text: '是'},
            {value: 'false', text: '否'},
          ],
          render: (text, record) => {
            if (text === 'true') {
              return '是'
            } else {
              return '否'
            }
          }
        },
        {
          title: '列宽',
          dataIndex: 'Width',
          inputType: 'number',
          editable: true,
          width: '20%',
          initval: 120
        }
      ]
    },
    {
      type: 'select',
      key: 'primaryKey',
      label: '主键',
      initVal: card.primaryKey || '',
      required: true,
      readonly: false,
      options: 'columns'
    },
    {
      type: 'text',
      key: 'order',
      label: '默认排序',
      initVal: card.order || '',
      placeholder: 'ID asc',
      required: true
    },
    {
      type: 'select',
      key: 'showField',
      label: '显示字段',
      initVal: card.showField || '',
      tooltip: '用于控制选择框中的显示内容。',
      required: true,
      options: 'columns'
    },
    {
      type: 'select',
      key: 'controlField',
      label: '禁用字段',
      initVal: card.controlField || '',
      tooltip: '用于控制行数据是否可选择。字段值为true时,选项不可选。',
      required: false,
      allowClear: true,
      options: 'columns'
    },
    {
      type: 'text',
      key: 'searchKey',
      label: '搜索字段',
      initVal: card.searchKey || '',
      tooltip: '多个值请用逗号分隔。',
      required: false,
      rules: [{
        pattern: /^[0-9a-zA-Z,_-]*$/ig,
        message: '字段名只允许包含数字、字母以及_-',
      }]
    },
    {
      type: 'number',
      key: 'popWidth',
      label: '弹窗宽度',
      initVal: card.popWidth || 60,
      tooltip: '小于100时为百分率,大于100时为绝对值。',
      required: true
    },
    {
      type: 'options',
@@ -2920,13 +3192,33 @@
      readonly: false
    },
    {
      type: 'codemirror',
      key: 'dataSource',
      label: '数据源',
      initVal: card.dataSource || '',
      placeholder: '系统变量:mk_departmentcode、mk_organization、mk_user_type。公共值:@ID@、@BID@。',
      required: true,
      readonly: false
      type: 'radio',
      key: 'laypage',
      label: '分页',
      initVal: card.laypage || 'true',
      required: false,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'radio',
      key: 'onload',
      label: '初始化',
      initVal: card.onload || 'true',
      tooltip: '当没有设置搜索字段时,初始化加载数据。',
      required: false,
      options: [{
        value: 'true',
        text: '加载'
      }, {
        value: 'false',
        text: '不加载'
      }]
    },
    {
      type: 'radio',
@@ -2985,7 +3277,7 @@
      readonly: false
    },
    {
      type: 'select',
      type: 'radio',
      key: 'orderType',
      label: '排序方式',
      initVal: card.orderType || 'asc',
@@ -3615,16 +3907,28 @@
    {
      type: 'radio',
      key: 'interception',
      label: '截取空格',
      label: '截取方式',
      initVal: card.interception || 'true',
      tooltip: '提交时,是否截取首尾的空白字符。',
      tooltip: '提交时的文本处理方式,空白字符指开头或结尾的空白字符。',
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
        text: '无'
      }, {
        value: 'true',
        text: '空白字符'
      }, {
        value: 'func',
        text: '自定义函数'
      }]
    },
    {
      type: 'textarea',
      key: 'func',
      label: '函数',
      initVal: card.func || '',
      tooltip: '函数有两个入参(value, data),第一个为当前表单值,第二个为表单所有字段-值的对象,请返回处理后的值。',
      rows: 2,
      required: true
    },
    {
      type: 'textarea',
@@ -3858,7 +4162,7 @@
      type: 'radio',
      key: 'constant',
      label: 'Unicode常量',
      tooltip: '使用时将在提交内容前加上 N,代表存入数据库时以 Unicode 格式存储。',
      tooltip: `使用时将在提交内容前加上 N,代表存入数据库时以 Unicode 格式存储。例如:@nvarchar=N'ØW30041'。`,
      initVal: card.constant || 'false',
      options: [{
        value: 'true',
@@ -4004,7 +4308,11 @@
      initVal: card.regularExtra || '',
      tooltip: '正则验证时允许添加的自定义字符,包括~!@#$%^&*()_+:;{}<>,.-',
      required: false,
      readonly: false
      readonly: false,
      rules: [{
        pattern: /^[~!@#$%^&*()_+:;{}<>,.-]*$/,
        message: '扩展符包括~!@#$%^&*()_+:;{}<>,.-'
      }]
    },
    {
      type: 'text',
@@ -4094,9 +4402,10 @@
      type: 'multiselect',
      key: 'linkSubField',
      label: '填充表单',
      tooltip: '在切换选项时会把信息自动填入关联的表单(文本或数字表单)中,开关会将提示文本填入此表单。',
      tooltip: '在切换选项时会把信息自动填入关联的表单(文本或数字表单)中,开关会将提示文本填入此表单,文件上传会将原文件名填入此表单。',
      initVal: card.linkSubField || [],
      options: inputfields
      options: inputfields,
      allowClear: true
    },
    // {
    //   type: 'number',