holidayInfo-list.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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="/messageNotice">节假日设置</a>
  10. </el-breadcrumb-item>
  11. </el-breadcrumb>
  12. <el-divider></el-divider>
  13. <!--
  14. 要resetFields起作用,必须配置:model和prop
  15. -->
  16. <el-divider></el-divider>
  17. <el-row class="button-group">
  18. <el-button type="primary" size="small" plain icon="el-icon-circle-plus" @click="handleAdd">新增</el-button>
  19. <el-button
  20. type="primary"
  21. size="small"
  22. plain
  23. icon="el-icon-remove"
  24. :disabled="multipleSelection.length==0"
  25. @click="handleBatchDelete"
  26. >删除选中项</el-button>
  27. </el-row>
  28. <el-table
  29. ref="formTable"
  30. :data="tableData"
  31. v-loading="loading"
  32. stripe
  33. @sort-change="sortChange"
  34. @selection-change="handleSelectionChange"
  35. >
  36. <el-table-column type="selection" width="55"></el-table-column>
  37. <el-table-column prop="holidayName" label="节假日名称" width="220" fixed="left"></el-table-column>
  38. <el-table-column prop="beginDate" label="开始日期" show-overflow-tooltip width="150"></el-table-column>
  39. <el-table-column prop="endDate" label="结束日期" width="150"></el-table-column>
  40. <el-table-column prop="working" label="是否需要上班" width="120">
  41. <template slot-scope="{row}">
  42. <span v-html="row.working ? '是': '否'"></span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="refWeekday" label="参考上班日" width="120"></el-table-column>
  46. <el-table-column label="操作" width="200" fixed="right">
  47. <template slot-scope="{row}">
  48. <el-button size="mini" type="warning" @click="handleEdit(row)">修改</el-button>
  49. <el-button size="mini" type="danger" @click="handleDelete(row)">删除</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <el-pagination
  54. :current-page.sync="pageIndex"
  55. :total="totalElements"
  56. :page-sizes="pageSizeList"
  57. @current-change="changePage"
  58. @size-change="pageSizeChange"
  59. layout="total, sizes, prev, pager, next, jumper"
  60. ></el-pagination>
  61. <holidayInfo-detail
  62. v-if="showModal"
  63. :businessKey="businessKey"
  64. :title="modalTitle"
  65. :companyResult="companyResult"
  66. @close="onDetailModalClose"
  67. ></holidayInfo-detail>
  68. </div>
  69. </template>
  70. <script>
  71. import Constant from "@/constant";
  72. import holidayInfoDetail from "./holidayInfo-detail";
  73. import holidayInfoApi from "@/api/base/holidayInfo";
  74. import companyInfoApi from "@/api/base/companyInfo";
  75. import NProgress from "nprogress"; // progress bar
  76. import "nprogress/nprogress.css"; // progress bar style
  77. export default {
  78. name: "BaseHolidayInfoList",
  79. data() {
  80. var self = this;
  81. return {
  82. loading: false,
  83. tableData: [],
  84. pageIndex: 1,
  85. pageSize: 10,
  86. totalPages: 0,
  87. totalElements: 0,
  88. field: "",
  89. direction: "",
  90. pageSizeList: [10, 20, 30],
  91. multipleSelection: [],
  92. showModal: false,
  93. modalTitle: "",
  94. businessKey: ""
  95. };
  96. },
  97. methods: {
  98. changePage(pageIndex) {
  99. var self = this;
  100. self.loading = true;
  101. self.pageIndex = pageIndex;
  102. var formData = new FormData();
  103. formData.append("pageIndex", self.pageIndex);
  104. formData.append("pageSize", self.pageSize);
  105. if (this.field != null) {
  106. formData.append("field", this.field);
  107. }
  108. if (this.direction != null) {
  109. formData.append("direction", this.direction);
  110. }
  111. holidayInfoApi
  112. .pageList(formData)
  113. .then(function(response) {
  114. self.loading = false;
  115. var jsonData = response.data.data;
  116. self.tableData = jsonData.data;
  117. self.totalPages = jsonData.totalPages;
  118. self.totalElements = jsonData.recordsTotal;
  119. //45为分页栏的高度
  120. //页面高度-列表上面的高度-分页栏高度
  121. self.tableHeight =
  122. window.innerHeight - self.$refs.formTable.$el.offsetTop - 45;
  123. })
  124. .catch(error => {
  125. self.loading = false;
  126. // self.$message.error(error + "");
  127. });
  128. },
  129. pageSizeChange(pageSize) {
  130. this.pageSize = pageSize;
  131. },
  132. sortChange(data) {
  133. this.field = data.column.field;
  134. this.direction = data.order;
  135. this.changePage(this.pageIndex);
  136. },
  137. handleSelectionChange(val) {
  138. this.multipleSelection = val;
  139. },
  140. handleReset(name) {
  141. this.$refs[name].resetFields();
  142. },
  143. handleAdd() {
  144. this.modalTitle = "新增";
  145. this.businessKey = "";
  146. this.showModal = true;
  147. },
  148. handleEdit(record) {
  149. this.modalTitle = "编辑";
  150. this.businessKey = record.id;
  151. this.showModal = true;
  152. },
  153. handleDelete(record) {
  154. var self = this;
  155. self
  156. .$confirm("是否确认删除?", "提示", {
  157. confirmButtonText: "确定",
  158. cancelButtonText: "取消",
  159. type: "warning"
  160. })
  161. .then(() => {
  162. holidayInfoApi.remove(record.id).then(function(response) {
  163. var jsonData = response.data;
  164. if (jsonData.result) {
  165. // var index = self.tableData.indexOf(record);
  166. // self.tableData.splice(index, 1);
  167. self.changePage(self.pageIndex);
  168. self.$message({
  169. type: "success",
  170. message: "删除成功!"
  171. });
  172. }
  173. });
  174. });
  175. },
  176. handleBatchDelete() {
  177. var self = this;
  178. var idList = this.multipleSelection.map(record => {
  179. return record.id;
  180. });
  181. this.$confirm("是否确认删除选中项?", "提示", {
  182. confirmButtonText: "确定",
  183. cancelButtonText: "取消",
  184. type: "warning"
  185. }).then(() => {
  186. holidayInfoApi.batchRemove(idList).then(function(response) {
  187. var jsonData = response.data;
  188. if (jsonData.result) {
  189. self.changePage(self.pageIndex);
  190. self.$message({
  191. type: "success",
  192. message: "删除成功!"
  193. });
  194. }
  195. });
  196. });
  197. },
  198. onDetailModalClose(refreshed) {
  199. //保存成功后回调
  200. this.showModal = false;
  201. if (refreshed) {
  202. this.changePage(this.pageIndex);
  203. }
  204. }
  205. },
  206. mounted: function() {
  207. var self = this;
  208. this.changePage(1);
  209. companyInfoApi.list().then(function(response) {
  210. var jsonData = response.data;
  211. if (jsonData.result) {
  212. self.companyResult = jsonData.data;
  213. }
  214. });
  215. },
  216. components: {
  217. "holidayInfo-detail": holidayInfoDetail
  218. }
  219. };
  220. </script>
  221. <style lang="scss" scoped>
  222. .el-breadcrumb {
  223. margin: 10px;
  224. line-height: 20px;
  225. }
  226. .el-divider {
  227. margin: 5px 0;
  228. }
  229. .demo-form-inline {
  230. margin-left: 10px;
  231. text-align: left;
  232. }
  233. .button-group {
  234. margin-left: 10px;
  235. text-align: left;
  236. }
  237. </style>