king
2024-03-03 67036fb0ed31d77ca33b660ce5f9f47c29ae65c0
src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
@@ -2,7 +2,7 @@
 * @description 获取显示列表单配置信息
 * @param {object} card       // 搜索条件对象
 */
export function getColumnForm (card, fields = [], columns = []) {
export function getColumnForm (card, fields = [], columns = [], wrap) {
  let roleList = sessionStorage.getItem('sysRoles')
  if (roleList) {
    try {
@@ -25,53 +25,83 @@
    value: 'number',
    text: '数字'
  }, {
    value: 'textarea',
    text: '多行文本'
  }, {
    value: 'custom',
    text: '自定义列'
  }, {
    value: 'colspan',
    text: '合并列'
  }, {
    value: 'formula',
    text: '公式'
  }, {
    value: 'textarea',
    text: '多行文本'
  }, {
    value: 'colspan',
    text: '合并列'
  }, {
    value: 'index',
    text: '序号'
  }]
  let editCols = [
    // {
    //   field: '$sub',
    //   label: '提交'
    // },
    {
      field: '$sub',
      label: '提交'
      field: '$noAct',
      label: '无动作'
    },
    {
      field: '$next',
      label: '下一行'
    },
    {
      field: '$noAct',
      label: '无动作'
    }
  ]
  columns.forEach(col => {
    if (col.editable === 'true' && col.uuid !== card.uuid) {
      editCols.push({
        field: col.uuid,
        label: col.label
      })
    } else if (col.type === 'colspan') {
      col.subcols.forEach(subcol => {
        if (subcol.editable === 'true' && subcol.uuid !== card.uuid) {
          editCols.push({
            field: subcol.uuid,
            label: col.label + '-' + subcol.label
          })
        }
      })
    }
  if (card.enter === '$sub') {
    card.enter = '$noAct'
  }
  if (wrap.commit === 'change') {
    editCols[0].label = '失去焦点'
  }
  let cols = []
  let getcols = (columns, suplabel = '') => {
    columns.forEach(col => {
      if (col.editable === 'true' && col.uuid !== card.uuid) {
        cols.push({
          field: col.uuid,
          label: suplabel + col.label
        })
      } else if (col.type === 'colspan') {
        getcols(col.subcols, col.label + '-')
      }
    })
  }
  getcols(columns)
  editCols.push(...cols)
  cols.forEach(col => {
    editCols.push({
      field: '$next_' + col.field,
      label: col.label + '(下一行)'
    })
  })
  editCols.push({
    field: '$next_' + card.uuid,
    label: card.label + '(下一行)'
  })
  if (wrap.commit === 'change') {
    editCols.push({
      field: '$noActX',
      label: '无动作',
      disabled: card.editType !== 'select'
    })
  } else if (card.enter === '$noActX') {
    card.enter = '$noAct'
  }
  return [
    {
@@ -125,7 +155,7 @@
      type: 'radio',
      key: 'IsSort',
      label: '排序',
      initVal: card.IsSort || (card.isSub ? 'false' : 'true'),
      initVal: card.IsSort || (card.isSub || card.type === 'custom' ? 'false' : 'true'),
      required: true,
      options: [{
        value: 'true',
@@ -136,16 +166,30 @@
      }]
    },
    {
      type: 'select',
      key: 'sortField',
      label: '排序字段',
      initVal: card.sortField || '',
      required: true,
      options: fields
    },
    {
      type: 'radio',
      key: 'eval',
      label: '解析',
      label: '解析方式',
      initVal: card.eval || 'false',
      tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。',
      tooltip: '当公式内容涉及计算时请选择“计算”,当公式内容为字段拼接时请选择“字段替换”,使用函数时入参为data(数组)。',
      required: false,
      options: [
        { value: 'true', text: '是' },
        { value: 'false', text: '否' }
      ]
      options: [{
        value: 'false',
        text: '字段替换'
      }, {
        value: 'true',
        text: '计算'
      }, {
        value: 'func',
        text: '函数'
      }]
    },
    {
      type: 'radio',
@@ -179,7 +223,7 @@
      }]
    },
    {
      type: 'radio',
      type: 'select',
      key: 'editType',
      label: '编辑类型',
      initVal: card.editType || 'text',
@@ -193,6 +237,45 @@
      }, {
        value: 'switch',
        text: '开关'
      }, {
        value: 'date',
        text: '日期(天)'
      }, {
        value: 'popSelect',
        text: '选择器'
      }]
    },
    {
      type: 'radio',
      key: 'precision',
      label: '精确度',
      initVal: card.precision || 'day',
      options: [{
        value: 'day',
        text: '天'
      }, {
        value: 'hour',
        text: '小时'
      }, {
        value: 'minute',
        text: '分钟'
      }, {
        value: 'second',
        text: '秒'
      }]
    },
    {
      type: 'radio',
      key: 'declareType',
      label: '数据类型',
      tooltip: '声明变量时的类型,时间格式datetime或文本格式nvarchar(50)。',
      initVal: card.declareType || 'datetime',
      options: [{
        value: 'datetime',
        text: 'datetime'
      }, {
        value: 'nvarchar(50)',
        text: 'nvarchar(50)'
      }]
    },
    {
@@ -257,7 +340,187 @@
      key: 'dataSource',
      label: '数据源',
      initVal: card.dataSource || '',
      placeholder: '系统变量:mk_departmentcode、mk_organization、mk_user_type。公共值@BID@。',
      required: true,
    },
    {
      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: false,
      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: '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',
      key: 'cache',
      label: '选项查询',
      initVal: card.cache || 'true',
      tooltip: '数据查询是否使用缓存。',
      required: false,
      options: [{
        value: 'true',
        text: '缓存'
      }, {
        value: 'false',
        text: '实时'
      }]
    },
    {
      type: 'text',
@@ -347,13 +610,13 @@
      key: 'enter',
      label: '回车切换',
      initVal: card.enter || '$noAct',
      tooltip: '包括文本或数值回车事件、下拉菜单选中事件、开关切换事件。',
      tooltip: '包括文本或数值回车事件、下拉菜单、选择器、时间变化事件、开关切换事件。',
      options: editCols
    },
    {
      type: 'select',
      key: 'ctrlField',
      label: '禁用字段',
      label: '禁止编辑',
      initVal: card.ctrlField || '',
      tooltip: '控制单元格是否可以编辑。',
      allowClear: true,
@@ -363,10 +626,20 @@
    {
      type: 'text',
      key: 'ctrlValue',
      label: '禁用值',
      label: '禁止值',
      initVal: card.ctrlValue || '',
      tooltip: '多个值用逗号分隔。',
      required: false
    },
    {
      type: 'select',
      key: 'clearField',
      label: '清空字段',
      initVal: card.clearField || '',
      tooltip: '当前字段编辑时需要清空的字段。',
      allowClear: true,
      required: false,
      options: fields
    },
    {
      type: 'number',
@@ -470,7 +743,7 @@
      key: 'noValue',
      label: '空值',
      initVal: card.noValue || 'show',
      tooltip: '当值为0时是否显示',
      tooltip: '数值为 0 或时间小于 1949-10-02 时,是否显示',
      required: false,
      options: [{
        value: 'show',