king
2022-08-06 cbeffcc0902631909c0373f274752a97ddaf2d4e
src/templates/zshare/formconfig.jsx
@@ -13,6 +13,17 @@
export function getTreeSettingForm (setting, usefulFields = [], MenuID) {
  let str = '^(' + usefulFields.join('|') + ')'
  let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g')
  let rules = [{
    max: formRule.func.max,
    message: formRule.func.maxMessage
  }]
  if (usefulFields.length > 0) {
    rules.push({
      pattern: _patten,
      message: formRule.func.innerMessage
    })
  }
  return [
    {
@@ -103,19 +114,11 @@
      key: 'innerFunc',
      label: Formdict['header.form.innerFunc'],
      initVal: setting.innerFunc || '',
      tooltip: '开头可用字符:' + usefulFields.join(', '),
      tooltip: usefulFields.length ? '开头可用字符:' + usefulFields.join(', ') : '',
      placement: 'bottomLeft',
      required: false,
      readonly: false,
      rules: [
        {
          pattern: _patten,
          message: formRule.func.innerMessage
        }, {
          max: formRule.func.max,
          message: formRule.func.maxMessage
        }
      ]
      rules: rules
    },
    {
      type: 'datasource',
@@ -286,7 +289,7 @@
 * @param {object} card           // 搜索条件对象
 * @param {Array}  linkableFields // 可关联字段
 */
export function getSearchForm (card, linkableFields) {
export function getSearchForm (card, linkableFields, columns, position) {
  let roleList = sessionStorage.getItem('sysRoles')
  let appType = sessionStorage.getItem('appType')
  if (roleList) {
@@ -318,7 +321,7 @@
      text: '选项卡'
    }, {
      value: 'date',
      text: Formdict['model.form.dateday']
      text: '日期(天)'
    }, {
      value: 'datemonth',
      text: Formdict['model.form.datemonth']
@@ -345,10 +348,10 @@
      text: '选项卡'
    }, {
      value: 'date',
      text: Formdict['model.form.dateday']
      text: '日期(天)'
    }, {
      value: 'dateweek',
      text: Formdict['model.form.dateweek']
      text: '日期(周)'
    }, {
      value: 'datemonth',
      text: Formdict['model.form.datemonth']
@@ -396,7 +399,8 @@
      key: 'field',
      label: Formdict['model.form.field'],
      initVal: card.field || '',
      required: true
      required: true,
      options: columns
    },
    {
      type: 'select',
@@ -460,6 +464,9 @@
      }, {
        value: 'picture',
        text: '图片'
      }, {
        value: 'color',
        text: '色块'
      }]
    },
    {
@@ -786,8 +793,8 @@
      key: 'advanced',
      label: '高级搜索',
      initVal: card.advanced || 'false',
      tooltip: '在隐藏搜索按钮时,高级搜索无效。',
      forbid: appType === 'mob',
      tooltip: '在高级搜索以模态框或抽屉展开时,搜索条件在开发界面占比为6,实际效果请在运行时查看。',
      forbid: appType === 'mob' || position === 'header',
      options: [{
        value: 'true',
        text: Formdict['model.true']
@@ -826,19 +833,29 @@
      }]
    },
    {
      type: 'radio',
      key: 'selectStyle',
      label: '选中效果',
      tooltip: '背景及文字变化时会使用系统色。',
      initVal: card.selectStyle || (card.backgroundColor ? 'custom' : 'background'),
      options: [{
        value: 'background',
        text: '背景变化'
      }, {
        value: 'font',
        text: '文字变化'
      }, {
        value: 'custom',
        text: '自定义'
      }]
    },
    {
      type: 'color',
      key: 'backgroundColor',
      label: '背景色',
      initVal: card.backgroundColor || '',
      tooltip: '设置背景色后,选中效果由背景颜色控制。',
      required: false
    },
    {
      type: 'color',
      key: 'borderColor',
      label: '边框颜色',
      initVal: card.borderColor || '',
      required: false
      required: true
    },
    {
      type: 'multiselect',
@@ -846,7 +863,8 @@
      label: Formdict['header.form.blacklist'],
      initVal: card.blacklist || [],
      required: false,
      options: roleList || []
      options: roleList || [],
      forbid: appType === 'mob'
    }
  ]
}
@@ -929,6 +947,10 @@
    card.control = 'disabled'
  }
  if (card.intertype === 'outer' && !card.procMode && !card.innerFunc) { // 兼容外部函数直传类型
    card.procMode = 'none'
  }
  return [
    {
      type: 'select',
@@ -937,6 +959,14 @@
      initVal: card.OpenType,
      required: true,
      options: opentypes
    },
    {
      type: 'text',
      key: 'label',
      label: '按钮名称',
      initVal: card.label,
      required: true,
      readonly: false
    },
    {
      type: 'select',
@@ -956,6 +986,9 @@
      }, {
        value: 'megvii',
        text: '旷视面板机'
      }, {
        value: 'filezip',
        text: '文件压缩包'
      }]
    },
    { // 旷视面板机接口 待扩展
@@ -997,7 +1030,8 @@
      type: 'radio',
      key: 'procMode',
      label: '参数处理',
      initVal: card.procMode || 'system',
      initVal: card.procMode || (card.innerFunc ? 'inner' : 'system'),
      tooltip: '当返回值存在 mk_ex_invoke 且值为 false 时,不会调用外部接口。',
      required: true,
      options: [{
        value: 'system',
@@ -1005,6 +1039,9 @@
      }, {
        value: 'inner',
        text: '内部函数'
      }, {
        value: 'none',
        text: '无'
      }]
    },
    {
@@ -1014,14 +1051,6 @@
      initVal: card.sqlType || '',
      required: true,
      options: []
    },
    {
      type: 'text',
      key: 'label',
      label: '按钮名称',
      initVal: card.label,
      required: true,
      readonly: false
    },
    {
      type: 'text',
@@ -1035,9 +1064,18 @@
      key: 'innerFunc',
      label: Formdict['header.form.innerFunc'],
      initVal: card.innerFunc || '',
      tooltip: `函数名称需以${usefulFields.join(', ')}等字符开始。`,
      tooltip: usefulFields.length ? `函数名称需以${usefulFields.join(', ')}等字符开始。` : '',
      fields: usefulFields,
      required: card.intertype === 'inner',
      readonly: false
    },
    {
      type: 'text',
      key: 'urlkey',
      label: '地址字段',
      initVal: card.urlkey || '',
      tooltip: '图片(文件)链接的字段名。',
      required: false,
      readonly: false
    },
    {
@@ -1163,7 +1201,7 @@
      type: 'radio',
      key: 'callbackType',
      label: '回调方式',
      initVal: card.callbackType || 'script',
      initVal: card.callbackType || (card.callbackFunc ? 'func' : 'script'),
      tooltip: '使用后台脚本执行时,需要配合计划任务。',
      required: true,
      options: [{
@@ -1172,6 +1210,12 @@
      }, {
        value: 'default',
        text: '后台脚本'
      }, {
        value: 'func',
        text: '回调函数'
      }, {
        value: 'none',
        text: '无'
      }]
    },
    {
@@ -1186,7 +1230,7 @@
      key: 'callbackFunc',
      label: Formdict['header.form.callbackFunc'],
      initVal: card.callbackFunc || '',
      required: false,
      required: true,
      readonly: false
    },
    {
@@ -1322,7 +1366,7 @@
      type: 'text',
      key: 'output',
      label: '返回值',
      tooltip: '执行成功后的返回值。例如:@id',
      tooltip: '执行成功后的返回值。系统函数可指定返回的变量(以@符开头,如@id);自定义函数可指定返回字段(如id)。',
      initVal: card.output || '',
      required: false
    },
