terminalInfo-list.vue 7.4 KB

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