king
2022-06-18 fe21d23b147ed5cec22b4f76a88840b05495d4ad
src/templates/zshare/formconfig.jsx
@@ -1,6 +1,6 @@
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import { formRule } from '@/utils/option.js'
import { formRule, btnClasses } from '@/utils/option.js'
const Formdict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
@@ -286,7 +286,7 @@
 * @param {object} card           // 搜索条件对象
 * @param {Array}  linkableFields // 可关联字段
 */
export function getSearchForm (card, linkableFields) {
export function getSearchForm (card, linkableFields, columns) {
  let roleList = sessionStorage.getItem('sysRoles')
  let appType = sessionStorage.getItem('appType')
  if (roleList) {
@@ -302,6 +302,14 @@
  let typeOptions = []
  if (appType === 'mob') {
    // let adapters = sessionStorage.getItem('adapter')
    // if (adapters) {
    //   adapters = adapters.split(',')
    // } else {
    //   adapters = []
    // }
    // (adapters.includes('wxmini') ? '(小程序暂不支持)' : '')
    typeOptions = [{
      value: 'range',
      text: '数值(区间)'
@@ -318,6 +326,7 @@
    //   value: 'daterange',
    //   text: Formdict['model.form.daterange']
    }]
  } else {
    typeOptions = [{
      value: 'text',
@@ -364,23 +373,31 @@
    }
  }
  let options = card.options || []
  if (['select', 'link'].includes(card.type) && card.setAll === 'true') { // 兼容
    options.unshift({
      key: 'empty',
      Value: '',
      Text: '全部',
      ParentID: ''
    })
  }
  return [
    {
      type: 'text',
      key: 'label',
      label: Formdict['model.name'],
      initVal: card.label || '',
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'text',
      key: 'field',
      label: Formdict['model.form.field'],
      initVal: card.field || '',
      tooltipClass: 'middle',
      required: true,
      readonly: false
      options: columns
    },
    {
      type: 'select',
@@ -395,8 +412,7 @@
      key: 'datefield',
      label: '时间字段',
      initVal: card.datefield || '',
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'text',
@@ -420,19 +436,19 @@
        text: Formdict['header.form.datasource']
      }]
    },
    {
      type: 'radio',
      key: 'setAll',
      label: '设置全部',
      initVal: card.setAll || 'true',
      options: [{
        value: 'true',
        text: Formdict['model.true']
      }, {
        value: 'false',
        text: Formdict['model.false']
      }]
    },
    // {
    //   type: 'radio',
    //   key: 'setAll',
    //   label: '设置全部',
    //   initVal: card.setAll || 'true',
    //   options: [{
    //     value: 'true',
    //     text: Formdict['model.true']
    //   }, {
    //     value: 'false',
    //     text: Formdict['model.false']
    //   }]
    // },
    {
      type: 'radio',
      key: 'display',
@@ -463,16 +479,14 @@
      key: 'cardValField',
      label: '值·字段',
      initVal: card.cardValField || 'Value',
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'text',
      key: 'urlField',
      label: '地址字段',
      initVal: card.urlField || '',
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'radio',
@@ -499,24 +513,21 @@
      key: 'fields',
      label: '字段集',
      initVal: card.fields || [],
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'textarea',
      type: 'codemirror',
      key: 'dataSource',
      label: Formdict['header.form.datasource'],
      initVal: card.dataSource || '',
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'options',
      key: 'options',
      label: '选项',
      initVal: card.options || [],
      required: true,
      readonly: false
      initVal: options,
      required: true
    },
    {
      type: 'checkbox',
@@ -524,7 +535,6 @@
      label: '选项',
      initVal: card.items || ['day', 'week', 'month', 'quarter', 'year', 'customized'],
      required: true,
      readonly: false,
      options: [{
        value: 'day',
        label: '日'
@@ -546,12 +556,26 @@
      }]
    },
    {
      type: 'radio',
      key: 'multiple',
      label: '选择形式',
      initVal: card.multiple || 'false',
      required: true,
      options: [{
        value: 'false',
        text: '单选'
      }, {
        value: 'true',
        text: '多选'
      }]
    },
    {
      type: 'select',
      key: 'linkField',
      label: '关联字段',
      initVal: card.linkField || '',
      required: true,
      readonly: false,
      allowClear: true,
      options: linkableFields
    },
    {
@@ -559,24 +583,21 @@
      key: 'valueField',
      label: '值·字段',
      initVal: card.valueField || '',
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'text',
      key: 'valueText',
      label: '文本·字段',
      initVal: card.valueText || '',
      required: true,
      readonly: false
      required: true
    },
    {
      type: 'text',
      key: 'orderBy',
      label: '排序·字段',
      initVal: card.orderBy || '',
      required: false,
      readonly: false
      required: false
    },
    {
      type: 'select',
@@ -639,17 +660,34 @@
      required: false
    },
    {
      type: 'radio',
      key: 'multiple',
      label: '可多选',
      initVal: card.multiple || 'false',
      type: 'number',
      key: 'labelwidth',
      min: 1,
      max: 100,
      precision: 1,
      label: '名称宽度',
      initVal: card.labelwidth || 33.3,
      tooltip: '名称占据搜索条件宽度的百分比。注:存在多列搜索时,当前搜索如果想要占据整行可参照以下比例,两列(16.5)、三列(10.8)、四列(8)',
      required: true,
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      key: 'precision',
      label: '精确度',
      initVal: card.precision || 'day',
      options: [{
        value: 'true',
        text: '是'
        value: 'day',
        text: '天'
      }, {
        value: 'false',
        text: '否'
        value: 'hour',
        text: '小时'
      }, {
        value: 'minute',
        text: '分钟'
      }, {
        value: 'second',
        text: '秒'
      }]
    },
    {
@@ -749,6 +787,7 @@
      key: 'advanced',
      label: '高级搜索',
      initVal: card.advanced || 'false',
      tooltip: '在隐藏搜索按钮时,高级搜索无效。',
      forbid: appType === 'mob',
      options: [{
        value: 'true',
@@ -808,7 +847,8 @@
      label: Formdict['header.form.blacklist'],
      initVal: card.blacklist || [],
      required: false,
      options: roleList || []
      options: roleList || [],
      forbid: appType === 'mob'
    }
  ]
}
@@ -820,7 +860,7 @@
 * @param {*} usefulFields   存储过程可用的开始字段
 * @param {*} type           按钮类型,用于区分可选的打开方式
 */
export function getActionForm (card, config, usefulFields, type, menulist = [], printTemps = []) {
export function getActionForm (card, config, usefulFields, type, menulist = [], printTemps = [], tabs = []) {
  let columns = (config.columns || []).filter(col => col.field)
  let opentypes = [
@@ -862,6 +902,11 @@
  }
  if (card.popClose === 'view') {
    card.popClose = 'grid'
  }
  if (card.OpenType === 'outerpage') {
    card.pageTemplate = 'custom'
    card.OpenType = 'innerpage'
  }
  let refresh = []
@@ -910,7 +955,20 @@
      }, {
        value: 'closetab',
        text: '标签关闭'
      }, {
        value: 'megvii',
        text: '旷视面板机'
      }]
    },
    { // 旷视面板机接口 待扩展
      type: 'radio',
      key: 'subFunc',
      label: '接口名称',
      initVal: card.subFunc || 'addUser',
      required: true,
      options: [
        { value: 'addUser', text: '添加用户' },
      ]
    },
    {
      type: 'select',
@@ -981,7 +1039,6 @@
      initVal: card.innerFunc || '',
      tooltip: `函数名称需以${usefulFields.join(', ')}等字符开始。`,
      fields: usefulFields,
      tooltipClass: 'middle',
      required: card.intertype === 'inner',
      readonly: false
    },
@@ -991,7 +1048,13 @@
      label: '关联标签',
      initVal: card.linkTab || '',
      required: false,
      options: []
      options: [
        {
          value: '',
          text: '新建'
        },
        ...tabs
      ]
    },
    {
      type: 'select',
@@ -1170,18 +1233,18 @@
      type: refresh.length === 0 ? 'radio' : 'select',
      key: 'execSuccess',
      label: Formdict['model.form.afterSuccess'],
      initVal: card.execSuccess || 'never',
      initVal: card.execSuccess || 'grid',
      tooltip: '选择刷新行时,如果选择多条数据会刷新表格。',
      required: true,
      options: [{
        value: 'never',
        text: '不刷新'
      }, {
        value: 'grid',
        text: '刷新表格'
      }, {
        value: 'line',
        text: '刷新行'
      }, {
        value: 'grid',
        text: '刷新表格'
      },
      ...refresh]
    },
@@ -1196,11 +1259,11 @@
        value: 'never',
        text: '不刷新'
      }, {
        value: 'grid',
        text: '刷新表格'
      }, {
        value: 'line',
        text: '刷新行'
      }, {
        value: 'grid',
        text: '刷新表格'
      },
      ...refresh]
    },
