Commit bf49382e authored by 杨柠瑞's avatar 杨柠瑞

issues6

parent 9918704d
...@@ -28,6 +28,12 @@ ...@@ -28,6 +28,12 @@
<span>{{ scope.row[column.code] }}</span> <span>{{ scope.row[column.code] }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column fixed="right" label="操作" width="100">
<template slot-scope="scope">
<el-button @click="openDialog('editData',scope.row)" type="text" size="small">编辑</el-button>
<el-button @click="" type="text" size="small">删除</el-button>
</template>
</el-table-column>
</el-table> </el-table>
<!-- end 表格 --> <!-- end 表格 -->
...@@ -306,11 +312,18 @@ ...@@ -306,11 +312,18 @@
}) })
}, },
// 添加一条数据 // 添加一条数据
openDialog(type) { openDialog(type, data) {
const self = this const self = this
self.dialogType = type self.dialogType = type
self.dialogFormVisible = true self.dialogFormVisible = true
self.dialogForm = _.cloneDeep(self.schema.columns) self.dialogForm = _.cloneDeep(self.schema.columns)
if (type === 'editData') {
_.map(self.dialogForm, function(item, index) {
item.value = data[item.code]
item.id = data.id
})
}
}, },
// 删除过滤条件为空的filter // 删除过滤条件为空的filter
deleteFilter(filters) { deleteFilter(filters) {
...@@ -328,20 +341,22 @@ ...@@ -328,20 +341,22 @@
submitDialog() { submitDialog() {
const self = this const self = this
const params = {} const params = {}
let url = self.schema.modelUnderscorePlural
let paramsId = ''
self.dialogFormVisible = false self.dialogFormVisible = false
_.each(self.dialogForm, function(data, index) { _.each(self.dialogForm, function(data, index) {
if (data.value) { if (data.value) {
params[data.code] = data.value params[data.code] = data.value
paramsId = data.id
} }
}) })
// 新建
if (self.dialogType === 'newData') { if (self.dialogType === 'newData') {
self.addData(params) url = url + '/new'
} else if (self.dialogType === 'editData') {
url = url + '/' + paramsId + '/edit'
} }
},
addData(params) { request(url, {
const self = this
request(self.schema.modelUnderscorePlural + '/new', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
data: params, data: params,
......
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