index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option" :data="dataList" ref="crud" v-model="form" :page.sync="page" :search.sync="search"
  4. :table-loading="loading" :span-method="spanMethod" @search-change="searchChange" @search-reset="searchReset"
  5. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  6. @refresh-change="refreshChange" @saveColumn="saveColumn" :cell-style="cellStyle" @resetColumn="resetColumn"
  7. @on-load="onLoad">
  8. <template slot="menuLeft">
  9. <el-button size="small" type="info" icon="el-icon-download" :loading="exportLoading" @click.stop="downFile">导出
  10. </el-button>
  11. </template>
  12. </avue-crud>
  13. </basic-container>
  14. </template>
  15. <script>
  16. import option from "./config/mainList.json";
  17. import { getProfitList } from "@/api/statisticAnalysis/profit";
  18. import { contrastList } from "@/util/contrastData";
  19. export default {
  20. data() {
  21. return {
  22. loading: false,
  23. exportLoading: false,
  24. form: {},
  25. search: {
  26. orderType:'棉花'
  27. },
  28. show: true,
  29. detailData: {},
  30. option: {},
  31. spanArr: [],
  32. position: 0,
  33. parentId: 0,
  34. dataList: [],
  35. page: {
  36. pageSize: 10,
  37. pagerCount: 5,
  38. total: 0,
  39. },
  40. query: {},
  41. configuration: {
  42. multipleChoices: false,
  43. multiple: false,
  44. disabled: false,
  45. searchShow: true,
  46. collapseTags: false,
  47. clearable: true,
  48. placeholder: '请点击右边按钮选择',
  49. dicData: []
  50. },
  51. }
  52. },
  53. async created() {
  54. this.option = await this.getColumnData(this.getColumnName(66), option);
  55. this.getWorkDicts("contractType").then(res => {
  56. this.findObject(this.option.column, "orderType").dicData =
  57. res.data.data;
  58. })
  59. },
  60. mounted() {
  61. },
  62. methods: {
  63. //导出
  64. downFile() {
  65. this.exportLoading = true
  66. let searchParams = Object.assign({}, this.search);
  67. let param = this.paramsAdjustment(searchParams)
  68. getProfitList(1, -1, param).then(res => {
  69. const fileData = this.deepClone(res.data.data.records)
  70. option.column.shift();
  71. option.column.shift();
  72. this.$Export.excel({
  73. title: "利润分析",
  74. columns: option.column,
  75. data: fileData,
  76. });
  77. }).finally(() => {
  78. this.exportLoading = false
  79. })
  80. },
  81. addReceipt() {
  82. console.log('1')
  83. },
  84. editOpen() {
  85. console.log('1')
  86. },
  87. rowspan() {
  88. //记录原始
  89. let oldList = [this.dataList[0].corpName, this.dataList[0].orderNo, this.dataList[0].invoiceWeight, this.dataList[0].customDutyMoney,
  90. this.dataList[0].gstMoney, this.dataList[0].quotaMoney, this.dataList[0].itemMoney, this.dataList[0].unitPrice]
  91. this.dataList.forEach((item, index) => {
  92. let newList = [item.corpName, item.orderNo, item.invoiceWeight, item.customDutyMoney, item.gstMoney, item.quotaMoney, item.itemMoney, item.unitPrice]
  93. if (index === 0) {
  94. this.spanArr.push(1)
  95. this.position = 0;
  96. } else {
  97. //如果循环数据与原始数据相等 那么合并
  98. if (!contrastList(oldList, newList)) {
  99. this.spanArr[this.position] += 1;
  100. this.spanArr.push(0)
  101. } else {
  102. //如果不等 更新原始数据 循环在比较
  103. oldList = newList
  104. this.spanArr.push(1)
  105. this.position = index
  106. }
  107. }
  108. })
  109. },
  110. spanMethod({ row, column, rowIndex, columnIndex }) {
  111. if (column.property === "corpName" || column.property === "orderNo" || column.property === "invoiceWeight" || column.property === "customDutyMoney" ||
  112. column.property === "gstMoney" || column.property === "quotaMoney" || column.property === "itemMoney" || column.property === "unitPrice") {
  113. const _row = this.spanArr[rowIndex];
  114. const _col = _row > 0 ? 1 : 0;
  115. return {
  116. rowspan: _row,
  117. colspan: _col
  118. }
  119. }
  120. },
  121. //点击搜索按钮触发
  122. searchChange(params, done) {
  123. this.query = params;
  124. this.page.currentPage = 1;
  125. this.onLoad(this.page, params);
  126. done()
  127. },
  128. searchReset() {
  129. console.log('1')
  130. },
  131. selectionChange() {
  132. console.log('1')
  133. },
  134. currentChange(val) {
  135. this.page.currentPage = val
  136. },
  137. sizeChange() {
  138. console.log('1')
  139. },
  140. refreshChange() {
  141. this.onLoad(this.page);
  142. },
  143. paramsAdjustment(params) {
  144. params = Object.assign({}, this.search);
  145. if (params.createTime && params.createTime.length !== 0) { //发货
  146. params.startTime = params.createTime[0] + " " + "00:00:00";
  147. params.endTime = params.createTime[1] + " " + "23:59:59";
  148. this.$delete(params, 'createTime')
  149. }
  150. return params
  151. },
  152. onLoad(page, params) {
  153. this.loading = true;
  154. params = this.paramsAdjustment(params)
  155. getProfitList(page.currentPage, page.pageSize, params).then(res => {
  156. this.dataList = res.data.data.records
  157. this.page.total = res.data.data.total
  158. if (this.page.total || this.page.total === 0) {
  159. this.option.height = window.innerHeight - 230;
  160. }
  161. this.rowspan()
  162. }).finally(() => {
  163. this.loading = false;
  164. })
  165. },
  166. cellStyle() {
  167. return "padding:0;height:40px;";
  168. },
  169. //列保存触发
  170. async saveColumn() {
  171. const inSave = await this.saveColumnData(
  172. this.getColumnName(66),
  173. this.option
  174. );
  175. if (inSave) {
  176. this.$message.success("保存成功");
  177. //关闭窗口
  178. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  179. }
  180. },
  181. async resetColumn() {
  182. const inSave = await this.delColumnData(
  183. this.getColumnName(66),
  184. option
  185. );
  186. if (inSave) {
  187. this.$message.success("重置成功");
  188. this.option = option;
  189. //关闭窗口
  190. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  191. }
  192. },
  193. }
  194. }
  195. </script>
  196. <style scoped>
  197. </style>