king
2023-10-18 81d0d7721bb14a34b1eef99fd9506c3eda4bda99
src/templates/zshare/formconfig.jsx
@@ -1,3 +1,4 @@
import React from 'react'
import { formRule, btnClasses } from '@/utils/option.js'
/**
@@ -549,19 +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',
@@ -645,7 +707,7 @@
      required: false
    },
    {
      type: 'select',
      type: 'radio',
      key: 'orderType',
      label: '排序方式',
      initVal: card.orderType || 'asc',
@@ -2568,6 +2630,9 @@
    value: 'link',
    text: '联动菜单'
  }, {
    value: 'popSelect',
    text: '选择器'
  }, {
    value: 'switch',
    text: '开关'
  }, {
@@ -2905,12 +2970,210 @@
    //   }]
    // },
    {
      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 '否'
            }
          }
        }
      ]
    },
    {
      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',
@@ -2921,14 +3184,33 @@
      readonly: false
    },
    {
      type: 'codemirror',
      key: 'dataSource',
      label: '数据源',
      initVal: card.dataSource || '',
      tooltip: '数据权限替换符 $@ -> /* 或 \'\'、 @$ -> */ 或 \'\'',
      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',
@@ -2987,7 +3269,7 @@
      readonly: false
    },
    {
      type: 'select',
      type: 'radio',
      key: 'orderType',
      label: '排序方式',
      initVal: card.orderType || 'asc',
@@ -4018,7 +4300,11 @@
      initVal: card.regularExtra || '',
      tooltip: '正则验证时允许添加的自定义字符,包括~!@#$%^&*()_+:;{}<>,.-',
      required: false,
      readonly: false
      readonly: false,
      rules: [{
        pattern: /^[~!@#$%^&*()_+:;{}<>,.-]*$/,
        message: '扩展符包括~!@#$%^&*()_+:;{}<>,.-'
      }]
    },
    {
      type: 'text',