@@ -1447,7 +1491,7 @@
      key: 'preFunc',
      label: '前置函数',
      initVal: card.preFunc || '',
      tooltip: `函数名称需以${usefulFields.join(', ')}等字符开始;前置函数执行完成后,结果会传入内部函数中,此时内部函数会异步执行;当前置函数返回中ErrCode等于-1时,将不再执行内部函数。`,
      tooltip: usefulFields.length ? `函数名称需以${usefulFields.join(', ')}等字符开始;前置函数执行完成后,结果会传入内部函数中,此时内部函数会异步执行;当前置函数返回中ErrCode等于-1时,将不再执行内部函数。` : '',
      fields: usefulFields,
      required: false,
      readonly: false
@@ -1506,6 +1550,20 @@
      }, {
        value: 'true',
        text: '是'
      }]
    },
    {
      type: 'radio',
      key: 'progress',
      label: '进度提示',
      initVal: card.progress || 'number',
      required: false,
      options: [{
        value: 'number',
        text: '剩余数'
      }, {
        value: 'progressbar',
        text: '进度条'
      }]
    }
  ]
@@ -2337,10 +2395,10 @@
    text: '选项卡'
  }, {
    value: 'fileupload',
    text: Formdict['header.form.fileupload']
    text: '文件上传'
  }, {
    value: 'date',
    text: Formdict['model.form.dateday']
    text: '日期(天)'
  }, {
    value: 'datemonth',
    text: Formdict['model.form.datemonth']
@@ -2350,6 +2408,9 @@
  }, {
    value: 'textarea',
    text: Formdict['model.form.textarea']
  }, {
    value: 'cascader',
    text: '级联菜单'
  }, {
    value: 'rate',
    text: '评分'
@@ -2371,6 +2432,9 @@
  }, {
    value: 'linkMain',
    text: '关联主表'
  }, {
    value: 'formula',
    text: '公式'
  }]
  let _fieldlength = 50
