Skip to content

Commit

Permalink
数据字典加入表单设计器中
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Feb 5, 2019
1 parent deb24a3 commit 4b3af31
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/api/system/dicttype.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import fetch from '@/utils/fetch'

export function DictTypeList(params) {
export function DictTypeList() {
return fetch({
url: '/dicttype/list',
method: 'post',
params,
})
}

Expand Down
33 changes: 24 additions & 9 deletions src/components/FormDesigner/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,30 @@ export default {
// })
// }
if (this.widget.options.remote && this.widget.options.remoteOptions) {
this.axios({
url: this.widget.options.remoteFunc,
method: 'post',
}).then((res) => {
this.widget.options.remoteOptions = res.data.list.map(item => ({
value: item[this.widget.options.props.value],
label: item[this.widget.options.props.label],
}))
})
if (this.widget.options.remoteFunc !== '') {
this.axios({
url: this.widget.options.remoteFunc,
method: 'post',
}).then((res) => {
this.widget.options.remoteOptions = res.data.list.map(item => ({
value: item[this.widget.options.props.value],
label: item[this.widget.options.props.label],
}))
})
} else {
this.axios({
url: '/dict/getDictByKey',
method: 'post',
params: {
DictID: this.widget.options.dictID,
},
}).then((res) => {
this.widget.options.remoteOptions = res.data.map(item => ({
value: item.value,
label: item.title,
}))
})
}
}
},
}
Expand Down
34 changes: 18 additions & 16 deletions src/components/FormDesigner/WidgetConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@
style="">
<template slot="prepend">标签</template>
</el-input>

<el-select
v-model="data.options.dictID"
filterable>
<el-option
v-for="item in options"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</template>
<template v-else>
Expand Down Expand Up @@ -334,22 +345,6 @@
</el-form-item>
</template>

<template v-if="data.type=='blank'">
<el-form-item label="绑定数据类型">
<el-select v-model="data.options.defaultType">
<el-option
value="String"
label="字符"/>
<el-option
value="Object"
label="对象"/>
<el-option
value="Array"
label="数组"/>
</el-select>
</el-form-item>
</template>

<template v-if="data.type == 'grid'">
<el-form-item label="栅格间隔">
<el-input
Expand Down Expand Up @@ -516,6 +511,7 @@ import 'vue-awesome/icons/toggle-off'
import 'vue-awesome/icons/sliders-h'
import 'vue-awesome/icons/regular/image'
import 'vue-awesome/icons/chalkboard'
import { DictTypeList } from '@/api/system/dicttype'
export default {
components: {
Expand All @@ -532,8 +528,14 @@ export default {
range: null,
length: null,
},
options: [],
}
},
created() {
DictTypeList().then((res) => {
this.options = res.data.filter(item => item.name !== '数据字典')
})
},
computed: {
show() {
if (this.data && Object.keys(this.data).length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormDesigner/WidgetForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default {
...this.data.list[newIndex],
options: {
...this.data.list[newIndex].options,
remoteFunc: `func_${key}`,
remoteFunc: '',
},
key,
// 绑定键值
Expand Down
1 change: 1 addition & 0 deletions src/components/FormDesigner/componentsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const basicComponents = [
label: 'label',
},
remoteFunc: '',
dictID: '',
},
},
{
Expand Down

0 comments on commit 4b3af31

Please sign in to comment.