|
|
@@ -1,4 +1,4 @@
|
|
|
-// import { isArray } from 'util'
|
|
|
+// import { Array.isArray } from 'util';
|
|
|
import {
|
|
|
exportDefault,
|
|
|
titleCase,
|
|
|
@@ -22,7 +22,7 @@ const inheritAttrs = {
|
|
|
* @param {Object} formConfig 整个表单配置
|
|
|
* @param {String} type 生成类型,文件或弹窗等
|
|
|
*/
|
|
|
-export function makeUpJs(formConfig, type) {
|
|
|
+export function makeUpJs (formConfig, type) {
|
|
|
confGlobal = formConfig = deepClone(formConfig);
|
|
|
const dataList = [];
|
|
|
const ruleList = [];
|
|
|
@@ -61,7 +61,7 @@ export function makeUpJs(formConfig, type) {
|
|
|
}
|
|
|
|
|
|
// 构建组件属性
|
|
|
-function buildAttributes(
|
|
|
+function buildAttributes (
|
|
|
scheme,
|
|
|
dataList,
|
|
|
ruleList,
|
|
|
@@ -124,12 +124,12 @@ function buildAttributes(
|
|
|
}
|
|
|
|
|
|
// 在Created调用函数
|
|
|
-function callInCreated(methodName, created) {
|
|
|
+function callInCreated (methodName, created) {
|
|
|
created.push(`this.${methodName}()`);
|
|
|
}
|
|
|
|
|
|
// 混入处理函数
|
|
|
-function mixinMethod(type) {
|
|
|
+function mixinMethod (type) {
|
|
|
const list = [];
|
|
|
const minxins = {
|
|
|
file: confGlobal.formBtns
|
|
|
@@ -173,7 +173,7 @@ function mixinMethod(type) {
|
|
|
}
|
|
|
|
|
|
// 构建data
|
|
|
-function buildData(scheme, dataList) {
|
|
|
+function buildData (scheme, dataList) {
|
|
|
const config = scheme.__config__;
|
|
|
if (scheme.__vModel__ === undefined) return;
|
|
|
const defaultValue = JSON.stringify(config.defaultValue);
|
|
|
@@ -181,14 +181,14 @@ function buildData(scheme, dataList) {
|
|
|
}
|
|
|
|
|
|
// 构建校验规则
|
|
|
-function buildRules(scheme, ruleList) {
|
|
|
+function buildRules (scheme, ruleList) {
|
|
|
const config = scheme.__config__;
|
|
|
if (scheme.__vModel__ === undefined) return;
|
|
|
const rules = [];
|
|
|
if (ruleTrigger[config.tag]) {
|
|
|
if (config.required) {
|
|
|
- const type = isArray(config.defaultValue) ? "type: 'array'," : '';
|
|
|
- let message = isArray(config.defaultValue)
|
|
|
+ const type = Array.isArray(config.defaultValue) ? "type: 'array'," : '';
|
|
|
+ let message = Array.isArray(config.defaultValue)
|
|
|
? `请至少选择一个${config.label}`
|
|
|
: scheme.placeholder;
|
|
|
if (message === undefined) message = `${config.label}不能为空`;
|
|
|
@@ -198,7 +198,7 @@ function buildRules(scheme, ruleList) {
|
|
|
}' }`
|
|
|
);
|
|
|
}
|
|
|
- if (config.regList && isArray(config.regList)) {
|
|
|
+ if (config.regList && Array.isArray(config.regList)) {
|
|
|
config.regList.forEach((item) => {
|
|
|
if (item.pattern) {
|
|
|
rules.push(
|
|
|
@@ -214,7 +214,7 @@ function buildRules(scheme, ruleList) {
|
|
|
}
|
|
|
|
|
|
// 构建options
|
|
|
-function buildOptions(scheme, optionsList) {
|
|
|
+function buildOptions (scheme, optionsList) {
|
|
|
if (scheme.__vModel__ === undefined) return;
|
|
|
// el-cascader直接有options属性,其他组件都是定义在slot中,所以有两处判断
|
|
|
let { options } = scheme;
|
|
|
@@ -226,7 +226,7 @@ function buildOptions(scheme, optionsList) {
|
|
|
optionsList.push(str);
|
|
|
}
|
|
|
|
|
|
-function buildProps(scheme, propsList) {
|
|
|
+function buildProps (scheme, propsList) {
|
|
|
const str = `${scheme.__vModel__}Props: ${JSON.stringify(
|
|
|
scheme.props.props
|
|
|
)},`;
|
|
|
@@ -234,7 +234,7 @@ function buildProps(scheme, propsList) {
|
|
|
}
|
|
|
|
|
|
// el-upload的BeforeUpload
|
|
|
-function buildBeforeUpload(scheme) {
|
|
|
+function buildBeforeUpload (scheme) {
|
|
|
const config = scheme.__config__;
|
|
|
const unitNum = units[config.sizeUnit];
|
|
|
let rightSizeCode = '';
|
|
|
@@ -263,14 +263,14 @@ function buildBeforeUpload(scheme) {
|
|
|
}
|
|
|
|
|
|
// el-upload的submit
|
|
|
-function buildSubmitUpload(scheme) {
|
|
|
+function buildSubmitUpload (scheme) {
|
|
|
const str = `submitUpload() {
|
|
|
this.$refs['${scheme.__vModel__}'].submit()
|
|
|
},`;
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
-function buildOptionMethod(methodName, model, methodList, scheme) {
|
|
|
+function buildOptionMethod (methodName, model, methodList, scheme) {
|
|
|
const config = scheme.__config__;
|
|
|
const str = `${methodName}() {
|
|
|
// 注意:this.$axios是通过Vue.prototype.$axios = axios挂载产生的
|
|
|
@@ -286,7 +286,7 @@ function buildOptionMethod(methodName, model, methodList, scheme) {
|
|
|
}
|
|
|
|
|
|
// js整体拼接
|
|
|
-function buildexport(
|
|
|
+function buildexport (
|
|
|
conf,
|
|
|
type,
|
|
|
data,
|