index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
  5. id="out-table" :header-cell-class-name="headerClassName" ref="crud" @row-del="rowDel"
  6. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  7. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  8. @resetColumn="resetColumn('crud', 'option', 'optionBack', 68)"
  9. @saveColumn="saveColumn('crud', 'option', 'optionBack', 68)" @on-load="onLoad">
  10. <template slot="menu" slot-scope="{ row, index }">
  11. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">编辑</el-button>
  12. </template>
  13. <template slot="cname" slot-scope="{ row }">
  14. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{ row.cname }}</span>
  15. </template>
  16. </avue-crud>
  17. </basic-container>
  18. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  19. </div>
  20. </template>
  21. <script>
  22. import { customerList } from "@/api/basicData/customerInformation";
  23. import detailsPage from "./detailsPage";
  24. export default {
  25. data() {
  26. return {
  27. detailData: {},
  28. isShow: true,
  29. query: {},
  30. loading: false,
  31. page: {
  32. pageSize: 10,
  33. currentPage: 1,
  34. total: 0
  35. },
  36. option: {},
  37. optionBack: {
  38. height: 'auto',
  39. calcHeight: 30,
  40. menuWidth: 140,
  41. tip: false,
  42. searchShow: true,
  43. searchMenuSpan: 12,
  44. border: true,
  45. index: true,
  46. addBtn: false,
  47. viewBtn: false,
  48. editBtn: false,
  49. delBtn: false,
  50. searchIcon: true,
  51. align: 'center',
  52. searchIndex: 3,
  53. column: [
  54. {
  55. label: "编码",
  56. prop: "code",
  57. search: true,
  58. searchOrder: 1,
  59. overHidden: true,
  60. },
  61. {
  62. label: "客户",
  63. prop: "cname",
  64. search: true,
  65. searchOrder: 2,
  66. overHidden: true,
  67. },
  68. {
  69. label: "总返利",
  70. prop: "profitReturn",
  71. overHidden: true,
  72. },
  73. {
  74. label: "已用返利",
  75. prop: "usedProfit",
  76. overHidden: true,
  77. },
  78. {
  79. label: "可用返利",
  80. prop: "surplusProfit",
  81. overHidden: true,
  82. },
  83. {
  84. label: "本月待到账",
  85. prop: "monthProfit",
  86. overHidden: true,
  87. },
  88. {
  89. label: "创建人",
  90. prop: "createName",
  91. overHidden: true,
  92. },
  93. {
  94. label: "创建时间",
  95. prop: "createTime",
  96. overHidden: true,
  97. }
  98. ]
  99. },
  100. data: [],
  101. };
  102. },
  103. components: {
  104. detailsPage
  105. },
  106. async created() {
  107. this.option = await this.getColumnData(this.getColumnName(68), this.optionBack);
  108. },
  109. methods: {
  110. rowEdit(row) {
  111. this.detailData = {
  112. id: row.id
  113. };
  114. this.isShow = false
  115. },
  116. searchReset() {
  117. this.query = this.$options.data().query;
  118. this.onLoad(this.page);
  119. },
  120. // 搜索按钮点击
  121. searchChange(params, done) {
  122. this.page.currentPage = 1;
  123. this.onLoad(this.page, this.query);
  124. done();
  125. },
  126. currentChange(currentPage) {
  127. this.page.currentPage = currentPage;
  128. },
  129. sizeChange(pageSize) {
  130. this.page.pageSize = pageSize;
  131. },
  132. refreshChange() {
  133. this.onLoad(this.page, this.query);
  134. },
  135. onLoad(page, params = {}) {
  136. let obj = {}
  137. obj = {
  138. size:this.page.pageSize,
  139. current:this.page.currentPage,
  140. ...Object.assign(params, this.query),
  141. }
  142. this.loading = true;
  143. customerList(obj).then(res => {
  144. this.data = res.data.data.records;
  145. this.page.total = res.data.data.total;
  146. this.$nextTick(() => {
  147. this.$refs.crud.doLayout();
  148. this.$refs.crud.dicInit();
  149. });
  150. }).finally(() => {
  151. this.loading = false;
  152. })
  153. },
  154. // 详情的返回列表
  155. goBack() {
  156. this.detailData = {}
  157. this.isShow = true;
  158. this.onLoad(this.page, this.query);
  159. },
  160. //自定义列保存
  161. async saveColumn(ref, option, optionBack, code) {
  162. /**
  163. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  164. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  165. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  166. */
  167. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  168. if (inSave) {
  169. this.$message.success("保存成功");
  170. //关闭窗口
  171. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  172. this.searchReset()
  173. }
  174. },
  175. //自定义列重置
  176. async resetColumn(ref, option, optionBack, code) {
  177. this[option] = this[optionBack];
  178. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  179. if (inSave) {
  180. this.$message.success("重置成功");
  181. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  182. this.searchReset()
  183. }
  184. },
  185. // 更改表格颜色
  186. headerClassName(tab) {
  187. //颜色间隔
  188. let back = ""
  189. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  190. if (tab.columnIndex % 2 === 0) {
  191. back = "back-one"
  192. } else if (tab.columnIndex % 2 === 1) {
  193. back = "back-two"
  194. }
  195. }
  196. return back;
  197. },
  198. }
  199. }
  200. </script>
  201. <style scoped>
  202. ::v-deep#out-table .back-one {
  203. background: #ecf5ff !important;
  204. text-align: center;
  205. }
  206. ::v-deep#out-table .back-two {
  207. background: #ecf5ff !important;
  208. text-align: center;
  209. }
  210. .pointerClick {
  211. cursor: pointer;
  212. color: #1e9fff;
  213. }
  214. ::v-deep .el-col-md-8 {
  215. width: 24.33333%;
  216. }
  217. </style>