index.vue 6.4 KB

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