king
2020-11-25 42fae277ae5ebe794fc070bf38482a919eb661fc
src/menu/components/card/cardcellcomponent/formconfig.jsx
@@ -1,16 +1,31 @@
// 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 = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
/**
 * @description 获取按钮表单配置信息
 * @param {*} card           编辑按钮
 * @param {*} setting        组件配置
 * @param {*} permFuncField  存储过程可用的开始字段
 * @param {*} type           按钮类型,用于区分可选的打开方式
 */
export function getCardCellForm (card) {
export function getCardCellForm (card, type) {
  let _options = [
    { value: 'text', text: '文本'},
    { value: 'number', text: '数值'},
    { value: 'picture', text: '图片'},
    { value: 'icon', text: '图标'},
    { value: 'link', text: '链接'},
    { value: 'slider', text: '进度条'},
    { value: 'splitline', text: '分割线'},
    { value: 'barcode', text: '条形码'},
    { value: 'qrcode', text: '二维码'},
    { value: 'currentDate', text: '当前时间'},
  ]
  if (type === 'table') {
    _options.push({value: 'sequence', text: '序号'})
  }
  let forms = [
    {
      type: 'select',
@@ -18,71 +33,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: '分割线'},
      ]
    },
    {
      type: 'radio',
      key: 'datatype',
      label: '数据类型',
      initVal: card.datatype || 'dynamic',
      required: true,
      options: [
        { value: 'dynamic', text: '动态' },
        { value: 'static', text: '静态' }
      ]
    },
    {
      type: 'select',
      key: 'field',
      label: '字段',
      initVal: card.field || '',
      required: true,
      options: []
    },
    {
      type: 'file',
      key: 'url',
      label: '图片',
      initVal: card.url || '',
      maxfile: 1,
      required: false
    },
    {
      type: 'text',
      key: 'value',
      label: '内容',
      initVal: card.value || '',
      required: true
    },
    {
      type: 'select',
      key: 'labelfield',
      label: '提示字段',
      initVal: card.labelfield || '',
      required: false,
      options: []
    },
    {
      type: 'text',
      key: 'prefix',
      label: '前缀',
      initVal: card.prefix || '',
      required: false
    },
    {
      type: 'text',
      key: 'postfix',
      label: '后缀',
      initVal: card.postfix || '',
      required: false
      options: _options
    },
    {
      type: 'select',
@@ -126,11 +77,45 @@
      ]
    },
    {
      type: 'radio',
      key: 'datatype',
      label: '数据类型',
      initVal: card.datatype || 'static',
      required: true,
      options: [
        { value: 'dynamic', text: '动态' },
        { value: 'static', text: '静态' }
      ]
    },
    {
      type: 'select',
      key: 'field',
      label: '字段',
      initVal: card.field || '',
      required: true,
      options: []
    },
    {
      type: 'text',
      key: 'tooltip',
      label: '提示信息',
      initVal: card.tooltip || '',
      tooltip: '鼠标悬浮时显示。',
      key: 'value',
      min: 0,
      label: '内容',
      initVal: card.value || '',
      required: true
    },
    {
      type: 'file',
      key: 'url',
      label: '图片',
      initVal: card.url || '',
      maxfile: 1,
      required: false
    },
    {
      type: 'text',
      key: 'label',
      label: '显示信息',
      initVal: card.label || '',
      required: false
    },
    {
@@ -148,10 +133,46 @@
      ]
    },
    {
      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',
      key: 'prefix',
      label: '前缀',
      initVal: card.prefix || '',
      required: false
    },
    {
      type: 'text',
      key: 'postfix',
      label: '后缀',
      initVal: card.postfix || '',
      required: false
    },
    {
      type: 'text',
      key: 'tooltip',
      label: '提示信息',
      initVal: card.tooltip || '',
      tooltip: '鼠标悬浮时显示。',
      required: false
    },
    {
      type: 'color',
      key: 'color',
      label: '颜色',
      initVal: card.color,
      initVal: card.color || 'rgba(0, 0, 0, 0.85)',
      required: true
    },
    {
@@ -169,9 +190,9 @@
      min: 1,
      max: 24,
      precision: 0,
      label: '宽度',
      label: '元素宽度',
      initVal: card.width || 12,
      tooltip: '每行等分为24份。',
      tooltip: '栅格布局,每行等分为24列。',
      required: true
    },
    {
@@ -182,6 +203,54 @@
      label: '高度(行)',
      initVal: card.height || 1,
      required: true,
    },
    {
      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',
@@ -198,14 +267,17 @@
    },
    {
      type: 'radio',
      key: 'radius',
      label: '圆角',
      initVal: card.radius || 'false',
      key: 'joint',
      label: Formdict['model.form.paramJoint'],
      initVal: card.joint || 'true',
      required: false,
      options: [
        { value: 'true', text: '有' },
        { value: 'false', text: '无' }
      ]
      options: [{
        value: 'true',
        text: Formdict['model.true']
      }, {
        value: 'false',
        text: Formdict['model.false']
      }]
    },
  ]