index.vue 6.0 KB

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