holidayInfo-list.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. data() {
  79. var self = this;
  80. return {
  81. loading: false,
  82. tableData: [],
  83. pageIndex: 1,
  84. pageSize: 10,
  85. totalPages: 0,
  86. totalElements: 0,
  87. field: "",
  88. direction: "",
  89. pageSizeList: [10, 20, 30],
  90. multipleSelection: [],
  91. showModal: false,
  92. modalTitle: "",
  93. businessKey: ""
  94. };
  95. },
  96. methods: {
  97. changePage(pageIndex) {
  98. var self = this;
  99. self.loading = true;
  100. self.pageIndex = pageIndex;
  101. var formData = new FormData();
  102. formData.append("pageIndex", self.pageIndex);
  103. formData.append("pageSize", self.pageSize);
  104. if (this.field != null) {
  105. formData.append("field", this.field);
  106. }
  107. if (this.direction != null) {
  108. formData.append("direction", this.direction);
  109. }
  110. holidayInfoApi
  111. .pageList(formData)
  112. .then(function(response) {
  113. self.loading = false;
  114. var jsonData = response.data.data;
  115. self.tableData = jsonData.data;
  116. self.totalPages = jsonData.totalPages;
  117. self.totalElements = jsonData.recordsTotal;
  118. //45为分页栏的高度
  119. //页面高度-列表上面的高度-分页栏高度
  120. self.tableHeight =
  121. window.innerHeight - self.$refs.formTable.$el.offsetTop - 45;
  122. })
  123. .catch(error => {
  124. self.loading = false;
  125. // self.$message.error(error + "");
  126. });
  127. },
  128. pageSizeChange(pageSize) {
  129. this.pageSize = pageSize;
  130. },
  131. sortChange(data) {
  132. this.field = data.column.field;
  133. this.direction = data.order;
  134. this.changePage(this.pageIndex);
  135. },
  136. handleSelectionChange(val) {
  137. this.multipleSelection = val;
  138. },
  139. handleReset(name) {
  140. this.$refs[name].resetFields();
  141. },
  142. handleAdd() {
  143. this.modalTitle = "新增";
  144. this.businessKey = "";
  145. this.showModal = true;
  146. },
  147. handleEdit(record) {
  148. this.modalTitle = "编辑";
  149. this.businessKey = record.id;
  150. this.showModal = true;
  151. },
  152. handleDelete(record) {
  153. var self = this;
  154. self
  155. .$confirm("是否确认删除?", "提示", {
  156. confirmButtonText: "确定",
  157. cancelButtonText: "取消",
  158. type: "warning"
  159. })
  160. .then(() => {
  161. holidayInfoApi.remove(record.id).then(function(response) {
  162. var jsonData = response.data;
  163. if (jsonData.result) {
  164. // var index = self.tableData.indexOf(record);
  165. // self.tableData.splice(index, 1);
  166. self.changePage(self.pageIndex);
  167. self.$message({
  168. type: "success",
  169. message: "删除成功!"
  170. });
  171. }
  172. });
  173. });
  174. },
  175. handleBatchDelete() {
  176. var self = this;
  177. var idList = this.multipleSelection.map(record => {
  178. return record.id;
  179. });
  180. this.$confirm("是否确认删除选中项?", "提示", {
  181. confirmButtonText: "确定",
  182. cancelButtonText: "取消",
  183. type: "warning"
  184. }).then(() => {
  185. holidayInfoApi.batchRemove(idList).then(function(response) {
  186. var jsonData = response.data;
  187. if (jsonData.result) {
  188. self.changePage(self.pageIndex);
  189. self.$message({
  190. type: "success",
  191. message: "删除成功!"
  192. });
  193. }
  194. });
  195. });
  196. },
  197. onDetailModalClose(refreshed) {
  198. //保存成功后回调
  199. this.showModal = false;
  200. if (refreshed) {
  201. this.changePage(this.pageIndex);
  202. }
  203. }
  204. },
  205. mounted: function() {
  206. var self = this;
  207. this.changePage(1);
  208. companyInfoApi.list().then(function(response) {
  209. var jsonData = response.data;
  210. if (jsonData.result) {
  211. self.companyResult = jsonData.data;
  212. }
  213. });
  214. },
  215. components: {
  216. "holidayInfo-detail": holidayInfoDetail
  217. }
  218. };
  219. </script>
  220. <style lang="scss" scoped>
  221. .el-breadcrumb {
  222. margin: 10px;
  223. line-height: 20px;
  224. }
  225. .el-divider {
  226. margin: 5px 0;
  227. }
  228. .demo-form-inline {
  229. margin-left: 10px;
  230. text-align: left;
  231. }
  232. .button-group {
  233. margin-left: 10px;
  234. text-align: left;
  235. }
  236. </style>