@@ -1246,7 +1309,7 @@
      label: Formdict['model.form.color'],
      initVal: card.class,
      required: false,
      options: []
      options: btnClasses
    },
    {
      type: 'cascader',
@@ -1261,8 +1324,16 @@
      type: 'text',
      key: 'output',
      label: '返回值',
      tooltip: '执行成功后的返回值。',
      tooltip: '执行成功后的返回值。系统函数可指定返回的变量(以@符开头,如@id);自定义函数可指定返回字段(如id)。',
      initVal: card.output || '',
      required: false
    },
    {
      type: 'text',
      key: 'tipTitle',
      label: '确认提示',
      initVal: card.tipTitle || '',
      tooltip: '注:弹窗(表单)在显示为是否框时有效。',
      required: false
    },
    {
@@ -1332,11 +1403,11 @@
      type: 'number',
      key: 'ratio',
      min: 1,
      max: 24,
      max: 3000,
      precision: 0,
      label: '比例',
      initVal: card.ratio || 85,
      tooltip: '小于100为宽度(或高度)百分比,大于100为像素值。',
      tooltip: '模态框或抽屉的宽度,小于100为窗口宽度(或高度)百分比,大于100为像素值。',
      required: true
    },
    {
@@ -1380,7 +1451,6 @@
      initVal: card.preFunc || '',
      tooltip: `函数名称需以${usefulFields.join(', ')}等字符开始;前置函数执行完成后,结果会传入内部函数中,此时内部函数会异步执行;当前置函数返回中ErrCode等于-1时,将不再执行内部函数。`,
      fields: usefulFields,
      tooltipClass: 'middle',
      required: false,
      readonly: false
    },
