companyInfo-list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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="/companyInfo">企业管理</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-circle-plus"
  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="sortNo" label="序号" width="80"></el-table-column>
  58. <el-table-column prop="logo" label="公司logo" width="120">
  59. <template slot-scope="{row}">
  60. <a :href="row.logo" target="_blank">
  61. <el-avatar
  62. :size="48"
  63. :src="row.logo+'?x-oss-process=image/resize,m_lfit,h_100,w_100'"
  64. :key="row.id"
  65. ></el-avatar>
  66. </a>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="name" label="公司名称" width="180"></el-table-column>
  70. <!-- <el-table-column prop="position1Name" label="一级位置" width="180"></el-table-column>
  71. <el-table-column prop="position2Name" label="二级位置" width="180"></el-table-column>
  72. <el-table-column prop="position3Name" label="三级位置" width="180"></el-table-column>
  73. <el-table-column prop="position4Name" label="四级位置" width="180"></el-table-column>
  74. <el-table-column prop="position5Name" label="五级位置" width="180"></el-table-column> -->
  75. <el-table-column prop="remark" sort-by="remark_" label="备注"></el-table-column>
  76. <el-table-column label="操作" width="150" fixed="right">
  77. <template slot-scope="{row}">
  78. <el-button size="mini" type="warning" @click="handleEdit(row)">编辑</el-button>
  79. <el-button size="mini" type="danger" @click="handleDelete(row)">删除</el-button>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <el-pagination
  84. :current-page.sync="pageIndex"
  85. :total="totalElements"
  86. :page-sizes="pageSizeList"
  87. @current-change="changePage"
  88. @size-change="pageSizeChange"
  89. layout="total, sizes, prev, pager, next, jumper"
  90. ></el-pagination>
  91. <companyInfo-detail
  92. v-if="showModal"
  93. :businessKey="businessKey"
  94. :title="modalTitle"
  95. @close="onDetailModalClose"
  96. ></companyInfo-detail>
  97. </div>
  98. </template>
  99. <script>
  100. import Constant from "@/constant";
  101. import companyInfoDetail from "./companyInfo-detail";
  102. import companyInfoApi from "@/api/base/companyInfo";
  103. import NProgress from "nprogress"; // progress bar
  104. import "nprogress/nprogress.css"; // progress bar style
  105. export default {
  106. data() {
  107. var self = this;
  108. return {
  109. queryModel: {
  110. name: ""
  111. },
  112. loading: false,
  113. tableData: [],
  114. pageIndex: 1,
  115. pageSize: 10,
  116. totalPages: 0,
  117. totalElements: 0,
  118. field: "",
  119. direction: "",
  120. pageSizeList: [10, 20, 30],
  121. multipleSelection: [],
  122. showModal: false,
  123. modalTitle: "",
  124. businessKey: ""
  125. };
  126. },
  127. methods: {
  128. changePage(pageIndex) {
  129. var self = this;
  130. self.loading = true;
  131. self.pageIndex = pageIndex;
  132. var formData = new FormData();
  133. formData.append("pageIndex", self.pageIndex);
  134. formData.append("pageSize", self.pageSize);
  135. formData.append("name", self.queryModel.name);
  136. if (this.field != null) {
  137. formData.append("field", this.field);
  138. }
  139. if (this.direction != null) {
  140. formData.append("direction", this.direction);
  141. }
  142. companyInfoApi
  143. .pageList(formData)
  144. .then(function(response) {
  145. self.loading = false;
  146. var jsonData = response.data.data;
  147. self.tableData = jsonData.data;
  148. self.totalPages = jsonData.totalPages;
  149. self.totalElements = jsonData.recordsTotal;
  150. })
  151. .catch(error => {
  152. self.loading = false;
  153. // self.$message.error(error + "");
  154. });
  155. },
  156. pageSizeChange(pageSize) {
  157. this.pageSize = pageSize;
  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. companyInfoApi.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. companyInfoApi.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. "companyInfo-detail": companyInfoDetail
  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>