index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
  5. @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  6. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  7. @resetColumn="resetColumn" :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
  8. <template slot="menuLeft">
  9. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="newAdd()">新增
  10. </el-button>
  11. </template>
  12. <template slot-scope="{ row,index}" slot="billNo">
  13. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.billNo }}</span>
  14. </template>
  15. <template slot-scope="{ row,index}" slot="corpId">
  16. <span>{{ row.corpName }}</span>
  17. </template>
  18. <template slot-scope="{ row, index }" slot="menu">
  19. <el-button type="text" size="small" @click.stop="rowDel(row, index)">
  20. 删除
  21. </el-button>
  22. </template>
  23. </avue-crud>
  24. </basic-container>
  25. <details-page v-if="!show" @goBack="backToList" :detailData="detailData" />
  26. </div>
  27. </template>
  28. <script>
  29. import detailsPage from "./detailsPage";
  30. import { option } from "./js/optionList";
  31. import { getList, remove } from "@/api/basicData/agreement";
  32. export default {
  33. name: "index",
  34. data() {
  35. return {
  36. show: true,
  37. loading: false,
  38. form: {},
  39. search: {},
  40. detailData: {},
  41. dataList: [],
  42. selectionList: [],
  43. page: {
  44. pageSize: 10,
  45. currentPage: 1,
  46. total: 0,
  47. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  48. },
  49. option: {},
  50. };
  51. },
  52. components: {
  53. detailsPage
  54. },
  55. async created() {
  56. this.option = await this.getColumnData(this.getColumnName(192), option);
  57. this.getWorkDicts("in_section").then(res => {
  58. this.findObject(this.option.column, "inSection").dicData = res.data.data;
  59. this.$refs.crud.init();
  60. });
  61. this.option.height = window.innerHeight - 210;
  62. },
  63. methods: {
  64. searchCriteriaSwitch(type) {
  65. if (type) {
  66. this.option.height = this.option.height - 46;
  67. } else {
  68. this.option.height = this.option.height + 46;
  69. }
  70. this.$refs.crud.getTableHeight();
  71. },
  72. cellStyle() {
  73. return "padding:0;height:40px;";
  74. },
  75. //点击搜索按钮触发
  76. searchChange(params, done) {
  77. this.page.currentPage = 1;
  78. this.onLoad(this.page, params);
  79. done();
  80. },
  81. refreshChange() {
  82. this.onLoad(this.page, this.search);
  83. },
  84. newAdd() {
  85. this.show = false;
  86. },
  87. onLoad(page, params = {}) {
  88. this.loading = true;
  89. this.dataList.forEach(item => {
  90. this.$refs.crud.toggleRowExpansion(item, false);
  91. });
  92. getList(
  93. page.currentPage,
  94. page.pageSize,
  95. Object.assign(params, this.search)
  96. )
  97. .then(res => {
  98. if (res.data.data.records) {
  99. res.data.data.records.forEach(e => {
  100. e.itemLoading = true;
  101. });
  102. }
  103. this.dataList = res.data.data.records ? res.data.data.records : [];
  104. this.page.total = res.data.data.total;
  105. })
  106. .finally(() => {
  107. this.loading = false;
  108. });
  109. },
  110. editOpen(row, status) {
  111. this.detailData = {
  112. id: row.id,
  113. status: status
  114. };
  115. this.show = false;
  116. },
  117. currentChange(val) {
  118. this.page.currentPage = val;
  119. },
  120. sizeChange(val) {
  121. this.page.currentPage = 1;
  122. this.page.pageSize = val;
  123. },
  124. rowDel(row, index, done) {
  125. this.$confirm("确定删除数据?", {
  126. confirmButtonText: "确定",
  127. cancelButtonText: "取消",
  128. type: "warning"
  129. }).then(() => {
  130. remove(row.id).then(res => {
  131. if (res.data.code == 200) {
  132. this.$message({
  133. type: "success",
  134. message: "删除成功!"
  135. });
  136. this.onLoad(this.page, this.search);
  137. }
  138. });
  139. });
  140. },
  141. async saveColumn() {
  142. const inSave = await this.saveColumnData(
  143. this.getColumnName(192),
  144. this.option
  145. );
  146. if (inSave) {
  147. this.$nextTick(() => {
  148. this.$refs.crud.doLayout();
  149. });
  150. this.$message.success("保存成功");
  151. //关闭窗口
  152. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  153. }
  154. },
  155. async resetColumn() {
  156. this.option = option;
  157. const inSave = await this.delColumnData(this.getColumnName(192), option);
  158. if (inSave) {
  159. this.$nextTick(() => {
  160. this.$refs.crud.doLayout();
  161. });
  162. this.$message.success("重置成功");
  163. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  164. }
  165. },
  166. //返回列表
  167. backToList() {
  168. this.detailData = this.$options.data().detailData;
  169. this.show = true;
  170. this.onLoad(this.page, this.search);
  171. }
  172. }
  173. };
  174. </script>
  175. <style scoped>
  176. .page-crad ::v-deep .basic-container__card {
  177. height: 94.2vh;
  178. }
  179. </style>