| <template> |
| <div class="app-container"> |
| <el-col :span="12"> |
| <el-card> |
| <div class="filter-container"> |
| <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="类型名称/编码" v-model="listQuery.name"> |
| </el-input> |
| <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查询</el-button> |
| <el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate(null, 'create')" type="primary" icon="el-icon-edit">添加</el-button> |
| </div> |
| <el-table :height="height" :data="items" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row> |
| <el-table-column label="类型编码" align="center"> |
| <template slot-scope="scope"> |
| {{scope.row.code}} |
| </template> |
| </el-table-column> |
| <el-table-column label="类型名称" align="center"> |
| <template slot-scope="scope"> |
| <span>{{scope.row.name}}</span> |
| </template> |
| </el-table-column> |
| <el-table-column |
| header-align="center" |
| align="center" |
| width="150" |
| label="操作"> |
| <template slot-scope="scope"> |
| <el-button type="text" size="small" @click="handleCreate(scope.row.id, 'update')">修改</el-button> |
| <el-button type="text" size="small" @click="handleView(scope.row.code)">查看</el-button> |
| <el-button type="text" size="small" @click="handleDelete(scope.row.id)">删除</el-button> |
| </template> |
| </el-table-column> |
| </el-table> |
| <div class="pagination-container"> |
| <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.pageIndex" |
| :page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="recordCount"> |
| </el-pagination> |
| </div> |
| |
| <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible"> |
| <el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="150px" style='width: 400px; margin-left:50px;'> |
| <el-form-item label="类型编码" prop="code"> |
| <el-input v-model="temp.code"></el-input> |
| <input type="hidden" v-model="temp.id" /> |
| </el-form-item> |
| <el-form-item label="类型名称" prop="name"> |
| <el-input v-model="temp.name"></el-input> |
| </el-form-item> |
| </el-form> |
| <div slot="footer" class="dialog-footer"> |
| <el-button @click="dialogFormVisible = false">返回</el-button> |
| <el-button type="primary" @click="createData">提交</el-button> |
| </div> |
| </el-dialog> |
| </el-card> |
| </el-col> |
| <el-col :span="12"> |
| <el-card> |
| <div class="filter-container"> |
| <el-button class="filter-item" style="margin-left: 10px;" @click="handleCreateDic(null, 'create')" type="primary" icon="el-icon-edit">添加</el-button> |
| </div> |
| <el-table :height="itemHeight" :data="dicList" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row> |
| <el-table-column label="字典编码" align="center"> |
| <template slot-scope="scope"> |
| {{scope.row.code}} |
| </template> |
| </el-table-column> |
| <el-table-column label="字典名称" align="center"> |
| <template slot-scope="scope"> |
| <span>{{scope.row.name}}</span> |
| </template> |
| </el-table-column> |
| <el-table-column |
| header-align="center" |
| align="center" |
| width="150" |
| label="操作"> |
| <template slot-scope="scope"> |
| <el-button type="text" size="small" @click="handleCreateDic(scope.row.id, 'update')">修改</el-button> |
| <el-button type="text" size="small" @click="handleDeleteDic(scope.row.id)">删除</el-button> |
| </template> |
| </el-table-column> |
| </el-table> |
| |
| <el-dialog :title="textMap[dialogStatus]" :visible.sync="dicDialogFormVisible"> |
| <el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="150px" style='width: 400px; margin-left:50px;'> |
| <el-form-item label="字典编码" prop="code"> |
| <el-input v-model="temp.code"></el-input> |
| <input type="hidden" v-model="temp.id" /> |
| </el-form-item> |
| <el-form-item label="字典名称" prop="name"> |
| <el-input v-model="temp.name"></el-input> |
| </el-form-item> |
| </el-form> |
| <div slot="footer" class="dialog-footer"> |
| <el-button @click="dicDialogFormVisible = false">返回</el-button> |
| <el-button type="primary" @click="createDataDic">提交</el-button> |
| </div> |
| </el-dialog> |
| </el-card> |
| </el-col> |
| </div> |
| </template> |
| |
| <script> |
| import { getPage, getType, getDicList, createType, deleteType, getDic, createDic, deleteDic } from '@/api/dictionary-api' |
| import waves from '@/directive/waves' // 水波纹指令 |
| import { MessageBox } from 'element-ui' |
| import { resetForm } from '@/utils' |
| import { crudPageList, crudGetItem, crudCreate, crudDelete } from '@/utils/crud' |
| import mixindata from '@/utils/crud' |
| |
| const initData = { sex: 'male', zt: 'on' } |
| export default { |
| name: 'type', |
| directives: { |
| waves |
| }, |
| mixins: [mixindata], |
| data() { |
| return { |
| dicDialogFormVisible: false, |
| dicDialogVisible: false, |
| dicList: [], |
| itemHeight: 500, |
| rules: { |
| ghxh: [{ required: true, message: '账号(工号/学号)必填', trigger: 'blur' }], |
| mm: [{ required: true, message: '密码必填', trigger: 'blur' }], |
| zhlb: [{ required: true, message: '账户类别必填', trigger: 'change' }], |
| xm: [{ required: true, message: '姓名必填', trigger: 'change' }] |
| } |
| } |
| }, |
| filters: { |
| statusFilter(status) { |
| const statusMap = { |
| '1': 'success', |
| '0': 'danger' |
| } |
| return statusMap[status] |
| } |
| }, |
| created() { |
| this.handlePageList() |
| this.height = window.innerHeight - 256 |
| this.itemHeight = window.innerHeight - 223 |
| }, |
| methods: { |
| handlePageList() { |
| crudPageList(this, getPage) |
| }, |
| handleCreate(rowid, dialogStatus) { |
| this.dialogStatus = dialogStatus |
| crudGetItem(this, getType, rowid, initData) |
| }, |
| handleReset() { |
| resetForm(this.listQuery) |
| }, |
| handleFilter() { |
| this.listQuery.pageIndex = 1 |
| this.handlePageList() |
| }, |
| handleSizeChange(val) { |
| this.listQuery.pageSize = val |
| this.handlePageList() |
| }, |
| handleCurrentChange(val) { |
| this.listQuery.pageIndex = val |
| this.handlePageList() |
| }, |
| createData() { |
| crudCreate(this, createType, this.handlePageList) |
| }, |
| handleDelete(rowid) { |
| crudDelete(this, deleteType, rowid, this.handlePageList) |
| }, |
| handleView(type) { |
| this.temp.type = type |
| getDicList({ dicType: type }).then(response => { |
| if (!response.items) { |
| MessageBox.alert('数据不存在,请确认是否已删除。', '消息', { |
| confirmButtonText: '确定' |
| }) |
| return |
| } |
| this.dicDialogVisible = true |
| this.dicList = response.items |
| }) |
| }, |
| handleCreateDic(rowid, dialogStatus) { |
| if (!this.temp.type) { |
| MessageBox.alert('请先选择字典类型!', '消息', { |
| confirmButtonText: '确定' |
| }) |
| return |
| } |
| this.dialogStatus = dialogStatus |
| const that = this |
| crudGetItem(this, getDic, rowid, { type: this.temp.type }, function() { |
| that.dicDialogFormVisible = true |
| that.dialogFormVisible = false |
| }) |
| }, |
| createDataDic() { |
| const that = this |
| crudCreate(this, createDic, function() { |
| that.handleView(that.temp.type) |
| that.dicDialogFormVisible = false |
| }) |
| }, |
| handleDeleteDic(rowid) { |
| const that = this |
| crudDelete(this, deleteDic, rowid, function() { |
| that.handleView(that.temp.type) |
| }) |
| } |
| } |
| } |
| </script> |
| <style scoped> |
| .el-card { |
| margin: 5px; |
| } |
| </style> |