index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
  4. <el-form-item label="楼层名称:" prop="name">
  5. <el-input
  6. v-model.trim="queryParams.name"
  7. placeholder="请输入建筑名称"
  8. clearable
  9. size="small"
  10. style="width: 240px"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  16. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  17. <el-button
  18. type="primary"
  19. plain
  20. icon="el-icon-plus"
  21. size="mini"
  22. @click="handleAdd"
  23. v-hasPermi="['system:admin:add']"
  24. >新增</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-table v-loading="loading" :data="adminList" height="calc(100vh - 28vh)">
  28. <el-table-column label="楼层名称" align="center" prop="floorName" show-overflow-tooltip />
  29. <el-table-column label="建筑名称" align="center" prop="buildName" show-overflow-tooltip />
  30. <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
  31. <el-table-column label="创建人" align="center" prop="creatMan" show-overflow-tooltip />
  32. <el-table-column label="创建时间" align="center" prop="creatTime" show-overflow-tooltip />
  33. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
  34. <template slot-scope="scope">
  35. <el-button
  36. size="mini"
  37. type="text"
  38. icon="el-icon-edit"
  39. @click="handleUpdate(scope.row)"
  40. v-hasPermi="['system:admin:edit']"
  41. >修改</el-button>
  42. <el-button
  43. size="mini"
  44. type="text"
  45. icon="el-icon-delete"
  46. @click="handleDelete(scope.row)"
  47. v-hasPermi="['system:admin:remove']"
  48. >删除</el-button>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <!-- 修改、新增对话框 -->
  53. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body :before-close="cancel" :close-on-click-modal="false">
  54. <el-form ref="form" :model="form" :rules="rules" label-width="auto" >
  55. <el-row :gutter="20">
  56. <el-col :span="12" >
  57. <el-form-item label="楼层名称" prop="floorName">
  58. <el-input v-model="form.floorName" placeholder="请填写楼层名称" @input="onInput()" maxlength="15" show-word-limit />
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="12">
  62. <el-form-item label="建筑名称" prop="buildId">
  63. <el-select
  64. v-model="form.buildId"
  65. placeholder="请选择建筑名称"
  66. clearable
  67. size="small"
  68. >
  69. <el-option
  70. v-for="(dict,index) in buildListData"
  71. :key="index"
  72. :label="dict.name"
  73. :value="dict.id"
  74. />
  75. </el-select>
  76. </el-form-item>
  77. </el-col>
  78. </el-row>
  79. <el-row :gutter="20">
  80. <el-col :span="12">
  81. <el-form-item label="备注" prop="remark">
  82. <el-input type="textarea" v-model.trim="form.remark" placeholder="请填写备注" @input="onInput()" rows="4" maxlength="25" show-word-limit/>
  83. </el-form-item>
  84. </el-col>
  85. </el-row>
  86. </el-form>
  87. <div slot="footer" class="dialog-footer">
  88. <el-button type="primary" @click="submitForm">确 定</el-button>
  89. <el-button @click="cancel">取 消</el-button>
  90. </div>
  91. </el-dialog>
  92. <pagination
  93. v-show="total>0"
  94. :total="total"
  95. :page.sync="queryParams.current"
  96. :limit.sync="queryParams.size"
  97. @pagination="getList"
  98. />
  99. </div>
  100. </template>
  101. <script>
  102. import { getBuilding, addFloor, delFloor, updateFloor, getFloor } from "@/api/business/buildMange";
  103. export default {
  104. name: "Floor",
  105. data() {
  106. return {
  107. exportLoading:false,
  108. // 显示搜索条件
  109. showSearch: true,
  110. // 总条数
  111. total: 0,
  112. // 参数表格数据
  113. adminList: [],
  114. // 弹出层标题
  115. title: "",
  116. // 是否显示弹出层
  117. open: false,
  118. // 查询参数
  119. queryParams: {
  120. current: 1,
  121. size: 20,
  122. name: undefined,
  123. },
  124. // 表单参数
  125. form: {},
  126. // 表单校验
  127. rules: {
  128. buildName: [
  129. { required: true, message: "建筑名称不能为空", trigger: ["blur",'change'] }
  130. ],
  131. floorName: [
  132. { required: true, message: "楼层名称不能为空", trigger: "blur" }
  133. ],
  134. },
  135. //建筑下拉
  136. buildListData:[],
  137. };
  138. },
  139. created() {
  140. this.getList();//初始化table
  141. this.buildList()//初始化建筑下拉
  142. },
  143. methods: {
  144. //强制el-input刷新
  145. onInput(){
  146. this.$forceUpdate();
  147. },
  148. // 取消按钮
  149. cancel() {
  150. this.open = false;
  151. this.reset();
  152. },
  153. /** 重置按钮操作 */
  154. resetQuery() {
  155. this.dateRange = [];
  156. this.queryParams = {
  157. name:undefined,
  158. current:1,
  159. size:20
  160. }
  161. this.resetForm("queryForm");
  162. this.handleQuery();
  163. },
  164. // 表单重置
  165. reset() {
  166. this.form = {};
  167. this.resetForm("form");
  168. },
  169. /** 搜索按钮操作 */
  170. handleQuery() {
  171. this.queryParams.current = 1;
  172. this.getList();
  173. },
  174. /** 查询参数列表 */
  175. getList() {
  176. this.loading = true;
  177. getFloor(this.queryParams).then(response => {
  178. this.adminList = response.data.records;
  179. this.total = response.data.total;
  180. this.loading = false;
  181. });
  182. },
  183. /** 修改按钮操作 */
  184. handleUpdate(row) {
  185. this.reset();
  186. this.title = "修改";
  187. this.form = row
  188. this.form.buildId = Number(this.form.buildId)
  189. this.open = true;
  190. },
  191. /** 新增按钮操作 */
  192. handleAdd() {
  193. this.reset();
  194. this.open = true;
  195. this.title = "新增";
  196. },
  197. /** 提交按钮 */
  198. submitForm(row) {
  199. this.$refs["form"].validate(valid => {
  200. if (valid) {
  201. this.loading = true
  202. if (this.form.id != undefined) {
  203. updateFloor(this.form).then(response => {
  204. this.loading = false,
  205. this.msgSuccess("修改成功");
  206. this.open = false;
  207. this.getList();
  208. }).catch(()=>{
  209. this.loading = false
  210. })
  211. } else {
  212. addFloor(this.form).then(response => {
  213. this.loading = false,
  214. this.msgSuccess("新增成功");
  215. this.open = false;
  216. this.getList();
  217. }).catch(()=>{
  218. this.loading = false
  219. })
  220. }
  221. }
  222. });
  223. },
  224. /** 删除按钮操作 */
  225. handleDelete(row) {
  226. const ids = row.id || this.ids;
  227. this.$confirm('是否确认删除', "警告", {
  228. confirmButtonText: "确定",
  229. cancelButtonText: "取消",
  230. type: "warning"
  231. }).then(function() {
  232. return delFloor(ids);
  233. }).then(() => {
  234. this.getList();
  235. this.msgSuccess("删除成功");
  236. }).catch(() => {});
  237. },
  238. /* 建筑列表 */
  239. buildList(){
  240. getBuilding(this.queryParams).then(response => {
  241. this.buildListData = (response.data).records.map(val =>{
  242. return {
  243. id:val.id,
  244. name:val.buildName
  245. }
  246. })
  247. });
  248. },
  249. }
  250. };
  251. </script>