index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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="sysNo">
  13. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 1)">{{ row.sysNo }}</span>
  14. </template>
  15. <template slot-scope="{ row,index}" slot="corpId">
  16. <span>{{ row.corpName }}</span>
  17. </template>
  18. <template slot="corpIdSearch">
  19. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  20. </template>
  21. <!-- <template slot="financingDateSearch">
  22. <el-date-picker v-model="search.financingDate" type="daterange" start-placeholder="开始日期"
  23. end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
  24. </el-date-picker>
  25. </template> -->
  26. <template slot-scope="{ row, index }" slot="menu">
  27. <el-button type="text" size="small" :disabled="row.status>0" @click.stop="rowDel(row, index)">
  28. 删除
  29. </el-button>
  30. </template>
  31. </avue-crud>
  32. </basic-container>
  33. <details-page v-if="!show" @goBack="backToList" :detailData="detailData" />
  34. </div>
  35. </template>
  36. <script>
  37. import detailsPage from "./detailsPage";
  38. import { option } from "./js/optionList";
  39. import { getList, remove } from "@/api/basicData/financing";
  40. export default {
  41. name: "index",
  42. data() {
  43. return {
  44. show: true,
  45. loading: false,
  46. form: {},
  47. search: {},
  48. detailData: {},
  49. dataList: [],
  50. selectionList: [],
  51. page: {
  52. pageSize: 10,
  53. currentPage: 1,
  54. total: 0,
  55. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  56. },
  57. option: {},
  58. };
  59. },
  60. components: {
  61. detailsPage
  62. },
  63. async created() {
  64. this.option = await this.getColumnData(this.getColumnName(198), option);
  65. this.getWorkDicts("approval_status").then(res => {
  66. this.findObject(this.option.column, "status").dicData =
  67. res.data.data;
  68. });
  69. this.getWorkDicts("financing_type").then(res => {
  70. this.findObject(this.option.column, "financingType").dicData =
  71. res.data.data;
  72. });
  73. this.option.height = window.innerHeight - 210;
  74. },
  75. activated() {
  76. setTimeout(() => {
  77. if (this.$route.query.check && this.show) {
  78. console.log(this.$route.query.check)
  79. // this.detailData = {
  80. // id: this.$route.query.check
  81. // }
  82. this.editOpen(this.$route.query.check.srcBillId,1)
  83. this.show = false;
  84. }
  85. }, 100);
  86. },
  87. methods: {
  88. searchCriteriaSwitch(type) {
  89. if (type) {
  90. this.option.height = this.option.height - 46;
  91. } else {
  92. this.option.height = this.option.height + 46;
  93. }
  94. this.$refs.crud.getTableHeight();
  95. },
  96. cellStyle() {
  97. return "padding:0;height:40px;";
  98. },
  99. //点击搜索按钮触发
  100. searchChange(params, done) {
  101. this.page.currentPage = 1;
  102. this.onLoad(this.page, params);
  103. done();
  104. },
  105. refreshChange() {
  106. this.onLoad(this.page, this.search);
  107. },
  108. newAdd() {
  109. this.show = false;
  110. },
  111. onLoad(page, params = {}) {
  112. this.loading = true;
  113. this.dataList.forEach(item => {
  114. this.$refs.crud.toggleRowExpansion(item, false);
  115. });
  116. getList(
  117. page.currentPage,
  118. page.pageSize,
  119. Object.assign(params, this.search)
  120. )
  121. .then(res => {
  122. this.dataList = res.data.data.records ? res.data.data.records : [];
  123. this.page.total = res.data.data.total;
  124. })
  125. .finally(() => {
  126. this.loading = false;
  127. });
  128. },
  129. editOpen(row, status) {
  130. this.detailData = {
  131. id: row.id,
  132. status: status
  133. };
  134. this.show = false;
  135. },
  136. currentChange(val) {
  137. this.page.currentPage = val;
  138. },
  139. sizeChange(val) {
  140. this.page.currentPage = 1;
  141. this.page.pageSize = val;
  142. },
  143. rowDel(row, index, done) {
  144. this.$confirm("确定删除数据?", {
  145. confirmButtonText: "确定",
  146. cancelButtonText: "取消",
  147. type: "warning"
  148. }).then(() => {
  149. remove(row.id).then(res => {
  150. if (res.data.code == 200) {
  151. this.$message({
  152. type: "success",
  153. message: "删除成功!"
  154. });
  155. this.onLoad(this.page, this.search);
  156. }
  157. });
  158. });
  159. },
  160. async saveColumn() {
  161. const inSave = await this.saveColumnData(
  162. this.getColumnName(198),
  163. this.option
  164. );
  165. if (inSave) {
  166. this.$nextTick(() => {
  167. this.$refs.crud.doLayout();
  168. });
  169. this.$message.success("保存成功");
  170. //关闭窗口
  171. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  172. }
  173. },
  174. async resetColumn() {
  175. this.option = option;
  176. const inSave = await this.delColumnData(this.getColumnName(198), option);
  177. if (inSave) {
  178. this.$nextTick(() => {
  179. this.$refs.crud.doLayout();
  180. });
  181. this.$message.success("重置成功");
  182. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  183. }
  184. },
  185. //返回列表
  186. backToList() {
  187. this.detailData = this.$options.data().detailData;
  188. this.show = true;
  189. this.onLoad(this.page, this.search);
  190. }
  191. }
  192. };
  193. </script>
  194. <style scoped>
  195. .page-crad ::v-deep .basic-container__card {
  196. height: 94.2vh;
  197. }
  198. </style>