parkingWay-list.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div>
  3. <el-breadcrumb separator=">">
  4. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  5. <el-breadcrumb-item>
  6. <a href="#">物业管理</a>
  7. </el-breadcrumb-item>
  8. <el-breadcrumb-item>
  9. <a href="#">车位收费管理</a>
  10. </el-breadcrumb-item>
  11. <el-breadcrumb-item>
  12. <a href="/base/parkingWay">车位租赁方式管理</a>
  13. </el-breadcrumb-item>
  14. </el-breadcrumb>
  15. <el-divider></el-divider>
  16. <!--
  17. 要resetFields起作用,必须配置:model和prop
  18. -->
  19. <el-form
  20. ref="queryForm"
  21. inline
  22. class="demo-form-inline"
  23. >
  24. <el-form-item label="购买方式" prop="name">
  25. <el-input type="text" size="mini" v-model="queryModel.name"></el-input>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button
  29. type="primary"
  30. size="mini"
  31. icon="ios-search"
  32. @click="changePage(1)"
  33. :loading="loading"
  34. >查询</el-button
  35. >&nbsp;
  36. <el-button
  37. type="info"
  38. size="mini"
  39. style="margin-left: 8px"
  40. @click="handleReset('queryForm')"
  41. >重置</el-button
  42. >&nbsp;
  43. </el-form-item>
  44. </el-form>
  45. <el-divider></el-divider>
  46. <el-row class="button-group">
  47. <el-button
  48. type="primary"
  49. size="small"
  50. plain
  51. icon="el-icon-circle-plus"
  52. @click="handleAdd"
  53. >新增</el-button
  54. >
  55. <el-button
  56. type="primary"
  57. size="small"
  58. plain
  59. icon="el-icon-circle-plus"
  60. :disabled="multipleSelection.length == 0"
  61. @click="handleBatchDelete"
  62. >删除选中项</el-button
  63. >
  64. </el-row>
  65. <el-table
  66. :data="tableData"
  67. style="min-height: 400px"
  68. v-loading="loading"
  69. stripe
  70. @sort-change="sortChange"
  71. @selection-change="handleSelectionChange"
  72. >
  73. <el-table-column type="selection" width="55"></el-table-column>
  74. <el-table-column
  75. prop="name"
  76. label="购买方式"
  77. width="180"
  78. ></el-table-column>
  79. <el-table-column prop="money" label="金额" width="180"></el-table-column>
  80. <el-table-column prop="sort" label="序号" width="180"></el-table-column>
  81. <el-table-column label="操作">
  82. <template slot-scope="{ row }">
  83. <el-button size="mini" type="warning" @click="handleEdit(row)"
  84. >编辑</el-button
  85. >
  86. <el-button size="mini" type="danger" @click="handleDelete(row)"
  87. >删除</el-button
  88. >
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <el-pagination
  93. :current-page.sync="pageIndex"
  94. :total="totalElements"
  95. :page-sizes="pageSizeList"
  96. @current-change="changePage"
  97. @size-change="pageSizeChange"
  98. layout="total, sizes, prev, pager, next, jumper"
  99. ></el-pagination>
  100. <parkingWay-detail
  101. v-if="showModal"
  102. :businessKey="businessKey"
  103. :title="modalTitle"
  104. @close="onDetailModalClose"
  105. ></parkingWay-detail>
  106. </div>
  107. </template>
  108. <script>
  109. import Constant from "@/constant";
  110. import ParkingWayDetail from "./parkingWay-detail";
  111. import parkingWayApi from "@/api/base/parkingWay";
  112. import NProgress from "nprogress"; // progress bar
  113. import "nprogress/nprogress.css"; // progress bar style
  114. export default {
  115. name: 'baseParkingWayList',
  116. data() {
  117. var self = this;
  118. return {
  119. queryModel: {
  120. id: "",
  121. companyId: "",
  122. name: "",
  123. money: "",
  124. sort: "",
  125. delFlag: "",
  126. createBy: "",
  127. createTime: "",
  128. updateBy: "",
  129. updateTime: "",
  130. },
  131. loading: false,
  132. tableData: [],
  133. pageIndex: 1,
  134. pageSize: 10,
  135. totalPages: 0,
  136. totalElements: 0,
  137. field: "",
  138. direction: "",
  139. pageSizeList: [10, 20, 30],
  140. multipleSelection: [],
  141. showModal: false,
  142. modalTitle: "",
  143. businessKey: "",
  144. };
  145. },
  146. methods: {
  147. changePage(pageIndex) {
  148. var self = this;
  149. self.loading = true;
  150. self.pageIndex = pageIndex;
  151. var formData = new FormData();
  152. formData.append("pageIndex", self.pageIndex);
  153. formData.append("pageSize", self.pageSize);
  154. formData.append("name", self.queryModel.name);
  155. if (this.field != null) {
  156. formData.append("field", this.field);
  157. }
  158. if (this.direction != null) {
  159. formData.append("direction", this.direction);
  160. }
  161. parkingWayApi
  162. .pageList(formData)
  163. .then(function (response) {
  164. self.loading = false;
  165. var jsonData = response.data.data;
  166. self.tableData = jsonData.data;
  167. self.totalPages = jsonData.totalPages;
  168. self.totalElements = jsonData.recordsTotal;
  169. })
  170. .catch((error) => {
  171. self.loading = false;
  172. // self.$message.error(error + "");
  173. });
  174. },
  175. pageSizeChange(pageSize) {
  176. this.pageSize = pageSize;
  177. this.$nextTick(() => {
  178. this.changePage(this.pageIndex);
  179. });
  180. },
  181. sortChange(data) {
  182. this.field = data.column.field;
  183. this.direction = data.order == "ascending" ? "asc" : "desc";
  184. this.changePage(this.pageIndex);
  185. },
  186. handleSelectionChange(val) {
  187. this.multipleSelection = val;
  188. },
  189. handleReset(name) {
  190. this.$refs[name].resetFields();
  191. },
  192. handleAdd() {
  193. this.modalTitle = "新增";
  194. this.businessKey = "";
  195. this.showModal = true;
  196. },
  197. handleEdit(record) {
  198. this.modalTitle = "编辑";
  199. this.businessKey = record.id;
  200. this.showModal = true;
  201. },
  202. handleDelete(record) {
  203. var self = this;
  204. self
  205. .$confirm("是否确认删除?", "提示", {
  206. confirmButtonText: "确定",
  207. cancelButtonText: "取消",
  208. type: "warning",
  209. })
  210. .then(() => {
  211. parkingWayApi.remove(record.id).then(function (response) {
  212. var jsonData = response.data;
  213. if (jsonData.result) {
  214. // var index = self.tableData.indexOf(record);
  215. // self.tableData.splice(index, 1);
  216. self.changePage(self.pageIndex);
  217. self.$message({
  218. type: "success",
  219. message: "删除成功!",
  220. });
  221. }
  222. });
  223. });
  224. },
  225. handleBatchDelete() {
  226. var self = this;
  227. var idList = this.multipleSelection.map((record) => {
  228. return record.id;
  229. });
  230. this.$confirm("是否确认删除选中项?", "提示", {
  231. confirmButtonText: "确定",
  232. cancelButtonText: "取消",
  233. type: "warning",
  234. }).then(() => {
  235. parkingWayApi.batchRemove(idList).then(function (response) {
  236. var jsonData = response.data;
  237. if (jsonData.result) {
  238. self.changePage(self.pageIndex);
  239. self.$message({
  240. type: "success",
  241. message: "删除成功!",
  242. });
  243. }
  244. });
  245. });
  246. },
  247. onDetailModalClose(refreshed) {
  248. //保存成功后回调
  249. this.showModal = false;
  250. if (refreshed) {
  251. this.changePage(this.pageIndex);
  252. }
  253. },
  254. },
  255. mounted: function () {
  256. this.changePage(1);
  257. },
  258. components: {
  259. "parkingWay-detail": ParkingWayDetail,
  260. },
  261. };
  262. </script>
  263. <style lang="scss" scoped>
  264. .el-breadcrumb {
  265. margin: 10px;
  266. line-height: 20px;
  267. }
  268. .el-divider {
  269. margin: 5px 0;
  270. }
  271. .demo-form-inline {
  272. margin-left: 10px;
  273. text-align: left;
  274. }
  275. .button-group {
  276. margin-left: 10px;
  277. text-align: left;
  278. }
  279. </style>