index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div>
  3. <basic-container class="page-crad">
  4. <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
  5. :cell-style="cellStyle" @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  6. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  7. @resetColumn="resetColumn" @search-criteria-switch="searchCriteriaSwitch">
  8. <template slot="menuLeft">
  9. <el-button type="info" size="small" @click="outExport">导出
  10. </el-button>
  11. </template>
  12. <template slot="businesDateSearch">
  13. <el-date-picker v-model="search.businesDate" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
  14. format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']">
  15. </el-date-picker>
  16. </template>
  17. </avue-crud>
  18. </basic-container>
  19. </div>
  20. </template>
  21. <script>
  22. import { getToken } from "@/util/auth";
  23. import { getList } from "@/api/statisticAnalysis/brandProfit"
  24. import { gainUser } from "@/api/basicData/customerInquiry";
  25. export default {
  26. name: "index",
  27. data() {
  28. return {
  29. UConfiguration: {
  30. multipleChoices: false,
  31. multiple: false,
  32. disabled: false,
  33. searchShow: true,
  34. collapseTags: false,
  35. placeholder: '请点击右边按钮选择',
  36. dicData: []
  37. },
  38. form: {},
  39. search: {},
  40. dataList: [],
  41. loading: false,
  42. detailData: {},
  43. page: {
  44. pageSize: 20,
  45. currentPage: 1,
  46. total: 0,
  47. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  48. },
  49. option: {},
  50. optionBack: {
  51. align: "center",
  52. searchShow: true,
  53. searchMenuPosition: "right",
  54. searchSpan: 8,
  55. searchMenuSpan: 8,
  56. border: true,
  57. index: true,
  58. addBtn: false,
  59. viewBtn: false,
  60. editBtn: false,
  61. delBtn: false,
  62. searchIcon: true,
  63. menu: false,
  64. showSummary: true,
  65. sumColumnList: [
  66. {
  67. name: "quantity",
  68. type: "sum"
  69. },
  70. {
  71. name: "grossProfit",
  72. type: "sum"
  73. },
  74. {
  75. name: "amount",
  76. type: "sum"
  77. },
  78. {
  79. name: "thisUsedProfit",
  80. type: "sum"
  81. },
  82. {
  83. name: "grossProfit",
  84. type: "sum"
  85. },
  86. {
  87. name: "predictOceanFreight",
  88. type: "sum"
  89. },
  90. {
  91. name: "netGrossProfit",
  92. type: "sum"
  93. },
  94. {
  95. name: "grossProfitRate",
  96. type: "sum"
  97. }
  98. ],
  99. column: [
  100. {
  101. label: "业务日期",
  102. prop: "date",
  103. type: "date",
  104. format: 'yyyy-MM-dd',
  105. valueFormat: 'yyyy-MM-dd',
  106. searchRange: true,
  107. overHidden: true,
  108. hide: true,
  109. showColumn: false,
  110. search: true,
  111. },
  112. {
  113. label: "品牌",
  114. prop: "brand",
  115. filterable: true,
  116. multiple: true,
  117. type: "select",
  118. props: {
  119. label: "dictValue",
  120. value: "dictValue"
  121. },
  122. dicData: [],
  123. dataType: "string",
  124. overHidden: true,
  125. search: true
  126. },
  127. {
  128. label: "销售收入",
  129. prop: "amount",
  130. overHidden: true,
  131. },
  132. {
  133. label: "销售成本",
  134. prop: "purchaseAmount",
  135. overHidden: true,
  136. },
  137. {
  138. label: "发货数量",
  139. prop: "quantity",
  140. overHidden: true,
  141. },
  142. {
  143. label: "返利",
  144. prop: "thisUsedProfit",
  145. overHidden: true,
  146. },
  147. {
  148. label: "平均单价",
  149. prop: "price",
  150. overHidden: true,
  151. },
  152. {
  153. label: "单条毛利",
  154. prop: "singleGrossProfit",
  155. overHidden: true,
  156. },
  157. {
  158. label: "订单运费",
  159. prop: "predictOceanFreight",
  160. overHidden: true,
  161. },
  162. {
  163. label: "毛利额(不含返利)",
  164. prop: "netGrossProfit",
  165. overHidden: true,
  166. },
  167. {
  168. label: "毛利额(含返利)",
  169. prop: "grossProfit",
  170. overHidden: true,
  171. },
  172. {
  173. label: "订单毛利率",
  174. prop: "grossProfitRate",
  175. overHidden: true,
  176. }
  177. ]
  178. }
  179. };
  180. },
  181. async created() {
  182. this.option = await this.getColumnData(this.getColumnName(229), this.optionBack);
  183. this.getAllWorkDicts()
  184. },
  185. methods: {
  186. getAllWorkDicts() {
  187. this.option.height = window.innerHeight - 210;
  188. this.getWorkDicts('brand').then(res => {
  189. this.findObject(this.option.column, "brand").dicData =
  190. res.data.data;
  191. })
  192. // gainUser().then(res => {
  193. // this.findObject(this.option.column, "chargeMember").dicData =
  194. // res.data.data;
  195. // })
  196. },
  197. cellStyle() {
  198. return "padding:0;height:40px;";
  199. },
  200. searchCriteriaSwitch(type) {
  201. if (type) {
  202. this.option.height = this.option.height - 46;
  203. } else {
  204. this.option.height = this.option.height + 46;
  205. }
  206. this.$refs.crud.getTableHeight();
  207. },
  208. //点击搜索按钮触发
  209. searchChange(params, done) {
  210. this.page.currentPage = 1;
  211. this.onLoad(this.page, params);
  212. done();
  213. },
  214. refreshChange() {
  215. this.onLoad(this.page, this.search);
  216. },
  217. currentChange(val) {
  218. this.page.currentPage = val;
  219. },
  220. sizeChange(val) {
  221. this.page.currentPage = 1;
  222. this.page.pageSize = val;
  223. },
  224. onLoad(page, params = {}) {
  225. let data = this.deepClone(Object.assign({}, params, this.search));
  226. if (data.date) {
  227. data.beginTime = data.date[0]
  228. data.endTime = data.date[1]
  229. delete data.date
  230. }
  231. this.loading = true;
  232. getList(
  233. page.currentPage,
  234. page.pageSize,
  235. data
  236. ).then(res => {
  237. this.dataList = res.data.data.records ? res.data.data.records : [];
  238. this.page.total = res.data.data.total;
  239. }).finally(() => {
  240. this.loading = false;
  241. });
  242. },
  243. //列保存触发
  244. async saveColumn() {
  245. const inSave = await this.saveColumnData(this.getColumnName(229), this.option);
  246. if (inSave) {
  247. this.$message.success("保存成功");
  248. //关闭窗口
  249. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  250. }
  251. },
  252. async resetColumn() {
  253. this.option = this.optionBack;
  254. const inSave = await this.delColumnData(this.getColumnName(229), this.optionBack);
  255. this.getAllWorkDicts()
  256. if (inSave) {
  257. this.$message.success("重置成功");
  258. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  259. }
  260. },
  261. editOpen(row) {
  262. },
  263. outExport() {
  264. let params = { ...this.search }
  265. if (params.date && params.date.length > 0) {
  266. params = {
  267. ...params,
  268. beginTime: params.date[0],
  269. endTime: params.date[1],
  270. }
  271. } else {
  272. params = {
  273. ...params,
  274. beginTime: '',
  275. endTime: '',
  276. }
  277. }
  278. window.open(
  279. `/api/blade-purchase-sales/exportOrder/brandProfitExport?${this.website.tokenHeader
  280. }=${getToken()}&beginTime=${params.beginTime}&endTime=${params.endTime}&brand=${params.brand? params.brand : ''}`
  281. );
  282. }
  283. }
  284. };
  285. </script>
  286. <style scoped>
  287. .page-crad ::v-deep .basic-container__card {
  288. height: 94.2vh;
  289. }
  290. ::v-deep .el-table__expanded-cell[class*="cell"] {
  291. padding: 0px;
  292. }
  293. .itemTable ::v-deep .el-table {
  294. width: 100%;
  295. }
  296. </style>