Skip to content

Commit

Permalink
[feature]{CustomFunction}: 表单设计器加入远端方法
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Mar 24, 2019
1 parent 6ddc1ed commit abcede8
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/components/CrudTable/CrudTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
@afterSave="Refresh"
:jsonData="jsonData"
:entity.sync="models"
:remoteFunctions="remoteFunctions"
>
</GenerateFormDialog>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/components/CrudTable/components/GenerateFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:value="formValues"
:entity.sync="models"
:disabled="disabled"
:remote="remoteFunctions"
/>
<div slot="footer" class="dialog-footer">
<template v-if="dialogStatus === 'detail'">
Expand Down Expand Up @@ -82,7 +83,10 @@ export default {
type: Object,
default: () => ({}),
},
remoteFunctions: {
type: Object,
default: () => ({}),
},
},
methods: {
Expand Down
4 changes: 4 additions & 0 deletions src/components/CrudTable/components/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ export default {
type: Object,
default: () => ({}),
},
remoteFunctions: {
type: Object,
default: () => ({}),
},
};
19 changes: 10 additions & 9 deletions src/components/FormDesigner/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,16 @@ export default {
created() {
if (this.widget.options.remote && this.widget.options.remoteOptions) {
if (this.widget.options.remoteFunc !== '') {
this.axios({
url: this.widget.options.remoteFunc,
method: 'post',
}).then((res) => {
this.widget.options.remoteOptions = res.data.map(item => ({
value: item[this.widget.options.props.value],
label: item[this.widget.options.props.label],
}))
})
const remoteReq = this.remote[this.widget.options.remoteFunc]
if (remoteReq) {
remoteReq().then((res) => {
const response = res.data.list === null ? res.data : res.data.list
this.widget.options.remoteOptions = response.map(item => ({
value: item[this.widget.options.props.value],
label: item[this.widget.options.props.label],
}))
})
}
} else {
this.axios({
url: '/dict/getDictByKey',
Expand Down
14 changes: 8 additions & 6 deletions src/components/FormDesigner/WidgetConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@
v-model="data.options.remote"
size="mini"
style="margin-bottom:10px;">
<el-radio-button :label="false">静态数据</el-radio-button>
<el-radio-button :label="true">远端数据</el-radio-button>
<el-radio-button label="dict">数据字典</el-radio-button>
<el-radio-button label="static">静态数据</el-radio-button>
<el-radio-button label="custom">自定义方法</el-radio-button>
</el-radio-group>
<template v-if="data.options.remote">
<template v-if="data.options.remote=='custom'">
<div>
<el-input
v-model="data.options.remoteFunc"
Expand All @@ -139,8 +140,10 @@
style="">
<template slot="prepend">标签</template>
</el-input>

<el-select
</div>
</template>
<template v-else-if="data.options.remote=='dict'">
<el-select
v-model="data.options.dictID"
filterable>
<el-option
Expand All @@ -150,7 +153,6 @@
:value="item.id">
</el-option>
</el-select>
</div>
</template>
<template v-else>
<template v-if="data.type=='radio' || (data.type=='select'&&!data.options.multiple)">
Expand Down
4 changes: 2 additions & 2 deletions src/views/SIX/Notice.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div>
<crud-table
<CrudTable
tableName="six_notice"
toolbarButton="add,clear,search"
handleButton="edit,delete"
></crud-table>
></CrudTable>
</div>
</template>
<script>
Expand Down
15 changes: 13 additions & 2 deletions src/views/SIX/RewardOrPunish.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<template>
<div>
<crud-table
<CrudTable
tableName="six_rewardorpunish"
toolbarButton="add,clear,search"
handleButton="edit,delete"
></crud-table>
></CrudTable>
</div>
</template>
<script>
import crud from '@/api/Public/crud.js'
export default {
name: 'RewardOrPunish',
data() {
return {
remoteFunctions: {
funcGetStaff() {
return crud('list', 'six_staff', { pageSize: 100 })
},
},
}
},
};
</script>
16 changes: 14 additions & 2 deletions src/views/SIX/Salary.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
<template>
<div>
<crud-table
<CrudTable
tableName="six_salary"
toolbarButton="add,clear,search"
handleButton="edit,delete"
></crud-table>
:remoteFunctions="remoteFunctions"
></CrudTable>
</div>
</template>
<script>
import crud from '@/api/Public/crud.js'
export default {
name: 'Salary',
data() {
return {
remoteFunctions: {
funcGetStaff() {
return crud('list', 'six_staff', { pageSize: 100 })
},
},
}
},
};
</script>
14 changes: 12 additions & 2 deletions src/views/SIX/Staff.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
<template>
<div>
<crud-table
<CrudTable
tableName="six_staff"
toolbarButton="add,clear,search"
handleButton="edit,delete"
></crud-table>
:remoteFunctinos="remoteFunctinos"
></CrudTable>
</div>
</template>
<script>
export default {
name: 'Staff',
data() {
return {
remoteFunctinos: {
funcGetStaff() {
return this.crud('list', 'six_staff', { pageSize: 100 })
},
},
}
},
};
</script>
2 changes: 0 additions & 2 deletions src/views/system/role.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ export default {
this.fetchData(this.listQuery);
const arr = [...asyncRouterMap]
arr.filter((item) => {
console.log(item)
if (item.children) {
const obj = item.children;
obj.forEach((k) => {
k.title = k.meta.title;
});
}
if (item.hidden) {
return false;
}
Expand Down

0 comments on commit abcede8

Please sign in to comment.