Skip to content

Commit

Permalink
数据字典 类目 增删改查
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Feb 8, 2019
1 parent f8c0a11 commit 13c2ac2
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 39 deletions.
1 change: 0 additions & 1 deletion src/components/FormDesigner/GenerateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export default {
}
genList.push({ ...obj })
console.log(genList)
for (let i = 0; i < genList.length; i++) {
if (genList[i].type === 'grid') {
genList[i].columns.forEach((item) => {
Expand Down
14 changes: 3 additions & 11 deletions src/components/FormDesigner/ListConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@
</td>
</tr>
</draggable>

</table>


<!-- <el-button @click="addOperationColumn()">添加操作列</el-button> -->
<el-button
style="margin:0 auto;display:block;margin-top:10px"
size="mini"
Expand Down Expand Up @@ -232,9 +228,9 @@ export default {
/* 如果是初次制作,默认显示所有列
* label为数据库字段注释
* value为数据库字段名
*/
* label为数据库字段注释
* value为数据库字段名
*/
if (this.config.columnList.length === 0 || !this.config.columnList) {
const obj = { ...this.configObj }
obj.label = item.COLUMN_COMMENT
Expand All @@ -247,10 +243,6 @@ export default {
},
},
methods: {
// addOperationColumn() {
// this.config.columnList.push({ ...this.operation })
// },
removeItem(item) {
const index = this.config.columnList.indexOf(item);
if (index != null) {
Expand Down
4 changes: 0 additions & 4 deletions src/components/FormDesigner/WidgetFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@
<template v-if="element.type=='upload'">
<upload-affix :params="element.options.uploadParams"/>
</template>
<!-- <template v-if="element.type=='blank'">
<div style="height: 50px;color: #999;background: #eee;line-height:50px;text-align:center;">自定义区域</div>
</template> -->

<el-button
v-if="selectWidget.key == element.key"
title="删除"
Expand Down
121 changes: 98 additions & 23 deletions src/views/system/dict.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,31 @@
node-key="id"
highlight-current
:default-expanded-keys="['00000000-0000-0000-0000-000000000001']"
@node-click="dicttypeTreeClick"
/>
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ node.label }}</span>
<span style="margin-left:8px">
<el-button
type="text"
size="mini"
@click="() => append(data)">
添加
</el-button>
<el-button
type="text"
size="mini"
@click="() => Edit(data.id)">
修改
</el-button>
<el-button
type="text"
size="mini"
@click="() => remove(data)">
删除
</el-button>
</span>
</span>
</el-tree>
</el-col>
<el-col :span="16">
<crud-table tableName="dict" class="no-boxshadow no-padding-top" toolbarButton="add,clear" handleButton="edit,delete"></crud-table>
Expand All @@ -21,6 +44,38 @@

</el-row>

<el-dialog
:title="textMap[dialogStatus]"
:visible.sync="dialogFormVisible"
width="80%">

<el-form ref="form" :model="entity" label-width="80px">
<el-form-item label="类目名">
<el-input v-model="entity.name"></el-input>
</el-form-item>

<el-form-item label="排序码">
<el-input-number v-model="entity.sort"></el-input-number>
</el-form-item>


</el-form>

<div
slot="footer"
class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button
v-if="dialogStatus=='create'"
type="primary"
@click="save">新 增</el-button>
<el-button
v-else
type="primary"
@click="save">修 改</el-button>
</div>
</el-dialog>

</div>
</template>

Expand All @@ -40,9 +95,20 @@ export default {
data() {
return {
dicttypeoptions: [],
dialogFormVisible: false,
textMap: {
update: '编辑',
create: '新增',
},
status: 'create',
dicttypeList: null,
temp: null,
entity: {
id: '',
name: '',
sort: '',
pid: '',
},
dialogStatus: '',
defaultProps: {
children: 'children',
label: 'nodeName',
Expand All @@ -59,47 +125,56 @@ export default {
},
methods: {
clearObj() {
Object.keys(this.temp).forEach((key) => {
this.temp[key] = ''
})
this.status = 'create'
},
fetchDictType() {
GetDictTypeTree().then((response) => {
this.dicttypeList = response.data;
});
},
dicttypeTreeClick(obj) {
this.status = 'update'
this.Edit(obj.id)
append(data) {
this.dialogStatus = 'create'
this.clearObj()
this.entity.pid = data.id
this.dialogFormVisible = true
},
Delete() {
remove(data) {
this.$confirm('确认删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
DeleteDictType(this.temp.id).then(() => {
DeleteDictType(data.id).then(() => {
this.dialogFormVisible = false
this.fetchDictType()
})
})
},
clearObj() {
Object.keys(this.entity).forEach((key) => {
this.entity[key] = ''
})
this.status = 'create'
},
fetchDictType() {
GetDictTypeTree().then((response) => {
this.dicttypeList = response.data;
});
},
Edit(id) {
GetDictTypeDetail(id).then((response) => {
this.temp = response.data;
this.entity = response.data;
this.status = 'update'
this.dialogFormVisible = true
});
},
save() {
if (this.status === 'create') {
AddDictType(this.temp).then(() => {
AddDictType(this.entity).then(() => {
this.fetchDictType();
this.dialogFormVisible = false
})
} else {
UpdateDictType(this.temp).then(() => {
UpdateDictType(this.entity).then(() => {
this.fetchDictType();
this.dialogFormVisible = false
})
}
},
Expand Down

0 comments on commit 13c2ac2

Please sign in to comment.