@@ -2402,10 +2466,10 @@
      text: '选项卡'
    }, {
      value: 'fileupload',
      text: Formdict['header.form.fileupload']
      text: '文件上传'
    }, {
      value: 'date',
      text: Formdict['model.form.dateday']
      text: '日期(天)'
    }, {
      value: 'datemonth',
      text: Formdict['model.form.datemonth']
@@ -2415,6 +2479,9 @@
    }, {
      value: 'textarea',
      text: Formdict['model.form.textarea']
    }, {
      value: 'cascader',
      text: '级联菜单'
    }, {
      value: 'rate',
      text: '评分'
@@ -2430,6 +2497,9 @@
    }, {
      value: 'linkMain',
      text: '关联主表'
    }, {
      value: 'formula',
      text: '公式'
    }]
  }
@@ -2539,10 +2609,10 @@
      required: true,
      options: [{
        value: '0',
        text: Formdict['header.form.custom']
        text: '自定义'
      }, {
        value: '1',
        text: Formdict['header.form.datasource']
        text: '数据源'
      }]
    },
    {
@@ -2557,6 +2627,9 @@
      }, {
        value: 'picture',
        text: '图片'
      }, {
        value: 'color',
        text: '色块'
      }]
    },
    {
@@ -2588,9 +2661,9 @@
    },
    {
      type: 'radio',
      key: 'ratio',
      key: 'picratio',
      label: '图片比例',
      initVal: card.ratio || '1:1',
      initVal: card.picratio || card.ratio || '1:1',
      required: true,
      options: [{
        value: '1:1',
@@ -2669,6 +2742,14 @@
    },
    {
      type: 'text',
      key: 'topmark',
      label: '顶级标识',
      initVal: card.topmark || '',
      tooltip: '关联字段值与顶级标识相同时,视为顶级节点。',
      required: false
    },
    {
      type: 'text',
      key: 'valueField',
      label: '值·字段',
      initVal: card.valueField || '',
@@ -2712,16 +2793,6 @@
      tooltip: '设置禁用字段,且字段值为true时,选项不可选。',
      required: false,
      readonly: false
    },
    {
      type: 'number',
      key: 'decimal',
      min: 0,
      max: 18,
      precision: 0,
      label: Formdict['header.form.decimal'],
      initVal: card.decimal || 0,
      required: true
    },
    {
      type: 'number',
@@ -2857,6 +2928,53 @@
      }]
    },
    {
      type: 'radio',
      key: 'declareType',
      label: '数据类型',
      tooltip: '声明变量时的类型,时间格式datetime或文本格式nvarchar(50)。',
      initVal: card.declareType || 'datetime',
      options: [{
        value: 'datetime',
        text: 'datetime'
      }, {
        value: 'nvarchar(50)',
        text: 'nvarchar(50)'
      }]
    },
    {
      type: 'text',
      key: 'separator',
      label: '连接符',
      initVal: card.separator || card.separator === undefined ? '/' : '',
      tooltip: '表单提交时信息之间的连接符。注:连接符为空时,初始化时填充其他表单无效。',
      required: false,
      readonly: false
    },
    {
      type: 'radio',
      key: 'declare',
      label: '数据类型',
      initVal: card.declare || 'nvarchar',
      tooltip: '声明变量时的类型。使用 decimal 时,请确认Value为数值,且不可为空。',
      options: [{
        value: 'nvarchar',
        text: 'nvarchar'
      }, {
        value: 'decimal',
        text: 'decimal'
      }]
    },
    {
      type: 'number',
      key: 'decimal',
      min: 0,
      max: 18,
      precision: 0,
      label: Formdict['header.form.decimal'],
      initVal: card.decimal || 0,
      required: true
    },
    {
      type: 'number',
      key: 'fieldlength',
      min: 1,
@@ -2885,16 +3003,16 @@
      initVal: card.regular || '',
      options: [{
        value: '',
        text: Formdict['model.empty']
        text: '空'
      }, {
        value: 'number',
        text: Formdict['model.form.number']
        text: '数字'
      }, {
        value: 'letter',
        text: Formdict['header.form.letter']
        text: '字母'
      }, {
        value: 'letter&number',
        text: '字母+数字'
        text: '数字、字母以及_@_.'
      }, {
        value: 'phone',
        text: '手机号'
@@ -3120,33 +3238,29 @@
      }]
    },
    {
      type: 'radio',
      key: 'selectStyle',
      label: '选中效果',
      tooltip: '背景及文字变化时会使用系统色。',
      initVal: card.selectStyle || (card.backgroundColor ? 'custom' : 'background'),
      options: [{
        value: 'background',
        text: '背景变化'
      }, {
        value: 'font',
        text: '文字变化'
      }, {
        value: 'custom',
        text: '自定义'
      }]
    },
    {
      type: 'color',
      key: 'backgroundColor',
      label: '背景色',
      initVal: card.backgroundColor || '',
      tooltip: '设置背景色后,选中效果由背景颜色控制。',
      required: false
    },
    {
      type: 'color',
      key: 'borderColor',
      label: '边框颜色',
      initVal: card.borderColor || '',
      required: false
    },
    {
      type: 'radio',
      key: 'declareType',
      label: '数据类型',
      tooltip: '声明变量时的类型,时间格式datetime或文本格式nvarchar(50)。',
      initVal: card.declareType || 'datetime',
      options: [{
        value: 'datetime',
        text: 'datetime'
      }, {
        value: 'nvarchar(50)',
        text: 'nvarchar(50)'
      }]
      required: true
    },
    // {
    //   type: 'radio',
