index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. :before-open="beforeOpen"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. @resetColumn="resetColumn"
  19. :cell-style="cellStyle"
  20. >
  21. <template slot-scope="{ row }" slot="updateUser">
  22. <span>{{ row.updateUserName }}</span>
  23. </template>
  24. <template slot-scope="{ row, index }" slot="menu">
  25. <el-button type="text" size="small" @click.stop="editOpen(row, 1)">
  26. 查看
  27. </el-button>
  28. <el-button type="text" size="small" @click.stop="editOpen(row, 2)">
  29. 编辑
  30. </el-button>
  31. <el-button type="text" size="small" @click.stop="rowDel(row, index)">
  32. 删除
  33. </el-button>
  34. </template>
  35. </avue-crud>
  36. </basic-container>
  37. <detailPage
  38. v-else
  39. ref="detail"
  40. @goBack="goBack"
  41. :detailData="detailData"
  42. ></detailPage>
  43. </div>
  44. </template>
  45. <script>
  46. import detailPage from "./detailsPage";
  47. import { getList, remove } from "@/api/salaryManagement/primarySchool";
  48. export default {
  49. name: "index",
  50. components: {
  51. detailPage
  52. },
  53. data() {
  54. return {
  55. form: {},
  56. dataList: [],
  57. loading: false,
  58. isShow: true,
  59. detailData: {},
  60. page: {
  61. pageSize: 10,
  62. currentPage: 1
  63. },
  64. option: {
  65. searchShow: true,
  66. searchMenuSpan: 16,
  67. align: "center",
  68. searchSpan: 8,
  69. border: true,
  70. index: true,
  71. viewBtn: false,
  72. editBtn: false,
  73. delBtn: false,
  74. menuWidth: 120,
  75. searchIcon: true,
  76. searchIndex: 2,
  77. addBtnText: "新单",
  78. column: [
  79. {
  80. label: "年",
  81. prop: "annual",
  82. type: "year",
  83. valueFormat: "yyyy",
  84. overHidden: true,
  85. width: 100,
  86. search: true
  87. },
  88. {
  89. label: "月",
  90. prop: "moon",
  91. type: "select",
  92. filterable: true,
  93. dicUrl: "/api/blade-system/dict-biz/dictionary?code=month",
  94. props: {
  95. label: "dictValue",
  96. value: "dictKey"
  97. },
  98. overHidden: true,
  99. width: 100,
  100. search: true
  101. },
  102. {
  103. label: "制单人",
  104. prop: "createUser",
  105. type: "select",
  106. filterable: true,
  107. dicUrl: "/api/blade-user/client/gainUser",
  108. props: {
  109. label: "name",
  110. value: "id"
  111. },
  112. overHidden: true,
  113. width: 100,
  114. search: true
  115. },
  116. {
  117. label: "制单日期",
  118. prop: "createTime",
  119. type: "date",
  120. overHidden: true,
  121. width: 200
  122. },
  123. {
  124. label: "更新人",
  125. prop: "updateUser",
  126. overHidden: true,
  127. width: 100
  128. },
  129. {
  130. label: "更新日期",
  131. prop: "updateTime",
  132. type: "date",
  133. overHidden: true,
  134. width: 200
  135. },
  136. {
  137. label: "备注",
  138. prop: "remarks",
  139. overHidden: true,
  140. search: true
  141. }
  142. ]
  143. }
  144. };
  145. },
  146. methods: {
  147. cellStyle() {
  148. return "padding:0;height:40px;";
  149. },
  150. //点击搜索按钮触发
  151. searchChange(params, done) {
  152. this.page.currentPage = 1;
  153. this.onLoad(this.page, params);
  154. done();
  155. },
  156. refreshChange() {
  157. this.onLoad(this.page, this.search);
  158. },
  159. currentChange(val) {
  160. this.page.currentPage = val;
  161. },
  162. sizeChange(val) {
  163. this.page.currentPage = 1;
  164. this.page.pageSize = val;
  165. },
  166. onLoad(page, params) {
  167. this.loading = true;
  168. getList(page.currentPage, page.pageSize, params)
  169. .then(res => {
  170. this.dataList = res.data.data.records ? res.data.data.records : [];
  171. this.page.total = res.data.data.total;
  172. if (this.page.total) {
  173. this.option.height = window.innerHeight - 260;
  174. }
  175. })
  176. .finally(() => {
  177. this.loading = false;
  178. });
  179. },
  180. //新增跳转页面
  181. beforeOpen() {
  182. this.isShow = false;
  183. },
  184. editOpen(row, status) {
  185. this.detailData = {
  186. id: row.id,
  187. status: status
  188. };
  189. this.isShow = false;
  190. },
  191. rowDel(row, index, done) {
  192. this.$confirm("确定删除数据?", {
  193. confirmButtonText: "确定",
  194. cancelButtonText: "取消",
  195. type: "warning"
  196. }).then(() => {
  197. remove(row.id).then(res => {
  198. if (res.data.code == 200) {
  199. this.$message({
  200. type: "success",
  201. message: "删除成功!"
  202. });
  203. this.onLoad(this.page, this.search);
  204. }
  205. });
  206. });
  207. },
  208. goBack() {
  209. this.detailData = this.$options.data().detailData;
  210. this.isShow = true;
  211. }
  212. }
  213. };
  214. </script>
  215. <style scoped>
  216. .page-crad ::v-deep .basic-container__card {
  217. height: 94.2vh;
  218. }
  219. </style>