| | |
| | | <template> |
| | | <GlobalWindow title="楼层管理" :showConfirm="false" :visible.sync="visible" width="800px"> |
| | | <GlobalWindow title="楼层管理" @close="close" :showConfirm="false" :visible.sync="visible" width="800px"> |
| | | <div class="head"> |
| | | <div class="title">楼层列表</div> |
| | | <el-button type="primary" @click="editClick()">新建楼层</el-button> |
| | | </div> |
| | | <el-table :data="list" stripe> |
| | | <el-table-column prop="id" label="楼层编码" min-width="100px"></el-table-column> |
| | | <el-table-column prop="code" label="楼层编码" min-width="100px"></el-table-column> |
| | | <el-table-column prop="name" label="楼层名称" min-width="100px"></el-table-column> |
| | | <el-table-column label="操作" min-width="100px"> |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="$refs.operaYwBuildingWindow.open('编辑楼宇', row)" icon="el-icon-edit" |
| | | <el-button type="text" @click="editClick(row)" icon="el-icon-edit" |
| | | v-permissions="['business:ywbuilding:update']">编辑</el-button> |
| | | <el-button type="text" @click="deleteById(row)" icon="el-icon-delete" |
| | | <el-button type="text" @click="handleDel(row)" icon="el-icon-delete" |
| | | v-permissions="['business:ywbuilding:delete']">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="projectName" label="所属项目" min-width="100px"></el-table-column> |
| | | </el-table> |
| | | <div class="mt20"> |
| | | <Pagination @size-change="handleSizeChange" @current-change="getList" :pagination="pagination" /> |
| | |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="showModal = false">取 消</el-button> |
| | | <el-button type="primary" @click="showModal = false">确 定</el-button> |
| | | <el-button type="primary" :loading="subLoading" @click="onSubmit">确 定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </GlobalWindow> |
| | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { fetchList, detailById, deleteById, create } from '@/api/project/yeFloor' |
| | | import { fetchList, detailById, deleteById, create, updateById } from '@/api/project/yeFloor' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import { Message } from 'element-ui' |
| | | export default { |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow, Pagination }, |
| | |
| | | id: '', |
| | | visible: false, |
| | | showModal: false, |
| | | subLoading: false, |
| | | list: [], |
| | | pagination: { |
| | | pageSize: 10, |
| | |
| | | param: {}, |
| | | rules: { |
| | | name: [{ required: true, message: '请输入楼层名称' }], |
| | | area: [{ required: true, message: '请输入楼层编码' }], |
| | | code: [{ required: true, message: '请输入楼层编码' }], |
| | | }, |
| | | } |
| | | }, |
| | | created() { |
| | | }, |
| | | methods: { |
| | | onSubmit() { |
| | | this.$refs['form'].validate((valid) => { |
| | | if (valid) { |
| | | const { param, id } = this |
| | | this.subLoading = true |
| | | let fn = param.id ? updateById : create |
| | | fn({ ...param, buildingId: id }).then(res => { |
| | | this.showModal = false |
| | | this.subLoading = false |
| | | Message.success('提交成功') |
| | | this.getList() |
| | | }, () => { |
| | | this.subLoading = false |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | getList(buildingId) { |
| | | const { pagination } = this |
| | | const { pagination, id } = this |
| | | // this.buildingId = |
| | | let capacity = pagination.pageSize |
| | | let page = pagination.page |
| | | fetchList({ capacity, page, model: { buildingId } }).then(res => { |
| | | this.list = res |
| | | fetchList({ capacity, page, model: { buildingId: id } }).then(res => { |
| | | this.list = res.records |
| | | this.pagination.total = res.total |
| | | }) |
| | | }, |
| | | editClick(row) { |
| | | if(row && row.id){ |
| | | if (row && row.id) { |
| | | this.title = '编辑楼层' |
| | | }else{ |
| | | this.param = { ...row } |
| | | } else { |
| | | this.title = '新建楼层' |
| | | this.param = {} |
| | | } |
| | | this.showModal = true |
| | | |
| | | }, |
| | | handleDel(row) { |
| | | this.$confirm('确定删除该楼层, 是否继续?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | deleteById(row.id).then(res => { |
| | | Message.success('删除成功') |
| | | this.getList() |
| | | }) |
| | | }) |
| | | }, |
| | | close() { |
| | | this.$emit('success') |
| | | }, |
| | | handleSizeChange(capacity) { |
| | | this.pagination.pageSize = capacity |