@@ -3167,12 +3281,16 @@
      key: 'encryption',
      label: '加密传输',
      initVal: card.type === 'brafteditor' ? (card.encryption || 'true') : (card.encryption || 'false'),
      tooltip: '使用md5加密时,加密前内容会转为小写,加密后的md5值为32位大写。',
      options: [{
        value: 'true',
        text: Formdict['model.true']
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '无'
      }, {
        value: 'true',
        text: 'base64加密'
      }, {
        value: 'md5',
        text: 'md5加密'
      }]
    },
    {
@@ -3188,6 +3306,37 @@
        value: 'false',
        text: Formdict['model.false']
      }]
    },
    {
      type: 'textarea',
      key: 'formula',
      label: '公式',
      initVal: card.formula || '',
      tooltip: '动态替换相应的字段,展示获得的结果。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等',
      rows: 2,
      required: true
    },
    {
      type: 'radio',
      key: 'eval',
      label: '解析',
      initVal: card.eval || 'true',
      tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。',
      required: false,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'text',
      key: 'postfix',
      label: '后缀',
      initVal: card.postfix || '',
      required: false
    },
    {
      type: 'radio',
@@ -3459,35 +3608,36 @@
      initVal: card.linkSubField || [],
      options: inputfields
    },
    {
      type: 'number',
      key: 'marginTop',
      label: '上边距(px)',
      initVal: card.marginTop || 0,
      min: -100,
      max: 1000,
      precision: 0,
      required: false,
      forbid: appType !== 'mob'
    },
    {
      type: 'number',
      key: 'marginBottom',
      label: '下边距(px)',
      initVal: card.marginBottom || 0,
      min: -100,
      max: 1000,
      precision: 0,
      required: false,
      forbid: appType !== 'mob'
    },
    // {
    //   type: 'number',
    //   key: 'marginTop',
    //   label: '上边距(px)',
    //   initVal: card.marginTop || 0,
    //   min: -100,
    //   max: 1000,
    //   precision: 0,
    //   required: false,
    //   forbid: appType !== 'mob'
    // },
    // {
    //   type: 'number',
    //   key: 'marginBottom',
    //   label: '下边距(px)',
    //   initVal: card.marginBottom || 0,
    //   min: -100,
    //   max: 1000,
    //   precision: 0,
    //   required: false,
    //   forbid: appType !== 'mob'
    // },
    {
      type: 'multiselect',
      key: 'blacklist',
      label: Formdict['header.form.blacklist'],
      initVal: card.blacklist || [],
      required: false,
      options: roleList
      options: roleList,
      forbid: appType === 'mob'
    }
  ]
}