@@ -1418,6 +1488,42 @@
      initVal: card.controlVal || '',
      required: false
    },
    {
      type: 'text',
      key: 'reason',
      label: '禁用原因',
      initVal: card.reason || '',
      required: false
    },
    {
      type: 'radio',
      key: 'hidden',
      label: '隐藏',
      initVal: card.hidden || 'false',
      tooltip: '隐藏后按钮在页面中不显示,且不参与权限分配。',
      required: false,
      options: [{
        value: 'false',
        text: '否'
      }, {
        value: 'true',
        text: '是'
      }]
    },
    {
      type: 'radio',
      key: 'progress',
      label: '进度提示',
      initVal: card.progress || 'number',
      required: false,
      options: [{
        value: 'number',
        text: '剩余数'
      }, {
        value: 'progressbar',
        text: '进度条'
      }]
    }
  ]
}
@@ -1618,7 +1724,7 @@
        text: Formdict['model.empty']
      }, {
        value: 'thdSeparator',
        text: Formdict['header.form.thdSeparator']
        text: '千分位'
      }, {
        value: 'percent',
        text: '百分比'
@@ -2254,9 +2360,9 @@
  }, {
    value: 'datemonth',
    text: Formdict['model.form.datemonth']
  }, {
    value: 'datetime',
    text: Formdict['model.form.datetime']
  // }, {
  //   value: 'datetime',
  //   text: '日期(分/秒)'
  }, {
    value: 'textarea',
    text: Formdict['model.form.textarea']
@@ -2319,9 +2425,9 @@
    }, {
      value: 'datemonth',
      text: Formdict['model.form.datemonth']
    }, {
      value: 'datetime',
      text: Formdict['model.form.datetime']
    // }, {
    //   value: 'datetime',
    //   text: '日期(分/秒)'
    }, {
      value: 'textarea',
      text: Formdict['model.form.textarea']
@@ -2337,6 +2443,9 @@
    }, {
      value: 'split',
      text: '分隔线'
    }, {
      value: 'linkMain',
      text: '关联主表'
    }]
  }
