king
2024-03-03 67036fb0ed31d77ca33b660ce5f9f47c29ae65c0
src/menu/components/table/base-table/columns/editColumn/formconfig.jsx
@@ -1,14 +1,8 @@
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
const Formdict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
/**
 * @description 获取显示列表单配置信息
 * @param {object} card       // 搜索条件对象
 */
export function getColumnForm (card, fields = []) {
  let appType = sessionStorage.getItem('appType')
  let roleList = sessionStorage.getItem('sysRoles')
  if (roleList) {
    try {
@@ -20,13 +14,7 @@
    roleList = []
  }
  let menulist = []
  if (appType === 'pc') {
    menulist = sessionStorage.getItem('appMenus')
  } else if (!appType) {
    menulist = sessionStorage.getItem('fstMenuList')
  }
  let menulist = sessionStorage.getItem('fstMenuList')
  if (menulist) {
    try {
@@ -40,42 +28,39 @@
  let options = [{
    value: 'text',
    text: Formdict['model.form.text']
    text: '文本'
  }, {
    value: 'number',
    text: Formdict['model.form.number']
  }, {
    value: 'picture',
    text: Formdict['model.form.picture']
  }, {
    value: 'link',
    text: Formdict['model.form.href']
  }, {
    value: 'textarea',
    text: Formdict['model.form.textarea']
    text: '数字'
  }, {
    value: 'custom',
    text: '自定义列'
  }, {
    value: 'colspan',
    text: '合并列'
  }, {
    value: 'formula',
    text: '公式'
  }, {
    value: 'picture',
    text: '图片'
  }, {
    value: 'video',
    text: '视频'
  }, {
    value: 'link',
    text: '链接'
  }, {
    value: 'textarea',
    text: '多行文本'
  }, {
    value: 'colspan',
    text: '合并列'
  }, {
    value: 'index',
    text: '序号'
  }]
  if (!card.isSub) {
    options.push({
      value: 'action',
      text: '操作'
    })
  }
  if (!card.linkurl && (!card.linkmenu || card.linkmenu.length === 0)) {
    card.perspective = ''
  let decimal = card.decimal === undefined ? 0 : card.decimal
  if (card.type === 'formula' && typeof(card.decimal) !== 'number') {
    decimal = ''
  }
  return [
@@ -84,31 +69,45 @@
      key: 'label',
      label: '列头文字',
      initVal: card.label,
      required: true
      required: true,
      rules: [{
        max: 100,
        message: '最多100个字符。'
      }]
    },
    {
      type: 'select',
      key: 'type',
      label: Formdict['model.form.type'],
      label: '类型',
      initVal: card.type,
      required: true,
      options: options
    },
    {
      type: 'select',
      type: card.isSub ? 'select' : 'text',
      key: 'field',
      label: Formdict['model.form.field'],
      label: '字段',
      initVal: card.field,
      required: true,
      options: fields
      options: card.isSub ? fields : [],
      rules: [{
        pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig,
        message: '字段名只允许包含数字、字母、汉字以及_'
      }, {
        max: 100,
        message: '最多100个字符。'
      }]
    },
    {
      type: 'select',
      type: 'text',
      key: 'nameField',
      label: Formdict['model.name'] + Formdict['model.form.field'],
      label: '名称字段',
      initVal: card.nameField || '',
      required: false,
      options: [{uuid: 'empty', field: '', label: '空'}, ...fields]
      rules: [{
        max: 100,
        message: '最多100个字符。'
      }]
    },
    {
      type: 'number',
@@ -116,68 +115,114 @@
      min: 20,
      max: 1000,
      decimal: 0,
      label: Formdict['model.form.columnWidth'],
      label: '列宽',
      initVal: card.Width || 120,
      required: true
    },
    {
      type: 'radio',
      key: 'joint',
      label: Formdict['model.form.paramJoint'],
      label: '拼接参数',
      initVal: card.joint || 'true',
      required: true,
      options: [{
        value: 'true',
        text: Formdict['model.true']
        text: '是'
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '否'
      }]
    },
    {
      type: 'radio',
      key: 'Hide',
      label: Formdict['model.hidden'],
      label: '隐藏',
      initVal: card.Hide || 'false',
      required: true,
      options: [{
        value: 'true',
        text: Formdict['model.true']
        text: '是'
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '否'
      }]
    },
    {
      type: 'radio',
      key: 'IsSort',
      label: Formdict['model.sort'],
      initVal: card.IsSort || (card.isSub ? 'false' : 'true'),
      label: '排序',
      initVal: card.IsSort || (card.isSub || card.type === 'custom' ? 'false' : 'true'),
      required: true,
      options: [{
        value: 'true',
        text: Formdict['model.true']
        text: '是'
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '否'
      }]
    },
    {
      type: 'select',
      key: 'sortField',
      label: '排序字段',
      initVal: card.sortField || '',
      required: true,
      options: fields
    },
    {
      type: 'radio',
      key: 'eval',
      label: '解析方式',
      initVal: card.eval || 'false',
      tooltip: '当公式内容涉及计算时请选择“计算”,当公式内容为字段拼接时请选择“字段替换”,使用函数时入参为data(数组)。',
      required: false,
      options: [{
        value: 'false',
        text: '字段替换'
      }, {
        value: 'true',
        text: '计算'
      }, {
        value: 'func',
        text: '函数'
      }]
    },
    {
      type: 'radio',
      key: 'Align',
      label: Formdict['model.form.align'],
      label: '对齐方式',
      initVal: card.Align || 'left',
      required: true,
      options: [{
        value: 'left',
        text: Formdict['model.form.alignLeft']
        text: '左对齐'
      }, {
        value: 'center',
        text: Formdict['model.form.alignCenter']
        text: '居中'
      }, {
        value: 'right',
        text: Formdict['model.form.alignRight']
        text: '右对齐'
      }]
    },
    {
      type: 'number',
      key: 'startTime',
      precision: 0,
      label: '开始时间',
      initVal: card.startTime || 0,
      tooltip: '视频开始播放的时间,用于调整视频初始化展示的界面。',
      required: false
    },
    {
      type: 'select',
      key: 'aspectRatio',
      label: '长宽比',
      initVal: card.aspectRatio || '16:9',
      required: true,
      options: [
        { value: '4:3', text: '4:3' },
        { value: '16:9', text: '16:9' }
      ]
    },
    {
      type: 'radio',
@@ -188,10 +233,10 @@
      required: false,
      options: [{
        value: 'true',
        text: Formdict['model.true']
        text: '是'
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '否'
      }]
    },
    {
@@ -203,11 +248,20 @@
      required: false,
      options: [{
        value: 'true',
        text: Formdict['model.true']
        text: '是'
      }, {
        value: 'false',
        text: Formdict['model.false']
      }]
        text: '否'
      }],
      forbid: card.isSub || card.sum !== 'true'
    },
    {
      type: 'number',
      key: 'fieldlength',
      label: '字段长度',
      initVal: card.fieldlength || 50,
      required: true,
      forbid: card.isSub
    },
    {
      type: 'number',
@@ -215,14 +269,14 @@
      min: 0,
      max: 18,
      decimal: 0,
      label: Formdict['header.form.decimal'],
      initVal: card.decimal || 0,
      required: true
      label: '小数位',
      initVal: decimal,
      required: !card.isSub
    },
    {
      type: 'select',
      key: 'format',
      label: Formdict['header.form.format'],
      label: '格式化',
      initVal: card.format || 'none',
      options: [{
        value: 'none',
@@ -242,7 +296,7 @@
    {
      type: 'select',
      key: 'textFormat',
      label: Formdict['header.form.format'],
      label: '格式化',
      initVal: card.textFormat || 'none',
      options: [{
        value: 'none',
@@ -262,18 +316,37 @@
    {
      type: 'text',
      key: 'prefix',
      label: Formdict['header.form.prefix'],
      label: '前缀',
      initVal: card.prefix || '',
      required: false,
      readonly: false
      readonly: false,
      rules: [{
        max: 100,
        message: '最多100个字符。'
      }]
    },
    {
      type: 'text',
      key: 'postfix',
      label: Formdict['header.form.postfix'],
      label: '后缀',
      initVal: card.postfix || '',
      required: false,
      readonly: false
      readonly: false,
      rules: [{
        max: 100,
        message: '最多100个字符。'
      }]
    },
    {
      type: 'number',
      key: 'span',
      min: 1,
      max: 24,
      precision: 0,
      label: '图片宽度',
      initVal: card.span || 24,
      tooltip: '栅格布局,等分为24份。',
      required: true
    },
    {
      type: 'select',
@@ -302,24 +375,15 @@
    },
    {
      type: 'radio',
      key: 'picSort',
      label: '图片排列',
      initVal: card.picSort || '1',
      tooltip: '同一单元格内,含有多张图片时的列数。',
      key: 'backgroundSize',
      label: '图像大小',
      initVal: card.backgroundSize || 'cover',
      required: false,
      options: [{
        value: '1',
        text: '1'
      }, {
        value: '2',
        text: '2'
      }, {
        value: '3',
        text: '3'
      }, {
        value: '4',
        text: '4'
      }]
      options: [
        { value: 'cover', text: '覆盖' },
        { value: 'contain', text: '包含' },
        { value: 'auto', text: '自适应' },
      ]
    },
    {
      type: 'radio',
@@ -329,11 +393,23 @@
      required: false,
      options: [{
        value: 'true',
        text: Formdict['model.true']
        text: '是'
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '否'
      }]
    },
    {
      type: 'radio',
      key: 'lostTip',
      label: '图片缺失',
      initVal: card.lostTip || 'true',
      tooltip: '图片地址不存在时,是否提示图片丢失。',
      required: false,
      options: [
        { value: 'true', text: '提示' },
        { value: 'false', text: '不提示' }
      ]
    },
    {
      type: 'radio',
@@ -350,24 +426,21 @@
        value: 'linkurl',
        text: '链接'
      }],
      forbidden: appType === 'mob'
    },
    {
      type: appType === 'pc' ? 'select' : 'cascader',
      type: 'cascader',
      key: 'linkmenu',
      label: Formdict['model.menu'],
      initVal: card.linkmenu || (appType === 'pc' ? '' : []),
      label: '菜单',
      initVal: card.linkmenu || [],
      required: true,
      options: menulist,
      forbidden: appType === 'mob'
      options: menulist
    },
    {
      type: 'textarea',
      key: 'linkurl',
      label: '链接地址',
      initVal: card.linkurl || '',
      required: true,
      forbidden: appType === 'mob'
      required: true
    },
    {
      type: 'multiselect',
@@ -376,31 +449,6 @@
      initVal: card.linkfields || [],
      required: false,
      options: fields,
      forbidden: appType === 'mob'
    },
    {
      type: 'radio',
      key: 'open',
      label: '打开方式',
      initVal: card.open || 'blank',
      required: false,
      forbid: appType !== 'pc',
      options: [
        { value: 'blank', text: '新窗口' },
        { value: 'self', text: '当前窗口' }
      ]
    },
    {
      type: 'radio',
      key: 'eval',
      label: '解析',
      initVal: card.eval || 'true',
      tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。',
      required: false,
      options: [
        { value: 'true', text: '是' },
        { value: 'false', text: '否' }
      ]
    },
    {
      type: 'textarea',
@@ -412,13 +460,27 @@
      required: true
    },
    {
      type: 'radio',
      key: 'noValue',
      label: '空值',
      initVal: card.noValue || 'show',
      tooltip: '数值为 0 或时间小于 1949-10-02 时,是否显示',
      required: false,
      options: [{
        value: 'show',
        text: '显示'
      }, {
        value: 'hide',
        text: '隐藏'
      }]
    },
    {
      type: 'multiselect',
      key: 'blacklist',
      label: Formdict['header.form.blacklist'],
      label: '黑名单',
      initVal: card.blacklist || [],
      required: false,
      options: roleList,
      forbidden: appType === 'mob'
      options: roleList
    }
  ]
}