ll
liukangdong
2024-11-20 8e753cc7eaf0e261612f0137504684b65f099342
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
  <GlobalWindow title="楼层管理" :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="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"
            v-permissions="['business:ywbuilding:update']">编辑</el-button>
          <el-button type="text" @click="deleteById(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" />
    </div>
 
    <!--  -->
    <el-dialog :title="title" :visible.sync="showModal" :append-to-body="true" width="500px">
      <el-form :model="param" ref="form" :rules="rules">
        <el-form-item label="楼层编码" prop="code">
          <el-input v-model="param.code" placeholder="请输入楼层编码" v-trim />
        </el-form-item>
        <el-form-item label="楼层名称" prop="name">
          <el-input v-model="param.name" placeholder="请输入楼层名称" v-trim />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showModal = false">取 消</el-button>
        <el-button type="primary" @click="showModal = false">确 定</el-button>
      </span>
    </el-dialog>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { fetchList, detailById, deleteById, create } from '@/api/project/yeFloor'
import Pagination from '@/components/common/Pagination'
export default {
  extends: BaseOpera,
  components: { GlobalWindow, Pagination },
  data() {
    return {
      // 表单数据
      info: {},
      id: '',
      visible: false,
      showModal: false,
      list: [],
      pagination: {
        pageSize: 10,
        page: 1,
        total: 0
      },
 
      title: '新建楼层',
      param: {},
      rules: {
        name: [{ required: true, message: '请输入楼层名称' }],
        area: [{ required: true, message: '请输入楼层编码' }],
      },
    }
  },
  created() {
  },
  methods: {
    getList(buildingId) {
      const { pagination } = this
      let capacity = pagination.pageSize
      let page = pagination.page
      fetchList({ capacity, page, model: { buildingId } }).then(res => {
        this.list = res
      })
    },
    editClick(row) {
      if(row && row.id){
        this.title = '编辑楼层'
      }else{
        this.title = '新建楼层'
      }
      this.showModal = true
 
    },
    handleSizeChange(capacity) {
      this.pagination.pageSize = capacity
    }
  }
}
</script>
<style lang="scss" scoped>
.head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
 
  .title {
    font-size: 16px;
    font-weight: 500;
  }
}
</style>