| | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import { formRule } from '@/utils/option.js' |
| | | |
| | | const Formdict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS |
| | | |
| | | /** |
| | | * @description 获取页面设置表单配置信息 |
| | | * @param {object} setting // 菜单全局设置信息 |
| | | * @param {string} type // 菜单类型 |
| | | */ |
| | | export function getSettingForm (setting, usefulFields = [], MenuID, primaryKey, columns, type) { |
| | | let str = '^(' + usefulFields.join('|') + ')' |
| | | let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') |
| | | |
| | | return [ |
| | | { |
| | | type: 'text', |
| | | key: 'tableName', |
| | | label: '表名', |
| | | initVal: setting.tableName || '', |
| | | required: true, |
| | | readonly: false, |
| | | rules: [ |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'tableType', |
| | | label: '表格属性', |
| | | initVal: setting.tableType, |
| | | required: false, |
| | | readonly: false, |
| | | options: [ |
| | | { value: '', text: '不可选' }, |
| | | { value: 'radio', text: '单选' }, |
| | | { value: 'checkbox', text: '多选' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'interType', |
| | | label: Formdict['header.form.intertype'], |
| | | initVal: setting.interType || 'inner', |
| | | required: false, |
| | | readonly: false, |
| | | options: [ |
| | | { value: 'inner', text: Formdict['header.form.interface.inner'] }, |
| | | { value: 'outer', text: Formdict['header.form.interface.outer'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'sysInterface', |
| | | label: Formdict['header.form.sysInterface'], |
| | | initVal: setting.sysInterface || 'false', |
| | | required: false, |
| | | readonly: false, |
| | | options: [ |
| | | { value: 'true', text: Formdict['header.form.true'] }, |
| | | { value: 'false', text: Formdict['header.form.false'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'interface', |
| | | label: Formdict['header.form.interface'], |
| | | initVal: setting.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (setting.interface || ''), |
| | | required: true, |
| | | readonly: setting.sysInterface === 'true', |
| | | rules: [ |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'outerFunc', |
| | | label: Formdict['header.form.outerFunc'], |
| | | initVal: setting.outerFunc || '', |
| | | required: false, |
| | | readonly: false, |
| | | rules: [ |
| | | { |
| | | pattern: formRule.func.pattern, |
| | | message: formRule.func.message |
| | | }, { |
| | | max: formRule.func.max, |
| | | message: formRule.func.maxMessage |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'innerFunc', |
| | | label: Formdict['header.form.innerFunc'], |
| | | initVal: setting.innerFunc || '', |
| | | tooltip: '开头可用字符:' + usefulFields.join(', '), |
| | | required: false, |
| | | readonly: false, |
| | | rules: [ |
| | | { |
| | | pattern: _patten, |
| | | message: formRule.func.innerMessage |
| | | }, { |
| | | max: formRule.func.max, |
| | | message: formRule.func.maxMessage |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'datasource', |
| | | key: 'dataresource', |
| | | label: '数据源', |
| | | initVal: setting.dataresource || '', |
| | | tooltip: '使用系统函数时,需填写数据源。', |
| | | help: '数据ID:' + MenuID, |
| | | required: false, |
| | | readonly: false, |
| | | rules: [ |
| | | { |
| | | pattern: _patten, |
| | | message: formRule.func.innerMessage |
| | | }, { |
| | | max: formRule.func.max, |
| | | message: formRule.func.maxMessage |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'primaryKey', |
| | | label: '主键', |
| | | initVal: primaryKey, |
| | | required: false, |
| | | readonly: false, |
| | | options: columns |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'order', |
| | | label: '默认排序', |
| | | initVal: setting.order || (primaryKey ? primaryKey + ' desc' : ''), |
| | | placeholder: 'ID asc, UID desc', |
| | | required: true, |
| | | readonly: false, |
| | | rules: [ |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'queryType', |
| | | label: Formdict['header.form.queryType'], |
| | | initVal: setting.queryType || 'query', |
| | | tooltip: '查询时,搜索条件以where条件拼接进入sql,统计时,将数据源中以“@+搜索字段”的内容,以搜索条件中的值进行替换后,提交查询,注:查询类型仅在使用系统函数时有效。', |
| | | required: false, |
| | | readonly: false, |
| | | options: [ |
| | | { value: 'query', text: Formdict['header.form.query'] }, |
| | | { value: 'statistics', text: Formdict['header.form.statistics'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'actionfixed', |
| | | label: '按钮固定', |
| | | initVal: setting.actionfixed ? 'true' : 'false', |
| | | required: false, |
| | | readonly: false, |
| | | forbid: type !== 'main', |
| | | options: [ |
| | | { value: 'true', text: Formdict['header.form.true'] }, |
| | | { value: 'false', text: Formdict['header.form.false'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'columnfixed', |
| | | label: '表头固定', |
| | | initVal: setting.columnfixed ? 'true' : 'false', |
| | | required: false, |
| | | readonly: false, |
| | | forbid: type !== 'main', |
| | | options: [ |
| | | { value: 'true', text: Formdict['header.form.true'] }, |
| | | { value: 'false', text: Formdict['header.form.false'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'onload', |
| | | label: '初始化', |
| | | initVal: setting.onload || 'true', |
| | | required: false, |
| | | readonly: false, |
| | | options: [ |
| | | { value: 'true', text: '加载数据' }, |
| | | { value: 'false', text: '不加载数据' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'laypage', |
| | | label: '是否分页', |
| | | initVal: setting.laypage || 'true', |
| | | required: false, |
| | | readonly: false, |
| | | options: [ |
| | | { value: 'true', text: Formdict['header.form.true'] }, |
| | | { value: 'false', text: Formdict['header.form.false'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'default', |
| | | label: '默认sql', |
| | | initVal: setting.default || 'true', |
| | | required: false, |
| | | readonly: false, |
| | | options: [ |
| | | { value: 'true', text: '执行' }, |
| | | { value: 'false', text: '不执行' } |
| | | ] |
| | | }, |
| | | ] |
| | | } |
| | | |
| | | /** |
| | | * @description 获取主菜单基本信息表单配置信息 |
| | | * @param {object} menu // 主表基本信息 |
| | | * @param {object} config // 主表配置信息 |
| | | */ |
| | | export function getMainMenuForm (menu, _config) { |
| | | return [ |
| | | { |
| | | type: 'select', |
| | | key: 'fstMenuId', |
| | | label: '一级菜单', |
| | | initVal: menu.fstMenuId, |
| | | required: true, |
| | | readonly: false, |
| | | options: menu.fstMenuList |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'parentId', |
| | | label: '二级菜单', |
| | | initVal: menu.ParentID, |
| | | required: true, |
| | | readonly: false, |
| | | options: menu.supMenuList |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'MenuName', |
| | | label: Formdict['header.menu.menuName'], |
| | | initVal: menu.MenuName, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'MenuNo', |
| | | label: Formdict['header.menu.menuNo'], |
| | | initVal: menu.MenuNo, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'opentype', |
| | | label: Formdict['header.menu.openType'], |
| | | initVal: menu.PageParam.OpenType, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'newtab', |
| | | text: Formdict['header.form.tab'] |
| | | }, { |
| | | MenuID: 'newpage', |
| | | text: Formdict['header.form.newpage'] |
| | | }, { |
| | | MenuID: 'currenttab', |
| | | text: Formdict['header.form.currenttab'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'easyCode', |
| | | label: Formdict['header.form.easyCode'], |
| | | initVal: _config.easyCode, |
| | | required: false, |
| | | readonly: false |
| | | } |
| | | ] |
| | | } |
| | | |
| | | /** |
| | | * @description 获取子菜单基本信息表单配置信息 |
| | | * @param {object} config // 子表配置信息 |
| | | */ |
| | | export function getSubMenuForm (config) { |
| | | return [ |
| | | { |
| | | type: 'text', |
| | | key: 'MenuName', |
| | | label: Formdict['header.menu.viewName'], |
| | | initVal: config.tabName, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'MenuNo', |
| | | label: Formdict['header.menu.menuNo'], |
| | | initVal: config.tabNo, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'Remark', |
| | | label: Formdict['header.menu.Remark'], |
| | | initVal: config.Remark, |
| | | required: false, |
| | | readonly: false |
| | | } |
| | | ] |
| | | } |
| | | |
| | | /** |
| | | * @description 获取搜索条件表单配置信息 |
| | | * @param {*} card |
| | | * @param {object} card // 搜索条件对象 |
| | | * @param {Array} roleList // 角色列表 |
| | | */ |
| | | export function getSearchForm (card, roleList) { |
| | | return [ |
| | |
| | | |
| | | /** |
| | | * @description 获取显示列表单配置信息 |
| | | * @param {*} card |
| | | * @param {object} card // 搜索条件对象 |
| | | * @param {Array} roleList // 角色列表-黑名单 |
| | | * @param {Array} menulist // 菜单列表-用于字段透视 |
| | | */ |
| | | export function getColumnForm (card, roleList = [], menulist = []) { |
| | | return [ |
| | |
| | | |
| | | /** |
| | | * @description 获取图表视图外部配置表单 |
| | | * @param {*} card |
| | | * @param {object} card // 搜索条件对象 |
| | | * @param {Array} roleList // 角色列表-黑名单 |
| | | */ |
| | | export function getChartViewForm (card, roleList = []) { |
| | | let _charts = [{ |
| | |
| | | |
| | | /** |
| | | * @description 获取图表视图配置表单 |
| | | * @param {*} card |
| | | * @param {object} card // 搜索条件对象 |
| | | * @param {Array} columns // 显示列 |
| | | * @param {String} type // 图表类型 |
| | | */ |
| | | export function getChartOptionForm (card, columns, type) { |
| | | let shapes = [] |
| | |
| | | |
| | | /** |
| | | * @description 获取表单配置信息 |
| | | * @param {*} card |
| | | * @param {*} inputfields |
| | | * @param {*} card // 表单对象 |
| | | * @param {*} inputfields // 可关联表单 |
| | | * @param {*} linkableFields // 可关联表单 |
| | | * @param {*} linksupFields // 上级表单 |
| | | * @param {*} subtable // 是否为子表表单 |
| | | * @param {*} roleList // 角色列表-黑名单 |
| | | */ |
| | | export function getModalForm (card, inputfields, linkableFields, linksupFields, subtable = false, roleList = []) { |
| | | let _openType = [] |