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

issues 11

parent b885e337
...@@ -17,16 +17,19 @@ ...@@ -17,16 +17,19 @@
<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> <el-button class="filter-item" type="primary" v-waves icon="el-icon-refresh" @click="refreshList">刷新</el-button>
<el-button class="filter-item" type="primary" v-waves icon="el-icon-close" @click="BatchRemove" v-if="multipleSelection.length">批量删除</el-button>
</div> </div>
<!-- end 过滤 --> <!-- end 过滤 -->
<!-- 表格 --> <!-- 表格 -->
<el-table :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row <el-table :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
style="width: 100%"> style="width: 100%" @selection-change="handleSelectionChange">
<el-table-column type="index" :index="indexMethod"></el-table-column> <el-table-column type="index" :index="indexMethod" label="序号" width="50px"></el-table-column>
<el-table-column type="selection" width="55">
</el-table-column>
<el-table-column v-for="(column,index) in showColumns" :key="index" align="center" :label="column.name"> <el-table-column v-for="(column,index) in showColumns" :key="index" align="center" :label="column.name">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row[column.code] }}</span> <span>{{ scope.row[column.codeCamel] }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column fixed="right" label="操作" width="100"> <el-table-column fixed="right" label="操作" width="100">
...@@ -40,8 +43,8 @@ ...@@ -40,8 +43,8 @@
<!-- 翻页 --> <!-- 翻页 -->
<div class="pagination-container"> <div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page_no" <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.pageNo"
:page-sizes="[10,20,50]" :page-size="listQuery.page_size" layout="total, sizes, prev, pager, next, jumper" :total="total"> :page-sizes="[10,20,50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- end翻页 --> <!-- end翻页 -->
...@@ -49,7 +52,7 @@ ...@@ -49,7 +52,7 @@
<!-- 弹窗 --> <!-- 弹窗 -->
<!-- @TODO 补充弹窗 --> <!-- @TODO 补充弹窗 -->
<el-dialog title="收货地址" :visible.sync="dialogFormVisible" :close-on-click-modal="closeOnClickModal" width="dialogWidth"> <el-dialog :title="dialogName" :visible.sync="dialogFormVisible" :close-on-click-modal="closeOnClickModal" width="dialogWidth">
<el-form> <el-form>
<el-form-item :label="dialog.name" :label-width="formLabelWidth" v-for="dialog in dialogForm"> <el-form-item :label="dialog.name" :label-width="formLabelWidth" v-for="dialog in dialogForm">
<el-input v-model="dialog.value" auto-complete="off"></el-input> <el-input v-model="dialog.value" auto-complete="off"></el-input>
...@@ -133,7 +136,7 @@ ...@@ -133,7 +136,7 @@
* [ * [
* { * {
* "name": "姓名", * "name": "姓名",
* "code": "username", * "codeCamel": "username",
* "render": function(value){ * "render": function(value){
* return "<a href='value'></a>" * return "<a href='value'></a>"
* } * }
...@@ -162,12 +165,12 @@ ...@@ -162,12 +165,12 @@
required: false required: false
}, },
/** /**
* 表格的选项,包括:page_size。完整的示例为: * 表格的选项,包括:pageSize。完整的示例为:
* { * {
* "page_size": 10, // 默认为10条数据/页 * "pageSize": 10, // 默认为10条数据/页
* "showExport": false, // 默认为不显示导出按钮 * "showExport": false, // 默认为不显示导出按钮
* "sort_item": "create_time", // 默认为create_time字段的desc排序 * "sortItem": "create_time", // 默认为create_time字段的desc排序
* "sort_order": "desc", * "sortOrder": "desc",
* "changeValue": { // 数据库字段转化显示,例如(0=否,1=是) * "changeValue": { // 数据库字段转化显示,例如(0=否,1=是)
* username: {1: '是', 0: '否'} * username: {1: '是', 0: '否'}
* } * }
...@@ -188,10 +191,10 @@ ...@@ -188,10 +191,10 @@
total: null, total: null,
listLoading: true, listLoading: true,
listQuery: { listQuery: {
page_no: 1, pageNo: 1,
page_size: 20, pageSize: 20,
sort_item: 'create_time', sortItem: 'create_time',
sort_order: 'desc', sortOrder: 'desc',
filters: {} filters: {}
}, },
downloadLoading: false, downloadLoading: false,
...@@ -200,7 +203,9 @@ ...@@ -200,7 +203,9 @@
dialogType: '', // 弹窗的类型 dialogType: '', // 弹窗的类型
showColumns: [], // 要显示的列数据 showColumns: [], // 要显示的列数据
formLabelWidth: '120px', formLabelWidth: '120px',
closeOnClickModal: false closeOnClickModal: false,
multipleSelection: [], // 选择的数组
dialogName: ''
} }
}, },
computed: { computed: {
...@@ -234,7 +239,7 @@ ...@@ -234,7 +239,7 @@
}, },
methods: { methods: {
indexMethod(index) { indexMethod(index) {
return this.listQuery.page_size * (this.listQuery.page_no - 1) + index + 1 return this.listQuery.pageSize * (this.listQuery.pageNo - 1) + index + 1
}, },
validate() { validate() {
const self = this const self = this
...@@ -338,10 +343,13 @@ ...@@ -338,10 +343,13 @@
self.dialogForm = _.cloneDeep(self.schema.columns) self.dialogForm = _.cloneDeep(self.schema.columns)
if (type === 'editData') { if (type === 'editData') {
self.dialogName = '编辑'
_.map(self.dialogForm, function(item, index) { _.map(self.dialogForm, function(item, index) {
item.value = data[item.code] item.value = data[item.code]
item.id = data.id item.id = data.id
}) })
} else {
self.dialogName = '新建'
} }
}, },
// 删除过滤条件为空的filter // 删除过滤条件为空的filter
...@@ -354,7 +362,7 @@ ...@@ -354,7 +362,7 @@
} }
}) })
}) })
return JSON.stringify(newFilters[Object.keys(newFilters)]) === '{}' ? {} : newFilters return JSON.stringify(newFilters[Object.keys(newFilters)]) === '{}' ? null : newFilters
}, },
// 弹框提交数据 // 弹框提交数据
submitDialog() { submitDialog() {
...@@ -415,25 +423,65 @@ ...@@ -415,25 +423,65 @@
}, },
refreshList() { refreshList() {
this.listQuery = { this.listQuery = {
page_no: 1, pageNo: 1,
page_size: 20, pageSize: 20,
sort_item: 'create_time', sortItem: 'create_time',
sort_order: 'desc', sortOrder: 'desc',
filters: {} filters: {}
} }
this.init() this.init()
this.getList() this.getList()
}, },
// 批量删除
BatchRemove() {
const self = this
const datas = {
ids: []
}
if (!self.multipleSelection) return false
_.each(self.multipleSelection, function(item, index) {
datas.ids.push(item.id)
})
datas.ids = JSON.stringify(datas.ids)
self.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
request(self.schema.modelUnderscorePlural + '/delete/batch', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
data: datas,
transformRequest: param
}).then(data => {
if (data.data.message === 'delete success') {
self.$message({
message: data.data.message,
type: 'success'
})
self.getList()
}
})
}).catch(() => {
self.$message({
message: '已取消删除',
type: 'success'
})
})
},
handleSelectionChange(val) {
this.multipleSelection = val
},
handleFilter() { handleFilter() {
this.getList() this.getList()
}, },
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.page_size = val this.listQuery.pageSize = val
this.getList() this.getList()
}, },
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.page_no = val this.listQuery.pageNo = val
this.getList() this.getList()
}, },
handleDelete(row) { handleDelete(row) {
...@@ -488,4 +536,7 @@ ...@@ -488,4 +536,7 @@
.hm-complex-table__filter-span { .hm-complex-table__filter-span {
margin-right: 5px; margin-right: 5px;
} }
.el-table__body tr.current-row>td{
background-color: #ecf5ff;
}
</style> </style>
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
created() { created() {
this.schema = schema this.schema = schema
this.userOptions = { this.userOptions = {
page_size: 10,
changeValue: { changeValue: {
username: { 1: '是', 0: '否' } username: { 1: '是', 0: '否' }
} }
} }
}, },
methods: {} methods: {}
......
...@@ -3486,13 +3486,13 @@ const ModelSchema = { ...@@ -3486,13 +3486,13 @@ const ModelSchema = {
} }
] ]
}, },
'HmUser3': { 'HmUser': {
'model': 'HmUser3', 'model': 'HmUser3',
'modelPlural': 'HmUser3S', 'modelPlural': 'HmUsers',
'modelCamel': 'hmUser3', 'modelCamel': 'hmUser',
'modelCamelPlural': 'hmUser3S', 'modelCamelPlural': 'hmUsers',
'modelUnderscore': 'hm_user3', 'modelUnderscore': 'hm_user',
'modelUnderscorePlural': 'hm_user3S', 'modelUnderscorePlural': 'hm_users',
'columns': [ 'columns': [
{ {
'id': 'o449', 'id': 'o449',
......
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