index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud :option="option" :data="dataList" ref="crud" v-model="form" :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" @expand-change="expandChange" @row-update="rowUpdate">
  8. <template slot-scope="{row,index}" slot="expand">
  9. <avue-crud :data="row.insideList" :option="expandOption">
  10. <template slot="headerSerial">
  11. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow(row)" circle>
  12. </el-button>
  13. </template>
  14. <template slot="menu" slot-scope="{row,index}">
  15. <el-button size="small" icon="el-icon-edit" type="text" @click.stop="rowCell(row)">
  16. {{ row.$cellEdit ?
  17. "保存" :
  18. "修改"
  19. }}</el-button>
  20. </template>
  21. </avue-crud>
  22. <!-- <el-table :data="scope.row.insideList" v-loading="scope.row.loading">
  23. <el-table-column label="订单号" prop="orderNo" align="center" show-overflow-tooltip width="200"></el-table-column>
  24. <el-table-column label="变动总返利" prop="changeProfitReturn" align="center" show-overflow-tooltip width="200"></el-table-column>
  25. <el-table-column label="变动已用返利" prop="changeUsedProfit" align="center" show-overflow-tooltip width="200">
  26. </el-table-column>
  27. <el-table-column label="变动可用返利" prop="changeSurplusProfit" align="center" show-overflow-tooltip width="200"></el-table-column>
  28. <el-table-column label="变动本月待到账返利" prop="changeMonthProfit" align="center" show-overflow-tooltip width="200"></el-table-column>
  29. <el-table-column label="变动时间" prop="createTime" align="center" show-overflow-tooltip width="200"></el-table-column>
  30. </el-table> -->
  31. <!-- <el-pagination
  32. :total="page.total"
  33. small
  34. hide-on-single-page
  35. @size-change="insideSizeChange"
  36. @current-change="insideCurrentChange"
  37. ></el-pagination> -->
  38. </template>
  39. <template slot="corpIdSearch">
  40. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  41. </template>
  42. <template slot-scope="scope" slot="corpId">
  43. {{ scope.row.corpName }}
  44. </template>
  45. <template slot-scope="{ row, index }" slot="profitReturn">
  46. <el-input v-if="row.$cellEdit" v-model="row.profitReturn" placeholder="请输入" size="small"
  47. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  48. @change="profitChange(row)"></el-input>
  49. <span v-else>{{ row.profitReturn }}</span>
  50. </template>
  51. </avue-crud>
  52. </basic-container>
  53. </div>
  54. </template>
  55. <script>
  56. import option from './config/mainList.json';
  57. import { customerList, getRebateDetail } from "@/api/basicData/customerInformation";
  58. import { typeSave } from "@/api/basicData/customerInformation";
  59. export default {
  60. name: "index",
  61. data() {
  62. return {
  63. option: {},
  64. dataList: [],
  65. form: {},
  66. page: {
  67. pageSize: 10,
  68. pagerCount: 5,
  69. total: 0,
  70. },
  71. search: {},
  72. loading: false,
  73. saveProfit: 0,
  74. insidePage: {
  75. total: 0,
  76. size: 10,
  77. current: 1,
  78. },
  79. expandOption: {
  80. border: true,
  81. align: 'center',
  82. menuAlign: 'center',
  83. header: false,
  84. index: true,
  85. editBtn: false,
  86. delBtn: false,
  87. menuWidth: "80",
  88. dialogClickModal: false,
  89. indexSlot: true,
  90. column: [
  91. {
  92. label: '订单号',
  93. prop: 'orderNo',
  94. width: 100,
  95. overHidden: true
  96. }, {
  97. label: '变动总返利',
  98. prop: 'changeProfitReturn',
  99. overHidden: true,
  100. width: 120,
  101. cell: true
  102. }, {
  103. label: '变动已用返利',
  104. prop: 'changeUsedProfit',
  105. width: 120,
  106. overHidden: true
  107. }, {
  108. label: '变动可用返利',
  109. prop: 'changeSurplusProfit',
  110. width: 120,
  111. overHidden: true
  112. }, {
  113. label: '变动本月待到账返利',
  114. prop: 'changeMonthProfit',
  115. width: 160,
  116. overHidden: true
  117. }, {
  118. label: '变动时间',
  119. prop: 'createTime',
  120. width: 120,
  121. overHidden: true
  122. }
  123. ]
  124. },
  125. }
  126. },
  127. async created() {
  128. // this.option = option
  129. this.option = await this.getColumnData(this.getColumnName(68), option);
  130. let i = 0;
  131. this.option.column.forEach(item => {
  132. if (item.search) i++
  133. })
  134. if (i % 3 !== 0) {
  135. const num = 3 - Number(i % 3)
  136. this.option.searchMenuSpan = num * 8;
  137. this.option.searchMenuPosition = "right";
  138. }
  139. },
  140. methods: {
  141. searchChange(params, done) {
  142. this.onLoad(this.page, params);
  143. done();
  144. },
  145. currentChange(val) {
  146. this.page.currentPage = val;
  147. },
  148. sizeChange(val) {
  149. this.page.currentPage = 1;
  150. this.page.pageSize = val;
  151. },
  152. refreshChange() {
  153. this.dataList.forEach(item => {
  154. this.$refs.crud.toggleRowExpansion(item, false)
  155. })
  156. this.page.currentPage = 1;
  157. this.onLoad(this.page, this.search);
  158. },
  159. onLoad(page, params = { parentId: 0 }) {
  160. this.dataList.forEach(item => {
  161. this.$refs.crud.toggleRowExpansion(item, false)
  162. })
  163. let queryParams = Object.assign({}, params, {
  164. size: page.pageSize,
  165. current: page.currentPage,
  166. corpsTypeId: '',
  167. corpType: 'KH'
  168. });
  169. this.loading = true;
  170. customerList(queryParams).then(res => {
  171. this.dataList = res.data.data.records;
  172. this.page.total = res.data.data.total;
  173. if (this.page.total) {
  174. this.option.height = window.innerHeight - 240;
  175. }
  176. this.dataList.forEach(item => {
  177. this.$set(item, 'insideList', [])
  178. this.$set(item, 'loading', true)
  179. })
  180. }).finally(() => {
  181. this.loading = false;
  182. });
  183. },
  184. async saveColumn() {
  185. const inSave = await this.saveColumnData(
  186. this.getColumnName(68),
  187. this.option
  188. );
  189. if (inSave) {
  190. this.$message.success("保存成功");
  191. //关闭窗口
  192. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  193. }
  194. },
  195. async resetColumn() {
  196. this.option = option;
  197. const inSave = await this.delColumnData(
  198. this.getColumnName(68),
  199. option
  200. );
  201. if (inSave) {
  202. this.$message.success("重置成功");
  203. //关闭窗口
  204. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  205. }
  206. },
  207. //编辑
  208. rowCell(row) {
  209. if (row.$cellEdit) {
  210. typeSave(row).then(res => {
  211. this.$message.success('保存成功')
  212. this.$set(row, "$cellEdit", false);
  213. })
  214. } else {
  215. this.$set(row, "$cellEdit", true);
  216. }
  217. },
  218. // 修改保存调用
  219. rowUpdate(row, index, done) {
  220. typeSave(row).then(res => {
  221. this.$message.success(row.id ? '修改成功' : '新增成功')
  222. })
  223. done()
  224. },
  225. profitChange(row) {
  226. if (Number(row.profitReturn) < Number(row.usedProfit)) {
  227. row.profitReturn = this.saveProfit
  228. return this.$message.error('总返利不能小于使用返利')
  229. }
  230. row.surplusProfit = (Number(row.profitReturn) - Number(row.usedProfit)).toFixed(2)
  231. },
  232. expandGetList() {
  233. // const data = {
  234. // corpId: row.id
  235. // }
  236. // getRebateDetail({corpId: row.id}).then(res => {
  237. // row.insideList = res.data.data? res.data.data.records: []
  238. // row.loading = false
  239. // })
  240. },
  241. addRow(row) {
  242. row.insideList.push({corpId:row.id,$cellEdit: true })
  243. },
  244. // 表格展开触发
  245. expandChange(row, index) {
  246. if (row.loading) {
  247. getRebateDetail({ corpId: row.id }).then(res => {
  248. row.insideList = res.data.data ? res.data.data.records : []
  249. row.loading = false
  250. })
  251. }
  252. },
  253. insideSizeChange(val) {
  254. this.insidePage.size = val
  255. },
  256. insideCurrentChange(val) {
  257. this.insidePage.current = val
  258. },
  259. },
  260. }
  261. </script>
  262. <style scoped>
  263. /deep/ .el-table__expanded-cell .el-table__header-wrapper .cell {
  264. font-size: 8px !important;
  265. }
  266. /deep/ .el-table__body-wrapper .cell {
  267. font-size: 8px;
  268. }
  269. </style>