king
2024-05-21 f0bf8c399c354c22227f8f1a76ed806098db59c0
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,17 @@
      appMenus = []
    }
    appMenus.push({value: 'goback', text: '返回(上一页)'})
  }
  let fields = []
  let isStatic = (cards.subtype === 'propcard' || cards.type === 'balcony') && cards.wrap.datatype === 'static'
  if (isStatic) {
    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 }))
      }
    }
  }
  let forms = [
@@ -145,12 +171,17 @@
      ]
    },
    {
      type: 'select',
      type: isStatic ? 'text' : 'select',
      key: 'field',
      label: '字段',
      initVal: card.field || '',
      tooltip: isStatic ? '可绑定上级组件字段,不存在上级组件时可绑定url参数字段。' : '',
      required: true,
      options: []
      options: fields,
      rules: [{
        pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig,
        message: '字段名只允许包含数字、字母、汉字以及_-'
      }]
    },
    {
      type: 'icon',
@@ -165,7 +196,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 +260,12 @@
      required: true
    },
    {
      type: 'select',
      type: isStatic ? 'text' : 'select',
      key: 'posterField',
      label: '预览地址',
      initVal: card.posterField || '',
      required: true
      required: true,
      options: fields
    },
    {
      type: 'radio',
@@ -301,6 +333,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 +460,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 +479,14 @@
      required: false
    },
    {
      type: 'select',
      type: isStatic ? 'text' : 'select',
      key: 'bgImage',
      label: '动态背景',
      initVal: card.bgImage || '',
      tooltip: '绑定数据源字段,可根据返回值改变背景图。',
      required: false,
      allowClear: true,
      options: [],
      options: fields,
      forbid: isHeader
    },
    {
@@ -579,7 +612,7 @@
      key: 'link',
      label: '链接',
      initVal: card.link || '',
      tooltip: '动态地址为绑定字段值。',
      tooltip: '动态地址为绑定字段值。使用 动态-关联菜单 时,请在“链接地址”字段返回菜单ID。',
      required: false,
      options: [
        { value: '', text: '无' },
@@ -589,7 +622,7 @@
      forbid: isHeader
    },
    {
      type: linkTypes.length > 4 ? 'select' : 'radio',
      type: 'select',
      key: 'linkType',
      label: '链接类型',
      initVal: card.linkType || 'other',
@@ -612,18 +645,31 @@
      key: 'linkmenu',
      label: '关联菜单',
      initVal: card.linkmenu || '',
      tooltip: '行信息(字段集中前40个长度不超过256的字段)将传递至此菜单,可在url变量、表单(关联主表)、静态属性卡、浮动卡中使用。',
      required: true,
      options: appMenus || [],
      forbid: !['pc', 'mob'].includes(appType)
    },
    {
      type: 'select',
      type: 'cascader',
      key: 'linkmenu',
      label: '关联菜单',
      initVal: card.linkmenu || [],
      tooltip: '行信息将传递至此菜单,可在url变量、表单(关联主表)、静态属性卡、浮动卡中使用。',
      required: true,
      options: menulist,
      forbid: ['pc', 'mob'].includes(appType)
    },
    {
      type: isStatic ? 'text' : 'select',
      defType: isStatic ? 'text' : 'select',
      key: 'linkurl',
      label: '链接地址',
      initVal: card.linkurl || '',
      tooltip: ['pc', 'mob'].includes(appType) ? '当链接类型为“其他”,且链接地址以@menuid@开头时,其后内容将被视为菜单ID。' : '',
      tooltip: '在链接中以@***@形式拼接的字段(字段来源于字段集中,此外 id、appkey、userid、LoginUID 为系统字段),跳转时将替换为对应值,例如:http://sso.mk9h.cn/doc/index.html?appkey=@appkey@&LoginUID=@LoginUID@,其中appkey与LoginUID将被替换。' + (['pc', 'mob'].includes(appType) ? '当链接类型为“其他”,且链接地址以@menuid@开头时,其后内容将被视为菜单ID。' : ''),
      toolWidth: 350,
      required: true,
      options: []
      options: fields
    },
    {
      type: 'radio',
@@ -639,25 +685,12 @@
      ]
    },
    {
      type: 'radio',
      key: 'joint',
      label: '拼接参数',
      initVal: card.joint || 'true',
      required: false,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      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@。',
      toolWidth: 450,
      placeholder: '例如:@price@ * @number@',
      required: true
    },
@@ -773,6 +806,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