From 3a1a4f95f3d07f669139ab1158d1e304be6d6a26 Mon Sep 17 00:00:00 2001 From: liukangdong <898885815@qq.com> Date: 星期六, 23 十一月 2024 17:32:50 +0800 Subject: [PATCH] ll --- admin/src/views/project/components/floorLevel.vue | 63 ++++++++++++++++++++++++------- 1 files changed, 49 insertions(+), 14 deletions(-) diff --git a/admin/src/views/project/components/floorLevel.vue b/admin/src/views/project/components/floorLevel.vue index 4e5d94c..edc027b 100644 --- a/admin/src/views/project/components/floorLevel.vue +++ b/admin/src/views/project/components/floorLevel.vue @@ -1,21 +1,20 @@ <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" /> @@ -33,7 +32,7 @@ </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> @@ -42,8 +41,9 @@ <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 }, @@ -54,6 +54,7 @@ id: '', visible: false, showModal: false, + subLoading: false, list: [], pagination: { pageSize: 10, @@ -65,29 +66,63 @@ 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 }) }, 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 -- Gitblit v1.9.3