@@ -2344,6 +2453,30 @@
    _fieldlength = 512
  } else if (['textarea', 'brafteditor'].includes(card.type)) {
    _fieldlength = 8000
  } else if (card.type === 'datetime') {
    card.type = 'date'
    card.precision = 'second'
  }
  let options = card.options || []
  if (['select', 'radio', 'link'].includes(card.type) && card.setAll === 'true') { // 兼容
    options.unshift({
      key: 'empty',
      Value: '',
      Text: card.emptyText || '空',
      ParentID: ''
    })
  }
  let initval = card.initval || ''
  if (card.type === 'switch') {
    initval = card.initval === true
  } else if (card.type === 'number') {
    initval = card.initval || 0
  }
  if (appType === 'mob' && ![24, 12, 8, 6].includes(card.span)) {
    card.span = 24
  }
  return [
@@ -2375,8 +2508,7 @@
      type: 'text',
      key: 'initval',
      label: Formdict['header.form.initval'],
      tooltip: '下拉多选与多选框,添加多个初始值请使用“,”号分隔。注:下拉选择、联动菜单或单选框中$first表示选择第一项',
      initVal: card.initval || '',
      initVal: initval,
      required: false
    },
    {
@@ -2406,16 +2538,14 @@
      key: 'openText',
      label: '开启提示',
      initVal: card.openText || '',
      required: false,
      forbid: appType === 'mob'
      required: false
    },
    {
      type: 'text',
      key: 'closeText',
      label: '关闭提示',
      initVal: card.closeText || '',
      required: false,
      forbid: appType === 'mob'
      required: false
    },
    {
      type: 'radio',
@@ -2492,19 +2622,19 @@
        text: '16:9'
      }]
    },
    {
      type: 'radio',
      key: 'setAll',
      label: '设置空值',
      initVal: card.setAll || 'false',
      options: [{
        value: 'true',
        text: Formdict['model.true']
      }, {
        value: 'false',
        text: Formdict['model.false']
      }]
    },
    // {
    //   type: 'radio',
    //   key: 'setAll',
    //   label: '设置空值',
    //   initVal: card.setAll || 'false',
    //   options: [{
    //     value: 'true',
    //     text: Formdict['model.true']
    //   }, {
    //     value: 'false',
    //     text: Formdict['model.false']
    //   }]
    // },
    {
      type: 'fields',
      key: 'fields',
@@ -2517,7 +2647,7 @@
      type: 'options',
      key: 'options',
      label: '选项',
      initVal: card.options || [],
      initVal: options,
      required: true,
      readonly: false
    },
