king
2021-05-26 f66e19dd13af07ee466306632ad43c72f1f16ae7
src/menu/components/card/cardcellcomponent/formconfig.jsx
@@ -1,16 +1,58 @@
// import zhCN from '@/locales/zh-CN/model.js'
// import enUS from '@/locales/en-US/model.js'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
// const Formdict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
const Formdict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
/**
 * @description 获取按钮表单配置信息
 * @param {*} card           编辑按钮
 * @param {*} setting        组件配置
 * @param {*} permFuncField  存储过程可用的开始字段
 * @param {*} type           按钮类型,用于区分可选的打开方式
 * @description 获取元素配置信息
 * @param {*} card
 * @param {*} type
 */
export function getCardCellForm (card) {
export function getCardCellForm (card, type, subtype, cardCell) {
  let _options = [
    { value: 'text', text: '文本'},
    { value: 'number', text: '数值'},
    { value: 'picture', text: '图片'},
    { value: 'video', text: '视频'},
    { value: 'icon', text: '图标'},
    { value: 'slider', text: '进度条'},
    { value: 'splitline', text: '分割线'},
    { value: 'barcode', text: '条形码'},
    { value: 'qrcode', text: '二维码'},
    { value: 'currentDate', text: '当前时间'},
  ]
  if (type === 'table' || (type === 'card' && subtype === 'datacard')) {
    _options.push({value: 'sequence', text: '序号'})
  }
  let appMenus = []
  const isApp = sessionStorage.getItem('appType') === 'pc'
  if (isApp) {
    appMenus = sessionStorage.getItem('appMenus')
    if (appMenus) {
      try {
        appMenus = JSON.parse(appMenus)
        appMenus = appMenus.map(item => ({value: item.MenuID, text: item.MenuName}))
      } catch {
        appMenus = []
      }
    } else {
      appMenus = []
    }
  }
  let dataTypes = [
    { value: 'dynamic', text: '动态' },
    { value: 'static', text: '静态' }
  ]
  if (cardCell.$cardType === 'extendCard') {
    card.datatype = 'static'
    dataTypes = [
      { value: 'static', text: '静态' }
    ]
  }
  let forms = [
    {
      type: 'select',
@@ -18,15 +60,7 @@
      label: '元素类型',
      initVal: card.eleType,
      required: true,
      options: [
        { value: 'text', text: '文本'},
        { value: 'number', text: '数值'},
        { value: 'picture', text: '图片'},
        { value: 'icon', text: '图标'},
        { value: 'link', text: '链接'},
        { value: 'slider', text: '进度条'},
        { value: 'splitline', text: '分割线'},
      ]
      options: _options
    },
    {
      type: 'select',
@@ -75,10 +109,7 @@
      label: '数据类型',
      initVal: card.datatype || 'static',
      required: true,
      options: [
        { value: 'dynamic', text: '动态' },
        { value: 'static', text: '静态' }
      ]
      options: dataTypes
    },
    {
      type: 'select',
@@ -89,27 +120,71 @@
      options: []
    },
    {
      type: 'file',
      key: 'url',
      label: '图片',
      initVal: card.url || '',
      maxfile: 1,
      required: false
    },
    {
      type: 'text',
      key: 'value',
      min: 0,
      label: '内容',
      initVal: card.value || '',
      tooltip: '文本类型,会替换内容中的@username@、@fullName@、@login_city@。',
      required: true
    },
    {
      type: 'select',
      key: 'labelfield',
      label: '提示字段',
      initVal: card.labelfield || '',
      type: 'file',
      key: 'url',
      label: '图片/文件',
      initVal: card.url || '',
      maxfile: 1,
      required: true
    },
    {
      type: 'radio',
      key: 'autoPlay',
      label: '自动播放',
      initVal: card.autoPlay || 'false',
      required: false,
      options: []
      options: [
        { value: 'true', text: '是' },
        { value: 'false', text: '否' }
      ]
    },
    {
      type: 'radio',
      key: 'loop',
      label: '循环播放',
      initVal: card.loop || 'false',
      required: false,
      options: [
        { value: 'true', text: '是' },
        { value: 'false', text: '否' }
      ]
    },
    {
      type: 'select',
      key: 'format',
      label: '格式化',
      initVal: card.format || '',
      required: false,
      options: [],
      oriOptions: [
        { value: '', text: '无' },
        { value: 'percent', text: '百分数' },
        { value: 'thdSeparator', text: '千分位' },
        { value: 'YYYY-MM-DD', text: 'YYYY-MM-DD' }
      ]
    },
    {
      type: 'select',
      key: 'dateFormat',
      label: '格式化',
      initVal: card.dateFormat || 'YYYY-MM-DD',
      required: true,
      options: [
        { value: 'YYYY-MM-DD', text: 'YYYY-MM-DD' },
        { value: 'YYYY', text: 'YYYY' },
        { value: 'YYYY-MM', text: 'YYYY-MM' },
        { value: 'YYYY-MM-DD HH:mm', text: 'YYYY-MM-DD HH:mm' },
        { value: 'YYYY-MM-DD HH:mm:ss', text: 'YYYY-MM-DD HH:mm:ss' },
      ]
    },
    {
      type: 'text',
@@ -134,24 +209,10 @@
      required: false
    },
    {
      type: 'select',
      key: 'format',
      label: '格式化',
      initVal: card.format || '',
      tooltip: '注:百分数、千分位对于数值类型有效,YYYY-MM-DD对于时间类型的文本有效。',
      required: false,
      options: [
        { value: '', text: '无' },
        { value: 'percent', text: '百分数' },
        { value: 'thdSeparator', text: '千分位' },
        { value: 'YYYY-MM-DD', text: 'YYYY-MM-DD' }
      ]
    },
    {
      type: 'color',
      key: 'color',
      label: '颜色',
      initVal: card.color,
      initVal: card.color || 'rgba(0, 0, 0, 0.85)',
      required: true
    },
    {
@@ -169,9 +230,9 @@
      min: 1,
      max: 24,
      precision: 0,
      label: '宽度',
      label: '元素宽度',
      initVal: card.width || 12,
      tooltip: '每行等分为24份。',
      tooltip: '栅格布局,每行等分为24列。',
      required: true
    },
    {
@@ -180,8 +241,57 @@
      min: 1,
      max: 10,
      label: '高度(行)',
      initVal: card.height || 1,
      initVal: card.height,
      tooltip: '内容显示行数,值为空时高度自适应,注:自适应高度仅在设置卡片高度后有效。',
      required: false
    },
    {
      type: 'number',
      key: 'barHeight',
      min: 5,
      max: 50,
      label: '高度',
      initVal: card.barHeight || 25,
      required: true,
    },
    {
      type: 'number',
      key: 'qrWidth',
      min: 5,
      max: 500,
      label: '宽度',
      initVal: card.qrWidth || 50,
      required: true,
    },
    {
      type: 'number',
      key: 'interval',
      min: 0.1,
      max: 10,
      precision: 1,
      label: '线条间隔',
      initVal: card.interval || 1,
      required: true,
    },
    {
      type: 'radio',
      key: 'displayValue',
      label: '显示值',
      initVal: card.displayValue || 'false',
      required: false,
      options: [
        { value: 'true', text: '是' },
        { value: 'false', text: '否' }
      ]
    },
    {
      type: 'number',
      key: 'borderWidth',
      min: 0,
      max: 50,
      label: '线宽',
      initVal: card.borderWidth || 1,
      required: true
    },
    {
      type: 'select',
@@ -191,22 +301,114 @@
      required: true,
      options: [
        { value: '1:1', text: '1:1' },
        { value: '4:3', text: '4:3' },
        { value: '3:2', text: '3:2' },
        { value: '16:9', text: '16:9' },
        { value: '2:1', text: '2:1' },
        { value: '3:1', text: '3:1' },
        { value: '4:1', text: '4:1' },
        { value: '5:1', text: '5:1' },
        { value: '6:1', text: '6:1' },
        { value: '7:1', text: '7:1' },
        { value: '8:1', text: '8:1' },
        { value: '9:1', text: '9:1' },
        { value: '10:1', text: '10:1' },
        { value: '3:4', text: '3:4' },
        { value: '2:3', text: '2:3' },
        { value: '9:16', text: '9:16' },
      ]
    },
    {
      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',
      key: 'radius',
      label: '圆角',
      initVal: card.radius || 'false',
      key: 'link',
      label: '链接',
      initVal: card.link || '',
      tooltip: '动态地址为绑定字段值。',
      required: false,
      forbid: isApp,
      options: [
        { value: 'true', text: '有' },
        { value: 'false', text: '无' }
        { value: '', text: '无' },
        { value: 'dynamic', text: '动态' },
        { value: 'static', text: '静态' }
      ]
    },
    {
      type: 'select',
      key: 'link',
      label: '链接',
      initVal: card.link || '',
      required: false,
      forbid: !isApp,
      options: [
        { value: '', text: '无' },
        { value: 'page', text: '菜单' },
        { value: 'linkpage', text: '关联菜单' },
        { value: 'custom', text: '链接' }
      ]
    },
    {
      type: 'select',
      key: 'linkmenu',
      label: '关联菜单',
      initVal: card.linkmenu || '',
      required: true,
      forbid: !isApp,
      options: appMenus
    },
    {
      type: 'radio',
      key: 'open',
      label: '打开方式',
      initVal: card.open || 'blank',
      required: false,
      forbid: !isApp,
      options: [
        { value: 'blank', text: '新页面' },
        { value: 'self', text: '当前页面' }
      ]
    },
    {
      type: 'select',
      key: 'copyMenuId',
      label: '复制菜单',
      initVal: card.copyMenuId || '',
      required: false,
      forbid: !isApp,
      options: appMenus
    },
    {
      type: 'radio',
      key: 'joint',
      label: Formdict['model.form.paramJoint'],
      initVal: card.joint || 'true',
      required: false,
      options: [{
        value: 'true',
        text: Formdict['model.true']
      }, {
        value: 'false',
        text: Formdict['model.false']
      }]
    },
    {
      type: 'select',
      key: 'linkurl',
      label: '链接地址',
      initVal: card.linkurl || '',
      required: true,
      options: []
    },
  ]
  return forms