king
2024-04-29 f9816a4078fdba44115c69025d9982997f23b484
src/menu/components/card/cardcellcomponent/formconfig.jsx
@@ -1,3 +1,4 @@
import React from 'react'
import MenuUtils from '@/utils/utils-custom.js'
/**
@@ -20,6 +21,7 @@
    { value: 'qrcode', text: '二维码'},
    { value: 'currentDate', text: '当前时间'},
    { value: 'formula', text: '公式'},
    { value: 'tag', text: '标签'},
    { value: 'color', text: '颜色'},
  ]
@@ -52,7 +54,7 @@
    _options = [{ value: 'text', text: '文本'}]
  }
  let width = card.width || 12
  let width = card.width === undefined ? 12 : card.width
  if (/x/.test(card.width)) {
    width = +width.replace(/x/, '.5')
  }
@@ -60,6 +62,7 @@
  let linkTypes = [
    { value: 'tel', text: '电话' },
    { value: 'email', text: '邮箱' },
    { value: 'linkmenu', text: '关联菜单' },
    { value: 'download', text: '下载' },
    { value: 'other', text: '其他' }
  ]
@@ -89,13 +92,25 @@
      card.linkType = ''
      card.linkurl = ''
    }
  } else if (card.linkType === 'linkmenu') {
    if (appType !== 'mob' && appType !== 'pc') {
      card.link = ''
      card.linkType = ''
      card.linkurl = ''
      card.linkmenu = ''
  // } else if (card.linkType === 'linkmenu') {
  //   if (appType !== 'mob' && appType !== 'pc') {
  //     card.link = ''
  //     card.linkType = ''
  //     card.linkurl = ''
  //     card.linkmenu = ''
  //   }
  }
  let menulist = sessionStorage.getItem('fstMenuList')
  if (appType === '' && menulist) {
    try {
      menulist = JSON.parse(menulist)
    } catch (e) {
      menulist = []
    }
  } else {
    menulist = []
  }
  let appMenus = sessionStorage.getItem('appMenus')
@@ -110,6 +125,18 @@
      appMenus = []
    }
    appMenus.push({value: 'goback', text: '返回(上一页)'})
  }
  let fields = []
  if (cards.subtype === 'propcard' && cards.wrap.datatype === 'static') {
    if (cards.wrap.supModule && cards.wrap.supModule.length) {
      let cell = MenuUtils.getComponent(cards.wrap.supModule[cards.wrap.supModule.length - 1])
      if (cell && cell.columns) {
        fields = cell.columns.map(col => ({ value: col.field }))
      }
    } else {
      fields = cards.columns.map(col => ({ value: col.field }))
    }
  }
  let forms = [
@@ -145,12 +172,12 @@
      ]
    },
    {
      type: 'select',
      type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select',
      key: 'field',
      label: '字段',
      initVal: card.field || '',
      required: true,
      options: []
      options: fields
    },
    {
      type: 'icon',
@@ -165,7 +192,7 @@
      min: 0,
      label: '内容',
      initVal: card.value || '',
      tooltip: '文本类型,会替换内容中的@username@、@fullName@、@mk_city@、@appname@、@bid@、@month@、@week@、@day@',
      // tooltip: '文本类型,会替换内容中的@username@、@fullName@、@mk_city@、@appname@、@bid@、@month@、@week@、@day@',
      required: true
    },
    {
@@ -229,11 +256,12 @@
      required: true
    },
    {
      type: 'select',
      type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select',
      key: 'posterField',
      label: '预览地址',
      initVal: card.posterField || '',
      required: true
      required: true,
      options: fields
    },
    {
      type: 'radio',
@@ -301,6 +329,7 @@
        { 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' },
        { value: 'YYYY年MM月DD日', text: 'YYYY年MM月DD日' },
      ]
    },
    {
@@ -427,12 +456,12 @@
    {
      type: 'number',
      key: 'width',
      min: 0.5,
      min: 0,
      max: 24,
      precision: 1,
      label: '元素宽度',
      initVal: width,
      tooltip: '栅格布局,每行等分为24列,可设置半列即.5。',
      tooltip: '栅格布局,每行等分为24列,可设置半列即.5。注:为0时宽度依据内容自适应(文本、数值、提示(图标)、当前时间、公式)。',
      required: true
    },
    {
@@ -446,14 +475,14 @@
      required: false
    },
    {
      type: 'select',
      type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select',
      key: 'bgImage',
      label: '动态背景',
      initVal: card.bgImage || '',
      tooltip: '绑定数据源字段,可根据返回值改变背景图。',
      required: false,
      allowClear: true,
      options: [],
      options: fields,
      forbid: isHeader
    },
    {
@@ -579,7 +608,7 @@
      key: 'link',
      label: '链接',
      initVal: card.link || '',
      tooltip: '动态地址为绑定字段值。',
      tooltip: '动态地址为绑定字段值。使用 动态-关联菜单 时,请在“链接地址”字段返回菜单ID。',
      required: false,
      options: [
        { value: '', text: '无' },
@@ -589,7 +618,7 @@
      forbid: isHeader
    },
    {
      type: linkTypes.length > 4 ? 'select' : 'radio',
      type: 'select',
      key: 'linkType',
      label: '链接类型',
      initVal: card.linkType || 'other',
@@ -617,13 +646,23 @@
      forbid: !['pc', 'mob'].includes(appType)
    },
    {
      type: 'select',
      type: 'cascader',
      key: 'linkmenu',
      label: '关联菜单',
      initVal: card.linkmenu || [],
      required: true,
      options: menulist,
      forbid: ['pc', 'mob'].includes(appType)
    },
    {
      type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select',
      defType: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select',
      key: 'linkurl',
      label: '链接地址',
      initVal: card.linkurl || '',
      tooltip: ['pc', 'mob'].includes(appType) ? '当链接类型为“其他”,且链接地址以@menuid@开头时,其后内容将被视为菜单ID。' : '',
      required: true,
      options: []
      options: fields
    },
    {
      type: 'radio',
@@ -653,11 +692,11 @@
      }]
    },
    {
      type: 'textarea',
      type: 'codemirror',
      key: 'formula',
      label: '公式',
      initVal: card.formula || '',
      tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果,在不使用解析时换行符或空格会替换为页面元素。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等',
      tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果,在不使用解析时换行符或空格会替换为页面元素。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等。注:会替换公式中的@username@、@fullName@、@bid@。',
      placeholder: '例如:@price@ * @number@',
      required: true
    },
@@ -773,6 +812,56 @@
      options: [],
      forbid: !isHeader
    },
    {
      type: 'table',
      key: 'signs',
      label: '标记',
      initVal: card.signs || [],
      tooltip: '可依据标签内容设置不同样式。',
      required: false,
      actions: ['edit', 'del', 'add', 'move'],
      columns: [
        {
          title: '值',
          dataIndex: 'value',
          inputType: 'text',
          editable: true,
          required: true,
          unique: true,
          width: '20%'
        },
        {
          title: '背景',
          dataIndex: 'background',
          inputType: 'color',
          className: 'mini-color',
          editable: true,
          required: true,
          width: '20%',
          render: (text) => <span className="mk-color-value" style={{background: text}}></span>,
        },
        {
          title: '文字',
          dataIndex: 'color',
          inputType: 'color',
          className: 'mini-color',
          editable: true,
          required: true,
          width: '20%',
          render: (text) => <span className="mk-color-value" style={{background: text}}></span>,
        },
        {
          title: '边框',
          dataIndex: 'border',
          inputType: 'color',
          className: 'mini-color',
          editable: true,
          required: true,
          width: '20%',
          render: (text) => <span className="mk-color-value" style={{background: text}}></span>,
        },
      ]
    },
  ]
  return forms