@@ -2530,12 +2660,27 @@
      readonly: false
    },
    {
      type: 'radio',
      key: 'multiple',
      label: '选择形式',
      initVal: card.multiple || 'false',
      required: true,
      options: [{
        value: 'false',
        text: '单选'
      }, {
        value: 'true',
        text: '多选'
      }]
    },
    {
      type: 'select',
      key: 'linkField',
      label: '关联字段',
      initVal: card.linkField || '',
      required: true,
      readonly: false,
      allowClear: true,
      options: linkableFields
    },
    {
@@ -2583,20 +2728,6 @@
      tooltip: '设置禁用字段,且字段值为true时,选项不可选。',
      required: false,
      readonly: false
    },
    {
      type: 'radio',
      key: 'multiple',
      label: '可多选',
      initVal: card.multiple || 'false',
      required: true,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'number',
@@ -2723,15 +2854,34 @@
      }]
    },
    {
      type: 'radio',
      key: 'precision',
      label: '精确度',
      initVal: card.precision || 'day',
      options: [{
        value: 'day',
        text: '天'
      }, {
        value: 'hour',
        text: '小时'
      }, {
        value: 'minute',
        text: '分钟'
      }, {
        value: 'second',
        text: '秒'
      }]
    },
    {
      type: 'number',
      key: 'fieldlength',
      min: 1,
      max: 1000000,
      max: 100000,
      precision: 0,
      label: Formdict['model.form.field'] + Formdict['model.length'],
      tooltip: '文本、下拉框、日期等字段默认长度为50,多行文本与文件上传字段默认长度为512',
      // tooltip: '文本、下拉框、日期等字段默认长度为50,多行文本与文件上传字段默认长度为512',
      initVal: card.fieldlength || _fieldlength,
      required: false
      required: true
    },
    {
      type: 'number',
@@ -2751,19 +2901,22 @@
      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: '手机号'
      }, {
        value: 'email',
        text: '邮箱'
      }]
    },
    {
@@ -3042,7 +3195,7 @@
      type: 'radio',
      key: 'interception',
      label: '截取空格',
      initVal: card.interception || 'false',
      initVal: card.interception || 'true',
      tooltip: '提交时,是否截取首尾的空白字符。',
      options: [{
        value: 'true',
@@ -3099,15 +3252,18 @@
    {
      type: 'radio',
      key: 'compress',
      label: '压缩',
      label: '文件处理',
      initVal: card.compress || 'false',
      tooltip: '文件压缩必须为图片,图片格式为jpg、png、gif 或 jpeg',
      tooltip: '文件压缩或base64必须为图片,图片格式为jpg、png、gif 或 jpeg。注:base64只可上传一张图片。',
      options: [{
        value: 'true',
        text: Formdict['model.true']
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '无'
      }, {
        value: 'true',
        text: '压缩'
      }, {
        value: 'base64',
        text: 'base64'
      }]
    },
    {
@@ -3132,6 +3288,46 @@
      tooltip: '栅格布局整行24等分。',
      required: true,
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      key: 'span',
      label: '表单宽度',
      initVal: card.span || 24,
      tooltip: '栅格布局整行24等分。',
      required: true,
      forbid: appType !== 'mob',
      options: [{
        value: 24,
        text: 24
      }, {
        value: 12,
        text: 12
      }, {
        value: 8,
        text: 8
      }, {
        value: 6,
        text: 6
      }]
    },
    {
      type: 'radio',
      key: 'lenControl',
      label: '长度控制',
      initVal: card.lenControl || 'limit',
      tooltip: '在设置字段长度后,对长度的控制方式。',
      required: false,
      options: [{
        value: 'limit',
        text: '限制输入'
      }, {
        value: 'left',
        text: '左截'
      }, {
        value: 'right',
        text: '右截'
      }]
    },
    {
      type: 'number',
@@ -3179,19 +3375,21 @@
      type: 'select',
      key: 'supField',
      label: '上级表单',
      tooltip: '上级表单为下拉选择、联动菜单、单选框及多选框,添加后该表单显示及隐藏将受上级表单控制,注:受控关系在该表单隐藏时失效。',
      tooltip: '该表单显示或隐藏受上级表单控制。',
      initVal: card.supField || '',
      required: false,
      readonly: false,
      allowClear: true,
      options: linksupFields
    },
    {
      type: 'text',
      key: 'supvalue',
      max: 512,
      label: '显示值',
      tooltip: '请填写显示值,只有上级表单值与显示值相同时,该表单才会显示,注:1、多个值用逗号分隔;2、上级表单初始值为$first时暂未处理。',
      initVal: card.supvalue || '',
      required: true,
      required: false,
      readonly: false
    },
    {
@@ -3213,6 +3411,22 @@
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      key: 'enterReplace',
      label: '回车符替换',
      tooltip: '回车符会替换为英文逗号。',
      initVal: card.enterReplace || 'false',
      required: false,
      forbid: appType !== 'mob',
      options: [{
        value: 'false',
        text: '否'
      }, {
        value: 'true',
        text: '是'
      }]
    },
    {
      type: 'text',
      key: 'placeholder',
      label: '提示信息',
@@ -3220,14 +3434,14 @@
      initVal: card.placeholder || '',
      required: false
    },
    {
      type: 'text',
      key: 'emptyText',
      label: '空值文本',
      tooltip: '空值的提示文本,选择设置空值时有效,默认值为《空》。',
      initVal: card.emptyText || '',
      required: false
    },
    // {
    //   type: 'text',
    //   key: 'emptyText',
    //   label: '空值文本',
    //   tooltip: '空值的提示文本,选择设置空值时有效,默认值为《空》。',
    //   initVal: card.emptyText || '',
    //   required: false
    // },
    {
      type: 'radio',
      key: 'enter',
@@ -3256,40 +3470,41 @@
    {
      type: 'multiselect',
      key: 'linkSubField',
      label: Formdict['model.form.linkform'],
      tooltip: '在切换选项时会把信息自动填入关联的表单(文本或数字表单)中。注:使用选项卡且设为可多选时无效。',
      label: '填充表单',
      tooltip: '在切换选项时会把信息自动填入关联的表单(文本或数字表单)中。',
      initVal: card.linkSubField || [],
      options: inputfields
    },
    {
      type: 'number',
      key: 'marginTop',
      label: '上边距(px)',
      initVal: card.marginTop || 0,
      min: 0,
      max: 1000,
      precision: 0,
      required: false,
      forbid: appType !== 'mob'
    },
    {
      type: 'number',
      key: 'marginBottom',
      label: '下边距(px)',
      initVal: card.marginBottom || 0,
      min: 0,
      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'
    }
  ]
}