Commit 14ea3982 authored by gaochao's avatar gaochao

Merge branch 'master' of 115.28.80.125:softwarefactory/vueelementtemplate

parents fc911235 f39d2ee5
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button> <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
<el-button class="filter-item" type="primary" :loading="downloadLoading" v-waves icon="el-icon-download" @click="handleDownload">导出</el-button> <el-button class="filter-item" type="primary" :loading="downloadLoading" v-waves icon="el-icon-download" @click="handleDownload">导出</el-button>
<el-button class="filter-item" type="primary" v-waves icon="el-icon-plus" @click="openDialog('newData')">新建</el-button> <el-button class="filter-item" type="primary" v-waves icon="el-icon-plus" @click="openDialog('newData')">新建</el-button>
<el-button class="filter-item" type="primary" v-waves icon="el-icon-refresh" @click="refreshList">刷新</el-button>
</div> </div>
<!-- end 过滤 --> <!-- end 过滤 -->
...@@ -166,7 +167,10 @@ ...@@ -166,7 +167,10 @@
* "page_size": 10, // 默认为10条数据/页 * "page_size": 10, // 默认为10条数据/页
* "showExport": false, // 默认为不显示导出按钮 * "showExport": false, // 默认为不显示导出按钮
* "sort_item": "create_time", // 默认为create_time字段的desc排序 * "sort_item": "create_time", // 默认为create_time字段的desc排序
"sort_order": "desc" * "sort_order": "desc",
* "changeValue": { // 数据库字段转化显示,例如(0=否,1=是)
* username: {1: '是', 0: '否'}
* }
* } * }
*/ */
options: { options: {
...@@ -281,7 +285,7 @@ ...@@ -281,7 +285,7 @@
const tableName = self.schema['modelUnderscore'] const tableName = self.schema['modelUnderscore']
const filters = {} const filters = {}
filters[tableName] = {} filters[tableName] = {}
_.each(self.filters, function(filter) { _.each(_.cloneDeep(self.filters), function(filter) {
filters[tableName] = Object.assign(filters[tableName], filter) filters[tableName] = Object.assign(filters[tableName], filter)
}) })
delete filters[tableName]['placeholder'] delete filters[tableName]['placeholder']
...@@ -306,11 +310,26 @@ ...@@ -306,11 +310,26 @@
request(self.schema.modelUnderscorePlural, { request(self.schema.modelUnderscorePlural, {
params: params params: params
}).then(resp => { }).then(resp => {
if (self.options.changeValue) {
resp.data = self.changeValue(resp.data)
}
self.list = resp.data self.list = resp.data
self.total = parseInt(resp.headers.total) self.total = parseInt(resp.headers.total)
self.listLoading = false self.listLoading = false
}) })
}, },
// 数据库字段转化显示,例如(0=否,1=是)
changeValue(data) {
const self = this
_.map(data, function(item, index) {
_.forEach(item, function(listValue, listKey) {
if (self.options.changeValue[listKey] && self.options.changeValue[listKey][listValue]) {
item[listKey] = self.options.changeValue[listKey][listValue]
}
})
})
return data
},
// 添加一条数据 // 添加一条数据
openDialog(type, data) { openDialog(type, data) {
const self = this const self = this
...@@ -370,19 +389,42 @@ ...@@ -370,19 +389,42 @@
// 删除一条数据 // 删除一条数据
deleteData(data) { deleteData(data) {
const self = this const self = this
request(self.schema.modelUnderscorePlural + '/' + data.id + '/delete', { self.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
method: 'POST', confirmButtonText: '确定',
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' } cancelButtonText: '取消',
}).then(data => { type: 'warning'
if (data.data.message === 'delete success') { }).then(() => {
self.$message({ request(self.schema.modelUnderscorePlural + '/' + data.id + '/delete', {
message: data.data.message, method: 'POST',
type: 'success' headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
}) }).then(data => {
self.getList() if (data.data.message === 'delete success') {
} self.$message({
message: data.data.message,
type: 'success'
})
self.getList()
}
})
}).catch(() => {
self.$message({
message: '已取消删除',
type: 'success'
})
}) })
}, },
refreshList() {
this.listQuery = {
page_no: 1,
page_size: 20,
sort_item: 'create_time',
sort_order: 'desc',
filters: {}
}
this.init()
this.getList()
},
handleFilter() { handleFilter() {
this.getList() this.getList()
}, },
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<div class="app-container calendar-list-container"> <div class="app-container calendar-list-container">
<hm-complex-table :schema="schema['HmUser']" <hm-complex-table :schema="schema['HmUser']"
:columns="showUserColumns" :columns="showUserColumns"
:filters="userFilters"></hm-complex-table> :filters="userFilters"
:options="userOptions"></hm-complex-table>
</div> </div>
</template> </template>
...@@ -31,6 +32,12 @@ ...@@ -31,6 +32,12 @@
}, },
created() { created() {
this.schema = schema this.schema = schema
this.userOptions = {
page_size: 10,
changeValue: {
username: { 1: '是', 0: '否' }
}
}
}, },
methods: {} methods: {}
} }
......
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