huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <div class="app-container"> |
| 3 | <div class="filter-container"> |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame^] | 4 | <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="学年代码" v-model="listQuery.code"> |
huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 5 | </el-input> |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame^] | 6 | <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="学年名称" v-model="listQuery.name"> |
huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 7 | </el-input> |
| 8 | <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查询</el-button> |
| 9 | <el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate(null, 'create')" type="primary" icon="el-icon-edit">添加</el-button> |
| 10 | <el-button class="filter-item" style="margin-left: 10px;" @click="handleReset" type="primary" icon="el-icon-edit">重置</el-button> |
| 11 | </div> |
| 12 | <el-table :height="height" :data="items" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row> |
| 13 | <el-table-column align="center" label='序号' width="95"> |
| 14 | <template slot-scope="scope"> |
| 15 | {{scope.row.id}} |
| 16 | </template> |
| 17 | </el-table-column> |
| 18 | <el-table-column label="学年代码" align="center"> |
| 19 | <template slot-scope="scope"> |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame^] | 20 | {{scope.row.code}} |
huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 21 | </template> |
| 22 | </el-table-column> |
| 23 | <el-table-column label="学年名称" align="center"> |
| 24 | <template slot-scope="scope"> |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame^] | 25 | <span>{{scope.row.name}}</span> |
huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 26 | </template> |
| 27 | </el-table-column> |
| 28 | <el-table-column |
| 29 | header-align="center" |
| 30 | align="center" |
| 31 | width="150" |
| 32 | label="操作"> |
| 33 | <template slot-scope="scope"> |
| 34 | <el-button type="text" size="small" @click="handleCreate(scope.row.id, 'update')">修改</el-button> |
| 35 | <el-button type="text" size="small" @click="handleDelete(scope.row.id)">删除</el-button> |
| 36 | </template> |
| 37 | </el-table-column> |
| 38 | </el-table> |
| 39 | <div class="pagination-container"> |
| 40 | <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.pageIndex" |
| 41 | :page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="recordCount"> |
| 42 | </el-pagination> |
| 43 | </div> |
| 44 | |
| 45 | <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible"> |
| 46 | <el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="150px" style='width: 400px; margin-left:50px;'> |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame^] | 47 | <el-form-item label="学年代码" prop="code"> |
| 48 | <el-input v-if="dialogStatus === 'update'" disabled v-model="temp.code"></el-input> |
| 49 | <el-input v-else v-model="temp.code"></el-input> |
huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 50 | <input type="hidden" v-model="temp.id" /> |
| 51 | </el-form-item> |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame^] | 52 | <el-form-item label="学年名称" prop="name"> |
| 53 | <el-input v-model="temp.name"></el-input> |
huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 54 | </el-form-item> |
| 55 | </el-form> |
| 56 | <div slot="footer" class="dialog-footer"> |
| 57 | <el-button @click="dialogFormVisible = false">返回</el-button> |
| 58 | <el-button type="primary" @click="createData">提交</el-button> |
| 59 | </div> |
| 60 | </el-dialog> |
| 61 | </div> |
| 62 | </template> |
| 63 | |
| 64 | <script> |
| 65 | import { getList, getItem, createSchoolyear, deleteSchoolyear } from '@/api/schoolyear-api' |
| 66 | import waves from '@/directive/waves' // 水波纹指令 |
| 67 | import { resetForm } from '@/utils' |
| 68 | import { crudPageList, crudGetItem, crudCreate, crudDelete } from '@/utils/crud' |
| 69 | import mixindata from '@/utils/crud' |
| 70 | |
| 71 | const initData = {} |
| 72 | export default { |
| 73 | name: 'schoolyear', |
| 74 | directives: { |
| 75 | waves |
| 76 | }, |
| 77 | mixins: [mixindata], |
| 78 | data() { |
| 79 | return { |
| 80 | rules: { |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame^] | 81 | code: [{ required: true, message: '学年代码必填', trigger: 'blur' }], |
| 82 | name: [{ required: true, message: '学年名称必填', trigger: 'blur' }] |
huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | }, |
| 86 | filters: { |
| 87 | statusFilter(status) { |
| 88 | const statusMap = { |
| 89 | '1': 'success', |
| 90 | '0': 'danger' |
| 91 | } |
| 92 | return statusMap[status] |
| 93 | } |
| 94 | }, |
| 95 | created() { |
| 96 | this.handlePageList() |
| 97 | this.height = window.innerHeight - 216 |
| 98 | }, |
| 99 | methods: { |
| 100 | handlePageList() { |
| 101 | crudPageList(this, getList) |
| 102 | }, |
| 103 | handleCreate(rowid, dialogStatus) { |
| 104 | this.dialogStatus = dialogStatus |
| 105 | crudGetItem(this, getItem, rowid, initData) |
| 106 | }, |
| 107 | handleReset() { |
| 108 | resetForm(this.listQuery) |
| 109 | }, |
| 110 | handleFilter() { |
| 111 | this.listQuery.pageIndex = 1 |
| 112 | this.handlePageList() |
| 113 | }, |
| 114 | handleSizeChange(val) { |
| 115 | this.listQuery.pageSize = val |
| 116 | this.handlePageList() |
| 117 | }, |
| 118 | handleCurrentChange(val) { |
| 119 | this.listQuery.pageIndex = val |
| 120 | this.handlePageList() |
| 121 | }, |
| 122 | createData() { |
| 123 | crudCreate(this, createSchoolyear, this.handlePageList) |
| 124 | }, |
| 125 | handleDelete(rowid) { |
| 126 | crudDelete(this, deleteSchoolyear, rowid, this.handlePageList) |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | </script> |