mirror of
https://github.com/vxcontrol/ncform.git
synced 2026-07-19 18:23:32 -04:00
+1
-1
@@ -3,5 +3,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.1.1"
|
||||
"version": "1.1.2"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ncform/ncform-common",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.2",
|
||||
"description": "ncform common",
|
||||
"main": "dist/ncformCommon.min.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -18,15 +18,15 @@ const ncformUtils = {
|
||||
} catch (err) {
|
||||
throw new Error("fromSchema must be a valid json format", err);
|
||||
}
|
||||
} else if (formSchema instanceof Object) {
|
||||
} else if (Object.prototype.toString.call(formSchema) === '[object Object]') {
|
||||
returnSchema = formSchema;
|
||||
} else {
|
||||
throw new Error("fromSchema must be a json object");
|
||||
}
|
||||
|
||||
// 验证格式
|
||||
if (returnSchema.type !== "object" && returnSchema.type !== "array") {
|
||||
throw new Error("fromSchema' root field type must be object or array");
|
||||
if (returnSchema.type !== "object") {
|
||||
throw new Error("fromSchema' root field type must be object");
|
||||
}
|
||||
|
||||
// 补全数据
|
||||
|
||||
@@ -5,37 +5,93 @@ import ncformUtils from '../../src/ncform-utils.js';
|
||||
describe('/src/ncform-utils.js', () => {
|
||||
// --- perfectFormSchema
|
||||
|
||||
it("perfectFormSchema - 填充对象", () => {
|
||||
it("perfectFormSchema - Data format check", () => {
|
||||
// not a valid json string
|
||||
let formSchema = "{a: 1}";
|
||||
assert.throws(ncformUtils.perfectFormSchema.bind(ncformUtils, formSchema), /fromSchema must be a valid json format/);
|
||||
|
||||
// not array
|
||||
formSchema = [];
|
||||
assert.throws(ncformUtils.perfectFormSchema.bind(ncformUtils, formSchema), /fromSchema must be a json object/);
|
||||
|
||||
// root node's type is not 'object'
|
||||
formSchema = {
|
||||
type: 'array'
|
||||
};
|
||||
assert.throws(ncformUtils.perfectFormSchema.bind(ncformUtils, formSchema), /fromSchema' root field type must be object/);
|
||||
});
|
||||
it("perfectFormSchema - Implicit widget and widgetConfig", () => {
|
||||
let formSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string'
|
||||
},
|
||||
note: {},
|
||||
age: {
|
||||
type: 'integer'
|
||||
},
|
||||
grade: {
|
||||
type: 'number'
|
||||
},
|
||||
audit: {
|
||||
type: 'boolean'
|
||||
},
|
||||
hobbies: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let newFormSchema = ncformUtils.perfectFormSchema(formSchema);
|
||||
assert(newFormSchema.globalConfig.style.hasOwnProperty('formCls'));
|
||||
|
||||
formSchema = {
|
||||
assert.equal(newFormSchema.ui.widget, 'object');
|
||||
assert.equal(newFormSchema.properties.hobbies.ui.widget, 'array');
|
||||
assert.equal(newFormSchema.properties.name.ui.widget, 'input');
|
||||
assert.equal(newFormSchema.properties.name.ui.widgetConfig.type, 'text');
|
||||
assert.equal(newFormSchema.properties.note.type, 'string');
|
||||
assert.equal(newFormSchema.properties.note.ui.widget, 'input');
|
||||
assert.equal(newFormSchema.properties.note.ui.widgetConfig.type, 'text');
|
||||
assert.equal(newFormSchema.properties.age.ui.widget, 'input');
|
||||
assert.equal(newFormSchema.properties.age.ui.widgetConfig.type, 'number');
|
||||
assert.equal(newFormSchema.properties.grade.ui.widget, 'input');
|
||||
assert.equal(newFormSchema.properties.grade.ui.widgetConfig.type, 'number');
|
||||
assert.equal(newFormSchema.properties.audit.ui.widget, 'radio');
|
||||
});
|
||||
it("perfectFormSchema - Other fields", () => {
|
||||
let formSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
ui: {
|
||||
widget: 'myCustom'
|
||||
}
|
||||
}
|
||||
},
|
||||
globalConfig: {
|
||||
style: {
|
||||
formCls: 'bs-form'
|
||||
type: 'string'
|
||||
},
|
||||
obj: {
|
||||
type: 'object'
|
||||
},
|
||||
_link: {
|
||||
type: 'HTML'
|
||||
}
|
||||
}
|
||||
};
|
||||
newFormSchema = ncformUtils.perfectFormSchema(formSchema);
|
||||
assert(newFormSchema.globalConfig.style.formCls === 'bs-form');
|
||||
assert(newFormSchema.properties.name.ui.widget === 'my-custom');
|
||||
let newFormSchema = ncformUtils.perfectFormSchema(formSchema);
|
||||
assert.equal(newFormSchema.ui.showLabel, true);
|
||||
assert.equal(newFormSchema.ui.showLegend, true);
|
||||
assert.equal(newFormSchema.ui.noLabelSpace, false);
|
||||
assert.deepEqual(newFormSchema.globalConfig, {
|
||||
style: {
|
||||
formCls: "",
|
||||
invalidFeedbackCls: ""
|
||||
},
|
||||
validationMsg: {},
|
||||
constants: {}
|
||||
})
|
||||
assert.equal(newFormSchema.properties.name.ui.label, 'name');
|
||||
assert.equal(newFormSchema.properties.name.ui.showLabel, true);
|
||||
assert.equal(newFormSchema.properties.name.ui.noLabelSpace, false);
|
||||
assert.equal(newFormSchema.properties.obj.ui.label, 'obj');
|
||||
assert.equal(newFormSchema.properties.obj.ui.showLegend, false);
|
||||
assert.equal(newFormSchema.properties._link.ui.noLabelSpace, true);
|
||||
});
|
||||
|
||||
// --- getModelFromSchema
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
margin: 0 20px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../../../node_modules/element-ui/lib/theme-chalk/index.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ncform-show",
|
||||
"private": true,
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"description": "ncform show",
|
||||
"author": "daniel.xiao",
|
||||
"keywords": [
|
||||
@@ -55,9 +55,9 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ncform/ncform": "^1.1.0",
|
||||
"@ncform/ncform-common": "^1.1.0",
|
||||
"@ncform/ncform-theme-elementui": "^1.1.1",
|
||||
"@ncform/ncform": "^1.1.2",
|
||||
"@ncform/ncform-common": "^1.1.2",
|
||||
"@ncform/ncform-theme-elementui": "^1.1.2",
|
||||
"ace-builds": "^1.2.9",
|
||||
"lodash-es": "^4.16.2",
|
||||
"vue": "^2.1.8"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -43,7 +43,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script src="https://unpkg.com/mockjs"></script>
|
||||
<script src="https://unpkg.com/js-url"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/colorPicker.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/datePicker.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/inputNumber.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script src="https://unpkg.com/mockjs"></script>
|
||||
<script src="https://unpkg.com/js-url"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/label.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script src="https://unpkg.com/mockjs"></script>
|
||||
<script src="https://unpkg.com/js-url"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/rate.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script src="https://unpkg.com/mockjs"></script>
|
||||
<script src="https://unpkg.com/js-url"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/slider.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -44,7 +44,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/textarea.js"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -45,7 +45,7 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script src="https://unpkg.com/mockjs"></script>
|
||||
<script src="https://unpkg.com/js-url"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/input.js"></script>
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
|
||||
<title>select widget</title>
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
||||
|
||||
</head>
|
||||
|
||||
@@ -21,13 +22,23 @@
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script src="https://unpkg.com/mockjs"></script>
|
||||
<script src="https://unpkg.com/js-url"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/select.js"></script>
|
||||
<script type="text/javascript" src="../../dist/object.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
Mock.mock(/getMoney/, function(options) {
|
||||
let params = url('?', options.url) || {};
|
||||
let result = [{ id: 1, name: '1 yuan' }, { id: 2, name: '2 yuan' }];
|
||||
console.log('>>>>> getMoney')
|
||||
return result.filter(item => !params.keyword || item.name.indexOf(params.keyword) >= 0);
|
||||
});
|
||||
|
||||
Vue.use(vueNcform, { extComponents: { object: object.default, select: select.default } });
|
||||
|
||||
// Bootstrap the app
|
||||
@@ -35,46 +46,71 @@
|
||||
el: '#demo',
|
||||
data: {
|
||||
formSchema: {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"province": {
|
||||
"type": "string",
|
||||
"ui": {
|
||||
"widget": "select",
|
||||
"widgetConfig": {
|
||||
"itemLabelField": "name",
|
||||
"itemValueField": "id",
|
||||
"enumSourceRemote": {
|
||||
"remoteUrl": "/api/test/getProvinces",
|
||||
"paramName": "keyword"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"city": {
|
||||
"type": "string",
|
||||
"ui": {
|
||||
"widget": "select",
|
||||
"widgetConfig": {
|
||||
"itemLabelField": "name",
|
||||
"itemValueField": "id",
|
||||
"multiple": true,
|
||||
"enumSourceRemote": {
|
||||
"remoteUrl": "/api/test/getCities",
|
||||
"paramName": "keyword",
|
||||
"otherParams": {
|
||||
"provinceId": "dx: {{$root.province}}"
|
||||
},
|
||||
selectFirstItem: true
|
||||
type: 'object',
|
||||
properties: {
|
||||
choice: {
|
||||
type: 'number',
|
||||
ui: {
|
||||
widget: 'select',
|
||||
widgetConfig: {
|
||||
itemLabelField: "name",
|
||||
itemValueField: "id",
|
||||
itemTemplate: "<span>{{item.name}}</span>",
|
||||
multiple: true,
|
||||
filterable: true,
|
||||
enumSourceRemote: {
|
||||
remoteUrl: '/api/test/getMoney',
|
||||
paramName: "keyword",
|
||||
otherParams: {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// formSchema: {
|
||||
// "type": "object",
|
||||
// "properties": {
|
||||
// "province": {
|
||||
// "type": "string",
|
||||
// "ui": {
|
||||
// "widget": "select",
|
||||
// "widgetConfig": {
|
||||
// "itemLabelField": "name",
|
||||
// "itemValueField": "id",
|
||||
// "enumSourceRemote": {
|
||||
// "remoteUrl": "/api/test/getProvinces",
|
||||
// "paramName": "keyword"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// "city": {
|
||||
// "type": "string",
|
||||
// "ui": {
|
||||
// "widget": "select",
|
||||
// "widgetConfig": {
|
||||
// "itemLabelField": "name",
|
||||
// "itemValueField": "id",
|
||||
// "multiple": true,
|
||||
// "enumSourceRemote": {
|
||||
// "remoteUrl": "/api/test/getCities",
|
||||
// "paramName": "keyword",
|
||||
// "otherParams": {
|
||||
// "provinceId": "dx: {{$root.province}}"
|
||||
// },
|
||||
// selectFirstItem: true
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
model: {
|
||||
province: 2,
|
||||
city: 30
|
||||
// province: 2,
|
||||
// city: 30
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<!-- 引入样式 -->
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="../../node_modules/element-ui/lib/theme-chalk/index.css"
|
||||
href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"
|
||||
/>
|
||||
|
||||
<script>
|
||||
@@ -58,7 +58,7 @@
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="https://unpkg.com/element-ui@2.0.7/lib/index.js"
|
||||
src="https://unpkg.com/element-ui/lib/index.js"
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<!-- 引入样式 -->
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="../../node_modules/element-ui/lib/theme-chalk/index.css"
|
||||
href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"
|
||||
/>
|
||||
|
||||
<script>
|
||||
@@ -58,7 +58,7 @@
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="https://unpkg.com/element-ui@2.0.7/lib/index.js"
|
||||
src="https://unpkg.com/element-ui/lib/index.js"
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<!-- 引入样式 -->
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="../../node_modules/element-ui/lib/theme-chalk/index.css"
|
||||
href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"
|
||||
/>
|
||||
|
||||
<script>
|
||||
@@ -58,7 +58,7 @@
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="https://unpkg.com/element-ui@2.0.7/lib/index.js"
|
||||
src="https://unpkg.com/element-ui/lib/index.js"
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../demo.css" />
|
||||
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../../node_modules/element-ui/lib/theme-chalk/index.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
||||
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/vue/dist/vue.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.7/lib/index.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
||||
<script type="text/javascript" src="../../dist/input.js"></script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ncform/ncform-theme-elementui",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"description": "ncform theme element-ui",
|
||||
"author": "daniel.xiao; kyle.lo;",
|
||||
"main": "dist/ncformStdComps.min.js",
|
||||
@@ -10,7 +10,7 @@
|
||||
"element-ui"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@ncform/ncform": "^1.1.0",
|
||||
"@ncform/ncform": "^1.1.2",
|
||||
"autoprefixer": "^6.0.2",
|
||||
"axios": "^0.17.1",
|
||||
"babel-core": "^6.26.3",
|
||||
@@ -61,7 +61,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ncform/ncform-common": "^1.1.0",
|
||||
"@ncform/ncform-common": "^1.1.2",
|
||||
"element-ui": "^2.0.7",
|
||||
"lodash-es": "^4.16.2",
|
||||
"vue": "^2.1.8"
|
||||
|
||||
@@ -123,7 +123,7 @@ export default {
|
||||
methods: {
|
||||
// 你可以通过该方法在modelVal传出去之前进行加工处理,即在this.$emit('input')之前
|
||||
_processModelVal(newVal){
|
||||
return `${new Date(newVal).getTime()}`;
|
||||
return `${newVal ? new Date(newVal).getTime() : ''}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
:multiple="mergeConfig.multiple"
|
||||
:filterable="mergeConfig.filterable"
|
||||
:remote="!isLocalSource && !mergeConfig.filterLocal"
|
||||
:remote-method="remoteMethod"
|
||||
:remote-method="(!isLocalSource && !mergeConfig.filterLocal) ? remoteMethod : null"
|
||||
:loading="loading"
|
||||
>
|
||||
<el-option
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# ncform
|
||||
|
||||

|
||||

|
||||
|
||||
ncform, a nice form development way that generates form UIs and their interactions with just configuration.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ncform/ncform",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.2",
|
||||
"description": "ncform, a very nice configuration generation way to develop form ( vue, json-schema, form, generator )",
|
||||
"author": "daniel.xiao",
|
||||
"main": "dist/vueNcform.min.js",
|
||||
@@ -67,7 +67,7 @@
|
||||
"src"
|
||||
],
|
||||
"dependencies": {
|
||||
"@ncform/ncform-common": "^1.1.0",
|
||||
"@ncform/ncform-common": "^1.1.2",
|
||||
"axios": "^0.18.0",
|
||||
"extend": "^3.0.1",
|
||||
"lodash-es": "^4.16.2",
|
||||
|
||||
Reference in New Issue
Block a user