Commit 0818ce00 authored by YuleiLan's avatar YuleiLan

模版管理。

parent 41ec6a93
......@@ -37,6 +37,7 @@
],
"dependencies": {
"@riophae/vue-treeselect": "0.4.0",
"ace-builds": "^1.4.12",
"axios": "0.18.1",
"clipboard": "2.0.4",
"codemirror": "5.45.0",
......@@ -46,6 +47,7 @@
"echarts": "4.2.1",
"element-ui": "2.11.1",
"file-saver": "2.0.1",
"form-making": "^1.2.8",
"fuse.js": "3.4.4",
"js-cookie": "2.2.0",
"jsonlint": "1.6.3",
......@@ -54,14 +56,19 @@
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"path-to-regexp": "2.4.0",
"qiniu-js": "^3.0.3",
"screenfull": "4.2.0",
"showdown": "^1.9.1",
"solarlunar": "^2.0.7",
"sortablejs": "1.8.4",
"tui-editor": "1.3.3",
"viewerjs": "^1.6.1",
"vue": "2.6.10",
"vue-codemirror-lite": "^1.0.4",
"vue-count-to": "1.0.13",
"vue-cropper": "^0.5.0",
"vue-i18n": "^5.0.3",
"vue-quill-editor": "^3.0.6",
"vue-router": "3.0.2",
"vue-splitpane": "1.0.4",
"vuedraggable": "2.20.0",
......
<template>
<div id="app">
<div class="fm-header">
<img class="fm-logo" src="./assets/logo.png">
<div class="fm-title" @click="handleHome">{{ $t('header.title') }}</div>
<iframe style="vertical-align: middle;margin-top:10px;margin-left: 10px;" src="https://ghbtns.com/github-btn.html?user=GavinZhulei&repo=vue-form-making&type=star&count=true" frameborder="0" scrolling="0" width="160px" height="30px" />
<div class="fm-link">
<a target="_blank" href="http://form.xiaoyaoji.cn/pricing">{{ $t('header.pricing') }}</a>
<a target="_blank" href="http://docs.form.xiaoyaoji.cn">{{ $t('header.document') }}</a>
<a v-if="$lang == 'zh-CN'" target="_blank" href="http://docs.form.xiaoyaoji.cn/zh/other/course.html">学习课程</a>
<a target="_blank" href="https://github.com/GavinZhuLei/vue-form-making">GitHub</a>
<div class="action-item">
<el-dropdown trigger="click" @command="handleLangCommand">
<span class="el-dropdown-link">
{{ $route.params.lang == 'zh-CN' ? '简体中文' : 'English' }}<i class="el-icon-arrow-down el-icon--right" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="zh-CN">简体中文</el-dropdown-item>
<el-dropdown-item command="en-US">English</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<a class="ad" href="http://form.xiaoyaoji.cn" target="_blank">{{ $t('header.advanced') }}</a>
<a v-if="$lang == 'zh-CN'" class="ad" href="http://www.xiaoyaoji.cn" target="_blank">小幺鸡接口工具</a>
</div>
</div>
<div class="fm-container"><router-view /></div>
</div>
</template>
<script>
import Vue from 'vue'
export default {
name: 'App',
methods: {
handleHome() {
this.$router.push({ path: '/' })
},
handleLangCommand(command) {
this.$router.replace({ name: this.$route.name, params: { lang: command }})
}
}
}
</script>
<style lang="scss">
.fm-header{
height: 50px;
box-shadow: 0 2px 10px rgba(70,160,252, 0.6);
padding: 0 10px;
background-image: linear-gradient(to right,#1278f6,#00b4aa);
position: relative;
.fm-logo{
height: 26px;
vertical-align: middle;
}
.fm-title{
display: inline-block;
line-height: 50px;
vertical-align: middle;
color: #fff;
font-size: 20px;
font-weight: 600;
opacity: 0.8;
margin-left: 6px;
cursor: pointer;
}
.fm-link{
height: 50px;
float: right;
a{
color: #fff;
text-decoration: none;
font-size: 14px;
line-height: 50px;
font-weight: 500;
margin-left: 15px;
&:hover{
opacity: 0.8;
}
&.ad{
color: #f5dab1;
}
}
.action-item{
display: inline-block;
margin-left: 15px;
.el-dropdown{
// font-size: 16px;
// font-weight: 500;
}
.el-dropdown-link{
cursor: pointer;
color: #fff;
&:hover{
opacity: 0.8;
}
}
&.action-item-user{
.el-dropdown-link{
color: #f5dab1;
}
}
}
}
}
.fm-container{
height: calc(100% - 50px);
}
*, :after, :before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html,body{
height: 100%;
}
#app {
font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
min-height: 100%;
height: 100%;
}
</style>
This diff is collapsed.
<template>
<el-dialog
:id="id"
ref="elDialog"
class="cus-dialog-container"
:title="title"
:visible.sync="dialogVisible"
:close-on-click-modal="false"
append-to-body
center
:width="width"
>
<span v-if="show">
<slot />
</span>
<span
v-if="action"
slot="footer"
v-loading="loading"
class="dialog-footer"
:element-loading-text="loadingText"
>
<slot name="action">
<el-button @click="close">{{ $t('fm.actions.cancel') }}</el-button>
<el-button type="primary" @click="submit">{{ $t('fm.actions.confirm') }}</el-button>
</slot>
</span>
</el-dialog>
</template>
<script>
export default {
props: {
visible: Boolean,
loadingText: {
type: String,
default: ''
},
title: {
type: String,
default: ''
},
width: {
type: String,
default: '600px'
},
form: {
type: Boolean,
default: true
},
action: {
type: Boolean,
default: true
}
},
data() {
return {
loading: false,
dialogVisible: this.visible,
id: 'dialog_' + new Date().getTime(),
showForm: false
}
},
computed: {
show() {
if (this.form) {
return this.showForm
} else {
return true
}
}
},
watch: {
dialogVisible(val) {
if (!val) {
this.loading = false
this.$emit('on-close')
setTimeout(() => {
this.showForm = false
}, 300)
} else {
this.showForm = true
}
},
visible(val) {
this.dialogVisible = val
}
},
mounted() {
},
methods: {
close() {
this.dialogVisible = false
},
submit() {
this.loading = true
this.$emit('on-submit')
},
end() {
this.loading = false
}
}
}
</script>
<style lang="scss">
.cus-dialog-container{
.el-dialog__footer{
margin: 0 20px;
// border-top: 1px dashed #ccc;
padding: 15px 0 16px;
text-align: center;
position: relative;
.dialog-footer{
display: block;
.circular{
display: inline-block;
vertical-align: middle;
margin-right: 5px;
width: 24px;
height: 24px;
}
.el-loading-text{
display: inline-block;
vertical-align: middle;
}
.el-loading-spinner{
margin-top: -12px;
}
}
}
}
</style>
<template>
<div class="form-config-container">
<el-form label-position="top">
<el-form-item :label="$t('fm.config.form.labelPosition.title')">
<el-radio-group v-model="data.labelPosition">
<el-radio-button label="left">{{ $t('fm.config.form.labelPosition.left') }}</el-radio-button>
<el-radio-button label="right">{{ $t('fm.config.form.labelPosition.right') }}</el-radio-button>
<el-radio-button label="top">{{ $t('fm.config.form.labelPosition.top') }}</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('fm.config.form.labelWidth')">
<el-input-number v-model="data.labelWidth" :min="0" :max="200" :step="10" />
</el-form-item>
<el-form-item :label="$t('fm.config.form.size')">
<el-radio-group v-model="data.size">
<el-radio-button label="medium">medium</el-radio-button>
<el-radio-button label="small">small</el-radio-button>
<el-radio-button label="mini">mini</el-radio-button>
</el-radio-group>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
/* eslint-disable */
props: ['data']
}
</script>
<template>
<div>
<el-form
ref="generateForm"
label-suffix=":"
:size="data.config.size"
:model="models"
:rules="rules"
:label-position="data.config.labelPosition"
:label-width="data.config.labelWidth + 'px'"
>
<template v-for="item in data.list">
<template v-if="item.type == 'grid'">
<el-row
:key="item.key"
type="flex"
:gutter="item.options.gutter ? item.options.gutter : 0"
:justify="item.options.justify"
:align="item.options.align"
>
<el-col v-for="(col, colIndex) in item.columns" :key="colIndex" :span="col.span">
<template v-for="citem in col.list">
<el-form-item v-if="citem.type=='blank'" :key="citem.key" :label="citem.name" :prop="citem.model">
<slot :name="citem.model" :model="models" />
</el-form-item>
<genetate-form-item
v-else
:key="citem.key"
:models.sync="models"
:remote="remote"
:rules="rules"
:widget="citem"
@input-change="onInputChange"
:data="data"
/>
</template>
</el-col>
</el-row>
</template>
<template v-else-if="item.type == 'blank'">
<el-form-item :key="item.key" :label="item.name" :prop="item.model">
<slot :name="item.model" :model="models" />
</el-form-item>
</template>
<template v-else>
<genetate-form-item
:key="item.key"
:models.sync="models"
:rules="rules"
:widget="item"
:remote="remote"
:data="data"
@input-change="onInputChange"
/>
</template>
</template>
</el-form>
</div>
</template>
<script>
import GenetateFormItem from './GenerateFormItem'
export default {
name: 'FmGenerateForm',
components: {
GenetateFormItem
},
/* eslint-disable */
props: ['data', 'remote', 'value', 'insite'],
data() {
return {
models: {},
rules: {}
}
},
watch: {
data: {
deep: true,
handler(val) {
this.generateModle(val.list)
}
},
value: {
deep: true,
handler(val) {
this.models = { ...this.models, ...val }
}
}
},
created() {
this.generateModle(this.data.list)
},
mounted() {
},
methods: {
generateModle(genList) {
for (let i = 0; i < genList.length; i++) {
if (genList[i].type === 'grid') {
genList[i].columns.forEach(item => {
this.generateModle(item.list)
})
} else {
if (this.value && Object.keys(this.value).indexOf(genList[i].model) >= 0) {
this.models[genList[i].model] = this.value[genList[i].model]
} else {
if (genList[i].type === 'blank') {
this.$set(this.models, genList[i].model, genList[i].options.defaultType === 'String' ? '' : (genList[i].options.defaultType === 'Object' ? {} : []))
} else {
this.models[genList[i].model] = genList[i].options.defaultValue
}
}
if (this.rules[genList[i].model]) {
this.rules[genList[i].model] = [...this.rules[genList[i].model], ...genList[i].rules.map(item => {
if (item.pattern) {
return { ...item, pattern: eval(item.pattern) }
} else {
return { ...item }
}
})]
} else {
this.rules[genList[i].model] = [...genList[i].rules.map(item => {
if (item.pattern) {
return { ...item, pattern: eval(item.pattern) }
} else {
return { ...item }
}
})]
}
}
}
},
getData() {
return new Promise((resolve, reject) => {
this.$refs.generateForm.validate(valid => {
if (valid) {
resolve(this.models)
} else {
reject(new Error(this.$t('fm.message.validError')).message)
}
})
})
},
reset() {
this.$refs.generateForm.resetFields()
},
onInputChange(value, field) {
this.$emit('on-change', field, value, this.models)
},
refresh() {
}
}
}
</script>
<style lang="scss">
// @import '../styles/cover.scss';
</style>
<template>
<el-form-item
:label-width="widget.type==='divider' || (widget.type==='text' && widget.options.textLabelStatus===false)?'0px':data.config.labelWidth + 'px'"
:label="widget.type==='divider' || (widget.type==='text' && widget.options.textLabelStatus===false)?'':widget.name"
:prop="widget.model"
>
<template v-if="widget.type == 'input'">
<el-input
v-if="widget.options.dataType == 'number' || widget.options.dataType == 'integer' || widget.options.dataType == 'float'"
v-model.number="dataModel"
:type="widget.options.dataType"
:placeholder="widget.options.placeholder"
:style="{width: widget.options.width}"
:disabled="widget.options.disabled"
/>
<el-input
v-else
v-model="dataModel"
:type="widget.options.dataType"
:disabled="widget.options.disabled"
:placeholder="widget.options.placeholder"
:style="{width: widget.options.width}"
/>
</template>
<template v-if="widget.type == 'textarea'">
<el-input
v-model="dataModel"
type="textarea"
:rows="5"
:disabled="widget.options.disabled"
:placeholder="widget.options.placeholder"
:style="{width: widget.options.width}"
/>
</template>
<template v-if="widget.type == 'number'">
<el-input-number
v-model="dataModel"
:style="{width: widget.options.width}"
:step="widget.options.step"
controls-position="right"
:disabled="widget.options.disabled"
/>
</template>
<template v-if="widget.type == 'radio'">
<el-radio-group
v-model="dataModel"
:style="{width: widget.options.width}"
:disabled="widget.options.disabled"
>
<el-radio
v-for="(item, index) in (widget.options.remote ? widget.options.remoteOptions : widget.options.options)"
:key="index"
:style="{display: widget.options.inline ? 'inline-block' : 'block'}"
:label="item.value"
>
<template v-if="widget.options.remote">{{ item.label }}</template>
<template v-else>{{ widget.options.showLabel ? item.label : item.value }}</template>
</el-radio>
</el-radio-group>
</template>
<template v-if="widget.type == 'checkbox'">
<el-checkbox-group
v-model="dataModel"
:style="{width: widget.options.width}"
:disabled="widget.options.disabled"
>
<el-checkbox
v-for="(item, index) in (widget.options.remote ? widget.options.remoteOptions : widget.options.options)"
:key="index"
:style="{display: widget.options.inline ? 'inline-block' : 'block'}"
:label="item.value"
>
<template v-if="widget.options.remote">{{ item.label }}</template>
<template v-else>{{ widget.options.showLabel ? item.label : item.value }}</template>
</el-checkbox>
</el-checkbox-group>
</template>
<template v-if="widget.type == 'time'">
<el-time-picker
v-model="dataModel"
:is-range="widget.options.isRange"
:placeholder="widget.options.placeholder"
:start-placeholder="widget.options.startPlaceholder"
:end-placeholder="widget.options.endPlaceholder"
:readonly="widget.options.readonly"
:disabled="widget.options.disabled"
:editable="widget.options.editable"
:clearable="widget.options.clearable"
:arrow-control="widget.options.arrowControl"
:value-format="widget.options.format"
:style="{width: widget.options.width}"
/>
</template>
<template v-if="widget.type=='date'">
<el-date-picker
v-model="dataModel"
:type="widget.options.type"
:placeholder="widget.options.placeholder"
:start-placeholder="widget.options.startPlaceholder"
:end-placeholder="widget.options.endPlaceholder"
:readonly="widget.options.readonly"
:disabled="widget.options.disabled"
:editable="widget.options.editable"
:clearable="widget.options.clearable"
:value-format="widget.options.timestamp ? 'timestamp' : widget.options.format"
:format="widget.options.format"
:style="{width: widget.options.width}"
/>
</template>
<template v-if="widget.type =='rate'">
<el-rate
v-model="dataModel"
:max="widget.options.max"
:disabled="widget.options.disabled"
:allow-half="widget.options.allowHalf"
/>
</template>
<template v-if="widget.type == 'color'">
<el-color-picker
v-model="dataModel"
:disabled="widget.options.disabled"
:show-alpha="widget.options.showAlpha"
/>
</template>
<template v-if="widget.type == 'select'">
<el-select
v-model="dataModel"
:disabled="widget.options.disabled"
:multiple="widget.options.multiple"
:clearable="widget.options.clearable"
:placeholder="widget.options.placeholder"
:style="{width: widget.options.width}"
:filterable="widget.options.filterable"
>
<el-option v-for="item in (widget.options.remote ? widget.options.remoteOptions : widget.options.options)" :key="item.value" :value="item.value" :label="widget.options.showLabel || widget.options.remote?item.label:item.value" />
</el-select>
</template>
<template v-if="widget.type=='switch'">
<el-switch
v-model="dataModel"
:disabled="widget.options.disabled"
/>
</template>
<template v-if="widget.type=='slider'">
<el-slider
v-model="dataModel"
:min="widget.options.min"
:max="widget.options.max"
:disabled="widget.options.disabled"
:step="widget.options.step"
:show-input="widget.options.showInput"
:range="widget.options.range"
:style="{width: widget.options.width}"
/>
</template>
<template v-if="widget.type=='imgupload'">
<fm-upload
v-model="dataModel"
:disabled="widget.options.disabled"
:style="{'width': widget.options.width}"
:width="widget.options.size.width"
:height="widget.options.size.height"
:token="widget.options.token"
:domain="widget.options.domain"
:multiple="widget.options.multiple"
:length="widget.options.length"
:is-qiniu="widget.options.isQiniu"
:is-delete="widget.options.isDelete"
:min="widget.options.min"
:is-edit="widget.options.isEdit"
:action="widget.options.action"
/>
</template>
<template v-if="widget.type == 'editor'">
<vue-editor
v-model="dataModel"
:style="{width: widget.options.width}"
/>
</template>
<template v-if="widget.type === 'cascader'">
<el-cascader
v-model="dataModel"
:disabled="widget.options.disabled"
:clearable="widget.options.clearable"
:placeholder="widget.options.placeholder"
:style="{width: widget.options.width}"
:options="widget.options.remoteOptions"
/>
</template>
<template v-if="widget.type === 'text'">
<span
:style="{
'font-size': widget.options.font_size,
'font-family': widget.options.font_family,
'font-weight': widget.options.font_weight,
'color': widget.options.font_color
}"
>
{{ widget.options.defaultValue }}
</span>
</template>
<template v-if="widget.type === 'divider'">
<el-divider
:direction="widget.options.direction"
:content-position="widget.options.content_position"
>
<span
:style="{
'font-size': widget.options.font_size,
'font-family': widget.options.font_family,
'font-weight': widget.options.font_weight,
'color': widget.options.font_color
}"
>
{{ widget.options.defaultValue }}
</span>
</el-divider>
</template>
</el-form-item>
</template>
<script>
import FmUpload from './Upload'
export default {
components: {
FmUpload
},
/* eslint-disable */
props: ['widget', 'models', 'rules', 'remote', 'data'],
data() {
return {
dataModel: this.models[this.widget.model]
}
},
watch: {
dataModel: {
deep: true,
handler(val) {
this.models[this.widget.model] = val
this.$emit('update:models', {
...this.models,
[this.widget.model]: val
})
this.$emit('input-change', val, this.widget.model)
}
},
models: {
deep: true,
handler(val) {
this.dataModel = val[this.widget.model]
}
}
},
created() {
if (this.widget.options.remote && this.remote[this.widget.options.remoteFunc]) {
this.remote[this.widget.options.remoteFunc]((data) => {
this.widget.options.remoteOptions = data.map(item => {
return {
value: item[this.widget.options.props.value],
label: item[this.widget.options.props.label],
children: item[this.widget.options.props.children]
}
})
})
}
if (this.widget.type === 'imgupload' && this.widget.options.isQiniu) {
this.remote[this.widget.options.tokenFunc]((data) => {
this.widget.options.token = data
})
}
},
methods: {
}
}
</script>
This diff is collapsed.
This diff is collapsed.
<template>
<div class="widget-form-container">
<div v-if="data.list.length == 0" class="form-empty">{{ $t('fm.description.containerEmpty') }}</div>
<el-form :size="data.config.size" label-suffix=":" :label-position="data.config.labelPosition" :label-width="data.config.labelWidth + 'px'">
<draggable
v-model="data.list"
class=""
v-bind="{group:'people', ghostClass: 'ghost',animation: 200, handle: '.drag-widget'}"
@end="handleMoveEnd"
@add="handleWidgetAdd"
>
<transition-group name="fade" tag="div" class="widget-form-list">
<template v-for="(element, index) in data.list">
<template v-if="element.type == 'grid'">
<el-row
v-if="element && element.key"
:key="element.key"
class="widget-col widget-view"
type="flex"
:class="{active: selectWidget.key == element.key}"
:gutter="element.options.gutter ? element.options.gutter : 0"
:justify="element.options.justify"
:align="element.options.align"
@click.native="handleSelectWidget(index)"
>
<el-col v-for="(col, colIndex) in element.columns" :key="colIndex" :span="col.span ? col.span : 0">
<draggable
v-model="col.list"
:no-transition-on-drag="true"
v-bind="{group:'people', ghostClass: 'ghost',animation: 200, handle: '.drag-widget'}"
@end="handleMoveEnd"
@add="handleWidgetColAdd($event, element, colIndex)"
>
<transition-group name="fade" tag="div" class="widget-col-list">
<widget-form-item
v-for="(el, i) in col.list"
v-if="el.key"
:key="el.key"
:element="el"
:select.sync="selectWidget"
:index="i"
:data="col"
:data-config="data"
/>
</transition-group>
</draggable>
</el-col>
<div v-if="selectWidget.key == element.key" class="widget-view-action widget-col-action">
<i class="iconfont icon-trash" @click.stop="handleWidgetDelete(index)" />
</div>
<div v-if="selectWidget.key == element.key" class="widget-view-drag widget-col-drag">
<i class="iconfont icon-drag drag-widget" />
</div>
</el-row>
</template>
<template v-else>
<widget-form-item
v-if="element && element.key"
:key="element.key"
:element="element"
:select.sync="selectWidget"
:index="index"
:data-config="data"
:data="data"
/>
</template>
</template>
</transition-group>
</draggable>
</el-form>
</div>
</template>
<script>
import Draggable from 'vuedraggable'
import WidgetFormItem from './WidgetFormItem'
export default {
components: {
Draggable,
WidgetFormItem
},
/* eslint-disable */
props: ['data', 'select'],
data() {
return {
selectWidget: this.select
}
},
watch: {
select(val) {
this.selectWidget = val
},
selectWidget: {
handler(val) {
this.$emit('update:select', val)
},
deep: true
}
},
mounted() {
document.body.ondrop = function(event) {
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1
if (isFirefox) {
event.preventDefault()
event.stopPropagation()
}
}
},
methods: {
handleMoveEnd({ newIndex, oldIndex }) {
},
handleSelectWidget(index) {
this.selectWidget = this.data.list[index]
},
handleWidgetAdd(evt) {
const newIndex = evt.newIndex
const to = evt.to
// 为拖拽到容器的元素添加唯一 key
const key = Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999)
this.$set(this.data.list, newIndex, {
...this.data.list[newIndex],
options: {
...this.data.list[newIndex].options,
remoteFunc: 'func_' + key
},
key,
// 绑定键值
model: this.data.list[newIndex].type + '_' + key,
rules: []
})
if (this.data.list[newIndex].type === 'radio' || this.data.list[newIndex].type === 'checkbox' || this.data.list[newIndex].type === 'select') {
this.$set(this.data.list, newIndex, {
...this.data.list[newIndex],
options: {
...this.data.list[newIndex].options,
options: this.data.list[newIndex].options.options.map(item => ({
...item
}))
}
})
}
if (this.data.list[newIndex].type === 'grid') {
this.$set(this.data.list, newIndex, {
...this.data.list[newIndex],
columns: this.data.list[newIndex].columns.map(item => ({ ...item }))
})
}
this.selectWidget = this.data.list[newIndex]
},
handleWidgetColAdd($event, row, colIndex) {
const newIndex = $event.newIndex
const oldIndex = $event.oldIndex
const item = $event.item
// 防止布局元素的嵌套拖拽
if (item.className.indexOf('data-grid') >= 0) {
// 如果是列表中拖拽的元素需要还原到原来位置
item.tagName === 'DIV' && this.data.list.splice(oldIndex, 0, row.columns[colIndex].list[newIndex])
row.columns[colIndex].list.splice(newIndex, 1)
return false
}
const key = Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999)
this.$set(row.columns[colIndex].list, newIndex, {
...row.columns[colIndex].list[newIndex],
options: {
...row.columns[colIndex].list[newIndex].options,
remoteFunc: 'func_' + key
},
key,
// 绑定键值
model: row.columns[colIndex].list[newIndex].type + '_' + key,
rules: []
})
if (row.columns[colIndex].list[newIndex].type === 'radio' || row.columns[colIndex].list[newIndex].type === 'checkbox' || row.columns[colIndex].list[newIndex].type === 'select') {
this.$set(row.columns[colIndex].list, newIndex, {
...row.columns[colIndex].list[newIndex],
options: {
...row.columns[colIndex].list[newIndex].options,
options: row.columns[colIndex].list[newIndex].options.options.map(item => ({
...item
}))
}
})
}
this.selectWidget = row.columns[colIndex].list[newIndex]
},
handleWidgetDelete(index) {
if (this.data.list.length - 1 === index) {
if (index === 0) {
this.selectWidget = {}
} else {
this.selectWidget = this.data.list[index - 1]
}
} else {
this.selectWidget = this.data.list[index + 1]
}
this.$nextTick(() => {
this.data.list.splice(index, 1)
})
}
}
}
</script>
<template>
<el-form-item
v-if="element && element.key"
:label-width="element.type==='divider' || (element.type==='text' && element.options.textLabelStatus===false)?'0px':dataConfig.config.labelWidth + 'px'"
class="widget-view "
:class="{active: selectWidget.key === element.key, 'is_req': element.options.required}"
:label="element.type==='divider' || (element.type==='text' && element.options.textLabelStatus===false)?'':element.name"
@click.native.stop="handleSelectWidget(index)"
>
<template v-if="element.type == 'input'">
<el-input
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
:placeholder="element.options.placeholder"
:disabled="element.options.disabled"
/>
</template>
<template v-if="element.type == 'textarea'">
<el-input
v-model="element.options.defaultValue"
type="textarea"
:rows="5"
:style="{width: element.options.width}"
:disabled="element.options.disabled"
:placeholder="element.options.placeholder"
/>
</template>
<template v-if="element.type == 'number'">
<el-input-number
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
:controls-position="element.options.controlsPosition"
:style="{width: element.options.width}"
/>
</template>
<template v-if="element.type == 'radio'">
<el-radio-group
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
:disabled="element.options.disabled"
>
<el-radio
v-for="(item, index2) in element.options.options"
:key="item.value + index2"
:style="{display: element.options.inline ? 'inline-block' : 'block'}"
:label="item.value"
>
{{ element.options.showLabel ? item.label : item.value }}
</el-radio>
</el-radio-group>
</template>
<template v-if="element.type == 'checkbox'">
<el-checkbox-group
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
:disabled="element.options.disabled"
>
<el-checkbox
v-for="(item, index1) in element.options.options"
:key="item.value + index1"
:style="{display: element.options.inline ? 'inline-block' : 'block'}"
:label="item.value"
>
{{ element.options.showLabel ? item.label : item.value }}
</el-checkbox>
</el-checkbox-group>
</template>
<template v-if="element.type == 'time'">
<el-time-picker
v-model="element.options.defaultValue"
:is-range="element.options.isRange"
:placeholder="element.options.placeholder"
:start-placeholder="element.options.startPlaceholder"
:end-placeholder="element.options.endPlaceholder"
:readonly="element.options.readonly"
:disabled="element.options.disabled"
:editable="element.options.editable"
:clearable="element.options.clearable"
:arrow-control="element.options.arrowControl"
:style="{width: element.options.width}"
/>
</template>
<template v-if="element.type == 'date'">
<el-date-picker
v-model="element.options.defaultValue"
:type="element.options.type"
:is-range="element.options.isRange"
:placeholder="element.options.placeholder"
:start-placeholder="element.options.startPlaceholder"
:end-placeholder="element.options.endPlaceholder"
:readonly="element.options.readonly"
:disabled="element.options.disabled"
:editable="element.options.editable"
:clearable="element.options.clearable"
:style="{width: element.options.width}"
/>
</template>
<template v-if="element.type == 'rate'">
<el-rate
v-model="element.options.defaultValue"
:max="element.options.max"
:disabled="element.options.disabled"
:allow-half="element.options.allowHalf"
/>
</template>
<template v-if="element.type == 'color'">
<el-color-picker
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
:show-alpha="element.options.showAlpha"
/>
</template>
<template v-if="element.type == 'select'">
<el-select
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
:multiple="element.options.multiple"
:clearable="element.options.clearable"
:placeholder="element.options.placeholder"
:style="{width: element.options.width}"
>
<el-option v-for="item in element.options.options" :key="item.value" :value="item.value" :label="element.options.showLabel?item.label:item.value" />
</el-select>
</template>
<template v-if="element.type=='switch'">
<el-switch
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
/>
</template>
<template v-if="element.type=='slider'">
<el-slider
v-model="element.options.defaultValue"
:min="element.options.min"
:max="element.options.max"
:disabled="element.options.disabled"
:step="element.options.step"
:show-input="element.options.showInput"
:range="element.options.range"
:style="{width: element.options.width}"
/>
</template>
<template v-if="element.type=='imgupload'">
<fm-upload
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
:style="{'width': element.options.width}"
:width="element.options.size.width"
:height="element.options.size.height"
token="xxx"
domain="xxx"
/>
</template>
<template v-if="element.type == 'cascader'">
<el-cascader
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
:clearable="element.options.clearable"
:placeholder="element.options.placeholder"
:style="{width: element.options.width}"
:options="element.options.remoteOptions"
/>
</template>
<template v-if="element.type == 'editor'">
<vue-editor
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
/>
</template>
<template v-if="element.type=='blank'">
<div style="height: 50px;color: #999;background: #eee;line-height:50px;text-align:center;">{{ $t('fm.components.fields.blank') }}</div>
</template>
<template v-if="element.type === 'text'">
<span
:style="{
'font-size': element.options.font_size,
'font-family': element.options.font_family,
'font-weight': element.options.font_weight,
'color': element.options.font_color
}"
>
{{ element.options.defaultValue }}
</span>
</template>
<template v-if="element.type === 'divider'">
<el-divider
:direction="element.options.direction"
:content-position="element.options.content_position"
>
<span
:style="{
'font-size': element.options.font_size,
'font-family': element.options.font_family,
'font-weight': element.options.font_weight,
'color': element.options.font_color
}"
>
{{ element.options.defaultValue }}
</span>
</el-divider>
</template>
<div v-if="selectWidget.key == element.key" class="widget-view-action">
<i class="iconfont icon-icon_clone" @click.stop="handleWidgetClone(index)" />
<i class="iconfont icon-trash" @click.stop="handleWidgetDelete(index)" />
</div>
<div v-if="selectWidget.key == element.key" class="widget-view-drag">
<i class="iconfont icon-drag drag-widget" />
</div>
</el-form-item>
</template>
<script>
import FmUpload from './Upload'
export default {
components: {
FmUpload
},
/* eslint-disable */
props: ['element', 'select', 'index', 'data', 'dataConfig'],
data() {
return {
selectWidget: this.select
}
},
watch: {
select(val) {
this.selectWidget = val
},
selectWidget: {
handler(val) {
this.$emit('update:select', val)
},
deep: true
}
},
mounted() {
},
methods: {
handleSelectWidget(index) {
this.selectWidget = this.data.list[index]
},
handleWidgetDelete(index) {
if (this.data.list.length - 1 === index) {
if (index === 0) {
this.selectWidget = {}
} else {
this.selectWidget = this.data.list[index - 1]
}
} else {
this.selectWidget = this.data.list[index + 1]
}
this.$nextTick(() => {
this.data.list.splice(index, 1)
})
},
handleWidgetClone(index) {
let cloneData = {
...this.data.list[index],
options: { ...this.data.list[index].options },
key: Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999)
}
if (this.data.list[index].type === 'radio' || this.data.list[index].type === 'checkbox' || this.data.list[index].type === 'select') {
cloneData = {
...cloneData,
options: {
...cloneData.options,
options: cloneData.options.options.map(item => ({ ...item }))
}
}
}
this.data.list.splice(index, 0, cloneData)
this.$nextTick(() => {
this.selectWidget = this.data.list[index + 1]
})
}
}
}
</script>
export const basicComponents = [
{
type: 'input',
icon: 'icon-input',
options: {
width: '100%',
defaultValue: '',
required: false,
dataType: 'string',
pattern: '',
placeholder: '',
disabled: false
}
},
{
type: 'textarea',
icon: 'icon-diy-com-textarea',
options: {
width: '100%',
defaultValue: '',
required: false,
disabled: false,
pattern: '',
placeholder: ''
}
},
{
type: 'number',
icon: 'icon-number',
options: {
width: '',
required: false,
defaultValue: 0,
min: '',
max: '',
step: 1,
disabled: false,
controlsPosition: ''
}
},
{
type: 'radio',
icon: 'icon-radio-active',
options: {
inline: false,
defaultValue: '',
showLabel: false,
options: [
{
value: 'Option 1',
label: 'Option 1'
},
{
value: 'Option 2',
label: 'Option 2'
},
{
value: 'Option 3',
label: 'Option 3'
}
],
required: false,
width: '',
remote: false,
remoteOptions: [],
props: {
value: 'value',
label: 'label'
},
remoteFunc: '',
disabled: false
}
},
{
type: 'checkbox',
icon: 'icon-check-box',
options: {
inline: false,
defaultValue: [],
showLabel: false,
options: [
{
value: 'Option 1'
},
{
value: 'Option 2'
},
{
value: 'Option 3'
}
],
required: false,
width: '',
remote: false,
remoteOptions: [],
props: {
value: 'value',
label: 'label'
},
remoteFunc: '',
disabled: false
}
},
{
type: 'time',
icon: 'icon-time',
options: {
defaultValue: '21:19:56',
readonly: false,
disabled: false,
editable: true,
clearable: true,
placeholder: '',
startPlaceholder: '',
endPlaceholder: '',
isRange: false,
arrowControl: true,
format: 'HH:mm:ss',
required: false,
width: ''
}
},
{
type: 'date',
icon: 'icon-date',
options: {
defaultValue: '',
readonly: false,
disabled: false,
editable: true,
clearable: true,
placeholder: '',
startPlaceholder: '',
endPlaceholder: '',
type: 'date',
format: 'yyyy-MM-dd',
timestamp: false,
required: false,
width: ''
}
},
{
type: 'rate',
icon: 'icon-pingfen1',
options: {
defaultValue: null,
max: 5,
disabled: false,
allowHalf: false,
required: false
}
},
{
type: 'color',
icon: 'icon-color',
options: {
defaultValue: '',
disabled: false,
showAlpha: false,
required: false
}
},
{
type: 'select',
icon: 'icon-select',
options: {
defaultValue: '',
multiple: false,
disabled: false,
clearable: false,
placeholder: '',
required: false,
showLabel: false,
width: '',
options: [
{
value: 'Option 1'
},
{
value: 'Option 2'
}, {
value: 'Option 3'
}
],
remote: false,
filterable: false,
remoteOptions: [],
props: {
value: 'value',
label: 'label'
},
remoteFunc: ''
}
},
{
type: 'switch',
icon: 'icon-switch',
options: {
defaultValue: false,
required: false,
disabled: false
}
},
{
type: 'slider',
icon: 'icon-slider',
options: {
defaultValue: 0,
disabled: false,
required: false,
min: 0,
max: 100,
step: 1,
showInput: false,
range: false,
width: ''
}
},
{
type: 'text',
icon: 'icon-wenzishezhi-',
options: {
font_size: '15px', // 字体大小
font_color: '#606266', // 字体颜色
font_weight: '500', // 粗体
font_family: '', // 字体属性
defaultValue: 'This is a text',
textLabelStatus: true,
customClass: ''
}
}
]
export const advanceComponents = [
{
type: 'blank',
icon: 'icon-zidingyishuju',
options: {
defaultType: 'String'
}
},
{
type: 'imgupload',
icon: 'icon-tupian',
options: {
defaultValue: [],
size: {
width: 100,
height: 100
},
width: '',
tokenFunc: 'funcGetToken',
token: '',
domain: 'http://pfp81ptt6.bkt.clouddn.com/',
disabled: false,
length: 8,
multiple: false,
isQiniu: false,
isDelete: false,
min: 0,
isEdit: false,
action: 'https://jsonplaceholder.typicode.com/photos/'
}
},
{
type: 'editor',
icon: 'icon-fuwenbenkuang',
options: {
defaultValue: '',
width: ''
}
},
{
type: 'cascader',
icon: 'icon-jilianxuanze',
options: {
defaultValue: [],
width: '',
placeholder: '',
disabled: false,
clearable: false,
remote: true,
remoteOptions: [],
props: {
value: 'value',
label: 'label',
children: 'children'
},
remoteFunc: ''
}
}
]
export const layoutComponents = [
{
type: 'grid',
icon: 'icon-grid-',
columns: [
{
span: 12,
list: []
},
{
span: 12,
list: []
}
],
options: {
gutter: 0,
justify: 'start',
align: 'top'
}
},
{
type: 'divider',
icon: 'icon-input',
options: {
defaultValue: '分割线', // 字体大小
font_size: '15px', // 字体大小
font_color: '#606266', // 字体颜色
font_weight: '500', // 粗体
font_family: '', // 字体属性
direction: 'horizontal', // horizontal / vertical 设置分割线方向
content_position: 'center' // left / right / center 设置分割线文案的位置
}
}
]
function findRemoteFunc(list, funcList, tokenFuncList, blankList) {
for (let i = 0; i < list.length; i++) {
if (list[i].type === 'grid') {
list[i].columns.forEach(item => {
findRemoteFunc(item.list, funcList, tokenFuncList, blankList)
})
} else {
if (list[i].type === 'blank') {
if (list[i].model) {
blankList.push({
name: list[i].model,
label: list[i].name
})
}
} else if (list[i].type === 'imgupload') {
if (list[i].options.tokenFunc) {
tokenFuncList.push({
func: list[i].options.tokenFunc,
label: list[i].name,
model: list[i].model
})
}
} else {
if (list[i].options.remote && list[i].options.remoteFunc) {
funcList.push({
func: list[i].options.remoteFunc,
label: list[i].name,
model: list[i].model
})
}
}
}
}
}
export default function(data) {
const funcList = []
const tokenFuncList = []
const blankList = []
findRemoteFunc(JSON.parse(data).list, funcList, tokenFuncList, blankList)
let funcTemplate = ''
let blankTemplate = ''
for (let i = 0; i < funcList.length; i++) {
funcTemplate += `
${funcList[i].func} (resolve) {
// ${funcList[i].label} ${funcList[i].model}
// Call callback function once get the data from remote server
// resolve(data)
},
`
}
for (let i = 0; i < tokenFuncList.length; i++) {
funcTemplate += `
${tokenFuncList[i].func} (resolve) {
// ${tokenFuncList[i].label} ${tokenFuncList[i].model}
// Call callback function once get the token
// resolve(token)
},
`
}
for (let i = 0; i < blankList.length; i++) {
blankTemplate += `
<template slot="${blankList[i].name}" slot-scope="scope">
<!-- ${blankList[i].label} -->
<!-- use v-model="scope.model.${blankList[i].name}" to bind data -->
</template>
`
}
return `<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<link rel="stylesheet" href="https://unpkg.com/form-making/dist/FormMaking.css">
</head>
<body>
<div id="app">
<fm-generate-form :data="jsonData" :remote="remoteFuncs" :value="editData" ref="generateForm">
${blankTemplate}
</fm-generate-form>
<el-button type="primary" @click="handleSubmit">提交</el-button>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/form-making/dist/FormMaking.umd.js"></script>
<script>
new Vue({
el: '#app',
data: {
jsonData: ${data},
editData: {},
remoteFuncs: {
${funcTemplate}
}
},
methods: {
handleSubmit () {
this.$refs.generateForm.getData().then(data => {
// data check success
// data - form data
}).catch(e => {
// data check failed
})
}
}
})
</script>
</body>
</html>`
}
<template>
<fm-making-form ref="makingForm" upload preview generate-code generate-json clearable>
<template slot="action" />
</fm-making-form>
</template>
<script>
export default {
mounted() {
}
}
</script>
/* Logo 字体 */
@font-face {
font-family: "iconfont logo";
src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834');
src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834#iefix') format('embedded-opentype'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.woff?t=1545807318834') format('woff'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.ttf?t=1545807318834') format('truetype'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.svg?t=1545807318834#iconfont') format('svg');
}
.logo {
font-family: "iconfont logo";
font-size: 160px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* tabs */
.nav-tabs {
position: relative;
}
.nav-tabs .nav-more {
position: absolute;
right: 0;
bottom: 0;
height: 42px;
line-height: 42px;
color: #666;
}
#tabs {
border-bottom: 1px solid #eee;
}
#tabs li {
cursor: pointer;
width: 100px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 16px;
border-bottom: 2px solid transparent;
position: relative;
z-index: 1;
margin-bottom: -1px;
color: #666;
}
#tabs .active {
border-bottom-color: #f00;
color: #222;
}
.tab-container .content {
display: none;
}
/* 页面布局 */
.main {
padding: 30px 100px;
width: 960px;
margin: 0 auto;
}
.main .logo {
color: #333;
text-align: left;
margin-bottom: 30px;
line-height: 1;
height: 110px;
margin-top: -50px;
overflow: hidden;
*zoom: 1;
}
.main .logo a {
font-size: 160px;
color: #333;
}
.helps {
margin-top: 40px;
}
.helps pre {
padding: 20px;
margin: 10px 0;
border: solid 1px #e7e1cd;
background-color: #fffdef;
overflow: auto;
}
.icon_lists {
width: 100% !important;
overflow: hidden;
*zoom: 1;
}
.icon_lists li {
width: 100px;
margin-bottom: 10px;
margin-right: 20px;
text-align: center;
list-style: none !important;
cursor: default;
}
.icon_lists li .code-name {
line-height: 1.2;
}
.icon_lists .icon {
display: block;
height: 100px;
line-height: 100px;
font-size: 42px;
margin: 10px auto;
color: #333;
-webkit-transition: font-size 0.25s linear, width 0.25s linear;
-moz-transition: font-size 0.25s linear, width 0.25s linear;
transition: font-size 0.25s linear, width 0.25s linear;
}
.icon_lists .icon:hover {
font-size: 100px;
}
.icon_lists .svg-icon {
/* 通过设置 font-size 来改变图标大小 */
width: 1em;
/* 图标和文字相邻时,垂直对齐 */
vertical-align: -0.15em;
/* 通过设置 color 来改变 SVG 的颜色/fill */
fill: currentColor;
/* path 和 stroke 溢出 viewBox 部分在 IE 下会显示
normalize.css 中也包含这行 */
overflow: hidden;
}
.icon_lists li .name,
.icon_lists li .code-name {
color: #666;
}
/* markdown 样式 */
.markdown {
color: #666;
font-size: 14px;
line-height: 1.8;
}
.highlight {
line-height: 1.5;
}
.markdown img {
vertical-align: middle;
max-width: 100%;
}
.markdown h1 {
color: #404040;
font-weight: 500;
line-height: 40px;
margin-bottom: 24px;
}
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
color: #404040;
margin: 1.6em 0 0.6em 0;
font-weight: 500;
clear: both;
}
.markdown h1 {
font-size: 28px;
}
.markdown h2 {
font-size: 22px;
}
.markdown h3 {
font-size: 16px;
}
.markdown h4 {
font-size: 14px;
}
.markdown h5 {
font-size: 12px;
}
.markdown h6 {
font-size: 12px;
}
.markdown hr {
height: 1px;
border: 0;
background: #e9e9e9;
margin: 16px 0;
clear: both;
}
.markdown p {
margin: 1em 0;
}
.markdown>p,
.markdown>blockquote,
.markdown>.highlight,
.markdown>ol,
.markdown>ul {
width: 80%;
}
.markdown ul>li {
list-style: circle;
}
.markdown>ul li,
.markdown blockquote ul>li {
margin-left: 20px;
padding-left: 4px;
}
.markdown>ul li p,
.markdown>ol li p {
margin: 0.6em 0;
}
.markdown ol>li {
list-style: decimal;
}
.markdown>ol li,
.markdown blockquote ol>li {
margin-left: 20px;
padding-left: 4px;
}
.markdown code {
margin: 0 3px;
padding: 0 5px;
background: #eee;
border-radius: 3px;
}
.markdown strong,
.markdown b {
font-weight: 600;
}
.markdown>table {
border-collapse: collapse;
border-spacing: 0px;
empty-cells: show;
border: 1px solid #e9e9e9;
width: 95%;
margin-bottom: 24px;
}
.markdown>table th {
white-space: nowrap;
color: #333;
font-weight: 600;
}
.markdown>table th,
.markdown>table td {
border: 1px solid #e9e9e9;
padding: 8px 16px;
text-align: left;
}
.markdown>table th {
background: #F7F7F7;
}
.markdown blockquote {
font-size: 90%;
color: #999;
border-left: 4px solid #e9e9e9;
padding-left: 0.8em;
margin: 1em 0;
}
.markdown blockquote p {
margin: 0;
}
.markdown .anchor {
opacity: 0;
transition: opacity 0.3s ease;
margin-left: 8px;
}
.markdown .waiting {
color: #ccc;
}
.markdown h1:hover .anchor,
.markdown h2:hover .anchor,
.markdown h3:hover .anchor,
.markdown h4:hover .anchor,
.markdown h5:hover .anchor,
.markdown h6:hover .anchor {
opacity: 1;
display: inline-block;
}
.markdown>br,
.markdown>p>br {
clear: both;
}
.hljs {
display: block;
background: white;
padding: 0.5em;
color: #333333;
overflow-x: auto;
}
.hljs-comment,
.hljs-meta {
color: #969896;
}
.hljs-string,
.hljs-variable,
.hljs-template-variable,
.hljs-strong,
.hljs-emphasis,
.hljs-quote {
color: #df5000;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-type {
color: #a71d5d;
}
.hljs-literal,
.hljs-symbol,
.hljs-bullet,
.hljs-attribute {
color: #0086b3;
}
.hljs-section,
.hljs-name {
color: #63a35c;
}
.hljs-tag {
color: #333333;
}
.hljs-title,
.hljs-attr,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #795da3;
}
.hljs-addition {
color: #55a532;
background-color: #eaffea;
}
.hljs-deletion {
color: #bd2c00;
background-color: #ffecec;
}
.hljs-link {
text-decoration: underline;
}
/* 代码高亮 */
/* PrismJS 1.15.0
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection,
pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection,
code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection,
pre[class*="language-"] ::selection,
code[class*="language-"]::selection,
code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre)>code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre)>code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function,
.token.class-name {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import VueI18n from 'vue-i18n'
import 'normalize.css/normalize.css'
import MakingForm from './components/Container.vue'
import GenerateForm from './components/GenerateForm.vue'
import enUS from './lang/en-US'
import zhCN from './lang/zh-CN'
import './iconfont/iconfont.css'
import './styles/cover.scss'
import './styles/index.scss'
const loadLang = function(Vue, lang, locale, i18n) {
if (locale) {
locale('en-US', { ...locale('en-US'), ...enUS })
locale('zh-CN', { ...locale('zh-CN'), ...zhCN })
Vue.config.lang = lang
} else if (i18n) {
i18n.setLocaleMessage('en-US', { ...i18n.messages['en-US'], ...enUS })
i18n.setLocaleMessage('zh-CN', { ...i18n.messages['zh-CN'], ...zhCN })
i18n.locale = lang
} else {
Vue.use(VueI18n)
Vue.locale('en-US', { ...Vue.locale('en-US'), ...enUS })
Vue.locale('zh-CN', { ...Vue.locale('zh-CN'), ...zhCN })
Vue.config.lang = lang
}
}
MakingForm.install = function(Vue, opts = {
lang: 'zh-CN',
locale: null,
i18n: null
}) {
loadLang(Vue, opts.lang, opts.locale, opts.i18n)
Vue.component(MakingForm.name, MakingForm)
}
GenerateForm.install = function(Vue, opts = {
lang: 'zh-CN',
locale: null,
i18n: null
}) {
loadLang(Vue, opts.lang, opts.locale, opts.i18n)
Vue.component(GenerateForm.name, GenerateForm)
}
const components = [
MakingForm,
GenerateForm
]
const install = function(Vue, opts = {
lang: 'zh-CN',
locale: null,
i18n: null
}) {
loadLang(Vue, opts.lang, opts.locale, opts.i18n)
components.forEach(component => {
Vue.component(component.name, component)
})
}
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
export {
install,
MakingForm,
GenerateForm
}
export default {
install,
MakingForm,
GenerateForm
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment