From 6def3330d1d1cf4036916ed04c8bbc4128e1e5d0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 03 五月 2020 19:42:17 +0800 Subject: [PATCH] 2020-05-03 --- src/templates/zshare/formconfig.jsx | 356 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 350 insertions(+), 6 deletions(-) diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 371490a..3b79d42 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -1,11 +1,346 @@ 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: '鏌ヨ鏃讹紝鎼滅储鏉′欢浠here鏉′欢鎷兼帴杩涘叆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 [ @@ -634,7 +969,9 @@ /** * @description 鑾峰彇鏄剧ず鍒楄〃鍗曢厤缃俊鎭� - * @param {*} card + * @param {object} card // 鎼滅储鏉′欢瀵硅薄 + * @param {Array} roleList // 瑙掕壊鍒楄〃-榛戝悕鍗� + * @param {Array} menulist // 鑿滃崟鍒楄〃-鐢ㄤ簬瀛楁閫忚 */ export function getColumnForm (card, roleList = [], menulist = []) { return [ @@ -886,7 +1223,8 @@ /** * @description 鑾峰彇鍥捐〃瑙嗗浘澶栭儴閰嶇疆琛ㄥ崟 - * @param {*} card + * @param {object} card // 鎼滅储鏉′欢瀵硅薄 + * @param {Array} roleList // 瑙掕壊鍒楄〃-榛戝悕鍗� */ export function getChartViewForm (card, roleList = []) { let _charts = [{ @@ -972,7 +1310,9 @@ /** * @description 鑾峰彇鍥捐〃瑙嗗浘閰嶇疆琛ㄥ崟 - * @param {*} card + * @param {object} card // 鎼滅储鏉′欢瀵硅薄 + * @param {Array} columns // 鏄剧ず鍒� + * @param {String} type // 鍥捐〃绫诲瀷 */ export function getChartOptionForm (card, columns, type) { let shapes = [] @@ -1175,8 +1515,12 @@ /** * @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 = [] -- Gitblit v1.8.0